Imported Upstream version 4.4
[platform/upstream/make.git] / doc / make.1
1 .TH MAKE 1 "31 May 2022" "GNU" "User Commands"
2 .SH NAME
3 make \- GNU make utility to maintain groups of programs
4 .SH SYNOPSIS
5 .B make
6 [\fIOPTION\fR]... [\fITARGET\fR]...
7 .SH DESCRIPTION
8 .LP
9 The
10 .I make
11 utility will determine automatically which pieces of a large program need to
12 be recompiled, and issue the commands to recompile them.  The manual describes
13 the GNU implementation of
14 .BR make ,
15 which was written by Richard Stallman and Roland McGrath, and is currently
16 maintained by Paul Smith.  Our examples show C programs, since they are very
17 common, but you can use
18 .B make
19 with any programming language whose compiler can be run with a shell command.
20 In fact,
21 .B make
22 is not limited to programs.  You can use it to describe any task where some
23 files must be updated automatically from others whenever the others change.
24 .LP
25 To prepare to use
26 .BR make ,
27 you must write a file called the
28 .I makefile
29 that describes the relationships among files in your program, and provides
30 commands for updating each file.  In a program, typically the executable file
31 is updated from object files, which are in turn made by compiling source
32 files.
33 .LP
34 Once a suitable makefile exists, each time you change some source files,
35 this simple shell command:
36 .sp 1
37 .RS
38 .B make
39 .RE
40 .sp 1
41 suffices to perform all necessary recompilations.
42 The
43 .B make
44 program uses the makefile description and the last-modification times of the
45 files to decide which of the files need to be updated.  For each of those
46 files, it issues the commands recorded in the makefile.
47 .LP
48 .B make
49 executes commands in the
50 .I makefile
51 to update one or more
52 .IR targets ,
53 where
54 .I target
55 is typically a program.
56 If no
57 .B \-f
58 option is present,
59 .B make
60 will look for the makefiles
61 .IR GNUmakefile ,
62 .IR makefile ,
63 and
64 .IR Makefile ,
65 in that order.
66 .LP
67 Normally you should call your makefile either
68 .I makefile
69 or
70 .IR Makefile .
71 (We recommend
72 .I Makefile
73 because it appears prominently near the beginning of a directory
74 listing, right near other important files such as
75 .IR  README .)
76 The first name checked,
77 .IR GNUmakefile ,
78 is not recommended for most makefiles.  You should use this name if you have a
79 makefile that is specific to GNU
80 .BR make ,
81 and will not be understood by other versions of
82 .BR make .
83 If
84 .I makefile
85 is '\-', the standard input is read.
86 .LP
87 .B make
88 updates a target if it depends on prerequisite files
89 that have been modified since the target was last modified,
90 or if the target does not exist.
91 .SH OPTIONS
92 .sp 1
93 .TP 0.5i
94 \fB\-b\fR, \fB\-m\fR
95 These options are ignored for compatibility with other versions of
96 .BR make .
97 .TP 0.5i
98 \fB\-B\fR, \fB\-\-always\-make\fR
99 Unconditionally make all targets.
100 .TP 0.5i
101 \fB\-C\fR \fIdir\fR, \fB\-\-directory\fR=\fIdir\fR
102 Change to directory
103 .I dir
104 before reading the makefiles or doing anything else.
105 If multiple
106 .B \-C
107 options are specified, each is interpreted relative to the
108 previous one:
109 .BR "\-C " /
110 .BR "\-C " etc
111 is equivalent to
112 .BR "\-C " /etc.
113 This is typically used with recursive invocations of
114 .BR make .
115 .TP 0.5i
116 .B \-d
117 Print debugging information in addition to normal processing.
118 The debugging information says which files are being considered for
119 remaking, which file-times are being compared and with what results,
120 which files actually need to be remade, which implicit rules are
121 considered and which are applied---everything interesting about how
122 .B make
123 decides what to do.
124 .TP 0.5i
125 .BI \-\-debug "[=FLAGS]"
126 Print debugging information in addition to normal processing.
127 If the
128 .I FLAGS
129 are omitted, then the behavior is the same as if
130 .B \-d
131 was specified.
132 .I FLAGS
133 may be any or all of the following names, comma- or space-separated.  Only the
134 first character is significant: the rest may be omitted:
135 .I all
136 for all debugging output (same as using
137 .BR \-d ),
138 .I basic
139 for basic debugging,
140 .I verbose
141 for more verbose basic debugging,
142 .I implicit
143 for showing implicit rule search operations,
144 .I jobs
145 for details on invocation of commands,
146 .I makefile
147 for debugging while remaking makefiles,
148 .I print
149 shows all recipes that are run even if they are silent, and
150 .I why
151 shows the reason
152 .BR make
153 decided to rebuild each target.  Use
154 .I none
155 to disable all previous debugging flags.
156 .TP 0.5i
157 \fB\-e\fR, \fB\-\-environment\-overrides\fR
158 Give variables taken from the environment precedence over variables
159 from makefiles.
160 .TP 0.5i
161 \fB\-E\fR \fIstring\fR, \fB\-\-eval\fR \fIstring\fR
162 Interpret \fIstring\fR using the \fBeval\fR function, before parsing any
163 makefiles.
164 .TP 0.5i
165 \fB\-f\fR \fIfile\fR, \fB\-\-file\fR=\fIfile\fR, \fB\-\-makefile\fR=\fIFILE\fR
166 Use
167 .I file
168 as a makefile.
169 .TP 0.5i
170 \fB\-i\fR, \fB\-\-ignore\-errors\fR
171 Ignore all errors in commands executed to remake files.
172 .TP 0.5i
173 \fB\-I\fR \fIdir\fR, \fB\-\-include\-dir\fR=\fIdir\fR
174 Specifies a directory
175 .I dir
176 to search for included makefiles.
177 If several
178 .B \-I
179 options are used to specify several directories, the directories are
180 searched in the order specified.
181 Unlike the arguments to other flags of
182 .BR make ,
183 directories given with
184 .B \-I
185 flags may come directly after the flag:
186 .BI \-I dir
187 is allowed, as well as
188 .B \-I
189 .IR dir .
190 This syntax is allowed for compatibility with the C
191 preprocessor's
192 .B \-I
193 flag.
194 .TP 0.5i
195 \fB\-j\fR [\fIjobs\fR], \fB\-\-jobs\fR[=\fIjobs\fR]
196 Specifies the number of
197 .I jobs
198 (commands) to run simultaneously.
199 If there is more than one
200 .B \-j
201 option, the last one is effective.
202 If the
203 .B \-j
204 option is given without an argument,
205 .BR make
206 will not limit the number of jobs that can run simultaneously.
207 .TP 0.5i
208 \fB\--jobserver-style=\fR\fIstyle\fR
209 The style of jobserver to use.  The
210 .I style
211 may be one of
212 .BR fifo ,
213 .BR pipe ,
214 or
215 .B sem
216 (Windows only).
217 .TP 0.5i
218 \fB\-k\fR, \fB\-\-keep\-going\fR
219 Continue as much as possible after an error.
220 While the target that failed, and those that depend on it, cannot
221 be remade, the other dependencies of these targets can be processed
222 all the same.
223 .TP 0.5i
224 \fB\-l\fR [\fIload\fR], \fB\-\-load\-average\fR[=\fIload\fR]
225 Specifies that no new jobs (commands) should be started if there are
226 others jobs running and the load average is at least
227 .I load
228 (a floating-point number).
229 With no argument, removes a previous load limit.
230 .TP 0.5i
231 \fB\-L\fR, \fB\-\-check\-symlink\-times\fR
232 Use the latest mtime between symlinks and target.
233 .TP 0.5i
234 \fB\-n\fR, \fB\-\-just\-print\fR, \fB\-\-dry\-run\fR, \fB\-\-recon\fR
235 Print the commands that would be executed, but do not execute them (except in
236 certain circumstances).
237 .TP 0.5i
238 \fB\-o\fR \fIfile\fR, \fB\-\-old\-file\fR=\fIfile\fR, \fB\-\-assume\-old\fR=\fIfile\fR
239 Do not remake the file
240 .I file
241 even if it is older than its dependencies, and do not remake anything
242 on account of changes in
243 .IR file .
244 Essentially the file is treated as very old and its rules are ignored.
245 .TP 0.5i
246 \fB\-O\fR[\fItype\fR], \fB\-\-output\-sync\fR[=\fItype\fR]
247 When running multiple jobs in parallel with \fB-j\fR, ensure the output of
248 each job is collected together rather than interspersed with output from
249 other jobs.  If
250 .I type
251 is not specified or is
252 .B target
253 the output from the entire recipe for each target is grouped together.  If
254 .I type
255 is
256 .B line
257 the output from each command line within a recipe is grouped together.
258 If
259 .I type
260 is
261 .B recurse
262 output from an entire recursive make is grouped together.  If
263 .I type
264 is
265 .B none
266 output synchronization is disabled.
267 .TP 0.5i
268 \fB\-p\fR, \fB\-\-print\-data\-base\fR
269 Print the data base (rules and variable values) that results from
270 reading the makefiles; then execute as usual or as otherwise
271 specified.
272 This also prints the version information given by the
273 .B \-v
274 switch (see below).
275 To print the data base without trying to remake any files, use
276 .IR "make \-p \-f/dev/null" .
277 .TP 0.5i
278 \fB\-q\fR, \fB\-\-question\fR
279 ``Question mode''.
280 Do not run any commands, or print anything; just return an exit status
281 that is zero if the specified targets are already up to date, nonzero
282 otherwise.
283 .TP 0.5i
284 \fB\-r\fR, \fB\-\-no\-builtin\-rules\fR
285 Eliminate use of the built\-in implicit rules.
286 Also clear out the default list of suffixes for suffix rules.
287 .TP 0.5i
288 \fB\-R\fR, \fB\-\-no\-builtin\-variables\fR
289 Don't define any built\-in variables.
290 .TP 0.5i
291 \fB\-s\fR, \fB\-\-silent\fR, \fB\-\-quiet\fR
292 Silent operation; do not print the commands as they are executed.
293 .TP 0.5i
294 .B \-\-no\-silent
295 Cancel the effect of the \fB\-s\fR option.
296 .TP 0.5i
297 \fB\-S\fR, \fB\-\-no\-keep\-going\fR, \fB\-\-stop\fR
298 Cancel the effect of the
299 .B \-k
300 option.
301 .TP 0.5i
302 \fB\-t\fR, \fB\-\-touch\fR
303 Touch files (mark them up to date without really changing them)
304 instead of running their commands.
305 This is used to pretend that the commands were done, in order to fool
306 future invocations of
307 .BR make .
308 .TP 0.5i
309 .B \-\-trace
310 Information about the disposition of each target is printed (why the target is
311 being rebuilt and what commands are run to rebuild it).
312 .TP 0.5i
313 \fB\-v\fR, \fB\-\-version\fR
314 Print the version of the
315 .B make
316 program plus a copyright, a list of authors and a notice that there
317 is no warranty.
318 .TP 0.5i
319 \fB\-w\fR, \fB\-\-print\-directory\fR
320 Print a message containing the working directory
321 before and after other processing.
322 This may be useful for tracking down errors from complicated nests of
323 recursive
324 .B make
325 commands.
326 .TP 0.5i
327 .B \-\-no\-print\-directory
328 Turn off
329 .BR \-w ,
330 even if it was turned on implicitly.
331 .TP 0.5i
332 .BI \-\-shuffle "[=MODE]"
333 Enable shuffling of goal and prerequisite ordering.
334 .I MODE
335 is one of
336 .I none
337 to disable shuffle mode,
338 .I random
339 to shuffle prerequisites in random order,
340 .I reverse
341 to consider prerequisites in reverse order, or an integer
342 .I <seed>
343 which enables
344 .I random
345 mode with a specific
346 .I seed
347 value.  If
348 .I MODE
349 is omitted the default is
350 .IR random .
351 .TP 0.5i
352 \fB\-W\fR \fIfile\fR, \fB\-\-what\-if\fR=\fIfile\fR, \fB\-\-new\-file\fR=\fIfile\fR, \fB\-\-assume\-new\fR=\fIfile\fR
353 Pretend that the target
354 .I file
355 has just been modified.
356 When used with the
357 .B \-n
358 flag, this shows you what would happen if you were to modify that file.
359 Without
360 .BR \-n ,
361 it is almost the same as running a
362 .I touch
363 command on the given file before running
364 .BR make ,
365 except that the modification time is changed only in the imagination of
366 .BR make .
367 .TP 0.5i
368 .B \-\-warn\-undefined\-variables
369 Warn when an undefined variable is referenced.
370 .SH "EXIT STATUS"
371 GNU
372 .B make
373 exits with a status of zero if all makefiles were successfully parsed
374 and no targets that were built failed.  A status of one will be returned
375 if the
376 .B \-q
377 flag was used and
378 .B make
379 determines that a target needs to be rebuilt.  A status of two will be
380 returned if any errors were encountered.
381 .SH "SEE ALSO"
382 The full documentation for
383 .B make
384 is maintained as a Texinfo manual.  If the
385 .B info
386 and
387 .B make
388 programs are properly installed at your site, the command
389 .IP
390 .B info make
391 .PP
392 should give you access to the complete manual.
393 .SH BUGS
394 See the chapter ``Problems and Bugs'' in
395 .IR "The GNU Make Manual" .
396 .SH AUTHOR
397 This manual page contributed by Dennis Morse of Stanford University.
398 Further updates contributed by Mike Frysinger.  It has been reworked by Roland
399 McGrath.  Maintained by Paul Smith.
400 .SH "COPYRIGHT"
401 Copyright \(co 1992-1993, 1996-2022 Free Software Foundation, Inc.
402 This file is part of
403 .IR "GNU make" .
404 .LP
405 GNU Make is free software; you can redistribute it and/or modify it under the
406 terms of the GNU General Public License as published by the Free Software
407 Foundation; either version 3 of the License, or (at your option) any later
408 version.
409 .LP
410 GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
411 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
412 A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
413 .LP
414 You should have received a copy of the GNU General Public License along with
415 this program.  If not, see
416 .IR https://www.gnu.org/licenses/ .