1MAKE(1P) POSIX Programmer's Manual MAKE(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 make - maintain, update, and regenerate groups of programs (DEVELOP‐
13 MENT)
14
16 make [-einpqrst][-f makefile]...[ -k| -S][macro=value]...
17 [target_name...]
18
20 The make utility shall update files that are derived from other files.
21 A typical case is one where object files are derived from the corre‐
22 sponding source files. The make utility examines time relationships and
23 shall update those derived files (called targets) that have modified
24 times earlier than the modified times of the files (called prerequi‐
25 sites) from which they are derived. A description file (makefile) con‐
26 tains a description of the relationships between files, and the com‐
27 mands that need to be executed to update the targets to reflect changes
28 in their prerequisites. Each specification, or rule, shall consist of
29 a target, optional prerequisites, and optional commands to be executed
30 when a prerequisite is newer than the target. There are two types of
31 rule:
32
33 1. Inference rules, which have one target name with at least one
34 period ( '.' ) and no slash ( '/' )
35
36 2. Target rules, which can have more than one target name
37
38 In addition, make shall have a collection of built-in macros and infer‐
39 ence rules that infer prerequisite relationships to simplify mainte‐
40 nance of programs.
41
42 To receive exactly the behavior described in this section, the user
43 shall ensure that a portable makefile shall:
44
45 * Include the special target .POSIX
46
47 * Omit any special target reserved for implementations (a leading
48 period followed by uppercase letters) that has not been specified by
49 this section
50
51 The behavior of make is unspecified if either or both of these condi‐
52 tions are not met.
53
55 The make utility shall conform to the Base Definitions volume of
56 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
57
58 The following options shall be supported:
59
60 -e Cause environment variables, including those with null values,
61 to override macro assignments within makefiles.
62
63 -f makefile
64 Specify a different makefile. The argument makefile is a path‐
65 name of a description file, which is also referred to as the
66 makefile. A pathname of '-' shall denote the standard input.
67 There can be multiple instances of this option, and they shall
68 be processed in the order specified. The effect of specifying
69 the same option-argument more than once is unspecified.
70
71 -i Ignore error codes returned by invoked commands. This mode is
72 the same as if the special target .IGNORE were specified without
73 prerequisites.
74
75 -k Continue to update other targets that do not depend on the cur‐
76 rent target if a non-ignored error occurs while executing the
77 commands to bring a target up-to-date.
78
79 -n Write commands that would be executed on standard output, but do
80 not execute them. However, lines with a plus sign ( '+' ) prefix
81 shall be executed. In this mode, lines with an at sign ( '@' )
82 character prefix shall be written to standard output.
83
84 -p Write to standard output the complete set of macro definitions
85 and target descriptions. The output format is unspecified.
86
87 -q Return a zero exit value if the target file is up-to-date; oth‐
88 erwise, return an exit value of 1. Targets shall not be updated
89 if this option is specified. However, a makefile command line
90 (associated with the targets) with a plus sign ( '+' ) prefix
91 shall be executed.
92
93 -r Clear the suffix list and do not use the built-in rules.
94
95 -S Terminate make if an error occurs while executing the commands
96 to bring a target up-to-date. This shall be the default and the
97 opposite of -k.
98
99 -s Do not write makefile command lines or touch messages (see -t)
100 to standard output before executing. This mode shall be the same
101 as if the special target .SILENT were specified without prereq‐
102 uisites.
103
104 -t Update the modification time of each target as though a touch
105 target had been executed. Targets that have prerequisites but no
106 commands (see Target Rules ), or that are already up-to-date,
107 shall not be touched in this manner. Write messages to standard
108 output for each target file indicating the name of the file and
109 that it was touched. Normally, the makefile command lines asso‐
110 ciated with each target are not executed. However, a command
111 line with a plus sign ( '+' ) prefix shall be executed.
112
113
114 Any options specified in the MAKEFLAGS environment variable shall be
115 evaluated before any options specified on the make utility command
116 line. If the -k and -S options are both specified on the make utility
117 command line or by the MAKEFLAGS environment variable, the last option
118 specified shall take precedence. If the -f or -p options appear in the
119 MAKEFLAGS environment variable, the result is undefined.
120
122 The following operands shall be supported:
123
124 target_name
125 Target names, as defined in the EXTENDED DESCRIPTION section. If
126 no target is specified, while make is processing the makefiles,
127 the first target that make encounters that is not a special tar‐
128 get or an inference rule shall be used.
129
130 macro=value
131 Macro definitions, as defined in Macros .
132
133
134 If the target_name and macro= value operands are intermixed on the make
135 utility command line, the results are unspecified.
136
138 The standard input shall be used only if the makefile option-argument
139 is '-' . See the INPUT FILES section.
140
142 The input file, otherwise known as the makefile, is a text file con‐
143 taining rules, macro definitions, and comments. See the EXTENDED
144 DESCRIPTION section.
145
147 The following environment variables shall affect the execution of make:
148
149 LANG Provide a default value for the internationalization variables
150 that are unset or null. (See the Base Definitions volume of
151 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
152 ables for the precedence of internationalization variables used
153 to determine the values of locale categories.)
154
155 LC_ALL If set to a non-empty string value, override the values of all
156 the other internationalization variables.
157
158 LC_CTYPE
159 Determine the locale for the interpretation of sequences of
160 bytes of text data as characters (for example, single-byte as
161 opposed to multi-byte characters in arguments and input files).
162
163 LC_MESSAGES
164 Determine the locale that should be used to affect the format
165 and contents of diagnostic messages written to standard error.
166
167 MAKEFLAGS
168
169 This variable shall be interpreted as a character string repre‐
170 senting a series of option characters to be used as the default
171 options. The implementation shall accept both of the following
172 formats (but need not accept them when intermixed):
173
174 * The characters are option letters without the leading hyphens
175 or <blank> separation used on a make utility command line.
176
177 * The characters are formatted in a manner similar to a portion
178 of the make utility command line: options are preceded by
179 hyphens and <blank>-separated as described in the Base Defi‐
180 nitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility
181 Syntax Guidelines. The macro= value macro definition oper‐
182 ands can also be included. The difference between the con‐
183 tents of MAKEFLAGS and the make utility command line is that
184 the contents of the variable shall not be subjected to the
185 word expansions (see Word Expansions ) associated with pars‐
186 ing the command line values.
187
188 NLSPATH
189 Determine the location of message catalogs for the processing of
190 LC_MESSAGES .
191
192 PROJECTDIR
193
194 Provide a directory to be used to search for SCCS files not
195 found in the current directory. In all of the following cases,
196 the search for SCCS files is made in the directory SCCS in the
197 identified directory. If the value of PROJECTDIR begins with a
198 slash, it shall be considered an absolute pathname; otherwise,
199 the value of PROJECTDIR is treated as a user name and that
200 user's initial working directory shall be examined for a subdi‐
201 rectory src or source. If such a directory is found, it shall be
202 used. Otherwise, the value is used as a relative pathname.
203
204 If PROJECTDIR is not set or has a null value, the search for SCCS files
205 shall be made in the directory SCCS in the current directory.
206
207 The setting of PROJECTDIR affects all files listed in the remainder of
208 this utility description for files with a component named SCCS.
209
210
211 The value of the SHELL environment variable shall not be used as a
212 macro and shall not be modified by defining the SHELL macro in a make‐
213 file or on the command line. All other environment variables, including
214 those with null values, shall be used as macros, as defined in Macros .
215
217 If not already ignored, make shall trap SIGHUP, SIGTERM, SIGINT, and
218 SIGQUIT and remove the current target unless the target is a directory
219 or the target is a prerequisite of the special target .PRECIOUS or
220 unless one of the -n, -p, or -q options was specified. Any targets
221 removed in this manner shall be reported in diagnostic messages of
222 unspecified format, written to standard error. After this cleanup
223 process, if any, make shall take the standard action for all other sig‐
224 nals.
225
227 The make utility shall write all commands to be executed to standard
228 output unless the -s option was specified, the command is prefixed with
229 an at sign, or the special target .SILENT has either the current target
230 as a prerequisite or has no prerequisites. If make is invoked without
231 any work needing to be done, it shall write a message to standard out‐
232 put indicating that no action was taken. If the -t option is present
233 and a file is touched, make shall write to standard output a message of
234 unspecified format indicating that the file was touched, including the
235 filename of the file.
236
238 The standard error shall be used only for diagnostic messages.
239
241 Files can be created when the -t option is present. Additional files
242 can also be created by the utilities invoked by make.
243
245 The make utility attempts to perform the actions required to ensure
246 that the specified targets are up-to-date. A target is considered out-
247 of-date if it is older than any of its prerequisites or if it does not
248 exist. The make utility shall treat all prerequisites as targets them‐
249 selves and recursively ensure that they are up-to-date, processing them
250 in the order in which they appear in the rule. The make utility shall
251 use the modification times of files to determine whether the corre‐
252 sponding targets are out-of-date.
253
254 After make has ensured that all of the prerequisites of a target are
255 up-to-date and if the target is out-of-date, the commands associated
256 with the target entry shall be executed. If there are no commands
257 listed for the target, the target shall be treated as up-to-date.
258
259 Makefile Syntax
260 A makefile can contain rules, macro definitions (see Macros ), and com‐
261 ments. There are two kinds of rules: inference rules and target rules.
262 The make utility shall contain a set of built-in inference rules. If
263 the -r option is present, the built-in rules shall not be used and the
264 suffix list shall be cleared. Additional rules of both types can be
265 specified in a makefile. If a rule is defined more than once, the value
266 of the rule shall be that of the last one specified. Macros can also be
267 defined more than once, and the value of the macro is specified in
268 Macros . Comments start with a number sign ( '#' ) and continue until
269 an unescaped <newline> is reached.
270
271 By default, the following files shall be tried in sequence: ./makefile
272 and ./Makefile. If neither ./makefile or ./Makefile are found, other
273 implementation-defined files may also be tried. On XSI-conformant sys‐
274 tems, the additional files ./s.makefile, SCCS/s.makefile, ./s.Makefile,
275 and SCCS/s.Makefile shall also be tried.
276
277 The -f option shall direct make to ignore any of these default files
278 and use the specified argument as a makefile instead. If the '-' argu‐
279 ment is specified, standard input shall be used.
280
281 The term makefile is used to refer to any rules provided by the user,
282 whether in ./makefile or its variants, or specified by the -f option.
283
284 The rules in makefiles shall consist of the following types of lines:
285 target rules, including special targets (see Target Rules ), inference
286 rules (see Inference Rules ), macro definitions (see Macros ), empty
287 lines, and comments.
288
289 When an escaped <newline> (one preceded by a backslash) is found any‐
290 where in the makefile except in a command line, it shall be replaced,
291 along with any leading white space on the following line, with a single
292 <space>. When an escaped <newline> is found in a command line in a
293 makefile, the command line shall contain the backslash, the <newline>,
294 and the next line, except that the first character of the next line
295 shall not be included if it is a <tab>.
296
297 Makefile Execution
298 Makefile command lines shall be processed one at a time by writing the
299 makefile command line to the standard output (unless one of the condi‐
300 tions listed under '@' suppresses the writing) and executing the com‐
301 mand(s) in the line. A <tab> may precede the command to standard out‐
302 put. Command execution shall be as if the makefile command line were
303 the argument to the system() function. The environment for the command
304 being executed shall contain all of the variables in the environment of
305 make.
306
307 By default, when make receives a non-zero status from the execution of
308 a command, it shall terminate with an error message to standard error.
309
310 Makefile command lines can have one or more of the following prefixes:
311 a hyphen ( '-' ), an at sign ( '@' ), or a plus sign ( '+' ). These
312 shall modify the way in which make processes the command. When a com‐
313 mand is written to standard output, the prefix shall not be included in
314 the output.
315
316 - If the command prefix contains a hyphen, or the -i option is
317 present, or the special target .IGNORE has either the current
318 target as a prerequisite or has no prerequisites, any error
319 found while executing the command shall be ignored.
320
321 @ If the command prefix contains an at sign and the make utility
322 command line -n option is not specified, or the -s option is
323 present, or the special target .SILENT has either the current
324 target as a prerequisite or has no prerequisites, the command
325 shall not be written to standard output before it is executed.
326
327 + If the command prefix contains a plus sign, this indicates a
328 makefile command line that shall be executed even if -n, -q, or
329 -t is specified.
330
331
332 Target Rules
333 Target rules are formatted as follows:
334
335
336 target [target...]: [prerequisite...][;command]
337 [<tab>command<tab>command...]
338
339 line that does not begin with <tab>
340
341 Target entries are specified by a <blank>-separated, non-null list of
342 targets, then a colon, then a <blank>-separated, possibly empty list of
343 prerequisites. Text following a semicolon, if any, and all following
344 lines that begin with a <tab>, are makefile command lines to be exe‐
345 cuted to update the target. The first non-empty line that does not
346 begin with a <tab> or '#' shall begin a new entry. An empty or blank
347 line, or a line beginning with '#', may begin a new entry.
348
349 Applications shall select target names from the set of characters con‐
350 sisting solely of periods, underscores, digits, and alphabetics from
351 the portable character set (see the Base Definitions volume of
352 IEEE Std 1003.1-2001, Section 6.1, Portable Character Set). Implementa‐
353 tions may allow other characters in target names as extensions. The
354 interpretation of targets containing the characters '%' and '' is
355 implementation-defined.
356
357 A target that has prerequisites, but does not have any commands, can be
358 used to add to the prerequisite list for that target. Only one target
359 rule for any given target can contain commands.
360
361 Lines that begin with one of the following are called special targets
362 and control the operation of make:
363
364 .DEFAULT
365 If the makefile uses this special target, the application shall
366 ensure that it is specified with commands, but without prerequi‐
367 sites. The commands shall be used by make if there are no other
368 rules available to build a target.
369
370 .IGNORE
371 Prerequisites of this special target are targets themselves;
372 this shall cause errors from commands associated with them to be
373 ignored in the same manner as specified by the -i option. Subse‐
374 quent occurrences of .IGNORE shall add to the list of targets
375 ignoring command errors. If no prerequisites are specified, make
376 shall behave as if the -i option had been specified and errors
377 from all commands associated with all targets shall be ignored.
378
379 .POSIX The application shall ensure that this special target is speci‐
380 fied without prerequisites or commands. If it appears as the
381 first non-comment line in the makefile, make shall process the
382 makefile as specified by this section; otherwise, the behavior
383 of make is unspecified.
384
385 .PRECIOUS
386 Prerequisites of this special target shall not be removed if
387 make receives one of the asynchronous events explicitly
388 described in the ASYNCHRONOUS EVENTS section. Subsequent occur‐
389 rences of .PRECIOUS shall add to the list of precious files. If
390 no prerequisites are specified, all targets in the makefile
391 shall be treated as if specified with .PRECIOUS.
392
393 .SCCS_GET
394 The application shall ensure that this special target is speci‐
395 fied without prerequisites. If this special target is included
396 in a makefile, the commands specified with this target shall
397 replace the default commands associated with this special target
398 (see Default Rules ). The commands specified with this target
399 are used to get all SCCS files that are not found in the current
400 directory.
401
402 When source files are named in a dependency list, make shall treat them
403 just like any other target. Because the source file is presumed to be
404 present in the directory, there is no need to add an entry for it to
405 the makefile. When a target has no dependencies, but is present in the
406 directory, make shall assume that that file is up-to-date. If, however,
407 an SCCS file named SCCS/s. source_file is found for a target
408 source_file, make compares the timestamp of the target file with that
409 of the SCCS/s.source_file to ensure the target is up-to-date. If the
410 target is missing, or if the SCCS file is newer, make shall automati‐
411 cally issue the commands specified for the .SCCS_GET special target to
412 retrieve the most recent version. However, if the target is writable by
413 anyone, make shall not retrieve a new version.
414
415 .SILENT
416 Prerequisites of this special target are targets themselves;
417 this shall cause commands associated with them not to be written
418 to the standard output before they are executed. Subsequent
419 occurrences of .SILENT shall add to the list of targets with
420 silent commands. If no prerequisites are specified, make shall
421 behave as if the -s option had been specified and no commands or
422 touch messages associated with any target shall be written to
423 standard output.
424
425 .SUFFIXES
426 Prerequisites of .SUFFIXES shall be appended to the list of
427 known suffixes and are used in conjunction with the inference
428 rules (see Inference Rules ). If .SUFFIXES does not have any
429 prerequisites, the list of known suffixes shall be cleared.
430
431
432 The special targets .IGNORE, .POSIX, .PRECIOUS, .SILENT, and .SUFFIXES
433 shall be specified without commands.
434
435 Targets with names consisting of a leading period followed by the
436 uppercase letters "POSIX" and then any other characters are reserved
437 for future standardization. Targets with names consisting of a leading
438 period followed by one or more uppercase letters are reserved for
439 implementation extensions.
440
441 Macros
442 Macro definitions are in the form:
443
444
445 string1 = [string2]
446
447 The macro named string1 is defined as having the value of string2,
448 where string2 is defined as all characters, if any, after the equal
449 sign, up to a comment character ( '#' ) or an unescaped <newline>. Any
450 <blank>s immediately before or after the equal sign shall be ignored.
451
452 Applications shall select macro names from the set of characters con‐
453 sisting solely of periods, underscores, digits, and alphabetics from
454 the portable character set (see the Base Definitions volume of
455 IEEE Std 1003.1-2001, Section 6.1, Portable Character Set). A macro
456 name shall not contain an equals sign. Implementations may allow other
457 characters in macro names as extensions.
458
459 Macros can appear anywhere in the makefile. Macro expansions using the
460 forms $( string1) or ${ string1} shall be replaced by string2, as fol‐
461 lows:
462
463 * Macros in target lines shall be evaluated when the target line is
464 read.
465
466 * Macros in makefile command lines shall be evaluated when the command
467 is executed.
468
469 * Macros in the string before the equals sign in a macro definition
470 shall be evaluated when the macro assignment is made.
471
472 * Macros after the equals sign in a macro definition shall not be
473 evaluated until the defined macro is used in a rule or command, or
474 before the equals sign in a macro definition.
475
476 The parentheses or braces are optional if string1 is a single charac‐
477 ter. The macro $$ shall be replaced by the single character '$' . If
478 string1 in a macro expansion contains a macro expansion, the results
479 are unspecified.
480
481 Macro expansions using the forms $( string1 [: subst1 =[ subst2 ]]) or
482 ${ string1 [: subst1 =[ subst2 ]]} can be used to replace all occur‐
483 rences of subst1 with subst2 when the macro substitution is performed.
484 The subst1 to be replaced shall be recognized when it is a suffix at
485 the end of a word in string1 (where a word, in this context, is defined
486 to be a string delimited by the beginning of the line, a <blank>, or a
487 <newline>). If string1 in a macro expansion contains a macro expansion,
488 the results are unspecified.
489
490 Macro expansions in string1 of macro definition lines shall be evalu‐
491 ated when read. Macro expansions in string2 of macro definition lines
492 shall be performed when the macro identified by string1 is expanded in
493 a rule or command.
494
495 Macro definitions shall be taken from the following sources, in the
496 following logical order, before the makefile(s) are read.
497
498 1. Macros specified on the make utility command line, in the order
499 specified on the command line. It is unspecified whether the inter‐
500 nal macros defined in Internal Macros are accepted from this
501 source.
502
503 2. Macros defined by the MAKEFLAGS environment variable, in the order
504 specified in the environment variable. It is unspecified whether
505 the internal macros defined in Internal Macros are accepted from
506 this source.
507
508 3. The contents of the environment, excluding the MAKEFLAGS and SHELL
509 variables and including the variables with null values.
510
511 4. Macros defined in the inference rules built into make.
512
513 Macro definitions from these sources shall not override macro defini‐
514 tions from a lower-numbered source. Macro definitions from a single
515 source (for example, the make utility command line, the MAKEFLAGS envi‐
516 ronment variable, or the other environment variables) shall override
517 previous macro definitions from the same source.
518
519 Macros defined in the makefile(s) shall override macro definitions that
520 occur before them in the makefile(s) and macro definitions from source
521 4. If the -e option is not specified, macros defined in the makefile(s)
522 shall override macro definitions from source 3. Macros defined in the
523 makefile(s) shall not override macro definitions from source 1 or
524 source 2.
525
526 Before the makefile(s) are read, all of the make utility command line
527 options (except -f and -p) and make utility command line macro defini‐
528 tions (except any for the MAKEFLAGS macro), not already included in the
529 MAKEFLAGS macro, shall be added to the MAKEFLAGS macro, quoted in an
530 implementation-defined manner such that when MAKEFLAGS is read by
531 another instance of the make command, the original macro's value is
532 recovered. Other implementation-defined options and macros may also be
533 added to the MAKEFLAGS macro. If this modifies the value of the MAKE‐
534 FLAGS macro, or, if the MAKEFLAGS macro is modified at any subsequent
535 time, the MAKEFLAGS environment variable shall be modified to match the
536 new value of the MAKEFLAGS macro. The result of setting MAKEFLAGS in
537 the Makefile is unspecified.
538
539 Before the makefile(s) are read, all of the make utility command line
540 macro definitions (except the MAKEFLAGS macro or the SHELL macro) shall
541 be added to the environment of make. Other implementation-defined vari‐
542 ables may also be added to the environment of make.
543
544 The SHELL macro shall be treated specially. It shall be provided by
545 make and set to the pathname of the shell command language interpreter
546 (see sh ). The SHELL environment variable shall not affect the value of
547 the SHELL macro. If SHELL is defined in the makefile or is specified on
548 the command line, it shall replace the original value of the SHELL
549 macro, but shall not affect the SHELL environment variable. Other
550 effects of defining SHELL in the makefile or on the command line are
551 implementation-defined.
552
553 Inference Rules
554 Inference rules are formatted as follows:
555
556
557 target:
558 <tab>command
559 [<tab>command]...
560
561
562 line that does not begin with <tab> or #
563
564 The application shall ensure that the target portion is a valid target
565 name (see Target Rules ) of the form .s2 or .s1.s2 (where .s1 and .s2
566 are suffixes that have been given as prerequisites of the .SUFFIXES
567 special target and s1 and s2 do not contain any slashes or periods.) If
568 there is only one period in the target, it is a single-suffix inference
569 rule. Targets with two periods are double-suffix inference rules.
570 Inference rules can have only one target before the colon.
571
572 The application shall ensure that the makefile does not specify prereq‐
573 uisites for inference rules; no characters other than white space shall
574 follow the colon in the first line, except when creating the empty
575 rule, described below. Prerequisites are inferred, as described below.
576
577 Inference rules can be redefined. A target that matches an existing
578 inference rule shall overwrite the old inference rule. An empty rule
579 can be created with a command consisting of simply a semicolon (that
580 is, the rule still exists and is found during inference rule search,
581 but since it is empty, execution has no effect). The empty rule can
582 also be formatted as follows:
583
584
585 rule: ;
586
587 where zero or more <blank>s separate the colon and semicolon.
588
589 The make utility uses the suffixes of targets and their prerequisites
590 to infer how a target can be made up-to-date. A list of inference rules
591 defines the commands to be executed. By default, make contains a built-
592 in set of inference rules. Additional rules can be specified in the
593 makefile.
594
595 The special target .SUFFIXES contains as its prerequisites a list of
596 suffixes that shall be used by the inference rules. The order in which
597 the suffixes are specified defines the order in which the inference
598 rules for the suffixes are used. New suffixes shall be appended to the
599 current list by specifying a .SUFFIXES special target in the makefile.
600 A .SUFFIXES target with no prerequisites shall clear the list of suf‐
601 fixes. An empty .SUFFIXES target followed by a new .SUFFIXES list is
602 required to change the order of the suffixes.
603
604 Normally, the user would provide an inference rule for each suffix.
605 The inference rule to update a target with a suffix .s1 from a prereq‐
606 uisite with a suffix .s2 is specified as a target .s2.s1. The internal
607 macros provide the means to specify general inference rules (see Inter‐
608 nal Macros ).
609
610 When no target rule is found to update a target, the inference rules
611 shall be checked. The suffix of the target ( .s1) to be built is com‐
612 pared to the list of suffixes specified by the .SUFFIXES special tar‐
613 gets. If the .s1 suffix is found in .SUFFIXES, the inference rules
614 shall be searched in the order defined for the first .s2.s1 rule whose
615 prerequisite file ( $*.s2) exists. If the target is out-of-date with
616 respect to this prerequisite, the commands for that inference rule
617 shall be executed.
618
619 If the target to be built does not contain a suffix and there is no
620 rule for the target, the single suffix inference rules shall be
621 checked. The single-suffix inference rules define how to build a target
622 if a file is found with a name that matches the target name with one of
623 the single suffixes appended. A rule with one suffix .s2 is the defini‐
624 tion of how to build target from target.s2. The other suffix ( .s1) is
625 treated as null.
626
627 A tilde ( '~' ) in the above rules refers to an SCCS file in the cur‐
628 rent directory. Thus, the rule .c~.o would transform an SCCS C-language
629 source file into an object file ( .o). Because the s. of the SCCS files
630 is a prefix, it is incompatible with make's suffix point of view.
631 Hence, the '~' is a way of changing any file reference into an SCCS
632 file reference.
633
634 Libraries
635 If a target or prerequisite contains parentheses, it shall be treated
636 as a member of an archive library. For the lib( member .o) expression
637 lib refers to the name of the archive library and member .o to the mem‐
638 ber name. The application shall ensure that the member is an object
639 file with the .o suffix. The modification time of the expression is the
640 modification time for the member as kept in the archive library; see ar
641 . The .a suffix shall refer to an archive library. The .s2.a rule shall
642 be used to update a member in the library from a file with a suffix
643 .s2.
644
645 Internal Macros
646 The make utility shall maintain five internal macros that can be used
647 in target and inference rules. In order to clearly define the meaning
648 of these macros, some clarification of the terms target rule, inference
649 rule, target, and prerequisite is necessary.
650
651 Target rules are specified by the user in a makefile for a particular
652 target. Inference rules are user-specified or make-specified rules for
653 a particular class of target name. Explicit prerequisites are those
654 prerequisites specified in a makefile on target lines. Implicit prereq‐
655 uisites are those prerequisites that are generated when inference rules
656 are used. Inference rules are applied to implicit prerequisites or to
657 explicit prerequisites that do not have target rules defined for them
658 in the makefile. Target rules are applied to targets specified in the
659 makefile.
660
661 Before any target in the makefile is updated, each of its prerequisites
662 (both explicit and implicit) shall be updated. This shall be accom‐
663 plished by recursively processing each prerequisite. Upon recursion,
664 each prerequisite shall become a target itself. Its prerequisites in
665 turn shall be processed recursively until a target is found that has no
666 prerequisites, at which point the recursion stops. The recursion shall
667 then back up, updating each target as it goes.
668
669 In the definitions that follow, the word target refers to one of:
670
671 * A target specified in the makefile
672
673 * An explicit prerequisite specified in the makefile that becomes the
674 target when make processes it during recursion
675
676 * An implicit prerequisite that becomes a target when make processes
677 it during recursion
678
679 In the definitions that follow, the word prerequisite refers to one of
680 the following:
681
682 * An explicit prerequisite specified in the makefile for a particular
683 target
684
685 * An implicit prerequisite generated as a result of locating an appro‐
686 priate inference rule and corresponding file that matches the suffix
687 of the target
688
689 The five internal macros are:
690
691 $@ The $@ shall evaluate to the full target name of the current
692 target, or the archive filename part of a library archive tar‐
693 get. It shall be evaluated for both target and inference rules.
694
695 For example, in the .c.a inference rule, $@ represents the out-of-date
696 .a file to be built. Similarly, in a makefile target rule to build
697 lib.a from file.c, $@ represents the out-of-date lib.a.
698
699 $% The $% macro shall be evaluated only when the current target is
700 an archive library member of the form libname( member .o). In
701 these cases, $@ shall evaluate to libname and $% shall evaluate
702 to member .o. The $% macro shall be evaluated for both target
703 and inference rules.
704
705 For example, in a makefile target rule to build lib.a( file.o), $% rep‐
706 resents file.o, as opposed to $@, which represents lib.a.
707
708 $? The $? macro shall evaluate to the list of prerequisites that
709 are newer than the current target. It shall be evaluated for
710 both target and inference rules.
711
712 For example, in a makefile target rule to build prog from file1.o,
713 file2.o, and file3.o, and where prog is not out-of-date with respect to
714 file1.o, but is out-of-date with respect to file2.o and file3.o, $?
715 represents file2.o and file3.o.
716
717 $< In an inference rule, the $< macro shall evaluate to the file‐
718 name whose existence allowed the inference rule to be chosen for
719 the target. In the .DEFAULT rule, the $< macro shall evaluate to
720 the current target name. The meaning of the $< macro shall be
721 otherwise unspecified.
722
723 For example, in the .c.a inference rule, $< represents the prerequisite
724 .c file.
725
726 $* The $* macro shall evaluate to the current target name with its
727 suffix deleted. It shall be evaluated at least for inference
728 rules.
729
730 For example, in the .c.a inference rule, $*.o represents the out-of-
731 date .o file that corresponds to the prerequisite .c file.
732
733
734 Each of the internal macros has an alternative form. When an uppercase
735 'D' or 'F' is appended to any of the macros, the meaning shall be
736 changed to the directory part for 'D' and filename part for 'F' . The
737 directory part is the path prefix of the file without a trailing slash;
738 for the current directory, the directory part is '.' . When the $?
739 macro contains more than one prerequisite filename, the $(?D) and $(?F)
740 (or ${?D} and ${?F}) macros expand to a list of directory name parts
741 and filename parts respectively.
742
743 For the target lib( member .o) and the s2.a rule, the internal macros
744 shall be defined as:
745
746 $< member .s2
747
748 $* member
749
750 $@ lib
751
752 $? member .s2
753
754 $% member .o
755
756
757 Default Rules
758 The default rules for make shall achieve results that are the same as
759 if the following were used. Implementations that do not support the C-
760 Language Development Utilities option may omit CC, CFLAGS, YACC,
761 YFLAGS, LEX, LFLAGS, LDFLAGS, and the .c, .y, and .l inference rules.
762 Implementations that do not support FORTRAN may omit FC, FFLAGS, and
763 the .f inference rules. Implementations may provide additional macros
764 and rules.
765
766
767 SPECIAL TARGETS
768
769
770 .SCCS_GET: sccs $(SCCSFLAGS) get $(SCCSGETFLAGS) $@
771
772
773
774
775 .SUFFIXES: .o .c .y .l .a .sh .f .c~ .y~ .l~ .sh~ .f~
776
777
778 MACROS
779
780 MAKE=make
781 AR=ar
782 ARFLAGS=-rv
783 YACC=yacc
784 YFLAGS=
785 LEX=lex
786 LFLAGS=
787 LDFLAGS=
788 CC=c99
789 CFLAGS=-O
790 FC=fort77
791 FFLAGS=-O 1
792
793 GET=get
794 GFLAGS=
795 SCCSFLAGS=
796 SCCSGETFLAGS=-s
797
798
799
800 SINGLE SUFFIX RULES
801
802 .c:
803 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $<
804
805
806 .f:
807 $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $<
808
809
810 .sh:
811 cp $< $@
812 chmod a+x $@
813
814
815
816 .c~:
817 $(GET) $(GFLAGS) -p $< > $*.c
818 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $*.c
819
820
821 .f~:
822 $(GET) $(GFLAGS) -p $< > $*.f
823 $(FC) $(FFLAGS) $(LDFLAGS) -o $@ $*.f
824
825
826 .sh~:
827 $(GET) $(GFLAGS) -p $< > $*.sh
828 cp $*.sh $@
829 chmod a+x $@
830
831
832
833 DOUBLE SUFFIX RULES
834
835 .c.o:
836 $(CC) $(CFLAGS) -c $<
837
838
839 .f.o:
840 $(FC) $(FFLAGS) -c $<
841
842
843 .y.o:
844 $(YACC) $(YFLAGS) $<
845 $(CC) $(CFLAGS) -c y.tab.c
846 rm -f y.tab.c
847 mv y.tab.o $@
848
849
850 .l.o:
851 $(LEX) $(LFLAGS) $<
852 $(CC) $(CFLAGS) -c lex.yy.c
853 rm -f lex.yy.c
854 mv lex.yy.o $@
855
856
857 .y.c:
858 $(YACC) $(YFLAGS) $<
859 mv y.tab.c $@
860
861
862 .l.c:
863 $(LEX) $(LFLAGS) $<
864 mv lex.yy.c $@
865
866
867
868 .c~.o:
869 $(GET) $(GFLAGS) -p $< > $*.c
870 $(CC) $(CFLAGS) -c $*.c
871
872
873 .f~.o:
874 $(GET) $(GFLAGS) -p $< > $*.f
875 $(FC) $(FFLAGS) -c $*.f
876
877
878 .y~.o:
879 $(GET) $(GFLAGS) -p $< > $*.y
880 $(YACC) $(YFLAGS) $*.y
881 $(CC) $(CFLAGS) -c y.tab.c
882 rm -f y.tab.c
883 mv y.tab.o $@
884
885
886 .l~.o:
887 $(GET) $(GFLAGS) -p $< > $*.l
888 $(LEX) $(LFLAGS) $*.l
889 $(CC) $(CFLAGS) -c lex.yy.c
890 rm -f lex.yy.c
891 mv lex.yy.o $@
892
893
894 .y~.c:
895 $(GET) $(GFLAGS) -p $< > $*.y
896 $(YACC) $(YFLAGS) $*.y
897 mv y.tab.c $@
898
899
900 .l~.c:
901 $(GET) $(GFLAGS) -p $< > $*.l
902 $(LEX) $(LFLAGS) $*.l
903 mv lex.yy.c $@
904
905
906
907 .c.a:
908 $(CC) -c $(CFLAGS) $<
909 $(AR) $(ARFLAGS) $@ $*.o
910 rm -f $*.o
911
912
913 .f.a:
914 $(FC) -c $(FFLAGS) $<
915 $(AR) $(ARFLAGS) $@ $*.o
916 rm -f $*.o
917
919 When the -q option is specified, the make utility shall exit with one
920 of the following values:
921
922 0 Successful completion.
923
924 1 The target was not up-to-date.
925
926 >1 An error occurred.
927
928
929 When the -q option is not specified, the make utility shall exit with
930 one of the following values:
931
932 0 Successful completion.
933
934 >0 An error occurred.
935
936
938 Default.
939
940 The following sections are informative.
941
943 If there is a source file (such as ./source.c) and there are two SCCS
944 files corresponding to it ( ./s.source.c and ./SCCS/s.source.c), on
945 XSI-conformant systems make uses the SCCS file in the current direc‐
946 tory. However, users are advised to use the underlying SCCS utilities (
947 admin, delta, get, and so on) or the sccs utility for all source files
948 in a given directory. If both forms are used for a given source file,
949 future developers are very likely to be confused.
950
951 It is incumbent upon portable makefiles to specify the .POSIX special
952 target in order to guarantee that they are not affected by local exten‐
953 sions.
954
955 The -k and -S options are both present so that the relationship between
956 the command line, the MAKEFLAGS variable, and the makefile can be con‐
957 trolled precisely. If the k flag is passed in MAKEFLAGS and a command
958 is of the form:
959
960
961 $(MAKE) -S foo
962
963 then the default behavior is restored for the child make.
964
965 When the -n option is specified, it is always added to MAKEFLAGS . This
966 allows a recursive make -n target to be used to see all of the action
967 that would be taken to update target.
968
969 Because of widespread historical practice, interpreting a '#' number
970 sign inside a variable as the start of a comment has the unfortunate
971 side effect of making it impossible to place a number sign in a vari‐
972 able, thus forbidding something like:
973
974
975 CFLAGS = "-D COMMENT_CHAR='#'"
976
977 Many historical make utilities stop chaining together inference rules
978 when an intermediate target is nonexistent. For example, it might be
979 possible for a make to determine that both .y.c and .c.o could be used
980 to convert a .y to a .o. Instead, in this case, make requires the use
981 of a .y.o rule.
982
983 The best way to provide portable makefiles is to include all of the
984 rules needed in the makefile itself. The rules provided use only fea‐
985 tures provided by other parts of this volume of IEEE Std 1003.1-2001.
986 The default rules include rules for optional commands in this volume of
987 IEEE Std 1003.1-2001. Only rules pertaining to commands that are pro‐
988 vided are needed in an implementation's default set.
989
990 Macros used within other macros are evaluated when the new macro is
991 used rather than when the new macro is defined. Therefore:
992
993
994 MACRO = value1NEW = $(MACRO)
995 MACRO = value2
996
997 target:
998 echo $(NEW)
999
1000 would produce value2 and not value1 since NEW was not expanded until it
1001 was needed in the echo command line.
1002
1003 Some historical applications have been known to intermix target_name
1004 and macro=name operands on the command line, expecting that all of the
1005 macros are processed before any of the targets are dealt with. Conform‐
1006 ing applications do not do this, although some backwards-compatibility
1007 support may be included in some implementations.
1008
1009 The following characters in filenames may give trouble: '=', ':', '`',
1010 '", and '@' . For inference rules, the description of $< and $? seem
1011 similar. However, an example shows the minor difference. In a makefile
1012 containing:
1013
1014
1015 foo.o: foo.h
1016
1017 if foo.h is newer than foo.o, yet foo.c is older than foo.o, the built-
1018 in rule to make foo.o from foo.c is used, with $< equal to foo.c and $?
1019 equal to foo.h. If foo.c is also newer than foo.o, $< is equal to foo.c
1020 and $? is equal to foo.h foo.c.
1021
1023 1. The following command:
1024
1025
1026 make
1027
1028 makes the first target found in the makefile.
1029
1030 2. The following command:
1031
1032
1033 make junk
1034
1035 makes the target junk.
1036
1037 3. The following makefile says that pgm depends on two files, a.o and
1038 b.o, and that they in turn depend on their corresponding source
1039 files ( a.c and b.c), and a common file incl.h:
1040
1041
1042 pgm: a.o b.o
1043 c99 a.o b.o -o pgm
1044 a.o: incl.h a.c
1045 c99 -c a.c
1046 b.o: incl.h b.c
1047 c99 -c b.c
1048
1049 4. An example for making optimized .o files from .c files is:
1050
1051
1052 .c.o:
1053 c99 -c -O $*.c
1054
1055 or:
1056
1057
1058 .c.o:
1059 c99 -c -O $<
1060
1061 5. The most common use of the archive interface follows. Here, it is
1062 assumed that the source files are all C-language source:
1063
1064
1065 lib: lib(file1.o) lib(file2.o) lib(file3.o)
1066 @echo lib is now up-to-date
1067
1068 The .c.a rule is used to make file1.o, file2.o, and file3.o and insert
1069 them into lib.
1070
1071 The treatment of escaped <newline>s throughout the makefile is histori‐
1072 cal practice. For example, the inference rule:
1073
1074
1075 .c.o\
1076 :
1077
1078 works, and the macro:
1079
1080
1081 f= bar baz\
1082 biz
1083 a:
1084 echo ==$f==
1085
1086 echoes "==bar baz biz==" .
1087
1088 If $? were:
1089
1090
1091 /usr/include/stdio.h /usr/include/unistd.h foo.h
1092
1093 then $(?D) would be:
1094
1095
1096 /usr/include /usr/include .
1097
1098 and $(?F) would be:
1099
1100
1101 stdio.h unistd.h foo.h
1102
1103 6. The contents of the built-in rules can be viewed by running:
1104
1105
1106 make -p -f /dev/null 2>/dev/null
1107
1109 The make utility described in this volume of IEEE Std 1003.1-2001 is
1110 intended to provide the means for changing portable source code into
1111 executables that can be run on an IEEE Std 1003.1-2001-conforming sys‐
1112 tem. It reflects the most common features present in System V and BSD
1113 makes.
1114
1115 Historically, the make utility has been an especially fertile ground
1116 for vendor and research organization-specific syntax modifications and
1117 extensions. Examples include:
1118
1119 * Syntax supporting parallel execution (such as from various multi-
1120 processor vendors, GNU, and others)
1121
1122 * Additional "operators" separating targets and their prerequisites
1123 (System V, BSD, and others)
1124
1125 * Specifying that command lines containing the strings "${MAKE}" and
1126 "$(MAKE)" are executed when the -n option is specified (GNU and Sys‐
1127 tem V)
1128
1129 * Modifications of the meaning of internal macros when referencing
1130 libraries (BSD and others)
1131
1132 * Using a single instance of the shell for all of the command lines of
1133 the target (BSD and others)
1134
1135 * Allowing spaces as well as tabs to delimit command lines (BSD)
1136
1137 * Adding C preprocessor-style "include" and "ifdef" constructs (System
1138 V, GNU, BSD, and others)
1139
1140 * Remote execution of command lines (Sprite and others)
1141
1142 * Specifying additional special targets (BSD, System V, and most oth‐
1143 ers)
1144
1145 Additionally, many vendors and research organizations have rethought
1146 the basic concepts of make, creating vastly extended, as well as com‐
1147 pletely new, syntaxes. Each of these versions of make fulfills the
1148 needs of a different community of users; it is unreasonable for this
1149 volume of IEEE Std 1003.1-2001 to require behavior that would be incom‐
1150 patible (and probably inferior) to historical practice for such a com‐
1151 munity.
1152
1153 In similar circumstances, when the industry has enough sufficiently
1154 incompatible formats as to make them irreconcilable, this volume of
1155 IEEE Std 1003.1-2001 has followed one or both of two courses of action.
1156 Commands have been renamed ( cksum, echo, and pax) and/or command line
1157 options have been provided to select the desired behavior ( grep, od,
1158 and pax).
1159
1160 Because the syntax specified for the make utility is, by and large, a
1161 subset of the syntaxes accepted by almost all versions of make, it was
1162 decided that it would be counter-productive to change the name. And
1163 since the makefile itself is a basic unit of portability, it would not
1164 be completely effective to reserve a new option letter, such as make
1165 -P, to achieve the portable behavior. Therefore, the special target
1166 .POSIX was added to the makefile, allowing users to specify "standard"
1167 behavior. This special target does not preclude extensions in the make
1168 utility, nor does it preclude such extensions being used by the make‐
1169 file specifying the target; it does, however, preclude any extensions
1170 from being applied that could alter the behavior of previously valid
1171 syntax; such extensions must be controlled via command line options or
1172 new special targets. It is incumbent upon portable makefiles to specify
1173 the .POSIX special target in order to guarantee that they are not
1174 affected by local extensions.
1175
1176 The portable version of make described in this reference page is not
1177 intended to be the state-of-the-art software generation tool and, as
1178 such, some newer and more leading-edge features have not been included.
1179 An attempt has been made to describe the portable makefile in a manner
1180 that does not preclude such extensions as long as they do not disturb
1181 the portable behavior described here.
1182
1183 When the -n option is specified, it is always added to MAKEFLAGS . This
1184 allows a recursive make -n target to be used to see all of the action
1185 that would be taken to update target.
1186
1187 The definition of MAKEFLAGS allows both the System V letter string and
1188 the BSD command line formats. The two formats are sufficiently differ‐
1189 ent to allow implementations to support both without ambiguity.
1190
1191 Early proposals stated that an "unquoted" number sign was treated as
1192 the start of a comment. The make utility does not pay any attention to
1193 quotes. A number sign starts a comment regardless of its surroundings.
1194
1195 The text about "other implementation-defined pathnames may also be
1196 tried" in addition to ./makefile and ./Makefile is to allow such exten‐
1197 sions as SCCS/s.Makefile and other variations. It was made an implemen‐
1198 tation-defined requirement (as opposed to unspecified behavior) to
1199 highlight surprising implementations that might select something unex‐
1200 pected like /etc/Makefile. XSI-conformant systems also try ./s.make‐
1201 file, SCCS/s.makefile, ./s.Makefile, and SCCS/s.Makefile.
1202
1203 Early proposals contained the macro NPROC as a means of specifying that
1204 make should use n processes to do the work required. While this feature
1205 is a valuable extension for many systems, it is not common usage and
1206 could require other non-trivial extensions to makefile syntax. This
1207 extension is not required by this volume of IEEE Std 1003.1-2001, but
1208 could be provided as a compatible extension. The macro PARALLEL is used
1209 by some historical systems with essentially the same meaning (but with‐
1210 out using a name that is a common system limit value). It is suggested
1211 that implementors recognize the existing use of NPROC and/or PARALLEL
1212 as extensions to make.
1213
1214 The default rules are based on System V. The default CC= value is c99
1215 instead of cc because this volume of IEEE Std 1003.1-2001 does not
1216 standardize the utility named cc. Thus, every conforming application
1217 would be required to define CC= c99 to expect to run. There is no
1218 advantage conferred by the hope that the makefile might hit the "pre‐
1219 ferred" compiler because this cannot be guaranteed to work. Also, since
1220 the portable makescript can only use the c99 options, no advantage is
1221 conferred in terms of what the script can do. It is a quality-of-imple‐
1222 mentation issue as to whether c99 is as valuable as cc.
1223
1224 The -d option to make is frequently used to produce debugging informa‐
1225 tion, but is too implementation-defined to add to this volume of
1226 IEEE Std 1003.1-2001.
1227
1228 The -p option is not passed in MAKEFLAGS on most historical implementa‐
1229 tions and to change this would cause many implementations to break
1230 without sufficiently increased portability.
1231
1232 Commands that begin with a plus sign ( '+' ) are executed even if the
1233 -n option is present. Based on the GNU version of make, the behavior of
1234 -n when the plus-sign prefix is encountered has been extended to apply
1235 to -q and -t as well. However, the System V convention of forcing com‐
1236 mand execution with -n when the command line of a target contains
1237 either of the strings "$(MAKE)" or "${MAKE}" has not been adopted. This
1238 functionality appeared in early proposals, but the danger of this
1239 approach was pointed out with the following example of a portion of a
1240 makefile:
1241
1242
1243 subdir:
1244 cd subdir; rm all_the_files; $(MAKE)
1245
1246 The loss of the System V behavior in this case is well-balanced by the
1247 safety afforded to other makefiles that were not aware of this situa‐
1248 tion. In any event, the command line plus-sign prefix can provide the
1249 desired functionality.
1250
1251 The double colon in the target rule format is supported in BSD systems
1252 to allow more than one target line containing the same target name to
1253 have commands associated with it. Since this is not functionality
1254 described in the SVID or XPG3 it has been allowed as an extension, but
1255 not mandated.
1256
1257 The default rules are provided with text specifying that the built-in
1258 rules shall be the same as if the listed set were used. The intent is
1259 that implementations should be able to use the rules without change,
1260 but will be allowed to alter them in ways that do not affect the pri‐
1261 mary behavior.
1262
1263 The best way to provide portable makefiles is to include all of the
1264 rules needed in the makefile itself. The rules provided use only fea‐
1265 tures provided by other portions of this volume of
1266 IEEE Std 1003.1-2001. The default rules include rules for optional
1267 commands in this volume of IEEE Std 1003.1-2001. Only rules pertaining
1268 to commands that are provided are needed in the default set of an
1269 implementation.
1270
1271 One point of discussion was whether to drop the default rules list from
1272 this volume of IEEE Std 1003.1-2001. They provide convenience, but do
1273 not enhance portability of applications. The prime benefit is in
1274 portability of users who wish to type make command and have the command
1275 build from a command.c file.
1276
1277 The historical MAKESHELL feature was omitted. In some implementations
1278 it is used to let a user override the shell to be used to run make com‐
1279 mands. This was confusing; for a portable make, the shell should be
1280 chosen by the makefile writer or specified on the make command line and
1281 not by a user running make.
1282
1283 The make utilities in most historical implementations process the pre‐
1284 requisites of a target in left-to-right order, and the makefile format
1285 requires this. It supports the standard idiom used in many makefiles
1286 that produce yacc programs; for example:
1287
1288
1289 foo: y.tab.o lex.o main.o
1290 $(CC) $(CFLAGS) -o $@ t.tab.o lex.o main.o
1291
1292 In this example, if make chose any arbitrary order, the lex.o might not
1293 be made with the correct y.tab.h. Although there may be better ways to
1294 express this relationship, it is widely used historically. Implementa‐
1295 tions that desire to update prerequisites in parallel should require an
1296 explicit extension to make or the makefile format to accomplish it, as
1297 described previously.
1298
1299 The algorithm for determining a new entry for target rules is partially
1300 unspecified. Some historical makes allow blank, empty, or comment lines
1301 within the collection of commands marked by leading <tab>s. A conform‐
1302 ing makefile must ensure that each command starts with a <tab>, but
1303 implementations are free to ignore blank, empty, and comment lines
1304 without triggering the start of a new entry.
1305
1306 The ASYNCHRONOUS EVENTS section includes having SIGTERM and SIGHUP,
1307 along with the more traditional SIGINT and SIGQUIT, remove the current
1308 target unless directed not to do so. SIGTERM and SIGHUP were added to
1309 parallel other utilities that have historically cleaned up their work
1310 as a result of these signals. When make receives any signal other than
1311 SIGQUIT, it is required to resend itself the signal it received so that
1312 it exits with a status that reflects the signal. The results from
1313 SIGQUIT are partially unspecified because, on systems that create core
1314 files upon receipt of SIGQUIT, the core from make would conflict with a
1315 core file from the command that was running when the SIGQUIT arrived.
1316 The main concern was to prevent damaged files from appearing up-to-date
1317 when make is rerun.
1318
1319 The .PRECIOUS special target was extended to affect all targets glob‐
1320 ally (by specifying no prerequisites). The .IGNORE and .SILENT special
1321 targets were extended to allow prerequisites; it was judged to be more
1322 useful in some cases to be able to turn off errors or echoing for a
1323 list of targets than for the entire makefile. These extensions to make
1324 in System V were made to match historical practice from the BSD make.
1325
1326 Macros are not exported to the environment of commands to be run. This
1327 was never the case in any historical make and would have serious conse‐
1328 quences. The environment is the same as the environment to make except
1329 that MAKEFLAGS and macros defined on the make command line are added.
1330
1331 Some implementations do not use system() for all command lines, as
1332 required by the portable makefile format; as a performance enhancement,
1333 they select lines without shell metacharacters for direct execution by
1334 execve(). There is no requirement that system() be used specifically,
1335 but merely that the same results be achieved. The metacharacters typi‐
1336 cally used to bypass the direct execve() execution have been any of:
1337
1338
1339 = | ^ ( ) ; & < > * ? [ ] : $ ` ' " \ \n
1340
1341 The default in some advanced versions of make is to group all the com‐
1342 mand lines for a target and execute them using a single shell invoca‐
1343 tion; the System V method is to pass each line individually to a sepa‐
1344 rate shell. The single-shell method has the advantages in performance
1345 and the lack of a requirement for many continued lines. However, con‐
1346 verting to this newer method has caused portability problems with many
1347 historical makefiles, so the behavior with the POSIX makefile is speci‐
1348 fied to be the same as that of System V. It is suggested that the spe‐
1349 cial target .ONESHELL be used as an implementation extension to achieve
1350 the single-shell grouping for a target or group of targets.
1351
1352 Novice users of make have had difficulty with the historical need to
1353 start commands with a <tab>. Since it is often difficult to discern
1354 differences between <tab>s and <space>s on terminals or printed list‐
1355 ings, confusing bugs can arise. In early proposals, an attempt was made
1356 to correct this problem by allowing leading <blank>s instead of <tab>s.
1357 However, implementors reported many makefiles that failed in subtle
1358 ways following this change, and it is difficult to implement a make
1359 that unambiguously can differentiate between macro and command lines.
1360 There is extensive historical practice of allowing leading spaces
1361 before macro definitions. Forcing macro lines into column 1 would be a
1362 significant backwards-compatibility problem for some makefiles. There‐
1363 fore, historical practice was restored.
1364
1365 The System V INCLUDE feature was considered, but not included. This
1366 would treat a line that began in the first column and contained INCLUDE
1367 <filename> as an indication to read <filename> at that point in the
1368 makefile. This is difficult to use in a portable way, and it raises
1369 concerns about nesting levels and diagnostics. System V, BSD, GNU, and
1370 others have used different methods for including files.
1371
1372 The System V dynamic dependency feature was not included. It would sup‐
1373 port:
1374
1375
1376 cat: $$@.c
1377
1378 that would expand to;
1379
1380
1381 cat: cat.c
1382
1383 This feature exists only in the new version of System V make and, while
1384 useful, is not in wide usage. This means that macros are expanded twice
1385 for prerequisites: once at makefile parse time and once at target
1386 update time.
1387
1388 Consideration was given to adding metarules to the POSIX make. This
1389 would make %.o: %.c the same as .c.o:. This is quite useful and avail‐
1390 able from some vendors, but it would cause too many changes to this
1391 make to support. It would have introduced rule chaining and new substi‐
1392 tution rules. However, the rules for target names have been set to
1393 reserve the '%' and '' characters. These are traditionally used to
1394 implement metarules and quoting of target names, respectively. Imple‐
1395 mentors are strongly encouraged to use these characters only for these
1396 purposes.
1397
1398 A request was made to extend the suffix delimiter character from a
1399 period to any character. The metarules feature in newer makes solves
1400 this problem in a more general way. This volume of IEEE Std 1003.1-2001
1401 is staying with the more conservative historical definition.
1402
1403 The standard output format for the -p option is not described because
1404 it is primarily a debugging option and because the format is not gener‐
1405 ally useful to programs. In historical implementations the output is
1406 not suitable for use in generating makefiles. The -p format has been
1407 variable across historical implementations. Therefore, the definition
1408 of -p was only to provide a consistently named option for obtaining
1409 make script debugging information.
1410
1411 Some historical implementations have not cleared the suffix list with
1412 -r.
1413
1414 Implementations should be aware that some historical applications have
1415 intermixed target_name and macro= value operands on the command line,
1416 expecting that all of the macros are processed before any of the tar‐
1417 gets are dealt with. Conforming applications do not do this, but some
1418 backwards-compatibility support may be warranted.
1419
1420 Empty inference rules are specified with a semicolon command rather
1421 than omitting all commands, as described in an early proposal. The lat‐
1422 ter case has no traditional meaning and is reserved for implementation
1423 extensions, such as in GNU make.
1424
1426 None.
1427
1429 Shell Command Language, ar, c99, get, lex, sccs, sh, yacc, the System
1430 Interfaces volume of IEEE Std 1003.1-2001, exec, system()
1431
1433 Portions of this text are reprinted and reproduced in electronic form
1434 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
1435 -- Portable Operating System Interface (POSIX), The Open Group Base
1436 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
1437 Electrical and Electronics Engineers, Inc and The Open Group. In the
1438 event of any discrepancy between this version and the original IEEE and
1439 The Open Group Standard, the original IEEE and The Open Group Standard
1440 is the referee document. The original Standard can be obtained online
1441 at http://www.opengroup.org/unix/online.html .
1442
1443
1444
1445IEEE/The Open Group 2003 MAKE(1P)