1.4 Invoking make

     

The previous examples assume that:

  • All the project source code and the make description file are stored in a single directory.

  • The make description file is called makefile , Makefile , or GNUMakefile .

  • The makefile resides in the user 's current directory when executing the make command.

When make is invoked under these conditions, it automatically creates the first target it sees. To update a different target (or to update more than one target) include the target name on the command line:

 $  make lexer.c  

When make is executed, it will read the description file and identify the target to be updated. If the target or any of its prerequisite files are out of date (or missing) the shell commands in the rule's command script will be executed one at a time. After the commands are run make assumes the target is up to date and moves on to the next target or exits.

If the target you specify is already up to date, make will say so and immediately exit, doing nothing else:

 $  make lexer.c  make: `lexer.c' is up to date. 

If you specify a target that is not in the makefile and for which there is no implicit rule (discussed in Chapter 2), make will respond with:

 $  make non-existent-target  make: *** No rule to make target `non-existent-target'.  Stop. 

make has many command-line options. One of the most useful is ”just-print (or -n ) which tells make to display the commands it would execute for a particular target without actually executing them. This is particularly valuable while writing makefile s. It is also possible to set almost any makefile variable on the command line to override the default value or the value set in the makefile .



Managing Projects with GNU make
Managing Projects with GNU Make (Nutshell Handbooks)
ISBN: 0596006101
EAN: 2147483647
Year: 2003
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net