BSD 4_1c_2 release
[unix-history] / usr / man / man1 / make.1
CommitLineData
28db68b2
C
1.TH MAKE 1 "18 January 1983"
2.UC 4
3.SH NAME
4make \- maintain program groups
5.SH SYNOPSIS
6.B make
7[
8.B \-f
9makefile ] [ option ] ...
10file ...
11.SH DESCRIPTION
12.I Make
13executes commands in
14.I makefile
15to update
16one or more target
17.IR names .
18.I Name
19is typically a program.
20If no
21.B \-f
22option is present, `makefile' and `Makefile' are
23tried in order.
24If
25.I makefile
26is `\-', the standard input is taken.
27More than one
28.B \-f
29option may appear
30.PP
31.I Make
32updates a target if it depends on prerequisite files
33that have been modified since the target was last modified,
34or if the target does not exist.
35.PP
36.I Makefile
37contains a sequence of entries that specify dependencies.
38The first line of an entry is a
39blank-separated list of targets, then a colon,
40then a list of prerequisite files.
41Text following a semicolon, and all following lines
42that begin with a tab, are shell commands
43to be executed to update the target.
44If a name appears on the left of more than one `colon' line, then it depends
45on all of the names on the right of the colon on those lines, but only
46one command sequence may be specified for it.
47If a name appears on a line with a double colon
48.B "::"
49then the command sequence following that line is performed
50only if the name is out of date with respect to the names to the right
51of the double colon, and is not affected by other double colon lines
52on which that name may appear.
53.PP
54Two special forms of a name are recognized.
55A name like
56.IR a ( b )
57means the file named
58.I b
59stored in the archive named
60.I a.
61A name like
62.IR a (( b ))
63means the file stored in archive
64.I a
65containing the entry point
66.I b.
67.PP
68Sharp and newline surround comments.
69.PP
70The following makefile says that `pgm' depends on two
71files `a.o' and `b.o', and that they in turn depend on
72`.c' files and a common file `incl'.
73.RS
74.HP
75.PD 0
76.nf
77pgm: a.o b.o
78cc a.o b.o \-lm \-o pgm
79.HP
80a.o: incl a.c
81cc \-c a.c
82.HP
83b.o: incl b.c
84cc \-c b.c
85.fi
86.RE
87.PD
88.PP
89.I Makefile
90entries of the form
91.PP
92.IP
93string1 = string2
94.PP
95are macro definitions.
96Subsequent appearances of
97.RI $( string1 )
98or
99.RI ${ string1 }
100are replaced by
101.IR string2 .
102If
103.I string1
104is a single character, the parentheses or braces
105are optional.
106.PP
107.I Make
108infers prerequisites for files for which
109.I makefile
110gives no construction commands.
111For example, a
112`.c' file may be inferred as prerequisite for a `.o' file
113and be compiled to produce the `.o' file.
114Thus the preceding example can be done more briefly:
115.RS
116.HP
117.PD 0
118.nf
119pgm: a.o b.o
120cc a.o b.o \-lm \-o pgm
121.HP
122a.o b.o: incl
123.fi
124.RE
125.PD
126.PP
127Prerequisites are inferred according to selected suffixes
128listed as the `prerequisites' for the special name `.SUFFIXES';
129multiple lists accumulate;
130an empty list clears what came before.
131Order is significant; the first possible name for which both
132a file and a rule as described in the next paragraph exist
133is inferred.
134The default list is
135.IP
136\&.SUFFIXES: .out .o .c .e .r .f .y .l .s .p
137.PP
138The rule to create a file with suffix
139.I s2
140that depends on a similarly named file with suffix
141.I s1
142is specified as an entry
143for the `target'
144.IR s1s2 .
145In such an entry, the special macro $* stands for
146the target name with suffix deleted, $@ for the full target name,
147$< for the complete list of prerequisites,
148and
149$? for the list of prerequisites that are out of date.
150For example, a rule for making
151optimized `.o' files from `.c' files is
152.IP
153\&.c.o: ; cc \-c \-O \-o $@ $*.c
154.PP
155Certain macros are used by the default inference rules
156to communicate optional arguments to
157any resulting compilations.
158In particular,
159`CFLAGS' is used for
160.IR cc (1)
161options,
162`FFLAGS' for
163.IR f77 (1)
164options,
165`PFLAGS' for
166.IR pc (1)
167options,
168and `LFLAGS' and `YFLAGS' for
169.I lex
170and
171.IR yacc (1)
172options. In addition, the macro `MFLAGS' is filled in
173with the initial command line options supplied to
174.IR make .
175This simplifies maintaining a hierarchy of makefiles as
176one may then invoke
177.I make
178on makefiles in subdirectories and pass along useful options
179such as
180.BR \-k .
181.PP
182Command lines are executed one at a time, each by its
183own shell.
184A line is printed when it is executed unless
185the special target `.SILENT'
186is in
187.I makefile,
188or the first character of the command is `@'.
189.PP
190Commands returning nonzero status (see
191.IR intro (1))
192cause
193.I make
194to terminate unless
195the special target `.IGNORE' is in
196.I makefile
197or the command begins with
198<tab><hyphen>.
199.PP
200Interrupt and quit cause the target to be deleted
201unless the target is a directory or
202depends on the special name `.PRECIOUS'.
203.PP
204Other options:
205.TP
206.B \-i
207Equivalent to the special entry `.IGNORE:'.
208.TP
209.B \-k
210When a command returns nonzero status,
211abandon work on the current entry, but
212continue on branches that do not depend on the current entry.
213.TP
214.B \-n
215Trace and print, but do not execute the commands
216needed to update the targets.
217.TP
218.B \-t
219Touch, i.e. update the modified date of targets, without
220executing any commands.
221.TP
222.B \-r
223Equivalent to an initial special entry `.SUFFIXES:'
224with no list.
225.TP
226.B \-s
227Equivalent to the special entry
228`.SILENT:'.
229.SH FILES
230makefile, Makefile
231.br
232.SH "SEE ALSO"
233sh(1), touch(1), f77(1), pc(1)
234.br
235S. I. Feldman
236.I
237Make \- A Program for Maintaining Computer Programs
238.SH BUGS
239Some commands return nonzero status inappropriately.
240Use
241.B \-i
242to overcome the difficulty.
243.br
244Commands that are directly executed by the shell,
245notably
246.IR cd (1),
247are ineffectual across newlines in
248.I make.
249