xref: /dragonfly/contrib/bmake/bmake.cat1 (revision f9993810)
1BMAKE(1)                FreeBSD General Commands Manual               BMAKE(1)
2
3NAME
4     bmake -- maintain program dependencies
5
6SYNOPSIS
7     bmake [-BeikNnqrSstWwX] [-C directory] [-D variable] [-d flags]
8           [-f makefile] [-I directory] [-J private] [-j max_jobs]
9           [-m directory] [-T file] [-V variable] [-v variable]
10           [variable=value] [target ...]
11
12DESCRIPTION
13     bmake is a program designed to simplify the maintenance of other pro-
14     grams.  Its input is a list of specifications as to the files upon which
15     programs and other files depend.  If no -f makefile option is given,
16     bmake tries to open `makefile' then `Makefile' in order to find the spec-
17     ifications.  If the file `.depend' exists, it is read (see mkdep(1)).
18
19     This manual page is intended as a reference document only.  For a more
20     thorough description of bmake and makefiles, please refer to PMake - A
21     Tutorial (from 1993).
22
23     bmake prepends the contents of the MAKEFLAGS environment variable to the
24     command line arguments before parsing them.
25
26     The options are as follows:
27
28     -B      Try to be backwards compatible by executing a single shell per
29             command and by making the sources of a dependency line in se-
30             quence.
31
32     -C directory
33             Change to directory before reading the makefiles or doing any-
34             thing else.  If multiple -C options are specified, each is inter-
35             preted relative to the previous one: -C / -C etc is equivalent to
36             -C /etc.
37
38     -D variable
39             Define variable to be 1, in the global scope.
40
41     -d [-]flags
42             Turn on debugging, and specify which portions of bmake are to
43             print debugging information.  Unless the flags are preceded by
44             `-', they are added to the MAKEFLAGS environment variable and are
45             passed on to any child make processes.  By default, debugging in-
46             formation is printed to standard error, but this can be changed
47             using the F debugging flag.  The debugging output is always un-
48             buffered; in addition, if debugging is enabled but debugging out-
49             put is not directed to standard output, the standard output is
50             line buffered.  The available flags are:
51
52             A       Print all possible debugging information; equivalent to
53                     specifying all of the debugging flags.
54
55             a       Print debugging information about archive searching and
56                     caching.
57
58             C       Print debugging information about the current working di-
59                     rectory.
60
61             c       Print debugging information about conditional evaluation.
62
63             d       Print debugging information about directory searching and
64                     caching.
65
66             e       Print debugging information about failed commands and
67                     targets.
68
69             F[+]filename
70                     Specify where debugging output is written.  This must be
71                     the last flag, because it consumes the remainder of the
72                     argument.  If the character immediately after the F flag
73                     is `+', the file is opened in append mode; otherwise the
74                     file is overwritten.  If the file name is `stdout' or
75                     `stderr', debugging output is written to the standard
76                     output or standard error output file descriptors respec-
77                     tively (and the `+' option has no effect).  Otherwise,
78                     the output is written to the named file.  If the file
79                     name ends with `.%d', the `%d' is replaced by the pid.
80
81             f       Print debugging information about loop evaluation.
82
83             g1      Print the input graph before making anything.
84
85             g2      Print the input graph after making everything, or before
86                     exiting on error.
87
88             g3      Print the input graph before exiting on error.
89
90             h       Print debugging information about hash table operations.
91
92             j       Print debugging information about running multiple
93                     shells.
94
95             L       Turn on lint checks.  This throws errors for variable as-
96                     signments that do not parse correctly, at the time of as-
97                     signment, so the file and line number are available.
98
99             l       Print commands in Makefiles regardless of whether or not
100                     they are prefixed by `@' or other "quiet" flags.  Also
101                     known as "loud" behavior.
102
103             M       Print debugging information about "meta" mode decisions
104                     about targets.
105
106             m       Print debugging information about making targets, includ-
107                     ing modification dates.
108
109             n       Don't delete the temporary command scripts created when
110                     running commands.  These temporary scripts are created in
111                     the directory referred to by the TMPDIR environment vari-
112                     able, or in /tmp if TMPDIR is unset or set to the empty
113                     string.  The temporary scripts are created by mkstemp(3),
114                     and have names of the form makeXXXXXX.  NOTE: This can
115                     create many files in TMPDIR or /tmp, so use with care.
116
117             p       Print debugging information about makefile parsing.
118
119             s       Print debugging information about suffix-transformation
120                     rules.
121
122             t       Print debugging information about target list mainte-
123                     nance.
124
125             V       Force the -V option to print raw values of variables,
126                     overriding the default behavior set via
127                     .MAKE.EXPAND_VARIABLES.
128
129             v       Print debugging information about variable assignment and
130                     expansion.
131
132             x       Run shell commands with -x so the actual commands are
133                     printed as they are executed.
134
135     -e      Let environment variables override global variables within make-
136             files.
137
138     -f makefile
139             Specify a makefile to read instead of the default makefile or
140             Makefile.  If makefile is `-', standard input is read.  Multiple
141             makefiles may be specified, and are read in the order specified.
142
143     -I directory
144             Specify a directory in which to search for makefiles and included
145             makefiles.  The system makefile directory (or directories, see
146             the -m option) is automatically included as part of this list.
147
148     -i      Ignore non-zero exit of shell commands in the makefile.  Equiva-
149             lent to specifying `-' before each command line in the makefile.
150
151     -J private
152             This option should not be specified by the user.
153
154             When the -j option is in use in a recursive build, this option is
155             passed by a make to child makes to allow all the make processes
156             in the build to cooperate to avoid overloading the system.
157
158     -j max_jobs
159             Specify the maximum number of jobs that bmake may have running at
160             any one time.  The value is saved in .MAKE.JOBS.  Turns compati-
161             bility mode off, unless the -B option is also specified.  When
162             compatibility mode is off, all commands associated with a target
163             are executed in a single shell invocation as opposed to the tra-
164             ditional one shell invocation per line.  This can break tradi-
165             tional scripts which change directories on each command invoca-
166             tion and then expect to start with a fresh environment on the
167             next line.  It is more efficient to correct the scripts rather
168             than turn backwards compatibility on.
169
170     -k      Continue processing after errors are encountered, but only on
171             those targets that do not depend on the target whose creation
172             caused the error.
173
174     -m directory
175             Specify a directory in which to search for sys.mk and makefiles
176             included via the <file>-style include statement.  The -m option
177             can be used multiple times to form a search path.  This path
178             overrides the default system include path /usr/share/mk.  Fur-
179             thermore, the system include path is appended to the search path
180             used for "file"-style include statements (see the -I option).
181
182             If a directory name in the -m argument (or the MAKESYSPATH envi-
183             ronment variable) starts with the string `.../', bmake searches
184             for the specified file or directory named in the remaining part
185             of the argument string.  The search starts with the current di-
186             rectory and then works upward towards the root of the file sys-
187             tem.  If the search is successful, the resulting directory re-
188             places the `.../' specification in the -m argument.  This feature
189             allows bmake to easily search in the current source tree for cus-
190             tomized sys.mk files (e.g., by using `.../mk/sys.mk' as an argu-
191             ment).
192
193     -n      Display the commands that would have been executed, but do not
194             actually execute them unless the target depends on the .MAKE spe-
195             cial source (see below) or the command is prefixed with `+'.
196
197     -N      Display the commands that would have been executed, but do not
198             actually execute any of them; useful for debugging top-level
199             makefiles without descending into subdirectories.
200
201     -q      Do not execute any commands, instead exit 0 if the specified tar-
202             gets are up to date, and 1 otherwise.
203
204     -r      Do not use the built-in rules specified in the system makefile.
205
206     -S      Stop processing if an error is encountered.  This is the default
207             behavior and the opposite of -k.
208
209     -s      Do not echo any commands as they are executed.  Equivalent to
210             specifying `@' before each command line in the makefile.
211
212     -T tracefile
213             When used with the -j flag, append a trace record to tracefile
214             for each job started and completed.
215
216     -t      Rather than re-building a target as specified in the makefile,
217             create it or update its modification time to make it appear up-
218             to-date.
219
220     -V variable
221             Print the value of variable.  Do not build any targets.  Multiple
222             instances of this option may be specified; the variables are
223             printed one per line, with a blank line for each null or unde-
224             fined variable.  The value printed is extracted from the global
225             scope after all makefiles have been read.  By default, the raw
226             variable contents (which may include additional unexpanded vari-
227             able references) are shown.  If variable contains a `$', the
228             value is recursively expanded to its complete resultant text be-
229             fore printing.  The expanded value is also printed if
230             .MAKE.EXPAND_VARIABLES is set to true and the -dV option has not
231             been used to override it.  Note that loop-local and target-local
232             variables, as well as values taken temporarily by global vari-
233             ables during makefile processing, are not accessible via this op-
234             tion.  The -dv debug mode can be used to see these at the cost of
235             generating substantial extraneous output.
236
237     -v variable
238             Like -V, but all printed variables are always expanded to their
239             complete value.  The last occurrence of -V or -v decides whether
240             all variables are expanded or not.
241
242     -W      Treat any warnings during makefile parsing as errors.
243
244     -w      Print entering and leaving directory messages, pre and post pro-
245             cessing.
246
247     -X      Don't export variables passed on the command line to the environ-
248             ment individually.  Variables passed on the command line are
249             still exported via the MAKEFLAGS environment variable.  This op-
250             tion may be useful on systems which have a small limit on the
251             size of command arguments.
252
253     variable=value
254             Set the value of the variable variable to value.  Normally, all
255             values passed on the command line are also exported to sub-makes
256             in the environment.  The -X flag disables this behavior.  Vari-
257             able assignments should follow options for POSIX compatibility
258             but no ordering is enforced.
259
260     There are several different types of lines in a makefile: dependency
261     specifications, shell commands, variable assignments, include statements,
262     conditional directives, for loops, other directives, and comments.
263
264     Lines may be continued from one line to the next by ending them with a
265     backslash (`\').  The trailing newline character and initial whitespace
266     on the following line are compressed into a single space.
267
268FILE DEPENDENCY SPECIFICATIONS
269     Dependency lines consist of one or more targets, an operator, and zero or
270     more sources.  This creates a relationship where the targets "depend" on
271     the sources and are customarily created from them.  A target is consid-
272     ered out of date if it does not exist, or if its modification time is
273     less than that of any of its sources.  An out-of-date target is re-cre-
274     ated, but not until all sources have been examined and themselves re-cre-
275     ated as needed.  Three operators may be used:
276
277     :     Many dependency lines may name this target but only one may have
278           attached shell commands.  All sources named in all dependency lines
279           are considered together, and if needed the attached shell commands
280           are run to create or re-create the target.  If bmake is inter-
281           rupted, the target is removed.
282
283     !     The same, but the target is always re-created whether or not it is
284           out of date.
285
286     ::    Any dependency line may have attached shell commands, but each one
287           is handled independently: its sources are considered and the at-
288           tached shell commands are run if the target is out of date with re-
289           spect to (only) those sources.  Thus, different groups of the at-
290           tached shell commands may be run depending on the circumstances.
291           Furthermore, unlike :, for dependency lines with no sources, the
292           attached shell commands are always run.  Also unlike :, the target
293           is not removed if bmake is interrupted.
294     All dependency lines mentioning a particular target must use the same op-
295     erator.
296
297     Targets and sources may contain the shell wildcard values `?', `*', `[]',
298     and `{}'.  The values `?', `*', and `[]' may only be used as part of the
299     final component of the target or source, and only match existing files.
300     The value `{}' need not necessarily be used to describe existing files.
301     Expansion is in directory order, not alphabetically as done in the shell.
302
303SHELL COMMANDS
304     Each target may have associated with it one or more lines of shell com-
305     mands, normally used to create the target.  Each of the lines in this
306     script must be preceded by a tab.  (For historical reasons, spaces are
307     not accepted.)  While targets can occur in many dependency lines if de-
308     sired, by default only one of these rules may be followed by a creation
309     script.  If the `::' operator is used, however, all rules may include
310     scripts and the scripts are executed in the order found.
311
312     Each line is treated as a separate shell command, unless the end of line
313     is escaped with a backslash (`\'), in which case that line and the next
314     are combined.  If the first characters of the command are any combination
315     of `@', `+', or `-', the command is treated specially.  A `@' causes the
316     command not to be echoed before it is executed.  A `+' causes the command
317     to be executed even when -n is given.  This is similar to the effect of
318     the .MAKE special source, except that the effect can be limited to a sin-
319     gle line of a script.  A `-' in compatibility mode causes any non-zero
320     exit status of the command line to be ignored.
321
322     When bmake is run in jobs mode with -j max_jobs, the entire script for
323     the target is fed to a single instance of the shell.  In compatibility
324     (non-jobs) mode, each command is run in a separate process.  If the com-
325     mand contains any shell meta characters (`#=|^(){};&<>*?[]:$`\\n'), it is
326     passed to the shell; otherwise bmake attempts direct execution.  If a
327     line starts with `-' and the shell has ErrCtl enabled, failure of the
328     command line is ignored as in compatibility mode.  Otherwise `-' affects
329     the entire job; the script stops at the first command line that fails,
330     but the target is not deemed to have failed.
331
332     Makefiles should be written so that the mode of bmake operation does not
333     change their behavior.  For example, any command which uses "cd" or
334     "chdir" without the intention of changing the directory for subsequent
335     commands should be put in parentheses so it executes in a subshell.  To
336     force the use of a single shell, escape the line breaks so as to make the
337     whole script one command.  For example:
338
339           avoid-chdir-side-effects:
340                   @echo Building $@ in `pwd`
341                   @(cd ${.CURDIR} && ${MAKE} $@)
342                   @echo Back in `pwd`
343
344           ensure-one-shell-regardless-of-mode:
345                   @echo Building $@ in `pwd`; \
346                   (cd ${.CURDIR} && ${MAKE} $@); \
347                   echo Back in `pwd`
348
349     Since bmake changes the current working directory to `.OBJDIR' before ex-
350     ecuting any targets, each child process starts with that as its current
351     working directory.
352
353VARIABLE ASSIGNMENTS
354     Variables in make behave much like macros in the C preprocessor.
355
356     Variable assignments have the form `NAME op value', where:
357
358     NAME    is a single-word variable name, consisting, by tradition, of all
359             upper-case letters,
360
361     op      is one of the five variable assignment operators described below,
362             and
363
364     value   is interpreted according to the variable assignment operator.
365
366     Whitespace around NAME, op and value is discarded.
367
368   Variable assignment operators
369     The five operators that assign values to variables are:
370
371     =       Assign the value to the variable.  Any previous value is over-
372             written.
373
374     +=      Append the value to the current value of the variable, separating
375             them by a single space.
376
377     ?=      Assign the value to the variable if it is not already defined.
378
379     :=      Assign with expansion, i.e. expand the value before assigning it
380             to the variable.  Normally, expansion is not done until the vari-
381             able is referenced.
382
383             NOTE: References to undefined variables are not expanded.  This
384             can cause problems when variable modifiers are used.
385
386     !=      Expand the value and pass it to the shell for execution, then as-
387             sign the output from the child's standard output to the variable.
388             Any newlines in the result are replaced with spaces.
389
390   Expansion of variables
391     In most contexts where variables are expanded, `$$' expands to a single
392     dollar sign.  In other contexts (most variable modifiers, string literals
393     in conditions), `\$' expands to a single dollar sign.
394
395     References to variables have the form ${name[:modifiers]} or
396     $(name[:modifiers]).  If the variable name consists of only a single
397     character, the surrounding curly braces or parentheses are not required.
398     This shorter form is not recommended.
399
400     If the variable name contains a dollar, the name itself is expanded
401     first.  This allows almost arbitrary variable names, however names con-
402     taining dollar, braces, parentheses or whitespace are really best
403     avoided.
404
405     If the result of expanding a nested variable expression contains a dollar
406     sign (`$'), the string is subject to further expansion.
407
408     Variable substitution occurs at four distinct times, depending on where
409     the variable is being used.
410
411     1.   Variables in dependency lines are expanded as the line is read.
412
413     2.   Variables in conditionals are expanded individually, but only as far
414          as necessary to determine the result of the conditional.
415
416     3.   Variables in shell commands are expanded when the shell command is
417          executed.
418
419     4.   .for loop index variables are expanded on each loop iteration.  Note
420          that other variables are not expanded when composing the body of a
421          loop, so the following example code:
422
423                .for i in 1 2 3
424                a+=     ${i}
425                j=      ${i}
426                b+=     ${j}
427                .endfor
428
429                all:
430                        @echo ${a}
431                        @echo ${b}
432
433          prints:
434
435                1 2 3
436                3 3 3
437
438          Because while a contains `${:U1} ${:U2} ${:U3}' after the loop is
439          executed, b contains `${j} ${j} ${j}' which expands to `3 3 3' since
440          after the loop completes j contains `${:U3}'.
441
442   Variable classes
443     The four different classes of variables (in order of increasing prece-
444     dence) are:
445
446     Environment variables
447             Variables defined as part of bmake's environment.
448
449     Global variables
450             Variables defined in the makefile or in included makefiles.
451
452     Command line variables
453             Variables defined as part of the command line.
454
455     Local variables
456             Variables that are defined specific to a certain target.
457
458     Local variables can be set on a dependency line, unless
459     .MAKE.TARGET_LOCAL_VARIABLES is set to `false'.  The rest of the line
460     (which already has had global variables expanded) is the variable value.
461     For example:
462
463           COMPILER_WRAPPERS= ccache distcc icecc
464
465           ${OBJS}: .MAKE.META.CMP_FILTER=${COMPILER_WRAPPERS:S,^,N,}
466
467     Only the targets `${OBJS}' are impacted by that filter (in "meta" mode)
468     and simply enabling/disabling any of the compiler wrappers does not ren-
469     der all of those targets out-of-date.
470
471     NOTE: target-local variable assignments behave differently in that;
472
473           +=      Only appends to a previous local assignment for the same
474                   target and variable.
475
476           :=      Is redundant with respect to global variables, which have
477                   already been expanded.
478
479     The seven built-in local variables are:
480
481           .ALLSRC   The list of all sources for this target; also known as
482                     `>'.
483
484           .ARCHIVE  The name of the archive file; also known as `!'.
485
486           .IMPSRC   In suffix-transformation rules, the name/path of the
487                     source from which the target is to be transformed (the
488                     "implied" source); also known as `<'.  It is not defined
489                     in explicit rules.
490
491           .MEMBER   The name of the archive member; also known as `%'.
492
493           .OODATE   The list of sources for this target that were deemed out-
494                     of-date; also known as `?'.
495
496           .PREFIX   The file prefix of the target, containing only the file
497                     portion, no suffix or preceding directory components;
498                     also known as `*'.  The suffix must be one of the known
499                     suffixes declared with .SUFFIXES, or it is not recog-
500                     nized.
501
502           .TARGET   The name of the target; also known as `@'.  For compati-
503                     bility with other makes this is an alias for .ARCHIVE in
504                     archive member rules.
505
506     The shorter forms (`>', `!', `<', `%', `?', `*', and `@') are permitted
507     for backward compatibility with historical makefiles and legacy POSIX
508     make and are not recommended.
509
510     Variants of these variables with the punctuation followed immediately by
511     `D' or `F', e.g. `$(@D)', are legacy forms equivalent to using the `:H'
512     and `:T' modifiers.  These forms are accepted for compatibility with AT&T
513     System V UNIX makefiles and POSIX but are not recommended.
514
515     Four of the local variables may be used in sources on dependency lines
516     because they expand to the proper value for each target on the line.
517     These variables are `.TARGET', `.PREFIX', `.ARCHIVE', and `.MEMBER'.
518
519   Additional built-in variables
520     In addition, bmake sets or knows about the following variables:
521
522     .ALLTARGETS     The list of all targets encountered in the makefiles.  If
523                     evaluated during makefile parsing, lists only those tar-
524                     gets encountered thus far.
525
526     .CURDIR         A path to the directory where bmake was executed.  Refer
527                     to the description of `PWD' for more details.
528
529     .INCLUDEDFROMDIR
530                     The directory of the file this Makefile was included
531                     from.
532
533     .INCLUDEDFROMFILE
534                     The filename of the file this Makefile was included from.
535
536     MAKE            The name that bmake was executed with (argv[0]).  For
537                     compatibility, bmake also sets .MAKE with the same value.
538                     The preferred variable to use is the environment variable
539                     MAKE because it is more compatible with other make vari-
540                     ants and cannot be confused with the special target with
541                     the same name.
542
543     .MAKE.DEPENDFILE
544                     Names the makefile (default `.depend') from which gener-
545                     ated dependencies are read.
546
547     .MAKE.EXPAND_VARIABLES
548                     A boolean that controls the default behavior of the -V
549                     option.  If true, variable values printed with -V are
550                     fully expanded; if false, the raw variable contents
551                     (which may include additional unexpanded variable refer-
552                     ences) are shown.
553
554     .MAKE.EXPORTED  The list of variables exported by bmake.
555
556     .MAKE.JOBS      The argument to the -j option.
557
558     .MAKE.JOB.PREFIX
559                     If bmake is run with -j, the output for each target is
560                     prefixed with a token
561                           --- target ---
562                     the first part of which can be controlled via
563                     .MAKE.JOB.PREFIX.  If .MAKE.JOB.PREFIX is empty, no token
564                     is printed.  For example, setting .MAKE.JOB.PREFIX to
565                     `${.newline}---${.MAKE:T}[${.MAKE.PID}]' would produce
566                     tokens like
567                           ---make[1234] target ---
568                     making it easier to track the degree of parallelism being
569                     achieved.
570
571     .MAKE.TARGET_LOCAL_VARIABLES
572                     If set to `false', apparent variable assignments in de-
573                     pendency lines are treated as normal sources.
574
575     MAKEFLAGS       The environment variable `MAKEFLAGS' may contain anything
576                     that may be specified on bmake's command line.  Anything
577                     specified on bmake's command line is appended to the
578                     MAKEFLAGS variable, which is then added to the environ-
579                     ment for all programs that bmake executes.
580
581     .MAKE.LEVEL     The recursion depth of bmake.  The top-level instance of
582                     bmake has level 0, and each child make has its parent
583                     level plus 1.  This allows tests like: .if ${.MAKE.LEVEL}
584                     == 0 to protect things which should only be evaluated in
585                     the top-level instance of bmake.
586
587     .MAKE.MAKEFILE_PREFERENCE
588                     The ordered list of makefile names (default `makefile',
589                     `Makefile') that bmake looks for.
590
591     .MAKE.MAKEFILES
592                     The list of makefiles read by bmake, which is useful for
593                     tracking dependencies.  Each makefile is recorded only
594                     once, regardless of the number of times read.
595
596     .MAKE.MODE      Processed after reading all makefiles.  Affects the mode
597                     that bmake runs in.  It can contain a number of keywords:
598
599                     compat               Like -B, puts bmake into "compat"
600                                          mode.
601
602                     meta                 Puts bmake into "meta" mode, where
603                                          meta files are created for each tar-
604                                          get to capture the command run, the
605                                          output generated, and if filemon(4)
606                                          is available, the system calls which
607                                          are of interest to bmake.  The cap-
608                                          tured output can be useful when di-
609                                          agnosing errors.
610
611                     curdirOk=bf          By default, bmake does not create
612                                          .meta files in `.CURDIR'.  This can
613                                          be overridden by setting bf to a
614                                          value which represents true.
615
616                     missing-meta=bf      If bf is true, a missing .meta file
617                                          makes the target out-of-date.
618
619                     missing-filemon=bf   If bf is true, missing filemon data
620                                          makes the target out-of-date.
621
622                     nofilemon            Do not use filemon(4).
623
624                     env                  For debugging, it can be useful to
625                                          include the environment in the .meta
626                                          file.
627
628                     verbose              If in "meta" mode, print a clue
629                                          about the target being built.  This
630                                          is useful if the build is otherwise
631                                          running silently.  The message
632                                          printed is the expanded value of
633                                          .MAKE.META.PREFIX.
634
635                     ignore-cmd           Some makefiles have commands which
636                                          are simply not stable.  This keyword
637                                          causes them to be ignored for deter-
638                                          mining whether a target is out of
639                                          date in "meta" mode.  See also
640                                          .NOMETA_CMP.
641
642                     silent=bf            If bf is true, when a .meta file is
643                                          created, mark the target .SILENT.
644
645                     randomize-targets    In both compat and parallel mode, do
646                                          not make the targets in the usual
647                                          order, but instead randomize their
648                                          order.  This mode can be used to de-
649                                          tect undeclared dependencies between
650                                          files.
651
652     .MAKE.META.BAILIWICK
653                     In "meta" mode, provides a list of prefixes which match
654                     the directories controlled by bmake.  If a file that was
655                     generated outside of .OBJDIR but within said bailiwick is
656                     missing, the current target is considered out-of-date.
657
658     .MAKE.META.CMP_FILTER
659                     In "meta" mode, it can (very rarely!) be useful to filter
660                     command lines before comparison.  This variable can be
661                     set to a set of modifiers that are applied to each line
662                     of the old and new command that differ, if the filtered
663                     commands still differ, the target is considered out-of-
664                     date.
665
666     .MAKE.META.CREATED
667                     In "meta" mode, this variable contains a list of all the
668                     meta files updated.  If not empty, it can be used to
669                     trigger processing of .MAKE.META.FILES.
670
671     .MAKE.META.FILES
672                     In "meta" mode, this variable contains a list of all the
673                     meta files used (updated or not).  This list can be used
674                     to process the meta files to extract dependency informa-
675                     tion.
676
677     .MAKE.META.IGNORE_PATHS
678                     Provides a list of path prefixes that should be ignored;
679                     because the contents are expected to change over time.
680                     The default list includes: `/dev /etc /proc /tmp /var/run
681                     /var/tmp'
682
683     .MAKE.META.IGNORE_PATTERNS
684                     Provides a list of patterns to match against pathnames.
685                     Ignore any that match.
686
687     .MAKE.META.IGNORE_FILTER
688                     Provides a list of variable modifiers to apply to each
689                     pathname.  Ignore if the expansion is an empty string.
690
691     .MAKE.META.PREFIX
692                     Defines the message printed for each meta file updated in
693                     "meta verbose" mode.  The default value is:
694                           Building ${.TARGET:H:tA}/${.TARGET:T}
695
696     .MAKEOVERRIDES  This variable is used to record the names of variables
697                     assigned to on the command line, so that they may be ex-
698                     ported as part of `MAKEFLAGS'.  This behavior can be dis-
699                     abled by assigning an empty value to `.MAKEOVERRIDES'
700                     within a makefile.  Extra variables can be exported from
701                     a makefile by appending their names to `.MAKEOVERRIDES'.
702                     `MAKEFLAGS' is re-exported whenever `.MAKEOVERRIDES' is
703                     modified.
704
705     .MAKE.PATH_FILEMON
706                     If bmake was built with filemon(4) support, this is set
707                     to the path of the device node.  This allows makefiles to
708                     test for this support.
709
710     .MAKE.PID       The process ID of bmake.
711
712     .MAKE.PPID      The parent process ID of bmake.
713
714     .MAKE.SAVE_DOLLARS
715                     If true, `$$' are preserved when doing `:=' assignments.
716                     The default is false, for backwards compatibility.  Set
717                     to true for compatability with other makes.  If set to
718                     false, `$$' becomes `$' per normal evaluation rules.
719
720     .MAKE.UID       The numeric ID of the user running bmake.
721
722     .MAKE.GID       The numeric group ID of the user running bmake.
723
724     MAKE_PRINT_VAR_ON_ERROR
725                     When bmake stops due to an error, it sets `.ERROR_TARGET'
726                     to the name of the target that failed, `.ERROR_CMD' to
727                     the commands of the failed target, and in "meta" mode, it
728                     also sets `.ERROR_CWD' to the getcwd(3), and
729                     `.ERROR_META_FILE' to the path of the meta file (if any)
730                     describing the failed target.  It then prints its name
731                     and the value of `.CURDIR' as well as the value of any
732                     variables named in `MAKE_PRINT_VAR_ON_ERROR'.
733
734     .newline        This variable is simply assigned a newline character as
735                     its value.  This allows expansions using the :@ modifier
736                     to put a newline between iterations of the loop rather
737                     than a space.  For example, in case of an error, bmake
738                     prints the variable names and their values using:
739                           ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
740
741     .OBJDIR         A path to the directory where the targets are built.  Its
742                     value is determined by trying to chdir(2) to the follow-
743                     ing directories in order and using the first match:
744
745                     1.   ${MAKEOBJDIRPREFIX}${.CURDIR}
746
747                          (Only if `MAKEOBJDIRPREFIX' is set in the environ-
748                          ment or on the command line.)
749
750                     2.   ${MAKEOBJDIR}
751
752                          (Only if `MAKEOBJDIR' is set in the environment or
753                          on the command line.)
754
755                     3.   ${.CURDIR}/obj.${MACHINE}
756
757                     4.   ${.CURDIR}/obj
758
759                     5.   /usr/obj/${.CURDIR}
760
761                     6.   ${.CURDIR}
762
763                     Variable expansion is performed on the value before it is
764                     used, so expressions such as
765                     ${.CURDIR:S,^/usr/src,/var/obj,} may be used.  This is
766                     especially useful with `MAKEOBJDIR'.
767
768                     `.OBJDIR' may be modified in the makefile via the special
769                     target `.OBJDIR'.  In all cases, bmake changes to the
770                     specified directory if it exists, and sets `.OBJDIR' and
771                     `PWD' to that directory before executing any targets.
772
773                     Except in the case of an explicit `.OBJDIR' target, bmake
774                     checks that the specified directory is writable and ig-
775                     nores it if not.  This check can be skipped by setting
776                     the environment variable `MAKE_OBJDIR_CHECK_WRITABLE' to
777                     "no".
778
779     .PARSEDIR       The directory name of the current makefile being parsed.
780
781     .PARSEFILE      The basename of the current makefile being parsed.  This
782                     variable and `.PARSEDIR' are both set only while the
783                     makefiles are being parsed.  To retain their current val-
784                     ues, assign them to a variable using assignment with ex-
785                     pansion `:='.
786
787     .PATH           The space-separated list of directories that bmake
788                     searches for files.  To update this search list, use the
789                     special target `.PATH' rather than modifying the variable
790                     directly.
791
792     PWD             Alternate path to the current directory.  bmake normally
793                     sets `.CURDIR' to the canonical path given by getcwd(3).
794                     However, if the environment variable `PWD' is set and
795                     gives a path to the current directory, bmake sets
796                     `.CURDIR' to the value of `PWD' instead.  This behavior
797                     is disabled if `MAKEOBJDIRPREFIX' is set or `MAKEOBJDIR'
798                     contains a variable transform.  `PWD' is set to the value
799                     of `.OBJDIR' for all programs which bmake executes.
800
801     .SHELL          The pathname of the shell used to run target scripts.  It
802                     is read-only.
803
804     .SUFFIXES       The list of known suffixes.  It is read-only.
805
806     .TARGETS        The list of targets explicitly specified on the command
807                     line, if any.
808
809     VPATH           The colon-separated (":") list of directories that bmake
810                     searches for files.  This variable is supported for com-
811                     patibility with old make programs only, use `.PATH' in-
812                     stead.
813
814   Variable modifiers
815     The general format of a variable expansion is:
816
817           ${variable[:modifier[:...]]}
818
819     Each modifier begins with a colon.  To escape a colon, precede it with a
820     backslash `\'.
821
822     A list of indirect modifiers can be specified via a variable, as follows:
823
824           modifier_variable = modifier[:...]
825
826           ${variable:${modifier_variable}[:...]}
827
828     In this case, the first modifier in the modifier_variable does not start
829     with a colon, since that colon already occurs in the referencing vari-
830     able.  If any of the modifiers in the modifier_variable contains a dollar
831     sign (`$'), these must be doubled to avoid early expansion.
832
833     Some modifiers interpret the expression value as a single string, others
834     treat the expression value as a whitespace-separated list of words.  When
835     splitting a string into words, whitespace can be escaped using double
836     quotes, single quotes and backslashes, like in the shell.  The quotes and
837     backslashes are retained in the words.
838
839     The supported modifiers are:
840
841     :E   Replaces each word in the variable with its suffix.
842
843     :H   Replaces each word in the variable with its dirname.
844
845     :Mpattern
846          Selects only those words that match pattern.  The standard shell
847          wildcard characters (`*', `?', and `[]') may be used.  The wildcard
848          characters may be escaped with a backslash (`\').  As a consequence
849          of the way values are split into words, matched, and then joined,
850          the construct
851                ${VAR:M*}
852          removes all leading and trailing whitespace and normalizes the in-
853          ter-word spacing to a single space.
854
855     :Npattern
856          This is the opposite of `:M', selecting all words which do not match
857          pattern.
858
859     :O   Orders the words alphabetically.
860
861     :On  Orders the words numerically.  A number followed by one of `k', `M'
862          or `G' is multiplied by the appropriate factor, which is 1024 for
863          `k', 1048576 for `M', or 1073741824 for `G'.  Both upper- and lower-
864          case letters are accepted.
865
866     :Or  Orders the words in reverse alphabetical order.
867
868     :Orn
869          Orders the words in reverse numerical order.
870
871     :Ox  Shuffles the words.  The results are different each time you are re-
872          ferring to the modified variable; use the assignment with expansion
873          `:=' to prevent such behavior.  For example,
874
875                LIST=                   uno due tre quattro
876                RANDOM_LIST=            ${LIST:Ox}
877                STATIC_RANDOM_LIST:=    ${LIST:Ox}
878
879                all:
880                        @echo "${RANDOM_LIST}"
881                        @echo "${RANDOM_LIST}"
882                        @echo "${STATIC_RANDOM_LIST}"
883                        @echo "${STATIC_RANDOM_LIST}"
884          may produce output similar to:
885
886                quattro due tre uno
887                tre due quattro uno
888                due uno quattro tre
889                due uno quattro tre
890
891     :Q   Quotes every shell meta-character in the value, so that it can be
892          passed safely to the shell.
893
894     :q   Quotes every shell meta-character in the value, and also doubles `$'
895          characters so that it can be passed safely through recursive invoca-
896          tions of bmake.  This is equivalent to `:S/\$/&&/g:Q'.
897
898     :R   Replaces each word in the variable with everything but its suffix.
899
900     :range[=count]
901          The value is an integer sequence representing the words of the orig-
902          inal value, or the supplied count.
903
904     :gmtime[=timestamp]
905          The value is interpreted as a format string for strftime(3), using
906          gmtime(3), producing the formatted timestamp.  If a timestamp value
907          is not provided or is 0, the current time is used.
908
909     :hash
910          Computes a 32-bit hash of the value and encodes it as 8 hex digits.
911
912     :localtime[=timestamp]
913          The value is interpreted as a format string for strftime(3), using
914          localtime(3), producing the formatted timestamp.  If a timestamp
915          value is not provided or is 0, the current time is used.
916
917     :tA  Attempts to convert the value to an absolute path using realpath(3).
918          If that fails, the value is unchanged.
919
920     :tl  Converts the value to lower-case letters.
921
922     :tsc
923          When joining the words after a modifier that treats the value as
924          words, the words are normally separated by a space.  This modifier
925          changes the separator to the character c.  If c is omitted, no sepa-
926          rator is used.  The common escapes (including octal numeric codes)
927          work as expected.
928
929     :tu  Converts the value to upper-case letters.
930
931     :tW  Causes subsequent modifiers to treat the value as a single word
932          (possibly containing embedded whitespace).  See also `:[*]'.
933
934     :tw  Causes the value to be treated as a list of words.  See also `:[@]'.
935
936     :S/old_string/new_string/[1gW]
937          Modifies the first occurrence of old_string in each word of the
938          value, replacing it with new_string.  If a `g' is appended to the
939          last delimiter of the pattern, all occurrences in each word are re-
940          placed.  If a `1' is appended to the last delimiter of the pattern,
941          only the first occurrence is affected.  If a `W' is appended to the
942          last delimiter of the pattern, the value is treated as a single
943          word.  If old_string begins with a caret (`^'), old_string is an-
944          chored at the beginning of each word.  If old_string ends with a
945          dollar sign (`$'), it is anchored at the end of each word.  Inside
946          new_string, an ampersand (`&') is replaced by old_string (without
947          the anchoring `^' or `$').  Any character may be used as the delim-
948          iter for the parts of the modifier string.  The anchoring, ampersand
949          and delimiter characters can be escaped with a backslash (`\').
950
951          Variable expansion occurs in the normal fashion inside both
952          old_string and new_string with the single exception that a backslash
953          is used to prevent the expansion of a dollar sign (`$'), not a pre-
954          ceding dollar sign as is usual.
955
956     :C/pattern/replacement/[1gW]
957          The :C modifier works like the :S modifier except that the old and
958          new strings, instead of being simple strings, are an extended regu-
959          lar expression pattern (see regex(3)) and an ed(1)-style
960          replacement.  Normally, the first occurrence of the pattern pattern
961          in each word of the value is substituted with replacement.  The `1'
962          modifier causes the substitution to apply to at most one word; the
963          `g' modifier causes the substitution to apply to as many instances
964          of the search pattern pattern as occur in the word or words it is
965          found in; the `W' modifier causes the value to be treated as a sin-
966          gle word (possibly containing embedded whitespace).
967
968          As for the :S modifier, the pattern and replacement are subjected to
969          variable expansion before being parsed as regular expressions.
970
971     :T   Replaces each word in the variable with its last path component
972          (basename).
973
974     :u   Removes adjacent duplicate words (like uniq(1)).
975
976     :?true_string:false_string
977          If the variable name (not its value), when parsed as a .if condi-
978          tional expression, evaluates to true, return as its value the
979          true_string, otherwise return the false_string.  Since the variable
980          name is used as the expression, :? must be the first modifier after
981          the variable name itself--which, of course, usually contains vari-
982          able expansions.  A common error is trying to use expressions like
983                ${NUMBERS:M42:?match:no}
984          which actually tests defined(NUMBERS).  To determine if any words
985          match "42", you need to use something like:
986                ${"${NUMBERS:M42}" != "":?match:no}.
987
988     :old_string=new_string
989          This is the AT&T System V UNIX style variable substitution.  It must
990          be the last modifier specified.  If old_string or new_string do not
991          contain the pattern matching character `%', it is assumed that they
992          are anchored at the end of each word, so only suffixes or entire
993          words may be replaced.  Otherwise `%' is the substring of old_string
994          to be replaced in new_string.  If only old_string contains the pat-
995          tern matching character `%', and old_string matches, the result is
996          the new_string.  If only the new_string contains the pattern match-
997          ing character `%', it is not treated specially and it is printed as
998          a literal `%' on match.  If there is more than one pattern matching
999          character `%' in either the new_string or old_string, only the first
1000          instance is treated specially (as the pattern character); all subse-
1001          quent instances are treated as regular characters.
1002
1003          Variable expansion occurs in the normal fashion inside both
1004          old_string and new_string with the single exception that a backslash
1005          is used to prevent the expansion of a dollar sign (`$'), not a pre-
1006          ceding dollar sign as is usual.
1007
1008     :@varname@string@
1009          This is the loop expansion mechanism from the OSF Development Envi-
1010          ronment (ODE) make.  Unlike .for loops, expansion occurs at the time
1011          of reference.  For each word in the value, assign the word to the
1012          variable named varname and evaluate string.  The ODE convention is
1013          that varname should start and end with a period, for example:
1014                ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1015
1016          However, a single-letter variable is often more readable:
1017                ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1018
1019     :_[=var]
1020          Saves the current variable value in `$_' or the named var for later
1021          reference.  Example usage:
1022
1023                M_cmpv.units = 1 1000 1000000
1024                M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \
1025                \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
1026
1027                .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
1028
1029          Here `$_' is used to save the result of the `:S' modifier which is
1030          later referenced using the index values from `:range'.
1031
1032     :Unewval
1033          If the variable is undefined, newval is the value.  If the variable
1034          is defined, the existing value is returned.  This is another ODE
1035          make feature.  It is handy for setting per-target CFLAGS for in-
1036          stance:
1037                ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1038          If a value is only required if the variable is undefined, use:
1039                ${VAR:D:Unewval}
1040
1041     :Dnewval
1042          If the variable is defined, newval is the value.
1043
1044     :L   The name of the variable is the value.
1045
1046     :P   The path of the node which has the same name as the variable is the
1047          value.  If no such node exists or its path is null, the name of the
1048          variable is used.  In order for this modifier to work, the name
1049          (node) must at least have appeared on the right-hand side of a de-
1050          pendency.
1051
1052     :!cmd!
1053          The output of running cmd is the value.
1054
1055     :sh  The value is run as a command, and the output becomes the new value.
1056
1057     ::=str
1058          The variable is assigned the value str after substitution.  This
1059          modifier and its variations are useful in obscure situations such as
1060          wanting to set a variable at a point where a target's shell commands
1061          are being parsed.  These assignment modifiers always expand to noth-
1062          ing.
1063
1064          The `::' helps avoid false matches with the AT&T System V UNIX style
1065          := modifier and since substitution always occurs, the ::= form is
1066          vaguely appropriate.
1067
1068     ::?=str
1069          As for ::= but only if the variable does not already have a value.
1070
1071     ::+=str
1072          Append str to the variable.
1073
1074     ::!=cmd
1075          Assign the output of cmd to the variable.
1076
1077     :[range]
1078          Selects one or more words from the value, or performs other opera-
1079          tions related to the way in which the value is split into words.
1080
1081          An empty value, or a value that consists entirely of white-space, is
1082          treated as a single word.  For the purposes of the `:[]' modifier,
1083          the words are indexed both forwards using positive integers (where
1084          index 1 represents the first word), and backwards using negative in-
1085          tegers (where index -1 represents the last word).
1086
1087          The range is subjected to variable expansion, and the expanded re-
1088          sult is then interpreted as follows:
1089
1090          index  Selects a single word from the value.
1091
1092          start..end
1093                 Selects all words from start to end, inclusive.  For example,
1094                 `:[2..-1]' selects all words from the second word to the last
1095                 word.  If start is greater than end, the words are output in
1096                 reverse order.  For example, `:[-1..1]' selects all the words
1097                 from last to first.  If the list is already ordered, this ef-
1098                 fectively reverses the list, but it is more efficient to use
1099                 `:Or' instead of `:O:[-1..1]'.
1100
1101          *      Causes subsequent modifiers to treat the value as a single
1102                 word (possibly containing embedded whitespace).  Analogous to
1103                 the effect of $* in Bourne shell.
1104
1105          0      Means the same as `:[*]'.
1106
1107          @      Causes subsequent modifiers to treat the value as a sequence
1108                 of words delimited by whitespace.  Analogous to the effect of
1109                 $@ in Bourne shell.
1110
1111          #      Returns the number of words in the value.
1112
1113DIRECTIVES
1114     Makefile inclusion, conditional structures and for loops are provided in
1115     bmake.  All such structures are identified by a line beginning with a
1116     single dot (`.') character, followed by the keyword of the directive,
1117     such as include or if.
1118
1119   File inclusion
1120     Files are included with either .include <file> or .include "file".  Vari-
1121     ables between the angle brackets or double quotes are expanded to form
1122     the file name.  If angle brackets are used, the included makefile is ex-
1123     pected to be in the system makefile directory.  If double quotes are
1124     used, the including makefile's directory and any directories specified
1125     using the -I option are searched before the system makefile directory.
1126
1127     For compatibility with other make variants, `include file ...' (without
1128     leading dot) is also accepted.
1129
1130     If the include statement is written as .-include or as .sinclude, errors
1131     locating and/or opening include files are ignored.
1132
1133     If the include statement is written as .dinclude, not only are errors lo-
1134     cating and/or opening include files ignored, but stale dependencies
1135     within the included file are ignored just like in .MAKE.DEPENDFILE.
1136
1137   Exporting variables
1138     The directives for exporting and unexporting variables are:
1139
1140     .export variable ...
1141             Export the specified global variable.  If no variable list is
1142             provided, all globals are exported except for internal variables
1143             (those that start with `.').  This is not affected by the -X
1144             flag, so should be used with caution.  For compatibility with
1145             other make programs, export variable=value (without leading dot)
1146             is also accepted.
1147
1148             Appending a variable name to .MAKE.EXPORTED is equivalent to ex-
1149             porting a variable.
1150
1151     .export-env variable ...
1152             The same as `.export', except that the variable is not appended
1153             to .MAKE.EXPORTED.  This allows exporting a value to the environ-
1154             ment which is different from that used by bmake internally.
1155
1156     .export-literal variable ...
1157             The same as `.export-env', except that variables in the value are
1158             not expanded.
1159
1160     .unexport variable ...
1161             The opposite of `.export'.  The specified global variable is re-
1162             moved from .MAKE.EXPORTED.  If no variable list is provided, all
1163             globals are unexported, and .MAKE.EXPORTED deleted.
1164
1165     .unexport-env
1166             Unexport all globals previously exported and clear the environ-
1167             ment inherited from the parent.  This operation causes a memory
1168             leak of the original environment, so should be used sparingly.
1169             Testing for .MAKE.LEVEL being 0 would make sense.  Also note that
1170             any variables which originated in the parent environment should
1171             be explicitly preserved if desired.  For example:
1172
1173                   .if ${.MAKE.LEVEL} == 0
1174                   PATH := ${PATH}
1175                   .unexport-env
1176                   .export PATH
1177                   .endif
1178
1179             Would result in an environment containing only `PATH', which is
1180             the minimal useful environment.  Actually `.MAKE.LEVEL' is also
1181             pushed into the new environment.
1182
1183   Messages
1184     The directives for printing messages to the output are:
1185
1186     .info message
1187             The message is printed along with the name of the makefile and
1188             line number.
1189
1190     .warning message
1191             The message prefixed by `warning:' is printed along with the name
1192             of the makefile and line number.
1193
1194     .error message
1195             The message is printed along with the name of the makefile and
1196             line number, bmake exits immediately.
1197
1198   Conditionals
1199     The directives for conditionals are:
1200
1201     .if [!]expression [operator expression ...]
1202             Test the value of an expression.
1203
1204     .ifdef [!]variable [operator variable ...]
1205             Test the value of a variable.
1206
1207     .ifndef [!]variable [operator variable ...]
1208             Test the value of a variable.
1209
1210     .ifmake [!]target [operator target ...]
1211             Test the target being requested.
1212
1213     .ifnmake [!]target [operator target ...]
1214             Test the target being requested.
1215
1216     .else   Reverse the sense of the last conditional.
1217
1218     .elif [!]expression [operator expression ...]
1219             A combination of `.else' followed by `.if'.
1220
1221     .elifdef [!]variable [operator variable ...]
1222             A combination of `.else' followed by `.ifdef'.
1223
1224     .elifndef [!]variable [operator variable ...]
1225             A combination of `.else' followed by `.ifndef'.
1226
1227     .elifmake [!]target [operator target ...]
1228             A combination of `.else' followed by `.ifmake'.
1229
1230     .elifnmake [!]target [operator target ...]
1231             A combination of `.else' followed by `.ifnmake'.
1232
1233     .endif  End the body of the conditional.
1234
1235     The operator may be any one of the following:
1236
1237     ||     Logical OR.
1238
1239     &&     Logical AND; of higher precedence than `||'.
1240
1241     bmake only evaluates a conditional as far as is necessary to determine
1242     its value.  Parentheses can be used to override the operator precedence.
1243     The boolean operator `!' may be used to logically negate an entire condi-
1244     tional.  It is of higher precedence than `&&'.
1245
1246     The value of expression may be any of the following:
1247
1248     defined  Takes a variable name as an argument and evaluates to true if
1249              the variable has been defined.
1250
1251     make     Takes a target name as an argument and evaluates to true if the
1252              target was specified as part of bmake's command line or was de-
1253              clared the default target (either implicitly or explicitly, see
1254              .MAIN) before the line containing the conditional.
1255
1256     empty    Takes a variable name, with possible modifiers, and evaluates to
1257              true if the expansion of the variable results in an empty
1258              string.
1259
1260     exists   Takes a file name as an argument and evaluates to true if the
1261              file exists.  The file is searched for on the system search path
1262              (see .PATH).
1263
1264     target   Takes a target name as an argument and evaluates to true if the
1265              target has been defined.
1266
1267     commands
1268              Takes a target name as an argument and evaluates to true if the
1269              target has been defined and has commands associated with it.
1270
1271     Expression may also be an arithmetic or string comparison.  Variable ex-
1272     pansion is performed on both sides of the comparison.  If both sides are
1273     numeric and neither is enclosed in quotes, the comparison is done numeri-
1274     cally, otherwise lexicographically.  A string is interpreted as hexadeci-
1275     mal integer if it is preceded by 0x, otherwise it is a decimal floating-
1276     point number; octal numbers are not supported.
1277
1278     All comparisons may use the operators `==' and `!='.  Numeric comparisons
1279     may also use the operators `<', `<=', `>' and `>='.
1280
1281     If the comparison has neither a comparison operator nor a right side, the
1282     expression evaluates to true if it is nonempty and its numeric value (if
1283     any) is not zero.
1284
1285     When bmake is evaluating one of these conditional expressions, and it en-
1286     counters a (whitespace separated) word it doesn't recognize, either the
1287     "make" or "defined" function is applied to it, depending on the form of
1288     the conditional.  If the form is `.ifdef', `.ifndef' or `.if', the
1289     "defined" function is applied.  Similarly, if the form is `.ifmake' or
1290     `.ifnmake', the "make" function is applied.
1291
1292     If the conditional evaluates to true, parsing of the makefile continues
1293     as before.  If it evaluates to false, the following lines are skipped.
1294     In both cases, this continues until the corresponding `.else' or `.endif'
1295     is found.
1296
1297   For loops
1298     For loops are typically used to apply a set of rules to a list of files.
1299     The syntax of a for loop is:
1300
1301     .for variable [variable ...] in expression
1302     <make-lines>
1303     .endfor
1304
1305     The expression is expanded and then split into words.  On each iteration
1306     of the loop, one word is taken and assigned to each variable, in order,
1307     and these variables are substituted into the make-lines inside the body
1308     of the for loop.  The number of words must come out even; that is, if
1309     there are three iteration variables, the number of words provided must be
1310     a multiple of three.
1311
1312     If `.break' is encountered within a .for loop, it causes early termina-
1313     tion of the loop, otherwise a parse error.
1314
1315   Other directives
1316     .undef variable ...
1317             Un-define the specified global variables.  Only global variables
1318             can be un-defined.
1319
1320COMMENTS
1321     Comments begin with a hash (`#') character, anywhere but in a shell com-
1322     mand line, and continue to the end of an unescaped new line.
1323
1324SPECIAL SOURCES (ATTRIBUTES)
1325     .EXEC     Target is never out of date, but always execute commands any-
1326               way.
1327
1328     .IGNORE   Ignore any errors from the commands associated with this tar-
1329               get, exactly as if they all were preceded by a dash (`-').
1330
1331     .MADE     Mark all sources of this target as being up to date.
1332
1333     .MAKE     Execute the commands associated with this target even if the -n
1334               or -t options were specified.  Normally used to mark recursive
1335               bmakes.
1336
1337     .META     Create a meta file for the target, even if it is flagged as
1338               .PHONY, .MAKE, or .SPECIAL.  Usage in conjunction with .MAKE is
1339               the most likely case.  In "meta" mode, the target is out-of-
1340               date if the meta file is missing.
1341
1342     .NOMETA   Do not create a meta file for the target.  Meta files are also
1343               not created for .PHONY, .MAKE, or .SPECIAL targets.
1344
1345     .NOMETA_CMP
1346               Ignore differences in commands when deciding if target is out
1347               of date.  This is useful if the command contains a value which
1348               always changes.  If the number of commands change, though, the
1349               target is still considered out of date.  The same effect ap-
1350               plies to any command line that uses the variable .OODATE, which
1351               can be used for that purpose even when not otherwise needed or
1352               desired:
1353
1354
1355                     skip-compare-for-some:
1356                             @echo this is compared
1357                             @echo this is not ${.OODATE:M.NOMETA_CMP}
1358                             @echo this is also compared
1359
1360               The :M pattern suppresses any expansion of the unwanted vari-
1361               able.
1362
1363     .NOPATH   Do not search for the target in the directories specified by
1364               .PATH.
1365
1366     .NOTMAIN  Normally bmake selects the first target it encounters as the
1367               default target to be built if no target was specified.  This
1368               source prevents this target from being selected.
1369
1370     .OPTIONAL
1371               If a target is marked with this attribute and bmake can't fig-
1372               ure out how to create it, it ignores this fact and assumes the
1373               file isn't needed or already exists.
1374
1375     .PHONY    The target does not correspond to an actual file; it is always
1376               considered to be out of date, and is not created with the -t
1377               option.  Suffix-transformation rules are not applied to .PHONY
1378               targets.
1379
1380     .PRECIOUS
1381               When bmake is interrupted, it normally removes any partially
1382               made targets.  This source prevents the target from being re-
1383               moved.
1384
1385     .RECURSIVE
1386               Synonym for .MAKE.
1387
1388     .SILENT   Do not echo any of the commands associated with this target,
1389               exactly as if they all were preceded by an at sign (`@').
1390
1391     .USE      Turn the target into bmake's version of a macro.  When the tar-
1392               get is used as a source for another target, the other target
1393               acquires the commands, sources, and attributes (except for
1394               .USE) of the source.  If the target already has commands, the
1395               .USE target's commands are appended to them.
1396
1397     .USEBEFORE
1398               Like .USE, but instead of appending, prepend the .USEBEFORE
1399               target commands to the target.
1400
1401     .WAIT     If .WAIT appears in a dependency line, the sources that precede
1402               it are made before the sources that succeed it in the line.
1403               Since the dependents of files are not made until the file it-
1404               self could be made, this also stops the dependents being built
1405               unless they are needed for another branch of the dependency
1406               tree.  So given:
1407
1408               x: a .WAIT b
1409                       echo x
1410               a:
1411                       echo a
1412               b: b1
1413                       echo b
1414               b1:
1415                       echo b1
1416
1417               the output is always `a', `b1', `b', `x'.
1418
1419               The ordering imposed by .WAIT is only relevant for parallel
1420               makes.
1421
1422SPECIAL TARGETS
1423     Special targets may not be included with other targets, i.e. they must be
1424     the only target specified.
1425
1426     .BEGIN   Any command lines attached to this target are executed before
1427              anything else is done.
1428
1429     .DEFAULT
1430              This is sort of a .USE rule for any target (that was used only
1431              as a source) that bmake can't figure out any other way to cre-
1432              ate.  Only the shell script is used.  The .IMPSRC variable of a
1433              target that inherits .DEFAULT's commands is set to the target's
1434              own name.
1435
1436     .DELETE_ON_ERROR
1437              If this target is present in the makefile, it globally causes
1438              make to delete targets whose commands fail.  (By default, only
1439              targets whose commands are interrupted during execution are
1440              deleted.  This is the historical behavior.)  This setting can be
1441              used to help prevent half-finished or malformed targets from be-
1442              ing left around and corrupting future rebuilds.
1443
1444     .END     Any command lines attached to this target are executed after ev-
1445              erything else is done successfully.
1446
1447     .ERROR   Any command lines attached to this target are executed when an-
1448              other target fails.  The .ERROR_TARGET variable is set to the
1449              target that failed.  See also MAKE_PRINT_VAR_ON_ERROR.
1450
1451     .IGNORE  Mark each of the sources with the .IGNORE attribute.  If no
1452              sources are specified, this is the equivalent of specifying the
1453              -i option.
1454
1455     .INTERRUPT
1456              If bmake is interrupted, the commands for this target are exe-
1457              cuted.
1458
1459     .MAIN    If no target is specified when bmake is invoked, this target is
1460              built.
1461
1462     .MAKEFLAGS
1463              This target provides a way to specify flags for bmake at the
1464              time when the makefiles are read.  The flags are as if typed to
1465              the shell, though the -f option has no effect.
1466
1467     .NOPATH  Apply the .NOPATH attribute to any specified sources.
1468
1469     .NOTPARALLEL
1470              Disable parallel mode.
1471
1472     .NO_PARALLEL
1473              Synonym for .NOTPARALLEL, for compatibility with other pmake
1474              variants.
1475
1476     .OBJDIR  The source is a new value for `.OBJDIR'.  If it exists, bmake
1477              changes the current working directory to it and updates the
1478              value of `.OBJDIR'.
1479
1480     .ORDER   In parallel mode, the named targets are made in sequence.  This
1481              ordering does not add targets to the list of targets to be made.
1482
1483              Since the dependents of a target do not get built until the tar-
1484              get itself could be built, unless `a' is built by another part
1485              of the dependency graph, the following is a dependency loop:
1486
1487              .ORDER: b a
1488              b: a
1489
1490     .PATH    The sources are directories which are to be searched for files
1491              not found in the current directory.  If no sources are speci-
1492              fied, any previously specified directories are removed from the
1493              search path.  If the source is the special .DOTLAST target, the
1494              current working directory is searched last.
1495
1496     .PATH.suffix
1497              Like .PATH but applies only to files with a particular suffix.
1498              The suffix must have been previously declared with .SUFFIXES.
1499
1500     .PHONY   Apply the .PHONY attribute to any specified sources.
1501
1502     .POSIX   If this is the first non-comment line in the main makefile, the
1503              variable %POSIX is set to the value `1003.2' and the makefile
1504              `<posix.mk>' is included if it exists, to provide POSIX-compati-
1505              ble default rules.  If bmake is run with the -r flag, only
1506              `posix.mk' contributes to the default rules.
1507
1508     .PRECIOUS
1509              Apply the .PRECIOUS attribute to any specified sources.  If no
1510              sources are specified, the .PRECIOUS attribute is applied to ev-
1511              ery target in the file.
1512
1513     .SHELL   Sets the shell that bmake uses to execute commands.  The sources
1514              are a set of field=value pairs.
1515
1516              name        This is the minimal specification, used to select
1517                          one of the built-in shell specs; sh, ksh, and csh.
1518
1519              path        Specifies the absolute path to the shell.
1520
1521              hasErrCtl   Indicates whether the shell supports exit on error.
1522
1523              check       The command to turn on error checking.
1524
1525              ignore      The command to disable error checking.
1526
1527              echo        The command to turn on echoing of commands executed.
1528
1529              quiet       The command to turn off echoing of commands exe-
1530                          cuted.
1531
1532              filter      The output to filter after issuing the quiet com-
1533                          mand.  It is typically identical to quiet.
1534
1535              errFlag     The flag to pass the shell to enable error checking.
1536
1537              echoFlag    The flag to pass the shell to enable command echo-
1538                          ing.
1539
1540              newline     The string literal to pass the shell that results in
1541                          a single newline character when used outside of any
1542                          quoting characters.
1543              Example:
1544
1545              .SHELL: name=ksh path=/bin/ksh hasErrCtl=true \
1546                      check="set -e" ignore="set +e" \
1547                      echo="set -v" quiet="set +v" filter="set +v" \
1548                      echoFlag=v errFlag=e newline="'\n'"
1549
1550     .SILENT  Apply the .SILENT attribute to any specified sources.  If no
1551              sources are specified, the .SILENT attribute is applied to every
1552              command in the file.
1553
1554     .STALE   This target gets run when a dependency file contains stale en-
1555              tries, having .ALLSRC set to the name of that dependency file.
1556
1557     .SUFFIXES
1558              Each source specifies a suffix to bmake.  If no sources are
1559              specified, any previously specified suffixes are deleted.  It
1560              allows the creation of suffix-transformation rules.
1561
1562              Example:
1563
1564              .SUFFIXES: .o
1565              .c.o:
1566                      cc -o ${.TARGET} -c ${.IMPSRC}
1567
1568ENVIRONMENT
1569     bmake uses the following environment variables, if they exist: MACHINE,
1570     MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX, MAKESYSPATH,
1571     PWD, and TMPDIR.
1572
1573     MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on
1574     the command line to bmake and not as makefile variables; see the descrip-
1575     tion of `.OBJDIR' for more details.
1576
1577FILES
1578     .depend        list of dependencies
1579     Makefile       list of dependencies
1580     makefile       list of dependencies
1581     sys.mk         system makefile
1582     /usr/share/mk  system makefile directory
1583
1584COMPATIBILITY
1585     The basic make syntax is compatible between different make variants; how-
1586     ever the special variables, variable modifiers and conditionals are not.
1587
1588   Older versions
1589     An incomplete list of changes in older versions of bmake:
1590
1591     The way that .for loop variables are substituted changed after NetBSD 5.0
1592     so that they still appear to be variable expansions.  In particular this
1593     stops them being treated as syntax, and removes some obscure problems us-
1594     ing them in .if statements.
1595
1596     The way that parallel makes are scheduled changed in NetBSD 4.0 so that
1597     .ORDER and .WAIT apply recursively to the dependent nodes.  The algo-
1598     rithms used may change again in the future.
1599
1600   Other make dialects
1601     Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not sup-
1602     port most of the features of bmake as described in this manual.  Most no-
1603     tably:
1604
1605           +o   The .WAIT and .ORDER declarations and most functionality per-
1606               taining to parallelization.  (GNU make supports parallelization
1607               but lacks these features needed to control it effectively.)
1608
1609           +o   Directives, including for loops and conditionals and most of
1610               the forms of include files.  (GNU make has its own incompatible
1611               and less powerful syntax for conditionals.)
1612
1613           +o   All built-in variables that begin with a dot.
1614
1615           +o   Most of the special sources and targets that begin with a dot,
1616               with the notable exception of .PHONY, .PRECIOUS, and .SUFFIXES.
1617
1618           +o   Variable modifiers, except for the
1619                     :old=new
1620               string substitution, which does not portably support globbing
1621               with `%' and historically only works on declared suffixes.
1622
1623           +o   The $> variable even in its short form; most makes support this
1624               functionality but its name varies.
1625
1626     Some features are somewhat more portable, such as assignment with +=, ?=,
1627     and !=.  The .PATH functionality is based on an older feature VPATH found
1628     in GNU make and many versions of SVR4 make; however, historically its be-
1629     havior is too ill-defined (and too buggy) to rely upon.
1630
1631     The $@ and $< variables are more or less universally portable, as is the
1632     $(MAKE) variable.  Basic use of suffix rules (for files only in the cur-
1633     rent directory, not trying to chain transformations together, etc.) is
1634     also reasonably portable.
1635
1636SEE ALSO
1637     mkdep(1)
1638
1639HISTORY
1640     bmake is derived from NetBSD make(1).  It uses autoconf to facilitate
1641     portability to other platforms.
1642
1643     A make command appeared in Version 7 AT&T UNIX.  This make implementation
1644     is based on Adam de Boor's pmake program, which was written for Sprite at
1645     Berkeley.  It was designed to be a parallel distributed make running jobs
1646     on different machines using a daemon called "customs".
1647
1648     Historically the target/dependency FRC has been used to FoRCe rebuilding
1649     (since the target/dependency does not exist... unless someone creates an
1650     FRC file).
1651
1652BUGS
1653     The make syntax is difficult to parse without actually acting on the
1654     data.  For instance, finding the end of a variable's use should involve
1655     scanning each of the modifiers, using the correct terminator for each
1656     field.  In many places make just counts {} and () in order to find the
1657     end of a variable expansion.
1658
1659     There is no way of escaping a space character in a filename.
1660
1661FreeBSD 13.0                  September 12, 2022                  FreeBSD 13.0
1662