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