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