Noeud:Invoking Make, Noeud « Next »:Further Reading, Noeud « Previous »:Multiple Directories, Noeud « Up »:GNU Make
The majority of the time, with the hard work already expended in
creating a Makefile
, employing that file to refresh build targets
is no more complicated than this:
$ make target
This being the GNU system though, you can of course do so much
more. There are many command line options that affect the way that
GNU Make behaves, which you can always get a summary of by running
make --help
from the command line. We will describe a useful
subset in this section, but you can find comprehensive details in
The Gnu Make Manual that ships with GNU Make.
-I
directory
include
directive.
-f
file-name
Makefile
, file-name
will be read instead.
-n
-n
option to have Make
display those commands but not execute them.
-k
One of the most useful facilities is being able to override Make
variable values from the command line: With this feature you can set
your Makefile variable to perform a production build of your project
(say, maximum optimisation, create shared libraries, minimum debug code
enabled), but specify more appropriate values on the command line during
development. So, in our Makefile
we would specify the following:
CFLAGS = -O6 CPPFLAGS =
Example 5.31: Production build values for compilation flags
But during development, by invoking Make as follows, change the values of those Make variables for the current build:
$ make CFLAGS='-ggdb3 -Wall' CPPFLAGS='-DDEBUG=9' m4
Do be aware that it is easy to end up with a set of mismatched objects,
compiled with different flags if you keep changing the override values
without performing a complete build. To avoid doing this accidentally,
you should probably run make clean
between changes to the override
settings. Unless you really do want to compile just a few objects with
different build options for some reason...