Solution 1: Make commands, if a shell command, must be in one line, or be on multiple lines using a backslash for line extension. So, this approach will work:
Solution 2: This approach functions with minimal echos: .PHONY: all all: ifneq ($ (wildcard ~/Dropbox/.*),) @echo “Found ~/Dropbox.”
Solution 3: Act upon the absence of a directory
You can check if a directory exists using our generic function. Let’s take a simple example where we just want to load an exceptionally large directory if it doesn’t already exist. , “”) @echo “The directory will not exist.”
Write the command line when it comes to creating a Makefile: directory if it doesn’t exist. Otherwise, no. MYREP= /home/myaccount/dev -d [ cash ( MYREP) ] || mkdir -p cash (MYDIR) Tested on Ubuntu Linux 15.10. References:
Each run in the makefile is sent to the shell separately, so the actual “” to get multiple lines is treated as a single line. Thanks a lot. Another question? 1. UNIX for beginners. FAQ Check if there is at least one file in this directory.
Each line of a valid makefile is executed in a separate commit. It means your rule here: /bin/sh -c [“if -f ./bin/status.]; bin/sh -c “fi” You can determine why you are getting this message. To make sure all lines are written in one shell, you must use backslashes for all strings, like this:
How do you check if a directory exists in a Makefile?
Check if the directory exists in the makefile. You can check if a huge directory exists with the wildcard feature.
How to test whether a directory exists inside a makefile?
I tried using it internally to run the makefile like this: bring foo.bak (assuming foo.bar exists) and see if the following error occurs: The workaround I did was to have a separate script bash where the test is actually implemented and I called the illegal program from the makefile. However, it looks very cumbersome.
Ermias is a tech writer with a passion for helping people solve Windows problems. He loves to write and share his knowledge with others in the hope that they can benefit from it. He’s been writing about technology and software since he was in college, and has been an avid Microsoft fan ever since he first used Windows 95.