|developer||Stuart Feldman , various|
|operating system||POSIX ( Linux , Unix , ...), ported to various other platforms|
|category||Build management tool|
make ( English for make , create ) is a build management tool that performs commands depending on conditions. It is mainly used as a programming tool in software development .
It is used, for example, to automatically control all work steps ( translation , linking , copying files, etc.) in projects that consist of many different files with source code , right through to the finished, executable program. make is designed so flexibly that it can also control any other tasks in which the time dependency of files plays a role.
The utility program
makeis part of the POSIX standard, the current name of which is IEEE Std 1003.1, 2008 Edition (equivalent to Single UNIX Specification V3, SUSv3).
makereads a so-called Makefile (note the capitalization, which is differentiated in Unix file systems), in which the dependencies of the compilation process of programs are formally recorded. This formalization describes which source text files are processed in which way by the compiler or by other programs to which object files or results, or which object files are linked by the linker to form program libraries or executable programs . All steps are carried out taking into account the dependencies recorded in the Makefile .
When the Makefile is
makeprocessed by the program, a source file, for example , is converted into an object file only if the source file is newer than the existing version of the result file, or if no result file is available. In the development of large software packages with many source files and many executable programs eliminated so the need for all a series of small changes compilations be repeated. The success of this economy measure depends on the correct specification of the file dependencies. All dependencies must be completely and correctly described in the Makefile - which is not easy to implement in large projects. New dependencies can arise, in particular with program changes or extensions. In order to function correctly, these dependencies must be entered in the Makefile. In the early 1980s, utility programs such as
mkmfor were often
makedependused to do this. Since the mid-1980s there have been methods integrated into the make programs for the automatic generation of the dependency lists (e.g. in SunPro make) or rules integrated into the makefiles for their generation.
makecommands executed by are not limited to compilers or linkers. Any tool provided by the command line interpreter can be used to achieve the desired file manipulation. So you can z. B. automatically generate images from texts.
makehas established itself in large areas of software development, but had problems until the mid-1980s - especially with large projects - (as long as the automated generation of all dependency rules was not resolved) (see literature ) . Therefore, attempts were made again and again to find and establish a successor (see alternatives ) .
The creation of a file is referred to as a target in the Makefile. The boundary conditions for this are described in an entry.
A: B C cmd_A
This line means: Target
Adepends on the sources
C(“Depends on” usually means “will be created from”). If to be
Cconsidered. If either is younger than
A, it will
Aconsidered current and
cmd_Atherefore not executed.
Bor targets from further make rules can be used
Cas sources of
B: D E cmd_B
Bdependent, is thus
Bconsidered before for
Arunning another. Overall, it describes the execution of instructions backwards. The starting point is the ultimate goal
A. This consideration must end with sources that are available and for which there are no further educational regulations. These are the actual sources of all generation. If a source does not exist, but it is also found no education provision, the maker only respond with an error message:
don't know how to make …. The cause of such an error can either be an error in the Makefile or the actual lack of the source.
Definition of derivation rules : In the above illustration
Betc. can be named files with directory information. However, it is also possible to define general rules by specifying the file extension:
.c.o: $(CC) $(CFLAGS) -c -o $@ $<
In the above example there is a so-called inference rule which is written in the form of a suffix rule .
Example of a Makefile
The present example only shows the simplest form of a Makefile. There are also methods such as B. Pattern rules that make the Makefile more powerful.
progshould consist of the two source files
bar.care generated so that little translation and binding operations, whenever possible are required when only one of the two source files is changed.
1 CC = cc 2 LD = ld 3 4 prog: foo.o bar.o 5 $(LD) -o prog foo.o bar.o 6 7 foo.o: foo.c 8 $(CC) -c foo.c 9 10 bar.o: bar.c 11 $(CC) -c bar.c
In the first two lines global variables are defined which contain the program names for the compiler and the linker. Line 4 defines a label in the Makefile, called targets ; the expressions
bar.ocall the targets defined in lines 7 and 10 in the specified order before the command in line 5 is finally executed. In line 5 a command is composed of the global variable
LDand some parameters. The two files
bar.oare available because the other two targets that generated these files have already been executed. The next line specifies that it is
foo.c, in the eighth line by calling
cc, the C compiler. The last two lines are analogous.
There is no mandatory connection between the names of the jump labels and the files processed under them. Instructions that are executed under a jump label always begin with a horizontal tab character .
The process is started on the command line with
make prog. If no parameter is given,
makethe target defined first (here
prog) is executed. In the example above it would have
makethe same effect as
The development of large programs and program packages, which consist of many individual source code files and have dependencies on separate libraries, is
makehardly conceivable without or similar tools. In the world of open source it is common that the Makefile is published with the source code of a project in order to simplify the compilation of software.
Especially with larger programs, the Makefile is not always written directly by the developers, but either created using different programs from simpler rules or more powerful systems are used. A method for the automatic generation of complex Makefiles is the use of preprocessors like the GNU autotools ( autoconf and automake ) or also mkmf , qmake or CMake . Methods to reduce the complexity of the Makefiles are based on more powerful systems such as the nmake program by David Korn . This system enables Makefiles that simply list the source files involved in a table.
Alternatives to the make command
GNU Make is usually used in Linux, nmake is available for Windows . As the successor to UNIX make, nmake was written by AT&T ; it enables simple tabular makefiles.
- is also a derivative of GNU make, but also offers an integrated, expandable command and include parser to automatically detect implicit dependencies. Changed command options etc. General conditions are recognized. The big
makeproblem with recursion can be avoided elegantly in order to guarantee correct structures. In addition, Perl can be integrated at all levels.
- (under plan 9 ) is also developed from make , but in the direction of simplification.
Python -implemented, cross-platform system with many improvements over
make. Also integrates some features of
autoconf. Its strength comes from the fact that the Makefiles called "SConstruct" can use the entire functionality of the Python programming language.
- Apache Ant and Apache Maven
- XML -based systems with the same purpose, which can be extended with the help of Java .
- is an SCM tool with an integrated build tool.
- a build tool from the Boost library, the extension of the C ++ standard library of the C ++ programming language.
- A tool implemented in Ruby with rakefiles written in Ruby .
- A program written in Python to automate the creation of computer programs, comparable to make or Ant. In addition to the classic automation of the creation process, it also enables the location, download, installation and modification of computer programs as well as troubleshooting. AAP has an integrated connection to CVS .
- Helmut Herold: make . Addison-Wesley, ISBN 3-8273-2095-X
- Thomas Peschel-Findeisen: Make packed . Mitp-Verlag, ISBN 3-8266-1442-9
- Robert Mecklenburg: GNU make . O'Reilly, ISBN 3-89721-408-3
make(1): maintain, update, and regenerate groups of programs - Open Group Base Specification
make(1): maintain program dependencies - OpenBSD General Commands Manual
make(1): maintain program dependencies - FreeBSD General Commands Manual
make(1): GNU make utility to maintain groups of programs - Debian GNU / Linux executables or shell commands man page
- Peter Miller: Recursive Make Considered Harmful (PDF) - Describes the problems that can arise from recursive "makefiles" (which is a typical procedure).
- Advanced Auto-Dependency Generation with make
- Make7 - A portable open source make program written in Seed7 (English)
- ↑ Interview with Stu Feldman, 9-20-89, accessed November 22, 2019.
- ↑ a b c d GNU Make. Retrieved October 3, 2018 .
- ^ GNU Make: What a Rule Looks Like. Retrieved October 3, 2018 .
- ↑ a b c GNU Make: A Simple Makefile. Retrieved October 3, 2018 .
- ^ GNU Make: Old-Fashioned Suffix Rules. Retrieved October 3, 2018 .
- ^ An Introduction to the Autotools. Retrieved October 3, 2018 .
- ↑ qmake manual. Retrieved October 3, 2018 .
- ↑ About CMake. Retrieved October 3, 2018 .
- ↑ MS C / C ++: The nmake Command. Retrieved October 3, 2018 .
- ↑ Makepp home page. Retrieved October 3, 2018 .
- ↑ Apache Ant About. Retrieved October 3, 2018 .
- ↑ Welcome to Apache Maven. Retrieved October 3, 2018 .
- ↑ RAKE - Ruby Make. Retrieved October 3, 2018 .
- ↑ PyPI: Aap. Retrieved October 3, 2018 .