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