W3cubDocs

/GNU Make

Features of GNU make

Here 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 not use the features of make listed here, nor the ones in Missing.

Many features come from the version of make in System V.

  • The VPATH variable and its special meaning. See Searching Directories for Prerequisites. 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).
  • Included makefiles. See Including Other Makefiles. Allowing multiple files to be included with a single directive is a GNU extension.
  • Variables are read from and communicated via the environment. See Variables from the Environment.
  • Options passed through the variable MAKEFLAGS to recursive invocations of make. See Communicating Options to a Sub-make.
  • The automatic variable $% is set to the member name in an archive reference. See Automatic Variables.
  • The automatic variables $@, $*, $<, $%, and $? have corresponding forms like $(@F) and $(@D). We have generalized this to $^ as an obvious extension. See Automatic Variables.
  • Substitution variable references. See Basics of Variable References.
  • The command line options ‘-b’ and ‘-m’, accepted and ignored. In System V make, these options actually do something.
  • Execution of recursive commands to run make via the variable MAKE even if ‘-n’, ‘-q’ or ‘-t’ is specified. See Recursive Use of make.
  • Support for suffix ‘.a’ in suffix rules. See Archive Suffix Rules. 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 Archive Update) to be sufficient.
  • The arrangement of lines and backslash/newline combinations in recipes is retained when the recipes 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.

  • 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.
  • 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.
  • The automatic variable $^ containing a list of all prerequisites 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 $^.
  • The “what if” flag (‘-W’ in GNU make) was (as far as we know) invented by Andrew Hume in mk. See Instead of Executing Recipes.
  • 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 Recipe Execution.
  • A number of different build tools that support parallelism also support collecting output and displaying as a single block. See Output During Parallel Execution.
  • 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.
  • The special significance of ‘+’ characters preceding recipe lines (see Instead of Executing Recipes) is mandated by IEEE Standard 1003.2-1992 (POSIX.2).
  • The ‘+=’ syntax to append to the value of a variable comes from SunOS 4 make. See Appending More Text to Variables.
  • The syntax ‘archive(mem1 mem2…)’ to list multiple members in a single archive file comes from SunOS 4 make. See Archive Members.
  • 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 same feature appears with the name sinclude in SGI make and perhaps others.
  • The != shell assignment operator exists in many BSD of make and is purposefully implemented here to behave identically to those implementations.
  • Various build management tools are implemented using scripting languages such as Perl or Python and thus provide a natural embedded scripting language, similar to GNU make’s integration of GNU Guile.

The remaining features are inventions new in GNU make:

Copyright © 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Free Software Foundation, Inc.
Licensed under the GNU Free Documentation License.
https://www.gnu.org/software/make/manual/html_node/Features.html