Datasheet
542
Exploring the Software-Development Tools in Linux
Even when you have a makefile with a default name such as Makefile,
you may want to build a specific target out of several targets defined in the
makefile. In that case, you have to use the following syntax when you run
make:
make target
For example, if the makefile contains the target named clean, you can
build that target with this command:
make clean
Another special syntax overrides the value of a make variable. For example,
GNU make uses the CFLAGS variable to hold the flags used when compiling
C files. You can override the value of this variable when you invoke make.
Here’s an example of how you can define CFLAGS as the option -g -O2:
make CFLAGS=”-g -O2”
In addition to these options, GNU make accepts several other command-line
options. Table 1-3 lists the GNU make options.
Table 1-3 Options for GNU make
Option Meaning
-b
Ignores the variable given but accepts that variable for compatibil-
ity with other versions of make.
-C DIR Changes to the specified directory before reading the makefile.
-d
Prints debugging information.
-e
Allows environment variables to override definitions of similarly
named variables in the makefile.
-f FILE Reads FILE as the makefile.
-h Displays the list of make options.
-i
Ignores all errors in commands executed when building a target.
-I DIR Searches the specified directory for included makefiles.
(The capability to include a file in a makefile is unique to GNU
make.)
-j NUM Specifies the number of commands that the make command can
run simultaneously.
-k
Continues to build unrelated targets, even if an error occurs when
building one of the targets.
-l LOAD Doesn’t start a new job if load average is at least LOAD (a floating-
point number).
42_770191-bk08ch01.indd 54242_770191-bk08ch01.indd 542 8/6/10 9:51 AM8/6/10 9:51 AM