Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ make(1) — 4.2BSD 3.04v10.B

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sh(1)

touch(1)

f77(1)

pc(1)

MAKE(1)  —  Unix Programmer’s Manual

NAME

make − maintain program groups

SYNOPSIS

make [ options ] [ files ]

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  − , the standard input is taken.  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 list of targets separated by blanks, 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 so as to update the target.  If a name appears on the left of more than one “colon” line, then it depends on all of the names to the right of the colon on those lines, but only one command sequence may be specified for it.  If a name appears on a line with a double colon ( :: ) then 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. 

Two special forms of a name are recognized.  A name like a(b) means the file named b stored in the archive named a.  A name like a((b)) means the file stored in archive a containing the entry point b. 

Sharp and newline surround comments. 

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

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

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

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

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 for which makefile gives no construction commands.  For example, a .c file may be inferred as prerequisite for an .o file and may be compiled to produce the .o file.  Thus the preceding example can be done more briefly:

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

a.o b.o: incl

Prerequisites are inferred 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; make infers the first possible name for which both a file and a rule (as described in the next paragraph) exist.  The default list is

.SUFFIXES:  .out  .o  .c  .e  .r  .f  .y  .l  .s  .p

To create a file with suffix s2 that depends on a similarly named file with suffix s1, the rule is specified as an entry for the “target” s1s2. In such an entry, special macros have the following meanings:
$∗   the target name with suffix deleted
@    the full target name,
$<   the complete list of prerequisites, and
$?   the list of prerequisites that are out of date

For example, a rule for making optimized .o files from .c files is

.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, FFLAGS for f77(1) options, PFLAGS for pc(1) options, and LFLAGS and YFLAGS for lex 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 @ . 

Commands returning non-zero status (see intro(1)) 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

−f makefile Specifies name of description file (defaults:  makefile, Makefile, s.makefile, s.Makefile). 

−i Ignores errors of invoked commands.  Equivalent to the “.IGNORE:” special entry. 

−k When a command returns non-zero status, aborts the current entry, but continues with unrelated entries. 

−n Traces and prints, but does not execute, the commands needed to update the targets. 

−r Uses predefined suffixes.  Equivalent to an initial special entry “.SUFFIXES:” with no list. 

−s Does not print commands before executing them.  Equivalent to the “.SILENT:” special entry. 

−t Touches (updates) the modified date of target files, but does not execute any commands. 

FILES

makefile, Makefile

SEE ALSO

sh(1), touch(1), f77(1), pc(1)
S. I. Feldman, “Make − A Program for Maintaining Computer Programs,” in Volume III of the UNIX Programmer’s Manual. 

BUGS

Some commands return non-zero status inappropriately.  Use −i to overcome the difficulty. 
Commands that are directly executed by the shell, notably cd(1), are ineffectual across newlines in make. 
 

4th Berkeley Distribution  —  1 August 1985

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