BSD 4_1_snap development
[unix-history] / usr / man / man1 / make.1
CommitLineData
e3758c96
C
1.TH MAKE 1
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.I a(b)
57means the file named
58.I b
59stored in the archive named
60.I a.
61A name like
62.I 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.I $(string1)
98are replaced by
99.IR string2 .
100If
101.I string1
102is a single character, the parentheses are optional.
103.PP
104.I Make
105infers prerequisites for files for which
106.I makefile
107gives no construction commands.
108For example, a
109`.c' file may be inferred as prerequisite for a `.o' file
110and be compiled to produce the `.o' file.
111Thus the preceding example can be done more briefly:
112.RS
113.HP
114.PD 0
115.nf
116pgm: a.o b.o
117cc a.o b.o \-lm \-o pgm
118.HP
119a.o b.o: incl
120.fi
121.RE
122.PD
123.PP
124Prerequisites are inferred according to selected suffixes
125listed as the `prerequisites' for the special name `.SUFFIXES';
126multiple lists accumulate;
127an empty list clears what came before.
128Order is significant; the first possible name for which both
129a file and a rule as described in the next paragraph exist
130is inferred.
131The default list is
132.IP
133\&.SUFFIXES: .out .o .c .e .r .f .y .l .s .p
134.PP
135The rule to create a file with suffix
136.I s2
137that depends on a similarly named file with suffix
138.I s1
139is specified as an entry
140for the `target'
141.IR s1s2 .
142In such an entry, the special macro $* stands for
143the target name with suffix deleted, $@ for the full target name,
144$< for the complete list of prerequisites,
145and
146$? for the list of prerequisites that are out of date.
147For example, a rule for making
148optimized `.o' files from `.c' files is
149.IP
150\&.c.o: ; cc \-c \-O \-o $@ $*.c
151.PP
152Certain macros are used by the default inference rules
153to communicate optional arguments to
154any resulting compilations.
155In particular,
156`CFLAGS' is used for
157.IR cc (1)
158options,
159`FFLAGS' for
160.IR f77 (1)
161options,
162`PFLAGS' for
163.IR pc (1)
164options,
165and `LFLAGS' and `YFLAGS' for
166.I lex
167and
168.IR yacc (1)
169options.
170.PP
171Command lines are executed one at a time, each by its
172own shell.
173A line is printed when it is executed unless
174the special target `.SILENT'
175is in
176.I makefile,
177or the first character of the command is `@'.
178.PP
179Commands returning nonzero status (see
180.IR intro (1))
181cause
182.I make
183to terminate unless
184the special target `.IGNORE' is in
185.I makefile
186or the command begins with
187<tab><hyphen>.
188.PP
189Interrupt and quit cause the target to be deleted
190unless the target depends on the special name `.PRECIOUS'.
191.PP
192Other options:
193.TP
194.B \-i
195Equivalent to the special entry `.IGNORE:'.
196.TP
197.B \-k
198When a command returns nonzero status,
199abandon work on the current entry, but
200continue on branches that do not depend on the current entry.
201.TP
202.B \-n
203Trace and print, but do not execute the commands
204needed to update the targets.
205.TP
206.B \-t
207Touch, i.e. update the modified date of targets, without
208executing any commands.
209.TP
210.B \-r
211Equivalent to an initial special entry `.SUFFIXES:'
212with no list.
213.TP
214.B \-s
215Equivalent to the special entry
216`.SILENT:'.
217.SH FILES
218makefile, Makefile
219.br
220.SH "SEE ALSO"
221sh(1), touch(1), f77(1), pc(1)
222.br
223S. I. Feldman
224.I
225Make \- A Program for Maintaining Computer Programs
226.SH BUGS
227Some commands return nonzero status inappropriately.
228Use
229.B \-i
230to overcome the difficulty.
231.br
232Commands that are directly executed by the shell,
233notably
234.IR cd (1),
235are ineffectual across newlines in
236.I make.
237