Inhaltsverzeichnis

GNU Make

Manual

Anatomy of a Make Rule

target: prerequisite prerequisite prerequisite ...
    recipe

Source

Misc

Automatic variables

See Automatic-Variables

Rules for overwriting variables

  1. Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value.
  2. An explicit assignment in the makefile overrides the environment
  3. An assignment in the makefile can be overridden by the command line argument, eg make CFLAGS='-g -O' [target]

Sources: 1 2

Variable assignment

a = Peter
c =  $(a)
d := $(a)
a = Franz
 
test:
        @echo c expands to $(c) # Franz
        @echo d expands to $(d) # Peter

CFLAGS usage

If there are C compiler options that must be used for proper compilation of certain files, do not include them in CFLAGS. Users expect to be able to specify CFLAGS freely themselves. Instead, arrange to pass the necessary options to the C compiler independently of CFLAGS, by writing them explicitly in the compilation commands or by defining an implicit rule.

See also: See Command-Variables, GNU GCC

Implicit rules

Example: file.o is made automatically from file.c with a command of the form `$(CC) -c $(CPPFLAGS) $(CFLAGS)'