Command Reference Guide

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man1/!!!intro.1
________________________________________________________________
___ ___
m
make(1) make(1)
A tilde in the above rules refers to an SCCS file (see sccsfile(4)). Thus, the rule .c˜.o would transform an
SCCS C source file into an object file (.o). Since the s. of the SCCS files is a prefix, it is incompatible
with make’s sufx point-of-view. Hence, the tilde is a way of changing any file reference into an SCCS file
reference.
A rule to create a file with suffix .o from a file with suffix .c is specified as an entry with .c.o as the tar-
get and no dependents. Shell commands associated with the target define the rule for making a .o file
from a .c file. Any target name that has no slashes in it and starts with a dot is identified as an inference
(implicit) rule instead of a target (explicit) rule. Targets with one dot are single suffix inference rules;
targets with two dots are double suffix inference rules. Users can, in a makefile, define additional inference
rules and either redefine or cancel default inference rules.
The default inference rule for changing a .c file into a .o file might look like this:
.c.o:
$(CC) $(CFLAGS) -c $<
and the default inference rule for changing a yacc file to a C object file might look like this:
.y.o:
$(YACC) $(YFLAGS) $<
$(CC) $(CFLAGS) -c y.tab.c
rm y.tab.c
mv y.tab.o $@
Certain macros are used in the default inference rules to permit the inclusion of optional matter in any
resulting commands. For example, CFLAGS, LDFLAGS, and YFLAGS are used for compiler options to
cc(1), lex(1), and yacc(1), respectively.
LDFLAGS is commonly used to designate linker/loader options.
These macros are automatically defined by
make but can be redefined by the user in the makefile.
The macro
LIBS is, by convention, used to specify the order of inclusion of any special libraries during the
linking phase of compilation. To specify a particular order of inclusion for a particular set of libraries, the
existing single suffix rule for a .c file,
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
can be redefined as
$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ $(LIBS)
as well as defining LIBS in the makefile.
There are also some special built-in macros used in the inference rules (@, <). See the Built-in Macros sec-
tion.
If a target does not have explicit dependents, or if a dependent does not also have a target that matches it
with associated explicit rules,
make looks for the first inference rule that matches both the target’s
(dependent’s) suffix (which may be null) and a file which matches the other suffix of the rule. Since it con-
ducts this search by going through the list of .SUFFIXES values front to back, the order in which .SUF-
FIXES
is defined is significant.
To print out the rules compiled into the make on any machine, type:
make -fp - 2>/dev/null </dev/null
Since make defines an inference rule .c.o, the example in the General Description section can be rewrit-
ten more simply:
OBJS = a.o b.o
pgm: $(OBJS)
cc $(OBJS) -o pgm
$(OBJS): incl.h
Libraries
If a target or dependent name contains parentheses, it is assumed to be an archive library, the string
within parentheses referring to a member within the library. Thus lib(file.o) and
$(LIB)(file.o) both refer to an archive library that contains file.o (this assumes the LIB macro
has been previously defined). The expression $(LIB)(file1.o file2.o)
is not valid. Rules per-
taining to archive libraries have the form
.xx.a where xx is the suffix from which the archive member is to
be made. An unfortunate byproduct of the current implementation requires the xx to be different from the
suffix of the archive member. Thus, one cannot have
lib(file.o) depend upon file.o explicitly.
HP-UX Release 11i: December 2000 6 Section 1513
___
___