Make (software)

aesthetics  →
being  →
complexity  →
database  →
enterprise  →
ethics  →
fiction  →
history  →
internet  →
knowledge  →
language  →
licensing  →
linux  →
logic  →
method  →
news  →
perception  →
philosophy  →
policy  →
purpose  →
religion  →
science  →
sociology  →
software  →
truth  →
unix  →
wiki  →
essay  →
feed  →
help  →
system  →
wiki  →
critical  →
discussion  →
forked  →
imported  →
original  →
Make (software)
[ temporary import ]
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki

In software development, Make is a build automation tool that automatically builds executable programs and libraries from source code by reading files called Makefiles which specify how to derive the target program. Though integrated development environments and language-specific compiler features can also be used to manage a build process, Make remains widely used, especially in Unix and Unix-like operating systems.Besides building programs, Make can be used to manage any project where some files must be updated automatically from others whenever the others change.


There are now a number of dependency-tracking build utilities, but Make is one of the most widespread, primarily due to its inclusion in Unix, starting with the PWB/UNIX 1.0, which featured a variety of tools targeting software development tasks.JOURNAL, Thompson, T. J., Designer's Workbench: Providing a Production Environment, Bell System Technical Journal, November 1980, 59, 9, 1811–1825, 10.1002/j.1538-7305.1980.tb03063.x, In the general maintenance of DWB, we have used the Source Code Control System and make utility provided by the PWB/UNIX* interactive operating system., It was originally created by Stuart Feldman in April 1976 at Bell Labs.WEB,weblinkweblink" title="">weblink yes, V7/usr/src/cmd/make/ident.c, 1 September 2013, 1 September 2013,, 18 March 2018, JOURNAL, Feldman, S. I., Make --- A Program for Maintaining Computer Programs, Software: Practice and Experience, April 1979, 9, 4, 255–265, 10.1002/spe.4380090402,, Feldman received the 2003 ACM Software System Award for the authoring of this widespread tool.BOOK, 94, Practical Development Environments, Matthew Doar, 978-0-596-00796-6, 2005, O'Reilly Media, Feldman was inspired to write Make by the experience of a coworker in futilely debugging a program of his where the executable was accidentally not being updated with changes:Before Make's introduction, the Unix build system most commonly consisted of operating system dependent "make" and "install" shell scripts accompanying their program's source. Being able to combine the commands for the different targets into a single file and being able to abstract out dependency tracking and archive handling was an important step in the direction of modern build environments.


Make has gone through a number of rewrites, including a number of from-scratch variants which used the same file format and basic algorithmic principles and also provided a number of their own non-standard enhancements. Some of them are:
  • Sun DevPro Make appeared in 1986 with SunOS-3.2. With SunOS-3.2, It was delivered as optional program; with SunOS-4.0, SunPro Make was made the default Make program.WEB,weblink Google Groups,, 18 March 2018, bot: unknown,weblinkweblink 22 January 2011, {{better source|date=May 2017}} In December 2006, Sun DevPro Make was made OpenSource as part of the efforts to open-source Solaris,WEB,weblink OpenSolaris at Two (Jim Grisanzio), 12 December 2013, 18 March 2018, yes,weblink 12 December 2013, in order to regain lost market shareweblink "Sun is dead. Solaris is dead. There's no
