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