Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sh(1)

touch(1)

MAKE(1)

NAME

make − maintain program groups

USAGE

make [ −f makefile ] [ options ] ...  file ... 

DESCRIPTION

Make executes commands in makefile to update one or more target names. Name is typically a program.  If no −f option is present, makefile and Makefile are tried in order.  If makefile is specified as a dash (−), make uses the standard input.  More than one −f option may appear. 

Make updates a target if it depends on prerequisite files that have been modified since the target was last modified, or if the target does not exist. 

Makefile contains a sequence of entries that specify dependencies.  The first line of an entry is a blank-separated list of targets, then a colon, then a list of prerequisite files.  Text following a semicolon, and all following lines that begin with a tab, are Shell commands to be executed to update the target.  If a name appears on the left of more than one line containing a colon, the name depends on all of the names on the right of the colon on those lines.  Only one command sequence, however, may be specified for it.  If a name appears on a line with a double colon, the command sequence following that line is performed only if the name is out of date with respect to the names to the right of the double colon (::), and is not affected by other double colon lines on which that name may appear. 

Comments begin with a pound sign (#) and end with a newline.  Note that a pound sign is treated as a comment character, whether surrounded by quotes or not, wherever it appears (except when it is embedded in a command). 

Makefile entries of the form string1 = string2 are macro definitions.  Subsequent appearances of $(string1) or ${string1} are replaced by string2. If string1 is a single character, the parentheses or braces are optional. 

Make infers prerequisites for files not controlled by makefile construction commands.  It does this according to selected suffixes listed as the prerequisites for the special name .SUFFIXES. Multiple lists accumulate; an empty list clears what came before. Order is significant.  The first possible name for which both a file and a rule exist is inferred. The default list is

.SUFFIXES: .o .c .y .asm .bin .pas .ftn .rat .l .s .sh .h

The rule for creating a file with suffix s2 that depends on a similarly named file with suffix s1 is specified as an entry for the target s1s2. In such an entry, the special macro $* stands for the target name with the suffix deleted, $@ for the full target name, $< for the complete list of prerequisites, and $? for the list of prerequisites that are out of date. For example, a rule for making optimized .o files from .c files is as follows:

.c.o: ; cc −c −O −o $@ $*.c

Certain macros are used by the default inference rules to communicate optional arguments to any resulting compilations.  In particular, CFLAGS is used for cc(1) options, PFLAGS for /com/pas options, and LFLAGS and YFLAGS for lex(1) and yacc(1) options.  In addition, the macro MFLAGS is filled in with the initial command line options supplied to make.  This simplifies maintaining a hierarchy of makefiles as one may then invoke make on makefiles in subdirectories and pass along useful options such as −k. 

Command lines are executed one at a time, each by its own Shell.  A line is printed when it is executed unless the special target .SILENT is in makefile, or the first character of the command is an at sign (@). 

Commands returning nonzero status cause make to terminate unless the special target .IGNORE is in makefile or the command begins with <tab><hyphen>. 

Interrupt and quit cause the target to be deleted unless the target is a directory or depends on the special name .PRECIOUS.

OPTIONS

−i Ignore error codes returned by invoked commands.  This option is equivalent to the .IGNORE: special entry. 

−k When a command returns nonzero status, abandon work on the current entry, but continue on branches that do not depend on the current entry. 

−n Trace and print, but do not execute the commands needed to update the targets. 

−t Update the modified date of targets without executing any commands. 

−r Do not use built-in rules.  This option is equivalent to an initial special entry of .SUFFIXES: with no list. 

−s Do not print command lines before executing.  This option is equivalent to the .SILENT: special entry. 

EXAMPLES

The following makefile says that pgm depends on two files, a.o and b.o. They in turn depend on .c files and a common file incl.

pgm: a.o b.o
cc a.o b.o −lcurses −o pgm

a.o: incl a.c
cc −c a.c

b.o: incl b.c
cc −c b.c

A .c file may be inferred as a prerequisite for a .o file and be compiled to produce the .o file.  Thus, the above example can be made shorter, as shown here:

pgm: a.o b.o
cc a.o b.o −lcurses −o pgm

a.o b.o: incl

CAUTIONS

Some commands return a nonzero status inappropriately.  Use −i to overcome this difficulty. 

Commands directly executed by the Shell, notably cd(1), are ineffectual across newlines in make. 

FILES

makefile, Makefile

RELATED INFORMATION

sh(1), touch(1). 

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026