16.2. Command-Line Syntax

 < Day Day Up > 

The make program is invoked as follows:

     make  [options  ]  [targets]  [macro definitions]

Options, targets, and macro definitions can appear in any order. The last assignment to a variable is the one that's used. Macro definitions are typed as:

     name=string

or

     name:=string

For more information, see the section "Creating and Using Macros," later in this chapter.

If no GNUmakefile, makefile, or Makefile exists, make attempts to extract the most recent version of one from either an RCS file, if one exists, or from an SCCS file, if one exists. Note though, that if a real makefile exists, make will not attempt to extract one from RCS or SCCS, even if the RCS or SCCS file is newer than the makefile.

16.2.1. Options

Like just about every other GNU program, GNU make has both long and short options. The available options are as follows:


-b

Silently accepted, but ignored, for compatibility with other versions of make.


-B, --always-make

Treat all targets as out of date. All targets are remade, no matter what the actual status is of their prerequisites.


-C dir, --directory=dir

Change directory to dir before reading makefiles. With multiple options, each one is relative to the previous. This is usually used for recursive invocations of make.


-d

Print debugging information in addition to regular output. This information includes which files are out of date, the file times being compared, the rules being used to update the targets, and so on. Equivalent to --debug=a.


--debug[= debug-opt]

Print debugging information as specified by debug-opt, which is one or more of the following letters, separated by spaces or commas. With no argument, provide basic debugging.

a

All. Enable all debugging.

b

Basic. Print each target that is out of date, and whether or not the build was successful.

i

Implicit. Like basic, but include information about the implicit rules searched for each target.

j

Jobs. Provide information about subcommand invocation.

m

Makefiles. Enable basic debugging, and any of the other options, for description of attempts to rebuild makefiles. (Normally, make doesn't print information about its attempts to rebuild makefiles.)

v

Verbose. Like basic, but also print information about which makefiles were read, and which prerequisites did not need to be rebuilt.



-e, --environment-overrides

Environment variables override any macros defined in makefiles.


-f file, --file=file, --makefile=file

Use file as the makefile; a filename of - denotes standard input. -f can be used more than once to concatenate multiple makefiles. With no -f option, make first looks for a file named GNUmakefile, then one named makefile, and finally one named Makefile.


-h, --help

Print a usage summary, and then exit.


-i, --ignore-errors

Ignore error codes from commands (same as .IGNORE).


-I dir, --include-dir=dir

Look in dir for makefiles included with the include directive. Multiple options add more directories to the list; make searches them in order.


-j [count], --jobs[= count]

Run commands in parallel. With no count, make runs as many separate commands as possible. (In other words, it will build all the targets that are independent of each other, in parallel.) Otherwise, it runs no more than count jobs. This can decrease the time it takes to rebuild a large project.


-k, --keep-going

Abandon the current target when it fails, but keep working with unrelated targets. In other words, rebuild as much as possible.


-l [load], --load-average[= load], --max-load[= load]

If there are jobs running and the system load average is at least load, don't start any new jobs running. Without an argument, clear a previous limit. The load value is a floating point number.


-m

Silently accepted, but ignored, for compatibility with other versions of make.


-n, --dry-run, --just-print, --recon

Print commands but don't execute (used for testing). -n prints commands even if they begin with @ in the makefile.

Lines that contain $(MAKE) are an exception. Such lines are executed. However, since the -n is passed to the subsequent make in the MAKEFLAGS environment variable, that make also just prints the commands it executes. This allows you to test out all the makefiles in a whole software hierarchy without actually doing anything.


--no-print-directory

Don't print the working directory as make runs recursive invocations. Useful if -w is automatically in effect but you don't want to see the extra messages.


-o file, --assume-old= file, --old-file= file

Pretend that file is older than the files that depend upon it, even if it's not. This avoids remaking the other files that depend on file. Use this in cases where you know that the changed contents of file will have no effect upon the files that depend upon it; e.g., changing a comment in a header file.


-p, --print-data-base

Print macro definitions, suffixes, and built-in rules. In a directory without a makefile, use env -i make -p to print out the default variable definitions and built-in rules.


-q, --question

Query; return 0 if the target is up to date; nonzero otherwise.


-r, --no-builtin-rules

Do not use the default rules. This also clears out the default list of suffixes and suffix rules.


-s, --quiet, --silent

Do not display command lines (same as .SILENT).


-S, --no-keep-going, --stop

Cancel the effect of a previous -k. This is only needed for recursive make invocations, where the -k option might be inherited via the MAKEFLAGS environment variable.


-t, --touch

Touch the target files, causing them to be updated.


-v, --version

Print version, copyright, and author information, and exit.


-w, --print-directory

Print the working directory, before and after executing the makefile. Useful for recursive make invocations. This is usually done by default, so it's rare to explicitly need this option.


--warn-undefined-variables

Print a warning message whenever an undefined variable is used. This is useful for debugging complicated makefiles .


-W file, --assume-new= file, --new-file= file, --what-if= file

Treat file as if it had just been modified. Together with -n, this lets you see what make would do if file were modified, without actually doing anything. Without -n, make pretends that the file is freshly updated, and acts accordingly.

     < Day Day Up > 


    Unix in a Nutshell
    Unix in a Nutshell, Fourth Edition
    ISBN: 0596100299
    EAN: 2147483647
    Year: 2005
    Pages: 201

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