f78 Features of GNU make Contents|Index|Previous|Next

Features of GNU make

The following is a summary of the features of GNU make, for comparison with and credit to other versions of make. We consider the features of make in 4.2 BSD systems as a baseline. If you are concerned with writing portable makefiles, you should use only the features of make not listed in the following documentation or in Incompatibilities and Missing Features. Many features come from the version of make in System V.

make00090000.gif The VPATH variable and its special meaning. See Searching Directories for Dependencies. This feature exists in System V make, but is undocumented. It is documented in 4.3 BSD make (which says it mimics System V’s VPATH feature).

make00090000.gif Included makefiles. See Including Other Makefiles. Allowing multiple files to be included with a single directive is a GNU extension.

make00090000.gif Variables are read from and communicated via the environment. See Variables from the Environment.

make00090000.gif Options passed through the variable MAKEFLAGS to recursive invocations of make. See Communicating Options to a Sub-make.

make00090000.gif The automatic variable, $%, is set to th ffb e member name in an archive reference. See Automatic Variables.

make00090000.gif The automatic variables, $@, $*, $<, $%, and $? have corresponding forms like $(@F) and $(@D). We have generalized this to as an obvious extension. See Automatic Variables.

make00090000.gif Substitution variable references. See Basics of Variable References.

make00090000.gif The command-line options ‘-b’ and ‘-m’, accepted and ignored. In System V make, these options actually do something.

make00090000.gif Execution of recursive commands to run make via the variable MAKE even if ‘-n’, ‘-q’ or ‘-t’ is specified. See Recursive Use of make.

make00090000.gif Support for suffix ‘.a’ in suffix rules. See Suffix Rules for Archive Files. This feature is obsolete in GNU make because the general feature of rule chaining (see Chains of Implicit Rules) allows one pattern rule for installing members in an archive (see Implicit Rule for Archive Member Targets) to be sufficient.

make00090000.gif The arrangement of lines and backslash-newline combinations in commands is retained when the commands are printed, so they appear as they do in the makefile, except for the stripping of initial whitespace.

The following features were inspired by various other versions of make. In some cases it is unclear exactly which versions inspired which others.

make00090000.gif Pattern rules using ‘%’. This has been implemented in several versions of make. We’re not sure who invented it first, but it’s been spread around a bit. See Defining and Redefining Pattern Rules.

make00090000.gif Rule chaining and implicit intermediate files. This was implemented by Stu Feldman in his version of make for AT&T Eighth Edition Research Unix, and later by Andrew Hume of AT&T Bell Labs in his mk program (where he terms it “transitive closure”). We do not really know if we got this from either of them or thought it up ourselves at the same time. See Chains of Implicit Rules.

make00090000.gif The automatic variable, , containing a list of all dependencies of the current target. We did not invent this, but we have no idea who did. See Automatic Variables. The automatic variable, $+, is a simple extension of .

make00090000.gif The “what if ” flag (‘-W’ in GNU make) was (as far as we know) invented by Andrew Hume in mk. See Instead of Executing the Commands.

make00090000.gif The concept of doing several things at once (parallelism) exists in many incarnations of make and similar programs, though not in the System V or BSD implementations. See Command Execution.

make00090000.gif Modified variable references using pattern substitution come from SunOS 4. See Basics of Variable References. This functionality was provided in GNU make by the patsubst function before the alternate syntax was implemented for compatibility with SunOS 4. It is not altogether clear who inspired whom, since GNU make had patsubst before SunOS 4 was released.

make00090000.gif The special significance of ‘+’ characters preceding command lines (see Instead of Executing the Commands) is mandated by IEEE Standard 1003.2-1992 (POSIX.2).

make00090000.gif The ‘+=’ syntax to append to the value of a variable comes from SunOS 4 make. See Appending More Text to Variables.

make00090000.gif The syntax ‘archive(mem1 mem2 ...)’ to list multiple members in a single archive file comes from SunOS 4 make. See Implicit Rule for Archive Member Targets.

make00090000.gif The -include directive to include makefiles with no error for a nonexistent file comes from SunOS 4 make. (But note that SunOS 4 make does not allow multiple makefiles to be specified in one -include directive.)

The remaining features are inventions new in GNU make:

make00090000.gif Use the ‘-v’ or ‘--version’ option to print version and copyright information.

make00090000.gif Use the ‘-h’ or ‘--help’ option to summarize the options to make.

make00090000.gif Simply-expanded variables. See The Two Flavors of Variables.

make00090000.gif Pass command-line variable assignments automatically through the variable, MAKE, to recursive make invocations. See Recursive Use of make.

make00090000.gif Use the ‘-C’ or ‘--directory’ command option to change directory. See Summary of Options.

make00090000.gif Make verbatim variable definitions with define. See Defining Variables Verbatim.

make00090000.gif Declare phony targets with the special target, .PHONY.

Andrew Hume of AT&T Bell Labs implemented a similar feature with a different syntax in his mk program. This seems to be a case of parallel discovery. See Phony Targets.

make00090000.gif Manipulate text by calling functions. See Functions for Transforming Text.

make00090000.gif Use the ‘-o’ or ‘--old-file’ option to pretend a file’s modification-time is old. See Avoiding Recompilation of Some Files.

make00090000.gif Conditional execution
This feature has been implemented numerous times in various versions of
make; it seems a natural extension derived from the features of the C preprocessor and similar macro languages and is not a revolutionary concept. See Conditional Parts of Makefiles.

make00090000.gif Specify a search path for included makefiles. See Including Other Makefiles.

make00090000.gif Specify extra makefiles to read with an environment variable. See The Variable, MAKEFILES .

make00090000.gif Strip leading sequences of ‘./’ from file names, so that ‘./file’ and ‘file’ are considered to be the same file.

make00090000.gif Use a special search method for library dependencies written in the form ‘-l name’. See Directory Search for Link Libraries.

make00090000.gif Allow suffixes for suffix rules (see Old-Fashioned Suffix Rules) to contain any characters. In other versions of make, they must begin with ‘.’ and not contain any ‘/’ characters.

make00090000.gif Keep track of the current level of make recursion using the variable MAKELEVEL. See Recursive Use of make.

make00090000.gif Specify static pattern rules. See Static Pattern Rules.

make00090000.gif Provide selective vpath search. See Searching Directories for Dependencies.

make00090000.gif Provide computed variable references. See Basics of Variable References.

make00090000.gif Update makefiles. See How Makefiles Are Remade. System V make has a very, very limited form of this functionality in that it will check out SCCS files for makefiles.

make00090000.gif Various new built-in implicit rules. See Catalogue of Implicit Rules.

make00090000.gif The built-in variable, ‘MAKE_VERSION’, gives the version number of make.

0