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