Make

make is a traditional Logiciel of UNIX. It is a “Moteur of production”: it is used to call orders creating of the files. With the difference of a simple script Shell, make carries out the orders only if it are necessary. The goal is to arrive at a result (software compiled or installed, documentation created, etc) without necessarily remaking all the stages.

Operation

It is mainly used to facilitate the compilation and the linkage editing since in this process the end result depends on preceding operations.

With this intention, make uses a file of configuration called makefile which often bears the name of Makefile . This last describes target (which are often files, but not always), on which others target they depends, and by which actions (of the orders) to reach that point.

In order to rebuild a target specified by the user, make will seek the targets necessary to the rebuilding of this target, and this recursively. (By doing this, it creates in fact a topological Tri of the relation of dependence on the targets.) Certain alternatives of make envisage the possibility of execution in parallel of the tasks, if possible.

The rules of dependence can be explicit (file names given explicitly) or implicit (via reasons for files; for example file .o depends on file .c, if this one exists, via a recompiling).

History

make in the beginning was developed by the doctor Stuart Feldman, in 1977. This last worked then for Bell Labs.

Since, several derivatives were developed, the most known and used are those of BSD and that of GNU, this last being generally that used by defect with the systems Linux. They differ by certain functionalities, and for example the scripts planned for GNU Make can not function under BSD Make.

Nowadays, the Makefile files are more and more seldom generated with the hand by the developer but built starting from automatic tools such as Autoconf which facilitate the generation of Makefile complexes and specifically adapted to the environment in which the actions of production are supposed to be carried out.

Example of Makefile

Here an example of Makefile:

# To indicate which compiler is to be used DC? = GCC # To specify the options of the compiler CFLAGS? = - G LDFLAGS? = - L/usr/openwin/lib LDLIBS? = - lX11 - lXext # To recognize the Extension of file name *.c and *.o like suffix SUFFIXES? = .c .o .SUFFIXES: $ (SUFFIXES). # Name of the achievable one PROG = life # Lists files objects necessary for the final program OBJS = main.o window.o Board.o Life.o BoundedBoard.o all: $ (PROG) # Stage of compilation and linkage editings $ (PROG): $ (OBJS) $ (DC) $ (CFLAGS) $ (LDFLAGS) $ (LDLIBS) - O $ (PROG) $ (OBJS) .c.o: $ (DC) $ (CFLAGS) - C $*.c

In this example, .c.o is an implicit rule. By defect the targets are files, but when it is the juxtaposition of two suffixes, it is a rule which derives any file ending in the second suffix starting from a file bearing the same name but ending in the first suffix.

To arrive to this target, it is necessary to carry out the action, the order $ (DC) $ (CFLAGS) - C $*.c, where $* represents the name of the file without suffix.

all , on the other hand, is a target which depends on $ (PROG) (and thus of life , which is a file).

$ (PROG) - i.e. life - is a target which depends on $ (OBJ) (and thus of main.o window.o Board.o Life.o and BoundedBoard.o ). For that purpose, the action is to carry out the order $ (DC) $ (CFLAGS) $ (LDFLAGS) $ (LDLIBS) - O $ (PROG) $ (OBJS)

Syntax DC? = GCC , or more generally ? = , assigns to only if does not have of them already one. If were already affected, this instruction does not have any effect.

Limitations

The limitations of make rise directly from the simplicity of the concepts which popularized it: files and dates. These criteria are indeed insufficient to guarantee at the same time the effectiveness and reliability.

The criterion of date associated with files with him only cumulates the two defects. Unless the file resides on a nonrewriteable support nothing ensures that the date of a file is indeed the date of its last modification.

So for a nonprivileged user it is assured that the data cannot be posterior at the date indicated, the exact date of their anteriority therefore is not guaranteed.

Thus with the least change of date of a file a whole production perhaps considered necessary if it is about a worse source but still considered useless if on the contrary it is about a target.

  • In the first case there is loss of effectiveness.
  • In the second case there is loss of reliability.

If date and file remain essentially necessary to any engine of reliable and optimal production desired, they are not either sufficient and some particular examples are enough to illustrate it:

  • Make in him even is unaware of completely the semantics of the files whose it ensures the treatment, it is unaware of the contents quite simply of it. Thus, for example, no distinction is made between useful code and comments. As in the case of the addition or even only of the modification of a comment within a file C make will consider as target libraries or programs which depend on it will have to be refabriqués.

  • If the end result depends on the input data, it depends as much on the treatments applied. These treatments are described in the file Makefile. Rare are the writings of files makefile which envisage to invalidate any production before carried out in the case of evolution of the file makefile; indeed with this intention it would be advisable systematically to put the file makefile in dependence of all the rules of production which he defines itself. If it is technically not difficult to consider that can be directly carried out by an alternative of make that would have as an effect edge to touch all the targets even if they are not concerned with the modifications operated in the makefile.
  • an alternative of the preceding example is the case where variables governing the production are positioned either by variables of environment or via the line of order. There still, make does not have any means of detecting if these variables touch or not the production and in particular when these variables indicate options and not files.

It is for these reasons that the engines of productions of new generation specialize in the treatment of particular languages (semantic of the contents of the files) or is still coupled with a database in which are recorded all the effective characteristics of production (audit of production) of the targets (traceability).

Alternatives

There exist several alternatives to make:
  • Makepp : a derivative of (GNU) make, but which offers in more one extensible analyzer of orders and files included in order to recognize the dependences automatically. The options of changed orders and other influences are recognized. The major recursive problem of make can be easily avoided, to guarantee a correct construction. In more Perl is accessible on all the levels. * ant: rather related to the world Java.
  • SCons : completely different from make, it includes some of the functions of tool for compilation like autoconf. One can use Python to extend the tool.
  • Speedy Make uses XML for the makefiles, very simple to write, offers more automatisms than make.

Random links:Justine or Misfortunes of the virtue | Božidar Maljković | Canton of Saint-Gratien | François Perigot | Jose Iván Gutierrez Palacios | Alastair_Reynolds