OpenSolaris community. Sun will never be able to build a community. This is all too little too late.
  • dmake or Distributed Make that came with Sun Solaris Studio as its default Make, but not the default one on the Solaris Operating System (SunOS). It was originally required to build OpenOffice, but in 2009 the build system was rewritten to use GNU Make. While Apache OpenOffice still contains a mixture of both build systems,WEB,weblink Apache OpenOffice Building Guide - Apache OpenOffice Wiki,, 18 March 2018, the much more actively developed LibreOffice only uses the modernized "gbuild" now.WEB,weblink Development/Gbuild - The Document Foundation Wiki,, 18 March 2018,
  • BSD Make (pmake,{{citation |url=|title=FreeBSD 2.0.5 Make Source Code|date=1993 }} bmake{{citation needed|date=September 2014}} or fmake{{citation needed|date=August 2016}}), which is derived from Adam de Boor's work on a version of Make capable of building targets in parallel, and survives with varying degrees of modification in FreeBSD,{{citation needed|date=May 2014}} NetBSD{{citation needed|date=May 2014}} and OpenBSD.WEB,weblink make(1) - OpenBSD manual pages,, 18 March 2018, Distinctively, it has conditionals and iterative loops which are applied at the parsing stage and may be used to conditionally and programmatically construct the makefile, including generation of targets at runtime.{{citation needed|date=September 2014}}
  • GNU Make (short gmake) is the standard implementation of Make for Linux and OS X.{{citation |url= |title=Unix in a Nutshell, Fourth Edition |author=Arnold Robbins |date=2005 |publisher=O'Reilly }} It provides several extensions over the original Make, such as conditionals. It also provides many built-in functions which can be used to eliminate the need for shell-scripting in the makefile rules as well as to manipulate the variables set and used in the makefile.{{citation |url= |title=8. Functions for Transforming Text |work=GNU make |publisher=Free Software Foundation |date=2013 }} For example, the foreach function sets a variable to the list of all files in a given directory.{{citation |url= |title=8.5 The foreach Function |work=GNU make |publisher=Free Software Foundation |date=2013 }} GNU Make has been required for building gcc since version 3.4.WEB,weblink GCC 3.4 Release Series Changes, New Features, and Fixes, Free Software Foundation, 2006, It is required for building the Linux kernel,WEB,weblink Kbuild: the Linux Kernel Build System, Javier Martinez Canillas, Linux Journal, December 26, 2012, {{citation |url= |title=Linux Kernel in a Nutshell |author=Greg Kroah-Hartman |publisher=O'Reilly |date=2006 }} Apache OpenOffice and LibreOffice, Mozilla FirefoxWEB,weblink Build Instructions, and many others. To give an idea of the size of the software: GNU Make 4.2 consists of about 42,500 lines of C code.
  • Rocky Bernstein's RemakeWEB,weblink Remake – GNU Make with comprehensible tracing and a debugger, Rocky Bernstein, is a fork of GNU Make and provides several extensions over GNU Make, such as better location and error-location reporting, execution tracing, execution profiling, and it contains a debugger.
  • Glenn Fowler's nmakeWEB,weblink nmake Overview, Glenn Fowler, Information and Software Systems Research, AT&T Labs Research, January 4, 2012, is unrelated to the Microsoft program of the same name. Its input is similar to Make, but not compatible. This program provides shortcuts and built-in features, which according to its developers reduces the size of makefiles by a factor of 10.
  • Microsoft nmake, a command-line tool which normally is part of Visual Studio.WEB,weblink NMAKE Reference Visual Studio 2015, Microsoft, 2015, It supports preprocessor directives such as includes and conditional expressions which use variables set on the command-line or within the makefiles.WEB,weblink Makefile Preprocessing Directives, 2014, WEB,weblink Makefile Preprocessing Operators, Microsoft, 2014, Inference rules differ from Make; for example they can include search paths.WEB,weblink Search Paths in Rules, Microsoft, 2014, The Make tool supplied with Embarcadero products has a command-line option that "Causes MAKE to mimic Microsoft's NMAKE."WEB,weblink MAKE, CodeGear(TM), 2008,
  • Mk replaced Make in Research Unix, starting from version 9.TECHREPORT, M. D., McIlroy, Doug McIlroy, A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986, CSTR 139, Bell Labs, 1987,weblink A redesign of the original tool by Bell Labs programmer Andrew G. Hume, it features a different syntax. Mk became the standard build tool in Plan 9, Bell Labs' intended successor to Unix.ENCYCLOPEDIA, Hume, Andrew G., Bob, Flandrena, Maintaining files on Plan 9 with Mk, Plan 9 Programmer’s Manual, AT&T Bell Laboratories, 2002,weblinkweblink" title="">weblink July 11, 2015, no,
