xref: /netbsd-src/usr.bin/make/make.1 (revision 274254cdae52594c1aa480a736aef78313d15c9c)
1.\"	$NetBSD: make.1,v 1.153 2009/01/24 13:02:33 wiz 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 January 24, 2009
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 BeikNnqrstWX
41.Bk -words
42.Op Fl D Ar variable
43.Ek
44.Bk -words
45.Op Fl d Ar flags
46.Ek
47.Bk -words
48.Op Fl f Ar makefile
49.Ek
50.Bk -words
51.Op Fl I Ar directory
52.Ek
53.Bk -words
54.Op Fl J Ar private
55.Ek
56.Bk -words
57.Op Fl j Ar max_jobs
58.Ek
59.Bk -words
60.Op Fl m Ar directory
61.Ek
62.Bk -words
63.Op Fl T Ar file
64.Ek
65.Bk -words
66.Op Fl V Ar variable
67.Ek
68.Op Ar variable=value
69.Bk -words
70.Op Ar target ...
71.Ek
72.Sh DESCRIPTION
73.Nm
74is a program designed to simplify the maintenance of other programs.
75Its input is a list of specifications as to the files upon which programs
76and other files depend.
77If no
78.Fl f Ar makefile
79makefile option is given,
80.Nm
81will try to open
82.Ql Pa makefile
83then
84.Ql Pa Makefile
85in order to find the specifications.
86If the file
87.Ql Pa .depend
88exists, it is read (see
89.Xr mkdep 1 ) .
90.Pp
91This manual page is intended as a reference document only.
92For a more thorough description of
93.Nm
94and makefiles, please refer to
95.%T "Make \- A Tutorial" .
96.Pp
97.Nm
98will prepend the contents of the
99.Va MAKEFLAGS
100environment variable to the command line arguments before parsing them.
101.Pp
102The options are as follows:
103.Bl -tag -width Ds
104.It Fl B
105Try to be backwards compatible by executing a single shell per command and
106by executing the commands to make the sources of a dependency line in sequence.
107.It Fl D Ar variable
108Define
109.Ar variable
110to be 1, in the global context.
111.It Fl d Ar [-]flags
112Turn on debugging, and specify which portions of
113.Nm
114are to print debugging information.
115Unless the flags are preceded by
116.Ql -
117they are added to the
118.Va MAKEFLAGS
119environment variable and will be processed by any child make processes.
120By default, debugging information is printed to standard error,
121but this can be changed using the
122.Ar F
123debugging flag.
124The debugging output is always unbuffered; in addition, if debugging
125is enabled but debugging output is not directed to standard output,
126then the standard output is line buffered.
127.Ar Flags
128is one or more of the following:
129.Bl -tag -width Ds
130.It Ar A
131Print all possible debugging information;
132equivalent to specifying all of the debugging flags.
133.It Ar a
134Print debugging information about archive searching and caching.
135.It Ar C
136Print debugging information about current working directory.
137.It Ar c
138Print debugging information about conditional evaluation.
139.It Ar d
140Print debugging information about directory searching and caching.
141.It Ar e
142Print debugging information about failed commands and targets.
143.It Ar F Ns Oo Sy \&+ Oc Ns Ar filename
144Specify where debugging output is written.
145This must be the last flag, because it consumes the remainder of
146the argument.
147If the character immediately after the
148.Ql F
149flag is
150.Ql \&+ ,
151then the file will be opened in append mode;
152otherwise the file will be overwritten.
153If the file name is
154.Ql stdout
155or
156.Ql stderr
157then debugging output will be written to the
158standard output or standard error output file descriptors respectively
159(and the
160.Ql \&+
161option has no effect).
162Otherwise, the output will be written to the named file.
163If the file name ends
164.Ql .%d
165then the
166.Ql %d
167is replaced by the pid.
168.It Ar f
169Print debugging information about loop evaluation.
170.It Ar "g1"
171Print the input graph before making anything.
172.It Ar "g2"
173Print the input graph after making everything, or before exiting
174on error.
175.It Ar "g3"
176Print the input graph before exiting on error.
177.It Ar j
178Print debugging information about running multiple shells.
179.It Ar l
180Print commands in Makefiles regardless of whether or not they are prefixed by
181.Ql @
182or other "quiet" flags.
183Also known as "loud" behavior.
184.It Ar m
185Print debugging information about making targets, including modification
186dates.
187.It Ar n
188Don't delete the temporary command scripts created in
189.Pa /tmp
190when running commands.
191These are created via
192.Xr mkstemp 3
193and have names of the form
194.Pa /tmp/makeXXXXX .
195.Em NOTE :
196This can create many file in
197.Pa /tmp
198so use with care.
199.It Ar p
200Print debugging information about makefile parsing.
201.It Ar s
202Print debugging information about suffix-transformation rules.
203.It Ar t
204Print debugging information about target list maintenance.
205.It Ar v
206Print debugging information about variable assignment.
207.It Ar x
208Run shell commands with
209.Fl x
210so the actual commands are printed as they are executed.
211.El
212.It Fl e
213Specify that environment variables override macro assignments within
214makefiles.
215.It Fl f Ar makefile
216Specify a makefile to read instead of the default
217.Ql Pa makefile .
218If
219.Ar makefile
220is
221.Ql Fl ,
222standard input is read.
223Multiple makefiles may be specified, and are read in the order specified.
224.It Fl I Ar directory
225Specify a directory in which to search for makefiles and included makefiles.
226The system makefile directory (or directories, see the
227.Fl m
228option) is automatically included as part of this list.
229.It Fl i
230Ignore non-zero exit of shell commands in the makefile.
231Equivalent to specifying
232.Ql Fl
233before each command line in the makefile.
234.It Fl J Ar private
235This option should
236.Em not
237be specified by the user.
238.Pp
239When the
240.Ar j
241option is in use in a recursive build, this option is passed by a make
242to child makes to allow all the make processes in the build to
243cooperate to avoid overloading the system.
244.It Fl j Ar max_jobs
245Specify the maximum number of jobs that
246.Nm
247may have running at any one time.
248Turns compatibility mode off, unless the
249.Ar B
250flag is also specified.
251When compatibility mode is off, all commands associated with a
252target are executed in a single shell invocation as opposed to the
253traditional one shell invocation per line.
254This can break traditional scripts which change directories on each
255command invocation and then expect to start with a fresh environment
256on the next line.
257It is more efficient to correct the scripts rather than turn backwards
258compatibility on.
259.It Fl k
260Continue processing after errors are encountered, but only on those targets
261that do not depend on the target whose creation caused the error.
262.It Fl m Ar directory
263Specify a directory in which to search for sys.mk and makefiles included
264via the
265.Ao Ar file Ac Ns -style
266include statement.
267The
268.Fl m
269option can be used multiple times to form a search path.
270This path will override the default system include path: /usr/share/mk.
271Furthermore the system include path will be appended to the search path used
272for
273.Qo Ar file Qc Ns -style
274include statements (see the
275.Fl I
276option).
277.Pp
278If a file or directory name in the
279.Fl m
280argument (or the
281.Ev MAKESYSPATH
282environment variable) starts with the string
283.Qq \&.../
284then
285.Nm
286will search for the specified file or directory named in the remaining part
287of the argument string.
288The search starts with the current directory of
289the Makefile and then works upward towards the root of the filesystem.
290If the search is successful, then the resulting directory replaces the
291.Qq \&.../
292specification in the
293.Fl m
294argument.
295If used, this feature allows
296.Nm
297to easily search in the current source tree for customized sys.mk files
298(e.g., by using
299.Qq \&.../mk/sys.mk
300as an argument).
301.It Fl n
302Display the commands that would have been executed, but do not
303actually execute them unless the target depends on the .MAKE special
304source (see below).
305.It Fl N
306Display the commands which would have been executed, but do not
307actually execute any of them; useful for debugging top-level makefiles
308without descending into subdirectories.
309.It Fl q
310Do not execute any commands, but exit 0 if the specified targets are
311up-to-date and 1, otherwise.
312.It Fl r
313Do not use the built-in rules specified in the system makefile.
314.It Fl s
315Do not echo any commands as they are executed.
316Equivalent to specifying
317.Ql Ic @
318before each command line in the makefile.
319.It Fl T Ar tracefile
320When used with the
321.Fl j
322flag,
323append a trace record to
324.Ar tracefile
325for each job started and completed.
326.It Fl t
327Rather than re-building a target as specified in the makefile, create it
328or update its modification time to make it appear up-to-date.
329.It Fl V Ar variable
330Print
331.Nm Ns 's
332idea of the value of
333.Ar variable ,
334in the global context.
335Do not build any targets.
336Multiple instances of this option may be specified;
337the variables will be printed one per line,
338with a blank line for each null or undefined variable.
339If
340.Ar variable
341contains a
342.Ql \&$
343then the value will be expanded before printing.
344.It Fl W
345Treat any warnings during makefile parsing as errors.
346.It Fl X
347Don't export variables passed on the command line to the environment
348individually.
349Variables passed on the command line are still exported
350via the
351.Va MAKEFLAGS
352environment variable.
353This option may be useful on systems which have a small limit on the
354size of command arguments.
355.It Ar variable=value
356Set the value of the variable
357.Ar variable
358to
359.Ar value .
360Normally, all values passed on the command line are also exported to
361sub-makes in the environment.
362The
363.Fl X
364flag disables this behavior.
365Variable assignments should follow options for POSIX compatibility
366but no ordering is enforced.
367.El
368.Pp
369There are seven different types of lines in a makefile: file dependency
370specifications, shell commands, variable assignments, include statements,
371conditional directives, for loops, and comments.
372.Pp
373In general, lines may be continued from one line to the next by ending
374them with a backslash
375.Pq Ql \e .
376The trailing newline character and initial whitespace on the following
377line are compressed into a single space.
378.Sh FILE DEPENDENCY SPECIFICATIONS
379Dependency lines consist of one or more targets, an operator, and zero
380or more sources.
381This creates a relationship where the targets
382.Dq depend
383on the sources
384and are usually created from them.
385The exact relationship between the target and the source is determined
386by the operator that separates them.
387The three operators are as follows:
388.Bl -tag -width flag
389.It Ic \&:
390A target is considered out-of-date if its modification time is less than
391those of any of its sources.
392Sources for a target accumulate over dependency lines when this operator
393is used.
394The target is removed if
395.Nm
396is interrupted.
397.It Ic \&!
398Targets are always re-created, but not until all sources have been
399examined and re-created as necessary.
400Sources for a target accumulate over dependency lines when this operator
401is used.
402The target is removed if
403.Nm
404is interrupted.
405.It Ic \&::
406If no sources are specified, the target is always re-created.
407Otherwise, a target is considered out-of-date if any of its sources has
408been modified more recently than the target.
409Sources for a target do not accumulate over dependency lines when this
410operator is used.
411The target will not be removed if
412.Nm
413is interrupted.
414.El
415.Pp
416Targets and sources may contain the shell wildcard values
417.Ql \&? ,
418.Ql * ,
419.Ql [] ,
420and
421.Ql {} .
422The values
423.Ql \&? ,
424.Ql * ,
425and
426.Ql []
427may only be used as part of the final
428component of the target or source, and must be used to describe existing
429files.
430The value
431.Ql {}
432need not necessarily be used to describe existing files.
433Expansion is in directory order, not alphabetically as done in the shell.
434.Sh SHELL COMMANDS
435Each target may have associated with it a series of shell commands, normally
436used to create the target.
437Each of the commands in this script
438.Em must
439be preceded by a tab.
440While any target may appear on a dependency line, only one of these
441dependencies may be followed by a creation script, unless the
442.Ql Ic \&::
443operator is used.
444.Pp
445If the first characters of the command line are any combination of
446.Ql Ic @ ,
447.Ql Ic + ,
448or
449.Ql Ic \- ,
450the command is treated specially.
451A
452.Ql Ic @
453causes the command not to be echoed before it is executed.
454A
455.Ql Ic +
456causes the command to be executed even when
457.Fl n
458is given.
459This is similar to the effect of the .MAKE special source,
460except that the effect can be limited to a single line of a script.
461A
462.Ql Ic \-
463causes any non-zero exit status of the command line to be ignored.
464.Sh VARIABLE ASSIGNMENTS
465Variables in make are much like variables in the shell, and, by tradition,
466consist of all upper-case letters.
467.Ss Variable assignment modifiers
468The five operators that can be used to assign values to variables are as
469follows:
470.Bl -tag -width Ds
471.It Ic \&=
472Assign the value to the variable.
473Any previous value is overridden.
474.It Ic \&+=
475Append the value to the current value of the variable.
476.It Ic \&?=
477Assign the value to the variable if it is not already defined.
478.It Ic \&:=
479Assign with expansion, i.e. expand the value before assigning it
480to the variable.
481Normally, expansion is not done until the variable is referenced.
482.Em NOTE :
483References to undefined variables are
484.Em not
485expanded.
486This can cause problems when variable modifiers are used.
487.It Ic \&!=
488Expand the value and pass it to the shell for execution and assign
489the result to the variable.
490Any newlines in the result are replaced with spaces.
491.El
492.Pp
493Any white-space before the assigned
494.Ar value
495is removed; if the value is being appended, a single space is inserted
496between the previous contents of the variable and the appended value.
497.Pp
498Variables are expanded by surrounding the variable name with either
499curly braces
500.Pq Ql {}
501or parentheses
502.Pq Ql ()
503and preceding it with
504a dollar sign
505.Pq Ql \&$ .
506If the variable name contains only a single letter, the surrounding
507braces or parentheses are not required.
508This shorter form is not recommended.
509.Pp
510If the variable name contains a dollar, then the name itself is expanded first.
511This allows almost arbitrary variable names, however names containing dollar,
512braces, parenthesis, or whitespace are really best avoided!
513.Pp
514If the result of expanding a variable contains a dollar sign
515.Pq Ql \&$
516the string is expanded again.
517.Pp
518Variable substitution occurs at two distinct times, depending on where
519the variable is being used.
520Variables in dependency lines are expanded as the line is read.
521Variables in shell commands are expanded when the shell command is
522executed.
523.Ss Variable classes
524The four different classes of variables (in order of increasing precedence)
525are:
526.Bl -tag -width Ds
527.It Environment variables
528Variables defined as part of
529.Nm Ns 's
530environment.
531.It Global variables
532Variables defined in the makefile or in included makefiles.
533.It Command line variables
534Variables defined as part of the command line.
535.It Local variables
536Variables that are defined specific to a certain target.
537The seven local variables are as follows:
538.Bl -tag -width ".ARCHIVE"
539.It Va .ALLSRC
540The list of all sources for this target; also known as
541.Ql Va \&\*[Gt] .
542.It Va .ARCHIVE
543The name of the archive file.
544.It Va .IMPSRC
545In suffix-transformation rules, the name/path of the source from which the
546target is to be transformed (the
547.Dq implied
548source); also known as
549.Ql Va \&\*[Lt] .
550It is not defined in explicit rules.
551.It Va .MEMBER
552The name of the archive member.
553.It Va .OODATE
554The list of sources for this target that were deemed out-of-date; also
555known as
556.Ql Va \&? .
557.It Va .PREFIX
558The file prefix of the file, containing only the file portion, no suffix
559or preceding directory components; also known as
560.Ql Va * .
561.It Va .TARGET
562The name of the target; also known as
563.Ql Va @ .
564.El
565.Pp
566The shorter forms
567.Ql Va @ ,
568.Ql Va \&? ,
569.Ql Va \&\*[Lt] ,
570.Ql Va \&\*[Gt] ,
571and
572.Ql Va *
573are permitted for backward
574compatibility with historical makefiles and are not recommended.
575The six variables
576.Ql Va "@F" ,
577.Ql Va "@D" ,
578.Ql Va "\*[Lt]F" ,
579.Ql Va "\*[Lt]D" ,
580.Ql Va "*F" ,
581and
582.Ql Va "*D"
583are permitted for compatibility with
584.At V
585makefiles and are not recommended.
586.Pp
587Four of the local variables may be used in sources on dependency lines
588because they expand to the proper value for each target on the line.
589These variables are
590.Ql Va .TARGET ,
591.Ql Va .PREFIX ,
592.Ql Va .ARCHIVE ,
593and
594.Ql Va .MEMBER .
595.El
596.Ss Additional built-in variables
597In addition,
598.Nm
599sets or knows about the following variables:
600.Bl -tag -width .MAKEOVERRIDES
601.It Va \&$
602A single dollar sign
603.Ql \&$ ,
604i.e.
605.Ql \&$$
606expands to a single dollar
607sign.
608.It Va .ALLTARGETS
609The list of all targets encountered in the Makefile.
610If evaluated during
611Makefile parsing, lists only those targets encountered thus far.
612.It Va .CURDIR
613A path to the directory where
614.Nm
615was executed.
616Refer to the description of
617.Ql Ev PWD
618for more details.
619.It Ev MAKE
620The name that
621.Nm
622was executed with
623.Pq Va argv[0] .
624For compatibility
625.Nm
626also sets
627.Va .MAKE
628with the same value.
629The preferred variable to use is the environment variable
630.Ev MAKE
631because it is more compatible with other versions of
632.Nm
633and cannot be confused with the special target with the same name.
634.It Va .MAKE.EXPORTED
635The list of variables exported by
636.Nm .
637.It Va .MAKE.MAKEFILES
638The list of makefiles read by
639.Nm ,
640which is useful for tracking dependencies.
641Each makefile is recorded only once, regardless of the number of times read.
642.It Va .MAKE.PID
643The process-id of
644.Nm .
645.It Va .MAKE.PPID
646The parent process-id of
647.Nm .
648.It Va .MAKE.JOB.PREFIX
649If
650.Nm
651is run with
652.Ar j
653then output for each target is prefixed with a token
654.Ql --- target ---
655the first part of which can be controlled via
656.Va .MAKE.JOB.PREFIX .
657.br
658For example:
659.Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
660would produce tokens like
661.Ql ---make[1234] target ---
662making it easier to track the degree of parallelism being achieved.
663.It Ev MAKEFLAGS
664The environment variable
665.Ql Ev MAKEFLAGS
666may contain anything that
667may be specified on
668.Nm Ns 's
669command line.
670Anything specified on
671.Nm Ns 's
672command line is appended to the
673.Ql Ev MAKEFLAGS
674variable which is then
675entered into the environment for all programs which
676.Nm
677executes.
678.It Va .MAKEOVERRIDES
679This variable is used to record the names of variables assigned to
680on the command line, so that they may be exported as part of
681.Ql Ev MAKEFLAGS .
682This behaviour can be disabled by assigning an empty value to
683.Ql Va .MAKEOVERRIDES
684within a makefile.
685Extra variables can be exported from a makefile
686by appending their names to
687.Ql Va .MAKEOVERRIDES .
688.Ql Ev MAKEFLAGS
689is re-exported whenever
690.Ql Va .MAKEOVERRIDES
691is modified.
692.It Va MAKE_PRINT_VAR_ON_ERROR
693When
694.Nm
695stops due to an error, it prints its name and the value of
696.Ql Va .CURDIR
697as well as the value of any variables named in
698.Ql Va MAKE_PRINT_VAR_ON_ERROR .
699.It Va .newline
700This variable is simply assigned a newline character as its value.
701This allows expansions using the
702.Cm \&:@
703modifier to put a newline between
704iterations of the loop rather than a space.
705For example, the printing of
706.Ql Va MAKE_PRINT_VAR_ON_ERROR
707could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
708.It Va .OBJDIR
709A path to the directory where the targets are built.
710Its value is determined by trying to
711.Xr chdir 2
712to the following directories in order and using the first match:
713.Bl -enum
714.It
715.Ev ${MAKEOBJDIRPREFIX}${.CURDIR}
716.Pp
717(Only if
718.Ql Ev MAKEOBJDIRPREFIX
719is set in the environment or on the command line.)
720.It
721.Ev ${MAKEOBJDIR}
722.Pp
723(Only if
724.Ql Ev MAKEOBJDIR
725is set in the environment or on the command line.)
726.It
727.Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE}
728.It
729.Ev ${.CURDIR} Ns Pa /obj
730.It
731.Pa /usr/obj/ Ns Ev ${.CURDIR}
732.It
733.Ev ${.CURDIR}
734.El
735.Pp
736Variable expansion is performed on the value before it's used,
737so expressions such as
738.Dl ${.CURDIR:C,^/usr/src,/var/obj,}
739may be used.
740.Pp
741.Ql Va .OBJDIR
742may be modified in the makefile as a global variable.
743In all cases,
744.Nm
745will
746.Xr chdir 2
747to
748.Ql Va .OBJDIR
749and set
750.Ql Ev PWD
751to that directory before executing any targets.
752.
753.It Va .PARSEDIR
754A path to the directory of the current
755.Ql Pa Makefile
756being parsed.
757.It Va .PARSEFILE
758The basename of the current
759.Ql Pa Makefile
760being parsed.
761This variable and
762.Ql Va .PARSEDIR
763are both set only while the
764.Ql Pa Makefiles
765are being parsed.
766.It Va .PATH
767A variable that represents the list of directories that
768.Nm
769will search for files.
770The search list should be updated using the target
771.Ql Va .PATH
772rather than the variable.
773.It Ev PWD
774Alternate path to the current directory.
775.Nm
776normally sets
777.Ql Va .CURDIR
778to the canonical path given by
779.Xr getcwd 3 .
780However, if the environment variable
781.Ql Ev PWD
782is set and gives a path to the current directory, then
783.Nm
784sets
785.Ql Va .CURDIR
786to the value of
787.Ql Ev PWD
788instead.
789This behaviour is disabled if
790.Ql Ev MAKEOBJDIRPREFIX
791is set or
792.Ql Ev MAKEOBJDIR
793contains a variable transform.
794.Ql Ev PWD
795is set to the value of
796.Ql Va .OBJDIR
797for all programs which
798.Nm
799executes.
800.It Ev VPATH
801Colon-separated
802.Pq Dq \&:
803lists of directories that
804.Nm
805will search for files.
806The variable is supported for compatibility with old make programs only,
807use
808.Ql Va .PATH
809instead.
810.El
811.Ss Variable modifiers
812Variable expansion may be modified to select or modify each word of the
813variable (where a
814.Dq word
815is white-space delimited sequence of characters).
816The general format of a variable expansion is as follows:
817.Pp
818.Dl ${variable[:modifier[:...]]}
819.Pp
820Each modifier begins with a colon,
821which may be escaped with a backslash
822.Pq Ql \e .
823.Pp
824A set of modifiers can be specified via a variable, as follows:
825.Pp
826.Dl modifier_variable=modifier[:...]
827.Dl ${variable:${modifier_variable}[:...]}
828.Pp
829In this case the first modifier in the modifier_variable does not
830start with a colon, since that must appear in the referencing
831variable.
832If any of the modifiers in the modifier_variable contain a dollar sign
833.Pq Ql $ ,
834these must be doubled to avoid early expansion.
835.Pp
836The supported modifiers are:
837.Bl -tag -width EEE
838.It Cm \&:E
839Replaces each word in the variable with its suffix.
840.It Cm \&:H
841Replaces each word in the variable with everything but the last component.
842.It Cm \&:M Ns Ar pattern
843Select only those words that match
844.Ar pattern .
845The standard shell wildcard characters
846.Pf ( Ql * ,
847.Ql \&? ,
848and
849.Ql Op )
850may
851be used.
852The wildcard characters may be escaped with a backslash
853.Pq Ql \e .
854.It Cm \&:N Ns Ar pattern
855This is identical to
856.Ql Cm \&:M ,
857but selects all words which do not match
858.Ar pattern .
859.It Cm \&:O
860Order every word in variable alphabetically.
861To sort words in
862reverse order use the
863.Ql Cm \&:O:[-1..1]
864combination of modifiers.
865.It Cm \&:Ox
866Randomize words in variable.
867The results will be different each time you are referring to the
868modified variable; use the assignment with expansion
869.Pq Ql Cm \&:=
870to prevent such behaviour.
871For example,
872.Bd -literal -offset indent
873LIST=			uno due tre quattro
874RANDOM_LIST=		${LIST:Ox}
875STATIC_RANDOM_LIST:=	${LIST:Ox}
876
877all:
878	@echo "${RANDOM_LIST}"
879	@echo "${RANDOM_LIST}"
880	@echo "${STATIC_RANDOM_LIST}"
881	@echo "${STATIC_RANDOM_LIST}"
882.Ed
883may produce output similar to:
884.Bd -literal -offset indent
885quattro due tre uno
886tre due quattro uno
887due uno quattro tre
888due uno quattro tre
889.Ed
890.It Cm \&:Q
891Quotes every shell meta-character in the variable, so that it can be passed
892safely through recursive invocations of
893.Nm .
894.It Cm \&:R
895Replaces each word in the variable with everything but its suffix.
896.It Cm \&:tl
897Converts variable to lower-case letters.
898.It Cm \&:ts Ns Ar c
899Words in the variable are normally separated by a space on expansion.
900This modifier sets the separator to the character
901.Ar c .
902If
903.Ar c
904is omitted, then no separator is used.
905.It Cm \&:tu
906Converts variable to upper-case letters.
907.It Cm \&:tW
908Causes the value to be treated as a single word
909(possibly containing embedded white space).
910See also
911.Ql Cm \&:[*] .
912.It Cm \&:tw
913Causes the value to be treated as a sequence of
914words delimited by white space.
915See also
916.Ql Cm \&:[@] .
917.Sm off
918.It Cm \&:S No \&/ Ar old_string Xo
919.No \&/ Ar new_string
920.No \&/ Op Cm 1gW
921.Xc
922.Sm on
923Modify the first occurrence of
924.Ar old_string
925in the variable's value, replacing it with
926.Ar new_string .
927If a
928.Ql g
929is appended to the last slash of the pattern, all occurrences
930in each word are replaced.
931If a
932.Ql 1
933is appended to the last slash of the pattern, only the first word
934is affected.
935If a
936.Ql W
937is appended to the last slash of the pattern,
938then the value is treated as a single word
939(possibly containing embedded white space).
940If
941.Ar old_string
942begins with a caret
943.Pq Ql ^ ,
944.Ar old_string
945is anchored at the beginning of each word.
946If
947.Ar old_string
948ends with a dollar sign
949.Pq Ql \&$ ,
950it is anchored at the end of each word.
951Inside
952.Ar new_string ,
953an ampersand
954.Pq Ql \*[Am]
955is replaced by
956.Ar old_string
957(without any
958.Ql ^
959or
960.Ql \&$ ) .
961Any character may be used as a delimiter for the parts of the modifier
962string.
963The anchoring, ampersand and delimiter characters may be escaped with a
964backslash
965.Pq Ql \e .
966.Pp
967Variable expansion occurs in the normal fashion inside both
968.Ar old_string
969and
970.Ar new_string
971with the single exception that a backslash is used to prevent the expansion
972of a dollar sign
973.Pq Ql \&$ ,
974not a preceding dollar sign as is usual.
975.Sm off
976.It Cm \&:C No \&/ Ar pattern Xo
977.No \&/ Ar replacement
978.No \&/ Op Cm 1gW
979.Xc
980.Sm on
981The
982.Cm \&:C
983modifier is just like the
984.Cm \&:S
985modifier except that the old and new strings, instead of being
986simple strings, are a regular expression (see
987.Xr regex 3 )
988string
989.Ar pattern
990and an
991.Xr ed 1 Ns \-style
992string
993.Ar replacement .
994Normally, the first occurrence of the pattern
995.Ar pattern
996in each word of the value is substituted with
997.Ar replacement .
998The
999.Ql 1
1000modifier causes the substitution to apply to at most one word; the
1001.Ql g
1002modifier causes the substitution to apply to as many instances of the
1003search pattern
1004.Ar pattern
1005as occur in the word or words it is found in; the
1006.Ql W
1007modifier causes the value to be treated as a single word
1008(possibly containing embedded white space).
1009Note that
1010.Ql 1
1011and
1012.Ql g
1013are orthogonal; the former specifies whether multiple words are
1014potentially affected, the latter whether multiple substitutions can
1015potentially occur within each affected word.
1016.It Cm \&:T
1017Replaces each word in the variable with its last component.
1018.It Cm \&:u
1019Remove adjacent duplicate words (like
1020.Xr uniq 1 ) .
1021.Sm off
1022.It Cm \&:\&? Ar true_string Cm \&: Ar false_string
1023.Sm on
1024If the variable name (not its value), when parsed as a .if conditional
1025expression, evaluates to true, return as its value the
1026.Ar true_string ,
1027otherwise return the
1028.Ar false_string .
1029Since the variable name is used as the expression, \&:\&? must be the
1030first modifier after the variable name itself - which will, of course,
1031usually contain variable expansions.
1032If the expression is a single token, it will likely be treated as a check
1033for the name being defined.
1034.It Ar :old_string=new_string
1035This is the
1036.At V
1037style variable substitution.
1038It must be the last modifier specified.
1039If
1040.Ar old_string
1041or
1042.Ar new_string
1043do not contain the pattern matching character
1044.Ar %
1045then it is assumed that they are
1046anchored at the end of each word, so only suffixes or entire
1047words may be replaced.
1048Otherwise
1049.Ar %
1050is the substring of
1051.Ar old_string
1052to be replaced in
1053.Ar new_string .
1054.Pp
1055Variable expansion occurs in the normal fashion inside both
1056.Ar old_string
1057and
1058.Ar new_string
1059with the single exception that a backslash is used to prevent the
1060expansion of a dollar sign
1061.Pq Ql \&$ ,
1062not a preceding dollar sign as is usual.
1063.Sm off
1064.It Cm \&:@ Ar temp Cm @ Xo
1065.Ar string Cm @
1066.Sm on
1067.Xc
1068This is the loop expansion mechanism from the OSF Development
1069Environment (ODE) make.
1070Unlike
1071.Cm \&.for
1072loops expansion occurs at the time of
1073reference.
1074Assign
1075.Ar temp
1076to each word in the variable and evaluate
1077.Ar string .
1078The ODE convention is that
1079.Ar temp
1080should start and end with a period.
1081For example.
1082.Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1083.It Cm \&:U Ns Ar newval
1084If the variable is undefined
1085.Ar newval
1086is the value.
1087If the variable is defined, the existing value is returned.
1088This is another ODE make feature.
1089It is handy for setting per-target CFLAGS for instance:
1090.Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1091If a value is only required if the variable is undefined, use:
1092.Dl ${VAR:D:Unewval}
1093.It Cm \&:D Ns Ar newval
1094If the variable is defined
1095.Ar newval
1096is the value.
1097.It Cm \&:L
1098The name of the variable is the value.
1099.It Cm \&:P
1100The path of the node which has the same name as the variable
1101is the value.
1102If no such node exists or its path is null, then the
1103name of the variable is used.
1104.Sm off
1105.It Cm \&:\&! Ar cmd Cm \&!
1106.Sm on
1107The output of running
1108.Ar cmd
1109is the value.
1110.It Cm \&:sh
1111If the variable is non-empty it is run as a command and the output
1112becomes the new value.
1113.It Cm \&::= Ns Ar str
1114The variable is assigned the value
1115.Ar str
1116after substitution.
1117This modifier and its variations are useful in
1118obscure situations such as wanting to set a variable when shell commands
1119are being parsed.
1120These assignment modifiers always expand to
1121nothing, so if appearing in a rule line by themselves should be
1122preceded with something to keep
1123.Nm
1124happy.
1125.Pp
1126The
1127.Ql Cm \&::
1128helps avoid false matches with the
1129.At V
1130style
1131.Cm \&:=
1132modifier and since substitution always occurs the
1133.Cm \&::=
1134form is vaguely appropriate.
1135.It Cm \&::?= Ns Ar str
1136As for
1137.Cm \&::=
1138but only if the variable does not already have a value.
1139.It Cm \&::+= Ns Ar str
1140Append
1141.Ar str
1142to the variable.
1143.It Cm \&::!= Ns Ar cmd
1144Assign the output of
1145.Ar cmd
1146to the variable.
1147.It Cm \&:\&[ Ns Ar range Ns Cm \&]
1148Selects one or more words from the value,
1149or performs other operations related to the way in which the
1150value is divided into words.
1151.Pp
1152Ordinarily, a value is treated as a sequence of words
1153delimited by white space.
1154Some modifiers suppress this behaviour,
1155causing a value to be treated as a single word
1156(possibly containing embedded white space).
1157An empty value, or a value that consists entirely of white-space,
1158is treated as a single word.
1159For the purposes of the
1160.Ql Cm \&:[]
1161modifier, the words are indexed both forwards using positive integers
1162(where index 1 represents the first word),
1163and backwards using negative integers
1164(where index -1 represents the last word).
1165.Pp
1166The
1167.Ar range
1168is subjected to variable expansion, and the expanded result is
1169then interpreted as follows:
1170.Bl -tag -width index
1171.\" :[n]
1172.It Ar index
1173Selects a single word from the value.
1174.\" :[start..end]
1175.It Ar start Ns Cm \&.. Ns Ar end
1176Selects all words from
1177.Ar start
1178to
1179.Ar end ,
1180inclusive.
1181For example,
1182.Ql Cm \&:[2..-1]
1183selects all words from the second word to the last word.
1184If
1185.Ar start
1186is greater than
1187.Ar end ,
1188then the words are output in reverse order.
1189For example,
1190.Ql Cm \&:[-1..1]
1191selects all the words from last to first.
1192.\" :[*]
1193.It Cm \&*
1194Causes subsequent modifiers to treat the value as a single word
1195(possibly containing embedded white space).
1196Analogous to the effect of
1197\&"$*\&"
1198in Bourne shell.
1199.\" :[0]
1200.It 0
1201Means the same as
1202.Ql Cm \&:[*] .
1203.\" :[*]
1204.It Cm \&@
1205Causes subsequent modifiers to treat the value as a sequence of words
1206delimited by white space.
1207Analogous to the effect of
1208\&"$@\&"
1209in Bourne shell.
1210.\" :[#]
1211.It Cm \&#
1212Returns the number of words in the value.
1213.El \" :[range]
1214.El
1215.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1216Makefile inclusion, conditional structures and for loops  reminiscent
1217of the C programming language are provided in
1218.Nm .
1219All such structures are identified by a line beginning with a single
1220dot
1221.Pq Ql \&.
1222character.
1223Files are included with either
1224.Cm \&.include Aq Ar file
1225or
1226.Cm \&.include Pf \*q Ar file Ns \*q .
1227Variables between the angle brackets or double quotes are expanded
1228to form the file name.
1229If angle brackets are used, the included makefile is expected to be in
1230the system makefile directory.
1231If double quotes are used, the including makefile's directory and any
1232directories specified using the
1233.Fl I
1234option are searched before the system
1235makefile directory.
1236For compatibility with other versions of
1237.Nm
1238.Ql include file ...
1239is also accepted.
1240If the include statement is written as
1241.Cm .-include
1242or as
1243.Cm .sinclude
1244then errors locating and/or opening include files are ignored.
1245.Pp
1246Conditional expressions are also preceded by a single dot as the first
1247character of a line.
1248The possible conditionals are as follows:
1249.Bl -tag -width Ds
1250.It Ic .export Ar variable
1251Export the specified global variable.
1252If no variable is provided, all globals are exported
1253except for internal variables (those that start with
1254.Ql \&.
1255).
1256This is not affected by the
1257.Fl X
1258flag, so should be used with caution.
1259Appending a variable name to
1260.Va .MAKE.EXPORTED
1261is equivalent to exporting a variable.
1262.It Ic .undef Ar variable
1263Un-define the specified global variable.
1264Only global variables may be un-defined.
1265.It Xo
1266.Ic \&.if
1267.Oo \&! Oc Ns Ar expression
1268.Op Ar operator expression ...
1269.Xc
1270Test the value of an expression.
1271.It Xo
1272.Ic .ifdef
1273.Oo \&! Oc Ns Ar variable
1274.Op Ar operator variable ...
1275.Xc
1276Test the value of a variable.
1277.It Xo
1278.Ic .ifndef
1279.Oo \&! Oc Ns Ar variable
1280.Op Ar operator variable ...
1281.Xc
1282Test the value of a variable.
1283.It Xo
1284.Ic .ifmake
1285.Oo \&! Oc Ns Ar target
1286.Op Ar operator target ...
1287.Xc
1288Test the target being built.
1289.It Xo
1290.Ic .ifnmake
1291.Oo \&! Ns Oc Ar target
1292.Op Ar operator target ...
1293.Xc
1294Test the target being built.
1295.It Ic .else
1296Reverse the sense of the last conditional.
1297.It Xo
1298.Ic .elif
1299.Oo \&! Ns Oc Ar expression
1300.Op Ar operator expression ...
1301.Xc
1302A combination of
1303.Ql Ic .else
1304followed by
1305.Ql Ic .if .
1306.It Xo
1307.Ic .elifdef
1308.Oo \&! Oc Ns Ar variable
1309.Op Ar operator variable ...
1310.Xc
1311A combination of
1312.Ql Ic .else
1313followed by
1314.Ql Ic .ifdef .
1315.It Xo
1316.Ic .elifndef
1317.Oo \&! Oc Ns Ar variable
1318.Op Ar operator variable ...
1319.Xc
1320A combination of
1321.Ql Ic .else
1322followed by
1323.Ql Ic .ifndef .
1324.It Xo
1325.Ic .elifmake
1326.Oo \&! Oc Ns Ar target
1327.Op Ar operator target ...
1328.Xc
1329A combination of
1330.Ql Ic .else
1331followed by
1332.Ql Ic .ifmake .
1333.It Xo
1334.Ic .elifnmake
1335.Oo \&! Oc Ns Ar target
1336.Op Ar operator target ...
1337.Xc
1338A combination of
1339.Ql Ic .else
1340followed by
1341.Ql Ic .ifnmake .
1342.It Ic .endif
1343End the body of the conditional.
1344.El
1345.Pp
1346The
1347.Ar operator
1348may be any one of the following:
1349.Bl -tag -width "Cm XX"
1350.It Cm \&|\&|
1351Logical OR.
1352.It Cm \&\*[Am]\*[Am]
1353Logical
1354.Tn AND ;
1355of higher precedence than
1356.Dq \&|\&| .
1357.El
1358.Pp
1359As in C,
1360.Nm
1361will only evaluate a conditional as far as is necessary to determine
1362its value.
1363Parentheses may be used to change the order of evaluation.
1364The boolean operator
1365.Ql Ic \&!
1366may be used to logically negate an entire
1367conditional.
1368It is of higher precedence than
1369.Ql Ic \&\*[Am]\*[Am] .
1370.Pp
1371The value of
1372.Ar expression
1373may be any of the following:
1374.Bl -tag -width defined
1375.It Ic defined
1376Takes a variable name as an argument and evaluates to true if the variable
1377has been defined.
1378.It Ic make
1379Takes a target name as an argument and evaluates to true if the target
1380was specified as part of
1381.Nm Ns 's
1382command line or was declared the default target (either implicitly or
1383explicitly, see
1384.Va .MAIN )
1385before the line containing the conditional.
1386.It Ic empty
1387Takes a variable, with possible modifiers, and evaluates to true if
1388the expansion of the variable would result in an empty string.
1389.It Ic exists
1390Takes a file name as an argument and evaluates to true if the file exists.
1391The file is searched for on the system search path (see
1392.Va .PATH ) .
1393.It Ic target
1394Takes a target name as an argument and evaluates to true if the target
1395has been defined.
1396.It Ic commands
1397Takes a target name as an argument and evaluates to true if the target
1398has been defined and has commands associated with it.
1399.El
1400.Pp
1401.Ar Expression
1402may also be an arithmetic or string comparison.
1403Variable expansion is
1404performed on both sides of the comparison, after which the integral
1405values are compared.
1406A value is interpreted as hexadecimal if it is
1407preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1408The standard C relational operators are all supported.
1409If after
1410variable expansion, either the left or right hand side of a
1411.Ql Ic ==
1412or
1413.Ql Ic "!="
1414operator is not an integral value, then
1415string comparison is performed between the expanded
1416variables.
1417If no relational operator is given, it is assumed that the expanded
1418variable is being compared against 0 or an empty string in the case
1419of a string comparison.
1420.Pp
1421When
1422.Nm
1423is evaluating one of these conditional expressions, and it encounters
1424a (white-space separated) word it doesn't recognize, either the
1425.Dq make
1426or
1427.Dq defined
1428expression is applied to it, depending on the form of the conditional.
1429If the form is
1430.Ql Ic .ifdef ,
1431.Ql Ic .ifndef ,
1432or
1433.Ql Ic .if
1434the
1435.Dq defined
1436expression is applied.
1437Similarly, if the form is
1438.Ql Ic .ifmake
1439or
1440.Ql Ic .ifnmake , the
1441.Dq make
1442expression is applied.
1443.Pp
1444If the conditional evaluates to true the parsing of the makefile continues
1445as before.
1446If it evaluates to false, the following lines are skipped.
1447In both cases this continues until a
1448.Ql Ic .else
1449or
1450.Ql Ic .endif
1451is found.
1452.Pp
1453For loops are typically used to apply a set of rules to a list of files.
1454The syntax of a for loop is:
1455.Pp
1456.Bl -tag -compact -width Ds
1457.It Xo
1458.Ic \&.for
1459.Ar variable
1460.Op Ar variable ...
1461.Ic in
1462.Ar expression
1463.Xc
1464.It Aq make-rules
1465.It Ic \&.endfor
1466.El
1467.Pp
1468After the for
1469.Ic expression
1470is evaluated, it is split into words.
1471On each iteration of the loop, one word is taken and assigned to each
1472.Ic variable ,
1473in order, and these
1474.Ic variables
1475are substituted into the
1476.Ic make-rules
1477inside the body of the for loop.
1478The number of words must come out even; that is, if there are three
1479iteration variables, the number of words provided must be a multiple
1480of three.
1481.Sh COMMENTS
1482Comments begin with a hash
1483.Pq Ql \&#
1484character, anywhere but in a shell
1485command line, and continue to the end of an unescaped new line.
1486.Sh SPECIAL SOURCES (ATTRIBUTES)
1487.Bl -tag -width .IGNOREx
1488.It Ic .EXEC
1489Target is never out of date, but always execute commands anyway.
1490.It Ic .IGNORE
1491Ignore any errors from the commands associated with this target, exactly
1492as if they all were preceded by a dash
1493.Pq Ql \- .
1494.\" .It Ic .INVISIBLE
1495.\" XXX
1496.\" .It Ic .JOIN
1497.\" XXX
1498.It Ic .MADE
1499Mark all sources of this target as being up-to-date.
1500.It Ic .MAKE
1501Execute the commands associated with this target even if the
1502.Fl n
1503or
1504.Fl t
1505options were specified.
1506Normally used to mark recursive
1507.Nm Ns 's .
1508.It Ic .NOPATH
1509Do not search for the target in the directories specified by
1510.Ic .PATH .
1511.It Ic .NOTMAIN
1512Normally
1513.Nm
1514selects the first target it encounters as the default target to be built
1515if no target was specified.
1516This source prevents this target from being selected.
1517.It Ic .OPTIONAL
1518If a target is marked with this attribute and
1519.Nm
1520can't figure out how to create it, it will ignore this fact and assume
1521the file isn't needed or already exists.
1522.It Ic .PHONY
1523The target does not
1524correspond to an actual file; it is always considered to be out of date,
1525and will not be created with the
1526.Fl t
1527option.
1528.It Ic .PRECIOUS
1529When
1530.Nm
1531is interrupted, it normally removes any partially made targets.
1532This source prevents the target from being removed.
1533.It Ic .RECURSIVE
1534Synonym for
1535.Ic .MAKE .
1536.It Ic .SILENT
1537Do not echo any of the commands associated with this target, exactly
1538as if they all were preceded by an at sign
1539.Pq Ql @ .
1540.It Ic .USE
1541Turn the target into
1542.Nm Ns 's
1543version of a macro.
1544When the target is used as a source for another target, the other target
1545acquires the commands, sources, and attributes (except for
1546.Ic .USE )
1547of the
1548source.
1549If the target already has commands, the
1550.Ic .USE
1551target's commands are appended
1552to them.
1553.It Ic .USEBEFORE
1554Exactly like
1555.Ic .USE ,
1556but prepend the
1557.Ic .USEBEFORE
1558target commands to the target.
1559.It Ic .WAIT
1560If
1561.Ic .WAIT
1562appears in a dependency line, the sources that precede it are
1563made before the sources that succeed it in the line.
1564Since the dependents of files are not made until the file itself
1565could be made, this also stops the dependents being built unless they
1566are needed for another branch of the dependency tree.
1567So given:
1568.Bd -literal
1569x: a .WAIT b
1570	echo x
1571a:
1572	echo a
1573b: b1
1574	echo b
1575b1:
1576	echo b1
1577
1578.Ed
1579the output is always
1580.Ql a ,
1581.Ql b1 ,
1582.Ql b ,
1583.Ql x .
1584.br
1585The ordering imposed by
1586.Ic .WAIT
1587is only relevant for parallel makes.
1588.El
1589.Sh SPECIAL TARGETS
1590Special targets may not be included with other targets, i.e. they must be
1591the only target specified.
1592.Bl -tag -width .BEGINx
1593.It Ic .BEGIN
1594Any command lines attached to this target are executed before anything
1595else is done.
1596.It Ic .DEFAULT
1597This is sort of a
1598.Ic .USE
1599rule for any target (that was used only as a
1600source) that
1601.Nm
1602can't figure out any other way to create.
1603Only the shell script is used.
1604The
1605.Ic .IMPSRC
1606variable of a target that inherits
1607.Ic .DEFAULT Ns 's
1608commands is set
1609to the target's own name.
1610.It Ic .END
1611Any command lines attached to this target are executed after everything
1612else is done.
1613.It Ic .IGNORE
1614Mark each of the sources with the
1615.Ic .IGNORE
1616attribute.
1617If no sources are specified, this is the equivalent of specifying the
1618.Fl i
1619option.
1620.It Ic .INTERRUPT
1621If
1622.Nm
1623is interrupted, the commands for this target will be executed.
1624.It Ic .MAIN
1625If no target is specified when
1626.Nm
1627is invoked, this target will be built.
1628.It Ic .MAKEFLAGS
1629This target provides a way to specify flags for
1630.Nm
1631when the makefile is used.
1632The flags are as if typed to the shell, though the
1633.Fl f
1634option will have
1635no effect.
1636.\" XXX: NOT YET!!!!
1637.\" .It Ic .NOTPARALLEL
1638.\" The named targets are executed in non parallel mode.
1639.\" If no targets are
1640.\" specified, then all targets are executed in non parallel mode.
1641.It Ic .NOPATH
1642Apply the
1643.Ic .NOPATH
1644attribute to any specified sources.
1645.It Ic .NOTPARALLEL
1646Disable parallel mode.
1647.It Ic .NO_PARALLEL
1648Synonym for
1649.Ic .NOTPARALLEL ,
1650for compatibility with other pmake variants.
1651.It Ic .ORDER
1652The named targets are made in sequence.
1653This ordering does not add targets to the list of targets to be made.
1654Since the dependents of a target do not get built until the target itself
1655could be built, unless
1656.Ql a
1657is built by another part of the dependency graph,
1658the following is a dependency loop:
1659.Bd -literal
1660\&.ORDER a b
1661b: a
1662.Ed
1663.Pp
1664The ordering imposed by
1665.Ic .ORDER
1666is only relevant for parallel makes.
1667.\" XXX: NOT YET!!!!
1668.\" .It Ic .PARALLEL
1669.\" The named targets are executed in parallel mode.
1670.\" If no targets are
1671.\" specified, then all targets are executed in parallel mode.
1672.It Ic .PATH
1673The sources are directories which are to be searched for files not
1674found in the current directory.
1675If no sources are specified, any previously specified directories are
1676deleted.
1677If the source is the special
1678.Ic .DOTLAST
1679target, then the current working
1680directory is searched last.
1681.It Ic .PHONY
1682Apply the
1683.Ic .PHONY
1684attribute to any specified sources.
1685.It Ic .PRECIOUS
1686Apply the
1687.Ic .PRECIOUS
1688attribute to any specified sources.
1689If no sources are specified, the
1690.Ic .PRECIOUS
1691attribute is applied to every
1692target in the file.
1693.It Ic .SHELL
1694Sets the shell that
1695.Nm
1696will use to execute commands.
1697The sources are a set of
1698.Ar field=value
1699pairs.
1700.Bl -tag -width hasErrCtls
1701.It Ar name
1702This is the minimal specification, used to select one of the builtin
1703shell specs;
1704.Ar sh ,
1705.Ar ksh ,
1706and
1707.Ar csh .
1708.It Ar path
1709Specifies the path to the shell.
1710.It Ar hasErrCtl
1711Indicates whether the shell supports exit on error.
1712.It Ar check
1713The command to turn on error checking.
1714.It Ar ignore
1715The command to disable error checking.
1716.It Ar echo
1717The command to turn on echoing of commands executed.
1718.It Ar quiet
1719The command to turn off echoing of commands executed.
1720.It Ar filter
1721The output to filter after issuing the
1722.Ar quiet
1723command.
1724It is typically identical to
1725.Ar quiet .
1726.It Ar errFlag
1727The flag to pass the shell to enable error checking.
1728.It Ar echoFlag
1729The flag to pass the shell to enable command echoing.
1730.It Ar newline
1731The string literal to pass the shell that results in a single newline
1732character when used outside of any quoting characters.
1733.El
1734Example:
1735.Bd -literal
1736\&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \\
1737	check="set -e" ignore="set +e" \\
1738	echo="set -v" quiet="set +v" filter="set +v" \\
1739	echoFlag=v errFlag=e newline="'\\n'"
1740.Ed
1741.It Ic .SILENT
1742Apply the
1743.Ic .SILENT
1744attribute to any specified sources.
1745If no sources are specified, the
1746.Ic .SILENT
1747attribute is applied to every
1748command in the file.
1749.It Ic .SUFFIXES
1750Each source specifies a suffix to
1751.Nm .
1752If no sources are specified, any previously specified suffixes are deleted.
1753It allows the creation of suffix-transformation rules.
1754.Pp
1755Example:
1756.Bd -literal
1757\&.SUFFIXES: .o
1758\&.c.o:
1759	cc -o ${.TARGET} -c ${.IMPSRC}
1760.Ed
1761.El
1762.Sh ENVIRONMENT
1763.Nm
1764uses the following environment variables, if they exist:
1765.Ev MACHINE ,
1766.Ev MACHINE_ARCH ,
1767.Ev MAKE ,
1768.Ev MAKEFLAGS ,
1769.Ev MAKEOBJDIR ,
1770.Ev MAKEOBJDIRPREFIX ,
1771.Ev MAKESYSPATH ,
1772and
1773.Ev PWD .
1774.Pp
1775.Ev MAKEOBJDIRPREFIX
1776and
1777.Ev MAKEOBJDIR
1778may only be set in the environment or on the command line to
1779.Nm
1780and not as makefile variables;
1781see the description of
1782.Ql Va .OBJDIR
1783for more details.
1784.Sh FILES
1785.Bl -tag -width /usr/share/mk -compact
1786.It .depend
1787list of dependencies
1788.It Makefile
1789list of dependencies
1790.It makefile
1791list of dependencies
1792.It sys.mk
1793system makefile
1794.It /usr/share/mk
1795system makefile directory
1796.El
1797.Sh COMPATIBILITY
1798The basic make syntax is compatible between different versions of make,
1799however the special variables, variable modifiers and conditionals are not.
1800.Pp
1801The way that parallel makes are scheduled changed in
1802.Nx 4.0
1803so that .ORDER and .WAIT apply recursively to the dependant nodes.
1804The algorithms used may change again in the future.
1805.Pp
1806The way that .for loop variables are substituted changed after
1807.Nx 5.0
1808so that they still appear to be variable expansions.
1809In particular this stops them being treated as syntax, and removes some
1810obscure problems using them in .if statements.
1811.Sh SEE ALSO
1812.Xr mkdep 1
1813.Sh HISTORY
1814A
1815.Nm
1816command appeared in
1817.At v7 .
1818.Sh BUGS
1819The
1820.Nm
1821syntax is difficult to parse without actually acting of the data.
1822For instance finding the end of a variable use should involve scanning each
1823the modifiers using the correct terminator for each field.
1824In many places
1825.Nm
1826just counts {} and () in order to find the end of a variable expansion.
1827.Pp
1828There is no way of escaping a space character in a filename.
1829