1 .\" $NetBSD: make.1,v 1.179 2010/06/30 01:03:54 dholland Exp $
3 .\" Copyright (c) 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
37 .Nd maintain program dependencies
77 is a program designed to simplify the maintenance of other programs.
78 Its input is a list of specifications as to the files upon which programs
79 and other files depend.
82 makefile option is given,
88 in order to find the specifications.
91 exists, it is read (see
94 This manual page is intended as a reference document only.
95 For a more thorough description of
97 and makefiles, please refer to
98 .%T "Make \- A Tutorial" .
101 will prepend the contents of the
103 environment variable to the command line arguments before parsing them.
105 The options are as follows:
108 Try to be backwards compatible by executing a single shell per command and
109 by executing the commands to make the sources of a dependency line in sequence.
110 .It Fl C Ar directory
113 before reading the makefiles or doing anything else.
116 options are specified, each is interpreted relative to the previous one:
117 .Fl C Pa / Fl C Pa etc
123 to be 1, in the global context.
125 Turn on debugging, and specify which portions of
127 are to print debugging information.
128 Unless the flags are preceded by
130 they are added to the
132 environment variable and will be processed by any child make processes.
133 By default, debugging information is printed to standard error,
134 but this can be changed using the
137 The debugging output is always unbuffered; in addition, if debugging
138 is enabled but debugging output is not directed to standard output,
139 then the standard output is line buffered.
141 is one or more of the following:
144 Print all possible debugging information;
145 equivalent to specifying all of the debugging flags.
147 Print debugging information about archive searching and caching.
149 Print debugging information about current working directory.
151 Print debugging information about conditional evaluation.
153 Print debugging information about directory searching and caching.
155 Print debugging information about failed commands and targets.
156 .It Ar F Ns Oo Sy \&+ Oc Ns Ar filename
157 Specify where debugging output is written.
158 This must be the last flag, because it consumes the remainder of
160 If the character immediately after the
164 then the file will be opened in append mode;
165 otherwise the file will be overwritten.
170 then debugging output will be written to the
171 standard output or standard error output file descriptors respectively
174 option has no effect).
175 Otherwise, the output will be written to the named file.
176 If the file name ends
180 is replaced by the pid.
182 Print debugging information about loop evaluation.
184 Print the input graph before making anything.
186 Print the input graph after making everything, or before exiting
189 Print the input graph before exiting on error.
191 Print debugging information about running multiple shells.
193 Print commands in Makefiles regardless of whether or not they are prefixed by
195 or other "quiet" flags.
196 Also known as "loud" behavior.
198 Print debugging information about making targets, including modification
201 Don't delete the temporary command scripts created when running commands.
202 These temporary scripts are created in the directory
205 environment variable, or in
209 is unset or set to the empty string.
210 The temporary scripts are created by
212 and have names of the form
215 This can create many files in
221 Print debugging information about makefile parsing.
223 Print debugging information about suffix-transformation rules.
225 Print debugging information about target list maintenance.
227 Print debugging information about variable assignment.
229 Run shell commands with
231 so the actual commands are printed as they are executed.
234 Specify that environment variables override macro assignments within
237 Specify a makefile to read instead of the default
243 standard input is read.
244 Multiple makefiles may be specified, and are read in the order specified.
245 .It Fl I Ar directory
246 Specify a directory in which to search for makefiles and included makefiles.
247 The system makefile directory (or directories, see the
249 option) is automatically included as part of this list.
251 Ignore non-zero exit of shell commands in the makefile.
252 Equivalent to specifying
254 before each command line in the makefile.
258 be specified by the user.
262 option is in use in a recursive build, this option is passed by a make
263 to child makes to allow all the make processes in the build to
264 cooperate to avoid overloading the system.
266 Specify the maximum number of jobs that
268 may have running at any one time.
269 Turns compatibility mode off, unless the
271 flag is also specified.
272 When compatibility mode is off, all commands associated with a
273 target are executed in a single shell invocation as opposed to the
274 traditional one shell invocation per line.
275 This can break traditional scripts which change directories on each
276 command invocation and then expect to start with a fresh environment
278 It is more efficient to correct the scripts rather than turn backwards
281 Continue processing after errors are encountered, but only on those targets
282 that do not depend on the target whose creation caused the error.
283 .It Fl m Ar directory
284 Specify a directory in which to search for sys.mk and makefiles included
286 .Ao Ar file Ac Ns -style
290 option can be used multiple times to form a search path.
291 This path will override the default system include path: /usr/share/mk.
292 Furthermore the system include path will be appended to the search path used
294 .Qo Ar file Qc Ns -style
295 include statements (see the
299 If a file or directory name in the
303 environment variable) starts with the string
307 will search for the specified file or directory named in the remaining part
308 of the argument string.
309 The search starts with the current directory of
310 the Makefile and then works upward towards the root of the filesystem.
311 If the search is successful, then the resulting directory replaces the
316 If used, this feature allows
318 to easily search in the current source tree for customized sys.mk files
323 Display the commands that would have been executed, but do not
324 actually execute them unless the target depends on the .MAKE special
327 Display the commands which would have been executed, but do not
328 actually execute any of them; useful for debugging top-level makefiles
329 without descending into subdirectories.
331 Do not execute any commands, but exit 0 if the specified targets are
332 up-to-date and 1, otherwise.
334 Do not use the built-in rules specified in the system makefile.
336 Do not echo any commands as they are executed.
337 Equivalent to specifying
339 before each command line in the makefile.
340 .It Fl T Ar tracefile
344 append a trace record to
346 for each job started and completed.
348 Rather than re-building a target as specified in the makefile, create it
349 or update its modification time to make it appear up-to-date.
355 in the global context.
356 Do not build any targets.
357 Multiple instances of this option may be specified;
358 the variables will be printed one per line,
359 with a blank line for each null or undefined variable.
364 then the value will be expanded before printing.
366 Treat any warnings during makefile parsing as errors.
368 Don't export variables passed on the command line to the environment
370 Variables passed on the command line are still exported
373 environment variable.
374 This option may be useful on systems which have a small limit on the
375 size of command arguments.
376 .It Ar variable=value
377 Set the value of the variable
381 Normally, all values passed on the command line are also exported to
382 sub-makes in the environment.
385 flag disables this behavior.
386 Variable assignments should follow options for POSIX compatibility
387 but no ordering is enforced.
390 There are seven different types of lines in a makefile: file dependency
391 specifications, shell commands, variable assignments, include statements,
392 conditional directives, for loops, and comments.
394 In general, lines may be continued from one line to the next by ending
395 them with a backslash
397 The trailing newline character and initial whitespace on the following
398 line are compressed into a single space.
399 .Sh FILE DEPENDENCY SPECIFICATIONS
400 Dependency lines consist of one or more targets, an operator, and zero
402 This creates a relationship where the targets
405 and are usually created from them.
406 The exact relationship between the target and the source is determined
407 by the operator that separates them.
408 The three operators are as follows:
411 A target is considered out-of-date if its modification time is less than
412 those of any of its sources.
413 Sources for a target accumulate over dependency lines when this operator
415 The target is removed if
419 Targets are always re-created, but not until all sources have been
420 examined and re-created as necessary.
421 Sources for a target accumulate over dependency lines when this operator
423 The target is removed if
427 If no sources are specified, the target is always re-created.
428 Otherwise, a target is considered out-of-date if any of its sources has
429 been modified more recently than the target.
430 Sources for a target do not accumulate over dependency lines when this
432 The target will not be removed if
437 Targets and sources may contain the shell wildcard values
448 may only be used as part of the final
449 component of the target or source, and must be used to describe existing
453 need not necessarily be used to describe existing files.
454 Expansion is in directory order, not alphabetically as done in the shell.
456 Each target may have associated with it a series of shell commands, normally
457 used to create the target.
458 Each of the commands in this script
460 be preceded by a tab.
461 While any target may appear on a dependency line, only one of these
462 dependencies may be followed by a creation script, unless the
466 If the first characters of the command line are any combination of
471 the command is treated specially.
474 causes the command not to be echoed before it is executed.
477 causes the command to be executed even when
480 This is similar to the effect of the .MAKE special source,
481 except that the effect can be limited to a single line of a script.
484 causes any non-zero exit status of the command line to be ignored.
485 .Sh VARIABLE ASSIGNMENTS
486 Variables in make are much like variables in the shell, and, by tradition,
487 consist of all upper-case letters.
488 .Ss Variable assignment modifiers
489 The five operators that can be used to assign values to variables are as
493 Assign the value to the variable.
494 Any previous value is overridden.
496 Append the value to the current value of the variable.
498 Assign the value to the variable if it is not already defined.
500 Assign with expansion, i.e. expand the value before assigning it
502 Normally, expansion is not done until the variable is referenced.
504 References to undefined variables are
507 This can cause problems when variable modifiers are used.
509 Expand the value and pass it to the shell for execution and assign
510 the result to the variable.
511 Any newlines in the result are replaced with spaces.
514 Any white-space before the assigned
516 is removed; if the value is being appended, a single space is inserted
517 between the previous contents of the variable and the appended value.
519 Variables are expanded by surrounding the variable name with either
524 and preceding it with
527 If the variable name contains only a single letter, the surrounding
528 braces or parentheses are not required.
529 This shorter form is not recommended.
531 If the variable name contains a dollar, then the name itself is expanded first.
532 This allows almost arbitrary variable names, however names containing dollar,
533 braces, parenthesis, or whitespace are really best avoided!
535 If the result of expanding a variable contains a dollar sign
537 the string is expanded again.
539 Variable substitution occurs at three distinct times, depending on where
540 the variable is being used.
543 Variables in dependency lines are expanded as the line is read.
545 Variables in shell commands are expanded when the shell command is
549 loop index variables are expanded on each loop iteration.
550 Note that other variables are not expanded inside loops so
551 the following example code:
552 .Bd -literal -offset indent
566 .Bd -literal -offset indent
571 Because while ${a} contains
573 after the loop is executed, ${b}
578 since after the loop completes ${j} contains
582 The four different classes of variables (in order of increasing precedence)
585 .It Environment variables
586 Variables defined as part of
590 Variables defined in the makefile or in included makefiles.
591 .It Command line variables
592 Variables defined as part of the command line.
594 Variables that are defined specific to a certain target.
595 The seven local variables are as follows:
596 .Bl -tag -width ".ARCHIVE"
598 The list of all sources for this target; also known as
601 The name of the archive file.
603 In suffix-transformation rules, the name/path of the source from which the
604 target is to be transformed (the
606 source); also known as
608 It is not defined in explicit rules.
610 The name of the archive member.
612 The list of sources for this target that were deemed out-of-date; also
616 The file prefix of the target, containing only the file portion, no suffix
617 or preceding directory components; also known as
620 The name of the target; also known as
631 are permitted for backward
632 compatibility with historical makefiles and are not recommended.
641 are permitted for compatibility with
643 makefiles and are not recommended.
645 Four of the local variables may be used in sources on dependency lines
646 because they expand to the proper value for each target on the line.
654 .Ss Additional built-in variables
657 sets or knows about the following variables:
658 .Bl -tag -width .MAKEOVERRIDES
664 expands to a single dollar
667 The list of all targets encountered in the Makefile.
669 Makefile parsing, lists only those targets encountered thus far.
671 A path to the directory where
674 Refer to the description of
687 The preferred variable to use is the environment variable
689 because it is more compatible with other versions of
691 and cannot be confused with the special target with the same name.
692 .It Va .MAKE.DEPENDFILE
693 Names the makefile (default
695 from which generated dependencies are read.
696 .It Va .MAKE.EXPORTED
697 The list of variables exported by
703 .It Va .MAKE.JOB.PREFIX
708 then output for each target is prefixed with a token
710 the first part of which can be controlled via
711 .Va .MAKE.JOB.PREFIX .
714 .Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
715 would produce tokens like
716 .Ql ---make[1234] target ---
717 making it easier to track the degree of parallelism being achieved.
719 The environment variable
721 may contain anything that
725 Anything specified on
727 command line is appended to the
729 variable which is then
730 entered into the environment for all programs which
734 The recursion depth of
736 The initial instance of
738 will be 0, and an incremented value is put into the environment
739 to be seen by the next generation.
740 This allows tests like:
741 .Li .if ${.MAKE.LEVEL} == 0
742 to protect things which should only be evaluated in the initial instance of
744 .It Va .MAKE.MAKEFILE_PREFERENCE
745 The ordered list of makefile names
752 .It Va .MAKE.MAKEFILES
753 The list of makefiles read by
755 which is useful for tracking dependencies.
756 Each makefile is recorded only once, regardless of the number of times read.
758 Processed after reading all makefiles.
759 Can affect the mode that
765 .It Va .MAKEOVERRIDES
766 This variable is used to record the names of variables assigned to
767 on the command line, so that they may be exported as part of
769 This behaviour can be disabled by assigning an empty value to
770 .Ql Va .MAKEOVERRIDES
772 Extra variables can be exported from a makefile
773 by appending their names to
774 .Ql Va .MAKEOVERRIDES .
776 is re-exported whenever
777 .Ql Va .MAKEOVERRIDES
783 The parent process-id of
785 .It Va MAKE_PRINT_VAR_ON_ERROR
788 stops due to an error, it prints its name and the value of
790 as well as the value of any variables named in
791 .Ql Va MAKE_PRINT_VAR_ON_ERROR .
793 This variable is simply assigned a newline character as its value.
794 This allows expansions using the
796 modifier to put a newline between
797 iterations of the loop rather than a space.
798 For example, the printing of
799 .Ql Va MAKE_PRINT_VAR_ON_ERROR
800 could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
802 A path to the directory where the targets are built.
803 Its value is determined by trying to
805 to the following directories in order and using the first match:
808 .Ev ${MAKEOBJDIRPREFIX}${.CURDIR}
811 .Ql Ev MAKEOBJDIRPREFIX
812 is set in the environment or on the command line.)
818 is set in the environment or on the command line.)
820 .Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE}
822 .Ev ${.CURDIR} Ns Pa /obj
824 .Pa /usr/obj/ Ns Ev ${.CURDIR}
829 Variable expansion is performed on the value before it's used,
830 so expressions such as
831 .Dl ${.CURDIR:S,^/usr/src,/var/obj,}
833 This is especially useful with
837 may be modified in the makefile as a global variable.
846 to that directory before executing any targets.
849 A path to the directory of the current
853 The basename of the current
858 are both set only while the
862 A variable that represents the list of directories that
864 will search for files.
865 The search list should be updated using the target
867 rather than the variable.
869 Alternate path to the current directory.
873 to the canonical path given by
875 However, if the environment variable
877 is set and gives a path to the current directory, then
884 This behaviour is disabled if
885 .Ql Ev MAKEOBJDIRPREFIX
888 contains a variable transform.
890 is set to the value of
892 for all programs which
896 The list of targets explicitly specified on the command line, if any.
900 lists of directories that
902 will search for files.
903 The variable is supported for compatibility with old make programs only,
908 .Ss Variable modifiers
909 Variable expansion may be modified to select or modify each word of the
912 is white-space delimited sequence of characters).
913 The general format of a variable expansion is as follows:
915 .Dl ${variable[:modifier[:...]]}
917 Each modifier begins with a colon,
918 which may be escaped with a backslash
921 A set of modifiers can be specified via a variable, as follows:
923 .Dl modifier_variable=modifier[:...]
924 .Dl ${variable:${modifier_variable}[:...]}
926 In this case the first modifier in the modifier_variable does not
927 start with a colon, since that must appear in the referencing
929 If any of the modifiers in the modifier_variable contain a dollar sign
931 these must be doubled to avoid early expansion.
933 The supported modifiers are:
936 Replaces each word in the variable with its suffix.
938 Replaces each word in the variable with everything but the last component.
939 .It Cm \&:M Ns Ar pattern
940 Select only those words that match
942 The standard shell wildcard characters
949 The wildcard characters may be escaped with a backslash
951 .It Cm \&:N Ns Ar pattern
954 but selects all words which do not match
957 Order every word in variable alphabetically.
959 reverse order use the
961 combination of modifiers.
963 Randomize words in variable.
964 The results will be different each time you are referring to the
965 modified variable; use the assignment with expansion
967 to prevent such behaviour.
969 .Bd -literal -offset indent
970 LIST= uno due tre quattro
971 RANDOM_LIST= ${LIST:Ox}
972 STATIC_RANDOM_LIST:= ${LIST:Ox}
975 @echo "${RANDOM_LIST}"
976 @echo "${RANDOM_LIST}"
977 @echo "${STATIC_RANDOM_LIST}"
978 @echo "${STATIC_RANDOM_LIST}"
980 may produce output similar to:
981 .Bd -literal -offset indent
988 Quotes every shell meta-character in the variable, so that it can be passed
989 safely through recursive invocations of
992 Replaces each word in the variable with everything but its suffix.
994 Attempt to convert variable to an absolute path using
996 if that fails, the value is unchanged.
998 Converts variable to lower-case letters.
1000 Words in the variable are normally separated by a space on expansion.
1001 This modifier sets the separator to the character
1005 is omitted, then no separator is used.
1006 The common escapes (including octal numeric codes), work as expected.
1008 Converts variable to upper-case letters.
1010 Causes the value to be treated as a single word
1011 (possibly containing embedded white space).
1015 Causes the value to be treated as a sequence of
1016 words delimited by white space.
1020 .It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW
1022 Modify the first occurrence of
1024 in the variable's value, replacing it with
1028 is appended to the last slash of the pattern, all occurrences
1029 in each word are replaced.
1032 is appended to the last slash of the pattern, only the first word
1036 is appended to the last slash of the pattern,
1037 then the value is treated as a single word
1038 (possibly containing embedded white space).
1044 is anchored at the beginning of each word.
1047 ends with a dollar sign
1049 it is anchored at the end of each word.
1060 Any character may be used as a delimiter for the parts of the modifier
1062 The anchoring, ampersand and delimiter characters may be escaped with a
1066 Variable expansion occurs in the normal fashion inside both
1070 with the single exception that a backslash is used to prevent the expansion
1073 not a preceding dollar sign as is usual.
1075 .It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW
1079 modifier is just like the
1081 modifier except that the old and new strings, instead of being
1082 simple strings, are a regular expression (see
1090 Normally, the first occurrence of the pattern
1092 in each word of the value is substituted with
1096 modifier causes the substitution to apply to at most one word; the
1098 modifier causes the substitution to apply to as many instances of the
1101 as occur in the word or words it is found in; the
1103 modifier causes the value to be treated as a single word
1104 (possibly containing embedded white space).
1109 are orthogonal; the former specifies whether multiple words are
1110 potentially affected, the latter whether multiple substitutions can
1111 potentially occur within each affected word.
1113 Replaces each word in the variable with its last component.
1115 Remove adjacent duplicate words (like
1118 .It Cm \&:\&? Ar true_string Cm \&: Ar false_string
1120 If the variable name (not its value), when parsed as a .if conditional
1121 expression, evaluates to true, return as its value the
1123 otherwise return the
1125 Since the variable name is used as the expression, \&:\&? must be the
1126 first modifier after the variable name itself - which will, of course,
1127 usually contain variable expansions.
1128 A common error is trying to use expressions like
1129 .Dl ${NUMBERS:M42:?match:no}
1130 which actually tests defined(NUMBERS),
1131 to determine is any words match "42" you need to use something like:
1132 .Dl ${${NUMBERS:M42} != "":?match:no} .
1133 .It Ar :old_string=new_string
1136 style variable substitution.
1137 It must be the last modifier specified.
1142 do not contain the pattern matching character
1144 then it is assumed that they are
1145 anchored at the end of each word, so only suffixes or entire
1146 words may be replaced.
1154 Variable expansion occurs in the normal fashion inside both
1158 with the single exception that a backslash is used to prevent the
1159 expansion of a dollar sign
1161 not a preceding dollar sign as is usual.
1163 .It Cm \&:@ Ar temp Cm @ Ar string Cm @
1165 This is the loop expansion mechanism from the OSF Development
1166 Environment (ODE) make.
1169 loops expansion occurs at the time of
1173 to each word in the variable and evaluate
1175 The ODE convention is that
1177 should start and end with a period.
1179 .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1180 .It Cm \&:U Ns Ar newval
1181 If the variable is undefined
1184 If the variable is defined, the existing value is returned.
1185 This is another ODE make feature.
1186 It is handy for setting per-target CFLAGS for instance:
1187 .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1188 If a value is only required if the variable is undefined, use:
1189 .Dl ${VAR:D:Unewval}
1190 .It Cm \&:D Ns Ar newval
1191 If the variable is defined
1195 The name of the variable is the value.
1197 The path of the node which has the same name as the variable
1199 If no such node exists or its path is null, then the
1200 name of the variable is used.
1202 .It Cm \&:\&! Ar cmd Cm \&!
1204 The output of running
1208 If the variable is non-empty it is run as a command and the output
1209 becomes the new value.
1210 .It Cm \&::= Ns Ar str
1211 The variable is assigned the value
1214 This modifier and its variations are useful in
1215 obscure situations such as wanting to set a variable when shell commands
1217 These assignment modifiers always expand to
1218 nothing, so if appearing in a rule line by themselves should be
1219 preceded with something to keep
1225 helps avoid false matches with the
1229 modifier and since substitution always occurs the
1231 form is vaguely appropriate.
1232 .It Cm \&::?= Ns Ar str
1235 but only if the variable does not already have a value.
1236 .It Cm \&::+= Ns Ar str
1240 .It Cm \&::!= Ns Ar cmd
1241 Assign the output of
1244 .It Cm \&:\&[ Ns Ar range Ns Cm \&]
1245 Selects one or more words from the value,
1246 or performs other operations related to the way in which the
1247 value is divided into words.
1249 Ordinarily, a value is treated as a sequence of words
1250 delimited by white space.
1251 Some modifiers suppress this behaviour,
1252 causing a value to be treated as a single word
1253 (possibly containing embedded white space).
1254 An empty value, or a value that consists entirely of white-space,
1255 is treated as a single word.
1256 For the purposes of the
1258 modifier, the words are indexed both forwards using positive integers
1259 (where index 1 represents the first word),
1260 and backwards using negative integers
1261 (where index -1 represents the last word).
1265 is subjected to variable expansion, and the expanded result is
1266 then interpreted as follows:
1267 .Bl -tag -width index
1270 Selects a single word from the value.
1272 .It Ar start Ns Cm \&.. Ns Ar end
1273 Selects all words from
1280 selects all words from the second word to the last word.
1285 then the words are output in reverse order.
1288 selects all the words from last to first.
1291 Causes subsequent modifiers to treat the value as a single word
1292 (possibly containing embedded white space).
1293 Analogous to the effect of
1302 Causes subsequent modifiers to treat the value as a sequence of words
1303 delimited by white space.
1304 Analogous to the effect of
1309 Returns the number of words in the value.
1312 .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1313 Makefile inclusion, conditional structures and for loops reminiscent
1314 of the C programming language are provided in
1316 All such structures are identified by a line beginning with a single
1320 Files are included with either
1321 .Cm \&.include Aq Ar file
1323 .Cm \&.include Pf \*q Ar file Ns \*q .
1324 Variables between the angle brackets or double quotes are expanded
1325 to form the file name.
1326 If angle brackets are used, the included makefile is expected to be in
1327 the system makefile directory.
1328 If double quotes are used, the including makefile's directory and any
1329 directories specified using the
1331 option are searched before the system
1333 For compatibility with other versions of
1335 .Ql include file ...
1337 If the include statement is written as
1341 then errors locating and/or opening include files are ignored.
1343 Conditional expressions are also preceded by a single dot as the first
1344 character of a line.
1345 The possible conditionals are as follows:
1347 .It Ic .error Ar message
1348 The message is printed along with the name of the makefile and line number,
1352 .It Ic .export Ar variable ...
1353 Export the specified global variable.
1354 If no variable list is provided, all globals are exported
1355 except for internal variables (those that start with
1357 This is not affected by the
1359 flag, so should be used with caution.
1361 Appending a variable name to
1363 is equivalent to exporting a variable.
1364 .It Ic .export-env Ar variable ...
1367 except that the variable is not appended to
1368 .Va .MAKE.EXPORTED .
1369 This allows exporting a value to the environment which is different from that
1373 .It Ic .info Ar message
1374 The message is printed along with the name of the makefile and line number.
1375 .It Ic .undef Ar variable
1376 Un-define the specified global variable.
1377 Only global variables may be un-defined.
1378 .It Ic .unexport Ar variable ...
1381 The specified global
1383 will be removed from
1384 .Va .MAKE.EXPORTED .
1385 If no variable list is provided, all globals are unexported,
1389 .It Ic .unexport-env
1390 Unexport all globals previously exported and
1391 clear the environment inherited from the parent.
1392 This operation will cause a memory leak of the original environment,
1393 so should be used sparingly.
1396 being 0, would make sense.
1397 Also note that any variables which originated in the parent environment
1398 should be explicitly preserved if desired.
1400 .Bd -literal -offset indent
1401 .Li .if ${.MAKE.LEVEL} == 0
1408 Would result in an environment containing only
1410 which is the minimal useful environment.
1413 will also be pushed into the new environment.
1414 .It Ic .warning Ar message
1415 The message prefixed by
1417 is printed along with the name of the makefile and line number.
1418 .It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ...
1419 Test the value of an expression.
1420 .It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1421 Test the value of a variable.
1422 .It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1423 Test the value of a variable.
1424 .It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1425 Test the target being built.
1426 .It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ...
1427 Test the target being built.
1429 Reverse the sense of the last conditional.
1430 .It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ...
1435 .It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1440 .It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1445 .It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1450 .It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1456 End the body of the conditional.
1461 may be any one of the following:
1462 .Bl -tag -width "Cm XX"
1465 .It Cm \&\*[Am]\*[Am]
1468 of higher precedence than
1474 will only evaluate a conditional as far as is necessary to determine
1476 Parentheses may be used to change the order of evaluation.
1477 The boolean operator
1479 may be used to logically negate an entire
1481 It is of higher precedence than
1482 .Ql Ic \&\*[Am]\*[Am] .
1486 may be any of the following:
1487 .Bl -tag -width defined
1489 Takes a variable name as an argument and evaluates to true if the variable
1492 Takes a target name as an argument and evaluates to true if the target
1493 was specified as part of
1495 command line or was declared the default target (either implicitly or
1498 before the line containing the conditional.
1500 Takes a variable, with possible modifiers, and evaluates to true if
1501 the expansion of the variable would result in an empty string.
1503 Takes a file name as an argument and evaluates to true if the file exists.
1504 The file is searched for on the system search path (see
1507 Takes a target name as an argument and evaluates to true if the target
1510 Takes a target name as an argument and evaluates to true if the target
1511 has been defined and has commands associated with it.
1515 may also be an arithmetic or string comparison.
1516 Variable expansion is
1517 performed on both sides of the comparison, after which the integral
1518 values are compared.
1519 A value is interpreted as hexadecimal if it is
1520 preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1521 The standard C relational operators are all supported.
1523 variable expansion, either the left or right hand side of a
1527 operator is not an integral value, then
1528 string comparison is performed between the expanded
1530 If no relational operator is given, it is assumed that the expanded
1531 variable is being compared against 0 or an empty string in the case
1532 of a string comparison.
1536 is evaluating one of these conditional expressions, and it encounters
1537 a (white-space separated) word it doesn't recognize, either the
1541 expression is applied to it, depending on the form of the conditional.
1549 expression is applied.
1550 Similarly, if the form is
1553 .Ql Ic .ifnmake , the
1555 expression is applied.
1557 If the conditional evaluates to true the parsing of the makefile continues
1559 If it evaluates to false, the following lines are skipped.
1560 In both cases this continues until a
1566 For loops are typically used to apply a set of rules to a list of files.
1567 The syntax of a for loop is:
1569 .Bl -tag -compact -width Ds
1570 .It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression
1577 is evaluated, it is split into words.
1578 On each iteration of the loop, one word is taken and assigned to each
1582 are substituted into the
1584 inside the body of the for loop.
1585 The number of words must come out even; that is, if there are three
1586 iteration variables, the number of words provided must be a multiple
1589 Comments begin with a hash
1591 character, anywhere but in a shell
1592 command line, and continue to the end of an unescaped new line.
1593 .Sh SPECIAL SOURCES (ATTRIBUTES)
1594 .Bl -tag -width .IGNOREx
1596 Target is never out of date, but always execute commands anyway.
1598 Ignore any errors from the commands associated with this target, exactly
1599 as if they all were preceded by a dash
1601 .\" .It Ic .INVISIBLE
1606 Mark all sources of this target as being up-to-date.
1608 Execute the commands associated with this target even if the
1612 options were specified.
1613 Normally used to mark recursive
1616 Do not search for the target in the directories specified by
1621 selects the first target it encounters as the default target to be built
1622 if no target was specified.
1623 This source prevents this target from being selected.
1625 If a target is marked with this attribute and
1627 can't figure out how to create it, it will ignore this fact and assume
1628 the file isn't needed or already exists.
1631 correspond to an actual file; it is always considered to be out of date,
1632 and will not be created with the
1635 Suffix-transformation rules are not applied to
1641 is interrupted, it normally removes any partially made targets.
1642 This source prevents the target from being removed.
1647 Do not echo any of the commands associated with this target, exactly
1648 as if they all were preceded by an at sign
1651 Turn the target into
1654 When the target is used as a source for another target, the other target
1655 acquires the commands, sources, and attributes (except for
1659 If the target already has commands, the
1661 target's commands are appended
1668 target commands to the target.
1672 appears in a dependency line, the sources that precede it are
1673 made before the sources that succeed it in the line.
1674 Since the dependents of files are not made until the file itself
1675 could be made, this also stops the dependents being built unless they
1676 are needed for another branch of the dependency tree.
1689 the output is always
1695 The ordering imposed by
1697 is only relevant for parallel makes.
1700 Special targets may not be included with other targets, i.e. they must be
1701 the only target specified.
1702 .Bl -tag -width .BEGINx
1704 Any command lines attached to this target are executed before anything
1709 rule for any target (that was used only as a
1712 can't figure out any other way to create.
1713 Only the shell script is used.
1716 variable of a target that inherits
1719 to the target's own name.
1721 Any command lines attached to this target are executed after everything
1724 Any command lines attached to this target are executed when another target fails.
1727 variable is set to the target that failed.
1729 .Ic MAKE_PRINT_VAR_ON_ERROR .
1731 Mark each of the sources with the
1734 If no sources are specified, this is the equivalent of specifying the
1740 is interrupted, the commands for this target will be executed.
1742 If no target is specified when
1744 is invoked, this target will be built.
1746 This target provides a way to specify flags for
1748 when the makefile is used.
1749 The flags are as if typed to the shell, though the
1753 .\" XXX: NOT YET!!!!
1754 .\" .It Ic .NOTPARALLEL
1755 .\" The named targets are executed in non parallel mode.
1756 .\" If no targets are
1757 .\" specified, then all targets are executed in non parallel mode.
1761 attribute to any specified sources.
1763 Disable parallel mode.
1767 for compatibility with other pmake variants.
1769 The named targets are made in sequence.
1770 This ordering does not add targets to the list of targets to be made.
1771 Since the dependents of a target do not get built until the target itself
1772 could be built, unless
1774 is built by another part of the dependency graph,
1775 the following is a dependency loop:
1781 The ordering imposed by
1783 is only relevant for parallel makes.
1784 .\" XXX: NOT YET!!!!
1785 .\" .It Ic .PARALLEL
1786 .\" The named targets are executed in parallel mode.
1787 .\" If no targets are
1788 .\" specified, then all targets are executed in parallel mode.
1790 The sources are directories which are to be searched for files not
1791 found in the current directory.
1792 If no sources are specified, any previously specified directories are
1794 If the source is the special
1796 target, then the current working
1797 directory is searched last.
1801 attribute to any specified sources.
1805 attribute to any specified sources.
1806 If no sources are specified, the
1808 attribute is applied to every
1813 will use to execute commands.
1814 The sources are a set of
1817 .Bl -tag -width hasErrCtls
1819 This is the minimal specification, used to select one of the builtin
1826 Specifies the path to the shell.
1828 Indicates whether the shell supports exit on error.
1830 The command to turn on error checking.
1832 The command to disable error checking.
1834 The command to turn on echoing of commands executed.
1836 The command to turn off echoing of commands executed.
1838 The output to filter after issuing the
1841 It is typically identical to
1844 The flag to pass the shell to enable error checking.
1846 The flag to pass the shell to enable command echoing.
1848 The string literal to pass the shell that results in a single newline
1849 character when used outside of any quoting characters.
1853 \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e
1854 check="set -e" ignore="set +e" \e
1855 echo="set -v" quiet="set +v" filter="set +v" \e
1856 echoFlag=v errFlag=e newline="'\en'"
1861 attribute to any specified sources.
1862 If no sources are specified, the
1864 attribute is applied to every
1865 command in the file.
1867 Each source specifies a suffix to
1869 If no sources are specified, any previously specified suffixes are deleted.
1870 It allows the creation of suffix-transformation rules.
1876 cc -o ${.TARGET} -c ${.IMPSRC}
1881 uses the following environment variables, if they exist:
1887 .Ev MAKEOBJDIRPREFIX ,
1893 .Ev MAKEOBJDIRPREFIX
1896 may only be set in the environment or on the command line to
1898 and not as makefile variables;
1899 see the description of
1903 .Bl -tag -width /usr/share/mk -compact
1905 list of dependencies
1907 list of dependencies
1909 list of dependencies
1913 system makefile directory
1916 The basic make syntax is compatible between different versions of make,
1917 however the special variables, variable modifiers and conditionals are not.
1919 The way that parallel makes are scheduled changed in
1921 so that .ORDER and .WAIT apply recursively to the dependant nodes.
1922 The algorithms used may change again in the future.
1924 The way that .for loop variables are substituted changed after
1926 so that they still appear to be variable expansions.
1927 In particular this stops them being treated as syntax, and removes some
1928 obscure problems using them in .if statements.
1939 syntax is difficult to parse without actually acting of the data.
1940 For instance finding the end of a variable use should involve scanning each
1941 the modifiers using the correct terminator for each field.
1944 just counts {} and () in order to find the end of a variable expansion.
1946 There is no way of escaping a space character in a filename.