xref: /openbsd/usr.bin/make/make.1 (revision 4bdff4be)
1.\"	$OpenBSD: make.1,v 1.141 2023/08/10 10:56:34 espie Exp $
2.\"	$NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
3.\"
4.\" Copyright (c) 1990, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
32.\"
33.Dd $Mdocdate: August 10 2023 $
34.Dt MAKE 1
35.Os
36.Sh NAME
37.Nm make
38.Nd maintain program dependencies
39.Sh SYNOPSIS
40.Nm make
41.Op Fl BeiknpqrSst
42.Op Fl C Ar directory
43.Op Fl D Ar variable
44.Op Fl d Ar flags
45.Op Fl f Ar mk
46.Op Fl I Ar directory
47.Op Fl j Ar max_jobs
48.Op Fl m Ar directory
49.Op Fl V Ar variable
50.Op Ar NAME Ns = Ns Ar value ...
51.Bk -words
52.Op Ar target ...
53.Ek
54.Sh DESCRIPTION
55.Nm
56is a program designed to simplify the maintenance of other programs.
57Its input is a
58.Em makefile :
59a list of specifications (target rules) describing build
60relationships between programs and other files.
61By default, the file
62.Pa makefile
63is used;
64if no such file is found, it tries
65.Pa Makefile .
66If neither of these exist,
67.Nm
68can still rely on a set of built-in system rules.
69.Pp
70If the file
71.Sq Pa .depend
72exists, it will also be read after the main
73.Ar makefile
74(see
75.Xr mkdep 1 ) .
76.Pp
77The handling of
78.Sq Pa .depend
79is a
80.Bx
81extension.
82.Pp
83If a list of
84.Ar target ...
85is specified,
86.Nm
87will build those targets.
88Otherwise a default target will be built:
89either a target explicitly marked with
90.Ic .MAIN
91or the first target encountered in the
92.Em makefile .
93.Pp
94Standard options are as follows:
95.Bl -tag -width Ds
96.It Fl e
97Environment variables override macro assignments within
98makefiles.
99.It Fl f Ar mk
100Read file
101.Ar mk
102instead of the default makefile.
103If
104.Ar mk
105is
106.Ql \- ,
107standard input is used.
108Multiple makefiles may be specified, and are read in the order specified.
109.It Fl i
110Ignore non-zero exit of shell commands in the makefile.
111Equivalent to specifying
112.Ql \-
113before each command line in the makefile.
114.It Fl k
115Continue processing after errors are encountered, but only on those targets
116that do not depend on the target whose creation caused the error.
117.It Fl n
118Display the commands that would have been executed, but do not actually
119execute them.
120.It Fl p
121Print a dump of the target rules and variables on stdout.
122Do not build anything.
123.It Fl q
124Do not execute any commands, but exit with status 0 if the specified targets
125are up to date, and 1 otherwise.
126.It Fl r
127Do not use the built-in rules specified in the system makefile,
128.Pa <sys.mk> .
129.It Fl S
130Stop processing when an error is encountered.
131This is the default behavior.
132This is needed to negate the
133.Fl k
134option during recursive builds.
135.It Fl s
136Do not echo commands as they are executed.
137Equivalent to specifying
138.Sq Ic @
139before each command line in the makefile.
140.It Fl t
141Rather than re-building a target as specified in the makefile, create it
142or update its modification time to make it appear up to date, a bit like
143.Xr touch 1 .
144.It Ar NAME Ns = Ns Ar value
145Set the value of the variable
146.Ar NAME
147to
148.Ar value .
149.El
150.Pp
151Extended options are as follows:
152.Bl -tag -width Ds
153.It Fl B
154Try to be backwards compatible by executing the commands to make
155the prerequisites in a target rule in sequence.
156This is the default, in the absence of
157.Fl j Ar max_jobs .
158.It Fl C Ar directory
159Enter
160.Ar directory
161before doing anything.
162.It Fl D Ar variable
163Define
164.Ar variable
165to be 1.
166.It Fl d Ar flags
167Turn on debugging, and specify which portions of
168.Nm
169are to print debugging information.
170.Ar flags
171is one or more of the following:
172.Bl -tag -width Ds
173.It Ar A
174Print all possible debugging information;
175equivalent to specifying all of the debugging flags.
176.It Ar a
177Print debugging information about archive searching and caching.
178.It Ar c
179Print debugging information about conditional evaluation.
180.It Ar d
181Print debugging information about directory searching and caching.
182.It Ar D
183Print warning messages about multiply defined command lists.
184.It Ar e
185Print debugging information about expensive command heuristics.
186.It Ar f
187Print debugging information about the expansion of for loops.
188.It Ar "g1"
189Print the input graph before making anything.
190.It Ar "g2"
191Print the input graph after making everything, or before exiting
192on error.
193.It Ar h
194Print information about jobs being held back because of sibling/target
195groups races.
196.It Ar j
197Print debugging information about forking processes to run commands.
198.It Ar k
199Print debugging information about manually killing processes.
200.It Ar l
201Print commands in Makefile targets regardless of whether or not they are
202prefixed by @.
203Also known as loud behavior.
204.It Ar m
205Print debugging information about making targets, including modification
206dates.
207.It Ar n
208Print debugging information about target names equivalence computations.
209.It Ar p
210Help finding concurrency issues for parallel make by adding some
211randomization.
212If
213.Va RANDOM_ORDER
214is defined,
215targets will be shuffled before being built.
216If
217.Va RANDOM_DELAY
218is defined,
219.Nm
220will wait between 0 and ${RANDOM_DELAY} seconds before starting a command.
221A given random seed can be forced by setting
222.Va RANDOM_SEED ,
223but this does not guarantee reproducibility.
224.It Ar q
225.Sq quick death
226option: after a fatal error, instead of waiting for other jobs to die,
227kill them right away.
228.It Ar s
229Print debugging information about inference (suffix) transformation rules.
230.It Ar t
231Print debugging information about target list maintenance.
232.It Ar T
233Print debugging information about target group determination.
234.It Ar v
235Print debugging information about variable assignment.
236.El
237.It Fl I Ar directory
238Specify a directory in which to search for makefiles and
239for "..."-style inclusions.
240Multiple directories can be added to form a search path.
241Furthermore, the system include path (see the
242.Fl m
243option) will be used after this search path.
244.It Fl j Ar max_jobs
245Specify the maximum number of jobs that
246.Nm
247may have running at any one time.
248See the discussion about recursive invocations under
249.Sx BUGS .
250.It Fl m Ar directory
251Specify a directory in which to search for system include files:
252.Pa sys.mk
253and <...>-style inclusions.
254Multiple directories can be added to form the system search path.
255Using
256.Fl m
257will override the default system include directory
258.Pa /usr/share/mk .
259.It Fl V Ar variable
260Print
261.Nm make Ns 's
262idea of the value of
263.Ar variable .
264Do not build any targets.
265Multiple instances of this option may be specified;
266the variables will be printed one per line,
267with a blank line for each null or undefined variable.
268.El
269.Pp
270There are seven different types of lines in a makefile: dependency
271lines, shell commands, variable assignments, include statements,
272conditional directives, for loops, and comments.
273Of these, include statements, conditional directives and for loops are
274extensions.
275.Pp
276A complete target rule is composed of a dependency line,
277followed by a list of shell commands.
278.Pp
279In general, lines may be continued from one line to the next by ending
280them with a backslash
281.Pq Ql \e .
282The trailing newline character and initial whitespace on the following
283line are compressed into a single space.
284.Sh DEPENDENCY LINES
285Dependency lines consist of one or more targets, an operator, and zero
286or more prerequisites:
287.Bd -ragged -offset indent
288.Ar target ... : Ns Op Ar prerequisite ...
289.Ed
290.Pp
291This creates a relationship where the targets
292.Dq depend
293on the prerequisites and are usually built from them.
294The exact relationship between targets and prerequisites is determined
295by the operator that separates them.
296.Pp
297It is an error to use different dependency operators for the same target.
298.Pp
299The operators are as follows:
300.Bl -tag -width flag
301.It Ic \&:
302A target is considered out of date if any of its prerequisites has
303been modified more recently than the target (that is, its modification time
304is less than that of any of its prerequisites).
305Thus, targets with no prerequisites are always out of date.
306.Pp
307.Nm
308will then execute the list of shell commands associated with that target.
309.Pp
310Additional prerequisites may be specified over additional dependency lines:
311.Nm
312will consider all prerequisites for determining out-of-date status.
313The target is removed if
314.Nm
315is interrupted.
316.It Ic \&!
317.Nm
318first examines all prerequisites and re-creates them as necessary.
319.Pp
320It will then always execute the list of shell commands associated with
321that target (as if the target always was out of date).
322.Pp
323Like
324.Ic \&: ,
325additional prerequisites may be specified over additional dependency lines,
326and the target is still removed if
327.Nm
328is interrupted.
329.It Ic \&::
330Each dependency line for a target is considered independently.
331A target is considered out of date for this target rule if any of its
332prerequisites in this dependency has been modified more recently than
333the target.
334.Pp
335.Nm
336will then execute the list of shell commands associated with that target.
337Target rules that specify no prerequisites are always executed.
338.Pp
339The target will not be removed if
340.Nm
341is interrupted.
342.El
343.Pp
344The
345.Ic \&:
346operator is the only standard operator.
347The
348.Ic \&::
349operator is a fairly standard extension,
350popularized by
351.Sy imake .
352The
353.Ic !\&
354operator is a
355.Bx
356extension.
357.Pp
358As an extension, targets and prerequisites may contain the shell wildcard
359expressions
360.Ql \&? ,
361.Ql * ,
362.Ql []
363and
364.Ql {} .
365The expressions
366.Ql \&? ,
367.Ql *
368and
369.Ql []
370may only be used as part of the final
371component of the target or prerequisite, and must be used to describe existing
372files.
373The expression
374.Ql {}
375need not necessarily be used to describe existing files.
376Expansion is in directory order, not alphabetically as done in the shell.
377.Pp
378For maximum portability, target names should only consist of periods,
379underscores, digits and alphabetic characters.
380.Pp
381The use of several targets can be a shorthand for duplicate rules.
382Specifically,
383.Bd -literal -offset indent
384target1 target2: reqa reqa
385	cmd1
386	cmd2
387.Ed
388.Pp
389may be replaced with
390.Bd -literal -offset indent
391target1: reqa reqa
392	cmd1
393	cmd2
394target2: reqa reqa
395	cmd1
396	cmd2
397.Ed
398.Pp
399in general.
400But
401.Nm
402is aware of parallel issues, and will not build those targets concurrently,
403if not appropriate.
404.Sh SHELL COMMANDS
405Each target may have associated with it a series of shell commands, normally
406used to build the target.
407While several dependency lines may name the same target, only one of
408these dependency lines should be followed by shell commands, and thus
409define a complete target rule (unless the
410.Sq Ic ::
411operator is used).
412Each of the shell commands in the target rule
413.Em must
414be preceded by a tab.
415.Pp
416If a command line begins with a combination of the characters,
417.Sq Ic @ ,
418.Sq Ic \-
419and/or
420.Sq Ic + ,
421the command is treated specially:
422.Bl -tag -width `@'
423.It Sq Ic @
424causes the command not to be echoed before it is executed.
425.It Sq Ic \-
426causes any non-zero exit status of the command line to be ignored.
427.It Sq Ic +
428causes the command to be executed even if
429.Fl n
430has been specified.
431(This can be useful to debug recursive Makefiles.)
432.El
433.Pp
434Commands are executed using
435.Pa /bin/sh
436in
437.Qq set -e
438mode, unless
439.Sq Ic \-
440is specified.
441.Pp
442As an optimization,
443.Nm
444may execute very simple commands without going through an extra shell
445process, as long as this does not change observable behavior.
446.Sh INFERENCE RULES
447.Nm
448also maintains a list of valid suffixes through the use of the
449.Ic .SUFFIXES
450special target.
451.Pp
452These suffixes can be used to write generic transformation rules called
453inference rules.
454.Pp
455If a target has the form
456.Sq \&.s1.s2 ,
457where .s1 and .s2 are currently valid suffixes, then it defines a
458transformation from *.s1 to *.s2 (double suffix inference).
459If a target has the form
460.Sq \&.s1 ,
461where .s1 is a currently valid suffix, then it defines a
462transformation from *.s1 to * (single suffix inference).
463.Pp
464A complete inference rule is a dependency line with such a target, the
465normal dependency operator, no prerequisites and a list of shell commands.
466.Pp
467When
468.Nm
469requires a target for which it has no complete target rule, it will try
470to apply a single active inference rule to create the target.
471.Pp
472For instance, with the following Makefile, describing a C program compiled
473from sources a.c and b.c, with header file a.h:
474.Bd -literal -offset indent
475\&.SUFFIXES: .c .o
476\&.c.o:
477	${CC} ${CFLAGS} -c $<
478
479prog: a.o b.o
480	${CC} ${CFLAGS} -o $@ a.o b.o
481
482a.o b.o: a.h
483
484b.o: b.c
485	${CC} -DFOO ${CFLAGS} -o $@ $<
486.Ed
487.Pp
488Consider b.o:
489there is a complete target rule re-creating it from b.c, so
490it will be compiled using ${CC} -DFOO.
491.Pp
492Consider a.o:
493there is no explicit target rule, so
494.Nm
495will consider valid transforms.
496Fortunately, there is an inference rule that can create a.o from a.c,
497so it will be compiled using ${CC}.
498.Pp
499Note that extra prerequisites are still taken into account, so both a.o
500and b.o depend on a.h for re-creation.
501.Pp
502Valid suffixes accumulate over
503.Ic .SUFFIXES
504lines.
505An empty
506.Ic .SUFFIXES
507can be used to reset the currently valid list of suffixes,
508but inference rules already read are still known by
509.Nm ,
510and they are marked as inactive.
511Redefining the corresponding suffix (or suffixes) will reactivate the rule.
512.Pp
513In case of duplicate inference rules with the same suffix combination,
514the new rule overrides the old one.
515.Pp
516For maximal portability, suffixes should start with a dot.
517.Sh VARIABLE ASSIGNMENTS
518Variables in
519.Nm
520are much like variables in the shell and, by tradition,
521consist of all upper-case letters.
522They are also called
523.Sq macros
524in various texts.
525For portability, only periods, underscores, digits and letters should be
526used for variable names.
527The following operators can be used to assign values to variables:
528.Bl -tag -width Ds
529.It Ic \&=
530Assign the value to the variable.
531Any previous value is overridden.
532.It Ic \&:=
533Assign with expansion, i.e., expand the value before assigning it
534to the variable (extension).
535.It Ic \&+=
536Append the value to the current value of the variable (extension).
537.It Ic \&?=
538Assign the value to the variable if it is not already defined
539.Po
540.Bx
541extension
542.Pc .
543Normally, expansion is not done until the variable is referenced.
544.It Ic \&!=
545Perform variable expansion and pass the result to the shell for
546execution on the spot, assigning the result to the variable.
547Any newlines in the result are also replaced with spaces
548.Po
549.Bx
550extension
551.Pc .
552.It Ic \&!!=
553Perform variable expansion on the spot and pass the result to the shell
554for execution only when the value is needed, assigning the result to
555the variable.
556.Pp
557This is almost identical to
558.Ic \&!=
559except that a shell is only run when the variable value is needed.
560Any newlines in the result are also replaced with spaces
561.Po
562.Ox
563extension
564.Pc .
565.El
566.Pp
567Any whitespace before the assigned
568.Ar value
569is removed; if the value is being appended, a single space is inserted
570between the previous contents of the variable and the appended value.
571.Pp
572Several extended assignment operators may be combined together.
573For instance,
574.Bd -literal -offset indent
575A ?!= cmd
576.Ed
577.Pp
578will only run
579.Qq cmd
580and put its output into
581.Va A
582if
583.Va A
584is not yet defined.
585.Pp
586Combinations that do not make sense, such as
587.Bd -literal -offset indent
588A +!!= cmd
589.Ed
590.Pp
591will not work.
592.Pp
593Variables are expanded by surrounding the variable name with either
594curly braces
595.Pq Ql {}
596or parentheses
597.Pq Ql ()
598and preceding it with
599a dollar sign
600.Pq Ql \&$ .
601If the variable name contains only a single letter, the surrounding
602braces or parentheses are not required.
603This shorter form is not recommended.
604.Pp
605Variable substitution occurs at distinct times, depending on the type of line.
606Variables in dependency lines, conditional directives and include statements
607are expanded as the line is read.
608Variables in shell commands are expanded when the shell command is
609executed.
610.Pp
611The four different classes of variables (in order of increasing precedence)
612are:
613.Bl -tag -width Ds
614.It Environment variables
615Variables defined as part of
616.Nm make Ns 's
617environment.
618.It Global variables
619Variables defined in the makefile or in included makefiles.
620.It Command line variables
621Variables defined as part of the command line.
622.It Local variables
623Variables that are defined specific to a certain target.
624Standard local variables are as follows:
625.Bl -tag -width ".ARCHIVE"
626.It Va @
627The name of the target.
628.It Va \&%
629The name of the archive member (only valid for library rules).
630.It Va \&!
631The name of the archive file (only valid for library rules).
632.It Va \&?
633The list of prerequisites for this target that were deemed out of date.
634.It Va \&<
635The name of the prerequisite from which this target is to be built, if a valid
636inference rule (suffix rule) is in scope.
637.It Va *
638The file prefix of the file, containing only the file portion,
639no suffix or preceding directory components.
640.El
641.Pp
642The six variables
643.Sq Va "@F" ,
644.Sq Va "@D" ,
645.Sq Va "<F" ,
646.Sq Va "<D" ,
647.Sq Va "*F" ,
648and
649.Sq Va "*D"
650yield the
651.Qq filename
652and
653.Qq directory
654parts of the corresponding macros.
655.Pp
656For maximum compatibility,
657.Sq Va \&<
658should only be used for actual inference rules.
659It is also set for normal target rules when there is an inference rule
660that matches the current target and prerequisite in scope.
661That is, in
662.Bd -literal -offset indent
663\&.SUFFIXES: .c .o
664file.o: file.c
665	cmd1 $<
666
667\&.c.o:
668	cmd2
669.Ed
670.Pp
671building
672.Pa file.o
673will execute
674.Qq cmd1 file.c .
675.Pp
676As an extension,
677.Nm
678supports the following local variables:
679.Bl -tag -width ".ARCHIVE"
680.It Va \&>
681The list of all prerequisites for this target.
682.It Va .ALLSRC
683Synonym for
684.Sq Va \&> .
685.It Va .ARCHIVE
686Synonym for
687.Sq Va \&! .
688.It Va .IMPSRC
689Synonym for
690.Sq Va \&< .
691.It Va .MEMBER
692Synonym for
693.Sq Va \&% .
694.It Va .OODATE
695Synonym for
696.Sq Va \&? .
697.It Va .PREFIX
698Synonym for
699.Sq Va * .
700.It Va .TARGET
701Synonym for
702.Sq Va @ .
703.El
704.Pp
705These variables may be used on the dependency half of dependency
706lines, when they make sense.
707.El
708.Pp
709In addition,
710.Nm
711sets or knows about the following internal variables, or environment
712variables:
713.Bl -tag -width MAKEFLAGS
714.It Va \&$
715A single dollar sign
716.Ql \&$ ,
717i.e.,
718.Ql \&$$
719expands to a single dollar
720sign.
721.It Va .MAKE
722The name that
723.Nm
724was executed with
725.Pq Va argv Ns Op 0 .
726.It Va .CURDIR
727A path to the directory where
728.Nm
729was executed.
730.It Va .OBJDIR
731Path to the directory where targets are built.
732At startup,
733.Nm
734searches for an alternate directory to place target files.
735.Nm
736tries to
737.Xr chdir 2
738into
739.Ev MAKEOBJDIR
740(or
741.Pa obj
742if
743.Ev MAKEOBJDIR
744is not defined),
745and sets
746.Va .OBJDIR
747accordingly.
748Should that fail,
749.Va .OBJDIR
750is set to
751.Va .CURDIR .
752.It Va MAKEFILE_LIST
753The list of files read by
754.Nm .
755.It Va .MAKEFLAGS
756The environment variable
757.Ev MAKEFLAGS
758may contain anything that
759may be specified on
760.Nm make Ns 's
761command line.
762Its contents are stored in
763.Nm make Ns 's
764.Va .MAKEFLAGS
765variable.
766Anything specified on
767.Nm make Ns 's
768command line is appended to the
769.Va .MAKEFLAGS
770variable which is then
771entered into the environment as
772.Ev MAKEFLAGS
773for all programs which
774.Nm
775executes.
776.It Va MFLAGS
777A shorter synonym for
778.Va .MAKEFLAGS .
779.It Ev PWD
780Alternate path to the current directory.
781.Nm
782normally sets
783.Sq Va .CURDIR
784to the canonical path given by
785.Xr getcwd 3 .
786However, if the environment variable
787.Ev PWD
788is set and gives a path to the current directory, then
789.Nm
790sets
791.Sq Va .CURDIR
792to the value of
793.Ev PWD
794instead.
795.Ev PWD
796is always set to the value of
797.Sq Va .OBJDIR
798for all programs which
799.Nm
800executes.
801.It Va .TARGETS
802List of targets
803.Nm
804is currently building.
805.It Va MACHINE
806Name of the machine architecture
807.Nm
808is running on, obtained from the
809.Ev MACHINE
810environment variable, or through
811.Xr uname 3
812if not defined.
813.It Va MACHINE_ARCH
814Name of the machine architecture
815.Nm
816was compiled for, obtained from the
817.Ev MACHINE_ARCH
818environment variable, or defined at compilation time.
819.It Va MACHINE_CPU
820Name of the machine processor
821.Nm
822was compiled for, obtained from the
823.Ev MACHINE_CPU
824environment variable, or defined at compilation time.
825On processors where only one endianness is possible, the value of this
826variable is always the same as
827.Ev MACHINE_ARCH .
828.It Va MAKEFILE
829Possibly the file name of the last makefile that has been read.
830It should not be used; see the
831.Sx BUGS
832section below.
833.It Va .VARIABLES
834List of all the names of global variables that have been set.
835.El
836.Pp
837Variable expansion may be modified to select or modify each word of the
838variable (where
839.Dq word
840is a whitespace delimited sequence of characters).
841The general format of a variable expansion is as follows:
842.Pp
843.Dl {variable[:modifier[:...]]}
844.Pp
845Each modifier begins with a colon and one of the following
846special characters.
847The colon may be escaped with a backslash
848.Pq Ql \e .
849.Bl -tag -width Ds
850.It Cm :E
851Replaces each word in the variable with its suffix.
852.It Cm :H
853Replaces each word in the variable with everything but the last component.
854.It Cm :L
855Replaces each word in the variable with its lower case equivalent.
856.It Cm :U
857Replaces each word in the variable with its upper case equivalent.
858.It Cm :M Ns Ar pattern
859Select only those words that match the rest of the modifier.
860The standard shell wildcard characters
861.Pf ( Ql * ,
862.Ql \&? ,
863and
864.Ql [] )
865may
866be used.
867The wildcard characters may be escaped with a backslash
868.Pq Ql \e .
869.It Cm :N Ns Ar pattern
870This is identical to
871.Cm :M ,
872but selects all words which do not match
873the rest of the modifier.
874.It Cm :Q
875Quotes every shell meta-character in the variable, so that it can be passed
876safely through recursive invocations of
877.Nm make .
878.It Cm :QL
879Quote list: quotes every shell meta-character in the variable, except
880whitespace, so that it can be passed to a shell's
881.Sq for
882loops.
883.It Cm :R
884Replaces each word in the variable with everything but its suffix.
885.Sm off
886.It Cm :S No \&/ Ar old_string Xo
887.No \&/ Ar new_string
888.No \&/ Op Cm 1g
889.Xc
890.Sm on
891Modify the first occurrence of
892.Ar old_string
893in the variable's value, replacing it with
894.Ar new_string .
895If a
896.Ql g
897is appended to the last slash of the pattern, all occurrences
898in each word are replaced.
899If a
900.Ql 1
901is appended to the last slash of the pattern, only the first word
902is affected.
903If
904.Ar old_string
905begins with a caret
906.Pq Ql ^ ,
907.Ar old_string
908is anchored at the beginning of each word.
909If
910.Ar old_string
911ends with a dollar sign
912.Pq Ql \&$ ,
913it is anchored at the end of each word.
914Inside
915.Ar new_string ,
916an ampersand
917.Pq Ql &
918is replaced by
919.Ar old_string
920(without any
921.Ql ^
922or
923.Ql \&$ ) .
924Any character may be used as a delimiter for the parts of the modifier
925string.
926The anchoring, ampersand and delimiter characters may be escaped with a
927backslash
928.Pq Ql \e .
929.Pp
930Variable expansion occurs in the normal fashion inside both
931.Ar old_string
932and
933.Ar new_string
934with the single exception that a backslash is used to prevent the expansion
935of a dollar sign
936.Pq Ql \&$ ,
937not a preceding dollar sign as is usual.
938.Sm off
939.It Cm :C No \&/ Ar pattern Xo
940.No \&/ Ar replacement
941.No \&/ Op Cm 1g
942.Xc
943.Sm on
944The
945.Cm :C
946modifier is just like the
947.Cm :S
948modifier except that the old and new strings, instead of being
949simple strings, are an extended regular expression (see
950.Xr re_format 7 )
951and an
952.Xr ed 1 Ns \-style
953replacement string.
954Normally, the first occurrence of the pattern in
955each word of the value is changed.
956The
957.Ql 1
958modifier causes the substitution to apply to at most one word; the
959.Ql g
960modifier causes the substitution to apply to as many instances of the
961search pattern as occur in the word or words it is found in.
962Note that
963.Ql 1
964and
965.Ql g
966are orthogonal; the former specifies whether multiple words are
967potentially affected, the latter whether multiple substitutions can
968potentially occur within each affected word.
969.It Cm :T
970Replaces each word in the variable with its last component.
971.It Ar :old_string Ns = Ns Ar new_string
972This is the
973.At V
974style variable substitution.
975It must be the last modifier specified.
976If
977.Ar old_string
978or
979.Ar new_string
980do not contain the pattern matching character
981.Sq %
982then it is assumed that they are
983anchored at the end of each word, so only suffixes or entire
984words may be replaced.
985Otherwise
986.Sq %
987is the substring of
988.Ar old_string
989to be replaced in
990.Ar new_string .
991The right hand side
992.Pq Ar new_string
993may contain variable values, which will be expanded.
994To put an actual single dollar, just double it.
995.El
996.Pp
997All modifiers are
998.Bx
999extensions, except for the standard
1000.At V
1001style variable substitution.
1002.Pp
1003The interpretation of
1004.Sq %
1005and
1006.Sq $
1007in
1008.At V
1009variable substitutions is not mandated by POSIX, though it is
1010fairly common.
1011.Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1012Makefile inclusion, conditional structures and for loops reminiscent
1013of the C programming language are provided in
1014.Nm make .
1015All such structures are identified by a line beginning with a single
1016dot
1017.Pq Ql \&.
1018character.
1019Whitespace characters may follow this dot, e.g.,
1020.Bd -literal -offset indent
1021\&.include <file>
1022.Ed
1023and
1024.Bd -literal -offset indent -compact
1025\&.   include <file>
1026.Ed
1027.Pp
1028are identical constructs.
1029Files are included with either
1030.Ql .include <file>
1031or
1032.Ql .include Qq file .
1033Variables between the angle brackets or double quotes are expanded
1034to form the file name.
1035If angle brackets are used, the included makefile is expected to be in
1036the system makefile directory.
1037If double quotes are used, the including makefile's directory and any
1038directories specified using the
1039.Fl I
1040option are searched before the system
1041makefile directory.
1042.Pp
1043Conditional expressions are also preceded by a single dot as the first
1044character of a line.
1045The possible conditionals are as follows:
1046.Bl -tag -width Ds
1047.It Ic .undef Ar variable
1048Un-define the specified global variable.
1049Only global variables may be un-defined.
1050.It Ic .poison Ar variable
1051Poison the specified global variable.
1052Any further reference to
1053.Ar variable
1054will be flagged as an error.
1055.It Ic .poison !defined Pq Ar variable
1056It is an error to try to use the value of
1057.Ar variable
1058in a context where it is not defined.
1059.It Ic .poison empty Pq Ar variable
1060It is an error to try to use the value of
1061.Ar variable
1062in a context where it is not defined or is empty.
1063.It Xo
1064.Ic \&.if
1065.Oo \&! Oc Ns Ar expression
1066.Op Ar operator expression ...
1067.Xc
1068Test the value of an expression.
1069.It Xo
1070.Ic .ifdef
1071.Oo \&! Oc Ns Ar variable
1072.Op Ar operator variable ...
1073.Xc
1074Test the value of a variable.
1075.It Xo
1076.Ic .ifndef
1077.Oo \&! Oc Ns Ar variable
1078.Op Ar operator variable ...
1079.Xc
1080Test the value of a variable.
1081.It Xo
1082.Ic .ifmake
1083.Oo \&! Oc Ns Ar target
1084.Op Ar operator target ...
1085.Xc
1086Test the target being built.
1087.It Xo
1088.Ic .ifnmake
1089.Oo \&! Oc Ns Ar target
1090.Op Ar operator target ...
1091.Xc
1092Test the target being built.
1093.It Ic .else
1094Reverse the sense of the last conditional.
1095.It Xo
1096.Ic .elif
1097.Oo \&! Oc Ns Ar expression
1098.Op Ar operator expression ...
1099.Xc
1100A combination of
1101.Sq Ic .else
1102followed by
1103.Sq Ic .if .
1104.It Xo
1105.Ic .elifdef
1106.Oo \&! Oc Ns Ar variable
1107.Op Ar operator variable ...
1108.Xc
1109A combination of
1110.Sq Ic .else
1111followed by
1112.Sq Ic .ifdef .
1113.It Xo
1114.Ic .elifndef
1115.Oo \&! Oc Ns Ar variable
1116.Op Ar operator variable ...
1117.Xc
1118A combination of
1119.Sq Ic .else
1120followed by
1121.Sq Ic .ifndef .
1122.It Xo
1123.Ic .elifmake
1124.Oo \&! Oc Ns Ar target
1125.Op Ar operator target ...
1126.Xc
1127A combination of
1128.Sq Ic .else
1129followed by
1130.Sq Ic .ifmake .
1131.It Xo
1132.Ic .elifnmake
1133.Oo \&! Oc Ns Ar target
1134.Op Ar operator target ...
1135.Xc
1136A combination of
1137.Sq Ic .else
1138followed by
1139.Sq Ic .ifnmake .
1140.It Ic .endif
1141End the body of the conditional.
1142.El
1143.Pp
1144The
1145.Ar operator
1146may be any one of the following:
1147.Bl -tag -width "Cm XX"
1148.It Cm ||
1149logical OR
1150.It Cm \&&&
1151Logical AND; of higher precedence than
1152.Cm || .
1153.El
1154.Pp
1155As in C,
1156.Nm
1157will only evaluate a conditional as far as is necessary to determine
1158its value.
1159Parentheses may be used to change the order of evaluation.
1160The boolean operator
1161.Sq Ic \&!
1162may be used to logically negate an entire
1163conditional.
1164It is of higher precedence than
1165.Sq Ic \&&& .
1166.Pp
1167The value of
1168.Ar expression
1169may be any of the following:
1170.Bl -tag -width commands
1171.It Ic commands
1172Takes a target name as an argument and evaluates to true if the target
1173has been defined and has shell commands associated with it.
1174.It Ic defined
1175Takes a variable name as an argument and evaluates to true if the variable
1176has been defined.
1177.It Ic make
1178Takes a target name as an argument and evaluates to true if the target
1179was specified as part of
1180.Nm make Ns 's
1181command line or was declared the default target (either implicitly or
1182explicitly, see
1183.Va .MAIN )
1184before the line containing the conditional.
1185.It Ic empty
1186Takes a variable, with possible modifiers, and evaluates to true if
1187the expansion of the variable would result in an empty string.
1188.It Ic exists
1189Takes a file name as an argument and evaluates to true if the file exists.
1190The file is searched for on the system search path (see
1191.Va .PATH ) .
1192.It Ic target
1193Takes a target name as an argument and evaluates to true if the target
1194has been defined.
1195.El
1196.Pp
1197.Ar expression
1198may also be an arithmetic or string comparison.
1199Variable expansion is
1200performed on both sides of the comparison, after which the integral
1201values are compared.
1202A value is interpreted as hexadecimal if it is
1203preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1204The standard C relational operators are all supported.
1205If after
1206variable expansion, either the left or right hand side of a
1207.Sq Ic ==
1208or
1209.Sq Ic "!="
1210operator is not an integral value, then
1211string comparison is performed between the expanded
1212variables.
1213If no relational operator is given, it is assumed that the expanded
1214variable is being compared against 0.
1215.Pp
1216When
1217.Nm
1218is evaluating one of these conditional expressions, and it encounters
1219a word it doesn't recognize, either the
1220.Dq make
1221or
1222.Dq defined
1223expression is applied to it, depending on the form of the conditional.
1224If the form is
1225.Sq Ic .ifdef
1226or
1227.Sq Ic .ifndef ,
1228the
1229.Dq defined
1230expression is applied.
1231Similarly, if the form is
1232.Sq Ic .ifmake
1233or
1234.Sq Ic .ifnmake ,
1235the
1236.Dq make
1237expression is applied.
1238.Pp
1239If the conditional evaluates to true, the parsing of the makefile continues
1240as before.
1241If it evaluates to false, the following lines are skipped.
1242In both cases this continues until a
1243.Sq Ic .else
1244or
1245.Sq Ic .endif
1246is found.
1247.Pp
1248For loops are typically used to apply a set of rules to a list of files.
1249The syntax of a for loop is:
1250.Bd -unfilled -offset indent
1251.Ic .for Ar variable Oo Ar variable ... Oc Ic in Ar expression
1252	<make-rules>
1253.Ic .endfor
1254.Ed
1255.Pp
1256After the for
1257.Ar expression
1258is evaluated, it is split into words.
1259On each iteration of the loop, one word is assigned to each
1260.Ar variable ,
1261in order,
1262and these
1263.Ar variables
1264are substituted in the
1265.Ic make-rules
1266inside the body of the for loop.
1267The number of words must match the number of iteration variables;
1268that is, if there are three iteration variables, the number of words
1269must be a multiple of three.
1270.Pp
1271Loops and conditional expressions may nest arbitrarily, but
1272they may not cross include file boundaries.
1273.Pp
1274.Nm
1275also supports
1276.Ic sinclude
1277and
1278.Ic -include
1279for compatibility with other implementations.
1280Both use the same syntax:
1281.Bd -unfilled -offset indent
1282.Ic sinclude Pa file
1283.Ic -include Pa file
1284.Ed
1285.Pp
1286.Po
1287note no quotes around
1288.Pa file
1289.Pc
1290and will include
1291.Pa file ,
1292but without any error if it does not exist.
1293.Sh COMMENTS
1294Comments begin with a hash
1295.Pq Ql \&#
1296character, anywhere but in a shell
1297command line, and continue to the end of the line
1298(but a
1299.Pq Ql \&#
1300character in a shell command line will be interpreted as a comment by
1301the shell).
1302.Sh TARGET ATTRIBUTES
1303Some targets may be tagged with some specific attributes by one
1304of the
1305.Sx SPECIAL TARGETS
1306or
1307.Sx SPECIAL PREREQUISITES
1308described below.
1309.Bl -tag -width "Ignoring errors"
1310.It Dq Always build
1311Run the commands associated with this target even if the
1312.Fl n
1313or
1314.Fl t
1315options were specified.
1316Can be used to mark recursive
1317.Nm make Ns 's ,
1318but prefer standard
1319.Sq Ic + Ns Ar cmd .
1320.It Dq Cheap
1321In parallel mode, don't scan the commands for occurrences of
1322.Nm ,
1323thus letting normal recursive
1324.Fl j
1325behavior apply.
1326.It Dq Expensive
1327In parallel mode, assume commands will invoke recursive commands.
1328Once
1329.Nm
1330starts building an expensive target, it won't start building anything else
1331until that target has finished building.
1332.It Dq Ignoring errors
1333Ignore any errors generating by running shell commands, exactly
1334as if they were all preceded by a dash
1335.Pq Ql \- .
1336.It Dq Phony
1337A phony target is a target that does not correspond to any object in the
1338file system (more like a placeholder for a list of commands).
1339.Pp
1340Phony targets are always out of date at the start of a run, but
1341.Nm
1342still keeps track of when they are built (that is, when the associated
1343command list finishes running).
1344.It Dq Precious
1345Don't remove the target if
1346.Nm
1347is interrupted in the middle of building it.
1348.It Dq Silent
1349Do not display shell commands before running them, exactly as
1350if they were all preceded by a
1351.Sq @ .
1352.El
1353.Sh SPECIAL TARGETS
1354.Nm
1355recognizes standard special targets:
1356.Bl -tag -width ".NOTPARALLEL"
1357.It Ic .DEFAULT
1358If there is a
1359.Ic .DEFAULT
1360target rule, with commands but no prerequisites, and
1361.Nm
1362can't figure out another way to build a target, it will use that
1363list of commands, setting
1364.Va \&<
1365and
1366.Va @
1367appropriately.
1368.It Ic .IGNORE
1369Mark its prerequisites as
1370.Dq Ignoring errors .
1371.Pp
1372If the list of prerequisites is empty, apply that to all targets, exactly
1373like the
1374.Fl i
1375command-line option.
1376.It Ic .PRECIOUS
1377Mark its prerequisites as
1378.Dq Precious .
1379.Pp
1380If the list of prerequisites is empty, apply that to all targets.
1381.It Ic .SILENT
1382Mark its prerequisites as
1383.Dq Silent .
1384.Pp
1385If the list of prerequisites is empty, apply that to all targets, exactly
1386like the
1387.Fl s
1388command-line option.
1389.It Ic .SUFFIXES
1390See
1391.Sx INFERENCE RULES .
1392.El
1393.Pp
1394and also some other special targets as an extension:
1395.Bl -tag -width ".NOTPARALLEL"
1396.It Ic .BEGIN
1397Command lines attached to this target are executed before anything
1398else is done.
1399.It Ic .CHEAP
1400Mark its prerequisites as
1401.Dq Cheap .
1402.It Ic .END
1403Command lines attached to this target are executed at the end of a successful
1404run.
1405.It Ic .EXPENSIVE
1406Mark its prerequisites as
1407.Dq Expensive .
1408.It Ic .INTERRUPT
1409Command lines attached to this target are executed if
1410.Nm
1411is interrupted by a SIGINT.
1412.It Ic .MAKE
1413Mark its prerequisites as
1414.Dq Always build .
1415Prefer standard
1416.Sq Ic + Ns Ar cmd .
1417.It Ic .MAIN
1418If no target is specified when
1419.Nm
1420is invoked, this target will be built.
1421This is always set, either
1422explicitly, or implicitly when
1423.Nm
1424selects the default target, to give the user a way to refer to the default
1425target on the command line.
1426.It Ic .MAKEFLAGS
1427This target provides a way to specify flags for
1428.Nm
1429when the makefile is used.
1430The flags are as if typed to the shell, though the
1431.Fl f
1432option will have
1433no effect.
1434.It Ic .NOTPARALLEL
1435Disable parallel mode for the current makefile.
1436The
1437.Fl j
1438option is still passed to submakes.
1439.It Ic .NO_PARALLEL
1440Same as above, for compatibility with other pmake variants.
1441.It Ic .ORDER
1442The list of prerequisites should be built in sequence.
1443.It Ic .PATH
1444The prerequisites define a search path: directories that will be searched
1445for files not found in the current directory.
1446If no prerequisites are specified, any previously specified directories are
1447deleted.
1448.It Ic .PATH\fI.suffix\fR
1449This target is only valid if .suffix is a currently valid suffix.
1450The prerequisites defines a search path for files ending in that suffix.
1451For files not found in the current directory,
1452.Nm
1453will first look in that path, before reverting to the default search path.
1454.It Ic .PHONY
1455Mark its prerequisites as
1456.Dq Phony
1457targets.
1458.El
1459.Pp
1460It is an error to use several special targets, or a special target and
1461normal targets, in a single dependency line.
1462.Sh SPECIAL PREREQUISITES
1463Of the special targets described in the previous
1464section, the ones that tag prerequisites can also be used as prerequisites,
1465in which case the corresponding targets will be tagged accordingly.
1466.Pp
1467This is an extension, even for standard special targets.
1468.Pp
1469.Nm
1470also recognizes some other prerequisites:
1471.Bl -tag -width ".PRECIOUS"
1472.It Ic .NOTMAIN
1473Normally
1474.Nm
1475selects the first target it encounters as the default target to be built
1476if no target was specified.
1477This prerequisite prevents this target from being selected.
1478.It Ic .OPTIONAL
1479If a target is marked with this attribute and
1480.Nm
1481can't figure out how to create it, it will ignore this fact and assume
1482the file isn't needed or already exists.
1483.It Ic .USE
1484Turn the target into
1485.Nm make Ns 's
1486version of a macro.
1487When the target is used as a prerequisite for another target, the other target
1488acquires the commands, prerequisites, and attributes (except for
1489.Ic .USE )
1490of the
1491prerequisite.
1492If the target already has commands, the
1493.Ic .USE
1494target's commands are appended
1495to them.
1496.It Ic .WAIT
1497If
1498.Ic .WAIT
1499appears in a dependency line, the prerequisites that precede it are
1500made before the prerequisites that follow it in the line.
1501Loops are not
1502detected and targets that form loops will be silently ignored.
1503.El
1504.Sh ENVIRONMENT
1505.Nm
1506uses the following environment variables, if they exist:
1507.Ev MACHINE ,
1508.Ev MACHINE_ARCH ,
1509.Ev MACHINE_CPU ,
1510.Ev MAKEFLAGS ,
1511.Ev MAKEOBJDIR
1512and
1513.Ev PWD .
1514.Nm
1515also ignores and unsets
1516.Ev CDPATH .
1517.Sh FILES
1518.Bl -tag -width /usr/share/mk -compact
1519.It Pa .depend
1520list of dependencies
1521.It Pa makefile
1522default makefile
1523.It Pa Makefile
1524default makefile if
1525.Pa makefile
1526does not exist
1527.It Pa sys.mk
1528system makefile
1529.It Pa /usr/share/mk
1530system makefile directory
1531.El
1532.Sh EXIT STATUS
1533If
1534.Fl q
1535was specified, the
1536.Nm
1537utility exits with one of the following values:
1538.Pp
1539.Bl -tag -width Ds -offset indent -compact
1540.It 0
1541Normal behavior.
1542.It 1
1543The target was not up to date.
1544.It >1
1545An error occurred.
1546.El
1547.Pp
1548Otherwise, the
1549.Nm
1550utility exits with a value of 0 on success, and >0 if an error occurred.
1551.Sh SEE ALSO
1552.Xr ed 1 ,
1553.Xr mkdep 1 ,
1554.Xr sh 1 ,
1555.Xr getcwd 3 ,
1556.Xr uname 3 ,
1557.Xr re_format 7
1558.Rs
1559.%A S. I. Feldman
1560.%T Make \(em A Program for Maintaining Computer Programs
1561.\".%R Computing Science Technical Report
1562.\".%N 57
1563.%J Software \(em Practice and Experience
1564.%V 9:4
1565.%P pp. 255-265
1566.%D April 1979
1567.Re
1568.Rs
1569.\" 4.4BSD PSD:12
1570.%A Adam de Boor
1571.%T PMake \(em A Tutorial
1572.%B 4.4BSD Programmer's Supplementary Documents (PSD)
1573.Re
1574.Sh STANDARDS
1575The
1576.Nm
1577utility is mostly compliant with the
1578.St -p1003.1-2008
1579specification,
1580though its presence is optional.
1581.Pp
1582The flags
1583.Op Fl BCDdIjmV
1584are extensions to that specification.
1585.Pp
1586Older versions of
1587.Nm
1588used
1589.Ev MAKE
1590instead of
1591.Ev MAKEFLAGS .
1592This was removed for POSIX compatibility.
1593The internal variable
1594.Va MAKE
1595is set to the same value as
1596.Va .MAKE .
1597Support for this may be removed in the future.
1598.Pp
1599Most of the more esoteric features of
1600.Nm
1601should probably be avoided for greater compatibility.
1602.Sh HISTORY
1603A
1604.Nm
1605command first appeared outside of Bell Labs in PWB/UNIX 1.0.
1606It was replaced in
1607.Bx 4.3 Reno .
1608.Sh AUTHORS
1609.An Stuart Feldman
1610wrote the original implementation at the
1611Bell Labs Computing Science Research Center.
1612.Pp
1613This implementation is a distant derivative of
1614.Nm pmake ,
1615originally written by Adam de Boor for the Sprite operating system.
1616.Sh BUGS
1617If the same target is specified several times in complete target rules,
1618.Nm
1619silently ignores all commands after the first non empty set of commands,
1620e.g., in
1621.Bd -literal -offset indent
1622a:
1623	@echo "Executed"
1624a:
1625	@echo "Bad luck"
1626.Ed
1627.Pp
1628@echo "Bad luck" will be ignored.
1629.Pp
1630.Va .TARGETS
1631is not set to the default target when
1632.Nm
1633is invoked without a target name and no
1634.Ic MAIN
1635special target exists.
1636.Pp
1637The evaluation of
1638.Ar expression
1639in a test is somewhat simplistic.
1640Variables don't need to be quoted, but strings do:
1641Tests like
1642.Ql .if ${VAR} == "string" ,
1643.Ql .if ${VAR} >= 5 ,
1644.Ql .if 5 <= 10 ,
1645and
1646.Ql .if "string" == ${VAR}
1647do work, but
1648.Ql .if string = ${VAR}
1649doesn't.
1650.Pp
1651For loops are expanded before tests, so a fragment such as:
1652.Bd -literal -offset indent
1653\&.for TMACHINE in ${SHARED_ARCHS}
1654\&.if "${TMACHINE}" == ${MACHINE}
1655     ...
1656\&.endif
1657\&.endfor
1658.Ed
1659.Pp
1660requires the quotes.
1661.Pp
1662When handling
1663.Pf pre- Bx 4.4
1664archives,
1665.Nm
1666may erroneously mark archive members as out of date if the archive name
1667was truncated.
1668.Pp
1669The handling of
1670.Sq ;\&
1671and other special characters in tests may be utterly bogus.
1672For instance, in
1673.Bd -literal -offset indent
1674\&A=abcd;c.c
1675\&.if ${A:R} == "abcd;c"
1676.Ed
1677.Pp
1678the test will never match, even though the value is correct.
1679.Pp
1680In a .for loop, only the variable value is used; assignments will be
1681evaluated later, e.g., in
1682.Bd -literal -offset indent
1683\&.for I in a b c d
1684I:=${I:S/a/z/}
1685A+=$I
1686\&.endfor
1687.Ed
1688.Pp
1689.Sq A
1690will evaluate to a b c d after the loop, not z b c d.
1691.Pp
1692.Ic ORDER
1693is currently only used in parallel mode, so
1694keep prerequisites ordered for sequential mode!
1695.Pp
1696Distinct target names are treated separately, even though they might
1697correspond to the same file in the file system.
1698This can cause excessive rebuilds of some targets, and bogus
1699races in parallel mode.
1700This can also prevent
1701.Nm
1702from finding a rule to solve a dependency if the target name is not
1703exactly the same as the dependency.
1704.Pp
1705In parallel mode,
1706.Fl j Ar n
1707only limits the number of direct children of
1708.Nm .
1709During recursive invocations, each level may multiply the total number
1710of processes by
1711.Ar n .
1712However,
1713.Nm
1714includes some heuristics to try to prevent catastrophic behavior:
1715if a command is marked as expensive, or preceded by
1716.Sq + ,
1717or seems to
1718invoke a program that looks sufficiently like
1719.Sq make ,
1720.Nm
1721will assume recursive invocation, and not start any new process until
1722said command has finished running.
1723Thus the number of processes run directly or indirectly by
1724.Nm
1725will increase linearly with each level of recursion instead of exponentially.
1726.Pp
1727The
1728.Va MAKEFILE
1729variable cannot be used reliably.
1730It is a compatibility feature and may get set to the last makefile
1731specified, as it is set by System V make.
1732