Linux Command Directory
This directory of Linux commands is from Linux in a Nutshell, 5th Edition.
Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.
make [options] [targets] [macro definitions]
Update one or more targets according to dependency instructions in a description file in the current directory. By default, this file is called makefile or Makefile. Options, targets, and macro definitions can be in any order. Macro definitions are typed as:
For more information on make, see Managing Projects with GNU Make (O'Reilly).
Print detailed debugging information.
Override Makefile macro definitions with environment variables.
Use Makefile as the description file; a filename of - denotes standard input.
Print options to make command.
Ignore command error codes (same as .IGNORE).
Attempt to execute this many jobs simultaneously or, if no number is specified, as many jobs as possible.
Abandon the current target when it fails, but keep working with unrelated targets.
Attempt to keep load below load, which should be a floating-point number. Used with -j.
Print commands but don't execute (used for testing).
Never remake file or cause other files to be remade on account of it.
Print rules and variables in addition to normal execution.
Query; return 0 if file is up to date, nonzero otherwise.
Do not use default rules.
Do not display command lines (same as .SILENT).
Touch the target files without remaking them.
Show version of make.
Display the current working directory before and after execution.
Print warning if a macro is used without being defined.
cd to directory before beginning make operations. A subsequent -C directive will cause make to attempt to cd into a directory relative to the current working directory.
Include directory in list of directories containing included files.
Cancel previous -k options. Useful in recursive makes.
Behave as though file has been recently updated.
Instructions in the description file are interpreted as single lines. If an instruction must span more than one input line, use a backslash (\) at the end of the line so that the next line is considered a continuation. The description file may contain any of the following types of lines:
Blank lines are ignored.
A pound sign (#) can be used at the beginning of a line or anywhere in the middle. make ignores everything after the #.
Depending on one or more targets, certain commands that follow will be executed. Possible formats include:
targets : dependencies targets : dependencies ; command
Subsequent commands are executed if dependency files (the names of which may contain wildcards) do not exist or are newer than a target. If no prerequisites are supplied, then subsequent commands are always executed (whenever any of the targets are specified). No tab should precede any targets.
Conditionals are evaluated when the
Makefileis first read and determine what make sees—i.e., which parts of the Makefileare obeyed and which parts are ignored. The general syntax for a conditional is:
conditional Text if true else Text if false endif
True if the two arguments are identical. The arguments should either be placed in parentheses and separated by a comma--(arg1, arg2)--or individually quoted with either single or double quotes.
True if the two arguments are not identical. The arguments should either be placed in parentheses and separated by a comma, or individually quoted with either single or double quotes.
True if variable has a nonempty value.
True if variable has an empty value.
These specify that files ending with the first suffix can be prerequisites for files ending with the second suffix (assuming the root filenames are the same). Either of these formats can be used:
The second form means that the root filename depends on the filename with the corresponding suffix.
Commands are grouped below the dependency line and are typed on lines that begin with a tab. If a command is preceded by a hyphen (-), make ignores any error returned. If a command is preceded by an at sign (@), the command line won't echo on the display (unless make is called with -n).
These have the following form:
name = string
define name string endef
Blank space is optional around the =.
Similar to the C include directive, these have the form:
The list of prerequisites that have been changed more recently than the current target. Can be used only in normal description-file entries, not in suffix rules.
The name of the current target, except in description-file entries for making libraries, where it becomes the library name. Can be used both in normal description-file entries and in suffix rules.
The name of the current prerequisite that has been modified more recently than the current target.
The name (without the suffix) of the current prerequisite that has been modified more recently than the current target. Can be used only in suffix rules.
The name of the corresponding .o file when the current target is a library module. Can be used both in normal description-file entries and in suffix rules.
A space-separated list of all dependencies with no duplications.
A space-separated list of all dependencies, which includes duplications.
These are a more general application of the idea behind suffix rules. If a target and a dependency both contain %, GNU make will substitute any part of an existing filename. For instance, the standard suffix rule:
$(cc) -o $@ $<
can be written as the following pattern rule:
%.o : %.c $(cc) -o $@ $<
The directory portion of any internal macro name except $?. Valid uses are:
$(*D) $$(@D) $(?D) $(<D) $(%D) $(@D) $(^D)
The file portion of any internal macro name except $?. Valid uses are:
$(*F) $$(@F) $(?F) $(<F) $(%F) $(@F) $(^F)
Replace all occurrences of from with to in string.
Similar to subst, but treat % as a wildcard within pattern. Substitute to for any word in string that matches pattern.
Remove all extraneous whitespace.
Return substring if it exists within mainstring; otherwise, return null.
Return those words in string that match at least one word in pattern. pattern may include the wildcard %.
Remove those words in string that match at least one word in pattern. pattern may include the wildcard %.
Return list, sorted in lexical order.
Return the directory part (everything up to the last slash) of each filename in list.
Return the nondirectory part (everything after the last slash) of each filename in list.
Return the suffix part (everything after the last period) of each filename in list.
Return everything but the suffix part (everything up to the last period) of each filename in list.
Return each filename given in list with suffix appended.
Return each filename given in list with prefix prepended.
Return a list formed by concatenating the two arguments word by word (e.g., $(join a b,.c .o) becomes a.c b.o).
Return the nth word of string.
Return words in string between word start and word end, inclusive.
Return the number of words in string.
Return the first word in the list list.
Return a list of existing files in the current directory that match pattern.
For each whitespace-separated word in list, expand its value and assign it to variable; then expand string, which usually contains a function referencing variable. Return the list of results.
Expand string condition if it expands to a nonempty string, then expand the then-string. If condition expands to an empty string, return the empty string or, if specified, expand and return the else-string.
Expand each item in comma-separated list parameters and assign it to a temporary variable, $(n), where n is an incremented number beginning with 0. Then expand variable, a string referencing these temporary variables, and return the result.
Return one of the following strings that describes how variable was defined: undefined, default, environment, environment override, file, command line, override, or automatic.
Return the results of command. Any newlines in the result are converted to spaces. This function works similarly to backquotes in most shells.
When evaluated, generate a fatal error with the message string.
When evaluated, generate a warning with the message string.
Macro string substitution
Evaluates to the current definition of $(macro), after substituting the string s2 for every occurrence of s1 that occurs either immediately before a blank or tab, or at the end of the macro definition.
Special target names
Commands associated with this target are executed if make can't find any description-file entries or suffix rules with which to build a requested target.
If this target exists in a Makefile, delete the target of any rule whose commands return a nonzero exit status.
If this target exists, export all macros to all child processes.
Ignore error codes. Same as the -i option.
This target's dependencies should be treated as intermediate files.
If this target exists in a Makefile, run make serially, ignoring option -j.
Always execute commands under a target, even if it is an existing, up-to-date file.
Files you specify for this target are not removed when you send a signal (such as an interrupt) that aborts make or when a command line in your description file returns an error.
Like .INTERMEDIATE, this target's dependencies should be treated as intermediate files, but never automatically deleted.
Execute commands, but do not echo them. Same as the -s option.
Suffixes associated with this target are meaningful in suffix rules. If no suffixes are listed, the existing list of suffix rules is effectively "turned off."