xref: /netbsd-src/usr.bin/make/make.1 (revision 8ecbf5f02b752fcb7debe1a8fab1dc82602bc760)
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 MAKE 1
34.Os
35.Sh NAME
36.Nm make
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 true, for compatibility with other makes.
1012If set to false,
1013.Ql $$
1014becomes
1015.Ql $
1016per normal evaluation rules.
1017.It Va MAKE_PRINT_VAR_ON_ERROR
1018When
1019.Nm
1020stops due to an error, it sets
1021.Ql Va .ERROR_TARGET
1022to the name of the target that failed,
1023.Ql Va .ERROR_CMD
1024to the commands of the failed target,
1025and in "meta" mode, it also sets
1026.Ql Va .ERROR_CWD
1027to the
1028.Xr getcwd 3 ,
1029and
1030.Ql Va .ERROR_META_FILE
1031to the path of the meta file (if any) describing the failed target.
1032It then prints its name and the value of
1033.Ql Va .CURDIR
1034as well as the value of any variables named in
1035.Ql Va MAKE_PRINT_VAR_ON_ERROR .
1036.It Va .newline
1037This variable is simply assigned a newline character as its value.
1038This allows expansions using the
1039.Cm \&:@
1040modifier to put a newline between
1041iterations of the loop rather than a space.
1042For example, the printing of
1043.Ql Va MAKE_PRINT_VAR_ON_ERROR
1044could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
1045.It Va .OBJDIR
1046A path to the directory where the targets are built.
1047Its value is determined by trying to
1048.Xr chdir 2
1049to the following directories in order and using the first match:
1050.Bl -enum
1051.It
1052.Ev ${MAKEOBJDIRPREFIX}${.CURDIR}
1053.Pp
1054(Only if
1055.Ql Ev MAKEOBJDIRPREFIX
1056is set in the environment or on the command line.)
1057.It
1058.Ev ${MAKEOBJDIR}
1059.Pp
1060(Only if
1061.Ql Ev MAKEOBJDIR
1062is set in the environment or on the command line.)
1063.It
1064.Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE}
1065.It
1066.Ev ${.CURDIR} Ns Pa /obj
1067.It
1068.Pa /usr/obj/ Ns Ev ${.CURDIR}
1069.It
1070.Ev ${.CURDIR}
1071.El
1072.Pp
1073Variable expansion is performed on the value before it's used,
1074so expressions such as
1075.Dl ${.CURDIR:S,^/usr/src,/var/obj,}
1076may be used.
1077This is especially useful with
1078.Ql Ev MAKEOBJDIR .
1079.Pp
1080.Ql Va .OBJDIR
1081may be modified in the makefile via the special target
1082.Ql Ic .OBJDIR .
1083In all cases,
1084.Nm
1085will
1086.Xr chdir 2
1087to the specified directory if it exists, and set
1088.Ql Va .OBJDIR
1089and
1090.Ql Ev PWD
1091to that directory before executing any targets.
1092.
1093.It Va .PARSEDIR
1094A path to the directory of the current
1095.Ql Pa Makefile
1096being parsed.
1097.It Va .PARSEFILE
1098The basename of the current
1099.Ql Pa Makefile
1100being parsed.
1101This variable and
1102.Ql Va .PARSEDIR
1103are both set only while the
1104.Ql Pa Makefiles
1105are being parsed.
1106If you want to retain their current values, assign them to a variable
1107using assignment with expansion:
1108.Pq Ql Cm \&:= .
1109.It Va .PATH
1110A variable that represents the list of directories that
1111.Nm
1112will search for files.
1113The search list should be updated using the target
1114.Ql Va .PATH
1115rather than the variable.
1116.It Ev PWD
1117Alternate path to the current directory.
1118.Nm
1119normally sets
1120.Ql Va .CURDIR
1121to the canonical path given by
1122.Xr getcwd 3 .
1123However, if the environment variable
1124.Ql Ev PWD
1125is set and gives a path to the current directory, then
1126.Nm
1127sets
1128.Ql Va .CURDIR
1129to the value of
1130.Ql Ev PWD
1131instead.
1132This behavior is disabled if
1133.Ql Ev MAKEOBJDIRPREFIX
1134is set or
1135.Ql Ev MAKEOBJDIR
1136contains a variable transform.
1137.Ql Ev PWD
1138is set to the value of
1139.Ql Va .OBJDIR
1140for all programs which
1141.Nm
1142executes.
1143.It Ev .SHELL
1144The pathname of the shell used to run target scripts.
1145It is read-only.
1146.It Ev .TARGETS
1147The list of targets explicitly specified on the command line, if any.
1148.It Ev VPATH
1149Colon-separated
1150.Pq Dq \&:
1151lists of directories that
1152.Nm
1153will search for files.
1154The variable is supported for compatibility with old make programs only,
1155use
1156.Ql Va .PATH
1157instead.
1158.El
1159.Ss Variable modifiers
1160Variable expansion may be modified to select or modify each word of the
1161variable (where a
1162.Dq word
1163is white-space delimited sequence of characters).
1164The general format of a variable expansion is as follows:
1165.Pp
1166.Dl ${variable[:modifier[:...]]}
1167.Pp
1168Each modifier begins with a colon,
1169which may be escaped with a backslash
1170.Pq Ql \e .
1171.Pp
1172A set of modifiers can be specified via a variable, as follows:
1173.Pp
1174.Dl modifier_variable=modifier[:...]
1175.Dl ${variable:${modifier_variable}[:...]}
1176.Pp
1177In this case the first modifier in the modifier_variable does not
1178start with a colon, since that must appear in the referencing
1179variable.
1180If any of the modifiers in the modifier_variable contain a dollar sign
1181.Pq Ql $ ,
1182these must be doubled to avoid early expansion.
1183.Pp
1184The supported modifiers are:
1185.Bl -tag -width EEE
1186.It Cm \&:E
1187Replaces each word in the variable with its suffix.
1188.It Cm \&:H
1189Replaces each word in the variable with everything but the last component.
1190.It Cm \&:M Ns Ar pattern
1191Selects only those words that match
1192.Ar pattern .
1193The standard shell wildcard characters
1194.Pf ( Ql * ,
1195.Ql \&? ,
1196and
1197.Ql Oo Oc )
1198may
1199be used.
1200The wildcard characters may be escaped with a backslash
1201.Pq Ql \e .
1202As a consequence of the way values are split into words, matched,
1203and then joined, a construct like
1204.Dl ${VAR:M*}
1205will normalize the inter-word spacing, removing all leading and
1206trailing space, and converting multiple consecutive spaces
1207to single spaces.
1208.
1209.It Cm \&:N Ns Ar pattern
1210This is identical to
1211.Ql Cm \&:M ,
1212but selects all words which do not match
1213.Ar pattern .
1214.It Cm \&:O
1215Orders every word in variable alphabetically.
1216.It Cm \&:Or
1217Orders every word in variable in reverse alphabetical order.
1218.It Cm \&:Ox
1219Shuffles the words in variable.
1220The results will be different each time you are referring to the
1221modified variable; use the assignment with expansion
1222.Pq Ql Cm \&:=
1223to prevent such behavior.
1224For example,
1225.Bd -literal -offset indent
1226LIST=			uno due tre quattro
1227RANDOM_LIST=		${LIST:Ox}
1228STATIC_RANDOM_LIST:=	${LIST:Ox}
1229
1230all:
1231	@echo "${RANDOM_LIST}"
1232	@echo "${RANDOM_LIST}"
1233	@echo "${STATIC_RANDOM_LIST}"
1234	@echo "${STATIC_RANDOM_LIST}"
1235.Ed
1236may produce output similar to:
1237.Bd -literal -offset indent
1238quattro due tre uno
1239tre due quattro uno
1240due uno quattro tre
1241due uno quattro tre
1242.Ed
1243.It Cm \&:Q
1244Quotes every shell meta-character in the variable, so that it can be passed
1245safely to the shell.
1246.It Cm \&:q
1247Quotes every shell meta-character in the variable, and also doubles
1248.Sq $
1249characters so that it can be passed
1250safely through recursive invocations of
1251.Nm .
1252This is equivalent to:
1253.Sq \&:S/\e\&$/&&/g:Q .
1254.It Cm \&:R
1255Replaces each word in the variable with everything but its suffix.
1256.It Cm \&:range[=count]
1257The value is an integer sequence representing the words of the original
1258value, or the supplied
1259.Va count .
1260.It Cm \&:gmtime[=utc]
1261The value is a format string for
1262.Xr strftime 3 ,
1263using
1264.Xr gmtime 3 .
1265If a
1266.Va utc
1267value is not provided or is 0, the current time is used.
1268.It Cm \&:hash
1269Computes a 32-bit hash of the value and encode it as hex digits.
1270.It Cm \&:localtime[=utc]
1271The value is a format string for
1272.Xr strftime 3 ,
1273using
1274.Xr localtime 3 .
1275If a
1276.Va utc
1277value is not provided or is 0, the current time is used.
1278.It Cm \&:tA
1279Attempts to convert variable to an absolute path using
1280.Xr realpath 3 ,
1281if that fails, the value is unchanged.
1282.It Cm \&:tl
1283Converts variable to lower-case letters.
1284.It Cm \&:ts Ns Ar c
1285Words in the variable are normally separated by a space on expansion.
1286This modifier sets the separator to the character
1287.Ar c .
1288If
1289.Ar c
1290is omitted, then no separator is used.
1291The common escapes (including octal numeric codes) work as expected.
1292.It Cm \&:tu
1293Converts variable to upper-case letters.
1294.It Cm \&:tW
1295Causes the value to be treated as a single word
1296(possibly containing embedded white space).
1297See also
1298.Ql Cm \&:[*] .
1299.It Cm \&:tw
1300Causes the value to be treated as a sequence of
1301words delimited by white space.
1302See also
1303.Ql Cm \&:[@] .
1304.Sm off
1305.It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW
1306.Sm on
1307Modifies the first occurrence of
1308.Ar old_string
1309in each word of the variable's value, replacing it with
1310.Ar new_string .
1311If a
1312.Ql g
1313is appended to the last delimiter of the pattern, all occurrences
1314in each word are replaced.
1315If a
1316.Ql 1
1317is appended to the last delimiter of the pattern, only the first occurrence
1318is affected.
1319If a
1320.Ql W
1321is appended to the last delimiter of the pattern,
1322then the value is treated as a single word
1323(possibly containing embedded white space).
1324If
1325.Ar old_string
1326begins with a caret
1327.Pq Ql ^ ,
1328.Ar old_string
1329is anchored at the beginning of each word.
1330If
1331.Ar old_string
1332ends with a dollar sign
1333.Pq Ql \&$ ,
1334it is anchored at the end of each word.
1335Inside
1336.Ar new_string ,
1337an ampersand
1338.Pq Ql &
1339is replaced by
1340.Ar old_string
1341(without any
1342.Ql ^
1343or
1344.Ql \&$ ) .
1345Any character may be used as a delimiter for the parts of the modifier
1346string.
1347The anchoring, ampersand and delimiter characters may be escaped with a
1348backslash
1349.Pq Ql \e .
1350.Pp
1351Variable expansion occurs in the normal fashion inside both
1352.Ar old_string
1353and
1354.Ar new_string
1355with the single exception that a backslash is used to prevent the expansion
1356of a dollar sign
1357.Pq Ql \&$ ,
1358not a preceding dollar sign as is usual.
1359.Sm off
1360.It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW
1361.Sm on
1362The
1363.Cm \&:C
1364modifier is just like the
1365.Cm \&:S
1366modifier except that the old and new strings, instead of being
1367simple strings, are an extended regular expression (see
1368.Xr regex 3 )
1369string
1370.Ar pattern
1371and an
1372.Xr ed 1 Ns \-style
1373string
1374.Ar replacement .
1375Normally, the first occurrence of the pattern
1376.Ar pattern
1377in each word of the value is substituted with
1378.Ar replacement .
1379The
1380.Ql 1
1381modifier causes the substitution to apply to at most one word; the
1382.Ql g
1383modifier causes the substitution to apply to as many instances of the
1384search pattern
1385.Ar pattern
1386as occur in the word or words it is found in; the
1387.Ql W
1388modifier causes the value to be treated as a single word
1389(possibly containing embedded white space).
1390.Pp
1391As for the
1392.Cm \&:S
1393modifier, the
1394.Ar pattern
1395and
1396.Ar replacement
1397are subjected to variable expansion before being parsed as
1398regular expressions.
1399.It Cm \&:T
1400Replaces each word in the variable with its last path component.
1401.It Cm \&:u
1402Removes adjacent duplicate words (like
1403.Xr uniq 1 ) .
1404.Sm off
1405.It Cm \&:\&? Ar true_string Cm \&: Ar false_string
1406.Sm on
1407If the variable name (not its value), when parsed as a .if conditional
1408expression, evaluates to true, return as its value the
1409.Ar true_string ,
1410otherwise return the
1411.Ar false_string .
1412Since the variable name is used as the expression, \&:\&? must be the
1413first modifier after the variable name itself - which will, of course,
1414usually contain variable expansions.
1415A common error is trying to use expressions like
1416.Dl ${NUMBERS:M42:?match:no}
1417which actually tests defined(NUMBERS),
1418to determine if any words match "42" you need to use something like:
1419.Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} .
1420.It Ar :old_string=new_string
1421This is the
1422.At V
1423style variable substitution.
1424It must be the last modifier specified.
1425If
1426.Ar old_string
1427or
1428.Ar new_string
1429do not contain the pattern matching character
1430.Ar %
1431then it is assumed that they are
1432anchored at the end of each word, so only suffixes or entire
1433words may be replaced.
1434Otherwise
1435.Ar %
1436is the substring of
1437.Ar old_string
1438to be replaced in
1439.Ar new_string .
1440If only
1441.Ar old_string
1442contains the pattern matching character
1443.Ar % ,
1444and
1445.Ar old_string
1446matches, then the result is the
1447.Ar new_string .
1448If only the
1449.Ar new_string
1450contains the pattern matching character
1451.Ar % ,
1452then it is not treated specially and it is printed as a literal
1453.Ar %
1454on match.
1455If there is more than one pattern matching character
1456.Ar ( % )
1457in either the
1458.Ar new_string
1459or
1460.Ar old_string ,
1461only the first instance is treated specially (as the pattern character);
1462all subsequent instances are treated as regular characters.
1463.Pp
1464Variable expansion occurs in the normal fashion inside both
1465.Ar old_string
1466and
1467.Ar new_string
1468with the single exception that a backslash is used to prevent the
1469expansion of a dollar sign
1470.Pq Ql \&$ ,
1471not a preceding dollar sign as is usual.
1472.Sm off
1473.It Cm \&:@ Ar temp Cm @ Ar string Cm @
1474.Sm on
1475This is the loop expansion mechanism from the OSF Development
1476Environment (ODE) make.
1477Unlike
1478.Cm \&.for
1479loops, expansion occurs at the time of reference.
1480Assigns
1481.Ar temp
1482to each word in the variable and evaluates
1483.Ar string .
1484The ODE convention is that
1485.Ar temp
1486should start and end with a period.
1487For example.
1488.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1489.Pp
1490However a single character variable is often more readable:
1491.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1492.It Cm \&:_[=var]
1493Saves the current variable value in
1494.Ql $_
1495or the named
1496.Va var
1497for later reference.
1498Example usage:
1499.Bd -literal -offset indent
1500M_cmpv.units = 1 1000 1000000
1501M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
1502\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
1503
1504.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
1505
1506.Ed
1507Here
1508.Ql $_
1509is used to save the result of the
1510.Ql :S
1511modifier which is later referenced using the index values from
1512.Ql :range .
1513.It Cm \&:U Ns Ar newval
1514If the variable is undefined,
1515.Ar newval
1516is the value.
1517If the variable is defined, the existing value is returned.
1518This is another ODE make feature.
1519It is handy for setting per-target CFLAGS for instance:
1520.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1521If a value is only required if the variable is undefined, use:
1522.Dl ${VAR:D:Unewval}
1523.It Cm \&:D Ns Ar newval
1524If the variable is defined,
1525.Ar newval
1526is the value.
1527.It Cm \&:L
1528The name of the variable is the value.
1529.It Cm \&:P
1530The path of the node which has the same name as the variable
1531is the value.
1532If no such node exists or its path is null, then the
1533name of the variable is used.
1534In order for this modifier to work, the name (node) must at least have
1535appeared on the rhs of a dependency.
1536.Sm off
1537.It Cm \&:\&! Ar cmd Cm \&!
1538.Sm on
1539The output of running
1540.Ar cmd
1541is the value.
1542.It Cm \&:sh
1543If the variable is non-empty it is run as a command and the output
1544becomes the new value.
1545.It Cm \&::= Ns Ar str
1546The variable is assigned the value
1547.Ar str
1548after substitution.
1549This modifier and its variations are useful in
1550obscure situations such as wanting to set a variable when shell commands
1551are being parsed.
1552These assignment modifiers always expand to
1553nothing, so if appearing in a rule line by themselves should be
1554preceded with something to keep
1555.Nm
1556happy.
1557.Pp
1558The
1559.Ql Cm \&::
1560helps avoid false matches with the
1561.At V
1562style
1563.Cm \&:=
1564modifier and since substitution always occurs the
1565.Cm \&::=
1566form is vaguely appropriate.
1567.It Cm \&::?= Ns Ar str
1568As for
1569.Cm \&::=
1570but only if the variable does not already have a value.
1571.It Cm \&::+= Ns Ar str
1572Append
1573.Ar str
1574to the variable.
1575.It Cm \&::!= Ns Ar cmd
1576Assign the output of
1577.Ar cmd
1578to the variable.
1579.It Cm \&:\&[ Ns Ar range Ns Cm \&]
1580Selects one or more words from the value,
1581or performs other operations related to the way in which the
1582value is divided into words.
1583.Pp
1584Ordinarily, a value is treated as a sequence of words
1585delimited by white space.
1586Some modifiers suppress this behavior,
1587causing a value to be treated as a single word
1588(possibly containing embedded white space).
1589An empty value, or a value that consists entirely of white-space,
1590is treated as a single word.
1591For the purposes of the
1592.Ql Cm \&:[]
1593modifier, the words are indexed both forwards using positive integers
1594(where index 1 represents the first word),
1595and backwards using negative integers
1596(where index \-1 represents the last word).
1597.Pp
1598The
1599.Ar range
1600is subjected to variable expansion, and the expanded result is
1601then interpreted as follows:
1602.Bl -tag -width index
1603.\" :[n]
1604.It Ar index
1605Selects a single word from the value.
1606.\" :[start..end]
1607.It Ar start Ns Cm \&.. Ns Ar end
1608Selects all words from
1609.Ar start
1610to
1611.Ar end ,
1612inclusive.
1613For example,
1614.Ql Cm \&:[2..-1]
1615selects all words from the second word to the last word.
1616If
1617.Ar start
1618is greater than
1619.Ar end ,
1620then the words are output in reverse order.
1621For example,
1622.Ql Cm \&:[-1..1]
1623selects all the words from last to first.
1624If the list is already ordered, then this effectively reverses
1625the list, but it is more efficient to use
1626.Ql Cm \&:Or
1627instead of
1628.Ql Cm \&:O:[-1..1] .
1629.\" :[*]
1630.It Cm \&*
1631Causes subsequent modifiers to treat the value as a single word
1632(possibly containing embedded white space).
1633Analogous to the effect of
1634\&"$*\&"
1635in Bourne shell.
1636.\" :[0]
1637.It 0
1638Means the same as
1639.Ql Cm \&:[*] .
1640.\" :[*]
1641.It Cm \&@
1642Causes subsequent modifiers to treat the value as a sequence of words
1643delimited by white space.
1644Analogous to the effect of
1645\&"$@\&"
1646in Bourne shell.
1647.\" :[#]
1648.It Cm \&#
1649Returns the number of words in the value.
1650.El \" :[range]
1651.El
1652.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1653Makefile inclusion, conditional structures and for loops reminiscent
1654of the C programming language are provided in
1655.Nm .
1656All such structures are identified by a line beginning with a single
1657dot
1658.Pq Ql \&.
1659character.
1660Files are included with either
1661.Cm \&.include \&< Ns Ar file Ns Cm \&>
1662or
1663.Cm \&.include \&\*q Ns Ar file Ns Cm \&\*q .
1664Variables between the angle brackets or double quotes are expanded
1665to form the file name.
1666If angle brackets are used, the included makefile is expected to be in
1667the system makefile directory.
1668If double quotes are used, the including makefile's directory and any
1669directories specified using the
1670.Fl I
1671option are searched before the system
1672makefile directory.
1673For compatibility with other versions of
1674.Nm
1675.Ql include file ...
1676is also accepted.
1677.Pp
1678If the include statement is written as
1679.Cm .-include
1680or as
1681.Cm .sinclude
1682then errors locating and/or opening include files are ignored.
1683.Pp
1684If the include statement is written as
1685.Cm .dinclude
1686not only are errors locating and/or opening include files ignored,
1687but stale dependencies within the included file will be ignored
1688just like
1689.Va .MAKE.DEPENDFILE .
1690.Pp
1691Conditional expressions are also preceded by a single dot as the first
1692character of a line.
1693The possible conditionals are as follows:
1694.Bl -tag -width Ds
1695.It Ic .error Ar message
1696The message is printed along with the name of the makefile and line number,
1697then
1698.Nm
1699will exit immediately.
1700.It Ic .export Ar variable ...
1701Export the specified global variable.
1702If no variable list is provided, all globals are exported
1703except for internal variables (those that start with
1704.Ql \&. ) .
1705This is not affected by the
1706.Fl X
1707flag, so should be used with caution.
1708For compatibility with other
1709.Nm
1710programs
1711.Ql export variable=value
1712is also accepted.
1713.Pp
1714Appending a variable name to
1715.Va .MAKE.EXPORTED
1716is equivalent to exporting a variable.
1717.It Ic .export-env Ar variable ...
1718The same as
1719.Ql .export ,
1720except that the variable is not appended to
1721.Va .MAKE.EXPORTED .
1722This allows exporting a value to the environment which is different from that
1723used by
1724.Nm
1725internally.
1726.It Ic .export-literal Ar variable ...
1727The same as
1728.Ql .export-env ,
1729except that variables in the value are not expanded.
1730.It Ic .info Ar message
1731The message is printed along with the name of the makefile and line number.
1732.It Ic .undef Ar variable
1733Un-define the specified global variable.
1734Only global variables may be un-defined.
1735.It Ic .unexport Ar variable ...
1736The opposite of
1737.Ql .export .
1738The specified global
1739.Va variable
1740will be removed from
1741.Va .MAKE.EXPORTED .
1742If no variable list is provided, all globals are unexported,
1743and
1744.Va .MAKE.EXPORTED
1745deleted.
1746.It Ic .unexport-env
1747Unexport all globals previously exported and
1748clear the environment inherited from the parent.
1749This operation will cause a memory leak of the original environment,
1750so should be used sparingly.
1751Testing for
1752.Va .MAKE.LEVEL
1753being 0, would make sense.
1754Also note that any variables which originated in the parent environment
1755should be explicitly preserved if desired.
1756For example:
1757.Bd -literal -offset indent
1758.Li .if ${.MAKE.LEVEL} == 0
1759PATH := ${PATH}
1760.Li .unexport-env
1761.Li .export PATH
1762.Li .endif
1763.Pp
1764.Ed
1765Would result in an environment containing only
1766.Ql Ev PATH ,
1767which is the minimal useful environment.
1768Actually
1769.Ql Ev .MAKE.LEVEL
1770will also be pushed into the new environment.
1771.It Ic .warning Ar message
1772The message prefixed by
1773.Ql Pa warning:
1774is printed along with the name of the makefile and line number.
1775.It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ...
1776Test the value of an expression.
1777.It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1778Test the value of a variable.
1779.It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1780Test the value of a variable.
1781.It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1782Test the target being built.
1783.It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ...
1784Test the target being built.
1785.It Ic .else
1786Reverse the sense of the last conditional.
1787.It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ...
1788A combination of
1789.Ql Ic .else
1790followed by
1791.Ql Ic .if .
1792.It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1793A combination of
1794.Ql Ic .else
1795followed by
1796.Ql Ic .ifdef .
1797.It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1798A combination of
1799.Ql Ic .else
1800followed by
1801.Ql Ic .ifndef .
1802.It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1803A combination of
1804.Ql Ic .else
1805followed by
1806.Ql Ic .ifmake .
1807.It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1808A combination of
1809.Ql Ic .else
1810followed by
1811.Ql Ic .ifnmake .
1812.It Ic .endif
1813End the body of the conditional.
1814.El
1815.Pp
1816The
1817.Ar operator
1818may be any one of the following:
1819.Bl -tag -width "Cm XX"
1820.It Cm \&|\&|
1821Logical OR.
1822.It Cm \&&&
1823Logical
1824.Tn AND ;
1825of higher precedence than
1826.Dq \&|\&| .
1827.El
1828.Pp
1829As in C,
1830.Nm
1831will only evaluate a conditional as far as is necessary to determine
1832its value.
1833Parentheses may be used to change the order of evaluation.
1834The boolean operator
1835.Ql Ic \&!
1836may be used to logically negate an entire
1837conditional.
1838It is of higher precedence than
1839.Ql Ic \&&& .
1840.Pp
1841The value of
1842.Ar expression
1843may be any of the following:
1844.Bl -tag -width defined
1845.It Ic defined
1846Takes a variable name as an argument and evaluates to true if the variable
1847has been defined.
1848.It Ic make
1849Takes a target name as an argument and evaluates to true if the target
1850was specified as part of
1851.Nm Ns 's
1852command line or was declared the default target (either implicitly or
1853explicitly, see
1854.Va .MAIN )
1855before the line containing the conditional.
1856.It Ic empty
1857Takes a variable, with possible modifiers, and evaluates to true if
1858the expansion of the variable would result in an empty string.
1859.It Ic exists
1860Takes a file name as an argument and evaluates to true if the file exists.
1861The file is searched for on the system search path (see
1862.Va .PATH ) .
1863.It Ic target
1864Takes a target name as an argument and evaluates to true if the target
1865has been defined.
1866.It Ic commands
1867Takes a target name as an argument and evaluates to true if the target
1868has been defined and has commands associated with it.
1869.El
1870.Pp
1871.Ar Expression
1872may also be an arithmetic or string comparison.
1873Variable expansion is
1874performed on both sides of the comparison, after which the integral
1875values are compared.
1876A value is interpreted as hexadecimal if it is
1877preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1878The standard C relational operators are all supported.
1879If after
1880variable expansion, either the left or right hand side of a
1881.Ql Ic ==
1882or
1883.Ql Ic "!="
1884operator is not an integral value, then
1885string comparison is performed between the expanded
1886variables.
1887If no relational operator is given, it is assumed that the expanded
1888variable is being compared against 0, or an empty string in the case
1889of a string comparison.
1890.Pp
1891When
1892.Nm
1893is evaluating one of these conditional expressions, and it encounters
1894a (white-space separated) word it doesn't recognize, either the
1895.Dq make
1896or
1897.Dq defined
1898expression is applied to it, depending on the form of the conditional.
1899If the form is
1900.Ql Ic .ifdef ,
1901.Ql Ic .ifndef ,
1902or
1903.Ql Ic .if
1904the
1905.Dq defined
1906expression is applied.
1907Similarly, if the form is
1908.Ql Ic .ifmake
1909or
1910.Ql Ic .ifnmake ,
1911the
1912.Dq make
1913expression is applied.
1914.Pp
1915If the conditional evaluates to true the parsing of the makefile continues
1916as before.
1917If it evaluates to false, the following lines are skipped.
1918In both cases this continues until a
1919.Ql Ic .else
1920or
1921.Ql Ic .endif
1922is found.
1923.Pp
1924For loops are typically used to apply a set of rules to a list of files.
1925The syntax of a for loop is:
1926.Pp
1927.Bl -tag -compact -width Ds
1928.It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression
1929.It Aq make-lines
1930.It Ic \&.endfor
1931.El
1932.Pp
1933After the for
1934.Ic expression
1935is evaluated, it is split into words.
1936On each iteration of the loop, one word is taken and assigned to each
1937.Ic variable ,
1938in order, and these
1939.Ic variables
1940are substituted into the
1941.Ic make-lines
1942inside the body of the for loop.
1943The number of words must come out even; that is, if there are three
1944iteration variables, the number of words provided must be a multiple
1945of three.
1946.Sh COMMENTS
1947Comments begin with a hash
1948.Pq Ql \&#
1949character, anywhere but in a shell
1950command line, and continue to the end of an unescaped new line.
1951.Sh SPECIAL SOURCES (ATTRIBUTES)
1952.Bl -tag -width .IGNOREx
1953.It Ic .EXEC
1954Target is never out of date, but always execute commands anyway.
1955.It Ic .IGNORE
1956Ignore any errors from the commands associated with this target, exactly
1957as if they all were preceded by a dash
1958.Pq Ql \- .
1959.\" .It Ic .INVISIBLE
1960.\" XXX
1961.\" .It Ic .JOIN
1962.\" XXX
1963.It Ic .MADE
1964Mark all sources of this target as being up-to-date.
1965.It Ic .MAKE
1966Execute the commands associated with this target even if the
1967.Fl n
1968or
1969.Fl t
1970options were specified.
1971Normally used to mark recursive
1972.Nm Ns s .
1973.It Ic .META
1974Create a meta file for the target, even if it is flagged as
1975.Ic .PHONY ,
1976.Ic .MAKE ,
1977or
1978.Ic .SPECIAL .
1979Usage in conjunction with
1980.Ic .MAKE
1981is the most likely case.
1982In "meta" mode, the target is out-of-date if the meta file is missing.
1983.It Ic .NOMETA
1984Do not create a meta file for the target.
1985Meta files are also not created for
1986.Ic .PHONY ,
1987.Ic .MAKE ,
1988or
1989.Ic .SPECIAL
1990targets.
1991.It Ic .NOMETA_CMP
1992Ignore differences in commands when deciding if target is out of date.
1993This is useful if the command contains a value which always changes.
1994If the number of commands change, though, the target will still be out of date.
1995The same effect applies to any command line that uses the variable
1996.Va .OODATE ,
1997which can be used for that purpose even when not otherwise needed or desired:
1998.Bd -literal -offset indent
1999
2000skip-compare-for-some:
2001	@echo this will be compared
2002	@echo this will not ${.OODATE:M.NOMETA_CMP}
2003	@echo this will also be compared
2004
2005.Ed
2006The
2007.Cm \&:M
2008pattern suppresses any expansion of the unwanted variable.
2009.It Ic .NOPATH
2010Do not search for the target in the directories specified by
2011.Ic .PATH .
2012.It Ic .NOTMAIN
2013Normally
2014.Nm
2015selects the first target it encounters as the default target to be built
2016if no target was specified.
2017This source prevents this target from being selected.
2018.It Ic .OPTIONAL
2019If a target is marked with this attribute and
2020.Nm
2021can't figure out how to create it, it will ignore this fact and assume
2022the file isn't needed or already exists.
2023.It Ic .PHONY
2024The target does not
2025correspond to an actual file; it is always considered to be out of date,
2026and will not be created with the
2027.Fl t
2028option.
2029Suffix-transformation rules are not applied to
2030.Ic .PHONY
2031targets.
2032.It Ic .PRECIOUS
2033When
2034.Nm
2035is interrupted, it normally removes any partially made targets.
2036This source prevents the target from being removed.
2037.It Ic .RECURSIVE
2038Synonym for
2039.Ic .MAKE .
2040.It Ic .SILENT
2041Do not echo any of the commands associated with this target, exactly
2042as if they all were preceded by an at sign
2043.Pq Ql @ .
2044.It Ic .USE
2045Turn the target into
2046.Nm Ns 's
2047version of a macro.
2048When the target is used as a source for another target, the other target
2049acquires the commands, sources, and attributes (except for
2050.Ic .USE )
2051of the
2052source.
2053If the target already has commands, the
2054.Ic .USE
2055target's commands are appended
2056to them.
2057.It Ic .USEBEFORE
2058Exactly like
2059.Ic .USE ,
2060but prepend the
2061.Ic .USEBEFORE
2062target commands to the target.
2063.It Ic .WAIT
2064If
2065.Ic .WAIT
2066appears in a dependency line, the sources that precede it are
2067made before the sources that succeed it in the line.
2068Since the dependents of files are not made until the file itself
2069could be made, this also stops the dependents being built unless they
2070are needed for another branch of the dependency tree.
2071So given:
2072.Bd -literal
2073x: a .WAIT b
2074	echo x
2075a:
2076	echo a
2077b: b1
2078	echo b
2079b1:
2080	echo b1
2081
2082.Ed
2083the output is always
2084.Ql a ,
2085.Ql b1 ,
2086.Ql b ,
2087.Ql x .
2088.br
2089The ordering imposed by
2090.Ic .WAIT
2091is only relevant for parallel makes.
2092.El
2093.Sh SPECIAL TARGETS
2094Special targets may not be included with other targets, i.e. they must be
2095the only target specified.
2096.Bl -tag -width .BEGINx
2097.It Ic .BEGIN
2098Any command lines attached to this target are executed before anything
2099else is done.
2100.It Ic .DEFAULT
2101This is sort of a
2102.Ic .USE
2103rule for any target (that was used only as a
2104source) that
2105.Nm
2106can't figure out any other way to create.
2107Only the shell script is used.
2108The
2109.Ic .IMPSRC
2110variable of a target that inherits
2111.Ic .DEFAULT Ns 's
2112commands is set
2113to the target's own name.
2114.It Ic .DELETE_ON_ERROR
2115If this target is present in the makefile, it globally causes make to
2116delete targets whose commands fail.
2117(By default, only targets whose commands are interrupted during
2118execution are deleted.
2119This is the historical behavior.)
2120This setting can be used to help prevent half-finished or malformed
2121targets from being left around and corrupting future rebuilds.
2122.It Ic .END
2123Any command lines attached to this target are executed after everything
2124else is done.
2125.It Ic .ERROR
2126Any command lines attached to this target are executed when another target fails.
2127The
2128.Ic .ERROR_TARGET
2129variable is set to the target that failed.
2130See also
2131.Ic MAKE_PRINT_VAR_ON_ERROR .
2132.It Ic .IGNORE
2133Mark each of the sources with the
2134.Ic .IGNORE
2135attribute.
2136If no sources are specified, this is the equivalent of specifying the
2137.Fl i
2138option.
2139.It Ic .INTERRUPT
2140If
2141.Nm
2142is interrupted, the commands for this target will be executed.
2143.It Ic .MAIN
2144If no target is specified when
2145.Nm
2146is invoked, this target will be built.
2147.It Ic .MAKEFLAGS
2148This target provides a way to specify flags for
2149.Nm
2150when the makefile is used.
2151The flags are as if typed to the shell, though the
2152.Fl f
2153option will have
2154no effect.
2155.\" XXX: NOT YET!!!!
2156.\" .It Ic .NOTPARALLEL
2157.\" The named targets are executed in non parallel mode.
2158.\" If no targets are
2159.\" specified, then all targets are executed in non parallel mode.
2160.It Ic .NOPATH
2161Apply the
2162.Ic .NOPATH
2163attribute to any specified sources.
2164.It Ic .NOTPARALLEL
2165Disable parallel mode.
2166.It Ic .NO_PARALLEL
2167Synonym for
2168.Ic .NOTPARALLEL ,
2169for compatibility with other pmake variants.
2170.It Ic .OBJDIR
2171The source is a new value for
2172.Ql Va .OBJDIR .
2173If it exists,
2174.Nm
2175will
2176.Xr chdir 2
2177to it and update the value of
2178.Ql Va .OBJDIR .
2179.It Ic .ORDER
2180The named targets are made in sequence.
2181This ordering does not add targets to the list of targets to be made.
2182Since the dependents of a target do not get built until the target itself
2183could be built, unless
2184.Ql a
2185is built by another part of the dependency graph,
2186the following is a dependency loop:
2187.Bd -literal
2188\&.ORDER: b a
2189b: a
2190.Ed
2191.Pp
2192The ordering imposed by
2193.Ic .ORDER
2194is only relevant for parallel makes.
2195.\" XXX: NOT YET!!!!
2196.\" .It Ic .PARALLEL
2197.\" The named targets are executed in parallel mode.
2198.\" If no targets are
2199.\" specified, then all targets are executed in parallel mode.
2200.It Ic .PATH
2201The sources are directories which are to be searched for files not
2202found in the current directory.
2203If no sources are specified, any previously specified directories are
2204deleted.
2205If the source is the special
2206.Ic .DOTLAST
2207target, then the current working
2208directory is searched last.
2209.It Ic .PATH. Ns Va suffix
2210Like
2211.Ic .PATH
2212but applies only to files with a particular suffix.
2213The suffix must have been previously declared with
2214.Ic .SUFFIXES .
2215.It Ic .PHONY
2216Apply the
2217.Ic .PHONY
2218attribute to any specified sources.
2219.It Ic .PRECIOUS
2220Apply the
2221.Ic .PRECIOUS
2222attribute to any specified sources.
2223If no sources are specified, the
2224.Ic .PRECIOUS
2225attribute is applied to every
2226target in the file.
2227.It Ic .SHELL
2228Sets the shell that
2229.Nm
2230will use to execute commands.
2231The sources are a set of
2232.Ar field=value
2233pairs.
2234.Bl -tag -width hasErrCtls
2235.It Ar name
2236This is the minimal specification, used to select one of the built-in
2237shell specs;
2238.Ar sh ,
2239.Ar ksh ,
2240and
2241.Ar csh .
2242.It Ar path
2243Specifies the path to the shell.
2244.It Ar hasErrCtl
2245Indicates whether the shell supports exit on error.
2246.It Ar check
2247The command to turn on error checking.
2248.It Ar ignore
2249The command to disable error checking.
2250.It Ar echo
2251The command to turn on echoing of commands executed.
2252.It Ar quiet
2253The command to turn off echoing of commands executed.
2254.It Ar filter
2255The output to filter after issuing the
2256.Ar quiet
2257command.
2258It is typically identical to
2259.Ar quiet .
2260.It Ar errFlag
2261The flag to pass the shell to enable error checking.
2262.It Ar echoFlag
2263The flag to pass the shell to enable command echoing.
2264.It Ar newline
2265The string literal to pass the shell that results in a single newline
2266character when used outside of any quoting characters.
2267.El
2268Example:
2269.Bd -literal
2270\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e
2271	check="set \-e" ignore="set +e" \e
2272	echo="set \-v" quiet="set +v" filter="set +v" \e
2273	echoFlag=v errFlag=e newline="'\en'"
2274.Ed
2275.It Ic .SILENT
2276Apply the
2277.Ic .SILENT
2278attribute to any specified sources.
2279If no sources are specified, the
2280.Ic .SILENT
2281attribute is applied to every
2282command in the file.
2283.It Ic .STALE
2284This target gets run when a dependency file contains stale entries, having
2285.Va .ALLSRC
2286set to the name of that dependency file.
2287.It Ic .SUFFIXES
2288Each source specifies a suffix to
2289.Nm .
2290If no sources are specified, any previously specified suffixes are deleted.
2291It allows the creation of suffix-transformation rules.
2292.Pp
2293Example:
2294.Bd -literal
2295\&.SUFFIXES: .o
2296\&.c.o:
2297	cc \-o ${.TARGET} \-c ${.IMPSRC}
2298.Ed
2299.El
2300.Sh ENVIRONMENT
2301.Nm
2302uses the following environment variables, if they exist:
2303.Ev MACHINE ,
2304.Ev MACHINE_ARCH ,
2305.Ev MAKE ,
2306.Ev MAKEFLAGS ,
2307.Ev MAKEOBJDIR ,
2308.Ev MAKEOBJDIRPREFIX ,
2309.Ev MAKESYSPATH ,
2310.Ev PWD ,
2311and
2312.Ev TMPDIR .
2313.Pp
2314.Ev MAKEOBJDIRPREFIX
2315and
2316.Ev MAKEOBJDIR
2317may only be set in the environment or on the command line to
2318.Nm
2319and not as makefile variables;
2320see the description of
2321.Ql Va .OBJDIR
2322for more details.
2323.Sh FILES
2324.Bl -tag -width /usr/share/mk -compact
2325.It .depend
2326list of dependencies
2327.It Makefile
2328list of dependencies
2329.It makefile
2330list of dependencies
2331.It sys.mk
2332system makefile
2333.It /usr/share/mk
2334system makefile directory
2335.El
2336.Sh COMPATIBILITY
2337The basic make syntax is compatible between different versions of make;
2338however the special variables, variable modifiers and conditionals are not.
2339.Ss Older versions
2340An incomplete list of changes in older versions of
2341.Nm :
2342.Pp
2343The way that .for loop variables are substituted changed after
2344.Nx 5.0
2345so that they still appear to be variable expansions.
2346In particular this stops them being treated as syntax, and removes some
2347obscure problems using them in .if statements.
2348.Pp
2349The way that parallel makes are scheduled changed in
2350.Nx 4.0
2351so that .ORDER and .WAIT apply recursively to the dependent nodes.
2352The algorithms used may change again in the future.
2353.Ss Other make dialects
2354Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
2355support most of the features of
2356.Nm
2357as described in this manual.
2358Most notably:
2359.Bl -bullet -offset indent
2360.It
2361The
2362.Ic .WAIT
2363and
2364.Ic .ORDER
2365declarations and most functionality pertaining to parallelization.
2366(GNU make supports parallelization but lacks these features needed to
2367control it effectively.)
2368.It
2369Directives, including for loops and conditionals and most of the
2370forms of include files.
2371(GNU make has its own incompatible and less powerful syntax for
2372conditionals.)
2373.It
2374All built-in variables that begin with a dot.
2375.It
2376Most of the special sources and targets that begin with a dot,
2377with the notable exception of
2378.Ic .PHONY ,
2379.Ic .PRECIOUS ,
2380and
2381.Ic .SUFFIXES .
2382.It
2383Variable modifiers, except for the
2384.Dl :old=new
2385string substitution, which does not portably support globbing with
2386.Ql %
2387and historically only works on declared suffixes.
2388.It
2389The
2390.Ic $>
2391variable even in its short form; most makes support this functionality
2392but its name varies.
2393.El
2394.Pp
2395Some features are somewhat more portable, such as assignment with
2396.Ic += ,
2397.Ic ?= ,
2398and
2399.Ic != .
2400The
2401.Ic .PATH
2402functionality is based on an older feature
2403.Ic VPATH
2404found in GNU make and many versions of SVR4 make; however,
2405historically its behavior is too ill-defined (and too buggy) to rely
2406upon.
2407.Pp
2408The
2409.Ic $@
2410and
2411.Ic $<
2412variables are more or less universally portable, as is the
2413.Ic $(MAKE)
2414variable.
2415Basic use of suffix rules (for files only in the current directory,
2416not trying to chain transformations together, etc.) is also reasonably
2417portable.
2418.Sh SEE ALSO
2419.Xr mkdep 1
2420.Sh HISTORY
2421A
2422.Nm
2423command appeared in
2424.At v7 .
2425This
2426.Nm
2427implementation is based on Adam De Boor's pmake program which was written
2428for Sprite at Berkeley.
2429It was designed to be a parallel distributed make running jobs on different
2430machines using a daemon called
2431.Dq customs .
2432.Pp
2433Historically the target/dependency
2434.Dq FRC
2435has been used to FoRCe rebuilding (since the target/dependency
2436does not exist... unless someone creates an
2437.Dq FRC
2438file).
2439.Sh BUGS
2440The
2441.Nm
2442syntax is difficult to parse without actually acting on the data.
2443For instance, finding the end of a variable's use should involve scanning
2444each of the modifiers, using the correct terminator for each field.
2445In many places
2446.Nm
2447just counts {} and () in order to find the end of a variable expansion.
2448.Pp
2449There is no way of escaping a space character in a filename.
2450