10.3 Variables Used by Implicit Rules(潜规则。哈哈)
The commands in built-in implicit rules make liberal use of certain predefined variables. You can alter the values of these variables in the makefile, with arguments to make
, or in the environment to alter how the implicit rules work without redefining the rules themselves. You can cancel all variables used by implicit rules with the `-R' or `--no-builtin-variables' option.
For example, the command used to compile a C source file actually says `$(CC) -c $(CFLAGS) $(CPPFLAGS)'. The default values of the variables used are `cc' and nothing, resulting in the command `cc -c'. By redefining `CC' to `ncc', you could cause `ncc' to be used for all C compilations performed by the implicit rule. By redefining `CFLAGS' to be `-g', you could pass the `-g' option to each compilation. All implicit rules that do C compilation use `$(CC)' to get the program name for the compiler and all include `$(CFLAGS)' among the arguments given to the compiler.
The variables used in implicit rules fall into two classes: those that are names of programs (like CC
) and those that contain arguments for the programs (like CFLAGS
). (The “name of a program” may also contain some command arguments, but it must start with an actual executable program name.) If a variable value contains more than one argument, separate them with spaces.
The following tables describe of some of the more commonly-used predefined variables. This list is not exhaustive, and the default values shown here may not be what are selected by make
for your environment. To see the complete list of predefined variables for your instance of GNU make
you can run `make -p' in a directory with no makefiles.
Here is a table of some of the more common variables used as names of programs in built-in rules: makefiles.
-
Archive-maintaining program; default `
ar'.
-
Program for compiling assembly files; default `
as'.
-
Program for compiling C programs; default `cc'.
-
Program for checking out files from RCS; default `
co'.
-
Program for compiling C++ programs; default `
g++'.
-
Program for extracting a file from RCS; default `
co'.
-
Program for running the C preprocessor, with results to standard output; default `
$(CC) -E'.
-
Program for compiling or preprocessing Fortran and Ratfor programs; default `
f77'.
-
Program for extracting a file from SCCS; default `
get'.
-
Program to use to turn Lex grammars into source code; default `
lex'.
-
Program to use to turn Yacc grammars into source code; default `
yacc'.
-
Program to use to run lint on source code; default `
lint'.
-
Program to use to compile Modula-2 source code; default `
m2c'.
-
Program for compiling Pascal programs; default `
pc'.
-
Program to convert a Texinfo source file into an Info file; default `
makeinfo'.
-
Program to make TeX
dvi files from TeX source; default `
tex'.
-
Program to make TeX
dvi files from Texinfo source; default `
texi2dvi'.
-
Program to translate Web into TeX; default `
weave'.
-
Program to translate C Web into TeX; default `
cweave'.
-
Program to translate Web into Pascal; default `
tangle'.
-
Program to translate C Web into C; default `
ctangle'.
- Command to remove a file; default ` rm -f'.
================================应用程序的变量==========================================================
AR
AS
CC
CO
CXX
CO
CPP
FC
GET
LEX
YACC
LINT
M2C
PC
MAKEINFO
TEX
TEXI2DVI
WEAVE
CWEAVE
TANGLE
CTANGLE
RM
=======================上面的程序的参数=================================================
Here is a table of variables whose values are additional arguments for the programs above. The default values for all of these is the empty string, unless otherwise noted.
-
Flags to give the archive-maintaining program; default `
rv'.
-
Extra flags to give to the assembler (when explicitly invoked on a `
.s' or `
.S' file).
-
Extra flags to give to the C compiler.
-
Extra flags to give to the C++ compiler.
-
Extra flags to give to the RCS
co
program.
-
Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers).
-
Extra flags to give to the Fortran compiler.
-
Extra flags to give to the SCCS
get
program.
-
Extra flags to give to compilers when they are supposed to invoke the linker, `ld'.
-
Extra flags to give to Lex.
-
Extra flags to give to Yacc.
-
Extra flags to give to the Pascal compiler.
-
Extra flags to give to the Fortran compiler for Ratfor programs.
- Extra flags to give to lint.
ARFLAGS
ASFLAGS
CFLAGS
CXXFLAGS
COFLAGS
CPPFLAGS
FFLAGS
GFLAGS
LDFLAGS
LFLAGS
YFLAGS
PFLAGS
RFLAGS
LINTFLAGS