Chinaunix首页 | 论坛 | 博客
  • 博客访问: 498972
  • 博文数量: 104
  • 博客积分: 3045
  • 博客等级: 少校
  • 技术积分: 1230
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-29 10:18
文章分类

全部博文(104)

文章存档

2011年(72)

2010年(1)

2009年(1)

2008年(30)

分类: LINUX

2008-10-08 16:32:18

make's Built-in Rules

make comes equipped with a long list of built-in defaults to make your job easier. You are free to override any of them in your Makefile. The defaults fall roughly into four categories:
  1. macros that reflect your current environment variables

2) macros that define standard compilers and options

3) suffix rules for finding required files when building targets

4) a list of known suffixes

To get a listing of all the built-in macros and rules, enter the command:

% make -p -f /dev/null [| less]

Depending on your platform, there may be nearly a thousand lines of definitions, so you might want to pipe this to less, or redirect the output to a file.


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.

AR
Archive-maintaining program; default `ar'.
AS
Program for compiling assembly files; default `as'.
CC
Program for compiling C programs; default `cc'.
CO
Program for checking out files from RCS; default `co'.
CXX
Program for compiling C++ programs; default `g++'.
CO
Program for extracting a file from RCS; default `co'.
CPP
Program for running the C preprocessor, with results to standard output; default `$(CC) -E'.
FC
Program for compiling or preprocessing Fortran and Ratfor programs; default `f77'.
GET
Program for extracting a file from SCCS; default `get'.
LEX
Program to use to turn Lex grammars into source code; default `lex'.
YACC
Program to use to turn Yacc grammars into source code; default `yacc'.
LINT
Program to use to run lint on source code; default `lint'.
M2C
Program to use to compile Modula-2 source code; default `m2c'.
PC
Program for compiling Pascal programs; default `pc'.
MAKEINFO
Program to convert a Texinfo source file into an Info file; default `makeinfo'.
TEX
Program to make TeX dvi files from TeX source; default `tex'.
TEXI2DVI
Program to make TeX dvi files from Texinfo source; default `texi2dvi'.
WEAVE
Program to translate Web into TeX; default `weave'.
CWEAVE
Program to translate C Web into TeX; default `cweave'.
TANGLE
Program to translate Web into Pascal; default `tangle'.
CTANGLE
Program to translate C Web into C; default `ctangle'.
RM
Command to remove a file; default `rm -f'.

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.

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.
COFLAGS
Extra flags to give to the RCS co program.
CPPFLAGS
Extra flags to give to the C preprocessor and programs that use it (the C and Fortran compilers).
FFLAGS
Extra flags to give to the Fortran compiler.
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'.
LFLAGS
Extra flags to give to Lex.
YFLAGS
Extra flags to give to Yacc.
PFLAGS
Extra flags to give to the Pascal compiler.
RFLAGS
Extra flags to give to the Fortran compiler for Ratfor programs.
LINTFLAGS
Extra flags to give to lint.
地址:



阅读(1366) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~