Specific syntax for the make command line



Last revision August 4, 2004

Table of contents:
  1. Managing programming source code with make
  2. How does make work?
  3. Specific syntax for lines in the makefile
  4. Specific syntax for the make command line

Typing
      make
as a Unix shell command causes the following actions:

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.