make(1)

make(1)

INCLUDE LINES

If the string include appears as the ®rst seven letters of a line in a make®le, and is followed by one or more space or tab characters, the rest of the line is assumed to be a ®le name and is read and processed by the current invocation of make as another make®le after any macros in the ®lename have been expanded.

The default behaviour of make is to use .DEFAULT built-in target, if target does not have explicit commands associated with it and .DEFAULT target is de®ned. See the Built-In Targets Section.

General Description

make executes commands previously placed in a make®le to update one or more target names. Target names are typically names of programs. If no -foption is speci®ed, the ®lenames makefile, Makefile, s.makefile, SCCS/s.makefile, s.Makefile and SCCS/s.Makefile are tried in that order. If -f - is speci®ed, the standard input is used. More than one -foption can be speci®ed. The make®le arguments are processed in the order speci®ed. A space between the -fand the ®lename must be present, and multiple make®le names must each have their own -foption preceding them. The contents of a make®le override the built-in rules and macros if they are present.

If no target names are speci®ed on the command line, make updates the ®rst target in the (®rst) make®le that is not an inference rule. A target is updated only if it depends on ®les that are newer than the target. Missing ®les are deemed to be out-of-date. All dependents of a target are recursively updated, if necessary, before the target is updated. This effects a depth-®rst update of the dependency tree for the target.

If a target does not have any dependents speci®ed after the separator on the target line (explicit dependents ), any shell commands associated with that target are executed if the target is out-of-date.

A target line can have either a single or double colon between the target name or names and any explicit dependent names. A target name can appear on more than one target line, but all of those lines must be of the same (single- or double-colon) type. For the usual single-colon case, at most one of these target lines can have explicit commands associated with it. If the target is out-of-date with any of its dependents on any of the lines, the explicit commands are executed, if they are speci®ed, or else a default rule can be exe- cuted. For the double-colon case, explicit commands can be associated with more than one of the target lines containing the target name; if the target is out-of-date with any of the dependents on a particular line, the commands for that line are executed. A built-in rule may also be executed.

Target lines and their associated shell command lines are also referred to as rules. Hash marks (#) and new-line characters surround comments anywhere in the make®le except in rules. Comments in the rules depend on the setting of the SHELL macro.

The following make®le says that pgm depends on two ®les: a.o and b.o, and that they in turn depend on their corresponding source ®les (a.c and b.c) and a common ®le incl.h:

OBJS = a.o b.o

pgm: $(OBJS)

cc $(OBJS) -o pgm

a.o: incl.h a.c cc -c a.c

b.o: incl.h b.c cc -c b.c

Command lines are executed one at a time, each by its own shell. Each command line can have one or more of the following pre®xes: -, @, or +. These pre®xes are explained below.

Commands returning non-zero status normally terminate make. The -ioption or the presence of the special target .IGNORE in the make®le cause make to continue executing the make®le regardless of how many command lines cause errors, although the error messages are still printed on standard output. If - is present at the beginning of a command line, any error returned by that line is printed to standard output but make does not terminate. The pre®x - can be used to selectively ignore errors in a make®le. If the -koption is speci®ed and a command line returns an error status, work is abandoned on the current target, but continues on other branches that do not depend on that target. If the -koption is present in the MAKEFLAGS environment variable, processing can be returned to the default by specifying the -Soption.

The -noption speci®es printing of a command line without execution. However, if the command line has the string $(MAKE) or ${MAKE} in it or + as a pre®x, the line is always executed (see discussion of the MAKEFLAGS macro under Environment). The -t(touch) option updates the modi®ed date of a ®le without executing any commands.

HP-UX Release 11i: December 2000

− 2 −

Section 1509

m