make: Implicit Variables

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