make.1 (2010 09)

m
make(1) make(1)
NAME
make - maintain, update, and regenerate groups of programs
SYNOPSIS
make [-f makefile][
-bBdeiknpPqrsStuw
][macro_name=value ][names]
DESCRIPTION
Makefile Structure
A makefile can contain four different kinds of lines: target lines, shell command lines, macro definitions,
and include lines.
Target Lines
Target lines consist of a blank-separated, nonnull list of targets, followed by a colon (
:) or double colon
(
::), followed by a (possibly null) list of prerequisite files called dependents. Pattern Matching Nota-
tion (see regexp (5)) is supported for the generation of file names as dependents.
Shell Command Lines
Text following a semicolon (
;) on a target line, and all following lines that begin with a tab are shell com-
mands to be executed to update the target (see the Environment subsection below about
SHELL). The
first line that does not begin with a tab or
# begins a new target definition, macro definition, or include
line. Shell commands can be continued across lines by using a <backslash><newline> sequence.
Target lines with their associated command lines are called rules .
Macros
Lines of the form string1
= string2 are macro definitions. Macros can be defined anywhere in the
makefile, but are usually grouped together at the beginning. string1 is the macro name; string2 is the
macro value. string2 is defined as all characters up to a comment character or an unescaped newline.
Spaces and tabs immediately to the left and right of the
= are ignored. Subsequent appearances of
$(string1 ) anywhere in the makefile (except in comments) are replaced by string2 . The parentheses are
optional if a single character macro name is used and there is no substitute sequence. An optional substi-
tute sequence,
$(string1 [:subst1 =[subst2 ]]) can be specified, which causes all nonoverlapping
occurrences of subst1 at the end of substrings in the value of string1 to be replaced by subst2 . Substrings
in a macro value are delimited by blanks, tabs, newline characters, and beginnings of lines. For example,
if
OBJS = file1.o file2.o file3.o
then
$(OBJS:.o=.c)
evaluates to
file1.c file2.c file3.c
Macro values can contain references to other macros (see the WARNINGS section):
ONE =1
TWELVE = $(ONE)2
The value of $(TWELVE) is set to $(ONE)2 but when it is used in a target, command, or include line, it
is expanded to 12. If the value of ONE is subsequently changed by another definition further down in the
makefile or on the command line, any references to $(TWELVE) reflect this change.
Macro definitions can also be specified on the command line and override any definitions in the makefile.
(UNIX Standard only, see standards (5). Macros on the command line are added to the
MAKEFLAGS
environment variable. Macros defined in the MAKEFLAGS environment variable, but without any com-
mand line macro, adds the macro to the environment overwriting any existing environment variable of
the same name.)
Certain macros are automatically defined for
make (see Built-in Macros). See the Environment subsec-
tion for a discussion of the order in which macro definitions are treated.
The value assigned to a macro can be overridden by a conditional macro definition. A conditional macro
definition takes on the form target
:= string1 = string2. When the target line associated with target is
being processed, the macro value specified in the conditional macro definition is in effect. If string1 is
previously defined, the new value of string1 will override the previous definition. The new value of
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (12 pages)