make(1)

make(1)

A tilde in the above rules refers to an SCCS ®le (see sccs®le(4)). Thus, the rule .cÄ.o would transform an SCCS C source ®le into an object ®le (.o). Since the s. of the SCCS ®les is a pre®x, it is incompatible with make's suf®x point-of-view. Hence, the tilde is a way of changing any ®le reference into an SCCS ®le reference.

A rule to create a ®le with suf®x .o from a ®le with suf®x .c is speci®ed as an entry with .c.o as the target and no dependents. Shell commands associated with the target de®ne the rule for making a .o ®le from a .c ®le. Any target name that has no slashes in it and starts with a dot is identi®ed as an inference (implicit) rule instead of a target (explicit) rule. Targets with one dot are single suf®x inference rules; targets with two dots are double suf®x inference rules. Users can, in a make®le, de®ne additional inference rules and either rede®ne or cancel default inference rules.

The default inference rule for changing a .c ®le into a .o ®le might look like this:

.c.o:

$(CC) $(CFLAGS) -c $<

and the default inference rule for changing a yacc ®le to a C object ®le 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 de®ned by make but can be rede®ned by the user in the make®le.

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 suf®x rule for a .c ®le,

$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@

can be rede®ned as

$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ $(LIBS)

as well as de®ning LIBS in the make®le.

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 ®rst inference rule that matches both the target's (dependent's) suf®x (which may be null) and a ®le which matches the other suf®x of the rule. Since it conducts this search by going through the list of .SUFFIXES values front to back, the order in which .SUF- FIXES is de®ned is signi®cant.

To print out the rules compiled into the make on any machine, type:

make -fp - 2>/dev/null </dev/null

Since make de®nes an inference rule .c.o, the example in the General Description section can be rewritten 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 de®ned). The expression $(LIB)(file1.o file2.o) is not valid. Rules pertaining to archive libraries have the form .xx.a where xx is the suf®x from which the archive member is to be made. An unfortunate byproduct of the current implementation requires the xx to be different from the suf®x 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

m