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