1MAKE(1)                   BSD General Commands Manual                  MAKE(1)
2

NAME

4     bmake — maintain program dependencies
5

SYNOPSIS

7     bmake [-BeikNnqrstWX] [-D variable] [-d flags] [-f makefile]
8           [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]
9           [-V variable] [variable=value] [target ...]
10

DESCRIPTION

12     bmake is a program designed to simplify the maintenance of other pro‐
13     grams.  Its input is a list of specifications as to the files upon which
14     programs and other files depend.  If no -f makefile makefile option is
15     given, bmake will try to open ‘makefile’ then ‘Makefile’ in order to find
16     the specifications.  If the file ‘.depend’ exists, it is read (see
17     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 Make - A
21     Tutorial.
22
23     bmake will prepend the contents of the MAKEFLAGS environment variable to
24     the 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 executing the commands to make the sources of a
30             dependency line in sequence.
31
32     -D variable
33             Define variable to be 1, in the global context.
34
35     -d [-]flags
36             Turn on debugging, and specify which portions of bmake are to
37             print debugging information.  Unless the flags are preceded by
38             ‘-’ they are added to the MAKEFLAGS environment variable and will
39             be processed by any child make processes.  By default, debugging
40             information is printed to standard error, but this can be changed
41             using the F debugging flag.  The debugging output is always
42             unbuffered; in addition, if debugging is enabled but debugging
43             output is not directed to standard output, then the standard out‐
44             put is line buffered.  Flags is one or more of the following:
45
46             A       Print all possible debugging information; equivalent to
47                     specifying all of the debugging flags.
48
49             a       Print debugging information about archive searching and
50                     caching.
51
52             C       Print debugging information about current working direc‐
53                     tory.
54
55             c       Print debugging information about conditional evaluation.
56
57             d       Print debugging information about directory searching and
58                     caching.
59
60             e       Print debugging information about failed commands and
61                     targets.
62
63             F[+]filename
64                     Specify where debugging output is written.  This must be
65                     the last flag, because it consumes the remainder of the
66                     argument.  If the character immediately after the ‘F’
67                     flag is ‘+’, then the file will be opened in append mode;
68                     otherwise the file will be overwritten.  If the file name
69                     is ‘stdout’ or ‘stderr’ then debugging output will be
70                     written to the standard output or standard error output
71                     file descriptors respectively (and the ‘+’ option has no
72                     effect).  Otherwise, the output will be written to the
73                     named file.  If the file name ends ‘.%d’ then the ‘%d’ is
74                     replaced by the pid.
75
76             f       Print debugging information about loop evaluation.
77
78             g1      Print the input graph before making anything.
79
80             g2      Print the input graph after making everything, or before
81                     exiting on error.
82
83             g3      Print the input graph before exiting on error.
84
85             j       Print debugging information about running multiple
86                     shells.
87
88             l       Print commands in Makefiles regardless of whether or not
89                     they are prefixed by ‘@’ or other "quiet" flags.  Also
90                     known as "loud" behavior.
91
92             m       Print debugging information about making targets, includ‐
93                     ing modification dates.
94
95             n       Don't delete the temporary command scripts created in
96                     /tmp when running commands.  These are created via
97                     mkstemp(3) and have names of the form /tmp/makeXXXXX.
98                     NOTE: This can create many file in /tmp so use with care.
99
100             p       Print debugging information about makefile parsing.
101
102             s       Print debugging information about suffix-transformation
103                     rules.
104
105             t       Print debugging information about target list mainte‐
106                     nance.
107
108             v       Print debugging information about variable assignment.
109
110             x       Run shell commands with -x so the actual commands are
111                     printed as they are executed.
112
113     -e      Specify that environment variables override macro assignments
114             within makefiles.
115
116     -f makefile
117             Specify a makefile to read instead of the default ‘makefile’.  If
118             makefile is ‘-’, standard input is read.  Multiple makefiles may
119             be specified, and are read in the order specified.
120
121     -I directory
122             Specify a directory in which to search for makefiles and included
123             makefiles.  The system makefile directory (or directories, see
124             the -m option) is automatically included as part of this list.
125
126     -i      Ignore non-zero exit of shell commands in the makefile.  Equiva‐
127             lent to specifying ‘-’ before each command line in the makefile.
128
129     -J private
130             This option should not be specified by the user.
131
132             When the j option is in use in a recursive build, this option is
133             passed by a make to child makes to allow all the make processes
134             in the build to cooperate to avoid overloading the system.
135
136     -j max_jobs
137             Specify the maximum number of jobs that bmake may have running at
138             any one time.  Turns compatibility mode off, unless the B flag is
139             also specified.  When compatibility mode is off, all commands
140             associated with a target are executed in a single shell invoca‐
141             tion as opposed to the traditional one shell invocation per line.
142             This can break traditional scripts which change directories on
143             each command invocation and then expect to start with a fresh
144             environment on the next line.  It is more efficient to correct
145             the scripts rather than turn backwards compatibility on.
146
147     -k      Continue processing after errors are encountered, but only on
148             those targets that do not depend on the target whose creation
149             caused the error.
150
151     -m directory
152             Specify a directory in which to search for sys.mk and makefiles
153             included via the ⟨file⟩-style include statement.  The -m option
154             can be used multiple times to form a search path.  This path will
155             override the default system include path: /usr/share/mk.  Fur‐
156             thermore the system include path will be appended to the search
157             path used for "file"-style include statements (see the -I
158             option).
159
160             If a file or directory name in the -m argument (or the
161             MAKESYSPATH environment variable) starts with the string ".../"
162             then bmake will search for the specified file or directory named
163             in the remaining part of the argument string.  The search starts
164             with the current directory of the Makefile and then works upward
165             towards the root of the filesystem.  If the search is successful,
166             then the resulting directory replaces the ".../" specification in
167             the -m argument.  If used, this feature allows bmake to easily
168             search in the current source tree for customized sys.mk files
169             (e.g., by using ".../mk/sys.mk" as an argument).
170
171     -n      Display the commands that would have been executed, but do not
172             actually execute them unless the target depends on the .MAKE spe‐
173             cial source (see below).
174
175     -N      Display the commands which would have been executed, but do not
176             actually execute any of them; useful for debugging top-level
177             makefiles without descending into subdirectories.
178
179     -q      Do not execute any commands, but exit 0 if the specified targets
180             are up-to-date and 1, otherwise.
181
182     -r      Do not use the built-in rules specified in the system makefile.
183
184     -s      Do not echo any commands as they are executed.  Equivalent to
185             specifying ‘@’ before each command line in the makefile.
186
187     -T tracefile
188             When used with the -j flag, append a trace record to tracefile
189             for each job started and completed.
190
191     -t      Rather than re-building a target as specified in the makefile,
192             create it or update its modification time to make it appear up-
193             to-date.
194
195     -V variable
196             Print bmake's idea of the value of variable, in the global con‐
197             text.  Do not build any targets.  Multiple instances of this
198             option may be specified; the variables will be printed one per
199             line, with a blank line for each null or undefined variable.  If
200             variable contains a ‘$’ then the value will be expanded before
201             printing.
202
203     -W      Treat any warnings during makefile parsing as errors.
204
205     -X      Don't export variables passed on the command line to the environ‐
206             ment individually.  Variables passed on the command line are
207             still exported via the MAKEFLAGS environment variable.  This
208             option may be useful on systems which have a small limit on the
209             size of command arguments.
210
211     variable=value
212             Set the value of the variable variable to value.  Normally, all
213             values passed on the command line are also exported to sub-makes
214             in the environment.  The -X flag disables this behavior.  Vari‐
215             able assignments should follow options for POSIX compatibility
216             but no ordering is enforced.
217
218     There are seven different types of lines in a makefile: file dependency
219     specifications, shell commands, variable assignments, include statements,
220     conditional directives, for loops, and comments.
221
222     In general, lines may be continued from one line to the next by ending
223     them with a backslash (‘\’).  The trailing newline character and initial
224     whitespace on the following line are compressed into a single space.
225

FILE DEPENDENCY SPECIFICATIONS

227     Dependency lines consist of one or more targets, an operator, and zero or
228     more sources.  This creates a relationship where the targets “depend” on
229     the sources and are usually created from them.  The exact relationship
230     between the target and the source is determined by the operator that sep‐
231     arates them.  The three operators are as follows:
232
233     :     A target is considered out-of-date if its modification time is less
234           than those of any of its sources.  Sources for a target accumulate
235           over dependency lines when this operator is used.  The target is
236           removed if bmake is interrupted.
237
238     !     Targets are always re-created, but not until all sources have been
239           examined and re-created as necessary.  Sources for a target accumu‐
240           late over dependency lines when this operator is used.  The target
241           is removed if bmake is interrupted.
242
243     ::    If no sources are specified, the target is always re-created.  Oth‐
244           erwise, a target is considered out-of-date if any of its sources
245           has been modified more recently than the target.  Sources for a
246           target do not accumulate over dependency lines when this operator
247           is used.  The target will not be removed if bmake is interrupted.
248
249     Targets and sources may contain the shell wildcard values ‘?’, ‘*’, ‘[]’,
250     and ‘{}’.  The values ‘?’, ‘*’, and ‘[]’ may only be used as part of the
251     final component of the target or source, and must be used to describe
252     existing files.  The value ‘{}’ need not necessarily be used to describe
253     existing files.  Expansion is in directory order, not alphabetically as
254     done in the shell.
255

SHELL COMMANDS

257     Each target may have associated with it a series of shell commands, nor‐
258     mally used to create the target.  Each of the commands in this script
259     must be preceded by a tab.  While any target may appear on a dependency
260     line, only one of these dependencies may be followed by a creation
261     script, unless the ‘::’ operator is used.
262
263     If the first characters of the command line are any combination of ‘@’,
264+’, or ‘-’, the command is treated specially.  A ‘@’ causes the command
265     not to be echoed before it is executed.  A ‘+’ causes the command to be
266     executed even when -n is given.  This is similar to the effect of the
267     .MAKE special source, except that the effect can be limited to a single
268     line of a script.  A ‘-’ causes any non-zero exit status of the command
269     line to be ignored.
270

VARIABLE ASSIGNMENTS

272     Variables in make are much like variables in the shell, and, by tradi‐
273     tion, consist of all upper-case letters.
274
275   Variable assignment modifiers
276     The five operators that can be used to assign values to variables are as
277     follows:
278
279     =       Assign the value to the variable.  Any previous value is overrid‐
280             den.
281
282     +=      Append the value to the current value of the variable.
283
284     ?=      Assign the value to the variable if it is not already defined.
285
286     :=      Assign with expansion, i.e. expand the value before assigning it
287             to the variable.  Normally, expansion is not done until the vari‐
288             able is referenced.  NOTE: References to undefined variables are
289             not expanded.  This can cause problems when variable modifiers
290             are used.
291
292     !=      Expand the value and pass it to the shell for execution and
293             assign the result to the variable.  Any newlines in the result
294             are replaced with spaces.
295
296     Any white-space before the assigned value is removed; if the value is
297     being appended, a single space is inserted between the previous contents
298     of the variable and the appended value.
299
300     Variables are expanded by surrounding the variable name with either curly
301     braces (‘{}’) or parentheses (‘()’) and preceding it with a dollar sign
302     (‘$’).  If the variable name contains only a single letter, the surround‐
303     ing braces or parentheses are not required.  This shorter form is not
304     recommended.
305
306     If the variable name contains a dollar, then the name itself is expanded
307     first.  This allows almost arbitrary variable names, however names con‐
308     taining dollar, braces, parenthesis, or whitespace are really best
309     avoided!
310
311     If the result of expanding a variable contains a dollar sign (‘$’) the
312     string is expanded again.
313
314     Variable substitution occurs at two distinct times, depending on where
315     the variable is being used.  Variables in dependency lines are expanded
316     as the line is read.  Variables in shell commands are expanded when the
317     shell command is executed.
318
319   Variable classes
320     The four different classes of variables (in order of increasing prece‐
321     dence) are:
322
323     Environment variables
324             Variables defined as part of bmake's environment.
325
326     Global variables
327             Variables defined in the makefile or in included makefiles.
328
329     Command line variables
330             Variables defined as part of the command line.
331
332     Local variables
333             Variables that are defined specific to a certain target.  The
334             seven local variables are as follows:
335
336             .ALLSRC   The list of all sources for this target; also known as
337>’.
338
339             .ARCHIVE  The name of the archive file.
340
341             .IMPSRC   In suffix-transformation rules, the name/path of the
342                       source from which the target is to be transformed (the
343                       “implied” source); also known as ‘<’.  It is not
344                       defined in explicit rules.
345
346             .MEMBER   The name of the archive member.
347
348             .OODATE   The list of sources for this target that were deemed
349                       out-of-date; also known as ‘?’.
350
351             .PREFIX   The file prefix of the file, containing only the file
352                       portion, no suffix or preceding directory components;
353                       also known as ‘*’.
354
355             .TARGET   The name of the target; also known as ‘@’.
356
357             The shorter forms ‘@’, ‘?’, ‘<’, ‘>’, and ‘*’ are permitted for
358             backward compatibility with historical makefiles and are not rec‐
359             ommended.  The six variables ‘@F’, ‘@D’, ‘<F’, ‘<D’, ‘*F’, and
360*D’ are permitted for compatibility with AT&T System V UNIX
361             makefiles and are not recommended.
362
363             Four of the local variables may be used in sources on dependency
364             lines because they expand to the proper value for each target on
365             the line.  These variables are ‘.TARGET’, ‘.PREFIX’, ‘.ARCHIVE’,
366             and ‘.MEMBER’.
367
368   Additional built-in variables
369     In addition, bmake sets or knows about the following variables:
370
371     $               A single dollar sign ‘$’, i.e.  ‘$$’ expands to a single
372                     dollar sign.
373
374     .ALLTARGETS     The list of all targets encountered in the Makefile.  If
375                     evaluated during Makefile parsing, lists only those tar‐
376                     gets encountered thus far.
377
378     .CURDIR         A path to the directory where bmake was executed.  Refer
379                     to the description of ‘PWD’ for more details.
380
381     MAKE            The name that bmake was executed with (argv[0]).  For
382                     compatibility bmake also sets .MAKE with the same value.
383                     The preferred variable to use is the environment variable
384                     MAKE because it is more compatible with other versions of
385                     bmake and cannot be confused with the special target with
386                     the same name.
387
388     .MAKE.EXPORTED  The list of variables exported by bmake.
389
390     .MAKE.MAKEFILES
391                     The list of makefiles read by bmake, which is useful for
392                     tracking dependencies.  Each makefile is recorded only
393                     once, regardless of the number of times read.
394
395     .MAKE.PID       The process-id of bmake.
396
397     .MAKE.PPID      The parent process-id of bmake.
398
399     .MAKE.JOB.PREFIX
400                     If bmake is run with j then output for each target is
401                     prefixed with a token ‘--- target ---’ the first part of
402                     which can be controlled via .MAKE.JOB.PREFIX.
403                     For example:
404                     .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
405                     would produce tokens like ‘---make[1234] target ---’ mak‐
406                     ing it easier to track the degree of parallelism being
407                     achieved.
408
409     MAKEFLAGS       The environment variable ‘MAKEFLAGS’ may contain anything
410                     that may be specified on bmake's command line.  Anything
411                     specified on bmake's command line is appended to the
412                     ‘MAKEFLAGS’ variable which is then entered into the envi‐
413                     ronment for all programs which bmake executes.
414
415     .MAKEOVERRIDES  This variable is used to record the names of variables
416                     assigned to on the command line, so that they may be
417                     exported as part of ‘MAKEFLAGS’.  This behaviour can be
418                     disabled by assigning an empty value to ‘.MAKEOVERRIDES
419                     within a makefile.  Extra variables can be exported from
420                     a makefile by appending their names to ‘.MAKEOVERRIDES’.
421                     ‘MAKEFLAGS’ is re-exported whenever ‘.MAKEOVERRIDES’ is
422                     modified.
423
424     MAKE_PRINT_VAR_ON_ERROR
425                     When bmake stops due to an error, it prints its name and
426                     the value of ‘.CURDIR’ as well as the value of any vari‐
427                     ables named in ‘MAKE_PRINT_VAR_ON_ERROR’.
428
429     .newline        This variable is simply assigned a newline character as
430                     its value.  This allows expansions using the :@ modifier
431                     to put a newline between iterations of the loop rather
432                     than a space.  For example, the printing of
433MAKE_PRINT_VAR_ON_ERROR’ could be done as
434                     ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
435
436     .OBJDIR         A path to the directory where the targets are built.  Its
437                     value is determined by trying to chdir(2) to the follow‐
438                     ing directories in order and using the first match:
439
440                     1.   ${MAKEOBJDIRPREFIX}${.CURDIR}
441
442                          (Only if ‘MAKEOBJDIRPREFIX’ is set in the environ‐
443                          ment or on the command line.)
444
445                     2.   ${MAKEOBJDIR}
446
447                          (Only if ‘MAKEOBJDIR’ is set in the environment or
448                          on the command line.)
449
450                     3.   ${.CURDIR}/obj.${MACHINE}
451
452                     4.   ${.CURDIR}/obj
453
454                     5.   /usr/obj/${.CURDIR}
455
456                     6.   ${.CURDIR}
457
458                     Variable expansion is performed on the value before it's
459                     used, so expressions such as
460                           ${.CURDIR:C,^/usr/src,/var/obj,}
461                     may be used.
462
463.OBJDIR’ may be modified in the makefile as a global
464                     variable.  In all cases, bmake will chdir(2) to ‘.OBJDIR
465                     and set ‘PWD’ to that directory before executing any tar‐
466                     gets.
467
468     .PARSEDIR       A path to the directory of the current ‘Makefile’ being
469                     parsed.
470
471     .PARSEFILE      The basename of the current ‘Makefile’ being parsed.
472                     This variable and ‘.PARSEDIR’ are both set only while the
473Makefiles’ are being parsed.
474
475     .PATH           A variable that represents the list of directories that
476                     bmake will search for files.  The search list should be
477                     updated using the target ‘.PATH’ rather than the vari‐
478                     able.
479
480     PWD             Alternate path to the current directory.  bmake normally
481                     sets ‘.CURDIR’ to the canonical path given by getcwd(3).
482                     However, if the environment variable ‘PWD’ is set and
483                     gives a path to the current directory, then bmake sets
484.CURDIR’ to the value of ‘PWD’ instead.  This behaviour
485                     is disabled if ‘MAKEOBJDIRPREFIX’ is set or ‘MAKEOBJDIR’
486                     contains a variable transform.  ‘PWD’ is set to the value
487                     of ‘.OBJDIR’ for all programs which bmake executes.
488
489     VPATH           Colon-separated (“:”) lists of directories that bmake
490                     will search for files.  The variable is supported for
491                     compatibility with old make programs only, use ‘.PATH
492                     instead.
493
494   Variable modifiers
495     Variable expansion may be modified to select or modify each word of the
496     variable (where a “word” is white-space delimited sequence of charac‐
497     ters).  The general format of a variable expansion is as follows:
498
499           ${variable[:modifier[:...]]}
500
501     Each modifier begins with a colon, which may be escaped with a backslash
502     (‘\’).
503
504     A set of modifiers can be specified via a variable, as follows:
505
506           modifier_variable=modifier[:...]
507           ${variable:${modifier_variable}[:...]}
508
509     In this case the first modifier in the modifier_variable does not start
510     with a colon, since that must appear in the referencing variable.  If any
511     of the modifiers in the modifier_variable contain a dollar sign (‘$’),
512     these must be doubled to avoid early expansion.
513
514     The supported modifiers are:
515
516     :E   Replaces each word in the variable with its suffix.
517
518     :H   Replaces each word in the variable with everything but the last com‐
519          ponent.
520
521     :Mpattern
522          Select only those words that match pattern.  The standard shell
523          wildcard characters (‘*’, ‘?’, and ‘[]’) may be used.  The wildcard
524          characters may be escaped with a backslash (‘\’).
525
526     :Npattern
527          This is identical to ‘:M’, but selects all words which do not match
528          pattern.
529
530     :O   Order every word in variable alphabetically.  To sort words in
531          reverse order use the ‘:O:[-1..1]’ combination of modifiers.
532
533     :Ox  Randomize words in variable.  The results will be different each
534          time you are referring to the modified variable; use the assignment
535          with expansion (‘:=’) to prevent such behaviour.  For example,
536
537                LIST=                   uno due tre quattro
538                RANDOM_LIST=            ${LIST:Ox}
539                STATIC_RANDOM_LIST:=    ${LIST:Ox}
540
541                all:
542                        @echo "${RANDOM_LIST}"
543                        @echo "${RANDOM_LIST}"
544                        @echo "${STATIC_RANDOM_LIST}"
545                        @echo "${STATIC_RANDOM_LIST}"
546          may produce output similar to:
547
548                quattro due tre uno
549                tre due quattro uno
550                due uno quattro tre
551                due uno quattro tre
552
553     :Q   Quotes every shell meta-character in the variable, so that it can be
554          passed safely through recursive invocations of bmake.
555
556     :R   Replaces each word in the variable with everything but its suffix.
557
558     :tl  Converts variable to lower-case letters.
559
560     :tsc
561          Words in the variable are normally separated by a space on expan‐
562          sion.  This modifier sets the separator to the character c.  If c is
563          omitted, then no separator is used.
564
565     :tu  Converts variable to upper-case letters.
566
567     :tW  Causes the value to be treated as a single word (possibly containing
568          embedded white space).  See also ‘:[*]’.
569
570     :tw  Causes the value to be treated as a sequence of words delimited by
571          white space.  See also ‘:[@]’.
572
573     :S/old_string/new_string/[1gW]
574          Modify the first occurrence of old_string in the variable's value,
575          replacing it with new_string.  If a ‘g’ is appended to the last
576          slash of the pattern, all occurrences in each word are replaced.  If
577          a ‘1’ is appended to the last slash of the pattern, only the first
578          word is affected.  If a ‘W’ is appended to the last slash of the
579          pattern, then the value is treated as a single word (possibly con‐
580          taining embedded white space).  If old_string begins with a caret
581          (‘^’), old_string is anchored at the beginning of each word.  If
582          old_string ends with a dollar sign (‘$’), it is anchored at the end
583          of each word.  Inside new_string, an ampersand (‘&’) is replaced by
584          old_string (without any ‘^’ or ‘$’).  Any character may be used as a
585          delimiter for the parts of the modifier string.  The anchoring,
586          ampersand and delimiter characters may be escaped with a backslash
587          (‘\’).
588
589          Variable expansion occurs in the normal fashion inside both
590          old_string and new_string with the single exception that a backslash
591          is used to prevent the expansion of a dollar sign (‘$’), not a pre‐
592          ceding dollar sign as is usual.
593
594     :C/pattern/replacement/[1gW]
595          The :C modifier is just like the :S modifier except that the old and
596          new strings, instead of being simple strings, are a regular expres‐
597          sion (see regex(3)) string pattern and an ed(1)-style string
598          replacement.  Normally, the first occurrence of the pattern pattern
599          in each word of the value is substituted with replacement.  The ‘1’
600          modifier causes the substitution to apply to at most one word; the
601          ‘g’ modifier causes the substitution to apply to as many instances
602          of the search pattern pattern as occur in the word or words it is
603          found in; the ‘W’ modifier causes the value to be treated as a sin‐
604          gle word (possibly containing embedded white space).  Note that ‘1’
605          and ‘g’ are orthogonal; the former specifies whether multiple words
606          are potentially affected, the latter whether multiple substitutions
607          can potentially occur within each affected word.
608
609     :T   Replaces each word in the variable with its last component.
610
611     :u   Remove adjacent duplicate words (like uniq(1)).
612
613     :?true_string:false_string
614          If the variable name (not its value), when parsed as a .if condi‐
615          tional expression, evaluates to true, return as its value the
616          true_string, otherwise return the false_string.  Since the variable
617          name is used as the expression, :? must be the first modifier after
618          the variable name itself - which will, of course, usually contain
619          variable expansions.  If the expression is a single token, it will
620          likely be treated as a check for the name being defined.
621
622     :old_string=new_string
623          This is the AT&T System V UNIX style variable substitution.  It must
624          be the last modifier specified.  If old_string or new_string do not
625          contain the pattern matching character % then it is assumed that
626          they are anchored at the end of each word, so only suffixes or
627          entire words may be replaced.  Otherwise % is the substring of
628          old_string to be replaced in new_string.
629
630          Variable expansion occurs in the normal fashion inside both
631          old_string and new_string with the single exception that a backslash
632          is used to prevent the expansion of a dollar sign (‘$’), not a pre‐
633          ceding dollar sign as is usual.
634
635     :@temp@string@
636          This is the loop expansion mechanism from the OSF Development Envi‐
637          ronment (ODE) make.  Unlike .for loops expansion occurs at the time
638          of reference.  Assign temp to each word in the variable and evaluate
639          string.  The ODE convention is that temp should start and end with a
640          period.  For example.
641                ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
642
643     :Unewval
644          If the variable is undefined newval is the value.  If the variable
645          is defined, the existing value is returned.  This is another ODE
646          make feature.  It is handy for setting per-target CFLAGS for
647          instance:
648                ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
649          If a value is only required if the variable is undefined, use:
650                ${VAR:D:Unewval}
651
652     :Dnewval
653          If the variable is defined newval is the value.
654
655     :L   The name of the variable is the value.
656
657     :P   The path of the node which has the same name as the variable is the
658          value.  If no such node exists or its path is null, then the name of
659          the variable is used.
660
661     :!cmd!
662          The output of running cmd is the value.
663
664     :sh  If the variable is non-empty it is run as a command and the output
665          becomes the new value.
666
667     ::=str
668          The variable is assigned the value str after substitution.  This
669          modifier and its variations are useful in obscure situations such as
670          wanting to set a variable when shell commands are being parsed.
671          These assignment modifiers always expand to nothing, so if appearing
672          in a rule line by themselves should be preceded with something to
673          keep bmake happy.
674
675          The ‘::’ helps avoid false matches with the AT&T System V UNIX style
676          := modifier and since substitution always occurs the ::= form is
677          vaguely appropriate.
678
679     ::?=str
680          As for ::= but only if the variable does not already have a value.
681
682     ::+=str
683          Append str to the variable.
684
685     ::!=cmd
686          Assign the output of cmd to the variable.
687
688     :[range]
689          Selects one or more words from the value, or performs other opera‐
690          tions related to the way in which the value is divided into words.
691
692          Ordinarily, a value is treated as a sequence of words delimited by
693          white space.  Some modifiers suppress this behaviour, causing a
694          value to be treated as a single word (possibly containing embedded
695          white space).  An empty value, or a value that consists entirely of
696          white-space, is treated as a single word.  For the purposes of the
697:[]’ modifier, the words are indexed both forwards using positive
698          integers (where index 1 represents the first word), and backwards
699          using negative integers (where index -1 represents the last word).
700
701          The range is subjected to variable expansion, and the expanded
702          result is then interpreted as follows:
703
704          index  Selects a single word from the value.
705
706          start..end
707                 Selects all words from start to end, inclusive.  For example,
708:[2..-1]’ selects all words from the second word to the last
709                 word.  If start is greater than end, then the words are out‐
710                 put in reverse order.  For example, ‘:[-1..1]’ selects all
711                 the words from last to first.
712
713          *      Causes subsequent modifiers to treat the value as a single
714                 word (possibly containing embedded white space).  Analogous
715                 to the effect of "$*" in Bourne shell.
716
717          0      Means the same as ‘:[*]’.
718
719          @      Causes subsequent modifiers to treat the value as a sequence
720                 of words delimited by white space.  Analogous to the effect
721                 of "$@" in Bourne shell.
722
723          #      Returns the number of words in the value.
724

INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS

726     Makefile inclusion, conditional structures and for loops  reminiscent of
727     the C programming language are provided in bmake.  All such structures
728     are identified by a line beginning with a single dot (‘.’) character.
729     Files are included with either .include file⟩ or .include "file".  Vari‐
730     ables between the angle brackets or double quotes are expanded to form
731     the file name.  If angle brackets are used, the included makefile is
732     expected to be in the system makefile directory.  If double quotes are
733     used, the including makefile's directory and any directories specified
734     using the -I option are searched before the system makefile directory.
735     For compatibility with other versions of bmake ‘include file ...’ is also
736     accepted.  If the include statement is written as .-include or as
737     .sinclude then errors locating and/or opening include files are ignored.
738
739     Conditional expressions are also preceded by a single dot as the first
740     character of a line.  The possible conditionals are as follows:
741
742     .export variable
743             Export the specified global variable.  If no variable is pro‐
744             vided, all globals are exported except for internal variables
745             (those that start with ‘.’ ).  This is not affected by the -X
746             flag, so should be used with caution.  Appending a variable name
747             to .MAKE.EXPORTED is equivalent to exporting a variable.
748
749     .undef variable
750             Un-define the specified global variable.  Only global variables
751             may be un-defined.
752
753     .if [!]expression [operator expression ...]
754             Test the value of an expression.
755
756     .ifdef [!]variable [operator variable ...]
757             Test the value of a variable.
758
759     .ifndef [!]variable [operator variable ...]
760             Test the value of a variable.
761
762     .ifmake [!]target [operator target ...]
763             Test the target being built.
764
765     .ifnmake [!] target [operator target ...]
766             Test the target being built.
767
768     .else   Reverse the sense of the last conditional.
769
770     .elif [!] expression [operator expression ...]
771             A combination of ‘.else’ followed by ‘.if’.
772
773     .elifdef [!]variable [operator variable ...]
774             A combination of ‘.else’ followed by ‘.ifdef’.
775
776     .elifndef [!]variable [operator variable ...]
777             A combination of ‘.else’ followed by ‘.ifndef’.
778
779     .elifmake [!]target [operator target ...]
780             A combination of ‘.else’ followed by ‘.ifmake’.
781
782     .elifnmake [!]target [operator target ...]
783             A combination of ‘.else’ followed by ‘.ifnmake’.
784
785     .endif  End the body of the conditional.
786
787     The operator may be any one of the following:
788
789     ||     Logical OR.
790
791     &&     Logical AND; of higher precedence than “||”.
792
793     As in C, bmake will only evaluate a conditional as far as is necessary to
794     determine its value.  Parentheses may be used to change the order of
795     evaluation.  The boolean operator ‘!’ may be used to logically negate an
796     entire conditional.  It is of higher precedence than ‘&&’.
797
798     The value of expression may be any of the following:
799
800     defined  Takes a variable name as an argument and evaluates to true if
801              the variable has been defined.
802
803     make     Takes a target name as an argument and evaluates to true if the
804              target was specified as part of bmake's command line or was
805              declared the default target (either implicitly or explicitly,
806              see .MAIN) before the line containing the conditional.
807
808     empty    Takes a variable, with possible modifiers, and evaluates to true
809              if the expansion of the variable would result in an empty
810              string.
811
812     exists   Takes a file name as an argument and evaluates to true if the
813              file exists.  The file is searched for on the system search path
814              (see .PATH).
815
816     target   Takes a target name as an argument and evaluates to true if the
817              target has been defined.
818
819     commands
820              Takes a target name as an argument and evaluates to true if the
821              target has been defined and has commands associated with it.
822
823     Expression may also be an arithmetic or string comparison.  Variable
824     expansion is performed on both sides of the comparison, after which the
825     integral values are compared.  A value is interpreted as hexadecimal if
826     it is preceded by 0x, otherwise it is decimal; octal numbers are not sup‐
827     ported.  The standard C relational operators are all supported.  If after
828     variable expansion, either the left or right hand side of a ‘==’ or ‘!=
829     operator is not an integral value, then string comparison is performed
830     between the expanded variables.  If no relational operator is given, it
831     is assumed that the expanded variable is being compared against 0 or an
832     empty string in the case of a string comparison.
833
834     When bmake is evaluating one of these conditional expressions, and it
835     encounters a (white-space separated) word it doesn't recognize, either
836     the “make” or “defined” expression is applied to it, depending on the
837     form of the conditional.  If the form is ‘.ifdef’, ‘.ifndef’, or ‘.if
838     the “defined” expression is applied.  Similarly, if the form is ‘.ifmake
839     or ‘.ifnmake, the’ “make” expression is applied.
840
841     If the conditional evaluates to true the parsing of the makefile contin‐
842     ues as before.  If it evaluates to false, the following lines are
843     skipped.  In both cases this continues until a ‘.else’ or ‘.endif’ is
844     found.
845
846     For loops are typically used to apply a set of rules to a list of files.
847     The syntax of a for loop is:
848
849     .for variable [variable ...] in expression
850     ⟨make-rules⟩
851     .endfor
852
853     After the for expression is evaluated, it is split into words.  On each
854     iteration of the loop, one word is taken and assigned to each variable,
855     in order, and these variables are substituted into the make-rules inside
856     the body of the for loop.  The number of words must come out even; that
857     is, if there are three iteration variables, the number of words provided
858     must be a multiple of three.
859

COMMENTS

861     Comments begin with a hash (‘#’) character, anywhere but in a shell com‐
862     mand line, and continue to the end of an unescaped new line.
863

SPECIAL SOURCES (ATTRIBUTES)

865     .EXEC     Target is never out of date, but always execute commands any‐
866               way.
867
868     .IGNORE   Ignore any errors from the commands associated with this tar‐
869               get, exactly as if they all were preceded by a dash (‘-’).
870
871     .MADE     Mark all sources of this target as being up-to-date.
872
873     .MAKE     Execute the commands associated with this target even if the -n
874               or -t options were specified.  Normally used to mark recursive
875               bmake's.
876
877     .NOPATH   Do not search for the target in the directories specified by
878               .PATH.
879
880     .NOTMAIN  Normally bmake selects the first target it encounters as the
881               default target to be built if no target was specified.  This
882               source prevents this target from being selected.
883
884     .OPTIONAL
885               If a target is marked with this attribute and bmake can't fig‐
886               ure out how to create it, it will ignore this fact and assume
887               the file isn't needed or already exists.
888
889     .PHONY    The target does not correspond to an actual file; it is always
890               considered to be out of date, and will not be created with the
891               -t option.
892
893     .PRECIOUS
894               When bmake is interrupted, it normally removes any partially
895               made targets.  This source prevents the target from being
896               removed.
897
898     .RECURSIVE
899               Synonym for .MAKE.
900
901     .SILENT   Do not echo any of the commands associated with this target,
902               exactly as if they all were preceded by an at sign (‘@’).
903
904     .USE      Turn the target into bmake's version of a macro.  When the tar‐
905               get is used as a source for another target, the other target
906               acquires the commands, sources, and attributes (except for
907               .USE) of the source.  If the target already has commands, the
908               .USE target's commands are appended to them.
909
910     .USEBEFORE
911               Exactly like .USE, but prepend the .USEBEFORE target commands
912               to the target.
913
914     .WAIT     If .WAIT appears in a dependency line, the sources that precede
915               it are made before the sources that succeed it in the line.
916               Since the dependents of files are not made until the file
917               itself could be made, this also stops the dependents being
918               built unless they are needed for another branch of the depen‐
919               dency tree.  So given:
920
921               x: a .WAIT b
922                       echo x
923               a:
924                       echo a
925               b: b1
926                       echo b
927               b1:
928                       echo b1
929
930               the output is always ‘a’, ‘b1’, ‘b’, ‘x’.
931               The ordering imposed by .WAIT is only relevant for parallel
932               makes.
933

SPECIAL TARGETS

935     Special targets may not be included with other targets, i.e. they must be
936     the only target specified.
937
938     .BEGIN   Any command lines attached to this target are executed before
939              anything else is done.
940
941     .DEFAULT
942              This is sort of a .USE rule for any target (that was used only
943              as a source) that bmake can't figure out any other way to cre‐
944              ate.  Only the shell script is used.  The .IMPSRC variable of a
945              target that inherits .DEFAULT's commands is set to the target's
946              own name.
947
948     .END     Any command lines attached to this target are executed after
949              everything else is done.
950
951     .IGNORE  Mark each of the sources with the .IGNORE attribute.  If no
952              sources are specified, this is the equivalent of specifying the
953              -i option.
954
955     .INTERRUPT
956              If bmake is interrupted, the commands for this target will be
957              executed.
958
959     .MAIN    If no target is specified when bmake is invoked, this target
960              will be built.
961
962     .MAKEFLAGS
963              This target provides a way to specify flags for bmake when the
964              makefile is used.  The flags are as if typed to the shell,
965              though the -f option will have no effect.
966
967     .NOPATH  Apply the .NOPATH attribute to any specified sources.
968
969     .NOTPARALLEL
970              Disable parallel mode.
971
972     .NO_PARALLEL
973              Synonym for .NOTPARALLEL, for compatibility with other pmake
974              variants.
975
976     .ORDER   The named targets are made in sequence.  This ordering does not
977              add targets to the list of targets to be made.  Since the depen‐
978              dents of a target do not get built until the target itself could
979              be built, unless ‘a’ is built by another part of the dependency
980              graph, the following is a dependency loop:
981
982              .ORDER a b
983              b: a
984
985              The ordering imposed by .ORDER is only relevant for parallel
986              makes.
987
988     .PATH    The sources are directories which are to be searched for files
989              not found in the current directory.  If no sources are speci‐
990              fied, any previously specified directories are deleted.  If the
991              source is the special .DOTLAST target, then the current working
992              directory is searched last.
993
994     .PHONY   Apply the .PHONY attribute to any specified sources.
995
996     .PRECIOUS
997              Apply the .PRECIOUS attribute to any specified sources.  If no
998              sources are specified, the .PRECIOUS attribute is applied to
999              every target in the file.
1000
1001     .SHELL   Sets the shell that bmake will use to execute commands.  The
1002              sources are a set of field=value pairs.
1003
1004              name        This is the minimal specification, used to select
1005                          one of the builtin shell specs; sh, ksh, and csh.
1006
1007              path        Specifies the path to the shell.
1008
1009              hasErrCtl   Indicates whether the shell supports exit on error.
1010
1011              check       The command to turn on error checking.
1012
1013              ignore      The command to disable error checking.
1014
1015              echo        The command to turn on echoing of commands executed.
1016
1017              quiet       The command to turn off echoing of commands exe‐
1018                          cuted.
1019
1020              filter      The output to filter after issuing the quiet com‐
1021                          mand.  It is typically identical to quiet.
1022
1023              errFlag     The flag to pass the shell to enable error checking.
1024
1025              echoFlag    The flag to pass the shell to enable command echo‐
1026                          ing.
1027
1028              newline     The string literal to pass the shell that results in
1029                          a single newline character when used outside of any
1030                          quoting characters.
1031              Example:
1032
1033              .SHELL: name=ksh path=/bin/ksh hasErrCtl=true \
1034                      check="set -e" ignore="set +e" \
1035                      echo="set -v" quiet="set +v" filter="set +v" \
1036                      echoFlag=v errFlag=e newline="'\n'"
1037
1038     .SILENT  Apply the .SILENT attribute to any specified sources.  If no
1039              sources are specified, the .SILENT attribute is applied to every
1040              command in the file.
1041
1042     .SUFFIXES
1043              Each source specifies a suffix to bmake.  If no sources are
1044              specified, any previously specified suffixes are deleted.  It
1045              allows the creation of suffix-transformation rules.
1046
1047              Example:
1048
1049              .SUFFIXES: .o
1050              .c.o:
1051                      cc -o ${.TARGET} -c ${.IMPSRC}
1052

ENVIRONMENT

1054     bmake uses the following environment variables, if they exist: MACHINE,
1055     MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX, MAKESYSPATH,
1056     and PWD.
1057
1058     MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on
1059     the command line to bmake and not as makefile variables; see the descrip‐
1060     tion of ‘.OBJDIR’ for more details.
1061

FILES

1063     .depend        list of dependencies
1064     Makefile       list of dependencies
1065     makefile       list of dependencies
1066     sys.mk         system makefile
1067     /usr/share/mk  system makefile directory
1068

COMPATIBILITY

1070     The basic make syntax is compatible between different versions of make,
1071     however the special variables, variable modifiers and conditionals are
1072     not.
1073
1074     The way that parallel makes are scheduled changed in NetBSD 4.0 so that
1075     .ORDER and .WAIT apply recursively to the dependant nodes.  The algo‐
1076     rithms used may change again in the future.
1077
1078     The way that .for loop variables are substituted changed after NetBSD 5.0
1079     so that they still appear to be variable expansions.  In particular this
1080     stops them being treated as syntax, and removes some obscure problems
1081     using them in .if statements.
1082

SEE ALSO

1084     mkdep(1)
1085

HISTORY

1087     bmake is derived from NetBSD's make(1).  It uses autoconf to facilitate
1088     portability to other platforms.
1089
1090BSD                            January 24, 2009                            BSD
Impressum