Specific syntax for the make command line
Last revision August 4, 2004
Table of contents:
|
Typing
make
as a Unix shell command causes the following actions:
- make reads the script in the file named makefile in the current directory, if it exists; otherwise it reads the file named Makefile, if it exists. If neither exists, it quits with an error.
- After processing macro definitions, target dependencies and commands in the makefile, make chooses the first target in the file as its objective and recreates the generators and the target as necessary. If that target is already fully up to date, make just prints a message.
Two of the things that you would like to be able to do are to specify a different filename for the makefile and to specify a target other than the first in the file.
Use the -f option followed by a filename to specify a different
filename for the makefile, for example:
make -f makefile.test
To specify a target or targets to process, other than the default first target,
just give the target names (no colons) on the command line after make.
Examples:
make prog1 prog2
make clean
You can also specify macro definitions on the command line to override those in
the makefile.
Use the syntax
macroname=string_of_characters
right on the command
line, but enclose the whole thing in quotes so the shell does not try to
process metacharacters or split at embedded blanks.
Example:
make 'LIBS= -lvplot -lloc'
would override the specification
LIBS = -lloc
that was already in a makefile.
There are other options described in the make documentation. One useful one is -n which shows which commands make would execute, but does not actually execute them. This allows you to preview what make would do.