POSIX includes standardization of the basic features and operation of the Make utility, and is implemented with varying degrees of completeness in Unix-based versions of Make. In general, simple makefiles may be used between various versions of Make with reasonable success. GNU Make, Makepp and some versions of BSD Make default to looking first for files named "GNUmakefile",WEB,weblink GNU 'make', Free Software Foundation, "Makeppfile"WEB,weblink Makepp, and "BSDmakefile"WEB,weblink Free BSD make, respectively, which allows one to put makefiles which use implementation-defined behavior in separate locations.


Make is typically used to build executable programs and libraries from source code. Generally though, Make is applicable to any process that involves executing arbitrary commands to transform a source file to a target result. For example, Make could be used to detect a change made to an image file (the source) and the transformation actions might be to convert the file to some specific format, copy the result into a content management system, and then send e-mail to a predefined set of users indicating that the above actions were performed.Make is invoked with a list of target file names to build as command-line arguments:make [TARGET ...]Without arguments, Make builds the first target that appears in its makefile, which is traditionally a symbolic "phony" target named all.Make decides whether a target needs to be regenerated by comparing file modification times.How to sort Linux ls command file output {{webarchive |url= |date=September 13, 2016 }} This solves the problem of avoiding the building of files which are already up to date, but it fails when a file changes but its modification time stays in the past. Such changes could be caused by restoring an older version of a source file, or when a network filesystem is a source of files and its clock or timezone is not synchronized with the machine running Make. The user must handle this situation by forcing a complete build. Conversely, if a source file's modification time is in the future, it triggers unnecessary rebuilding, which may inconvenience users.


Make searches the current directory for the makefile to use, e.g. GNU Make searches files in order for a file named one of GNUmakefile, makefile, Makefile and then runs the specified (or default) target(s) from (only) that file.The makefile language is similar to declarative overview on dsls {{webarchive |url= |date=October 23, 2007 }}, 2007/02/27, phoenix wikiRe: Choreography and REST {{webarchive |url= |date=September 12, 2016 }}, from Christopher B Ferris on 2002-08-09Target Junior Makefiles {{webarchive |url= |date=January 7, 2010 }}, Andrew W. Fitzgibbon and William A. Hoffman This class of language, in which necessary end conditions are described but the order in which actions are to be taken is not important, is sometimes confusing to programmers used to imperative programming.One problem in build automation is the tailoring of a build process to a given platform. For instance, the compiler used on one platform might not accept the same options as the one used on another. This is not well handled by Make. This problem is typically handled by generating platform-specific build instructions, which in turn are processed by Make. Common tools for this process are Autoconf and CMake.


A makefile consists of rules. Each rule begins with a textual dependency line which defines a target followed by a colon (:) and optionally an enumeration of components (files or other targets) on which the target depends. The dependency line is arranged so that the target (left hand of the colon) depends on components (right hand of the colon). It is common to refer to components as prerequisites of the target.
target [target ...]: [component ...]
{{keypress|TAB}}[command 1]
{{keypress|TAB}}[command n]
Usually each rule has a single unique target, rather than multiple targets.For example, a C .o object file is created from .c files, so .c files come first (i.e. specific object file target depends on a C source file and header files). Because Make itself does not understand, recognize or distinguish different kinds of files, this opens up a possibility for human error. A forgotten or an extra dependency may not be immediately obvious and may result in subtle bugs in the generated software. It is possible to write makefiles which generate these dependencies by calling third-party tools, and some makefile generators, such as the Automake toolchain provided by the GNU Project, can do so automatically.Each dependency line may be followed by a series of TAB indented command lines which define how to transform the components (usually source files) into the target (usually the "output"). If any of the prerequisites has a more recent modification time than the target, the command lines are run. The GNU Make documentation refers to the commands associated with a rule as a "recipe".The first command may appear on the same line after the prerequisites, separated by a semicolon,targets : prerequisites ; commandfor example,hello: ; @echo "hello"Make can decide where to start through topological sorting.Each command line must begin with a tab character to be recognized as a command. The tab is a whitespace character, but the space character does not have the same special meaning. This is problematic, since there may be no visual difference between a tab and a series of space characters. This aspect of the syntax of makefiles is often subject to criticism; it has been described by Eric S. Raymond as "one of the worst design botches in the history of Unix""Chapter 15. Tools: make: Automating Your Recipes", The Art of Unix Programming, Eric S. Raymond 2003 and The Unix-Haters Handbook said "using tabs as part of the syntax is like one of those pungee stick traps in The Green Berets". Feldman explains the choice as caused by a workaround for an early implementation difficulty preserved by a desire for backward compatibility with the very first users:However, the GNU Make since version 3.82 allows to choose any symbol (one character) as the recipe prefix using the .RECIPEPREFIX special variable, for example:.RECIPEPREFIX := :all:
@echo "recipe prefix symbol is set to '$(.RECIPEPREFIX)'"
Each command is executed by a separate shell or command-line interpreter instance. Since operating systems use different command-line interpreters this can lead to unportable makefiles. For instance, GNU Make by default executes commands with /bin/sh, where Unix commands like cp are normally used. In contrast to that, Microsoft's nmake executes commands with cmd.exe where batch commands like copy are available but not necessarily cp.A rule may have no command lines defined. The dependency line can consist solely of components that refer to targets, for example:realclean: clean distcleanThe command lines of a rule are usually arranged so that they generate the target. An example: if file.html is newer, it is converted to text. The contents of the makefile:file.txt: file.html lynx -dump file.html > file.txtThe above rule would be triggered when Make updates "file.txt". In the following invocation, Make would typically use this rule to update the "file.txt" target if "file.html" were newer.make file.txtCommand lines can have one or more of the following three prefixes:
  • a hyphen-minus (-), specifying that errors are ignored
  • an at sign (@), specifying that the command is not printed to standard output before it is executed
  • a plus sign (+), the command is executed even if Make is invoked in a "do not execute" mode
