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

NAME

4     make — maintain program dependencies
5

SYNOPSIS

7     make [-BeikNnqrstWwX] [-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

DESCRIPTION

13     make is a program designed to simplify the maintenance of other programs.
14     Its input is a list of specifications as to the files upon which programs
15     and other files depend.  If no -f makefile makefile option is given, make
16     will try to open ‘makefile’ then ‘Makefile’ in order to find the specifi‐
17     cations.  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 make and makefiles, please refer to PMake - A
21     Tutorial.
22
23     make 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     -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 context.
40
41     -d [-]flags
42             Turn on debugging, and specify which portions of make are to
43             print debugging information.  Unless the flags are preceded by
44             ‘-’ they are added to the MAKEFLAGS environment variable and will
45             be processed by any child make processes.  By default, debugging
46             information is printed to standard error, but this can be changed
47             using the F debugging flag.  The debugging output is always
48             unbuffered; in addition, if debugging is enabled but debugging
49             output is not directed to standard output, then the standard out‐
50             put is line buffered.  Flags is one or more of the following:
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 current working direc‐
59                     tory.
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’
73                     flag is ‘+’, then the file will be opened in append mode;
74                     otherwise the file will be overwritten.  If the file name
75                     is ‘stdout’ or ‘stderr’ then debugging output will be
76                     written to the standard output or standard error output
77                     file descriptors respectively (and the ‘+’ option has no
78                     effect).  Otherwise, the output will be written to the
79                     named file.  If the file name ends ‘.%d’ then the ‘%d’ is
80                     replaced by the pid.
81
82             f       Print debugging information about loop evaluation.
83
84             g1      Print the input graph before making anything.
85
86             g2      Print the input graph after making everything, or before
87                     exiting on error.
88
89             g3      Print the input graph before exiting on error.
90
91             j       Print debugging information about running multiple
92                     shells.
93
94             l       Print commands in Makefiles regardless of whether or not
95                     they are prefixed by ‘@’ or other "quiet" flags.  Also
96                     known as "loud" behavior.
97
98             M       Print debugging information about "meta" mode decisions
99                     about targets.
100
101             m       Print debugging information about making targets, includ‐
102                     ing modification dates.
103
104             n       Don't delete the temporary command scripts created when
105                     running commands.  These temporary scripts are created in
106                     the directory referred to by the TMPDIR environment vari‐
107                     able, or in /tmp if TMPDIR is unset or set to the empty
108                     string.  The temporary scripts are created by mkstemp(3),
109                     and have names of the form makeXXXXXX.  NOTE: This can
110                     create many files in TMPDIR or /tmp, so use with care.
111
112             p       Print debugging information about makefile parsing.
113
114             s       Print debugging information about suffix-transformation
115                     rules.
116
117             t       Print debugging information about target list mainte‐
118                     nance.
119
120             V       Force the -V option to print raw values of variables,
121                     overriding the default behavior set via
122                     .MAKE.EXPAND_VARIABLES.
123
124             v       Print debugging information about variable assignment.
125
126             x       Run shell commands with -x so the actual commands are
127                     printed as they are executed.
128
129     -e      Specify that environment variables override macro assignments
130             within makefiles.
131
132     -f makefile
133             Specify a makefile to read instead of the default ‘makefile’.  If
134             makefile is ‘-’, standard input is read.  Multiple makefiles may
135             be specified, and are read in the order specified.
136
137     -I directory
138             Specify a directory in which to search for makefiles and included
139             makefiles.  The system makefile directory (or directories, see
140             the -m option) is automatically included as part of this list.
141
142     -i      Ignore non-zero exit of shell commands in the makefile.  Equiva‐
143             lent to specifying ‘-’ before each command line in the makefile.
144
145     -J private
146             This option should not be specified by the user.
147
148             When the j option is in use in a recursive build, this option is
149             passed by a make to child makes to allow all the make processes
150             in the build to cooperate to avoid overloading the system.
151
152     -j max_jobs
153             Specify the maximum number of jobs that make may have running at
154             any one time.  The value is saved in .MAKE.JOBS.  Turns compati‐
155             bility mode off, unless the B flag is also specified.  When com‐
156             patibility mode is off, all commands associated with a target are
157             executed in a single shell invocation as opposed to the tradi‐
158             tional one shell invocation per line.  This can break traditional
159             scripts which change directories on each command invocation and
160             then expect to start with a fresh environment on the next line.
161             It is more efficient to correct the scripts rather than turn
162             backwards compatibility on.
163
164     -k      Continue processing after errors are encountered, but only on
165             those targets that do not depend on the target whose creation
166             caused the error.
167
168     -m directory
169             Specify a directory in which to search for sys.mk and makefiles
170             included via the ⟨file⟩-style include statement.  The -m option
171             can be used multiple times to form a search path.  This path will
172             override the default system include path: /usr/share/mk.  Fur‐
173             thermore the system include path will be appended to the search
174             path used for "file"-style include statements (see the -I
175             option).
176
177             If a file or directory name in the -m argument (or the
178             MAKESYSPATH environment variable) starts with the string ".../"
179             then make will search for the specified file or directory named
180             in the remaining part of the argument string.  The search starts
181             with the current directory of the Makefile and then works upward
182             towards the root of the file system.  If the search is success‐
183             ful, then the resulting directory replaces the ".../" specifica‐
184             tion in the -m argument.  If used, this feature allows make to
185             easily search in the current source tree for customized sys.mk
186             files (e.g., by using ".../mk/sys.mk" as an argument).
187
188     -n      Display the commands that would have been executed, but do not
189             actually execute them unless the target depends on the .MAKE spe‐
190             cial source (see below).
191
192     -N      Display the commands which would have been executed, but do not
193             actually execute any of them; useful for debugging top-level
194             makefiles without descending into subdirectories.
195
196     -q      Do not execute any commands, but exit 0 if the specified targets
197             are up-to-date and 1, otherwise.
198
199     -r      Do not use the built-in rules specified in the system makefile.
200
201     -s      Do not echo any commands as they are executed.  Equivalent to
202             specifying ‘@’ before each command line in the makefile.
203
204     -T tracefile
205             When used with the -j flag, append a trace record to tracefile
206             for each job started and completed.
207
208     -t      Rather than re-building a target as specified in the makefile,
209             create it or update its modification time to make it appear up-
210             to-date.
211
212     -V variable
213             Print the value of variable.  Do not build any targets.  Multiple
214             instances of this option may be specified; the variables will be
215             printed one per line, with a blank line for each null or unde‐
216             fined variable.  The value printed is extracted from the global
217             context after all makefiles have been read.  By default, the raw
218             variable contents (which may include additional unexpanded vari‐
219             able references) are shown.  If variable contains a ‘$’ then the
220             value will be recursively expanded to its complete resultant text
221             before printing.  The expanded value will also be printed if
222             .MAKE.EXPAND_VARIABLES is set to true and the -dV option has not
223             been used to override it.  Note that loop-local and target-local
224             variables, as well as values taken temporarily by global vari‐
225             ables during makefile processing, are not accessible via this
226             option.  The -dv debug mode can be used to see these at the cost
227             of generating substantial extraneous output.
228
229     -v variable
230             Like -V but the variable is always expanded to its complete
231             value.
232
233     -W      Treat any warnings during makefile parsing as errors.
234
235     -w      Print entering and leaving directory messages, pre and post pro‐
236             cessing.
237
238     -X      Don't export variables passed on the command line to the environ‐
239             ment individually.  Variables passed on the command line are
240             still exported via the MAKEFLAGS environment variable.  This
241             option may be useful on systems which have a small limit on the
242             size of command arguments.
243
244     variable=value
245             Set the value of the variable variable to value.  Normally, all
246             values passed on the command line are also exported to sub-makes
247             in the environment.  The -X flag disables this behavior.  Vari‐
248             able assignments should follow options for POSIX compatibility
249             but no ordering is enforced.
250
251     There are seven different types of lines in a makefile: file dependency
252     specifications, shell commands, variable assignments, include statements,
253     conditional directives, for loops, and comments.
254
255     In general, lines may be continued from one line to the next by ending
256     them with a backslash (‘\’).  The trailing newline character and initial
257     whitespace on the following line are compressed into a single space.
258

FILE DEPENDENCY SPECIFICATIONS

260     Dependency lines consist of one or more targets, an operator, and zero or
261     more sources.  This creates a relationship where the targets “depend” on
262     the sources and are usually created from them.  The exact relationship
263     between the target and the source is determined by the operator that sep‐
264     arates them.  The three operators are as follows:
265
266     :     A target is considered out-of-date if its modification time is less
267           than those of any of its sources.  Sources for a target accumulate
268           over dependency lines when this operator is used.  The target is
269           removed if make is interrupted.
270
271     !     Targets are always re-created, but not until all sources have been
272           examined and re-created as necessary.  Sources for a target accumu‐
273           late over dependency lines when this operator is used.  The target
274           is removed if make is interrupted.
275
276     ::    If no sources are specified, the target is always re-created.  Oth‐
277           erwise, a target is considered out-of-date if any of its sources
278           has been modified more recently than the target.  Sources for a
279           target do not accumulate over dependency lines when this operator
280           is used.  The target will not be removed if make is interrupted.
281
282     Targets and sources may contain the shell wildcard values ‘?’, ‘*’, ‘[]’,
283     and ‘{}’.  The values ‘?’, ‘*’, and ‘[]’ may only be used as part of the
284     final component of the target or source, and must be used to describe
285     existing files.  The value ‘{}’ need not necessarily be used to describe
286     existing files.  Expansion is in directory order, not alphabetically as
287     done in the shell.
288

SHELL COMMANDS

290     Each target may have associated with it one or more lines of shell com‐
291     mands, normally used to create the target.  Each of the lines in this
292     script must be preceded by a tab.  (For historical reasons, spaces are
293     not accepted.)  While targets can appear in many dependency lines if
294     desired, by default only one of these rules may be followed by a creation
295     script.  If the ‘::’ operator is used, however, all rules may include
296     scripts and the scripts are executed in the order found.
297
298     Each line is treated as a separate shell command, unless the end of line
299     is escaped with a backslash (‘\’) in which case that line and the next
300     are combined.  If the first characters of the command are any combination
301     of ‘@’, ‘+’, or ‘-’, the command is treated specially.  A ‘@’ causes the
302     command not to be echoed before it is executed.  A ‘+’ causes the command
303     to be executed even when -n is given.  This is similar to the effect of
304     the .MAKE special source, except that the effect can be limited to a sin‐
305     gle line of a script.  A ‘-’ in compatibility mode causes any non-zero
306     exit status of the command line to be ignored.
307
308     When make is run in jobs mode with -j max_jobs, the entire script for the
309     target is fed to a single instance of the shell.  In compatibility (non-
310     jobs) mode, each command is run in a separate process.  If the command
311     contains any shell meta characters (‘#=|^(){};&<>*?[]:$`\\n’) it will be
312     passed to the shell; otherwise make will attempt direct execution.  If a
313     line starts with ‘-’ and the shell has ErrCtl enabled then failure of the
314     command line will be ignored as in compatibility mode.  Otherwise ‘-
315     affects the entire job; the script will stop at the first command line
316     that fails, but the target will not be deemed to have failed.
317
318     Makefiles should be written so that the mode of make operation does not
319     change their behavior.  For example, any command which needs to use “cd”
320     or “chdir” without potentially changing the directory for subsequent com‐
321     mands should be put in parentheses so it executes in a subshell.  To
322     force the use of one shell, escape the line breaks so as to make the
323     whole script one command.  For example:
324
325           avoid-chdir-side-effects:
326                   @echo Building $@ in `pwd`
327                   @(cd ${.CURDIR} && ${MAKE} $@)
328                   @echo Back in `pwd`
329
330           ensure-one-shell-regardless-of-mode:
331                   @echo Building $@ in `pwd`; \
332                   (cd ${.CURDIR} && ${MAKE} $@); \
333                   echo Back in `pwd`
334
335     Since make will chdir(2) to ‘.OBJDIR’ before executing any targets, each
336     child process starts with that as its current working directory.
337

VARIABLE ASSIGNMENTS

339     Variables in make are much like variables in the shell, and, by tradi‐
340     tion, consist of all upper-case letters.
341
342   Variable assignment modifiers
343     The five operators that can be used to assign values to variables are as
344     follows:
345
346     =       Assign the value to the variable.  Any previous value is overrid‐
347             den.
348
349     +=      Append the value to the current value of the variable.
350
351     ?=      Assign the value to the variable if it is not already defined.
352
353     :=      Assign with expansion, i.e. expand the value before assigning it
354             to the variable.  Normally, expansion is not done until the vari‐
355             able is referenced.  NOTE: References to undefined variables are
356             not expanded.  This can cause problems when variable modifiers
357             are used.
358
359     !=      Expand the value and pass it to the shell for execution and
360             assign the result to the variable.  Any newlines in the result
361             are replaced with spaces.
362
363     Any white-space before the assigned value is removed; if the value is
364     being appended, a single space is inserted between the previous contents
365     of the variable and the appended value.
366
367     Variables are expanded by surrounding the variable name with either curly
368     braces (‘{}’) or parentheses (‘()’) and preceding it with a dollar sign
369     (‘$’).  If the variable name contains only a single letter, the surround‐
370     ing braces or parentheses are not required.  This shorter form is not
371     recommended.
372
373     If the variable name contains a dollar, then the name itself is expanded
374     first.  This allows almost arbitrary variable names, however names con‐
375     taining dollar, braces, parenthesis, or whitespace are really best
376     avoided!
377
378     If the result of expanding a variable contains a dollar sign (‘$’) the
379     string is expanded again.
380
381     Variable substitution occurs at three distinct times, depending on where
382     the variable is being used.
383
384     1.   Variables in dependency lines are expanded as the line is read.
385
386     2.   Variables in shell commands are expanded when the shell command is
387          executed.
388
389     3.   “.for” loop index variables are expanded on each loop iteration.
390          Note that other variables are not expanded inside loops so the fol‐
391          lowing example code:
392
393
394                .for i in 1 2 3
395                a+=     ${i}
396                j=      ${i}
397                b+=     ${j}
398                .endfor
399
400                all:
401                        @echo ${a}
402                        @echo ${b}
403
404          will print:
405
406                1 2 3
407                3 3 3
408
409          Because while ${a} contains “1 2 3” after the loop is executed, ${b}
410          contains “${j} ${j} ${j}” which expands to “3 3 3” since after the
411          loop completes ${j} contains “3”.
412
413   Variable classes
414     The four different classes of variables (in order of increasing prece‐
415     dence) are:
416
417     Environment variables
418             Variables defined as part of make's environment.
419
420     Global variables
421             Variables defined in the makefile or in included makefiles.
422
423     Command line variables
424             Variables defined as part of the command line.
425
426     Local variables
427             Variables that are defined specific to a certain target.
428
429     Local variables are all built in and their values vary magically from
430     target to target.  It is not currently possible to define new local vari‐
431     ables.  The seven local variables are as follows:
432
433           .ALLSRC   The list of all sources for this target; also known as
434>’.
435
436           .ARCHIVE  The name of the archive file; also known as ‘!’.
437
438           .IMPSRC   In suffix-transformation rules, the name/path of the
439                     source from which the target is to be transformed (the
440                     “implied” source); also known as ‘<’.  It is not defined
441                     in explicit rules.
442
443           .MEMBER   The name of the archive member; also known as ‘%’.
444
445           .OODATE   The list of sources for this target that were deemed out-
446                     of-date; also known as ‘?’.
447
448           .PREFIX   The file prefix of the target, containing only the file
449                     portion, no suffix or preceding directory components;
450                     also known as ‘*’.  The suffix must be one of the known
451                     suffixes declared with .SUFFIXES or it will not be recog‐
452                     nized.
453
454           .TARGET   The name of the target; also known as ‘@’.  For compati‐
455                     bility with other makes this is an alias for .ARCHIVE in
456                     archive member rules.
457
458     The shorter forms (‘>’, ‘!’, ‘<’, ‘%’, ‘?’, ‘*’, and ‘@’) are permitted
459     for backward compatibility with historical makefiles and legacy POSIX
460     make and are not recommended.
461
462     Variants of these variables with the punctuation followed immediately by
463     ‘D’ or ‘F’, e.g.  ‘$(@D)’, are legacy forms equivalent to using the ‘:H’
464     and ‘:T’ modifiers.  These forms are accepted for compatibility with AT&T
465     System V UNIX makefiles and POSIX but are not recommended.
466
467     Four of the local variables may be used in sources on dependency lines
468     because they expand to the proper value for each target on the line.
469     These variables are ‘.TARGET’, ‘.PREFIX’, ‘.ARCHIVE’, and ‘.MEMBER’.
470
471   Additional built-in variables
472     In addition, make sets or knows about the following variables:
473
474     $               A single dollar sign ‘$’, i.e.  ‘$$’ expands to a single
475                     dollar sign.
476
477     .ALLTARGETS     The list of all targets encountered in the Makefile.  If
478                     evaluated during Makefile parsing, lists only those tar‐
479                     gets encountered thus far.
480
481     .CURDIR         A path to the directory where make was executed.  Refer
482                     to the description of ‘PWD’ for more details.
483
484     .INCLUDEDFROMDIR
485                     The directory of the file this Makefile was included
486                     from.
487
488     .INCLUDEDFROMFILE
489                     The filename of the file this Makefile was included from.
490
491     MAKE            The name that make was executed with (argv[0]).  For com‐
492                     patibility make also sets .MAKE with the same value.  The
493                     preferred variable to use is the environment variable
494                     MAKE because it is more compatible with other versions of
495                     make and cannot be confused with the special target with
496                     the same name.
497
498     .MAKE.DEPENDFILE
499                     Names the makefile (default ‘.depend’) from which gener‐
500                     ated dependencies are read.
501
502     .MAKE.EXPAND_VARIABLES
503                     A boolean that controls the default behavior of the -V
504                     option.  If true, variable values printed with -V are
505                     fully expanded; if false, the raw variable contents
506                     (which may include additional unexpanded variable refer‐
507                     ences) are shown.
508
509     .MAKE.EXPORTED  The list of variables exported by make.
510
511     .MAKE.JOBS      The argument to the -j option.
512
513     .MAKE.JOB.PREFIX
514                     If make is run with j then output for each target is pre‐
515                     fixed with a token ‘--- target ---’ the first part of
516                     which can be controlled via .MAKE.JOB.PREFIX.  If
517                     .MAKE.JOB.PREFIX is empty, no token is printed.
518                     For example:
519                     .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
520                     would produce tokens like ‘---make[1234] target ---’ mak‐
521                     ing it easier to track the degree of parallelism being
522                     achieved.
523
524     MAKEFLAGS       The environment variable ‘MAKEFLAGS’ may contain anything
525                     that may be specified on make's command line.  Anything
526                     specified on make's command line is appended to the
527                     ‘MAKEFLAGS’ variable which is then entered into the envi‐
528                     ronment for all programs which make executes.
529
530     .MAKE.LEVEL     The recursion depth of make.  The initial instance of
531                     make will be 0, and an incremented value is put into the
532                     environment to be seen by the next generation.  This
533                     allows tests like: .if ${.MAKE.LEVEL} == 0 to protect
534                     things which should only be evaluated in the initial
535                     instance of make.
536
537     .MAKE.MAKEFILE_PREFERENCE
538                     The ordered list of makefile names (default ‘makefile’,
539Makefile’) that make will look for.
540
541     .MAKE.MAKEFILES
542                     The list of makefiles read by make, which is useful for
543                     tracking dependencies.  Each makefile is recorded only
544                     once, regardless of the number of times read.
545
546     .MAKE.MODE      Processed after reading all makefiles.  Can affect the
547                     mode that make runs in.  It can contain a number of key‐
548                     words:
549
550                     compat               Like -B, puts make into "compat"
551                                          mode.
552
553                     meta                 Puts make into "meta" mode, where
554                                          meta files are created for each tar‐
555                                          get to capture the command run, the
556                                          output generated and if filemon(4)
557                                          is available, the system calls which
558                                          are of interest to make.  The cap‐
559                                          tured output can be very useful when
560                                          diagnosing errors.
561
562                     curdirOk= bf         Normally make will not create .meta
563                                          files in ‘.CURDIR’.  This can be
564                                          overridden by setting bf to a value
565                                          which represents True.
566
567                     missing-meta= bf     If bf is True, then a missing .meta
568                                          file makes the target out-of-date.
569
570                     missing-filemon= bf  If bf is True, then missing filemon
571                                          data makes the target out-of-date.
572
573                     nofilemon            Do not use filemon(4).
574
575                     env                  For debugging, it can be useful to
576                                          include the environment in the .meta
577                                          file.
578
579                     verbose              If in "meta" mode, print a clue
580                                          about the target being built.  This
581                                          is useful if the build is otherwise
582                                          running silently.  The message
583                                          printed the value of:
584                                          .MAKE.META.PREFIX.
585
586                     ignore-cmd           Some makefiles have commands which
587                                          are simply not stable.  This keyword
588                                          causes them to be ignored for deter‐
589                                          mining whether a target is out of
590                                          date in "meta" mode.  See also
591                                          .NOMETA_CMP.
592
593                     silent= bf           If bf is True, when a .meta file is
594                                          created, mark the target .SILENT.
595
596     .MAKE.META.BAILIWICK
597                     In "meta" mode, provides a list of prefixes which match
598                     the directories controlled by make.  If a file that was
599                     generated outside of .OBJDIR but within said bailiwick is
600                     missing, the current target is considered out-of-date.
601
602     .MAKE.META.CREATED
603                     In "meta" mode, this variable contains a list of all the
604                     meta files updated.  If not empty, it can be used to
605                     trigger processing of .MAKE.META.FILES.
606
607     .MAKE.META.FILES
608                     In "meta" mode, this variable contains a list of all the
609                     meta files used (updated or not).  This list can be used
610                     to process the meta files to extract dependency informa‐
611                     tion.
612
613     .MAKE.META.IGNORE_PATHS
614                     Provides a list of path prefixes that should be ignored;
615                     because the contents are expected to change over time.
616                     The default list includes: ‘/dev /etc /proc /tmp /var/run
617                     /var/tmp
618
619     .MAKE.META.IGNORE_PATTERNS
620                     Provides a list of patterns to match against pathnames.
621                     Ignore any that match.
622
623     .MAKE.META.IGNORE_FILTER
624                     Provides a list of variable modifiers to apply to each
625                     pathname.  Ignore if the expansion is an empty string.
626
627     .MAKE.META.PREFIX
628                     Defines the message printed for each meta file updated in
629                     "meta verbose" mode.  The default value is:
630                           Building ${.TARGET:H:tA}/${.TARGET:T}
631
632     .MAKEOVERRIDES  This variable is used to record the names of variables
633                     assigned to on the command line, so that they may be
634                     exported as part of ‘MAKEFLAGS’.  This behavior can be
635                     disabled by assigning an empty value to ‘.MAKEOVERRIDES
636                     within a makefile.  Extra variables can be exported from
637                     a makefile by appending their names to ‘.MAKEOVERRIDES’.
638                     ‘MAKEFLAGS’ is re-exported whenever ‘.MAKEOVERRIDES’ is
639                     modified.
640
641     .MAKE.PATH_FILEMON
642                     If make was built with filemon(4) support, this is set to
643                     the path of the device node.  This allows makefiles to
644                     test for this support.
645
646     .MAKE.PID       The process-id of make.
647
648     .MAKE.PPID      The parent process-id of make.
649
650     .MAKE.SAVE_DOLLARS
651                     value should be a boolean that controls whether ‘$$’ are
652                     preserved when doing ‘:=’ assignments.  The default is
653                     false, for backwards compatibility.  Set to true for com‐
654                     patability with other makes.  If set to false, ‘$$’
655                     becomes ‘$’ per normal evaluation rules.
656
657     MAKE_PRINT_VAR_ON_ERROR
658                     When make stops due to an error, it sets ‘.ERROR_TARGET
659                     to the name of the target that failed, ‘.ERROR_CMD’ to
660                     the commands of the failed target, and in "meta" mode, it
661                     also sets ‘.ERROR_CWD’ to the getcwd(3), and
662.ERROR_META_FILE’ to the path of the meta file (if any)
663                     describing the failed target.  It then prints its name
664                     and the value of ‘.CURDIR’ as well as the value of any
665                     variables named in ‘MAKE_PRINT_VAR_ON_ERROR’.
666
667     .newline        This variable is simply assigned a newline character as
668                     its value.  This allows expansions using the :@ modifier
669                     to put a newline between iterations of the loop rather
670                     than a space.  For example, the printing of
671MAKE_PRINT_VAR_ON_ERROR’ could be done as
672                     ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
673
674     .OBJDIR         A path to the directory where the targets are built.  Its
675                     value is determined by trying to chdir(2) to the follow‐
676                     ing directories in order and using the first match:
677
678                     1.   ${MAKEOBJDIRPREFIX}${.CURDIR}
679
680                          (Only if ‘MAKEOBJDIRPREFIX’ is set in the environ‐
681                          ment or on the command line.)
682
683                     2.   ${MAKEOBJDIR}
684
685                          (Only if ‘MAKEOBJDIR’ is set in the environment or
686                          on the command line.)
687
688                     3.   ${.CURDIR}/obj.${MACHINE}
689
690                     4.   ${.CURDIR}/obj
691
692                     5.   /usr/obj/${.CURDIR}
693
694                     6.   ${.CURDIR}
695
696                     Variable expansion is performed on the value before it's
697                     used, so expressions such as
698                           ${.CURDIR:S,^/usr/src,/var/obj,}
699                     may be used.  This is especially useful with
700                     ‘MAKEOBJDIR’.
701
702.OBJDIR’ may be modified in the makefile via the special
703                     target ‘.OBJDIR’.  In all cases, make will chdir(2) to
704                     the specified directory if it exists, and set ‘.OBJDIR
705                     and ‘PWD’ to that directory before executing any targets.
706
707     .PARSEDIR       A path to the directory of the current ‘Makefile’ being
708                     parsed.
709
710     .PARSEFILE      The basename of the current ‘Makefile’ being parsed.
711                     This variable and ‘.PARSEDIR’ are both set only while the
712Makefiles’ are being parsed.  If you want to retain
713                     their current values, assign them to a variable using
714                     assignment with expansion: (‘:=’).
715
716     .PATH           A variable that represents the list of directories that
717                     make will search for files.  The search list should be
718                     updated using the target ‘.PATH’ rather than the vari‐
719                     able.
720
721     PWD             Alternate path to the current directory.  make normally
722                     sets ‘.CURDIR’ to the canonical path given by getcwd(3).
723                     However, if the environment variable ‘PWD’ is set and
724                     gives a path to the current directory, then make sets
725.CURDIR’ to the value of ‘PWD’ instead.  This behavior
726                     is disabled if ‘MAKEOBJDIRPREFIX’ is set or ‘MAKEOBJDIR’
727                     contains a variable transform.  ‘PWD’ is set to the value
728                     of ‘.OBJDIR’ for all programs which make executes.
729
730     .TARGETS        The list of targets explicitly specified on the command
731                     line, if any.
732
733     VPATH           Colon-separated (“:”) lists of directories that make will
734                     search for files.  The variable is supported for compati‐
735                     bility with old make programs only, use ‘.PATH’ instead.
736
737   Variable modifiers
738     Variable expansion may be modified to select or modify each word of the
739     variable (where a “word” is white-space delimited sequence of charac‐
740     ters).  The general format of a variable expansion is as follows:
741
742           ${variable[:modifier[:...]]}
743
744     Each modifier begins with a colon, which may be escaped with a backslash
745     (‘\’).
746
747     A set of modifiers can be specified via a variable, as follows:
748
749           modifier_variable=modifier[:...]
750           ${variable:${modifier_variable}[:...]}
751
752     In this case the first modifier in the modifier_variable does not start
753     with a colon, since that must appear in the referencing variable.  If any
754     of the modifiers in the modifier_variable contain a dollar sign (‘$’),
755     these must be doubled to avoid early expansion.
756
757     The supported modifiers are:
758
759     :E   Replaces each word in the variable with its suffix.
760
761     :H   Replaces each word in the variable with everything but the last com‐
762          ponent.
763
764     :Mpattern
765          Select only those words that match pattern.  The standard shell
766          wildcard characters (‘*’, ‘?’, and ‘[]’) may be used.  The wildcard
767          characters may be escaped with a backslash (‘\’).  As a consequence
768          of the way values are split into words, matched, and then joined, a
769          construct like
770                ${VAR:M*}
771          will normalize the inter-word spacing, removing all leading and
772          trailing space, and converting multiple consecutive spaces to single
773          spaces.
774
775     :Npattern
776          This is identical to ‘:M’, but selects all words which do not match
777          pattern.
778
779     :O   Order every word in variable alphabetically.  To sort words in
780          reverse order use the ‘:O:[-1..1]’ combination of modifiers.
781
782     :Ox  Randomize words in variable.  The results will be different each
783          time you are referring to the modified variable; use the assignment
784          with expansion (‘:=’) to prevent such behavior.  For example,
785
786                LIST=                   uno due tre quattro
787                RANDOM_LIST=            ${LIST:Ox}
788                STATIC_RANDOM_LIST:=    ${LIST:Ox}
789
790                all:
791                        @echo "${RANDOM_LIST}"
792                        @echo "${RANDOM_LIST}"
793                        @echo "${STATIC_RANDOM_LIST}"
794                        @echo "${STATIC_RANDOM_LIST}"
795          may produce output similar to:
796
797                quattro due tre uno
798                tre due quattro uno
799                due uno quattro tre
800                due uno quattro tre
801
802     :Q   Quotes every shell meta-character in the variable, so that it can be
803          passed safely through recursive invocations of make.
804
805     :R   Replaces each word in the variable with everything but its suffix.
806
807     :range[=count]
808          The value is an integer sequence representing the words of the orig‐
809          inal value, or the supplied count.
810
811     :gmtime[=utc]
812          The value is a format string for strftime(3), using gmtime(3).  If a
813          utc value is not provided or is 0, the current time is used.
814
815     :hash
816          Compute a 32-bit hash of the value and encode it as hex digits.
817
818     :localtime[=utc]
819          The value is a format string for strftime(3), using localtime(3).
820          If a utc value is not provided or is 0, the current time is used.
821
822     :tA  Attempt to convert variable to an absolute path using realpath(3),
823          if that fails, the value is unchanged.
824
825     :tl  Converts variable to lower-case letters.
826
827     :tsc
828          Words in the variable are normally separated by a space on expan‐
829          sion.  This modifier sets the separator to the character c.  If c is
830          omitted, then no separator is used.  The common escapes (including
831          octal numeric codes), work as expected.
832
833     :tu  Converts variable to upper-case letters.
834
835     :tW  Causes the value to be treated as a single word (possibly containing
836          embedded white space).  See also ‘:[*]’.
837
838     :tw  Causes the value to be treated as a sequence of words delimited by
839          white space.  See also ‘:[@]’.
840
841     :S/old_string/new_string/[1gW]
842          Modify the first occurrence of old_string in the variable's value,
843          replacing it with new_string.  If a ‘g’ is appended to the last
844          slash of the pattern, all occurrences in each word are replaced.  If
845          a ‘1’ is appended to the last slash of the pattern, only the first
846          word is affected.  If a ‘W’ is appended to the last slash of the
847          pattern, then the value is treated as a single word (possibly con‐
848          taining embedded white space).  If old_string begins with a caret
849          (‘^’), old_string is anchored at the beginning of each word.  If
850          old_string ends with a dollar sign (‘$’), it is anchored at the end
851          of each word.  Inside new_string, an ampersand (‘&’) is replaced by
852          old_string (without any ‘^’ or ‘$’).  Any character may be used as a
853          delimiter for the parts of the modifier string.  The anchoring,
854          ampersand and delimiter characters may be escaped with a backslash
855          (‘\’).
856
857          Variable expansion occurs in the normal fashion inside both
858          old_string and new_string with the single exception that a backslash
859          is used to prevent the expansion of a dollar sign (‘$’), not a pre‐
860          ceding dollar sign as is usual.
861
862     :C/pattern/replacement/[1gW]
863          The :C modifier is just like the :S modifier except that the old and
864          new strings, instead of being simple strings, are an extended regu‐
865          lar expression (see regex(3)) string pattern and an ed(1)-style
866          string replacement.  Normally, the first occurrence of the pattern
867          pattern in each word of the value is substituted with replacement.
868          The ‘1’ modifier causes the substitution to apply to at most one
869          word; the ‘g’ modifier causes the substitution to apply to as many
870          instances of the search pattern pattern as occur in the word or
871          words it is found in; the ‘W’ modifier causes the value to be
872          treated as a single word (possibly containing embedded white space).
873          Note that ‘1’ and ‘g’ are orthogonal; the former specifies whether
874          multiple words are potentially affected, the latter whether multiple
875          substitutions can potentially occur within each affected word.
876
877          As for the :S modifier, the pattern and replacement are subjected to
878          variable expansion before being parsed as regular expressions.
879
880     :T   Replaces each word in the variable with its last component.
881
882     :u   Remove adjacent duplicate words (like uniq(1)).
883
884     :?true_string:false_string
885          If the variable name (not its value), when parsed as a .if condi‐
886          tional expression, evaluates to true, return as its value the
887          true_string, otherwise return the false_string.  Since the variable
888          name is used as the expression, :? must be the first modifier after
889          the variable name itself - which will, of course, usually contain
890          variable expansions.  A common error is trying to use expressions
891          like
892                ${NUMBERS:M42:?match:no}
893          which actually tests defined(NUMBERS), to determine is any words
894          match "42" you need to use something like:
895                ${"${NUMBERS:M42}" != "":?match:no}.
896
897     :old_string=new_string
898          This is the AT&T System V UNIX style variable substitution.  It must
899          be the last modifier specified.  If old_string or new_string do not
900          contain the pattern matching character % then it is assumed that
901          they are anchored at the end of each word, so only suffixes or
902          entire words may be replaced.  Otherwise % is the substring of
903          old_string to be replaced in new_string.
904
905          Variable expansion occurs in the normal fashion inside both
906          old_string and new_string with the single exception that a backslash
907          is used to prevent the expansion of a dollar sign (‘$’), not a pre‐
908          ceding dollar sign as is usual.
909
910     :@temp@string@
911          This is the loop expansion mechanism from the OSF Development Envi‐
912          ronment (ODE) make.  Unlike .for loops expansion occurs at the time
913          of reference.  Assign temp to each word in the variable and evaluate
914          string.  The ODE convention is that temp should start and end with a
915          period.  For example.
916                ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
917
918          However a single character variable is often more readable:
919                ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
920
921     :_[=var]
922          Save the current variable value in ‘$_’ or the named var for later
923          reference.  Example usage:
924
925                M_cmpv.units = 1 1000 1000000
926                M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \
927                \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
928
929                .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
930
931          Here ‘$_’ is used to save the result of the ‘:S’ modifier which is
932          later referenced using the index values from ‘:range’.
933
934     :Unewval
935          If the variable is undefined newval is the value.  If the variable
936          is defined, the existing value is returned.  This is another ODE
937          make feature.  It is handy for setting per-target CFLAGS for
938          instance:
939                ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
940          If a value is only required if the variable is undefined, use:
941                ${VAR:D:Unewval}
942
943     :Dnewval
944          If the variable is defined newval is the value.
945
946     :L   The name of the variable is the value.
947
948     :P   The path of the node which has the same name as the variable is the
949          value.  If no such node exists or its path is null, then the name of
950          the variable is used.  In order for this modifier to work, the name
951          (node) must at least have appeared on the rhs of a dependency.
952
953     :!cmd!
954          The output of running cmd is the value.
955
956     :sh  If the variable is non-empty it is run as a command and the output
957          becomes the new value.
958
959     ::=str
960          The variable is assigned the value str after substitution.  This
961          modifier and its variations are useful in obscure situations such as
962          wanting to set a variable when shell commands are being parsed.
963          These assignment modifiers always expand to nothing, so if appearing
964          in a rule line by themselves should be preceded with something to
965          keep make happy.
966
967          The ‘::’ helps avoid false matches with the AT&T System V UNIX style
968          := modifier and since substitution always occurs the ::= form is
969          vaguely appropriate.
970
971     ::?=str
972          As for ::= but only if the variable does not already have a value.
973
974     ::+=str
975          Append str to the variable.
976
977     ::!=cmd
978          Assign the output of cmd to the variable.
979
980     :[range]
981          Selects one or more words from the value, or performs other opera‐
982          tions related to the way in which the value is divided into words.
983
984          Ordinarily, a value is treated as a sequence of words delimited by
985          white space.  Some modifiers suppress this behavior, causing a value
986          to be treated as a single word (possibly containing embedded white
987          space).  An empty value, or a value that consists entirely of white-
988          space, is treated as a single word.  For the purposes of the ‘:[]
989          modifier, the words are indexed both forwards using positive inte‐
990          gers (where index 1 represents the first word), and backwards using
991          negative integers (where index -1 represents the last word).
992
993          The range is subjected to variable expansion, and the expanded
994          result is then interpreted as follows:
995
996          index  Selects a single word from the value.
997
998          start..end
999                 Selects all words from start to end, inclusive.  For example,
1000:[2..-1]’ selects all words from the second word to the last
1001                 word.  If start is greater than end, then the words are out‐
1002                 put in reverse order.  For example, ‘:[-1..1]’ selects all
1003                 the words from last to first.
1004
1005          *      Causes subsequent modifiers to treat the value as a single
1006                 word (possibly containing embedded white space).  Analogous
1007                 to the effect of "$*" in Bourne shell.
1008
1009          0      Means the same as ‘:[*]’.
1010
1011          @      Causes subsequent modifiers to treat the value as a sequence
1012                 of words delimited by white space.  Analogous to the effect
1013                 of "$@" in Bourne shell.
1014
1015          #      Returns the number of words in the value.
1016

INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS

1018     Makefile inclusion, conditional structures and for loops  reminiscent of
1019     the C programming language are provided in make.  All such structures are
1020     identified by a line beginning with a single dot (‘.’) character.  Files
1021     are included with either .include file⟩ or .include "file".  Variables
1022     between the angle brackets or double quotes are expanded to form the file
1023     name.  If angle brackets are used, the included makefile is expected to
1024     be in the system makefile directory.  If double quotes are used, the
1025     including makefile's directory and any directories specified using the -I
1026     option are searched before the system makefile directory.  For compati‐
1027     bility with other versions of make ‘include file ...’ is also accepted.
1028
1029     If the include statement is written as .-include or as .sinclude then
1030     errors locating and/or opening include files are ignored.
1031
1032     If the include statement is written as .dinclude not only are errors
1033     locating and/or opening include files ignored, but stale dependencies
1034     within the included file will be ignored just like .MAKE.DEPENDFILE.
1035
1036     Conditional expressions are also preceded by a single dot as the first
1037     character of a line.  The possible conditionals are as follows:
1038
1039     .error message
1040             The message is printed along with the name of the makefile and
1041             line number, then make will exit.
1042
1043     .export variable ...
1044             Export the specified global variable.  If no variable list is
1045             provided, all globals are exported except for internal variables
1046             (those that start with ‘.’).  This is not affected by the -X
1047             flag, so should be used with caution.  For compatibility with
1048             other make programs ‘export variable=value’ is also accepted.
1049
1050             Appending a variable name to .MAKE.EXPORTED is equivalent to
1051             exporting a variable.
1052
1053     .export-env variable ...
1054             The same as ‘.export’, except that the variable is not appended
1055             to .MAKE.EXPORTED.  This allows exporting a value to the environ‐
1056             ment which is different from that used by make internally.
1057
1058     .export-literal variable ...
1059             The same as ‘.export-env’, except that variables in the value are
1060             not expanded.
1061
1062     .info message
1063             The message is printed along with the name of the makefile and
1064             line number.
1065
1066     .undef variable
1067             Un-define the specified global variable.  Only global variables
1068             may be un-defined.
1069
1070     .unexport variable ...
1071             The opposite of ‘.export’.  The specified global variable will be
1072             removed from .MAKE.EXPORTED.  If no variable list is provided,
1073             all globals are unexported, and .MAKE.EXPORTED deleted.
1074
1075     .unexport-env
1076             Unexport all globals previously exported and clear the environ‐
1077             ment inherited from the parent.  This operation will cause a mem‐
1078             ory leak of the original environment, so should be used spar‐
1079             ingly.  Testing for .MAKE.LEVEL being 0, would make sense.  Also
1080             note that any variables which originated in the parent environ‐
1081             ment should be explicitly preserved if desired.  For example:
1082
1083                   .if ${.MAKE.LEVEL} == 0
1084                   PATH := ${PATH}
1085                   .unexport-env
1086                   .export PATH
1087                   .endif
1088
1089             Would result in an environment containing only ‘PATH’, which is
1090             the minimal useful environment.  Actually ‘.MAKE.LEVEL’ will also
1091             be pushed into the new environment.
1092
1093     .warning message
1094             The message prefixed by ‘warning:’ is printed along with the name
1095             of the makefile and line number.
1096
1097     .if [!]expression [operator expression ...]
1098             Test the value of an expression.
1099
1100     .ifdef [!]variable [operator variable ...]
1101             Test the value of a variable.
1102
1103     .ifndef [!]variable [operator variable ...]
1104             Test the value of a variable.
1105
1106     .ifmake [!]target [operator target ...]
1107             Test the target being built.
1108
1109     .ifnmake [!] target [operator target ...]
1110             Test the target being built.
1111
1112     .else   Reverse the sense of the last conditional.
1113
1114     .elif [!] expression [operator expression ...]
1115             A combination of ‘.else’ followed by ‘.if’.
1116
1117     .elifdef [!]variable [operator variable ...]
1118             A combination of ‘.else’ followed by ‘.ifdef’.
1119
1120     .elifndef [!]variable [operator variable ...]
1121             A combination of ‘.else’ followed by ‘.ifndef’.
1122
1123     .elifmake [!]target [operator target ...]
1124             A combination of ‘.else’ followed by ‘.ifmake’.
1125
1126     .elifnmake [!]target [operator target ...]
1127             A combination of ‘.else’ followed by ‘.ifnmake’.
1128
1129     .endif  End the body of the conditional.
1130
1131     The operator may be any one of the following:
1132
1133     ||     Logical OR.
1134
1135     &&     Logical AND; of higher precedence than “||”.
1136
1137     As in C, make will only evaluate a conditional as far as is necessary to
1138     determine its value.  Parentheses may be used to change the order of
1139     evaluation.  The boolean operator ‘!’ may be used to logically negate an
1140     entire conditional.  It is of higher precedence than ‘&&’.
1141
1142     The value of expression may be any of the following:
1143
1144     defined  Takes a variable name as an argument and evaluates to true if
1145              the variable has been defined.
1146
1147     make     Takes a target name as an argument and evaluates to true if the
1148              target was specified as part of make's command line or was
1149              declared the default target (either implicitly or explicitly,
1150              see .MAIN) before the line containing the conditional.
1151
1152     empty    Takes a variable, with possible modifiers, and evaluates to true
1153              if the expansion of the variable would result in an empty
1154              string.
1155
1156     exists   Takes a file name as an argument and evaluates to true if the
1157              file exists.  The file is searched for on the system search path
1158              (see .PATH).
1159
1160     target   Takes a target name as an argument and evaluates to true if the
1161              target has been defined.
1162
1163     commands
1164              Takes a target name as an argument and evaluates to true if the
1165              target has been defined and has commands associated with it.
1166
1167     Expression may also be an arithmetic or string comparison.  Variable
1168     expansion is performed on both sides of the comparison, after which the
1169     integral values are compared.  A value is interpreted as hexadecimal if
1170     it is preceded by 0x, otherwise it is decimal; octal numbers are not sup‐
1171     ported.  The standard C relational operators are all supported.  If after
1172     variable expansion, either the left or right hand side of a ‘==’ or ‘!=
1173     operator is not an integral value, then string comparison is performed
1174     between the expanded variables.  If no relational operator is given, it
1175     is assumed that the expanded variable is being compared against 0 or an
1176     empty string in the case of a string comparison.
1177
1178     When make is evaluating one of these conditional expressions, and it
1179     encounters a (white-space separated) word it doesn't recognize, either
1180     the “make” or “defined” expression is applied to it, depending on the
1181     form of the conditional.  If the form is ‘.ifdef’, ‘.ifndef’, or ‘.if
1182     the “defined” expression is applied.  Similarly, if the form is ‘.ifmake
1183     or ‘.ifnmake’, the “make” expression is applied.
1184
1185     If the conditional evaluates to true the parsing of the makefile contin‐
1186     ues as before.  If it evaluates to false, the following lines are
1187     skipped.  In both cases this continues until a ‘.else’ or ‘.endif’ is
1188     found.
1189
1190     For loops are typically used to apply a set of rules to a list of files.
1191     The syntax of a for loop is:
1192
1193     .for variable [variable ...] in expression
1194     ⟨make-rules⟩
1195     .endfor
1196
1197     After the for expression is evaluated, it is split into words.  On each
1198     iteration of the loop, one word is taken and assigned to each variable,
1199     in order, and these variables are substituted into the make-rules inside
1200     the body of the for loop.  The number of words must come out even; that
1201     is, if there are three iteration variables, the number of words provided
1202     must be a multiple of three.
1203

COMMENTS

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

SPECIAL SOURCES (ATTRIBUTES)

1209     .EXEC     Target is never out of date, but always execute commands any‐
1210               way.
1211
1212     .IGNORE   Ignore any errors from the commands associated with this tar‐
1213               get, exactly as if they all were preceded by a dash (‘-’).
1214
1215     .MADE     Mark all sources of this target as being up-to-date.
1216
1217     .MAKE     Execute the commands associated with this target even if the -n
1218               or -t options were specified.  Normally used to mark recursive
1219               makes.
1220
1221     .META     Create a meta file for the target, even if it is flagged as
1222               .PHONY, .MAKE, or .SPECIAL.  Usage in conjunction with .MAKE is
1223               the most likely case.  In "meta" mode, the target is out-of-
1224               date if the meta file is missing.
1225
1226     .NOMETA   Do not create a meta file for the target.  Meta files are also
1227               not created for .PHONY, .MAKE, or .SPECIAL targets.
1228
1229     .NOMETA_CMP
1230               Ignore differences in commands when deciding if target is out
1231               of date.  This is useful if the command contains a value which
1232               always changes.  If the number of commands change, though, the
1233               target will still be out of date.  The same effect applies to
1234               any command line that uses the variable .OODATE, which can be
1235               used for that purpose even when not otherwise needed or
1236               desired:
1237
1238
1239                     skip-compare-for-some:
1240                             @echo this will be compared
1241                             @echo this will not ${.OODATE:M.NOMETA_CMP}
1242                             @echo this will also be compared
1243
1244               The :M pattern suppresses any expansion of the unwanted vari‐
1245               able.
1246
1247     .NOPATH   Do not search for the target in the directories specified by
1248               .PATH.
1249
1250     .NOTMAIN  Normally make selects the first target it encounters as the
1251               default target to be built if no target was specified.  This
1252               source prevents this target from being selected.
1253
1254     .OPTIONAL
1255               If a target is marked with this attribute and make can't figure
1256               out how to create it, it will ignore this fact and assume the
1257               file isn't needed or already exists.
1258
1259     .PHONY    The target does not correspond to an actual file; it is always
1260               considered to be out of date, and will not be created with the
1261               -t option.  Suffix-transformation rules are not applied to
1262               .PHONY targets.
1263
1264     .PRECIOUS
1265               When make is interrupted, it normally removes any partially
1266               made targets.  This source prevents the target from being
1267               removed.
1268
1269     .RECURSIVE
1270               Synonym for .MAKE.
1271
1272     .SILENT   Do not echo any of the commands associated with this target,
1273               exactly as if they all were preceded by an at sign (‘@’).
1274
1275     .USE      Turn the target into make's version of a macro.  When the tar‐
1276               get is used as a source for another target, the other target
1277               acquires the commands, sources, and attributes (except for
1278               .USE) of the source.  If the target already has commands, the
1279               .USE target's commands are appended to them.
1280
1281     .USEBEFORE
1282               Exactly like .USE, but prepend the .USEBEFORE target commands
1283               to the target.
1284
1285     .WAIT     If .WAIT appears in a dependency line, the sources that precede
1286               it are made before the sources that succeed it in the line.
1287               Since the dependents of files are not made until the file
1288               itself could be made, this also stops the dependents being
1289               built unless they are needed for another branch of the depen‐
1290               dency tree.  So given:
1291
1292               x: a .WAIT b
1293                       echo x
1294               a:
1295                       echo a
1296               b: b1
1297                       echo b
1298               b1:
1299                       echo b1
1300
1301               the output is always ‘a’, ‘b1’, ‘b’, ‘x’.
1302               The ordering imposed by .WAIT is only relevant for parallel
1303               makes.
1304

SPECIAL TARGETS

1306     Special targets may not be included with other targets, i.e. they must be
1307     the only target specified.
1308
1309     .BEGIN   Any command lines attached to this target are executed before
1310              anything else is done.
1311
1312     .DEFAULT
1313              This is sort of a .USE rule for any target (that was used only
1314              as a source) that make can't figure out any other way to create.
1315              Only the shell script is used.  The .IMPSRC variable of a target
1316              that inherits .DEFAULT's commands is set to the target's own
1317              name.
1318
1319     .DELETE_ON_ERROR
1320              If this target is present in the makefile, it globally causes
1321              make to delete targets whose commands fail.  (By default, only
1322              targets whose commands are interrupted during execution are
1323              deleted.  This is the historical behavior.)  This setting can be
1324              used to help prevent half-finished or malformed targets from
1325              being left around and corrupting future rebuilds.
1326
1327     .END     Any command lines attached to this target are executed after
1328              everything else is done.
1329
1330     .ERROR   Any command lines attached to this target are executed when
1331              another target fails.  The .ERROR_TARGET variable is set to the
1332              target that failed.  See also MAKE_PRINT_VAR_ON_ERROR.
1333
1334     .IGNORE  Mark each of the sources with the .IGNORE attribute.  If no
1335              sources are specified, this is the equivalent of specifying the
1336              -i option.
1337
1338     .INTERRUPT
1339              If make is interrupted, the commands for this target will be
1340              executed.
1341
1342     .MAIN    If no target is specified when make is invoked, this target will
1343              be built.
1344
1345     .MAKEFLAGS
1346              This target provides a way to specify flags for make when the
1347              makefile is used.  The flags are as if typed to the shell,
1348              though the -f option will have no effect.
1349
1350     .NOPATH  Apply the .NOPATH attribute to any specified sources.
1351
1352     .NOTPARALLEL
1353              Disable parallel mode.
1354
1355     .NO_PARALLEL
1356              Synonym for .NOTPARALLEL, for compatibility with other pmake
1357              variants.
1358
1359     .OBJDIR  The source is a new value for ‘.OBJDIR’.  If it exists, make
1360              will chdir(2) to it and update the value of ‘.OBJDIR’.
1361
1362     .ORDER   The named targets are made in sequence.  This ordering does not
1363              add targets to the list of targets to be made.  Since the depen‐
1364              dents of a target do not get built until the target itself could
1365              be built, unless ‘a’ is built by another part of the dependency
1366              graph, the following is a dependency loop:
1367
1368              .ORDER: b a
1369              b: a
1370
1371              The ordering imposed by .ORDER is only relevant for parallel
1372              makes.
1373
1374     .PATH    The sources are directories which are to be searched for files
1375              not found in the current directory.  If no sources are speci‐
1376              fied, any previously specified directories are deleted.  If the
1377              source is the special .DOTLAST target, then the current working
1378              directory is searched last.
1379
1380     .PATH.suffix
1381              Like .PATH but applies only to files with a particular suffix.
1382              The suffix must have been previously declared with .SUFFIXES.
1383
1384     .PHONY   Apply the .PHONY attribute to any specified sources.
1385
1386     .PRECIOUS
1387              Apply the .PRECIOUS attribute to any specified sources.  If no
1388              sources are specified, the .PRECIOUS attribute is applied to
1389              every target in the file.
1390
1391     .SHELL   Sets the shell that make will use to execute commands.  The
1392              sources are a set of field=value pairs.
1393
1394              name        This is the minimal specification, used to select
1395                          one of the built-in shell specs; sh, ksh, and csh.
1396
1397              path        Specifies the path to the shell.
1398
1399              hasErrCtl   Indicates whether the shell supports exit on error.
1400
1401              check       The command to turn on error checking.
1402
1403              ignore      The command to disable error checking.
1404
1405              echo        The command to turn on echoing of commands executed.
1406
1407              quiet       The command to turn off echoing of commands exe‐
1408                          cuted.
1409
1410              filter      The output to filter after issuing the quiet com‐
1411                          mand.  It is typically identical to quiet.
1412
1413              errFlag     The flag to pass the shell to enable error checking.
1414
1415              echoFlag    The flag to pass the shell to enable command echo‐
1416                          ing.
1417
1418              newline     The string literal to pass the shell that results in
1419                          a single newline character when used outside of any
1420                          quoting characters.
1421              Example:
1422
1423              .SHELL: name=ksh path=/bin/ksh hasErrCtl=true \
1424                      check="set -e" ignore="set +e" \
1425                      echo="set -v" quiet="set +v" filter="set +v" \
1426                      echoFlag=v errFlag=e newline="'\n'"
1427
1428     .SILENT  Apply the .SILENT attribute to any specified sources.  If no
1429              sources are specified, the .SILENT attribute is applied to every
1430              command in the file.
1431
1432     .STALE   This target gets run when a dependency file contains stale
1433              entries, having .ALLSRC set to the name of that dependency file.
1434
1435     .SUFFIXES
1436              Each source specifies a suffix to make.  If no sources are spec‐
1437              ified, any previously specified suffixes are deleted.  It allows
1438              the creation of suffix-transformation rules.
1439
1440              Example:
1441
1442              .SUFFIXES: .o
1443              .c.o:
1444                      cc -o ${.TARGET} -c ${.IMPSRC}
1445

ENVIRONMENT

1447     make uses the following environment variables, if they exist: MACHINE,
1448     MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX, MAKESYSPATH,
1449     PWD, and TMPDIR.
1450
1451     MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on
1452     the command line to make and not as makefile variables; see the descrip‐
1453     tion of ‘.OBJDIR’ for more details.
1454

FILES

1456     .depend        list of dependencies
1457     Makefile       list of dependencies
1458     makefile       list of dependencies
1459     sys.mk         system makefile
1460     /usr/share/mk  system makefile directory
1461

COMPATIBILITY

1463     The basic make syntax is compatible between different versions of make;
1464     however the special variables, variable modifiers and conditionals are
1465     not.
1466
1467   Older versions
1468     An incomplete list of changes in older versions of make:
1469
1470     The way that .for loop variables are substituted changed after NetBSD 5.0
1471     so that they still appear to be variable expansions.  In particular this
1472     stops them being treated as syntax, and removes some obscure problems
1473     using them in .if statements.
1474
1475     The way that parallel makes are scheduled changed in NetBSD 4.0 so that
1476     .ORDER and .WAIT apply recursively to the dependent nodes.  The algo‐
1477     rithms used may change again in the future.
1478
1479   Other make dialects
1480     Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not sup‐
1481     port most of the features of make as described in this manual.  Most
1482     notably:
1483
1484           ·   The .WAIT and .ORDER declarations and most functionality per‐
1485               taining to parallelization.  (GNU make supports parallelization
1486               but lacks these features needed to control it effectively.)
1487
1488           ·   Directives, including for loops and conditionals and most of
1489               the forms of include files.  (GNU make has its own incompatible
1490               and less powerful syntax for conditionals.)
1491
1492           ·   All built-in variables that begin with a dot.
1493
1494           ·   Most of the special sources and targets that begin with a dot,
1495               with the notable exception of .PHONY, .PRECIOUS, and .SUFFIXES.
1496
1497           ·   Variable modifiers, except for the
1498                     :old=new
1499               string substitution, which does not portably support globbing
1500               with ‘%’ and historically only works on declared suffixes.
1501
1502           ·   The $> variable even in its short form; most makes support this
1503               functionality but its name varies.
1504
1505     Some features are somewhat more portable, such as assignment with +=, ?=,
1506     and !=.  The .PATH functionality is based on an older feature VPATH found
1507     in GNU make and many versions of SVR4 make; however, historically its
1508     behavior is too ill-defined (and too buggy) to rely upon.
1509
1510     The $@ and $< variables are more or less universally portable, as is the
1511     $(MAKE) variable.  Basic use of suffix rules (for files only in the cur‐
1512     rent directory, not trying to chain transformations together, etc.) is
1513     also reasonably portable.
1514

SEE ALSO

1516     mkdep(1)
1517

HISTORY

1519     A make command appeared in Version 7 AT&T UNIX.  This make implementation
1520     is based on Adam De Boor's pmake program which was written for Sprite at
1521     Berkeley.  It was designed to be a parallel distributed make running jobs
1522     on different machines using a daemon called “customs”.
1523
1524     Historically the target/dependency “FRC” has been used to FoRCe rebuild‐
1525     ing (since the target/dependency does not exist... unless someone creates
1526     an “FRC” file).
1527

BUGS

1529     The make syntax is difficult to parse without actually acting of the
1530     data.  For instance finding the end of a variable use should involve
1531     scanning each the modifiers using the correct terminator for each field.
1532     In many places make just counts {} and () in order to find the end of a
1533     variable expansion.
1534
1535     There is no way of escaping a space character in a filename.
1536
1537BSD                              June 22, 2017                             BSD
Impressum