HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

m
make(1) make(1)
the following series of targets to be made is generated:
--- pgm
with two dependents and an explicit rule to follow
--- a.o
(recursively) with an implicit dependent of a.c
which matches the implicit rule .c.o
--- a.c
(recursively) with no implicit dependents and no implicit rules. This stops the recursion
and simply returns the last modification time of the file
a.c.
--- b.o
(recursively) with an implicit dependent of b.c which matches the implicit rule
.c.o
--- b.c
(recursively) with no implicit dependents and no implicit rules. This stops the recursion
and merely returns the last modification time of the file
b.c.
In the definitions below, the word target refers to a target specified in the makefile, an explicit dependent
specified in the makefile which becomes the target when
make recurses on it, or an implicit dependent
(generated as a result of locating an inference rule and file that match the suffix of the target) which
becomes the target when make recurses on it. The word dependent refers to an explicit dependent
specified in the makefile for a particular target, or an implicit dependent generated as a result of locating
an appropriate inference rule and corresponding file that matches the suffix of the target.
It may be helpful to think of target rules as user specified rules for a particular target name, and inference
rules as user or make specified rules for a particular class of target names. It may also be helpful to
remember that the value of the target name and its corresponding dependent names change as
make
recurses on both explicit and implicit dependents, and that inference rules are only applied to implicit
dependents or to explicit dependents which do not have target rules defined for them in the makefile.
$@ The $@ macro is the full target name of the current target, or the archive filename part of a
library archive target. It is evaluated for both target and inference rules.
$% The $% macro is only evaluated when the current target is an archive library member of
the form libname(member.o) or libname((entry)). In these cases, $@ evaluates to
libname and $% evaluates to member.o or the object file containing the symbol entry.
$% is evaluated for both target and inference rules.
$? The $? macro is the list of dependents that are out-of-date with respect to the current tar-
get; essentially, those modules that have been rebuilt. It is evaluated for both target and
inference rules, but is usually only used in target rules. $? evaluates to one name only in
an inference rule, but may evaluate to more than one name in a target rule.
$< In an inference rule, $< evaluates to the source file name that corresponds to the implicit
rule which matches the suffix of the target being made. In other words, it is the file that is
out-of-date with respect to the target. In the .DEFAULT rule, the $< macro evaluates to
the current target name. $< is evaluated only for inference rules. Thus, in the .c.o rule,
the
$< macro would evaluate to the .c file. An example for making optimized .o files
from
.c files is:
.c.o:
cc -c -O $*.c
or:
.c.o:
cc -c -O $<
$*
The macro $* is the current target name with the suffix deleted. It is evaluated only for
inference rules.
These five macros can have alternative forms. When an uppercase D or F is appended to any of the five
macros, the meaning is changed to ‘‘directory part’’ for D and ‘‘file part’’ for F. Thus, $(@D) refers to the
directory part of the string $@. If there is no directory part, ./ is generated. When the $? macro con-
tains more than one dependent name, the $(?D) expands to a list of directory name parts and the $(?F)
expands to a list of the filename parts.
In addition to the built-in macros listed above, other commonly used macros are defined by make. These
macros are used in the default inference rules, and can be displayed with the -p option. These macros can
HP-UX 11i Version 1: September 2005 8 Hewlett-Packard Company Section 1535