Command Reference Guide

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1/!!!intro.1
________________________________________________________________
___ ___
m
make(1) make(1)
The most common use of the archive interface follows. Here, we assume the source files are all C type
source:
lib: lib(file1.o) lib(file2.o) lib(file3.o)
@echo lib is now up-to-date
.c.a:
$(CC) -c $(CFLAGS) $<
ar rv $@ $*.o
rm -f $*.o
(See the section on Built-in Macros for an explanation of the <, @, and * symbols.) In fact, the .c.a rule
listed above is built into make and is unnecessary in this example. This rule is applied to each dependent
of lib in turn. The following example accomplishes this more efficiently:
lib: lib(file1.o) lib(file2.o) lib(file3.o)
$(CC) -c $(CFLAGS) $(?:.o=.c)
ar rv lib $?
rm $?
@echo lib is now up-to-date
.c.a:;
Here substitution in the macros is used. The $?
list is defined to be the set of object file names (inside
lib) whose C source files are out-of-date. The substitution sequence translates the .o to .c. (Unfor-
tunately, one cannot as yet transform to
.c˜; however, this may become possible in the future.) Note also,
the disabling of the .c.a rule, which would have created and archived each object file, one by one. This
particular construct speeds up archive library maintenance considerably, but becomes very cumbersome if
the archive library contains a mix of assembly programs and C programs.
Archive members containing the definition of a symbol are designated by double parentheses around the
symbol name, lib((entry_name)), but are otherwise handled as described above.
Built-In Targets
make has knowledge about some special targets. These must be specified in the makefile to take effect
(with the exception of .SUFFIXES, which is automatically set by
make but can be changed by the user).
.DEFAULT If a file must be made but there are no explicit commands or relevant built-in rules for
it, the commands associated with the target name .DEFAULT are used if .DEFAULT
has been defined in the makefile. .DEFAULT does not have any explicit dependents.
.PRECIOUS Dependents of this target are not removed when QUIT, INTERRUPT, TERMINATE,
or
HANGUP are received.
.SILENT Same effect as the -s option. No dependents or explicit commands need to be
specified.
.IGNORE Same effect as the -i option. No dependents or explicit commands need to be
specified.
.SUFFIXES The explicit dependents of .SUFFIXES are added to the built-in list of known
suffixes and are used in conjunction with the inference rules. If .SUFFIXES does not
have any dependents, the list of known sufxes is cleared. There are no commands
associated with .SUFFIXES.
.MUTEX Serialize the updating of specified targets (See the Parallel Make Section).
Built-in Macros
There are five internally maintained macros that are useful for writing rules for building targets. In order
to clearly define the meaning of these macros, some clarification of the terms target and dependent is
necessary. When
make updates a target, it may actually generate a series of targets to update. Before
any rule (either explicit or implicit) is applied to the target to update it, recursion takes place on each
dependent of the target. The dependent, upon recursion, becomes a target itself, and may have or generate
its own dependents, which in turn are recursed upon until a target is found that has no dependents, at
which point the recursion stops. Not all targets processed by make appear as explicit targets in the
makefile; some of them are explicit dependents from the makefile while others are implicit dependents gen-
erated as make recursively updates the target. For instance, when the following makefile is executed:
pgm: a.o b.o
cc a.o b.o -o pgm
Section 1514 7 HP-UX Release 11i: December 2000
___
___