常规宏

有各种默认的宏。你可以通过 “make -p” 命令看到他们。大多数的常规宏都是见名知意。

这些预定义变量(即隐式规则中使用的宏)分为两类 -

  • 作为程序名称的宏(如CC)

  • 包含程序参数的宏(如CFLAGS)。

以下是一些用作 Makefile 内置规则中程序名称的常用变量表。

AR档案保存程序;默认是ar
AS编译汇编文件的程序;默认是 as
CC编译 C 语言文件的程序;默认是 cc.
COProgram for checking out files from RCS; default is co.
CXX编译 C++ 文件的程序; 默认是 g++.
CPP运行 C 预处理器并输出到当前输出流的程序; 默认是 $(CC) -E.
FCProgram for compiling or preprocessing Fortran and Ratfor programs; default is f77.
GETProgram for extracting a file from SCCS; default is get.
LEXProgram to use to turn Lex grammars into source code; default is lex.
YACCProgram to use to turn Yacc grammars into source code; default is yacc.
LINTProgram to use to run lint on source code; default is lint.
M2CProgram to use to compile Modula-2 source code; default is m2c.
PC编译 Pascal 的程序;默认值是 pc
MAKEINFOProgram to convert a Texinfo source file into an Info file; default is makeinfo.
TEXProgram to make TeX dvi files from TeX source; default is tex.
TEXI2DVIProgram to make TeX dvi files from Texinfo source; default is texi2dvi.
WEAVE将 Web 转化为 TeX 的程序;默认值是 weave
CWEAVE将 C Web 转换为 TeX 的程序;默认值是 cweave
TANGLE将 Web 转化为 Pascal 的程序;默认值是 tangle
CTANGLE将 C Web 转换为 C 的程序;默认值是 ctangle
RM删除文件的命令;默认是 rm -f.

这是一个变量表,其值是上述程序的附加参数。除非另有说明,否则所有这些变量的默认值都是空字符串。

ARFLAGSFlags to give the archive-maintaining program; default is rv.
ASFLAGSExtra flags to give to the assembler when explicitly invoked on a .s or .S file.
CFLAGS传递给 C 编译器的额外 flag。
CXXFLAGS传递给 C 编译器 的额外 flag。
COFLAGSExtra flags to give to the RCS co program.
CPPFLAGSExtra flags to give to the C preprocessor and programs, which use it (such as C and Fortran compilers).
FFLAGSExtra flags to give to the Fortran compiler.
GFLAGSExtra flags to give to the SCCS get program.
LDFLAGSExtra flags to give to compilers when they are supposed to invoke the linker, ld.
LFLAGSExtra flags to give to Lex.
YFLAGSExtra flags to give to Yacc.
PFLAGSExtra flags to give to the Pascal compiler.
RFLAGSExtra flags to give to the Fortran compiler for Ratfor programs.
LINTFLAGSExtra flags to give to lint.

- 你可以使用 -R--no-builtin-variables 选项取消隐式规则使用的所有变量。

你也可以在命令行中定义宏,如下所示 -

  1. make CPP = /home/courses/cop4530/spring02