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