GNU make的自动变量 | Windows Nmake自动变量 |
$@ The file name of the target of the rule. If the target is an archive member, then ‘$@’ is the name of the archive file. $%: The target member name, when the target is an archive member. For example, if the target is foo.a(bar.o) then ‘$%’ is bar.o and ‘$@’ is foo.a. ‘$%’ is empty when the target is not an archive member. |
$(@) Current target's full name (path, base name, extension), as currently specified. |
$$@ |
$$@ Current target's full name (path, base name, extension), as currently specified. Valid only as a dependent in a dependency. |
$* 这个变量表示目标模式中"%"及其之前的部分 (少用) |
$* Current target's path and base name except file extension. |
$? The names of all the prerequisites that are newer than the target, with spaces between them. $^ The names of all the prerequisites, with spaces between them. $| The names of all the order-only prerequisites, with spaces between them. |
$? All dependent files in the dependency with a later timestamp than the target $** All dependents of the current target. |
$< The name of the first prerequisite. If the target got its recipe from an implicit rule, this will be the first prerequisite added by the implicit rule |
$< Dependent file with a later timestamp than the current target. Valid only in commands in inference rules. |
NMAKE GNU MAKE ======= ========== !MESSAGE hello world $(info hello world) !ERROR message $(error message) !INCLUDE filename include filename $(MAKEDIR) $(CURDIR) $(@D) $(@D:\=) $(@F) $(@F) $(@B) $(basename $(@F)) $(@R) $(basename $@) $(var:find=replace) $(subst find,replace,$(var)) !IF "a" == "b" (also !=) ifeq (a, b) (also ifneq) ... ... !ELSE else ... ... !ENDIF endif !IFDE var (also !IFNDEF) ifdef var (also ifndef) ... ... !ELSE else ... ... !ENDIF endif
http://msdn.microsoft.com/en-us/library/7y32zxwh.aspx
!IF EXIST("filename") ifeq ($(wildcard filename), filename) (NOTE: Case-sensitive!) ... ... !ELSE else ... ... !ENDIF endif doit: define runit_cmd @echo <nul ...$(1), $(2), $(3),... ...%1,%2,%3,... endef << doit: @call runit.cmd x y z $(call runit_cmd, x, y, z)
Letter | Description |
---|---|
No letter |
Complete name (same as %s) |
d |
Drive |
p |
Path |
f |
File base name |
e |
File extension |
For example, if the filename is c:\prog.exe:
%s will be c:\prog.exe
%|F will be c:\prog.exe
%|dF will be c
%|pF will be c:\
%|fF will be prog
%|eF will be exe
Microsoft product | Command macro | Defined as | Options macro |
---|---|---|---|
Macro Assembler |
AS |
ml |
AFLAGS |
Basic Compiler |
BC |
bc |
BFLAGS |
C Compiler |
CC |
cl |
CFLAGS |
C++ Compiler |
CPP |
cl |
CPPFLAGS |
C++ Compiler |
CXX |
cl |
CXXFLAGS |
Resource Compiler |
RC |
rc |
RFLAGS |
AR
Archive-maintaining program; default ‘ ar’.
AS
Program for compiling assembly files; default ‘ as’.
CC
Program for compiling C programs; default ‘ cc’.
CXX
Program for compiling C++ programs; default ‘ g++’.
CPP
Program for running the C preprocessor, with results to standard output; default ‘ $(CC) -E’.
ARFLAGS
Flags to give the archive-maintaining program; default ‘ rv’.
ASFLAGS
Extra flags to give to the assembler (when explicitly invoked on a ‘ .s’ or ‘ .S’ file).
CFLAGS
Extra flags to give to the C compiler.
CXXFLAGS
Extra flags to give to the C++ compiler.
CPPFLAGS
Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers).
GFLAGS
Extra flags to give to the SCCS
get
program.
LDFLAGS
Extra flags to give to compilers when they are supposed to invoke the linker, ‘ ld’.