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 | .\" | |
bfe02f44 | 5 | .\" @(#)make.1 6.3 (Berkeley) %G% |
4de361a5 | 6 | .\" |
2ec39d6d | 7 | .TH MAKE 1 "" |
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 | |
bfe02f44 | 35 | option may appear. |
4de361a5 KM |
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 | 187 | .PP |
93e0b34b KM |
188 | Another special macro is `VPATH'. |
189 | The `VPATH' macro should be set to a list of directories separated by colons. | |
190 | When | |
191 | .I make | |
192 | searches for a file as a result of a dependency relation, it will | |
193 | first search the current directory and then each of the directories on the | |
194 | `VPATH' list. | |
195 | If the file is found, the actual path to the file will be used, rather than | |
196 | just the filename. | |
197 | If `VPATH' is not defined, then only the current directory is searched. | |
198 | .PP | |
199 | One use for `VPATH' is when one has several programs that compile from the | |
200 | same source. | |
201 | The source can be kept in one directory and each set of | |
202 | object files (along with a separate | |
203 | .IR makefile ) | |
204 | would be in a separate subdirectory. | |
205 | The `VPATH' macro would point to the source directory in this case. | |
206 | .PP | |
4de361a5 KM |
207 | Command lines are executed one at a time, each by its |
208 | own shell. | |
209 | A line is printed when it is executed unless | |
210 | the special target `.SILENT' | |
211 | is in | |
212 | .I makefile, | |
213 | or the first character of the command is `@'. | |
214 | .PP | |
215 | Commands returning nonzero status (see | |
216 | .IR intro (1)) | |
217 | cause | |
218 | .I make | |
219 | to terminate unless | |
220 | the special target `.IGNORE' is in | |
221 | .I makefile | |
222 | or the command begins with | |
223 | <tab><hyphen>. | |
224 | .PP | |
225 | Interrupt and quit cause the target to be deleted | |
28e84832 KM |
226 | unless the target is a directory or |
227 | depends on the special name `.PRECIOUS'. | |
4de361a5 KM |
228 | .PP |
229 | Other options: | |
230 | .TP | |
231 | .B \-i | |
232 | Equivalent to the special entry `.IGNORE:'. | |
233 | .TP | |
234 | .B \-k | |
235 | When a command returns nonzero status, | |
236 | abandon work on the current entry, but | |
237 | continue on branches that do not depend on the current entry. | |
238 | .TP | |
239 | .B \-n | |
240 | Trace and print, but do not execute the commands | |
241 | needed to update the targets. | |
242 | .TP | |
243 | .B \-t | |
244 | Touch, i.e. update the modified date of targets, without | |
245 | executing any commands. | |
246 | .TP | |
247 | .B \-r | |
248 | Equivalent to an initial special entry `.SUFFIXES:' | |
249 | with no list. | |
250 | .TP | |
251 | .B \-s | |
252 | Equivalent to the special entry | |
253 | `.SILENT:'. | |
254 | .SH FILES | |
255 | makefile, Makefile | |
256 | .br | |
257 | .SH "SEE ALSO" | |
258 | sh(1), touch(1), f77(1), pc(1) | |
259 | .br | |
260 | S. I. Feldman | |
261 | .I | |
262 | Make \- A Program for Maintaining Computer Programs | |
263 | .SH BUGS | |
264 | Some commands return nonzero status inappropriately. | |
265 | Use | |
266 | .B \-i | |
267 | to overcome the difficulty. | |
268 | .br | |
269 | Commands that are directly executed by the shell, | |
270 | notably | |
271 | .IR cd (1), | |
272 | are ineffectual across newlines in | |
273 | .I make. | |
93e0b34b KM |
274 | .PP |
275 | `VPATH' is intended to act like the System V `VPATH' support, | |
276 | but there is no guarantee that it functions identically. |