For example: I want:
if file1 exists:
CLEAN_SRC = *.h file3
else
CLEAN_SRC =
just do @rm -f myfile. Because of the "-f" flag, "rm" will exit with 0 regardless of whether the file exists or not. Or, -rm myfile the lead dash telling make to ignore any error.
The include directive tells make to suspend reading the current makefile and read one or more other makefiles before continuing. The directive is a line in the makefile that looks like this: include filenames ... filenames can contain shell file name patterns.
A simple makefile consists of “rules” with the following shape: target … : prerequisites … recipe … … A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. A target can also be the name of an action to carry out, such as ' clean ' (see Phony Targets).
A dependency is a file that is used as input to create the target. A target often depends on several files. A command is an action that make carries out. A rule may have more than one command, each on its own line.
If file1
does not exist then $(wildcard file1)
will evaluate to an empty string.
ifeq ($(wildcard file1),) CLEAN_SRC = else CLEAN_SRC = *.h file3 endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With