1BMAKE(1) FreeBSD General Commands Manual
2BMAKE(1)
3
4[1mNAME[0m
5 [1mbmake [22m‐‐ maintain program dependencies
6
7[1mSYNOPSIS[0m
8 [1mbmake [22m[[1m‐BeikNnqrSstWwX[22m] [[1m‐C [4m[22mdirecto‐
9ry[24m] [[1m‐D [4m[22mvariable[24m] [[1m‐d [4m[22mflags[24m]
10 [[1m‐f [4m[22mmakefile[24m] [[1m‐I [4m[22mdirecto‐
11ry[24m] [[1m‐J [4m[22mprivate[24m] [[1m‐j [4m[22mmax_jobs[24m]
12 [[1m‐m [4m[22mdirectory[24m] [[1m‐T [4m[22mfile[24m]
13[[1m‐V [4m[22mvariable[24m] [[1m‐v [4m[22mvariable[24m]
14 [[4mvariable=value[24m] [[4mtarget[24m [4m...[24m]
15
16[1mDESCRIPTION[0m
17 [1mbmake [22mis a program designed to simplify the mainte‐
18nance of other pro‐
19 grams. Its input is a list of specifications as to the
20files upon which
21 programs and other files depend. If no [1m‐f [4m[22mmake‐
22file[24m makefile option is
23 given, [1mbmake [22mwill try to open ‘[4mmakefile[24m’ then
24‘[4mMakefile[24m’ in order to find
25 the specifications. If the file ‘[4m.depend[24m’ exists, it
26is read (see
27 mkdep(1)).
28
29 This manual page is intended as a reference document only.
30For a more
31 thorough description of [1mbmake [22mand makefiles, please
32refer to [4mPMake[24m [4m‐[24m [4mA[0m
33 [4mTutorial[24m.
34
35 [1mbmake [22mwill prepend the contents of the [4mMAKE‐
36FLAGS[24m environment variable to
37 the command line arguments before parsing them.
38
39 The options are as follows:
40
41 [1m‐B [22mTry to be backwards compatible by executing a
42single shell per
43 command and by executing the commands to make the
44sources of a
45 dependency line in sequence.
46
47 [1m‐C [4m[22mdirectory[0m
48 Change to [4mdirectory[24m before reading the make‐
49files or doing any‐
50 thing else. If multiple [1m‐C [22moptions are spec‐
51ified, each is inter‐
52 preted relative to the previous one: [1m‐C
53[4m[22m/[24m [1m‐C [4m[22metc[24m is equivalent to
54 [1m‐C [4m[22m/etc[24m.
55
56 [1m‐D [4m[22mvariable[0m
57 Define [4mvariable[24m to be 1, in the global con‐
58text.
59
60 [1m‐d [4m[22m[‐]flags[0m
61 Turn on debugging, and specify which portions of
62[1mbmake [22mare to
63 print debugging information. Unless the flags are
64preceded by
65 ‘‐’ they are added to the [4mMAKEFLAGS[24m environ‐
66ment variable and will
67 be processed by any child make processes. By de‐
68fault, debugging
69 information is printed to standard error, but this
70can be changed
71 using the [4mF[24m debugging flag. The debugging
72output is always un‐
73 buffered; in addition, if debugging is enabled but
74debugging out‐
75 put is not directed to standard output, then the
76standard output
77 is line buffered. [4mFlags[24m is one or more of
78the following:
79
80 [4mA[24m Print all possible debugging informa‐
81tion; equivalent to
82 specifying all of the debugging flags.
83
84 [4ma[24m Print debugging information about ar‐
85chive searching and
86 caching.
87
88 [4mC[24m Print debugging information about
89current working direc‐
90 tory.
91
92 [4mc[24m Print debugging information about
93conditional evaluation.
94
95 [4md[24m Print debugging information about di‐
96rectory searching and
97 caching.
98
99 [4me[24m Print debugging information about
100failed commands and
101 targets.
102
103 [4mF[24m[[1m+[22m][4mfilename[0m
104 Specify where debugging output is written.
105This must be
106 the last flag, because it consumes the re‐
107mainder of the
108 argument. If the character immediately af‐
109ter the ‘F’
110 flag is ‘+’, then the file will be opened in
111append mode;
112 otherwise the file will be overwritten. If
113the file name
114 is ‘stdout’ or ‘stderr’ then debugging out‐
115put will be
116 written to the standard output or standard
117error output
118 file descriptors respectively (and the ‘+’
119option has no
120 effect). Otherwise, the output will be
121written to the
122 named file. If the file name ends ‘.%d’
123then the ‘%d’ is
124 replaced by the pid.
125
126 [4mf[24m Print debugging information about
127loop evaluation.
128
129 [4mg1[24m Print the input graph before making
130anything.
131
132 [4mg2[24m Print the input graph after making
133everything, or before
134 exiting on error.
135
136 [4mg3[24m Print the input graph before exiting
137on error.
138
139 [4mh[24m Print debugging information about
140hash table operations.
141
142 [4mj[24m Print debugging information about
143running multiple
144 shells.
145
146 [4mL[24m Turn on lint checks. This will throw
147errors for variable
148 assignments that do not parse correctly, at
149the time of
150 assignment so the file and line number are
151available.
152
153 [4ml[24m Print commands in Makefiles regard‐
154less of whether or not
155 they are prefixed by ‘@’ or other "quiet"
156flags. Also
157 known as "loud" behavior.
158
159 [4mM[24m Print debugging information about
160"meta" mode decisions
161 about targets.
162
163 [4mm[24m Print debugging information about
164making targets, includ‐
165 ing modification dates.
166
167 [4mn[24m Don’t delete the temporary command
168scripts created when
169 running commands. These temporary scripts
170are created in
171 the directory referred to by the TMPDIR en‐
172vironment vari‐
173 able, or in [4m/tmp[24m if TMPDIR is unset
174or set to the empty
175 string. The temporary scripts are created
176by mkstemp(3),
177 and have names of the form
178[4mmakeXXXXXX[24m. [4mNOTE[24m: This can
179 create many files in TMPDIR or [4m/tmp[24m,
180so use with care.
181
182 [4mp[24m Print debugging information about
183makefile parsing.
184
185 [4ms[24m Print debugging information about
186suffix‐transformation
187 rules.
188
189 [4mt[24m Print debugging information about
190target list mainte‐
191 nance.
192
193 [4mV[24m Force the [1m‐V [22moption to print
194raw values of variables,
195 overriding the default behavior set via
196 [4m.MAKE.EXPAND_VARIABLES[24m.
197
198 [4mv[24m Print debugging information about
199variable assignment.
200
201 [4mx[24m Run shell commands with [1m‐x [22mso
202the actual commands are
203 printed as they are executed.
204
205 [1m‐e [22mSpecify that environment variables override
206macro assignments
207 within makefiles.
208
209 [1m‐f [4m[22mmakefile[0m
210 Specify a makefile to read instead of the default
211‘[4mmakefile[24m’. If
212 [4mmakefile[24m is ‘[1m‐[22m’, standard input is
213read. Multiple makefiles may
214 be specified, and are read in the order specified.
215
216 [1m‐I [4m[22mdirectory[0m
217 Specify a directory in which to search for makefiles
218and included
219 makefiles. The system makefile directory (or direc‐
220tories, see
221 the [1m‐m [22moption) is automatically included as
222part of this list.
223
224 [1m‐i [22mIgnore non‐zero exit of shell commands in the
225makefile. Equiva‐
226 lent to specifying ‘[1m‐[22m’ before each command
227line in the makefile.
228
229 [1m‐J [4m[22mprivate[0m
230 This option should [4mnot[24m be specified by the
231user.
232
233 When the [4mj[24m option is in use in a recursive
234build, this option is
235 passed by a make to child makes to allow all the
236make processes
237 in the build to cooperate to avoid overloading the
238system.
239
240 [1m‐j [4m[22mmax_jobs[0m
241 Specify the maximum number of jobs that [1mbmake
242[22mmay have running at
243 any one time. The value is saved in
244[4m.MAKE.JOBS[24m. Turns compati‐
245 bility mode off, unless the [4mB[24m flag is also
246specified. When com‐
247 patibility mode is off, all commands associated with
248a target are
249 executed in a single shell invocation as opposed to
250the tradi‐
251 tional one shell invocation per line. This can
252break traditional
253 scripts which change directories on each command in‐
254vocation and
255 then expect to start with a fresh environment on the
256next line.
257 It is more efficient to correct the scripts rather
258than turn
259 backwards compatibility on.
260
261 [1m‐k [22mContinue processing after errors are encoun‐
262tered, but only on
263 those targets that do not depend on the target whose
264creation
265 caused the error.
266
267 [1m‐m [4m[22mdirectory[0m
268 Specify a directory in which to search for sys.mk
269and makefiles
270 included via the <[4mfile[24m>‐style include state‐
271ment. The [1m‐m [22moption
272 can be used multiple times to form a search path.
273This path will
274 override the default system include path:
275/usr/share/mk. Fur‐
276 thermore the system include path will be appended to
277the search
278 path used for "[4mfile[24m"‐style include statements
279(see the [1m‐I [22mop‐
280 tion).
281
282 If a file or directory name in the [1m‐m [22margu‐
283ment (or the
284 MAKESYSPATH environment variable) starts with the
285string ".../"
286 then [1mbmake [22mwill search for the specified file
287or directory named
288 in the remaining part of the argument string. The
289search starts
290 with the current directory of the Makefile and then
291works upward
292 towards the root of the file system. If the search
293is success‐
294 ful, then the resulting directory replaces the
295".../" specifica‐
296 tion in the [1m‐m [22margument. If used, this fea‐
297ture allows [1mbmake [22mto
298 easily search in the current source tree for custom‐
299ized sys.mk
300 files (e.g., by using ".../mk/sys.mk" as an argu‐
301ment).
302
303 [1m‐n [22mDisplay the commands that would have been ex‐
304ecuted, but do not
305 actually execute them unless the target depends on
306the .MAKE spe‐
307 cial source (see below) or the command is prefixed
308with ‘[1m+[22m’.
309
310 [1m‐N [22mDisplay the commands which would have been
311executed, but do not
312 actually execute any of them; useful for debugging
313top‐level
314 makefiles without descending into subdirectories.
315
316 [1m‐q [22mDo not execute any commands, but exit 0 if
317the specified targets
318 are up‐to‐date and 1, otherwise.
319
320 [1m‐r [22mDo not use the built‐in rules specified in
321the system makefile.
322
323 [1m‐S [22mStop processing if an error is encountered.
324This is the default
325 behavior and the opposite of [1m‐k[22m.
326
327 [1m‐s [22mDo not echo any commands as they are execut‐
328ed. Equivalent to
329 specifying ‘[1m@[22m’ before each command line in
330the makefile.
331
332 [1m‐T [4m[22mtracefile[0m
333 When used with the [1m‐j [22mflag, append a trace
334record to [4mtracefile[0m
335 for each job started and completed.
336
337 [1m‐t [22mRather than re‐building a target as specified
338in the makefile,
339 create it or update its modification time to make it
340appear up‐
341 to‐date.
342
343 [1m‐V [4m[22mvariable[0m
344 Print the value of [4mvariable[24m. Do not build
345any targets. Multiple
346 instances of this option may be specified; the vari‐
347ables will be
348 printed one per line, with a blank line for each
349null or unde‐
350 fined variable. The value printed is extracted from
351the global
352 context after all makefiles have been read. By de‐
353fault, the raw
354 variable contents (which may include additional un‐
355expanded vari‐
356 able references) are shown. If [4mvariable[24m con‐
357tains a ‘$’ then the
358 value will be recursively expanded to its complete
359resultant text
360 before printing. The expanded value will also be
361printed if
362 [4m.MAKE.EXPAND_VARIABLES[24m is set to true and the
363[1m‐dV [22moption has not
364 been used to override it. Note that loop‐local and
365target‐local
366 variables, as well as values taken temporarily by
367global vari‐
368 ables during makefile processing, are not accessible
369via this op‐
370 tion. The [1m‐dv [22mdebug mode can be used to see
371these at the cost of
372 generating substantial extraneous output.
373
374 [1m‐v [4m[22mvariable[0m
375 Like [1m‐V [22mbut the variable is always expanded
376to its complete
377 value.
378
379 [1m‐W [22mTreat any warnings during makefile parsing as
380errors.
381
382 [1m‐w [22mPrint entering and leaving directory mes‐
383sages, pre and post pro‐
384 cessing.
385
386 [1m‐X [22mDon’t export variables passed on the command
387line to the environ‐
388 ment individually. Variables passed on the command
389line are
390 still exported via the [4mMAKEFLAGS[24m environment
391variable. This op‐
392 tion may be useful on systems which have a small
393limit on the
394 size of command arguments.
395
396 [4mvariable=value[0m
397 Set the value of the variable [4mvariable[24m to
398[4mvalue[24m. Normally, all
399 values passed on the command line are also exported
400to sub‐makes
401 in the environment. The [1m‐X [22mflag disables
402this behavior. Vari‐
403 able assignments should follow options for POSIX
404compatibility
405 but no ordering is enforced.
406
407 There are seven different types of lines in a makefile: file
408dependency
409 specifications, shell commands, variable assignments, in‐
410clude statements,
411 conditional directives, for loops, and comments.
412
413 In general, lines may be continued from one line to the next
414by ending
415 them with a backslash (‘´). The trailing newline character
416and initial
417 whitespace on the following line are compressed into a sin‐
418gle space.
419
420[1mFILE DEPENDENCY SPECIFICATIONS[0m
421 Dependency lines consist of one or more targets, an opera‐
422tor, and zero or
423 more sources. This creates a relationship where the targets
424"depend" on
425 the sources and are customarily created from them. A target
426is consid‐
427 ered out‐of‐date if it does not exist, or if its modifica‐
428tion time is
429 less than that of any of its sources. An out‐of‐date target
430will be re‐
431 created, but not until all sources have been examined and
432themselves re‐
433 created as needed. Three operators may be used:
434
435 [1m: [22mMany dependency lines may name this target but
436only one may have
437 attached shell commands. All sources named in all de‐
438pendency lines
439 are considered together, and if needed the attached
440shell commands
441 are run to create or re‐create the target. If [1mb‐
442make [22mis inter‐
443 rupted, the target is removed.
444
445 [1m! [22mThe same, but the target is always re‐created
446whether or not it is
447 out of date.
448
449 [1m:: [22mAny dependency line may have attached shell
450commands, but each one
451 is handled independently: its sources are considered
452and the at‐
453 tached shell commands are run if the target is out of
454date with re‐
455 spect to (only) those sources. Thus, different groups
456of the at‐
457 tached shell commands may be run depending on the cir‐
458cumstances.
459 Furthermore, unlike [1m:, [22mfor dependency lines
460with no sources, the
461 attached shell commands are always run. Also unlike
462[1m:, [22mthe target
463 will not be removed if [1mbmake [22mis interrupted.
464 All dependency lines mentioning a particular target must use
465the same op‐
466 erator.
467
468 Targets and sources may contain the shell wildcard values
469‘?’, ‘*’, ‘[]’,
470 and ‘{}’. The values ‘?’, ‘*’, and ‘[]’ may only be used as
471part of the
472 final component of the target or source, and must be used to
473describe ex‐
474 isting files. The value ‘{}’ need not necessarily be used
475to describe
476 existing files. Expansion is in directory order, not alpha‐
477betically as
478 done in the shell.
479
480[1mSHELL COMMANDS[0m
481 Each target may have associated with it one or more lines of
482shell com‐
483 mands, normally used to create the target. Each of the
484lines in this
485 script [4mmust[24m be preceded by a tab. (For historical
486reasons, spaces are
487 not accepted.) While targets can appear in many dependency
488lines if de‐
489 sired, by default only one of these rules may be followed by
490a creation
491 script. If the ‘[1m::[22m’ operator is used, however, all
492rules may include
493 scripts and the scripts are executed in the order found.
494
495 Each line is treated as a separate shell command, unless the
496end of line
497 is escaped with a backslash (‘´) in which case that line and
498the next
499 are combined. If the first characters of the command are
500any combination
501 of ‘[1m@[22m’, ‘[1m+[22m’, or ‘[1m‐[22m’, the command is
502treated specially. A ‘[1m@[22m’ causes the
503 command not to be echoed before it is executed. A
504‘[1m+[22m’ causes the command
505 to be executed even when [1m‐n [22mis given. This is simi‐
506lar to the effect of
507 the .MAKE special source, except that the effect can be lim‐
508ited to a sin‐
509 gle line of a script. A ‘[1m‐[22m’ in compatibility mode
510causes any non‐zero
511 exit status of the command line to be ignored.
512
513 When [1mbmake [22mis run in jobs mode with [1m‐j
514[4m[22mmax_jobs[24m, the entire script for
515 the target is fed to a single instance of the shell. In
516compatibility
517 (non‐jobs) mode, each command is run in a separate process.
518If the com‐
519 mand contains any shell meta characters
520(‘#=|^(){};&<>*?[]:$‘\n’) it
521 will be passed to the shell; otherwise [1mbmake [22mwill at‐
522tempt direct execu‐
523 tion. If a line starts with ‘[1m‐[22m’ and the shell has
524ErrCtl enabled then
525 failure of the command line will be ignored as in compati‐
526bility mode.
527 Otherwise ‘[1m‐[22m’ affects the entire job; the script will
528stop at the first
529 command line that fails, but the target will not be deemed
530to have
531 failed.
532
533 Makefiles should be written so that the mode of [1mbmake
534[22moperation does not
535 change their behavior. For example, any command which needs
536to use "cd"
537 or "chdir" without potentially changing the directory for
538subsequent com‐
539 mands should be put in parentheses so it executes in a sub‐
540shell. To
541 force the use of one shell, escape the line breaks so as to
542make the
543 whole script one command. For example:
544
545 avoid‐chdir‐side‐effects:
546 @echo Building $@ in ‘pwd‘
547 @(cd ${.CURDIR} && ${MAKE} $@)
548 @echo Back in ‘pwd‘
549
550 ensure‐one‐shell‐regardless‐of‐mode:
551 @echo Building $@ in ‘pwd‘;
552(cd ${.CURDIR} && ${MAKE} $@); echo Back in
553‘pwd‘
554
555 Since [1mbmake [22mwill chdir(2) to ‘[4m.OBJDIR[24m’ before
556executing any targets, each
557 child process starts with that as its current working direc‐
558tory.
559
560[1mVARIABLE ASSIGNMENTS[0m
561 Variables in make are much like variables in the shell, and,
562by tradi‐
563 tion, consist of all upper‐case letters.
564
565 [1mVariable assignment modifiers[0m
566 The five operators that can be used to assign values to
567variables are as
568 follows:
569
570 [1m= [22mAssign the value to the variable. Any previ‐
571ous value is overrid‐
572 den.
573
574 [1m+= [22mAppend the value to the current value of the
575variable.
576
577 [1m?= [22mAssign the value to the variable if it is not
578already defined.
579
580 [1m:= [22mAssign with expansion, i.e. expand the value
581before assigning it
582 to the variable. Normally, expansion is not done
583until the vari‐
584 able is referenced. [4mNOTE[24m: References to un‐
585defined variables are
586 [4mnot[24m expanded. This can cause problems when
587variable modifiers
588 are used.
589
590 [1m!= [22mExpand the value and pass it to the shell for
591execution and as‐
592 sign the result to the variable. Any newlines in
593the result are
594 replaced with spaces.
595
596 Any white‐space before the assigned [4mvalue[24m is removed;
597if the value is be‐
598 ing appended, a single space is inserted between the previ‐
599ous contents of
600 the variable and the appended value.
601
602 Variables are expanded by surrounding the variable name with
603either curly
604 braces (‘{}’) or parentheses (‘()’) and preceding it with a
605dollar sign
606 (‘$’). If the variable name contains only a single letter,
607the surround‐
608 ing braces or parentheses are not required. This shorter
609form is not
610 recommended.
611
612 If the variable name contains a dollar, then the name itself
613is expanded
614 first. This allows almost arbitrary variable names, however
615names con‐
616 taining dollar, braces, parentheses, or whitespace are real‐
617ly best
618 avoided!
619
620 If the result of expanding a variable contains a dollar sign
621(‘$’) the
622 string is expanded again.
623
624 Variable substitution occurs at three distinct times, de‐
625pending on where
626 the variable is being used.
627
628 1. Variables in dependency lines are expanded as the line
629is read.
630
631 2. Variables in shell commands are expanded when the shell
632command is
633 executed.
634
635 3. ".for" loop index variables are expanded on each loop
636iteration.
637 Note that other variables are not expanded inside loops
638so the fol‐
639 lowing example code:
640
641
642 .for i in 1 2 3
643 a+= ${i}
644 j= ${i}
645 b+= ${j}
646 .endfor
647
648 all:
649 @echo ${a}
650 @echo ${b}
651
652 will print:
653
654 1 2 3
655 3 3 3
656
657 Because while ${a} contains "1 2 3" after the loop is
658executed, ${b}
659 contains "${j} ${j} ${j}" which expands to "3 3 3"
660since after the
661 loop completes ${j} contains "3".
662
663 [1mVariable classes[0m
664 The four different classes of variables (in order of in‐
665creasing prece‐
666 dence) are:
667
668 Environment variables
669 Variables defined as part of [1mbmake[22m’s environ‐
670ment.
671
672 Global variables
673 Variables defined in the makefile or in included
674makefiles.
675
676 Command line variables
677 Variables defined as part of the command line.
678
679 Local variables
680 Variables that are defined specific to a certain
681target.
682
683 Local variables are all built in and their values vary magi‐
684cally from
685 target to target. It is not currently possible to define
686new local vari‐
687 ables. The seven local variables are as follows:
688
689 [4m.ALLSRC[24m The list of all sources for this tar‐
690get; also known as
691 ‘[4m>[24m’.
692
693 [4m.ARCHIVE[24m The name of the archive file; also
694known as ‘[4m![24m’.
695
696 [4m.IMPSRC[24m In suffix‐transformation rules, the
697name/path of the
698 source from which the target is to be trans‐
699formed (the
700 "implied" source); also known as ‘[4m<[24m’.
701It is not defined
702 in explicit rules.
703
704 [4m.MEMBER[24m The name of the archive member; also
705known as ‘[4m%[24m’.
706
707 [4m.OODATE[24m The list of sources for this target
708that were deemed out‐
709 of‐date; also known as ‘[4m?[24m’.
710
711 [4m.PREFIX[24m The file prefix of the target, con‐
712taining only the file
713 portion, no suffix or preceding directory
714components;
715 also known as ‘[4m*[24m’. The suffix must
716be one of the known
717 suffixes declared with [1m.SUFFIXES [22mor
718it will not be recog‐
719 nized.
720
721 [4m.TARGET[24m The name of the target; also known as
722‘[4m@[24m’. For compati‐
723 bility with other makes this is an alias for
724[1m.ARCHIVE [22min
725 archive member rules.
726
727 The shorter forms (‘[4m>[24m’, ‘[4m![24m’, ‘[4m<[24m’,
728‘[4m%[24m’, ‘[4m?[24m’, ‘[4m*[24m’, and ‘[4m@[24m’) are permitted
729 for backward compatibility with historical makefiles and
730legacy POSIX
731 make and are not recommended.
732
733 Variants of these variables with the punctuation followed
734immediately by
735 ‘D’ or ‘F’, e.g. ‘[4m$(@D)[24m’, are legacy forms equiva‐
736lent to using the ‘:H’
737 and ‘:T’ modifiers. These forms are accepted for compati‐
738bility with AT&T
739 System V UNIX makefiles and POSIX but are not recommended.
740
741 Four of the local variables may be used in sources on depen‐
742dency lines
743 because they expand to the proper value for each target on
744the line.
745 These variables are ‘[4m.TARGET[24m’, ‘[4m.PREFIX[24m’,
746‘[4m.ARCHIVE[24m’, and ‘[4m.MEMBER[24m’.
747
748 [1mAdditional built‐in variables[0m
749 In addition, [1mbmake [22msets or knows about the following
750variables:
751
752 [4m$[24m A single dollar sign ‘$’, i.e. ‘$$’
753expands to a single
754 dollar sign.
755
756 [4m.ALLTARGETS[24m The list of all targets encountered
757in the Makefile. If
758 evaluated during Makefile parsing, lists on‐
759ly those tar‐
760 gets encountered thus far.
761
762 [4m.CURDIR[24m A path to the directory where [1mb‐
763make [22mwas executed. Refer
764 to the description of ‘PWD’ for more de‐
765tails.
766
767 [4m.INCLUDEDFROMDIR[0m
768 The directory of the file this Makefile was
769included
770 from.
771
772 [4m.INCLUDEDFROMFILE[0m
773 The filename of the file this Makefile was
774included from.
775
776 MAKE The name that [1mbmake [22mwas executed with
777([4margv[0][24m). For
778 compatibility [1mbmake [22malso sets
779[4m.MAKE[24m with the same value.
780 The preferred variable to use is the envi‐
781ronment variable
782 MAKE because it is more compatible with oth‐
783er versions of
784 [1mbmake [22mand cannot be confused with the
785special target with
786 the same name.
787
788 [4m.MAKE.DEPENDFILE[0m
789 Names the makefile (default ‘[4m.de‐
790pend[24m’) from which gener‐
791 ated dependencies are read.
792
793 [4m.MAKE.EXPAND_VARIABLES[0m
794 A boolean that controls the default behavior
795of the [1m‐V[0m
796 option. If true, variable values printed
797with [1m‐V [22mare
798 fully expanded; if false, the raw variable
799contents
800 (which may include additional unexpanded
801variable refer‐
802 ences) are shown.
803
804 [4m.MAKE.EXPORTED[24m The list of variables exported by
805[1mbmake[22m.
806
807 [4m.MAKE.JOBS[24m The argument to the [1m‐j [22moption.
808
809 [4m.MAKE.JOB.PREFIX[0m
810 If [1mbmake [22mis run with [4mj[24m then
811output for each target is
812 prefixed with a token ‘‐‐‐ target ‐‐‐’ the
813first part of
814 which can be controlled via
815[4m.MAKE.JOB.PREFIX[24m. If
816 [4m.MAKE.JOB.PREFIX[24m is empty, no token
817is printed.
818 For example:
819 .MAKE.JOB.PREFIX=${.new‐
820line}‐‐‐${.MAKE:T}[${.MAKE.PID}]
821 would produce tokens like ‘‐‐‐make[1234]
822target ‐‐‐’ mak‐
823 ing it easier to track the degree of paral‐
824lelism being
825 achieved.
826
827 MAKEFLAGS The environment variable ‘MAKEFLAGS’ may
828contain anything
829 that may be specified on [1mbmake[22m’s com‐
830mand line. Anything
831 specified on [1mbmake[22m’s command line is
832appended to the
833 ‘MAKEFLAGS’ variable which is then entered
834into the envi‐
835 ronment for all programs which [1mbmake
836[22mexecutes.
837
838 [4m.MAKE.LEVEL[24m The recursion depth of [1mbmake[22m.
839The initial instance of
840 [1mbmake [22mwill be 0, and an incremented
841value is put into the
842 environment to be seen by the next genera‐
843tion. This al‐
844 lows tests like: .if ${.MAKE.LEVEL} == 0 to
845protect
846 things which should only be evaluated in the
847initial in‐
848 stance of [1mbmake[22m.
849
850 [4m.MAKE.MAKEFILE_PREFERENCE[0m
851 The ordered list of makefile names (default
852‘[4mmakefile[24m’,
853 ‘[4mMakefile[24m’) that [1mbmake [22mwill
854look for.
855
856 [4m.MAKE.MAKEFILES[0m
857 The list of makefiles read by [1mbmake[22m,
858which is useful for
859 tracking dependencies. Each makefile is
860recorded only
861 once, regardless of the number of times
862read.
863
864 [4m.MAKE.MODE[24m Processed after reading all make‐
865files. Can affect the
866 mode that [1mbmake [22mruns in. It can con‐
867tain a number of key‐
868 words:
869
870 [4mcompat[24m Like [1m‐B[22m,
871puts [1mbmake [22minto "compat"
872 mode.
873
874 [4mmeta[24m Puts [1mbmake
875[22minto "meta" mode, where
876 meta files are created
877for each tar‐
878 get to capture the com‐
879mand run, the
880 output generated and if
881filemon(4)
882 is available, the sys‐
883tem calls which
884 are of interest to
885[1mbmake[22m. The cap‐
886 tured output can be
887very useful when
888 diagnosing errors.
889
890 [4mcurdirOk=[24m [4mbf[24m Normally
891[1mbmake [22mwill not create .meta
892 files in ‘[4m.CUR‐
893DIR[24m’. This can be
894 overridden by setting
895[4mbf[24m to a value
896 which represents True.
897
898 [4mmissing‐meta=[24m [4mbf[24m If
899[4mbf[24m is True, then a missing .meta
900 file makes the target
901out‐of‐date.
902
903 [4mmissing‐filemon=[24m [4mbf[24m If
904[4mbf[24m is True, then missing filemon
905 data makes the target
906out‐of‐date.
907
908 [4mnofilemon[24m Do not use file‐
909mon(4).
910
911 [4menv[24m For debugging,
912it can be useful to
913 include the environment
914in the .meta
915 file.
916
917 [4mverbose[24m If in "meta"
918mode, print a clue
919 about the target being
920built. This
921 is useful if the build
922is otherwise
923 running silently. The
924message
925 printed the value of:
926 [4m.MAKE.META.PRE‐
927FIX[24m.
928
929 [4mignore‐cmd[24m Some makefiles
930have commands which
931 are simply not stable.
932This keyword
933 causes them to be ig‐
934nored for deter‐
935 mining whether a target
936is out of
937 date in "meta" mode.
938See also
939 [1m.NOMETA_CMP[22m.
940
941 [4msilent=[24m [4mbf[24m If
942[4mbf[24m is True, when a .meta file is
943 created, mark the tar‐
944get [1m.SILENT[22m.
945
946 [4m.MAKE.META.BAILIWICK[0m
947 In "meta" mode, provides a list of prefixes
948which match
949 the directories controlled by [1mbmake[22m.
950If a file that was
951 generated outside of [4m.OBJDIR[24m but
952within said bailiwick is
953 missing, the current target is considered
954out‐of‐date.
955
956 [4m.MAKE.META.CREATED[0m
957 In "meta" mode, this variable contains a
958list of all the
959 meta files updated. If not empty, it can be
960used to
961 trigger processing of
962[4m.MAKE.META.FILES[24m.
963
964 [4m.MAKE.META.FILES[0m
965 In "meta" mode, this variable contains a
966list of all the
967 meta files used (updated or not). This list
968can be used
969 to process the meta files to extract depen‐
970dency informa‐
971 tion.
972
973 [4m.MAKE.META.IGNORE_PATHS[0m
974 Provides a list of path prefixes that should
975be ignored;
976 because the contents are expected to change
977over time.
978 The default list includes: ‘[4m/dev[24m
979[4m/etc[24m [4m/proc[24m [4m/tmp[24m [4m/var/run[0m
980 [4m/var/tmp[24m’
981
982 [4m.MAKE.META.IGNORE_PATTERNS[0m
983 Provides a list of patterns to match against
984pathnames.
985 Ignore any that match.
986
987 [4m.MAKE.META.IGNORE_FILTER[0m
988 Provides a list of variable modifiers to ap‐
989ply to each
990 pathname. Ignore if the expansion is an
991empty string.
992
993 [4m.MAKE.META.PREFIX[0m
994 Defines the message printed for each meta
995file updated in
996 "meta verbose" mode. The default value is:
997 Building ${.TARGET:H:tA}/${.TARGET:T}
998
999 [4m.MAKEOVERRIDES[24m This variable is used to record the
1000names of variables
1001 assigned to on the command line, so that
1002they may be ex‐
1003 ported as part of ‘MAKEFLAGS’. This behav‐
1004ior can be dis‐
1005 abled by assigning an empty value to
1006‘[4m.MAKEOVERRIDES[24m’
1007 within a makefile. Extra variables can be
1008exported from
1009 a makefile by appending their names to
1010‘[4m.MAKEOVERRIDES[24m’.
1011 ‘MAKEFLAGS’ is re‐exported whenever
1012‘[4m.MAKEOVERRIDES[24m’ is
1013 modified.
1014
1015 [4m.MAKE.PATH_FILEMON[0m
1016 If [1mbmake [22mwas built with filemon(4)
1017support, this is set
1018 to the path of the device node. This allows
1019makefiles to
1020 test for this support.
1021
1022 [4m.MAKE.PID[24m The process‐id of [1mbmake[22m.
1023
1024 [4m.MAKE.PPID[24m The parent process‐id of [1mb‐
1025make[22m.
1026
1027 [4m.MAKE.SAVE_DOLLARS[0m
1028 value should be a boolean that controls
1029whether ‘$$’ are
1030 preserved when doing ‘:=’ assignments. The
1031default is
1032 false, for backwards compatibility. Set to
1033true for com‐
1034 patability with other makes. If set to
1035false, ‘$$’ be‐
1036 comes ‘$’ per normal evaluation rules.
1037
1038 [4m.MAKE.UID[24m The user‐id running [1mbmake[22m.
1039
1040 [4m.MAKE.GID[24m The group‐id running [1mbmake[22m.
1041
1042 [4mMAKE_PRINT_VAR_ON_ERROR[0m
1043 When [1mbmake [22mstops due to an error, it
1044sets ‘[4m.ERROR_TARGET[24m’
1045 to the name of the target that failed,
1046‘[4m.ERROR_CMD[24m’ to
1047 the commands of the failed target, and in
1048"meta" mode, it
1049 also sets ‘[4m.ERROR_CWD[24m’ to the
1050getcwd(3), and
1051 ‘[4m.ERROR_META_FILE[24m’ to the path of the
1052meta file (if any)
1053 describing the failed target. It then
1054prints its name
1055 and the value of ‘[4m.CURDIR[24m’ as well as
1056the value of any
1057 variables named in ‘[4mMAKE_PRINT_VAR_ON_ER‐
1058ROR[24m’.
1059
1060 [4m.newline[24m This variable is simply assigned a
1061newline character as
1062 its value. This allows expansions using the
1063[1m:@ [22mmodifier
1064 to put a newline between iterations of the
1065loop rather
1066 than a space. For example, the printing of
1067 ‘[4mMAKE_PRINT_VAR_ON_ERROR[24m’ could be
1068done as
1069 ${MAKE_PRINT_VAR_ON_ER‐
1070ROR:@v@$v=’${$v}’${.newline}@}.
1071
1072 [4m.OBJDIR[24m A path to the directory where the
1073targets are built. Its
1074 value is determined by trying to chdir(2) to
1075the follow‐
1076 ing directories in order and using the first
1077match:
1078
1079 1. ${MAKEOBJDIRPREFIX}${.CURDIR}
1080
1081 (Only if ‘MAKEOBJDIRPREFIX’ is set in
1082the environ‐
1083 ment or on the command line.)
1084
1085 2. ${MAKEOBJDIR}
1086
1087 (Only if ‘MAKEOBJDIR’ is set in the en‐
1088vironment or
1089 on the command line.)
1090
1091 3. ${.CURDIR}[4m/obj.[24m${MACHINE}
1092
1093 4. ${.CURDIR}[4m/obj[0m
1094
1095 5. [4m/usr/obj/[24m${.CURDIR}
1096
1097 6. ${.CURDIR}
1098
1099 Variable expansion is performed on the value
1100before it’s
1101 used, so expressions such as
1102 ${.CURDIR:S,^/usr/src,/var/obj,}
1103 may be used. This is especially useful with
1104 ‘MAKEOBJDIR’.
1105
1106 ‘[4m.OBJDIR[24m’ may be modified in the
1107makefile via the special
1108 target ‘[1m.OBJDIR[22m’. In all cases,
1109[1mbmake [22mwill chdir(2) to
1110 the specified directory if it exists, and
1111set ‘[4m.OBJDIR[24m’
1112 and ‘PWD’ to that directory before executing
1113any targets.
1114
1115 Except in the case of an explicit ‘[1m.OB‐
1116JDIR[22m’ target, [1mbmake[0m
1117 will check that the specified directory is
1118writable and
1119 ignore it if not. This check can be skipped
1120by setting
1121 the environment variable ‘MAKE_OB‐
1122JDIR_CHECK_WRITABLE’ to
1123 "no".
1124
1125 [4m.PARSEDIR[24m A path to the directory of the cur‐
1126rent ‘[4mMakefile[24m’ being
1127 parsed.
1128
1129 [4m.PARSEFILE[24m The basename of the current ‘[4mMake‐
1130file[24m’ being parsed.
1131 This variable and ‘[4m.PARSEDIR[24m’ are
1132both set only while the
1133 ‘[4mMakefiles[24m’ are being parsed. If you
1134want to retain
1135 their current values, assign them to a vari‐
1136able using as‐
1137 signment with expansion: (‘[1m:=[22m’).
1138
1139 [4m.PATH[24m A variable that represents the list
1140of directories that
1141 [1mbmake [22mwill search for files. The
1142search list should be
1143 updated using the target ‘[4m.PATH[24m’
1144rather than the vari‐
1145 able.
1146
1147 PWD Alternate path to the current directory.
1148[1mbmake [22mnormally
1149 sets ‘[4m.CURDIR[24m’ to the canonical path
1150given by getcwd(3).
1151 However, if the environment variable ‘PWD’
1152is set and
1153 gives a path to the current directory, then
1154[1mbmake [22msets
1155 ‘[4m.CURDIR[24m’ to the value of ‘PWD’ in‐
1156stead. This behavior
1157 is disabled if ‘MAKEOBJDIRPREFIX’ is set or
1158‘MAKEOBJDIR’
1159 contains a variable transform. ‘PWD’ is set
1160to the value
1161 of ‘[4m.OBJDIR[24m’ for all programs which
1162[1mbmake [22mexecutes.
1163
1164 .SHELL The pathname of the shell used to run target
1165scripts. It
1166 is read‐only.
1167
1168 .TARGETS The list of targets explicitly specified on
1169the command
1170 line, if any.
1171
1172 VPATH Colon‐separated (":") lists of directories
1173that [1mbmake[0m
1174 will search for files. The variable is sup‐
1175ported for
1176 compatibility with old make programs only,
1177use ‘[4m.PATH[24m’
1178 instead.
1179
1180 [1mVariable modifiers[0m
1181 Variable expansion may be modified to select or modify each
1182word of the
1183 variable (where a "word" is white‐space delimited sequence
1184of charac‐
1185 ters). The general format of a variable expansion is as
1186follows:
1187
1188 ${variable[:modifier[:...]]}
1189
1190 Each modifier begins with a colon, which may be escaped with
1191a backslash
1192 (‘´).
1193
1194 A set of modifiers can be specified via a variable, as fol‐
1195lows:
1196
1197 modifier_variable=modifier[:...]
1198 ${variable:${modifier_variable}[:...]}
1199
1200 In this case the first modifier in the modifier_variable
1201does not start
1202 with a colon, since that must appear in the referencing
1203variable. If any
1204 of the modifiers in the modifier_variable contain a dollar
1205sign (‘$’),
1206 these must be doubled to avoid early expansion.
1207
1208 The supported modifiers are:
1209
1210 [1m:E [22mReplaces each word in the variable with its suf‐
1211fix.
1212
1213 [1m:H [22mReplaces each word in the variable with every‐
1214thing but the last com‐
1215 ponent.
1216
1217 [1m:M[4m[22mpattern[0m
1218 Selects only those words that match [4mpattern[24m.
1219The standard shell
1220 wildcard characters (‘*’, ‘?’, and ‘[]’) may be used.
1221The wildcard
1222 characters may be escaped with a backslash (‘´). As a
1223consequence
1224 of the way values are split into words, matched, and
1225then joined, a
1226 construct like
1227 ${VAR:M*}
1228 will normalize the inter‐word spacing, removing all
1229leading and
1230 trailing space, and converting multiple consecutive
1231spaces to single
1232 spaces.
1233
1234 [1m:N[4m[22mpattern[0m
1235 This is identical to ‘[1m:M[22m’, but selects all words
1236which do not match
1237 [4mpattern[24m.
1238
1239 [1m:O [22mOrders every word in variable alphabetically.
1240
1241 [1m:Or [22mOrders every word in variable in reverse alpha‐
1242betical order.
1243
1244 [1m:Ox [22mShuffles the words in variable. The results
1245will be different each
1246 time you are referring to the modified variable; use
1247the assignment
1248 with expansion (‘[1m:=[22m’) to prevent such behavior.
1249For example,
1250
1251 LIST= uno due tre quattro
1252 RANDOM_LIST= ${LIST:Ox}
1253 STATIC_RANDOM_LIST:= ${LIST:Ox}
1254
1255 all:
1256 @echo "${RANDOM_LIST}"
1257 @echo "${RANDOM_LIST}"
1258 @echo "${STATIC_RANDOM_LIST}"
1259 @echo "${STATIC_RANDOM_LIST}"
1260 may produce output similar to:
1261
1262 quattro due tre uno
1263 tre due quattro uno
1264 due uno quattro tre
1265 due uno quattro tre
1266
1267 [1m:Q [22mQuotes every shell meta‐character in the vari‐
1268able, so that it can be
1269 passed safely to the shell.
1270
1271 [1m:q [22mQuotes every shell meta‐character in the vari‐
1272able, and also doubles
1273 ‘$’ characters so that it can be passed safely through
1274recursive in‐
1275 vocations of [1mbmake[22m. This is equivalent to:
1276‘:S/&&/g:Q’.
1277
1278 [1m:R [22mReplaces each word in the variable with every‐
1279thing but its suffix.
1280
1281 [1m:range[=count][0m
1282 The value is an integer sequence representing the words
1283of the orig‐
1284 inal value, or the supplied [4mcount[24m.
1285
1286 [1m:gmtime[=utc][0m
1287 The value is a format string for strftime(3), using gm‐
1288time(3). If a
1289 [4mutc[24m value is not provided or is 0, the current
1290time is used.
1291
1292 [1m:hash[0m
1293 Computes a 32‐bit hash of the value and encode it as
1294hex digits.
1295
1296 [1m:localtime[=utc][0m
1297 The value is a format string for strftime(3), using lo‐
1298caltime(3).
1299 If a [4mutc[24m value is not provided or is 0, the cur‐
1300rent time is used.
1301
1302 [1m:tA [22mAttempts to convert variable to an absolute path
1303using realpath(3),
1304 if that fails, the value is unchanged.
1305
1306 [1m:tl [22mConverts variable to lower‐case letters.
1307
1308 [1m:ts[4m[22mc[0m
1309 Words in the variable are normally separated by a space
1310on expan‐
1311 sion. This modifier sets the separator to the charac‐
1312ter [4mc[24m. If [4mc[24m is
1313 omitted, then no separator is used. The common escapes
1314(including
1315 octal numeric codes) work as expected.
1316
1317 [1m:tu [22mConverts variable to upper‐case letters.
1318
1319 [1m:tW [22mCauses the value to be treated as a single word
1320(possibly containing
1321 embedded white space). See also ‘[1m:[*][22m’.
1322
1323 [1m:tw [22mCauses the value to be treated as a sequence of
1324words delimited by
1325 white space. See also ‘[1m:[@][22m’.
1326
1327 [1m:S[22m/[4mold_string[24m/[4mnew_string[24m/[[1m1gW[22m]
1328 Modifies the first occurrence of [4mold_string[24m in
1329each word of the
1330 variable’s value, replacing it with [4mnew_string[24m.
1331If a ‘g’ is ap‐
1332 pended to the last delimiter of the pattern, all occur‐
1333rences in each
1334 word are replaced. If a ‘1’ is appended to the last
1335delimiter of
1336 the pattern, only the first occurrence is affected. If
1337a ‘W’ is ap‐
1338 pended to the last delimiter of the pattern, then the
1339value is
1340 treated as a single word (possibly containing embedded
1341white space).
1342 If [4mold_string[24m begins with a caret (‘^’),
1343[4mold_string[24m is anchored at
1344 the beginning of each word. If [4mold_string[24m ends
1345with a dollar sign
1346 (‘$’), it is anchored at the end of each word. Inside
1347[4mnew_string[24m,
1348 an ampersand (‘&’) is replaced by [4mold_string[24m
1349(without any ‘^’ or
1350 ‘$’). Any character may be used as a delimiter for the
1351parts of the
1352 modifier string. The anchoring, ampersand and delim‐
1353iter characters
1354 may be escaped with a backslash (‘´).
1355
1356 Variable expansion occurs in the normal fashion inside
1357both
1358 [4mold_string[24m and [4mnew_string[24m with the single
1359exception that a backslash
1360 is used to prevent the expansion of a dollar sign
1361(‘$’), not a pre‐
1362 ceding dollar sign as is usual.
1363
1364 [1m:C[22m/[4mpattern[24m/[4mreplacement[24m/[[1m1gW[22m]
1365 The [1m:C [22mmodifier is just like the [1m:S [22mmodi‐
1366fier except that the old and
1367 new strings, instead of being simple strings, are an
1368extended regu‐
1369 lar expression (see regex(3)) string [4mpattern[24m and
1370an ed(1)‐style
1371 string [4mreplacement[24m. Normally, the first occur‐
1372rence of the pattern
1373 [4mpattern[24m in each word of the value is substituted
1374with [4mreplacement[24m.
1375 The ‘1’ modifier causes the substitution to apply to at
1376most one
1377 word; the ‘g’ modifier causes the substitution to apply
1378to as many
1379 instances of the search pattern [4mpattern[24m as occur
1380in the word or
1381 words it is found in; the ‘W’ modifier causes the value
1382to be
1383 treated as a single word (possibly containing embedded
1384white space).
1385
1386 As for the [1m:S [22mmodifier, the [4mpattern[24m and
1387[4mreplacement[24m are subjected to
1388 variable expansion before being parsed as regular ex‐
1389pressions.
1390
1391 [1m:T [22mReplaces each word in the variable with its last
1392path component.
1393
1394 [1m:u [22mRemoves adjacent duplicate words (like uniq(1)).
1395
1396 [1m:?[4m[22mtrue_string[24m[1m:[4m[22mfalse_string[0m
1397 If the variable name (not its value), when parsed as a
1398.if condi‐
1399 tional expression, evaluates to true, return as its
1400value the
1401 [4mtrue_string[24m, otherwise return the
1402[4mfalse_string[24m. Since the variable
1403 name is used as the expression, :? must be the first
1404modifier after
1405 the variable name itself ‐ which will, of course, usu‐
1406ally contain
1407 variable expansions. A common error is trying to use
1408expressions
1409 like
1410 ${NUMBERS:M42:?match:no}
1411 which actually tests defined(NUMBERS), to determine if
1412any words
1413 match "42" you need to use something like:
1414 ${"${NUMBERS:M42}" != "":?match:no}.
1415
1416 [4m:old_string=new_string[0m
1417 This is the AT&T System V UNIX style variable substitu‐
1418tion. It must
1419 be the last modifier specified. If [4mold_string[24m
1420or [4mnew_string[24m do not
1421 contain the pattern matching character [4m%[24m then it
1422is assumed that
1423 they are anchored at the end of each word, so only suf‐
1424fixes or en‐
1425 tire words may be replaced. Otherwise [4m%[24m is the
1426substring of
1427 [4mold_string[24m to be replaced in [4mnew_string[24m.
1428If only [4mold_string[24m con‐
1429 tains the pattern matching character [4m%[24m, and
1430[4mold_string[24m matches, then
1431 the result is the [4mnew_string[24m. If only the
1432[4mnew_string[24m contains the
1433 pattern matching character [4m%[24m, then it is not
1434treated specially and
1435 it is printed as a literal [4m%[24m on match. If there
1436is more than one
1437 pattern matching character ([4m%[24m) in either the
1438[4mnew_string[24m or
1439 [4mold_string[24m, only the first instance is treated
1440specially (as the
1441 pattern character); all subsequent instances are treat‐
1442ed as regular
1443 characters.
1444
1445 Variable expansion occurs in the normal fashion inside
1446both
1447 [4mold_string[24m and [4mnew_string[24m with the single
1448exception that a backslash
1449 is used to prevent the expansion of a dollar sign
1450(‘$’), not a pre‐
1451 ceding dollar sign as is usual.
1452
1453 [1m:@[4m[22mtemp[24m[1m@[4m[22mstring[24m[1m@[0m
1454 This is the loop expansion mechanism from the OSF De‐
1455velopment Envi‐
1456 ronment (ODE) make. Unlike [1m.for [22mloops, expan‐
1457sion occurs at the time
1458 of reference. Assigns [4mtemp[24m to each word in the
1459variable and evalu‐
1460 ates [4mstring[24m. The ODE convention is that
1461[4mtemp[24m should start and end
1462 with a period. For example.
1463 ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1464
1465 However a single character variable is often more read‐
1466able:
1467 ${MAKE_PRINT_VAR_ON_ERROR:@v@$v=’${$v}’${.new‐
1468line}@}
1469
1470 [1m:_[=var][0m
1471 Saves the current variable value in ‘$_’ or the named
1472[4mvar[24m for later
1473 reference. Example usage:
1474
1475 M_cmpv.units = 1 1000 1000000
1476 M_cmpv = S,., ,g:_:range:@i@+ $${_:[‐$$i]}
1477$${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
1478
1479 .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
1480
1481 Here ‘$_’ is used to save the result of the ‘:S’ modi‐
1482fier which is
1483 later referenced using the index values from ‘:range’.
1484
1485 [1m:U[4m[22mnewval[0m
1486 If the variable is undefined, [4mnewval[24m is the val‐
1487ue. If the variable
1488 is defined, the existing value is returned. This is
1489another ODE
1490 make feature. It is handy for setting per‐target
1491CFLAGS for in‐
1492 stance:
1493 ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1494 If a value is only required if the variable is unde‐
1495fined, use:
1496 ${VAR:D:Unewval}
1497
1498 [1m:D[4m[22mnewval[0m
1499 If the variable is defined, [4mnewval[24m is the value.
1500
1501 [1m:L [22mThe name of the variable is the value.
1502
1503 [1m:P [22mThe path of the node which has the same name as
1504the variable is the
1505 value. If no such node exists or its path is null,
1506then the name of
1507 the variable is used. In order for this modifier to
1508work, the name
1509 (node) must at least have appeared on the rhs of a de‐
1510pendency.
1511
1512 [1m:![4m[22mcmd[24m[1m![0m
1513 The output of running [4mcmd[24m is the value.
1514
1515 [1m:sh [22mIf the variable is non‐empty it is run as a com‐
1516mand and the output
1517 becomes the new value.
1518
1519 [1m::=[4m[22mstr[0m
1520 The variable is assigned the value [4mstr[24m after
1521substitution. This
1522 modifier and its variations are useful in obscure situ‐
1523ations such as
1524 wanting to set a variable when shell commands are being
1525parsed.
1526 These assignment modifiers always expand to nothing, so
1527if appearing
1528 in a rule line by themselves should be preceded with
1529something to
1530 keep [1mbmake [22mhappy.
1531
1532 The ‘[1m::[22m’ helps avoid false matches with the AT&T
1533System V UNIX style
1534 [1m:= [22mmodifier and since substitution always occurs
1535the [1m::= [22mform is
1536 vaguely appropriate.
1537
1538 [1m::?=[4m[22mstr[0m
1539 As for [1m::= [22mbut only if the variable does not al‐
1540ready have a value.
1541
1542 [1m::+=[4m[22mstr[0m
1543 Append [4mstr[24m to the variable.
1544
1545 [1m::!=[4m[22mcmd[0m
1546 Assign the output of [4mcmd[24m to the variable.
1547
1548 [1m:[[4m[22mrange[24m[1m][0m
1549 Selects one or more words from the value, or performs
1550other opera‐
1551 tions related to the way in which the value is divided
1552into words.
1553
1554 Ordinarily, a value is treated as a sequence of words
1555delimited by
1556 white space. Some modifiers suppress this behavior,
1557causing a value
1558 to be treated as a single word (possibly containing em‐
1559bedded white
1560 space). An empty value, or a value that consists en‐
1561tirely of white‐
1562 space, is treated as a single word. For the purposes
1563of the ‘[1m:[][22m’
1564 modifier, the words are indexed both forwards using
1565positive inte‐
1566 gers (where index 1 represents the first word), and
1567backwards using
1568 negative integers (where index ‐1 represents the last
1569word).
1570
1571 The [4mrange[24m is subjected to variable expansion,
1572and the expanded re‐
1573 sult is then interpreted as follows:
1574
1575 [4mindex[24m Selects a single word from the value.
1576
1577 [4mstart[24m[1m..[4m[22mend[0m
1578 Selects all words from [4mstart[24m to
1579[4mend[24m, inclusive. For example,
1580 ‘[1m:[2..‐1][22m’ selects all words from the
1581second word to the last
1582 word. If [4mstart[24m is greater than
1583[4mend[24m, then the words are out‐
1584 put in reverse order. For example,
1585‘[1m:[‐1..1][22m’ selects all
1586 the words from last to first. If the list is
1587already or‐
1588 dered, then this effectively reverses the list,
1589but it is
1590 more efficient to use ‘[1m:Or[22m’ instead of
1591‘[1m:O:[‐1..1][22m’.
1592
1593 [1m* [22mCauses subsequent modifiers to treat the
1594value as a single
1595 word (possibly containing embedded white space).
1596Analogous
1597 to the effect of "$*" in Bourne shell.
1598
1599 0 Means the same as ‘[1m:[*][22m’.
1600
1601 [1m@ [22mCauses subsequent modifiers to treat the
1602value as a sequence
1603 of words delimited by white space. Analogous to
1604the effect
1605 of "$@" in Bourne shell.
1606
1607 [1m# [22mReturns the number of words in the value.
1608
1609[1mINCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS[0m
1610 Makefile inclusion, conditional structures and for loops
1611reminiscent of
1612 the C programming language are provided in [1mbmake[22m.
1613All such structures
1614 are identified by a line beginning with a single dot (‘.’)
1615character.
1616 Files are included with either [1m.include
1617<[4m[22mfile[24m[1m> [22mor [1m.include "[4m[22mfile[24m[1m"[22m.
1618Vari‐
1619 ables between the angle brackets or double quotes are ex‐
1620panded to form
1621 the file name. If angle brackets are used, the included
1622makefile is ex‐
1623 pected to be in the system makefile directory. If double
1624quotes are
1625 used, the including makefile’s directory and any directories
1626specified
1627 using the [1m‐I [22moption are searched before the system
1628makefile directory.
1629 For compatibility with other versions of [1mbmake [22m‘in‐
1630clude file ...’ is also
1631 accepted.
1632
1633 If the include statement is written as [1m.‐include [22mor
1634as [1m.sinclude [22mthen er‐
1635 rors locating and/or opening include files are ignored.
1636
1637 If the include statement is written as [1m.dinclude [22mnot
1638only are errors lo‐
1639 cating and/or opening include files ignored, but stale de‐
1640pendencies
1641 within the included file will be ignored just like
1642[4m.MAKE.DEPENDFILE[24m.
1643
1644 Conditional expressions are also preceded by a single dot as
1645the first
1646 character of a line. The possible conditionals are as fol‐
1647lows:
1648
1649 [1m.error [4m[22mmessage[0m
1650 The message is printed along with the name of the
1651makefile and
1652 line number, then [1mbmake [22mwill exit immediate‐
1653ly.
1654
1655 [1m.export [4m[22mvariable[24m [4m...[0m
1656 Export the specified global variable. If no vari‐
1657able list is
1658 provided, all globals are exported except for inter‐
1659nal variables
1660 (those that start with ‘.’). This is not affected
1661by the [1m‐X[0m
1662 flag, so should be used with caution. For compati‐
1663bility with
1664 other [1mbmake [22mprograms ‘export variable=value’
1665is also accepted.
1666
1667 Appending a variable name to [4m.MAKE.EXPORTED[24m
1668is equivalent to ex‐
1669 porting a variable.
1670
1671 [1m.export‐env [4m[22mvariable[24m [4m...[0m
1672 The same as ‘.export’, except that the variable is
1673not appended
1674 to [4m.MAKE.EXPORTED[24m. This allows exporting a
1675value to the environ‐
1676 ment which is different from that used by [1mbmake
1677[22minternally.
1678
1679 [1m.export‐literal [4m[22mvariable[24m [4m...[0m
1680 The same as ‘.export‐env’, except that variables in
1681the value are
1682 not expanded.
1683
1684 [1m.info [4m[22mmessage[0m
1685 The message is printed along with the name of the
1686makefile and
1687 line number.
1688
1689 [1m.undef [4m[22mvariable[24m [4m...[0m
1690 Un‐define the specified global variables. Only
1691global variables
1692 can be un‐defined.
1693
1694 [1m.unexport [4m[22mvariable[24m [4m...[0m
1695 The opposite of ‘.export’. The specified global
1696[4mvariable[24m will be
1697 removed from [4m.MAKE.EXPORTED[24m. If no variable
1698list is provided,
1699 all globals are unexported, and [4m.MAKE.EXPORT‐
1700ED[24m deleted.
1701
1702 [1m.unexport‐env[0m
1703 Unexport all globals previously exported and clear
1704the environ‐
1705 ment inherited from the parent. This operation will
1706cause a mem‐
1707 ory leak of the original environment, so should be
1708used spar‐
1709 ingly. Testing for [4m.MAKE.LEVEL[24m being 0,
1710would make sense. Also
1711 note that any variables which originated in the par‐
1712ent environ‐
1713 ment should be explicitly preserved if desired. For
1714example:
1715
1716 .if ${.MAKE.LEVEL} == 0
1717 PATH := ${PATH}
1718 .unexport‐env
1719 .export PATH
1720 .endif
1721
1722 Would result in an environment containing only
1723‘PATH’, which is
1724 the minimal useful environment. Actually
1725‘.MAKE.LEVEL’ will also
1726 be pushed into the new environment.
1727
1728 [1m.warning [4m[22mmessage[0m
1729 The message prefixed by ‘[4mwarning:[24m’ is printed
1730along with the name
1731 of the makefile and line number.
1732
1733 [1m.if [22m[!][4mexpression[24m [[4moperator[24m [4mexpres‐
1734sion[24m [4m...[24m]
1735 Test the value of an expression.
1736
1737 [1m.ifdef [22m[!][4mvariable[24m [[4moperator[24m [4mvari‐
1738able[24m [4m...[24m]
1739 Test the value of a variable.
1740
1741 [1m.ifndef [22m[!][4mvariable[24m [[4moperator[24m [4mvari‐
1742able[24m [4m...[24m]
1743 Test the value of a variable.
1744
1745 [1m.ifmake [22m[!][4mtarget[24m [[4moperator[24m [4mtar‐
1746get[24m [4m...[24m]
1747 Test the target being built.
1748
1749 [1m.ifnmake [22m[!] [4mtarget[24m [[4moperator[24m [4mtar‐
1750get[24m [4m...[24m]
1751 Test the target being built.
1752
1753 [1m.else [22mReverse the sense of the last conditional.
1754
1755 [1m.elif [22m[!] [4mexpression[24m [[4moperator[24m [4mex‐
1756pression[24m [4m...[24m]
1757 A combination of ‘[1m.else[22m’ followed by
1758‘[1m.if[22m’.
1759
1760 [1m.elifdef [22m[!][4mvariable[24m [[4moperator[24m [4mvari‐
1761able[24m [4m...[24m]
1762 A combination of ‘[1m.else[22m’ followed by
1763‘[1m.ifdef[22m’.
1764
1765 [1m.elifndef [22m[!][4mvariable[24m [[4moperator[24m
1766[4mvariable[24m [4m...[24m]
1767 A combination of ‘[1m.else[22m’ followed by
1768‘[1m.ifndef[22m’.
1769
1770 [1m.elifmake [22m[!][4mtarget[24m [[4moperator[24m [4mtar‐
1771get[24m [4m...[24m]
1772 A combination of ‘[1m.else[22m’ followed by ‘[1m.if‐
1773make[22m’.
1774
1775 [1m.elifnmake [22m[!][4mtarget[24m [[4moperator[24m [4mtar‐
1776get[24m [4m...[24m]
1777 A combination of ‘[1m.else[22m’ followed by
1778‘[1m.ifnmake[22m’.
1779
1780 [1m.endif [22mEnd the body of the conditional.
1781
1782 The [4moperator[24m may be any one of the following:
1783
1784 [1m|| [22mLogical OR.
1785
1786 [1m&& [22mLogical AND; of higher precedence than "||".
1787
1788 As in C, [1mbmake [22mwill only evaluate a conditional as
1789far as is necessary to
1790 determine its value. Parentheses may be used to change the
1791order of
1792 evaluation. The boolean operator ‘[1m![22m’ may be used to
1793logically negate an
1794 entire conditional. It is of higher precedence than
1795‘[1m&&[22m’.
1796
1797 The value of [4mexpression[24m may be any of the following:
1798
1799 [1mdefined [22mTakes a variable name as an argument and
1800evaluates to true if
1801 the variable has been defined.
1802
1803 [1mmake [22mTakes a target name as an argument and eval‐
1804uates to true if the
1805 target was specified as part of [1mbmake[22m’s com‐
1806mand line or was de‐
1807 clared the default target (either implicitly or ex‐
1808plicitly, see
1809 [4m.MAIN[24m) before the line containing the condi‐
1810tional.
1811
1812 [1mempty [22mTakes a variable, with possible modifiers,
1813and evaluates to true
1814 if the expansion of the variable would result in an
1815empty
1816 string.
1817
1818 [1mexists [22mTakes a file name as an argument and evalu‐
1819ates to true if the
1820 file exists. The file is searched for on the sys‐
1821tem search path
1822 (see [4m.PATH[24m).
1823
1824 [1mtarget [22mTakes a target name as an argument and eval‐
1825uates to true if the
1826 target has been defined.
1827
1828 [1mcommands[0m
1829 Takes a target name as an argument and evaluates to
1830true if the
1831 target has been defined and has commands associated
1832with it.
1833
1834 [4mExpression[24m may also be an arithmetic or string com‐
1835parison. Variable ex‐
1836 pansion is performed on both sides of the comparison, after
1837which the nu‐
1838 merical values are compared. A value is interpreted as
1839hexadecimal if it
1840 is preceded by 0x, otherwise it is decimal; octal numbers
1841are not sup‐
1842 ported. The standard C relational operators are all sup‐
1843ported. If after
1844 variable expansion, either the left or right hand side of a
1845‘[1m==[22m’ or ‘[1m!=[22m’
1846 operator is not a numerical value, then string comparison is
1847performed
1848 between the expanded variables. If no relational operator
1849is given, it
1850 is assumed that the expanded variable is being compared
1851against 0, or an
1852 empty string in the case of a string comparison.
1853
1854 When [1mbmake [22mis evaluating one of these conditional ex‐
1855pressions, and it en‐
1856 counters a (white‐space separated) word it doesn’t recog‐
1857nize, either the
1858 "make" or "defined" expression is applied to it, depending
1859on the form of
1860 the conditional. If the form is ‘[1m.ifdef[22m’, ‘[1m.ifn‐
1861def[22m’, or ‘[1m.if[22m’ the
1862 "defined" expression is applied. Similarly, if the form is
1863‘[1m.ifmake[22m’ or
1864 ‘[1m.ifnmake[22m’, the "make" expression is applied.
1865
1866 If the conditional evaluates to true the parsing of the
1867makefile contin‐
1868 ues as before. If it evaluates to false, the following
1869lines are
1870 skipped. In both cases this continues until a
1871‘[1m.else[22m’ or ‘[1m.endif[22m’ is
1872 found.
1873
1874 For loops are typically used to apply a set of rules to a
1875list of files.
1876 The syntax of a for loop is:
1877
1878 [1m.for [4m[22mvariable[24m [[4mvariable[24m [4m...[24m]
1879[1min [4m[22mexpression[0m
1880 <make‐lines>
1881 [1m.endfor[0m
1882
1883 After the for [1mexpression [22mis evaluated, it is split
1884into words. On each
1885 iteration of the loop, one word is taken and assigned to
1886each [1mvariable[22m,
1887 in order, and these [1mvariables [22mare substituted into
1888the [1mmake‐lines [22minside
1889 the body of the for loop. The number of words must come out
1890even; that
1891 is, if there are three iteration variables, the number of
1892words provided
1893 must be a multiple of three.
1894
1895[1mCOMMENTS[0m
1896 Comments begin with a hash (‘#’) character, anywhere but in
1897a shell com‐
1898 mand line, and continue to the end of an unescaped new line.
1899
1900[1mSPECIAL SOURCES (ATTRIBUTES)[0m
1901 [1m.EXEC [22mTarget is never out of date, but always ex‐
1902ecute commands any‐
1903 way.
1904
1905 [1m.IGNORE [22mIgnore any errors from the commands associ‐
1906ated with this tar‐
1907 get, exactly as if they all were preceded by a
1908dash (‘‐’).
1909
1910 [1m.MADE [22mMark all sources of this target as being
1911up‐to‐date.
1912
1913 [1m.MAKE [22mExecute the commands associated with this
1914target even if the [1m‐n[0m
1915 or [1m‐t [22moptions were specified. Normally
1916used to mark recursive
1917 [1mbmake[22ms.
1918
1919 [1m.META [22mCreate a meta file for the target, even if
1920it is flagged as
1921 [1m.PHONY[22m, [1m.MAKE[22m, or [1m.SPECIAL[22m.
1922Usage in conjunction with [1m.MAKE [22mis
1923 the most likely case. In "meta" mode, the target
1924is out‐of‐
1925 date if the meta file is missing.
1926
1927 [1m.NOMETA [22mDo not create a meta file for the target.
1928Meta files are also
1929 not created for [1m.PHONY[22m, [1m.MAKE[22m, or
1930[1m.SPECIAL [22mtargets.
1931
1932 [1m.NOMETA_CMP[0m
1933 Ignore differences in commands when deciding if
1934target is out
1935 of date. This is useful if the command contains a
1936value which
1937 always changes. If the number of commands change,
1938though, the
1939 target will still be out of date. The same effect
1940applies to
1941 any command line that uses the variable [4m.OO‐
1942DATE[24m, which can be
1943 used for that purpose even when not otherwise
1944needed or de‐
1945 sired:
1946
1947
1948 skip‐compare‐for‐some:
1949 @echo this will be compared
1950 @echo this will not ${.OO‐
1951DATE:M.NOMETA_CMP}
1952 @echo this will also be compared
1953
1954 The [1m:M [22mpattern suppresses any expansion of
1955the unwanted vari‐
1956 able.
1957
1958 [1m.NOPATH [22mDo not search for the target in the direc‐
1959tories specified by
1960 [1m.PATH[22m.
1961
1962 [1m.NOTMAIN [22mNormally [1mbmake [22mselects the first
1963target it encounters as the
1964 default target to be built if no target was speci‐
1965fied. This
1966 source prevents this target from being selected.
1967
1968 [1m.OPTIONAL[0m
1969 If a target is marked with this attribute and
1970[1mbmake [22mcan’t fig‐
1971 ure out how to create it, it will ignore this fact
1972and assume
1973 the file isn’t needed or already exists.
1974
1975 [1m.PHONY [22mThe target does not correspond to an actual
1976file; it is always
1977 considered to be out of date, and will not be cre‐
1978ated with the
1979 [1m‐t [22moption. Suffix‐transformation rules are
1980not applied to
1981 [1m.PHONY [22mtargets.
1982
1983 [1m.PRECIOUS[0m
1984 When [1mbmake [22mis interrupted, it normally re‐
1985moves any partially
1986 made targets. This source prevents the target
1987from being re‐
1988 moved.
1989
1990 [1m.RECURSIVE[0m
1991 Synonym for [1m.MAKE[22m.
1992
1993 [1m.SILENT [22mDo not echo any of the commands associated
1994with this target,
1995 exactly as if they all were preceded by an at sign
1996(‘@’).
1997
1998 [1m.USE [22mTurn the target into [1mbmake[22m’s version
1999of a macro. When the tar‐
2000 get is used as a source for another target, the
2001other target
2002 acquires the commands, sources, and attributes
2003(except for
2004 [1m.USE[22m) of the source. If the target already
2005has commands, the
2006 [1m.USE [22mtarget’s commands are appended to
2007them.
2008
2009 [1m.USEBEFORE[0m
2010 Exactly like [1m.USE[22m, but prepend the [1m.USE‐
2011BEFORE [22mtarget commands
2012 to the target.
2013
2014 [1m.WAIT [22mIf [1m.WAIT [22mappears in a dependency
2015line, the sources that precede
2016 it are made before the sources that succeed it in
2017the line.
2018 Since the dependents of files are not made until
2019the file it‐
2020 self could be made, this also stops the dependents
2021being built
2022 unless they are needed for another branch of the
2023dependency
2024 tree. So given:
2025
2026 x: a .WAIT b
2027 echo x
2028 a:
2029 echo a
2030 b: b1
2031 echo b
2032 b1:
2033 echo b1
2034
2035 the output is always ‘a’, ‘b1’, ‘b’, ‘x’.
2036 The ordering imposed by [1m.WAIT [22mis only rele‐
2037vant for parallel
2038 makes.
2039
2040[1mSPECIAL TARGETS[0m
2041 Special targets may not be included with other targets, i.e.
2042they must be
2043 the only target specified.
2044
2045 [1m.BEGIN [22mAny command lines attached to this target
2046are executed before
2047 anything else is done.
2048
2049 [1m.DEFAULT[0m
2050 This is sort of a [1m.USE [22mrule for any target
2051(that was used only
2052 as a source) that [1mbmake [22mcan’t figure out any
2053other way to cre‐
2054 ate. Only the shell script is used. The [1m.IMP‐
2055SRC [22mvariable of a
2056 target that inherits [1m.DEFAULT[22m’s commands is
2057set to the target’s
2058 own name.
2059
2060 [1m.DELETE_ON_ERROR[0m
2061 If this target is present in the makefile, it glob‐
2062ally causes
2063 make to delete targets whose commands fail. (By
2064default, only
2065 targets whose commands are interrupted during exe‐
2066cution are
2067 deleted. This is the historical behavior.) This
2068setting can be
2069 used to help prevent half‐finished or malformed
2070targets from be‐
2071 ing left around and corrupting future rebuilds.
2072
2073 [1m.END [22mAny command lines attached to this target
2074are executed after ev‐
2075 erything else is done.
2076
2077 [1m.ERROR [22mAny command lines attached to this target
2078are executed when an‐
2079 other target fails. The [1m.ERROR_TARGET [22mvari‐
2080able is set to the
2081 target that failed. See also
2082[1mMAKE_PRINT_VAR_ON_ERROR[22m.
2083
2084 [1m.IGNORE [22mMark each of the sources with the [1m.IGNORE
2085[22mattribute. If no
2086 sources are specified, this is the equivalent of
2087specifying the
2088 [1m‐i [22moption.
2089
2090 [1m.INTERRUPT[0m
2091 If [1mbmake [22mis interrupted, the commands for
2092this target will be
2093 executed.
2094
2095 [1m.MAIN [22mIf no target is specified when [1mbmake
2096[22mis invoked, this target
2097 will be built.
2098
2099 [1m.MAKEFLAGS[0m
2100 This target provides a way to specify flags for
2101[1mbmake [22mwhen the
2102 makefile is used. The flags are as if typed to the
2103shell,
2104 though the [1m‐f [22moption will have no effect.
2105
2106 [1m.NOPATH [22mApply the [1m.NOPATH [22mattribute to any
2107specified sources.
2108
2109 [1m.NOTPARALLEL[0m
2110 Disable parallel mode.
2111
2112 [1m.NO_PARALLEL[0m
2113 Synonym for [1m.NOTPARALLEL[22m, for compatibility
2114with other pmake
2115 variants.
2116
2117 [1m.OBJDIR [22mThe source is a new value for ‘[4m.OB‐
2118JDIR[24m’. If it exists, [1mbmake[0m
2119 will chdir(2) to it and update the value of
2120‘[4m.OBJDIR[24m’.
2121
2122 [1m.ORDER [22mThe named targets are made in sequence.
2123This ordering does not
2124 add targets to the list of targets to be made.
2125Since the depen‐
2126 dents of a target do not get built until the target
2127itself could
2128 be built, unless ‘a’ is built by another part of
2129the dependency
2130 graph, the following is a dependency loop:
2131
2132 .ORDER: b a
2133 b: a
2134
2135 The ordering imposed by [1m.ORDER [22mis only rele‐
2136vant for parallel
2137 makes.
2138
2139 [1m.PATH [22mThe sources are directories which are to be
2140searched for files
2141 not found in the current directory. If no sources
2142are speci‐
2143 fied, any previously specified directories are
2144deleted. If the
2145 source is the special [1m.DOTLAST [22mtarget, then
2146the current working
2147 directory is searched last.
2148
2149 [1m.PATH.[4m[22msuffix[0m
2150 Like [1m.PATH [22mbut applies only to files with a
2151particular suffix.
2152 The suffix must have been previously declared with
2153[1m.SUFFIXES[22m.
2154
2155 [1m.PHONY [22mApply the [1m.PHONY [22mattribute to any
2156specified sources.
2157
2158 [1m.PRECIOUS[0m
2159 Apply the [1m.PRECIOUS [22mattribute to any speci‐
2160fied sources. If no
2161 sources are specified, the [1m.PRECIOUS [22mat‐
2162tribute is applied to ev‐
2163 ery target in the file.
2164
2165 [1m.SHELL [22mSets the shell that [1mbmake [22mwill use to
2166execute commands. The
2167 sources are a set of [4mfield=value[24m pairs.
2168
2169 [4mname[24m This is the minimal specifica‐
2170tion, used to select
2171 one of the built‐in shell specs;
2172[4msh[24m, [4mksh[24m, and [4mcsh[24m.
2173
2174 [4mpath[24m Specifies the path to the shell.
2175
2176 [4mhasErrCtl[24m Indicates whether the shell sup‐
2177ports exit on error.
2178
2179 [4mcheck[24m The command to turn on error
2180checking.
2181
2182 [4mignore[24m The command to disable error
2183checking.
2184
2185 [4mecho[24m The command to turn on echoing
2186of commands executed.
2187
2188 [4mquiet[24m The command to turn off echoing
2189of commands exe‐
2190 cuted.
2191
2192 [4mfilter[24m The output to filter after issu‐
2193ing the [4mquiet[24m com‐
2194 mand. It is typically identical to
2195[4mquiet[24m.
2196
2197 [4merrFlag[24m The flag to pass the shell to
2198enable error checking.
2199
2200 [4mechoFlag[24m The flag to pass the shell to
2201enable command echo‐
2202 ing.
2203
2204 [4mnewline[24m The string literal to pass the
2205shell that results in
2206 a single newline character when used
2207outside of any
2208 quoting characters.
2209 Example:
2210
2211 .SHELL: name=ksh path=/bin/ksh hasErrCtl=true
2212check="set ‐e" ignore="set +e" echo="set
2213‐v" quiet="set +v" filter="set +v"
2214echoFlag=v errFlag=e newline="’0"
2215
2216 [1m.SILENT [22mApply the [1m.SILENT [22mattribute to any
2217specified sources. If no
2218 sources are specified, the [1m.SILENT [22mattribute
2219is applied to every
2220 command in the file.
2221
2222 [1m.STALE [22mThis target gets run when a dependency file
2223contains stale en‐
2224 tries, having [4m.ALLSRC[24m set to the name of
2225that dependency file.
2226
2227 [1m.SUFFIXES[0m
2228 Each source specifies a suffix to [1mbmake[22m. If
2229no sources are
2230 specified, any previously specified suffixes are
2231deleted. It
2232 allows the creation of suffix‐transformation rules.
2233
2234 Example:
2235
2236 .SUFFIXES: .o
2237 .c.o:
2238 cc ‐o ${.TARGET} ‐c ${.IMPSRC}
2239
2240[1mENVIRONMENT[0m
2241 [1mbmake [22muses the following environment variables, if
2242they exist: MACHINE,
2243 MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX,
2244MAKESYSPATH,
2245 PWD, and TMPDIR.
2246
2247 MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the envi‐
2248ronment or on
2249 the command line to [1mbmake [22mand not as makefile vari‐
2250ables; see the descrip‐
2251 tion of ‘[4m.OBJDIR[24m’ for more details.
2252
2253[1mFILES[0m
2254 .depend list of dependencies
2255 Makefile list of dependencies
2256 makefile list of dependencies
2257 sys.mk system makefile
2258 /usr/share/mk system makefile directory
2259
2260[1mCOMPATIBILITY[0m
2261 The basic make syntax is compatible between different ver‐
2262sions of make;
2263 however the special variables, variable modifiers and condi‐
2264tionals are
2265 not.
2266
2267 [1mOlder versions[0m
2268 An incomplete list of changes in older versions of [1mb‐
2269make[22m:
2270
2271 The way that .for loop variables are substituted changed af‐
2272ter NetBSD 5.0
2273 so that they still appear to be variable expansions. In
2274particular this
2275 stops them being treated as syntax, and removes some obscure
2276problems us‐
2277 ing them in .if statements.
2278
2279 The way that parallel makes are scheduled changed in NetBSD
22804.0 so that
2281 .ORDER and .WAIT apply recursively to the dependent nodes.
2282The algo‐
2283 rithms used may change again in the future.
2284
2285 [1mOther make dialects[0m
2286 Other make dialects (GNU make, SVR4 make, POSIX make, etc.)
2287do not sup‐
2288 port most of the features of [1mbmake [22mas described in
2289this manual. Most no‐
2290 tably:
2291
2292 [1m+o [22mThe [1m.WAIT [22mand [1m.ORDER [22mdeclara‐
2293tions and most functionality per‐
2294 taining to parallelization. (GNU make supports
2295parallelization
2296 but lacks these features needed to control it ef‐
2297fectively.)
2298
2299 [1m+o [22mDirectives, including for loops and condi‐
2300tionals and most of
2301 the forms of include files. (GNU make has its own
2302incompatible
2303 and less powerful syntax for conditionals.)
2304
2305 [1m+o [22mAll built‐in variables that begin with a
2306dot.
2307
2308 [1m+o [22mMost of the special sources and targets
2309that begin with a dot,
2310 with the notable exception of [1m.PHONY[22m,
2311[1m.PRECIOUS[22m, and [1m.SUFFIXES[22m.
2312
2313 [1m+o [22mVariable modifiers, except for the
2314 :old=new
2315 string substitution, which does not portably sup‐
2316port globbing
2317 with ‘%’ and historically only works on declared
2318suffixes.
2319
2320 [1m+o [22mThe [1m$> [22mvariable even in its short
2321form; most makes support this
2322 functionality but its name varies.
2323
2324 Some features are somewhat more portable, such as assignment
2325with [1m+=[22m, [1m?=[22m,
2326 and [1m!=[22m. The [1m.PATH [22mfunctionality is based on
2327an older feature [1mVPATH [22mfound
2328 in GNU make and many versions of SVR4 make; however, histor‐
2329ically its be‐
2330 havior is too ill‐defined (and too buggy) to rely upon.
2331
2332 The [1m$@ [22mand [1m$< [22mvariables are more or less uni‐
2333versally portable, as is the
2334 [1m$(MAKE) [22mvariable. Basic use of suffix rules (for
2335files only in the cur‐
2336 rent directory, not trying to chain transformations togeth‐
2337er, etc.) is
2338 also reasonably portable.
2339
2340[1mSEE ALSO[0m
2341 mkdep(1)
2342
2343[1mHISTORY[0m
2344 [1mbmake [22mis derived from NetBSD make(1). It uses auto‐
2345conf to facilitate
2346 portability to other platforms.
2347
2348 A make command appeared in Version 7 AT&T UNIX. This make
2349implementation
2350 is based on Adam De Boor’s pmake program which was written
2351for Sprite at
2352 Berkeley. It was designed to be a parallel distributed make
2353running jobs
2354 on different machines using a daemon called "customs".
2355
2356 Historically the target/dependency "FRC" has been used to
2357FoRCe rebuild‐
2358 ing (since the target/dependency does not exist... unless
2359someone creates
2360 an "FRC" file).
2361
2362[1mBUGS[0m
2363 The make syntax is difficult to parse without actually act‐
2364ing on the
2365 data. For instance, finding the end of a variable’s use
2366should involve
2367 scanning each of the modifiers, using the correct terminator
2368for each
2369 field. In many places make just counts {} and () in order
2370to find the
2371 end of a variable expansion.
2372
2373 There is no way of escaping a space character in a filename.
2374
2375FreeBSD 13.0 December 22, 2020
2376FreeBSD 13.0