xref: /trueos/usr.bin/make/make.1 (revision ede42824618710ffa9ac08c805d8bf39bd5661ce)
1.\" Copyright (c) 1990, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	@(#)make.1	8.8 (Berkeley) 6/13/95
33.\" $FreeBSD$
34.\"
35.Dd May 30, 2012
36.Dt MAKE 1
37.Os
38.Sh NAME
39.Nm make
40.Nd maintain program dependencies
41.Sh SYNOPSIS
42.Nm
43.Op Fl ABPSXeiknpqrstv
44.Op Fl C Ar directory
45.Op Fl D Ar variable
46.Op Fl d Ar flags
47.Op Fl E Ar variable
48.Op Fl f Ar makefile
49.Op Fl I Ar directory
50.Bk -words
51.Op Fl j Ar max_jobs
52.Op Fl m Ar directory
53.Ek
54.Op Fl V Ar variable
55.Op Fl x Ar warning_options
56.Op Ar variable Ns No = Ns Ar value
57.Op Ar target ...
58.Sh DESCRIPTION
59The
60.Nm
61utility is a program designed to simplify the maintenance of other programs.
62Its input is a list of specifications
63describing dependency relationships between the generation of
64files and programs.
65.Pp
66First of all, the initial list of specifications will be read
67from the system makefile,
68.Pa sys.mk ,
69unless inhibited with the
70.Fl r
71option.
72The standard
73.Pa sys.mk
74as shipped with
75.Fx
76also handles
77.Xr make.conf 5 ,
78the default path to which
79can be altered via the
80.Nm
81variable
82.Va __MAKE_CONF .
83.Pp
84Then the first of
85.Pa BSDmakefile ,
86.Pa makefile ,
87and
88.Pa Makefile
89that can be found in the current directory, object directory (see
90.Va .OBJDIR ) ,
91or search path (see the
92.Fl I
93option)
94will be read for the main list of dependency specifications.
95A different makefile or list of them can be supplied via the
96.Fl f
97option(s).
98Finally, if the file
99.Pa .depend
100can be found in any of the aforesaid locations, it will also be read (see
101.Xr mkdep 1 ) .
102.Pp
103When
104.Nm
105searches for a makefile, its name takes precedence over its location.
106For instance,
107.Pa BSDmakefile
108in the object directory will be favored over
109.Pa Makefile
110in the current directory.
111.Pp
112The options are as follows:
113.Bl -tag -width Ds
114.It Fl A
115Make archive errors non-fatal, causing
116.Nm
117to just skip the remainder
118or all of the archive and continue after printing a message.
119.It Fl B
120Try to be backwards compatible by executing a single shell per command and
121by executing the commands to make the sources of a dependency line in sequence.
122This is turned on by default unless
123.Fl j
124is used.
125.It Fl C Ar directory
126Change to
127.Ar directory
128before reading the makefiles or doing anything else.
129If multiple
130.Fl C
131options are specified, each is interpreted relative to the previous one:
132.Fl C Pa / Fl C Pa etc
133is equivalent to
134.Fl C Pa /etc .
135.It Fl D Ar variable
136Define
137.Ar variable
138to be 1, in the global context.
139.It Fl d Ar flags
140Turn on debugging, and specify which portions of
141.Nm
142are to print debugging information.
143Argument
144.Ar flags
145is one or more of the following:
146.Bl -tag -width Ds
147.It Ar A
148Print all possible debugging information;
149equivalent to specifying all of the debugging flags.
150.It Ar a
151Print debugging information about archive searching and caching.
152.It Ar c
153Print debugging information about conditional evaluation.
154.It Ar d
155Print debugging information about directory searching and caching.
156.It Ar f
157Print debugging information about the execution of for loops.
158.It Ar "g1"
159Print the input graph before making anything.
160.It Ar "g2"
161Print the input graph after making everything, or before exiting
162on error.
163.It Ar j
164Print debugging information about running multiple shells.
165.It Ar l
166Print commands in Makefiles regardless of whether or not they are prefixed
167by @ or other "quiet" flags.
168Also known as "loud" behavior.
169.It Ar m
170Print debugging information about making targets, including modification
171dates.
172.It Ar s
173Print debugging information about suffix-transformation rules.
174.It Ar t
175Print debugging information about target list maintenance.
176.It Ar v
177Print debugging information about variable assignment.
178.El
179.It Fl E Ar variable
180Specify a variable whose environment value (if any) will override
181macro assignments within makefiles.
182.It Fl e
183Specify that environment values override macro assignments within
184makefiles for all variables.
185.It Fl f Ar makefile
186Specify a makefile to read instead of the default one.
187If
188.Ar makefile
189is not an absolute pathname,
190.Nm
191will search for it as described above.
192In case
193.Ar makefile
194is
195.Sq Fl ,
196standard input is read.
197Multiple
198.Fl f
199options can be supplied,
200and the makefiles will be read in that order.
201Unlike the other command-line options,
202.Fl f
203is neither stored in
204.Va .MAKEFLAGS
205nor pushed down to sub-makes via
206.Ev MAKEFLAGS .
207See below for more details on these variables.
208.It Fl I Ar directory
209Specify a directory in which to search for makefiles and included makefiles.
210Multiple
211.Fl I
212options can be specified to form a search path.
213The system makefile directory (or directories, see the
214.Fl m
215option) is automatically appended at the tail of this path.
216.It Fl i
217Ignore non-zero exit of shell commands in the makefile.
218Equivalent to specifying
219.Sq Ic \-
220before each command line in the makefile.
221.It Fl j Ar max_jobs
222Specify the maximum number of jobs that
223.Nm
224may have running at any one time.
225Turns compatibility mode off, unless the
226.Fl B
227flag is also specified.
228.It Fl k
229Continue processing after errors are encountered, but only on those targets
230that do not depend on the target whose creation caused the error.
231.It Fl m Ar directory
232Specify a directory in which to search for
233the system makefile and makefiles included via the <...> style.
234Multiple
235.Fl m
236options can be specified to form a search path.
237This path will override the default system include path,
238.Pa /usr/share/mk .
239The system include path will always be appended to the search path used
240for "..."-style inclusions and makefile searches (see the
241.Fl I
242option).
243.Pp
244If a file or directory name in the
245.Fl m
246argument (or the
247.Ev MAKESYSPATH
248environment variable) starts with the string
249.Qq \&.../
250then
251.Nm
252will search for the specified file or directory named in the remaining part
253of the argument string.
254The search starts with the current directory of the Makefile and then works
255upward towards the root of the filesystem.
256If the search is successful,
257then the resulting directory replaces the
258.Qq \&.../
259specification in the
260.Fl m
261argument.
262If used, this feature allows
263.Nm
264to easily search in the current source tree for customized sys.mk files
265(e.g. by using
266.Qq \&.../mk/sys.mk
267as an argument).
268Note that a
269.Fl C
270that are earlier on the command line affect where
271.Fl m Qq \&.../
272searches.
273.It Fl n
274Display the commands that would have been executed, but do not actually
275execute them.
276.It Fl P
277Collate the output of a given job and display it only when the job finishes,
278instead of mixing the output of parallel jobs together.
279This option has no effect unless
280.Fl j
281is used too.
282.It Fl p
283Only print the input graph, not executing any commands.
284The output is the same as
285.Fl d Ar g1 .
286When combined with
287.Fl f Pa /dev/null ,
288only the builtin rules of
289.Nm
290are displayed.
291.It Fl Q
292Be extra quiet.
293For multi-job makes, this will cause file banners not to be generated.
294.It Fl q
295Do not execute any commands, but exit 0 if the specified targets are
296up-to-date and 1, otherwise.
297.It Fl r
298Do not process the system makefile.
299.It Fl S
300Stop processing when an error is encountered.
301Default behaviour.
302This is needed to negate the
303.Fl k
304option during recursive builds.
305.It Fl s
306Do not echo any commands as they are executed.
307Equivalent to specifying
308.Sq Ic @
309before each command line in the makefile.
310.It Fl t
311Rather than re-building a target as specified in the makefile, create it
312or update its modification time to make it appear up-to-date.
313.It Fl V Ar variable
314Print
315.Nm Ns 's
316idea of the value of
317.Ar variable ,
318in the global context.
319Do not build any targets.
320Multiple instances of this option may be specified;
321the variables will be printed one per line,
322with a blank line for each null or undefined variable.
323If
324.Ar variable
325contains a
326.Sq Ic $
327then the value will be expanded before printing.
328.It Fl v
329Be extra verbose.
330Print any extra information.
331.It Fl X
332When using the
333.Fl V
334option to print the values of variables,
335do not recursively expand the values.
336.It Ar variable Ns No = Ns Ar value
337Set the value of the variable
338.Ar variable
339to
340.Ar value .
341.It Fl x Ar warning_options
342Specify extended warning options.
343This option may be specified several times.
344A
345.Ar warning_option
346can be prefixed with
347.Dq Li no
348in which case the warning is switched off.
349The currently available options are:
350.Bl -tag -width indent
351.It Li dirsyntax
352Warn if anything except blanks and comments follows an
353.Ic .endif
354or
355.Ic .else
356directive.
357.El
358.Pp
359See also the
360.Ic .WARN
361special target.
362.El
363.Pp
364There are seven different types of lines in a makefile: file dependency
365specifications, shell commands, variable assignments, include statements,
366conditional directives, for loops, and comments.
367.Pp
368In general, lines may be continued from one line to the next by ending
369them with a backslash
370.Pq Ql \e .
371The trailing newline character and initial whitespace on the following
372line are compressed into a single space.
373.Sh FILE DEPENDENCY SPECIFICATIONS
374Dependency lines consist of one or more targets, an operator, and zero
375or more sources.
376This creates a relationship where the targets
377.Dq depend
378on the sources
379and are usually created from them.
380The exact relationship between the target and the source is determined
381by the operator that separates them.
382The three operators are as follows:
383.Bl -tag -width flag
384.It Ic \&:
385A target is considered out-of-date if its modification time is less than
386those of any of its sources.
387Sources for a target accumulate over dependency lines when this operator
388is used.
389The target is removed if
390.Nm
391is interrupted.
392.It Ic \&!
393Targets are always re-created, but not until all sources have been
394examined and re-created as necessary.
395Sources for a target accumulate over dependency lines when this operator
396is used.
397The target is removed if
398.Nm
399is interrupted.
400.It Ic ::
401If no sources are specified, the target is always re-created.
402Otherwise, a target is considered out-of-date if any of its sources has
403been modified more recently than the target.
404Sources for a target do not accumulate over dependency lines when this
405operator is used.
406The target will not be removed if
407.Nm
408is interrupted.
409.El
410.Pp
411Targets and sources may contain the shell wildcard expressions
412.Ql \&? ,
413.Ql * ,
414.Ql []
415and
416.Ql {} .
417The expressions
418.Ql \&? ,
419.Ql *
420and
421.Ql []
422may only be used as part of the final
423component of the target or source, and must be used to describe existing
424files.
425The expression
426.Ql {}
427need not necessarily be used to describe existing files.
428Expansion is in directory order, not alphabetically as done in the shell.
429.Sh SHELL COMMANDS
430Each target may have associated with it a series of shell commands, normally
431used to create the target.
432Each of the commands in this script
433.Em must
434be preceded by a tab.
435While any target may appear on a dependency line, only one of these
436dependencies may be followed by a creation script, unless the
437.Sq Ic ::
438operator is used.
439.Pp
440If the first characters of the command line are
441.Sq Ic @ ,
442.Sq Ic \- ,
443and/or
444.Sq Ic + ,
445the command is treated specially.
446A
447.Sq Ic @
448causes the command not to be echoed before it is executed.
449A
450.Sq Ic \-
451causes any non-zero exit status of the command line to be ignored.
452A
453.Sq Ic +
454causes the command to be executed even if
455.Fl n
456is specified on the command line.
457.Sh VARIABLE ASSIGNMENTS
458Variables in
459.Nm
460are much like variables in the shell, and, by tradition,
461consist of all upper-case letters.
462The five operators that can be used to assign values to variables are as
463follows:
464.Bl -tag -width Ds
465.It Ic =
466Assign the value to the variable.
467Any previous value is overridden.
468.It Ic +=
469Append the value to the current value of the variable.
470.It Ic ?=
471Assign the value to the variable if it is not already defined.
472.It Ic :=
473Assign with expansion, i.e., expand the value before assigning it
474to the variable.
475Normally, expansion is not done until the variable is referenced.
476.It Ic !=
477Expand the value and pass it to the shell for execution and assign
478the result to the variable.
479Any newlines in the result are replaced with spaces.
480.El
481.Pp
482Any whitespace before the assigned
483.Ar value
484is removed; if the value is being appended, a single space is inserted
485between the previous contents of the variable and the appended value.
486.Pp
487Variables are expanded by surrounding the variable name with either
488curly braces
489.Pq Ql {}
490or parentheses
491.Pq Ql ()
492and preceding it with
493a dollar sign
494.Pq Ql $ .
495If the variable name contains only a single letter, the surrounding
496braces or parentheses are not required.
497This shorter form is not recommended.
498.Pp
499Variable substitution occurs at two distinct times, depending on where
500the variable is being used.
501Variables in dependency lines are expanded as the line is read.
502Variables in shell commands are expanded when the shell command is
503executed.
504.Pp
505The four different classes of variables (in order of increasing precedence)
506are:
507.Bl -tag -width Ds
508.It Environment variables
509Variables defined as part of
510.Nm Ns 's
511environment.
512.It Global variables
513Variables defined in the makefile or in included makefiles.
514.It Command line variables
515Variables defined as part of the command line and variables
516obtained from the
517.Ev MAKEFLAGS
518environment variable or the
519.Ic .MAKEFLAGS
520target.
521.It Local variables
522Variables that are defined specific to a certain target.
523.El
524.Pp
525If the name of an environment variable appears in a makefile
526on the left-hand side of an assignment,
527a global variable with the same name is created, and the latter
528shadows the former as per their relative precedences.
529The environment is not changed in this case, and the change
530is not exported to programs executed by
531.Nm .
532However, a command-line variable actually replaces
533the environment variable of the same name if the latter exists,
534which is visible to child programs.
535.Pp
536There are seven local variables in
537.Nm :
538.Bl -tag -width ".ARCHIVE"
539.It Va .ALLSRC
540The list of all sources for this target; also known as
541.Sq Va > .
542.It Va .ARCHIVE
543The name of the archive file; also known as
544.Sq Va \&! .
545.It Va .IMPSRC
546The name/path of the source from which the target is to be transformed
547(the
548.Dq implied
549source); also known as
550.Sq Va < .
551.It Va .MEMBER
552The name of the archive member; also known as
553.Sq Va % .
554.It Va .OODATE
555The list of sources for this target that were deemed out-of-date; also
556known as
557.Sq Va \&? .
558.It Va .PREFIX
559The file prefix of the file, containing only the file portion, no suffix
560or preceding directory components; also known as
561.Sq Va * .
562.It Va .TARGET
563The name of the target; also known as
564.Sq Va @ .
565.El
566.Pp
567The shorter forms
568.Sq Va @ ,
569.Sq Va \&! ,
570.Sq Va < ,
571.Sq Va % ,
572.Sq Va \&? ,
573.Sq Va > ,
574and
575.Sq Va *
576are permitted for backward
577compatibility and are not recommended.
578The six variables
579.Sq Va @F ,
580.Sq Va @D ,
581.Sq Va <F ,
582.Sq Va <D ,
583.Sq Va *F ,
584and
585.Sq Va *D
586are
587permitted for compatibility with
588.At V
589makefiles and are not recommended.
590.Pp
591Four of the local variables may be used in sources on dependency lines
592because they expand to the proper value for each target on the line.
593These variables are
594.Va .TARGET ,
595.Va .PREFIX ,
596.Va .ARCHIVE ,
597and
598.Va .MEMBER .
599.Pp
600In addition,
601.Nm
602sets or knows about the following internal variables or environment
603variables:
604.Bl -tag -width ".Va .MAKEFILE_LIST"
605.It Va $
606A single dollar sign
607.Ql $ ,
608i.e.\&
609.Ql $$
610expands to a single dollar
611sign.
612.It Va MAKE
613The name that
614.Nm
615was executed with
616.Pq Va argv Ns Op 0 .
617.It Va .CURDIR
618A path to the directory where
619.Nm
620was executed.
621The
622.Nm
623utility sets
624.Va .CURDIR
625to the canonical path given by
626.Xr getcwd 3 .
627.It Va .OBJDIR
628A path to the directory where the targets are built.
629At startup,
630.Nm
631searches for an alternate directory to place target files.
632It will attempt to change into this special directory
633and will search this directory for makefiles
634not found in the current directory.
635The following directories are tried in order:
636.Pp
637.Bl -enum -compact
638.It
639${MAKEOBJDIRPREFIX}/`pwd -P`
640.It
641${MAKEOBJDIR}
642.It
643obj.${MACHINE}
644.It
645obj
646.It
647/usr/obj/`pwd -P`
648.El
649.Pp
650The first directory that
651.Nm
652successfully changes into is used.
653If either
654.Ev MAKEOBJDIRPREFIX
655or
656.Ev MAKEOBJDIR
657is set in the environment but
658.Nm
659is unable to change into the corresponding directory,
660then the current directory is used
661without checking the remainder of the list.
662If they are undefined and
663.Nm
664is unable to change into any of the remaining three directories,
665then the current directory is used.
666Note, that
667.Ev MAKEOBJDIRPREFIX
668and
669.Ev MAKEOBJDIR
670must be environment variables and should not be set on
671.Nm Ns 's
672command line.
673.Pp
674The
675.Nm
676utility sets
677.Va .OBJDIR
678to the canonical path given by
679.Xr getcwd 3 .
680.It Va .MAKEFILE_LIST
681As
682.Nm
683reads various makefiles, including the default files and any
684obtained from the command line and
685.Ic .include
686and
687.Ic .sinclude
688directives, their names will be automatically appended to the
689.Va .MAKEFILE_LIST
690variable.
691They are added right before
692.Nm
693begins to parse them, so that the name of the current makefile is the
694last word in this variable.
695.It Ev MAKEFLAGS
696The environment variable
697.Ev MAKEFLAGS
698may initially contain anything that
699may be specified on
700.Nm Ns 's
701command line,
702including
703.Fl f
704option(s).
705After processing, its contents are stored in the
706.Va .MAKEFLAGS
707global variable, although any
708.Fl f
709options are omitted.
710Then all options and variable assignments specified on
711.Nm Ns 's
712command line, except for
713.Fl f ,
714are appended to the
715.Va .MAKEFLAGS
716variable.
717.Pp
718Whenever
719.Nm
720executes a program, it sets
721.Ev MAKEFLAGS
722in the program's environment to the current value of the
723.Va .MAKEFLAGS
724global variable.
725Thus, if
726.Ev MAKEFLAGS
727in
728.Nm Ns 's
729environment contains any
730.Fl f
731options, they will not be pushed down to child programs automatically.
732The
733.Nm
734utility effectively filters out
735.Fl f
736options from the environment and command line although it
737passes the rest of its options down to sub-makes via
738.Ev MAKEFLAGS
739by default.
740.Pp
741When passing macro definitions and flag arguments in the
742.Ev MAKEFLAGS
743environment variable,
744space and tab characters are quoted by preceding them with a backslash.
745When reading the
746.Ev MAKEFLAGS
747variable from the environment,
748all sequences of a backslash and one of space or tab
749are replaced just with their second character
750without causing a word break.
751Any other occurrences of a backslash are retained.
752Groups of unquoted space, tab and newline characters cause word
753breaking.
754.It Va .MAKEFLAGS
755Initially, this global variable contains
756.Nm Ns 's
757current run-time options from the environment
758and command line as described above, under
759.Ev MAKEFLAGS .
760By modifying the contents of the
761.Va .MAKEFLAGS
762global variable, the makefile can alter the contents of the
763.Ev MAKEFLAGS
764environment variable made available for all programs which
765.Nm
766executes.
767This includes adding
768.Fl f
769option(s).
770The current value of
771.Va .MAKEFLAGS
772is just copied verbatim to
773.Ev MAKEFLAGS
774in the environment of child programs.
775.Pp
776Note that any options entered to
777.Va .MAKEFLAGS
778neither affect the current instance of
779.Nm
780nor show up in its own copy of
781.Ev MAKEFLAGS
782instantly.
783However, they do show up in the
784.Ev MAKEFLAGS
785environment variable of programs executed by
786.Nm .
787On the other hand, a direct assignment to
788.Ev MAKEFLAGS
789neither affects the current instance of
790.Nm
791nor is passed down to
792.Nm Ns 's
793children.
794Compare with the
795.Ic .MAKEFLAGS
796special target below.
797.It Va MFLAGS
798This variable is provided for backward compatibility and
799contains all the options from the
800.Ev MAKEFLAGS
801environment variable plus any options specified on
802.Nm Ns 's
803command line.
804.It Va .MAKE.PID
805The process-id of
806.Nm .
807.It Va .MAKE.PPID
808The parent process-id of
809.Nm .
810.It Va .MAKE.JOB.PREFIX
811If
812.Nm
813is run with
814.Fl j Fl v
815then output for each target is prefixed with a token
816.Ql --- target ---
817the first part of which can be controlled via
818.Va .MAKE.JOB.PREFIX .
819.br
820For example:
821.Li .MAKE.JOB.PREFIX=${.newline}---${MAKE:T}[${.MAKE.PID}]
822would produce tokens like
823.Ql ---make[1234] target ---
824or
825.Li .MAKE.JOB.PREFIX=---pid[${.MAKE.PID}],ppid[${.MAKE.PPID}]
826would produce tokens like
827.Ql ---pid[56789],ppid[1234] target ---
828making it easier to track the degree of parallelism being achieved.
829.It Va .TARGETS
830List of targets
831.Nm
832is currently building.
833.It Va .INCLUDES
834See
835.Ic .INCLUDES
836special target.
837.It Va .LIBS
838See
839.Ic .LIBS
840special target.
841.It Va MACHINE
842Name of the machine architecture
843.Nm
844is running on, obtained from the
845.Ev MACHINE
846environment variable, or through
847.Xr uname 3
848if not defined.
849.It Va MACHINE_ARCH
850Name of the machine architecture
851.Nm
852was compiled for, defined at compilation time.
853.It Va VPATH
854Makefiles may assign a colon-delimited list of directories to
855.Va VPATH .
856These directories will be searched for source files by
857.Nm
858after it has finished parsing all input makefiles.
859.El
860.Ss Variable Modifiers
861Variable expansion may be modified to select or modify each word of the
862variable (where a
863.Dq word
864is whitespace-delimited sequence of characters).
865The general format of a variable expansion is as follows:
866.Pp
867.Dl {variable[:modifier[:...]]}
868.Pp
869Each modifier begins with a colon and one of the following
870special characters.
871The colon may be escaped with a backslash
872.Pq Ql \e .
873.Bl -tag -width Cm
874.Sm off
875.It Cm :C No / Ar pattern Xo
876.No / Ar replacement
877.No / Op Cm 1g
878.Xc
879.Sm on
880Modify each word of the value,
881substituting every match of the extended regular expression
882.Ar pattern
883(see
884.Xr re_format 7 )
885with the
886.Xr ed 1 Ns \-style
887.Ar replacement
888string.
889Normally, the first occurrence of the pattern in
890each word of the value is changed.
891The
892.Ql 1
893modifier causes the substitution to apply to at most one word; the
894.Ql g
895modifier causes the substitution to apply to as many instances of the
896search pattern as occur in the word or words it is found in.
897Note that
898.Ql 1
899and
900.Ql g
901are orthogonal; the former specifies whether multiple words are
902potentially affected, the latter whether multiple substitutions can
903potentially occur within each affected word.
904.It Cm :E
905Replaces each word in the variable with its suffix.
906.It Cm :H
907Replaces each word in the variable with everything but the last component.
908.It Cm :L
909Converts variable to lower-case letters.
910(deprecated)
911.It Cm :M Ns Ar pattern
912Select only those words that match the rest of the modifier.
913The standard shell wildcard characters
914.Pf ( Ql * ,
915.Ql \&? ,
916and
917.Ql [] )
918may
919be used.
920The wildcard characters may be escaped with a backslash
921.Pq Ql \e .
922.It Cm :N Ns Ar pattern
923This is identical to
924.Cm :M ,
925but selects all words which do not match
926the rest of the modifier.
927.It Cm :O
928Order every word in the variable alphabetically.
929.It Cm :Q
930Quotes every shell meta-character in the variable, so that it can be passed
931safely through recursive invocations of
932.Nm .
933.It Cm :R
934Replaces each word in the variable with everything but its suffix.
935.Sm off
936.It Cm :S No / Ar old_string Xo
937.No / Ar new_string
938.No / Op Cm g
939.Xc
940.Sm on
941Modify the first occurrence of
942.Ar old_string
943in each word of the variable's value, replacing it with
944.Ar new_string .
945If a
946.Ql g
947is appended to the last slash of the pattern, all occurrences
948in each word are replaced.
949If
950.Ar old_string
951begins with a caret
952.Pq Ql ^ ,
953.Ar old_string
954is anchored at the beginning of each word.
955If
956.Ar old_string
957ends with a dollar sign
958.Pq Ql $ ,
959it is anchored at the end of each word.
960Inside
961.Ar new_string ,
962an ampersand
963.Pq Ql &
964is replaced by
965.Ar old_string .
966Any character may be used as a delimiter for the parts of the modifier
967string.
968The anchoring, ampersand, and delimiter characters may be escaped with a
969backslash
970.Pq Ql \e .
971.Pp
972Variable expansion occurs in the normal fashion inside both
973.Ar old_string
974and
975.Ar new_string
976with the single exception that a backslash is used to prevent the expansion
977of a dollar sign
978.Pq Ql $ ,
979not a preceding dollar sign as is usual.
980.It Ar :old_string=new_string
981This is the
982.At V
983style variable substitution.
984It must be the last modifier specified.
985If
986.Ar old_string
987or
988.Ar new_string
989do not contain the pattern matching character
990.Ar %
991then it is assumed that they are
992anchored at the end of each word, so only suffixes or entire
993words may be replaced.
994Otherwise
995.Ar %
996is the substring of
997.Ar old_string
998to be replaced in
999.Ar new_string .
1000.It Cm :T
1001Replaces each word in the variable with its last component.
1002.It Cm :tl
1003Converts variable to lower-case letters.
1004.It Cm :tu
1005Converts variable to upper-case letters.
1006.It Cm :U
1007Converts variable to upper-case letters.
1008(deprecated)
1009.It Cm :u
1010Remove adjacent duplicate words (like
1011.Xr uniq 1 ) .
1012.El
1013.Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS
1014Directives, conditionals, and for loops reminiscent
1015of the C programming language are provided in
1016.Nm .
1017All such structures are identified by a line beginning with a single
1018dot
1019.Pq Ql \&.
1020character.
1021The following directives are supported:
1022.Bl -tag -width Ds
1023.It Ic .include Ar <file>
1024.It Ic .include Ar \*qfile\*q
1025Include the specified makefile.
1026Variables between the angle brackets
1027or double quotes are expanded to form the file name.
1028If angle brackets
1029are used, the included makefile is expected to be in the system
1030makefile directory.
1031If double quotes are used, the including
1032makefile's directory and any directories specified using the
1033.Fl I
1034option are searched before the system
1035makefile directory.
1036.It Ic .sinclude Ar <file>
1037.It Ic .sinclude Ar \*qfile\*q
1038Like
1039.Ic .include ,
1040but silently ignored if the file cannot be found and opened.
1041.It Ic .undef Ar variable
1042Un-define the specified global variable.
1043Only global variables may be un-defined.
1044.It Ic .error Ar message
1045Terminate processing of the makefile immediately.
1046The filename of the
1047makefile, the line on which the error was encountered and the specified
1048message are printed to the standard error output and
1049.Nm
1050terminates with exit code 1.
1051Variables in the message are expanded.
1052.It Ic .warning Ar message
1053Emit a warning message.
1054The filename of the makefile,
1055the line on which the warning was encountered,
1056and the specified message are printed to the standard error output.
1057Variables in the message are expanded.
1058.El
1059.Pp
1060Conditionals are used to determine which parts of the Makefile
1061to process.
1062They are used similarly to the conditionals supported
1063by the C pre-processor.
1064The following conditionals are supported:
1065.Bl -tag -width Ds
1066.It Xo
1067.Ic .if
1068.Oo \&! Oc Ns Ar expression
1069.Op Ar operator expression ...
1070.Xc
1071Test the value of an expression.
1072.It Xo
1073.Ic .ifdef
1074.Oo \&! Oc Ns Ar variable
1075.Op Ar operator variable ...
1076.Xc
1077Test the value of a variable.
1078.It Xo
1079.Ic .ifndef
1080.Oo \&! Oc Ns Ar variable
1081.Op Ar operator variable ...
1082.Xc
1083Test the value of a variable.
1084.It Xo
1085.Ic .ifmake
1086.Oo \&! Oc Ns Ar target
1087.Op Ar operator target ...
1088.Xc
1089Test the target being built.
1090.It Xo
1091.Ic .ifnmake
1092.Oo \&! Oc Ns Ar target
1093.Op Ar operator target ...
1094.Xc
1095Test the target being built.
1096.It Ic .else
1097Reverse the sense of the last conditional.
1098.It Xo
1099.Ic .elif
1100.Oo \&! Oc Ns Ar expression
1101.Op Ar operator expression ...
1102.Xc
1103A combination of
1104.Ic .else
1105followed by
1106.Ic .if .
1107.It Xo
1108.Ic .elifdef
1109.Oo \&! Oc Ns Ar variable
1110.Op Ar operator variable ...
1111.Xc
1112A combination of
1113.Ic .else
1114followed by
1115.Ic .ifdef .
1116.It Xo
1117.Ic .elifndef
1118.Oo \&! Oc Ns Ar variable
1119.Op Ar operator variable ...
1120.Xc
1121A combination of
1122.Ic .else
1123followed by
1124.Ic .ifndef .
1125.It Xo
1126.Ic .elifmake
1127.Oo \&! Oc Ns Ar target
1128.Op Ar operator target ...
1129.Xc
1130A combination of
1131.Ic .else
1132followed by
1133.Ic .ifmake .
1134.It Xo
1135.Ic .elifnmake
1136.Oo \&! Oc Ns Ar target
1137.Op Ar operator target ...
1138.Xc
1139A combination of
1140.Ic .else
1141followed by
1142.Ic .ifnmake .
1143.It Ic .endif
1144End the body of the conditional.
1145.El
1146.Pp
1147The
1148.Ar operator
1149may be any one of the following:
1150.Bl -tag -width "Cm XX"
1151.It Cm ||
1152Logical
1153.Tn OR
1154.It Cm &&
1155Logical
1156.Tn AND ;
1157of higher precedence than
1158.Sq Ic || .
1159.El
1160.Pp
1161As in C,
1162.Nm
1163will only evaluate a conditional as far as is necessary to determine
1164its value.
1165Parentheses may be used to change the order of evaluation.
1166The boolean operator
1167.Sq Ic !\&
1168may be used to logically negate an entire
1169conditional.
1170It is of higher precedence than
1171.Sq Ic && .
1172.Pp
1173The value of
1174.Ar expression
1175may be any of the following:
1176.Bl -tag -width Ic
1177.It Ic defined
1178Takes a variable name as an argument and evaluates to true if the variable
1179has been defined.
1180.It Ic make
1181Takes a target name as an argument and evaluates to true if the target
1182was specified as part of
1183.Nm Ns 's
1184command line or was declared the default target (either implicitly or
1185explicitly, see
1186.Va .MAIN )
1187before the line containing the conditional.
1188.It Ic empty
1189Takes a variable, with possible modifiers, and evaluates to true if
1190the expansion of the variable would result in an empty string.
1191.It Ic exists
1192Takes a file name as an argument and evaluates to true if the file exists.
1193The file is searched for on the system search path (see
1194.Va .PATH ) .
1195.It Ic target
1196Takes a target name as an argument and evaluates to true if the target
1197has been defined.
1198.El
1199.Pp
1200An
1201.Ar expression
1202may also be a numeric or string comparison:
1203in this case, the left-hand side
1204.Ar must be
1205a variable expansion, whereas the right-hand side can be a
1206constant or a variable expansion.
1207Variable expansion is performed on both sides, after which the resulting
1208values are compared.
1209A value is interpreted as hexadecimal if it is
1210preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1211.Pp
1212String comparison can only use the
1213.Sq Ic ==
1214or
1215.Sq Ic !=
1216operators, whereas numeric values (both integer and floating point)
1217can also be compared using the
1218.Sq Ic > ,
1219.Sq Ic >= ,
1220.Sq Ic <
1221and
1222.Sq Ic <=
1223operators.
1224.Pp
1225If no relational operator (and right-hand value) are given, an implicit
1226.Sq Ic != 0
1227is used.
1228However be very careful in using this feature especially
1229when the left-hand side variable expansion returns a string.
1230.Pp
1231When
1232.Nm
1233is evaluating one of these conditional expressions, and it encounters
1234a word it does not recognize, either the
1235.Dq make
1236or
1237.Dq defined
1238expression is applied to it, depending on the form of the conditional.
1239If the form is
1240.Ic .if ,
1241.Ic .ifdef
1242or
1243.Ic .ifndef ,
1244the
1245.Dq defined
1246expression is applied.
1247Similarly, if the form is
1248.Ic .ifmake
1249or
1250.Ic .ifnmake ,
1251the
1252.Dq make
1253expression is applied.
1254.Pp
1255If the conditional evaluates to true the parsing of the makefile continues
1256as before.
1257If it evaluates to false, the following lines are skipped.
1258In both cases this continues until a
1259.Ic .else
1260or
1261.Ic .endif
1262is found.
1263.Pp
1264For loops are typically used to apply a set of rules to a list of files.
1265The syntax of a for loop is:
1266.Pp
1267.Bl -tag -width indent -compact
1268.It Ic .for Ar variable Ic in Ar expression
1269.It <make-rules>
1270.It Ic .endfor
1271.El
1272.Pp
1273After the for
1274.Ar expression
1275is evaluated, it is split into words.
1276The
1277iteration
1278.Ar variable
1279is successively set to each word, and substituted in the
1280.Ic make-rules
1281inside the body of the for loop.
1282.Sh COMMENTS
1283Comments begin with a hash
1284.Pq Ql #
1285character, anywhere but in a shell
1286command line, and continue to the end of the line.
1287.Sh SPECIAL SOURCES
1288.Bl -tag -width Ic
1289.It Ic .IGNORE
1290Ignore any errors from the commands associated with this target, exactly
1291as if they all were preceded by a dash
1292.Pq Ql \- .
1293.It Ic .MAKE
1294Execute the commands associated with this target even if the
1295.Fl n
1296or
1297.Fl t
1298options were specified.
1299Normally used to mark recursive
1300.Nm Ns 's .
1301.It Ic .NOTMAIN
1302Normally
1303.Nm
1304selects the first target it encounters as the default target to be built
1305if no target was specified.
1306This source prevents this target from being selected.
1307.It Ic .OPTIONAL
1308If a target is marked with this attribute and
1309.Nm
1310cannot figure out how to create it, it will ignore this fact and assume
1311the file is not needed or already exists.
1312.It Ic .PRECIOUS
1313When
1314.Nm
1315is interrupted, it removes any partially made targets.
1316This source prevents the target from being removed.
1317.It Ic .SILENT
1318Do not echo any of the commands associated with this target, exactly
1319as if they all were preceded by an at sign
1320.Pq Ql @ .
1321.It Ic .USE
1322Turn the target into
1323.Nm Ns 's
1324version of a macro.
1325When the target is used as a source for another target, the other target
1326acquires the commands, sources, and attributes (except for
1327.Ic .USE )
1328of the
1329source.
1330If the target already has commands, the
1331.Ic .USE
1332target's commands are appended
1333to them.
1334.It Ic .WAIT
1335If special
1336.Ic .WAIT
1337source appears in a dependency line, the sources that precede it are
1338made before the sources that succeed it in the line.
1339Loops are not being
1340detected and targets that form loops will be silently ignored.
1341.El
1342.Sh SPECIAL TARGETS
1343Special targets may not be included with other targets, i.e., they must be
1344the only target specified.
1345.Bl -tag -width Ic
1346.It Ic .BEGIN
1347Any command lines attached to this target are executed before anything
1348else is done.
1349.It Ic .DEFAULT
1350This is sort of a
1351.Ic .USE
1352rule for any target (that was used only as a
1353source) that
1354.Nm
1355cannot figure out any other way to create.
1356Only the shell script is used.
1357The
1358.Ic .IMPSRC
1359variable of a target that inherits
1360.Ic .DEFAULT Ns 's
1361commands is set
1362to the target's own name.
1363.It Ic .END
1364Any command lines attached to this target are executed after everything
1365else is done.
1366.It Ic .IGNORE
1367Mark each of the sources with the
1368.Ic .IGNORE
1369attribute.
1370If no sources are specified, this is the equivalent of specifying the
1371.Fl i
1372option.
1373.It Ic .INCLUDES
1374A list of suffixes that indicate files that can be included in a source
1375file.
1376The suffix must have already been declared with
1377.Ic .SUFFIXES ;
1378any suffix so declared will have the directories on its search path (see
1379.Ic .PATH )
1380placed in the
1381.Va .INCLUDES
1382special variable, each preceded by a
1383.Fl I
1384flag.
1385.It Ic .INTERRUPT
1386If
1387.Nm
1388is interrupted, the commands for this target will be executed.
1389.It Ic .LIBS
1390This does for libraries what
1391.Ic .INCLUDES
1392does for include files, except that the flag used is
1393.Fl L .
1394.It Ic .MAIN
1395If no target is specified when
1396.Nm
1397is invoked, this target will be built.
1398This is always set, either
1399explicitly, or implicitly when
1400.Nm
1401selects the default target, to give the user a way to refer to the default
1402target on the command line.
1403.It Ic .MAKEFILEDEPS
1404Enable the
1405.Dq Remaking Makefiles
1406functionality, as explained in the
1407.Sx REMAKING MAKEFILES
1408section below.
1409.It Ic .MAKEFLAGS
1410This target provides a way to specify flags for
1411.Nm
1412when the makefile is used.
1413The flags are as if typed to the shell, though the
1414.Fl f
1415option will have
1416no effect.
1417Flags (except for
1418.Fl f )
1419and variable assignments specified as the source
1420for this target are also appended to the
1421.Va .MAKEFLAGS
1422internal variable.
1423Please note the difference between this target and the
1424.Va .MAKEFLAGS
1425internal variable: specifying an option or variable
1426assignment as the source for this target will affect
1427.Em both
1428the current makefile and all processes that
1429.Nm
1430executes.
1431.It Ic .MFLAGS
1432Same as above, for backward compatibility.
1433.\" XXX: NOT YET!!!!
1434.\" .It Ic .NOTPARALLEL
1435.\" The named targets are executed in non parallel mode. If no targets are
1436.\" specified, then all targets are executed in non parallel mode.
1437.It Ic .NOTPARALLEL
1438Disable parallel mode.
1439.It Ic .NO_PARALLEL
1440Same as above, for compatibility with other
1441.Nm pmake
1442variants.
1443.It Ic .ORDER
1444The named targets are made in sequence.
1445.\" XXX: NOT YET!!!!
1446.\" .It Ic .PARALLEL
1447.\" The named targets are executed in parallel mode. If no targets are
1448.\" specified, then all targets are executed in parallel mode.
1449.It Ic .PATH
1450The sources are directories which are to be searched for files not
1451found in the current directory.
1452If no sources are specified, any previously specified directories are
1453deleted.
1454Where possible, use of
1455.Ic .PATH
1456is preferred over use of the
1457.Va VPATH
1458variable.
1459.It Ic .PATH\fIsuffix\fR
1460The sources are directories which are to be searched for suffixed files
1461not found in the current directory.
1462The
1463.Nm
1464utility
1465first searches the suffixed search path, before reverting to the default
1466path if the file is not found there.
1467This form is required for
1468.Ic .LIBS
1469and
1470.Ic .INCLUDES
1471to work.
1472.It Ic .PHONY
1473Apply the
1474.Ic .PHONY
1475attribute to any specified sources.
1476Targets with this attribute are always
1477considered to be out of date.
1478.It Ic .POSIX
1479Adjust
1480.Nm Ap s
1481behavior to match the applicable
1482.Tn POSIX
1483specifications.
1484(Note this disables the
1485.Dq Remaking Makefiles
1486feature.)
1487.It Ic .PRECIOUS
1488Apply the
1489.Ic .PRECIOUS
1490attribute to any specified sources.
1491If no sources are specified, the
1492.Ic .PRECIOUS
1493attribute is applied to every
1494target in the file.
1495.It Ic .SHELL
1496Select another shell.
1497The sources of this target have the format
1498.Ar key Ns = Ns Ar value .
1499The
1500.Ar key
1501is one of:
1502.Bl -tag -width ".Va hasErrCtl"
1503.It Va path
1504Specify the path to the new shell.
1505.It Va name
1506Specify the name of the new shell.
1507This may be either one of the three builtin shells (see below) or any
1508other name.
1509.It Va quiet
1510Specify the shell command to turn echoing off.
1511.It Va echo
1512Specify the shell command to turn echoing on.
1513.It Va filter
1514Usually shells print the echo off command before turning echoing off.
1515This is the exact string that will be printed by the shell and is used
1516to filter the shell output to remove the echo off command.
1517.It Va echoFlag
1518The shell option that turns echoing on.
1519.It Va errFlag
1520The shell option to turn on error checking.
1521If error checking is on, the shell should exit if a command returns
1522a non-zero status.
1523.It Va hasErrCtl
1524True if the shell has error control.
1525.It Va check
1526If
1527.Va hasErrCtl
1528is true then this is the shell command to turn error checking on.
1529If
1530.Va hasErrCtl
1531is false then this is a command template to echo commands for which error
1532checking is disabled.
1533The template must contain a
1534.Ql %s .
1535.It Va ignore
1536If
1537.Va hasErrCtl
1538is true, this is the shell command to turn error checking off.
1539If
1540.Va hasErrCtl
1541is false, this is a command template to execute a command so that errors
1542are ignored.
1543The template must contain a
1544.Ql %s .
1545.It Va meta
1546This is a string of meta characters of the shell.
1547.It Va builtins
1548This is a string holding all the shell's builtin commands separated by blanks.
1549The
1550.Va meta
1551and
1552.Va builtins
1553strings are used in compat mode.
1554When a command line contains neither a meta
1555character nor starts with a shell builtin, it is executed directly without
1556invoking a shell.
1557When one of these strings (or both) is empty all commands are executed
1558through a shell.
1559.It Va unsetenv
1560If true, remove the
1561.Ev ENV
1562environment variable before executing any command.
1563This is useful for the Korn-shell
1564.Pq Nm ksh .
1565.El
1566.Pp
1567Values that are strings must be surrounded by double quotes.
1568Boolean values are specified as
1569.Ql T
1570or
1571.Ql Y
1572(in either case) to mean true.
1573Any other value is taken to mean false.
1574.Pp
1575There are several uses of the
1576.Ic .SHELL
1577target:
1578.Bl -bullet
1579.It
1580Selecting one of the builtin shells.
1581This is done by just specifying the name of the shell with the
1582.Va name
1583keyword.
1584It is also possible to modify the parameters of the builtin shell by just
1585specifying other keywords (except for
1586.Va path ) .
1587.It
1588Using another executable for one of the builtin shells.
1589This is done by specifying the path to the executable with the
1590.Va path
1591keyword.
1592If the last component is the same as the name of the builtin shell, no
1593name needs to be specified; if it is different, the name must be given:
1594.Bd -literal -offset indent
1595\&.SHELL: path="/usr/local/bin/sh"
1596.Ed
1597.Pp
1598selects the builtin shell
1599.Dq Li sh
1600but will execute it from
1601.Pa /usr/local/bin/sh .
1602Like in the previous case, it is possible to modify parameters of the builtin
1603shell by just specifying them.
1604.It
1605Using an entirely different shell.
1606This is done by specifying all keywords.
1607.El
1608.Pp
1609The builtin shells are
1610.Dq Li sh ,
1611.Dq Li csh
1612and
1613.Dq Li ksh .
1614Because
1615.Fx
1616has no
1617.Nm ksh
1618in
1619.Pa /bin ,
1620it is unwise to specify
1621.Va name Ns = Ns Qq Li ksh
1622without also specifying a path.
1623.It Ic .SILENT
1624Apply the
1625.Ic .SILENT
1626attribute to any specified sources.
1627If no sources are specified, the
1628.Ic .SILENT
1629attribute is applied to every
1630command in the file.
1631.It Ic .SUFFIXES
1632Each source specifies a suffix to
1633.Nm .
1634If no sources are specified, any previous specified suffixes are deleted.
1635.It Ic .WARN
1636Each source specifies a warning flag as previously described for the
1637.Fl x
1638command line option.
1639Warning flags specified on the command line take precedence over flags
1640specified in the makefile.
1641Also, command line warning flags are pushed to sub-makes through the
1642.Ev MAKEFLAGS
1643environment variables so that a warning flag specified on the command
1644line will influence all sub-makes.
1645Several flags can be specified on a single
1646.Ic .WARN
1647target by separating them with blanks.
1648.El
1649.Sh REMAKING MAKEFILES
1650If the special target
1651.Ic .MAKEFILEDEPS
1652exists in the Makefile,
1653.Nm
1654enables the
1655.Dq Remaking Makefiles
1656feature.
1657After reading Makefile and all the files that are included using
1658.Ic .include
1659or
1660.Ic .sinclude
1661directives (source Makefiles)
1662.Nm
1663considers each source Makefile as a target and tries to rebuild it.
1664Both explicit and implicit rules are checked and all source Makefiles
1665are updated if necessary. If any of the source Makefiles were rebuilt,
1666.Nm
1667restarts from clean state.
1668.Pp
1669To prevent infinite loops the following source Makefile targets are ignored:
1670.Bl -bullet
1671.It
1672.Ic ::
1673targets that have no prerequisites
1674.It
1675.Ic \&!
1676targets
1677.It
1678targets that have
1679.Ic .PHONY
1680or
1681.Ic .EXEC
1682attributes
1683.It
1684targets without prerequisites and without commands
1685.El
1686.Pp
1687When remaking a source Makefile options
1688.Ic -t
1689(touch target),
1690.Ic -q
1691(query mode), and
1692.Ic -n
1693(no exec) do not take effect, unless source Makefile is specified
1694explicitly as a target in
1695.Nm
1696command line.
1697.Pp
1698Additionally, system makefiles and
1699.Ic .depend
1700are not considered as Makefiles that can be rebuilt.
1701.Sh ENVIRONMENT
1702The
1703.Nm
1704utility uses the following environment variables, if they exist:
1705.Ev MACHINE ,
1706.Ev MAKE ,
1707.Ev MAKEFLAGS ,
1708.Ev MAKEOBJDIR ,
1709.Ev MAKEOBJDIRPREFIX ,
1710and
1711.Ev MAKESYSPATH .
1712.Sh FILES
1713.Bl -tag -width /usr/share/doc/psd/12.make -compact
1714.It Pa .depend
1715list of dependencies
1716.It Pa Makefile
1717list of dependencies
1718.It Pa makefile
1719list of dependencies
1720.It Pa obj
1721object directory
1722.It Pa sys.mk
1723system makefile
1724.It Pa /usr/share/mk
1725default system makefile directory
1726.It Pa /usr/share/doc/psd/12.make
1727PMake tutorial
1728.It Pa /usr/obj
1729default
1730.Ev MAKEOBJDIRPREFIX
1731directory.
1732.It Pa /etc/make.conf
1733default path to
1734.Xr make.conf 5
1735.El
1736.Sh EXAMPLES
1737List all included makefiles in order visited:
1738.Pp
1739.Dl "make -V .MAKEFILE_LIST | tr \e\  \e\en"
1740.Sh COMPATIBILITY
1741Older versions of
1742.Nm
1743used
1744.Ev MAKE
1745instead of
1746.Ev MAKEFLAGS .
1747This was removed for
1748.Tn POSIX
1749compatibility.
1750The internal variable
1751.Va MAKE
1752is set to the same value as
1753.Va .MAKE ;
1754support for this may be removed in the future.
1755.Pp
1756The use of the
1757.Cm :L
1758and
1759.Cm :U
1760modifiers are deprecated
1761in
1762.Fx 10.0
1763and the more portable (among Pmake decedents)
1764.Cm :tl
1765and
1766.Cm :tu
1767should be used instead.
1768.Pp
1769Most of the more esoteric features of
1770.Nm
1771should probably be avoided for greater compatibility.
1772.Sh SEE ALSO
1773.Xr mkdep 1 ,
1774.Xr make.conf 5
1775.Rs
1776.%T "PMake - A Tutorial"
1777.Re
1778in
1779.Pa /usr/share/doc/psd/12.make
1780.Sh HISTORY
1781A
1782.Nm
1783command appeared in PWB UNIX.
1784.Sh BUGS
1785The determination of
1786.Va .OBJDIR
1787is contorted to the point of absurdity.
1788.Pp
1789In the presence of several
1790.Ic .MAIN
1791special targets,
1792.Nm
1793silently ignores all but the first.
1794.Pp
1795.Va .TARGETS
1796is not set to the default target when
1797.Nm
1798is invoked without a target name and no
1799.Ic .MAIN
1800special target exists.
1801.Pp
1802The evaluation of
1803.Ar expression
1804in a test is very simple-minded.
1805Currently, the only form that works is
1806.Ql .if ${VAR} op something .
1807For instance, you should write tests as
1808.Ql .if ${VAR} == "string"
1809not the other way around, which would give you an error.
1810.Pp
1811For loops are expanded before tests, so a fragment such as:
1812.Bd -literal -offset indent
1813\&.for ARCH in ${SHARED_ARCHS}
1814\&.if ${ARCH} == ${MACHINE}
1815     ...
1816\&.endif
1817\&.endfor
1818.Ed
1819.Pp
1820will not work, and should be rewritten as:
1821.Bd -literal -offset indent
1822\&.for ARCH in ${SHARED_ARCHS}
1823\&.if ${MACHINE} == ${ARCH}
1824     ...
1825\&.endif
1826\&.endfor
1827.Ed
1828.Pp
1829The parsing code is broken with respect to handling a semicolon
1830after a colon, so a fragment like this will fail:
1831.Bd -literal -offset indent
1832HDRS=   foo.h bar.h
1833
1834all:
1835\&.for h in ${HDRS:S;^;${.CURDIR}/;}
1836     ...
1837\&.endfor
1838.Ed
1839.Pp
1840A trailing backslash in a variable value defined on the command line causes
1841the delimiting space in the
1842.Ev MAKEFLAGS
1843environment variable to be preceded by that backslash.
1844That causes a submake to not treat that space as a word delimiter.
1845Fixing this requires a larger rewrite of the code handling command line
1846macros and assignments to
1847.Va .MAKEFLAGS .
1848