1 .\" $NetBSD: make.1,v 1.165 2009/11/19 00:30:24 sjg 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 two distinct times, depending on where
540 the variable is being used.
541 Variables in dependency lines are expanded as the line is read.
542 Variables in shell commands are expanded when the shell command is
545 The four different classes of variables (in order of increasing precedence)
548 .It Environment variables
549 Variables defined as part of
553 Variables defined in the makefile or in included makefiles.
554 .It Command line variables
555 Variables defined as part of the command line.
557 Variables that are defined specific to a certain target.
558 The seven local variables are as follows:
559 .Bl -tag -width ".ARCHIVE"
561 The list of all sources for this target; also known as
564 The name of the archive file.
566 In suffix-transformation rules, the name/path of the source from which the
567 target is to be transformed (the
569 source); also known as
571 It is not defined in explicit rules.
573 The name of the archive member.
575 The list of sources for this target that were deemed out-of-date; also
579 The file prefix of the file, containing only the file portion, no suffix
580 or preceding directory components; also known as
583 The name of the target; also known as
594 are permitted for backward
595 compatibility with historical makefiles and are not recommended.
604 are permitted for compatibility with
606 makefiles and are not recommended.
608 Four of the local variables may be used in sources on dependency lines
609 because they expand to the proper value for each target on the line.
617 .Ss Additional built-in variables
620 sets or knows about the following variables:
621 .Bl -tag -width .MAKEOVERRIDES
627 expands to a single dollar
630 The list of all targets encountered in the Makefile.
632 Makefile parsing, lists only those targets encountered thus far.
634 A path to the directory where
637 Refer to the description of
650 The preferred variable to use is the environment variable
652 because it is more compatible with other versions of
654 and cannot be confused with the special target with the same name.
655 .It Va .MAKE.EXPORTED
656 The list of variables exported by
658 .It Va .MAKE.MAKEFILES
659 The list of makefiles read by
661 which is useful for tracking dependencies.
662 Each makefile is recorded only once, regardless of the number of times read.
664 The recursion depth of
666 The initial instance of
668 will be 0, and an incremented value is put into the environment
669 to be seen by the next generation.
670 This allows tests like:
671 .Li .if ${.MAKE.LEVEL} == 0
672 to protect things which should only be evaluated in the initial instance of
678 The parent process-id of
680 .It Va .MAKE.JOB.PREFIX
685 then output for each target is prefixed with a token
687 the first part of which can be controlled via
688 .Va .MAKE.JOB.PREFIX .
691 .Li .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}]
692 would produce tokens like
693 .Ql ---make[1234] target ---
694 making it easier to track the degree of parallelism being achieved.
696 The environment variable
698 may contain anything that
702 Anything specified on
704 command line is appended to the
706 variable which is then
707 entered into the environment for all programs which
710 .It Va .MAKEOVERRIDES
711 This variable is used to record the names of variables assigned to
712 on the command line, so that they may be exported as part of
714 This behaviour can be disabled by assigning an empty value to
715 .Ql Va .MAKEOVERRIDES
717 Extra variables can be exported from a makefile
718 by appending their names to
719 .Ql Va .MAKEOVERRIDES .
721 is re-exported whenever
722 .Ql Va .MAKEOVERRIDES
724 .It Va MAKE_PRINT_VAR_ON_ERROR
727 stops due to an error, it prints its name and the value of
729 as well as the value of any variables named in
730 .Ql Va MAKE_PRINT_VAR_ON_ERROR .
732 This variable is simply assigned a newline character as its value.
733 This allows expansions using the
735 modifier to put a newline between
736 iterations of the loop rather than a space.
737 For example, the printing of
738 .Ql Va MAKE_PRINT_VAR_ON_ERROR
739 could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}.
741 A path to the directory where the targets are built.
742 Its value is determined by trying to
744 to the following directories in order and using the first match:
747 .Ev ${MAKEOBJDIRPREFIX}${.CURDIR}
750 .Ql Ev MAKEOBJDIRPREFIX
751 is set in the environment or on the command line.)
757 is set in the environment or on the command line.)
759 .Ev ${.CURDIR} Ns Pa /obj. Ns Ev ${MACHINE}
761 .Ev ${.CURDIR} Ns Pa /obj
763 .Pa /usr/obj/ Ns Ev ${.CURDIR}
768 Variable expansion is performed on the value before it's used,
769 so expressions such as
770 .Dl ${.CURDIR:C,^/usr/src,/var/obj,}
774 may be modified in the makefile as a global variable.
783 to that directory before executing any targets.
786 A path to the directory of the current
790 The basename of the current
795 are both set only while the
799 A variable that represents the list of directories that
801 will search for files.
802 The search list should be updated using the target
804 rather than the variable.
806 Alternate path to the current directory.
810 to the canonical path given by
812 However, if the environment variable
814 is set and gives a path to the current directory, then
821 This behaviour is disabled if
822 .Ql Ev MAKEOBJDIRPREFIX
825 contains a variable transform.
827 is set to the value of
829 for all programs which
835 lists of directories that
837 will search for files.
838 The variable is supported for compatibility with old make programs only,
843 .Ss Variable modifiers
844 Variable expansion may be modified to select or modify each word of the
847 is white-space delimited sequence of characters).
848 The general format of a variable expansion is as follows:
850 .Dl ${variable[:modifier[:...]]}
852 Each modifier begins with a colon,
853 which may be escaped with a backslash
856 A set of modifiers can be specified via a variable, as follows:
858 .Dl modifier_variable=modifier[:...]
859 .Dl ${variable:${modifier_variable}[:...]}
861 In this case the first modifier in the modifier_variable does not
862 start with a colon, since that must appear in the referencing
864 If any of the modifiers in the modifier_variable contain a dollar sign
866 these must be doubled to avoid early expansion.
868 The supported modifiers are:
871 Replaces each word in the variable with its suffix.
873 Replaces each word in the variable with everything but the last component.
874 .It Cm \&:M Ns Ar pattern
875 Select only those words that match
877 The standard shell wildcard characters
884 The wildcard characters may be escaped with a backslash
886 .It Cm \&:N Ns Ar pattern
889 but selects all words which do not match
892 Order every word in variable alphabetically.
894 reverse order use the
896 combination of modifiers.
898 Randomize words in variable.
899 The results will be different each time you are referring to the
900 modified variable; use the assignment with expansion
902 to prevent such behaviour.
904 .Bd -literal -offset indent
905 LIST= uno due tre quattro
906 RANDOM_LIST= ${LIST:Ox}
907 STATIC_RANDOM_LIST:= ${LIST:Ox}
910 @echo "${RANDOM_LIST}"
911 @echo "${RANDOM_LIST}"
912 @echo "${STATIC_RANDOM_LIST}"
913 @echo "${STATIC_RANDOM_LIST}"
915 may produce output similar to:
916 .Bd -literal -offset indent
923 Quotes every shell meta-character in the variable, so that it can be passed
924 safely through recursive invocations of
927 Replaces each word in the variable with everything but its suffix.
929 Converts variable to lower-case letters.
931 Words in the variable are normally separated by a space on expansion.
932 This modifier sets the separator to the character
936 is omitted, then no separator is used.
938 Converts variable to upper-case letters.
940 Causes the value to be treated as a single word
941 (possibly containing embedded white space).
945 Causes the value to be treated as a sequence of
946 words delimited by white space.
950 .It Cm \&:S No \&/ Ar old_string No \&/ Ar new_string No \&/ Op Cm 1gW
952 Modify the first occurrence of
954 in the variable's value, replacing it with
958 is appended to the last slash of the pattern, all occurrences
959 in each word are replaced.
962 is appended to the last slash of the pattern, only the first word
966 is appended to the last slash of the pattern,
967 then the value is treated as a single word
968 (possibly containing embedded white space).
974 is anchored at the beginning of each word.
977 ends with a dollar sign
979 it is anchored at the end of each word.
990 Any character may be used as a delimiter for the parts of the modifier
992 The anchoring, ampersand and delimiter characters may be escaped with a
996 Variable expansion occurs in the normal fashion inside both
1000 with the single exception that a backslash is used to prevent the expansion
1003 not a preceding dollar sign as is usual.
1005 .It Cm \&:C No \&/ Ar pattern No \&/ Ar replacement No \&/ Op Cm 1gW
1009 modifier is just like the
1011 modifier except that the old and new strings, instead of being
1012 simple strings, are a regular expression (see
1020 Normally, the first occurrence of the pattern
1022 in each word of the value is substituted with
1026 modifier causes the substitution to apply to at most one word; the
1028 modifier causes the substitution to apply to as many instances of the
1031 as occur in the word or words it is found in; the
1033 modifier causes the value to be treated as a single word
1034 (possibly containing embedded white space).
1039 are orthogonal; the former specifies whether multiple words are
1040 potentially affected, the latter whether multiple substitutions can
1041 potentially occur within each affected word.
1043 Replaces each word in the variable with its last component.
1045 Remove adjacent duplicate words (like
1048 .It Cm \&:\&? Ar true_string Cm \&: Ar false_string
1050 If the variable name (not its value), when parsed as a .if conditional
1051 expression, evaluates to true, return as its value the
1053 otherwise return the
1055 Since the variable name is used as the expression, \&:\&? must be the
1056 first modifier after the variable name itself - which will, of course,
1057 usually contain variable expansions.
1058 A common error is trying to use expressions like
1059 .Dl ${NUMBERS:M42:?match:no}
1060 which actually tests defined(NUMBERS),
1061 to determine is any words match "42" you need to use something like:
1062 .Dl ${${NUMBERS:M42} != "":?match:no} .
1063 .It Ar :old_string=new_string
1066 style variable substitution.
1067 It must be the last modifier specified.
1072 do not contain the pattern matching character
1074 then it is assumed that they are
1075 anchored at the end of each word, so only suffixes or entire
1076 words may be replaced.
1084 Variable expansion occurs in the normal fashion inside both
1088 with the single exception that a backslash is used to prevent the
1089 expansion of a dollar sign
1091 not a preceding dollar sign as is usual.
1093 .It Cm \&:@ Ar temp Cm @ Ar string Cm @
1095 This is the loop expansion mechanism from the OSF Development
1096 Environment (ODE) make.
1099 loops expansion occurs at the time of
1103 to each word in the variable and evaluate
1105 The ODE convention is that
1107 should start and end with a period.
1109 .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1110 .It Cm \&:U Ns Ar newval
1111 If the variable is undefined
1114 If the variable is defined, the existing value is returned.
1115 This is another ODE make feature.
1116 It is handy for setting per-target CFLAGS for instance:
1117 .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1118 If a value is only required if the variable is undefined, use:
1119 .Dl ${VAR:D:Unewval}
1120 .It Cm \&:D Ns Ar newval
1121 If the variable is defined
1125 The name of the variable is the value.
1127 The path of the node which has the same name as the variable
1129 If no such node exists or its path is null, then the
1130 name of the variable is used.
1132 .It Cm \&:\&! Ar cmd Cm \&!
1134 The output of running
1138 If the variable is non-empty it is run as a command and the output
1139 becomes the new value.
1140 .It Cm \&::= Ns Ar str
1141 The variable is assigned the value
1144 This modifier and its variations are useful in
1145 obscure situations such as wanting to set a variable when shell commands
1147 These assignment modifiers always expand to
1148 nothing, so if appearing in a rule line by themselves should be
1149 preceded with something to keep
1155 helps avoid false matches with the
1159 modifier and since substitution always occurs the
1161 form is vaguely appropriate.
1162 .It Cm \&::?= Ns Ar str
1165 but only if the variable does not already have a value.
1166 .It Cm \&::+= Ns Ar str
1170 .It Cm \&::!= Ns Ar cmd
1171 Assign the output of
1174 .It Cm \&:\&[ Ns Ar range Ns Cm \&]
1175 Selects one or more words from the value,
1176 or performs other operations related to the way in which the
1177 value is divided into words.
1179 Ordinarily, a value is treated as a sequence of words
1180 delimited by white space.
1181 Some modifiers suppress this behaviour,
1182 causing a value to be treated as a single word
1183 (possibly containing embedded white space).
1184 An empty value, or a value that consists entirely of white-space,
1185 is treated as a single word.
1186 For the purposes of the
1188 modifier, the words are indexed both forwards using positive integers
1189 (where index 1 represents the first word),
1190 and backwards using negative integers
1191 (where index -1 represents the last word).
1195 is subjected to variable expansion, and the expanded result is
1196 then interpreted as follows:
1197 .Bl -tag -width index
1200 Selects a single word from the value.
1202 .It Ar start Ns Cm \&.. Ns Ar end
1203 Selects all words from
1210 selects all words from the second word to the last word.
1215 then the words are output in reverse order.
1218 selects all the words from last to first.
1221 Causes subsequent modifiers to treat the value as a single word
1222 (possibly containing embedded white space).
1223 Analogous to the effect of
1232 Causes subsequent modifiers to treat the value as a sequence of words
1233 delimited by white space.
1234 Analogous to the effect of
1239 Returns the number of words in the value.
1242 .Sh INCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS
1243 Makefile inclusion, conditional structures and for loops reminiscent
1244 of the C programming language are provided in
1246 All such structures are identified by a line beginning with a single
1250 Files are included with either
1251 .Cm \&.include Aq Ar file
1253 .Cm \&.include Pf \*q Ar file Ns \*q .
1254 Variables between the angle brackets or double quotes are expanded
1255 to form the file name.
1256 If angle brackets are used, the included makefile is expected to be in
1257 the system makefile directory.
1258 If double quotes are used, the including makefile's directory and any
1259 directories specified using the
1261 option are searched before the system
1263 For compatibility with other versions of
1265 .Ql include file ...
1267 If the include statement is written as
1271 then errors locating and/or opening include files are ignored.
1273 Conditional expressions are also preceded by a single dot as the first
1274 character of a line.
1275 The possible conditionals are as follows:
1277 .It Ic .export Ar variable ...
1278 Export the specified global variable.
1279 If no variable list is provided, all globals are exported
1280 except for internal variables (those that start with
1282 This is not affected by the
1284 flag, so should be used with caution.
1286 Appending a variable name to
1288 is equivalent to exporting a variable.
1289 .It Ic .unexport Ar variable ...
1292 The specified global
1294 will be removed from
1295 .Va .MAKE.EXPORTED .
1296 If no variable list is provided, all globals are unexported,
1300 .It Ic .unexport-env
1301 Unexport all globals previously exported and
1302 clear the environment inherited from the parent.
1303 This operation will cause a memory leak of the original environment,
1304 so should be used sparingly.
1307 being 0, would make sense.
1308 Also note that any variables which originated in the parent environment
1309 should be explicitly preserved if desired.
1311 .Bd -literal -offset indent
1312 .Li .if ${.MAKE.LEVEL} == 0
1319 Would result in an environment containing only
1321 which is the minimal useful environment.
1324 will also be pushed into the new environment.
1325 .It Ic .undef Ar variable
1326 Un-define the specified global variable.
1327 Only global variables may be un-defined.
1328 .It Ic \&.if Oo \&! Oc Ns Ar expression Op Ar operator expression ...
1329 Test the value of an expression.
1330 .It Ic .ifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1331 Test the value of a variable.
1332 .It Ic .ifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1333 Test the value of a variable.
1334 .It Ic .ifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1335 Test the target being built.
1336 .It Ic .ifnmake Oo \&! Ns Oc Ar target Op Ar operator target ...
1337 Test the target being built.
1339 Reverse the sense of the last conditional.
1340 .It Ic .elif Oo \&! Ns Oc Ar expression Op Ar operator expression ...
1345 .It Ic .elifdef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1350 .It Ic .elifndef Oo \&! Oc Ns Ar variable Op Ar operator variable ...
1355 .It Ic .elifmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1360 .It Ic .elifnmake Oo \&! Oc Ns Ar target Op Ar operator target ...
1366 End the body of the conditional.
1371 may be any one of the following:
1372 .Bl -tag -width "Cm XX"
1375 .It Cm \&\*[Am]\*[Am]
1378 of higher precedence than
1384 will only evaluate a conditional as far as is necessary to determine
1386 Parentheses may be used to change the order of evaluation.
1387 The boolean operator
1389 may be used to logically negate an entire
1391 It is of higher precedence than
1392 .Ql Ic \&\*[Am]\*[Am] .
1396 may be any of the following:
1397 .Bl -tag -width defined
1399 Takes a variable name as an argument and evaluates to true if the variable
1402 Takes a target name as an argument and evaluates to true if the target
1403 was specified as part of
1405 command line or was declared the default target (either implicitly or
1408 before the line containing the conditional.
1410 Takes a variable, with possible modifiers, and evaluates to true if
1411 the expansion of the variable would result in an empty string.
1413 Takes a file name as an argument and evaluates to true if the file exists.
1414 The file is searched for on the system search path (see
1417 Takes a target name as an argument and evaluates to true if the target
1420 Takes a target name as an argument and evaluates to true if the target
1421 has been defined and has commands associated with it.
1425 may also be an arithmetic or string comparison.
1426 Variable expansion is
1427 performed on both sides of the comparison, after which the integral
1428 values are compared.
1429 A value is interpreted as hexadecimal if it is
1430 preceded by 0x, otherwise it is decimal; octal numbers are not supported.
1431 The standard C relational operators are all supported.
1433 variable expansion, either the left or right hand side of a
1437 operator is not an integral value, then
1438 string comparison is performed between the expanded
1440 If no relational operator is given, it is assumed that the expanded
1441 variable is being compared against 0 or an empty string in the case
1442 of a string comparison.
1446 is evaluating one of these conditional expressions, and it encounters
1447 a (white-space separated) word it doesn't recognize, either the
1451 expression is applied to it, depending on the form of the conditional.
1459 expression is applied.
1460 Similarly, if the form is
1463 .Ql Ic .ifnmake , the
1465 expression is applied.
1467 If the conditional evaluates to true the parsing of the makefile continues
1469 If it evaluates to false, the following lines are skipped.
1470 In both cases this continues until a
1476 For loops are typically used to apply a set of rules to a list of files.
1477 The syntax of a for loop is:
1479 .Bl -tag -compact -width Ds
1480 .It Ic \&.for Ar variable Oo Ar variable ... Oc Ic in Ar expression
1487 is evaluated, it is split into words.
1488 On each iteration of the loop, one word is taken and assigned to each
1492 are substituted into the
1494 inside the body of the for loop.
1495 The number of words must come out even; that is, if there are three
1496 iteration variables, the number of words provided must be a multiple
1499 Comments begin with a hash
1501 character, anywhere but in a shell
1502 command line, and continue to the end of an unescaped new line.
1503 .Sh SPECIAL SOURCES (ATTRIBUTES)
1504 .Bl -tag -width .IGNOREx
1506 Target is never out of date, but always execute commands anyway.
1508 Ignore any errors from the commands associated with this target, exactly
1509 as if they all were preceded by a dash
1511 .\" .It Ic .INVISIBLE
1516 Mark all sources of this target as being up-to-date.
1518 Execute the commands associated with this target even if the
1522 options were specified.
1523 Normally used to mark recursive
1526 Do not search for the target in the directories specified by
1531 selects the first target it encounters as the default target to be built
1532 if no target was specified.
1533 This source prevents this target from being selected.
1535 If a target is marked with this attribute and
1537 can't figure out how to create it, it will ignore this fact and assume
1538 the file isn't needed or already exists.
1541 correspond to an actual file; it is always considered to be out of date,
1542 and will not be created with the
1548 is interrupted, it normally removes any partially made targets.
1549 This source prevents the target from being removed.
1554 Do not echo any of the commands associated with this target, exactly
1555 as if they all were preceded by an at sign
1558 Turn the target into
1561 When the target is used as a source for another target, the other target
1562 acquires the commands, sources, and attributes (except for
1566 If the target already has commands, the
1568 target's commands are appended
1575 target commands to the target.
1579 appears in a dependency line, the sources that precede it are
1580 made before the sources that succeed it in the line.
1581 Since the dependents of files are not made until the file itself
1582 could be made, this also stops the dependents being built unless they
1583 are needed for another branch of the dependency tree.
1596 the output is always
1602 The ordering imposed by
1604 is only relevant for parallel makes.
1607 Special targets may not be included with other targets, i.e. they must be
1608 the only target specified.
1609 .Bl -tag -width .BEGINx
1611 Any command lines attached to this target are executed before anything
1616 rule for any target (that was used only as a
1619 can't figure out any other way to create.
1620 Only the shell script is used.
1623 variable of a target that inherits
1626 to the target's own name.
1628 Any command lines attached to this target are executed after everything
1631 Mark each of the sources with the
1634 If no sources are specified, this is the equivalent of specifying the
1640 is interrupted, the commands for this target will be executed.
1642 If no target is specified when
1644 is invoked, this target will be built.
1646 This target provides a way to specify flags for
1648 when the makefile is used.
1649 The flags are as if typed to the shell, though the
1653 .\" XXX: NOT YET!!!!
1654 .\" .It Ic .NOTPARALLEL
1655 .\" The named targets are executed in non parallel mode.
1656 .\" If no targets are
1657 .\" specified, then all targets are executed in non parallel mode.
1661 attribute to any specified sources.
1663 Disable parallel mode.
1667 for compatibility with other pmake variants.
1669 The named targets are made in sequence.
1670 This ordering does not add targets to the list of targets to be made.
1671 Since the dependents of a target do not get built until the target itself
1672 could be built, unless
1674 is built by another part of the dependency graph,
1675 the following is a dependency loop:
1681 The ordering imposed by
1683 is only relevant for parallel makes.
1684 .\" XXX: NOT YET!!!!
1685 .\" .It Ic .PARALLEL
1686 .\" The named targets are executed in parallel mode.
1687 .\" If no targets are
1688 .\" specified, then all targets are executed in parallel mode.
1690 The sources are directories which are to be searched for files not
1691 found in the current directory.
1692 If no sources are specified, any previously specified directories are
1694 If the source is the special
1696 target, then the current working
1697 directory is searched last.
1701 attribute to any specified sources.
1705 attribute to any specified sources.
1706 If no sources are specified, the
1708 attribute is applied to every
1713 will use to execute commands.
1714 The sources are a set of
1717 .Bl -tag -width hasErrCtls
1719 This is the minimal specification, used to select one of the builtin
1726 Specifies the path to the shell.
1728 Indicates whether the shell supports exit on error.
1730 The command to turn on error checking.
1732 The command to disable error checking.
1734 The command to turn on echoing of commands executed.
1736 The command to turn off echoing of commands executed.
1738 The output to filter after issuing the
1741 It is typically identical to
1744 The flag to pass the shell to enable error checking.
1746 The flag to pass the shell to enable command echoing.
1748 The string literal to pass the shell that results in a single newline
1749 character when used outside of any quoting characters.
1753 \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \\
1754 check="set -e" ignore="set +e" \\
1755 echo="set -v" quiet="set +v" filter="set +v" \\
1756 echoFlag=v errFlag=e newline="'\\n'"
1761 attribute to any specified sources.
1762 If no sources are specified, the
1764 attribute is applied to every
1765 command in the file.
1767 Each source specifies a suffix to
1769 If no sources are specified, any previously specified suffixes are deleted.
1770 It allows the creation of suffix-transformation rules.
1776 cc -o ${.TARGET} -c ${.IMPSRC}
1781 uses the following environment variables, if they exist:
1787 .Ev MAKEOBJDIRPREFIX ,
1793 .Ev MAKEOBJDIRPREFIX
1796 may only be set in the environment or on the command line to
1798 and not as makefile variables;
1799 see the description of
1803 .Bl -tag -width /usr/share/mk -compact
1805 list of dependencies
1807 list of dependencies
1809 list of dependencies
1813 system makefile directory
1816 The basic make syntax is compatible between different versions of make,
1817 however the special variables, variable modifiers and conditionals are not.
1819 The way that parallel makes are scheduled changed in
1821 so that .ORDER and .WAIT apply recursively to the dependant nodes.
1822 The algorithms used may change again in the future.
1824 The way that .for loop variables are substituted changed after
1826 so that they still appear to be variable expansions.
1827 In particular this stops them being treated as syntax, and removes some
1828 obscure problems using them in .if statements.
1839 syntax is difficult to parse without actually acting of the data.
1840 For instance finding the end of a variable use should involve scanning each
1841 the modifiers using the correct terminator for each field.
1844 just counts {} and () in order to find the end of a variable expansion.
1846 There is no way of escaping a space character in a filename.