René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

gmake variables

Variable assignment

deferred assignment

variable=value
variable?=value
For example, wildcard expansion does not take place in the following variable definition, the string '*.c' is assigned to c_files.
c_files = *.c
These kind of variables are also called recursively expanded variables.

immediate assignment

variable:=value
These kind of variables are also called simply expanded variables.

immediate or deferred assignment

In the following construct, it depends on the variable if the assignment is carried out immediatly or deferred.
variable+=value

define

A variable can alternatively be defined with the define directive:
define var_name 
foo
bar
baz
endef

Automatic variables

$?

All prerequisites that are newer than the target.

$^

All prerequisites.

$<

$< is the name of the first prerequisite.

$@

$@ is the automatic variable that holds the name of the target.

$*

Variables set by gmake

CURDIR ???

See also the -C option.

MAKE ???

When a makefile invokes another make (mostly in a subdirectory), this other make should be invoked with $(MAKE) so that is is executed even if the -t option, the -n option or the -q option are used.

MAKEFILE_LIST

MAKELEVEL

Used in recursivly invoked makes: 0 for the top level make, 1 for the first sub make and so on.

.VARIABLES

Other variables

VPATH

Specifies directories in which to search for prerequisites.
See also the vpath directive.

?=

VAR ?= VAL
is equal to
ifeq ($(origin VAR), undefined)
VAR = VAL
endif