% GNU Make - GNU Project - Free Software Foundation % % [Skip to content](#content) | [Skip to navigation](#navigation) | [Skip to search](#searcher)| [Translations of this page](#translations) | [Accessibility](/accessibility/) [The GNU Operating System](/) ============================= #### Sign up for the [Free Software Supporter](http://www.fsf.org/fss) A monthly email newsletter about GNU and Free Software Enter your email address (e.g. richard@example.com)   Search: - [Philosophy](/philosophy/philosophy.html) - [Licenses](/licenses/licenses.html) - [Education](/education/education.html) - [Downloads](/software/software.html) - [Documentation](/doc/doc.html) - [Help GNU](/help/help.html) - [Join the FSF!](https://www.fsf.org/associate/support_freedom?referrer=4052) GNU Make -------- Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files. Make gets its knowledge of how to build your program from a file called the *makefile*, which lists each of the non-source files and how to compute it from other files. When you write a program, you should write a makefile for it, so that it is possible to use Make to build and install the program. #### Capabilities of Make - Make enables the end user to build and install your package without knowing the details of how that is done -- because these details are recorded in the makefile that you supply. - Make figures out automatically which files it needs to update, based on which source files have changed. It also automatically determines the proper order for updating files, in case one non-source file depends on another non-source file. As a result, if you change a few source files and then run Make, it does not need to recompile all of your program. It updates only those non-source files that depend directly or indirectly on the source files that you changed. - Make is not limited to any particular language. For each non-source file in the program, the makefile specifies the shell commands to compute it. These shell commands can run a compiler to produce an object file, the linker to produce an executable, `ar` to update a library, or TeX or Makeinfo to format documentation. - Make is not limited to building a package. You can also use Make to control installing or deinstalling a package, generate tags tables for it, or anything else you want to do often enough to make it worth while writing down how to do it. #### Make Rules and Targets A *rule* in the makefile tells Make how to execute a series of commands in order to build a *target* file from source files. It also specifies a list of *dependencies* of the target file. This list should include all files (whether source files or other targets) which are used as inputs to the commands in the rule. Here is what a simple rule looks like: target: dependencies ... commands ... When you run Make, you can specify particular targets to update; otherwise, Make updates the first target listed in the makefile. Of course, any other target files needed as input for generating these targets must be updated first. Make uses the makefile to figure out which target files ought to be brought up to date, and then determines which of them actually need to be updated. If a target file is newer than all of its dependencies, then it is already up to date, and it does not need to be regenerated. The other target files do need to be updated, but in the right order: each target file must be regenerated before it is used in regenerating other targets. #### Advantages of GNU Make GNU Make has many powerful features for use in makefiles, beyond what other Make versions have. It can also regenerate, use, and then delete intermediate files which need not be saved. GNU Make also has a few simple features that are very convenient. For example, the `-o file` option which says \`\`pretend that source file *file* has not changed, even though it has changed.'' This is extremely useful when you add a new macro to a header file. Most versions of Make will assume they must therefore recompile all the source files that use the header file; but GNU Make gives you a way to avoid the recompilation, in the case where you know your change to the header file does not require it. However, the most important difference between GNU Make and most versions of Make is that GNU Make is free software. #### Makefiles And Conventions We have developed conventions for how to write Makefiles, which all GNU packages ought to follow. It is a good idea to follow these conventions in your program even if you don't intend it to be GNU software, so that users will be able to build your package just like many other packages, and will not need to learn anything special before doing so. These conventions are found in the chapter [\`\`Makefile conventions'' (147 k characters)](/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions) of the [GNU Coding Standards (147 k characters)](/prep/standards.html). ### Downloading GNU Make GNU Make can be found on the main GNU ftp server: [http://ftp.gnu.org/gnu/make/](http://ftp.gnu.org/gnu/make/) (via HTTP) and [ftp://ftp.gnu.org/gnu/make/](ftp://ftp.gnu.org/gnu/make/) (via FTP). It can also be found on the [GNU mirrors](/prep/ftp.html); please [use a mirror](http://ftpmirror.gnu.org/make/) if possible. ### Documentation [Documentation for Make](manual/) is available online, as is [documentation for most GNU software](/manual/). You may also find more information about Make by running *info make* or *man make*, or by looking at */usr/doc/make/*, */usr/local/doc/make/*, or similar directories on your system. A brief summary is available by running `make --help`. ### Mailing lists Make has two mailing lists: [\](mailto:bug-make@gnu.org) and [\](mailto:help-make@gnu.org). The main discussion list is [\](mailto:bug-make@gnu.org), and is used to discuss most aspects of Make, including development and enhancement requests, as well as bug reports. There is a separate list for general user help and discussion, [\](mailto:help-make@gnu.org). GNU Make has been ported to a great many systems. One that poses unique challenges is Microsoft DOS and Windows platforms; because of that there is a GNU Make mailing list dedicated specifically to users of those platforms: [\](mailto:make-w32@gnu.org). Announcements about Make and most other GNU software are made on [\](mailto:info-gnu@gnu.org). To subscribe to these or any GNU mailing lists, please send an empty mail with a Subject: header of just `subscribe` to the relevant -request list. For example, to subscribe yourself to the GNU announcement list, you would send mail to [\](mailto:info-gnu-request@gnu.org?Subject=subscribe). Or you can use the [mailing list web interface](http://lists.gnu.org/mailman/listinfo/info-gnu). ### Getting involved Development of Make, and GNU in general, is a volunteer effort, and you can contribute. For information, please read [How to help GNU](/help/). If you'd like to get involved, it's a good idea to join the discussion mailing list (see above). Test releases ~ Trying the latest test release (when available) is always appreciated. Test releases of Make can be found at [http://alpha.gnu.org/gnu/make/](http://alpha.gnu.org/gnu/make/) (via HTTP) and [ftp://alpha.gnu.org/gnu/make/](ftp://alpha.gnu.org/gnu/make/) (via FTP). Development ~ For development sources, bug and patch trackers, and other information, please see the [Make project page](http://savannah.gnu.org/projects/make/) at [savannah.gnu.org](http://savannah.gnu.org). Translating Make ~ To translate Make's messages into other languages, please see the [Translation Project page for Make](http://translationproject.org/domain/make.html). If you have a new translation of the message strings, or updates to the existing strings, please have the changes made in this repository. Only translations from this site will be incorporated into Make. For more information, see the [Translation Project](http://translationproject.org/html/welcome.html). Maintainer ~ GNU Make was written by Richard Stallman and Roland McGrath. It has been maintained and updated by Paul Smith since version 3.76 (1997). Please use the mailing lists for contact. ### Licensing Make is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - [GNU home page](/) - [FSF home page](http://www.fsf.org/) - [GNU Art](/graphics/graphics.html) - [GNU Fun](/fun/fun.html) - [GNU's Who?](/people/people.html) - [Free Software Directory](http://directory.fsf.org) - [Site map](/server/sitemap.html) The [Free Software Foundation](http://www.fsf.org) is the principal organizational sponsor of the [GNU Operating System](http://www.gnu.org/). **Our mission is to preserve, protect and promote the freedom to use, study, copy, modify, and redistribute computer software, and to defend the rights of Free Software users.** Support GNU and the FSF by [buying manuals and gear](http://shop.fsf.org/), [joining the FSF as an associate member](http://www.fsf.org/join) or by making a donation, either [directly to the FSF](http://donate.fsf.org/) or [via Flattr](http://flattr.com/thing/313733/gnuproject-on-Flattr). [back to top](#header) Please send general FSF & GNU inquiries to [\](mailto:gnu@gnu.org). There are also [other ways to contact](/contact/) the FSF.\ Please send broken links and other corrections or suggestions to [\](mailto:bug-make@gnu.org). Please see the [Translations README](/server/standards/README.translations.html) for information on coordinating and submitting translations of this article. Copyright © 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2010 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved. Updated: \$Date: 2010/07/03 18:28:15 \$ #### Translations of this page - [English](/server/standards/boilerplate.html) [en]