Cheatsheet Make
Cheatsheet Make
To invoke GNU make type the following command line: .PHONY define targets which are not files (e.g. clean)
.DEFAULT the default target
make [-f makefile-name] [options] [targets]
.IGNORE ignore errors in prerequisites of this rule
The following file names will be searched for in the current directory automatically:
GNUMakefile, Makefile, makefile.
Variables
By default, the first target will be invoked if not target are given.
HEADER = prg.h
FILES = $(HEADER)
Rule
then $(FILES) is expanded to prg.h running make program.
target : dependency [dependency ...]
command Automatic variables
[command]
$@ the file name of the target of the rule
where target is the result of the operation, command are the recipes to execute and $< the name of the first prerequisite
dependency is the input of the operation. Beware of tabulations before commands! $^ the names of all the prerequisites
$(XD) and $(XF) can be used to extract the directory and the file part of the name corre-
Dependency between rules sponding to $X. For instance, if $@ is src/foo.c, then $(@D) is src and $(@F) is foo.c
$(if CONDITION,THEN-PART[,ELSE-PART])
$(or CONDITION1,CONDITION2[,CONDITION3...])
$(and CONDITION1,CONDITION2[,CONDITION3...])
References
[1] Free Software Foundation. GNU Make. 2014. url: http://www.gnu.org/software/make/.