m

make(1)

make(1)

NAME

make - maintain, update, and regenerate groups of programs

SYNOPSIS

make [-fmake®le ] [-bBdeiknpPqrsStuw] [ macro_name=value ] [ names ]

DESCRIPTION

Make®le Structure

A make®le can contain four different kinds of lines: target lines, shell command lines, macro de®nitions, and include lines.

TARGET LINES

Target lines consist of a blank-separated, non-null list of targets, followed by a colon (:) or double colon

(::), followed by a (possibly null) list of prerequisite ®les called dependents. Pattern Matching Notation (see regexp(5)) is supported for the generation of ®le 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 commands to be executed to update the target (see the Environment section below about SHELL). The ®rst line that does not begin with a tab or # begins a new target de®nition, macro de®nition, or include line. Shell commands can be continued across lines by using a <backslash><new-line> sequence.

Target lines with their associated command lines are called rules.

MACROS

Lines of the form string1 = string2 are macro de®nitions. Macros can be de®ned anywhere in the make®le, but are usually grouped together at the beginning. string1 is the macro name; string2 is the macro value. string2 is de®ned as all characters up to a comment character or an unescaped new-line. Spaces and tabs immediately to the left and right of the = are ignored. Subsequent appearances of $(string1) anywhere in the make®le (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 substitute sequence, $(string1 [:subst1=[ subst2 ] ]) can be speci®ed, 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, new-line 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 WARNINGS):

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 de®nition further down in the make®le or on the command line, any references to $(TWELVE) re¯ect this change.

Macro de®nitions can also be speci®ed on the command line and override any de®nitions in the make®le.

(XPG4 only. Macros on the command line are added to the MAKEFLAGS environment variable. Macros de®ned in the MAKEFLAGS environment variable, but without any command line macro, adds the macro to the environment overwriting any existing environment variable of the same name.)

Certain macros are automatically de®ned for make (see Built-in Macros). See the Environment section for a discussion of the order in which macro de®nitions are treated.

The value assigned to a macro can be overridden by a conditional macro de®nition. A conditional macro de®nition takes on the form target := string1 = string2. When the target line associated with target is being processed, the macro value speci®ed in the conditional macro de®nition is in effect. If string1 is previously de®ned, the new value of string1 will override the previous de®nition. The new value of string1 takes effect when target or any dependents of target are being processed.

Section 1508

− 1 −

HP-UX Release 11i: December 2000