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