Ignoring errors and silencing echo can alternatively be obtained via the special targets ".IGNORE" and ".SILENT".make {{webarchive |url= |date=May 2, 2016 }}, The Open Group Base Specifications Issue 6Microsoft's NMAKE has predefined rules that can be omitted from these makefiles, e.g. "c.obj $(CC)$(CFLAGS)".


A makefile can contain definitions of macros. Macros are usually referred to as variables when they hold simple string definitions, like "CC=clang". Macros in makefiles may be overridden in the command-line arguments passed to the Make utility. Environment variables are also available as macros.Macros allow users to specify the programs invoked and other custom behavior during the build process. For example, the macro "CC" is frequently used in makefiles to refer to the location of a C compiler, and the user may wish to specify a particular compiler to use.New macros (or simple "variables") are traditionally defined using capital letters:MACRO = definitionA macro is used by expanding it. Traditionally this is done by enclosing its name inside $(). (Omitting the parentheses leads to Make interpreting the next letter after the $as the entire variable name.) An equivalent form uses curly braces rather than parentheses, i.e. ${}, which is the style used in the BSDs.NEW_MACRO = $(MACRO)-$(MACRO2)Macros can be composed of shell commands by using the command substitution operator, denoted by backticks (`).YYYYMMDD = ` date `The content of the definition is stored "as is". Lazy evaluation is used, meaning that macros are normally expanded only when their expansions are actually required, such as when used in the command lines of a rule. An extended example:PACKAGE = packageVERSION = ` date +"%Y.%m%d" `ARCHIVE = $(PACKAGE)-$(VERSION)dist: # Notice that only now macros are expanded for shell to interpret: # tar -cf package-`date +"%Y%m%d"`.tar tar -cf $(ARCHIVE).tar .The generic syntax for overriding macros on the command line is:make MACRO="value" [MACRO="value" ...] TARGET [TARGET ...]Makefiles can access any of a number of predefined internal macros, with '?' and '@' being the most component1 component2 # contains those components which need attention (i.e. they ARE YOUNGER than current TARGET). echo $? # evaluates to current TARGET name from among those left of the colon. echo $@

Suffix rules

Suffix rules have "targets" with names in the form .FROM.TO and are used to launch actions based on file extension. In the command lines of suffix rules, POSIX specifies that the internal macro $< refers to the first prerequisite and $@ refers to the target. In this example, which converts any HTML file into text, the shell redirection token > is part of the command line whereas $< is a macro referring to the HTML file:.SUFFIXES: .txt .html
  1. From .html to .txt
.html.txt: lynx -dump $< > $@When called from the command line, the above example expands.$ make -n file.txtlynx -dump file.html > file.txt

Pattern rules

Suffix rules cannot have any prerequisites of their own.WEB,weblink GNU make manual: suffix rules, Free Software Foundation, If they have any, they are treated as normal files with unusual names, not as suffix rules. GNU Make supports suffix rules for compatibility with old makefiles but otherwise encourages usage of pattern rules.WEB,weblink GNU make manual: pattern rules, Free Software Foundation, A pattern rule looks like an ordinary rule, except that its target contains exactly one character '%'. The target is considered a pattern for matching file names: the '%' can match any substring of zero or more characters,See section Pattern Matching Rules in the SunPro man page {{webarchive|url= |date=May 29, 2014 }} while other characters match only themselves. The prerequisites likewise use '%' to show how their names relate to the target name.The above example of a suffix rule would look like the following pattern rule:
  1. From %.html to %.txt
%.txt : %.html lynx -dump $< > $@

Other elements

Single-line comments are started with the hash symbol (#).Some directives in makefiles can include other makefiles.Line continuation is indicated with a backslash character at the end of a line.
target: component
{{keypress|TAB}}command ;
{{keypress|TAB}}command |

Example makefiles

Makefiles are traditionally used for compiling code (*.c, *.cc, *.C, etc.), but they can also be used for providing commands to automate common tasks. One such makefile is called from the command line:make # Without argument runs first TARGETmake help # Show available TARGETSmake dist # Make a release archive from current dirThe makefile:PACKAGE = packageVERSION = ` date "+%Y.%m%d%" `RELEASE_DIR = ..RELEASE_FILE = $(PACKAGE)-$(VERSION)
  1. Notice that the variable LOGNAME comes from the environment in
  2. POSIX shells.
  3. target: all - Default target. Does nothing.
all: echo "Hello $(LOGNAME), nothing to do by default" # sometimes: echo "Hello ${LOGNAME}, nothing to do by default" echo "Try 'make help'"
  1. target: help - Display callable targets.
help: egrep "^# target:" [Mm]akefile
  1. target: list - List source files
list: # Won't work. Each command is in separate shell cd src ls # Correct, continuation of the same shell cd src; ls
  1. target: dist - Make a release.
dist: tar -cf $(RELEASE_DIR)/$(RELEASE_FILE) && gzip -9 $(RELEASE_DIR)/$(RELEASE_FILE).tarBelow is a very simple makefile that by default (the "all" rule is listed first) compiles a source file called "helloworld.c" using the system's C compiler and also provides a "clean" target to remove the generated files if the user desires to start over. The $@ and $< are two of the so-called internal macros (also known as automatic variables) and stand for the target name and "implicit" source, respectively. In the example below, $^ expands to a space delimited list of the prerequisites. There are a number of other internal macros.Automatic Variables {{webarchive |url= |date=April 25, 2016 }} GNU `make'CFLAGS ?= -gall: helloworldhelloworld: helloworld.o # Commands start with TAB not spaces $(CC) $(LDFLAGS) -o $@ $^helloworld.o: helloworld.c $(CC) $(CFLAGS) -c -o $@ $
  • This pseudo target causes all targets that depend on FRC
  • to be remade even in case a file with the name of the target exists.
  • This works with any make implementation under the assumption that
  • there is no file FRC in the current directory.
  • FRC:Many systems come with predefined Make rules and macros to specify common tasks such as compilation based on file suffix. This lets users omit the actual (often unportable) instructions of how to generate the target from the source(s). On such a system the above makefile could be modified as follows:all: helloworldhelloworld: helloworld.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^clean: FRC rm -f helloworld helloworld.o
    1. This is an explicit suffix rule. It may be omitted on systems
    2. that handle simple rules like this automatically.
    .c.o: $(CC) $(CFLAGS) -c $
    [ this remote article is provided by Wikipedia ]
    LATEST EDITS [ see all ]
    GETWIKI 09 MAY 2016
    GETWIKI 18 OCT 2015
    M.R.M. Parrott
    GETWIKI 20 AUG 2014
    GETWIKI 19 AUG 2014
    GETWIKI 18 AUG 2014