René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
gmake directives | ||
define
Defines a variable.
endif, anchor=>'endif')export
Exports a variable so that it can be used in a recursivly invoked make.
export var=val export var:=val export var+=val
In order to export all variables, export must be alone on a line:
export Example
A directory containing a Makefile and a sub directory (appropriatly called subdir):
C:\temp\mk>dir Volume in drive C has no label. Volume Serial Number is EC22-DD8D Directory of C:\temp\mk 12/06/2004 11:55 AM <DIR> . 12/06/2004 11:55 AM <DIR> .. 12/06/2004 11:55 AM 191 Makefile 12/06/2004 11:55 AM <DIR> subdir 1 File(s) 191 bytes
The makefile in the upper directory:
Makefile
export VAR_EXPORTED=I am exported VAR_LOCAL=I am not exported all: subdir subdir: @echo VAR_EXPORTED: $(VAR_EXPORTED) VAR_LOCAL: $(VAR_LOCAL) @$(MAKE) -C subdir @echo VAR_EXPORTED: $(VAR_EXPORTED) VAR_LOCAL: $(VAR_LOCAL) .PHONY: subdir
The makefile in the subdir directory:
subdir\Makefile
VAR_EXPORTED+=locally appended all: @echo VAR_EXPORTED: $(VAR_EXPORTED) VAR_LOCAL: $(VAR_LOCAL)
Invoking make prints:
VAR_EXPORTED: I am exported VAR_LOCAL: I am not exported mingw32-make[1]: Entering directory `C:/temp/mk/subdir' VAR_EXPORTED: I am exported locally appended VAR_LOCAL: mingw32-make[1]: Leaving directory `C:/temp/mk/subdir' VAR_EXPORTED: I am exported VAR_LOCAL: I am not exported ifdefifdef var foo bar endif
ifdef tests if a variable has a non empty has been defined. It is true even if the value of the variable is the empty string.
ifeq
ifeq is one of the four conditional directives.
ifeq (arg1, arg2) ifeq 'arg1' 'arg2' ifeq "arg1" "arg2" ifeq "arg1" 'arg2' ifeq 'arg1' "arg2"
See also Test if a variable has non empty content.
ifdef
Quite the opposite of ifdef.
ifneq, anchor=>'ifneq')
ifeq is one of the four conditional directives.
ifneq (arg1, arg2) ifneq 'arg1' 'arg2' ifneq "arg1" "arg2" ifneq "arg1" 'arg2' ifneq 'arg1' "arg2" includeinclude filename include filename1 filename2 .. filenameN include filename1 filename2 .. *glob
Includes the indictated files. Does globbing, if * is used.
If a specified does not start with slash and is not found in the current directory, the directories specified with the
-I option are searched. Then the directories
If a file cannot be found in any of these directories, a warning is issued. The warning can be supressed if the include directive is prepended with a hyphen:
-include file_needs_not_exist
sinclude is a synonym for -include.
overridevpathvpath pattern directories
Searches in directories for files that match pattern. directories can contain multiple directories, seperated by
: or space. (; on windows systems)
The wildcard is %, not *.
The following example searches in ./src for *.c files and ./header for *.h files:
vpath %.h ./header vpath %.c ./src
See also VPATH.
Conditionsconditional-directive foo bar endif conditional-directive foo bar else quak muh endif |