1 .\" $NetBSD: make.1,v 1.366 2023/05/10 18:22:33 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
52 .Op Ar variable\| Ns Cm \&= Ns Ar value
56 is a program designed to simplify the maintenance of other programs.
57 Its input is a list of specifications as to the files upon which programs
58 and other files depend.
67 in order to find the specifications.
70 exists, it is read, see
73 This manual page is intended as a reference document only.
74 For a more thorough description of
76 and makefiles, please refer to
77 .%T "PMake \- A Tutorial"
81 prepends the contents of the
83 environment variable to the command line arguments before parsing them.
85 The options are as follows:
88 Try to be backwards compatible by executing a single shell per command and
89 by making the sources of a dependency line in sequence.
93 before reading the makefiles or doing anything else.
96 options are specified, each is interpreted relative to the previous one:
97 .Fl C Pa / Fl C Pa etc
103 to be 1, in the global scope.
104 .It Fl d Oo Cm \- Oc Ns Ar flags
105 Turn on debugging, and specify which portions of
107 are to print debugging information.
108 Unless the flags are preceded by
110 they are added to the
112 environment variable and are passed on to any child make processes.
113 By default, debugging information is printed to standard error,
114 but this can be changed using the
117 The debugging output is always unbuffered; in addition, if debugging
118 is enabled but debugging output is not directed to standard output,
119 the standard output is line buffered.
125 Print all possible debugging information;
126 equivalent to specifying all of the debugging flags.
128 Print debugging information about archive searching and caching.
130 Print debugging information about the current working directory.
132 Print debugging information about conditional evaluation.
134 Print debugging information about directory searching and caching.
136 Print debugging information about failed commands and targets.
137 .It Cm F Ns Oo Cm \&+ Oc Ns Ar filename
138 Specify where debugging output is written.
139 This must be the last flag, because it consumes the remainder of
141 If the character immediately after the
145 the file is opened in append mode;
146 otherwise the file is overwritten.
151 debugging output is written to the standard output or standard error output
152 respectively (and the
154 option has no effect).
155 Otherwise, the output is written to the named file.
156 If the file name ends with
160 is replaced by the pid.
162 Print debugging information about loop evaluation.
164 Print the input graph before making anything.
166 Print the input graph after making everything, or before exiting
169 Print the input graph before exiting on error.
171 Print debugging information about hash table operations.
173 Print debugging information about running multiple shells.
176 This throws errors for variable assignments that do not parse correctly,
177 at the time of assignment, so the file and line number are available.
179 Print commands in Makefiles regardless of whether or not they are prefixed by
188 Print debugging information about
190 mode decisions about targets.
192 Print debugging information about making targets, including modification
195 Don't delete the temporary command scripts created when running commands.
196 These temporary scripts are created in the directory
199 environment variable, or in
203 is unset or set to the empty string.
204 The temporary scripts are created by
206 and have names of the form
209 This can create many files in
215 Print debugging information about makefile parsing.
217 Print debugging information about suffix-transformation rules.
219 Print debugging information about target list maintenance.
223 option to print raw values of variables,
224 overriding the default behavior set via
225 .Va .MAKE.EXPAND_VARIABLES .
227 Print debugging information about variable assignment and expansion.
229 Run shell commands with
231 so the actual commands are printed as they are executed.
234 Let environment variables override global variables within makefiles.
236 Specify a makefile to read instead of the default
244 standard input is read.
245 Multiple makefiles may be specified, and are read in the order specified.
246 .It Fl I Ar directory
247 Specify a directory in which to search for makefiles and included makefiles.
248 The system makefile directory (or directories, see the
250 option) is automatically included as part of this list.
252 Ignore non-zero exit of shell commands in the makefile.
253 Equivalent to specifying
255 before each command line in the makefile.
259 be specified by the user.
263 option is in use in a recursive build, this option is passed by a make
264 to child makes to allow all the make processes in the build to
265 cooperate to avoid overloading the system.
267 Specify the maximum number of jobs that
269 may have running at any one time.
274 Turns compatibility mode off, unless the
276 option is also specified.
277 When compatibility mode is off, all commands associated with a
278 target are executed in a single shell invocation as opposed to the
279 traditional one shell invocation per line.
280 This can break traditional scripts which change directories on each
281 command invocation and then expect to start with a fresh environment
283 It is more efficient to correct the scripts rather than turn backwards
286 A job token pool with
288 tokens is used to control the total number of jobs running.
291 will wait for a token from the pool before running a new job.
293 Continue processing after errors are encountered, but only on those targets
294 that do not depend on the target whose creation caused the error.
295 .It Fl m Ar directory
296 Specify a directory in which to search for
298 and makefiles included via the
299 .Li \&< Ns Ar file Ns Li \&> Ns -style
303 option can be used multiple times to form a search path.
304 This path overrides the default system include path
306 Furthermore, the system include path is appended to the search path used for
307 .Li \*q Ns Ar file Ns Li \*q Ns -style
308 include statements (see the
311 The system include path can be referenced via the read-only variable
314 If a directory name in the
318 environment variable) starts with the string
321 searches for the specified file or directory named in the remaining part
322 of the argument string.
323 The search starts with the current directory
324 and then works upward towards the root of the file system.
325 If the search is successful, the resulting directory replaces the
332 to easily search in the current source tree for customized
334 files (e.g., by using
338 Display the commands that would have been executed, but do not
339 actually execute them unless the target depends on the
341 special source (see below) or the command is prefixed with
344 Display the commands that would have been executed,
345 but do not actually execute any of them;
346 useful for debugging top-level makefiles
347 without descending into subdirectories.
349 Do not execute any commands,
350 instead exit 0 if the specified targets are up to date, and 1 otherwise.
352 Do not use the built-in rules specified in the system makefile.
354 Stop processing if an error is encountered.
355 This is the default behavior and the opposite of
358 Do not echo any commands as they are executed.
359 Equivalent to specifying
361 before each command line in the makefile.
362 .It Fl T Ar tracefile
366 append a trace record to
368 for each job started and completed.
370 Rather than re-building a target as specified in the makefile, create it
371 or update its modification time to make it appear up-to-date.
375 Do not build any targets.
376 Multiple instances of this option may be specified;
377 the variables are printed one per line,
378 with a blank line for each null or undefined variable.
379 The value printed is extracted from the global scope after all
380 makefiles have been read.
382 By default, the raw variable contents (which may
383 include additional unexpanded variable references) are shown.
388 it is not interpreted as a variable name but rather as an expression.
389 Its value is expanded before printing.
390 The value is also expanded before printing if
391 .Va .MAKE.EXPAND_VARIABLES
392 is set to true and the
394 option has not been used to override it.
396 Note that loop-local and target-local variables, as well as values
397 taken temporarily by global variables during makefile processing, are
398 not accessible via this option.
401 debug mode can be used to see these at the cost of generating
402 substantial extraneous output.
406 but all printed variables are always expanded to their complete value.
407 The last occurrence of
411 decides whether all variables are expanded or not.
413 Treat any warnings during makefile parsing as errors.
415 Print entering and leaving directory messages, pre and post processing.
417 Don't export variables passed on the command line to the environment
419 Variables passed on the command line are still exported via the
421 environment variable.
422 This option may be useful on systems which have a small limit on the
423 size of command arguments.
424 .It Ar variable\| Ns Cm \&= Ns Ar value
425 Set the value of the variable
429 Normally, all values passed on the command line are also exported to
430 sub-makes in the environment.
433 flag disables this behavior.
434 Variable assignments should follow options for POSIX compatibility
435 but no ordering is enforced.
438 There are several different types of lines in a makefile: dependency
439 specifications, shell commands, variable assignments, include statements,
440 conditional directives, for loops, other directives, and comments.
442 Lines may be continued from one line to the next
443 by ending them with a backslash
445 The trailing newline character and initial whitespace on the following
446 line are compressed into a single space.
447 .Sh FILE DEPENDENCY SPECIFICATIONS
448 Dependency lines consist of one or more targets, an operator, and zero
450 This creates a relationship where the targets
452 on the sources and are customarily created from them.
453 A target is considered out of date if it does not exist,
454 or if its modification time is less than that of any of its sources.
455 An out-of-date target is re-created, but not until all sources
456 have been examined and themselves re-created as needed.
457 Three operators may be used:
460 Many dependency lines may name this target but only one may have
461 attached shell commands.
462 All sources named in all dependency lines are considered together,
463 and if needed the attached shell commands are run to create or
464 re-create the target.
467 is interrupted, the target is removed.
469 The same, but the target is always re-created whether or not it is out
472 Any dependency line may have attached shell commands, but each one
473 is handled independently: its sources are considered and the attached
474 shell commands are run if the target is out of date with respect to
475 (only) those sources.
476 Thus, different groups of the attached shell commands may be run
477 depending on the circumstances.
480 for dependency lines with no sources, the attached shell
481 commands are always run.
484 the target is not removed if
489 All dependency lines mentioning a particular target must use the same
492 Targets and sources may contain the shell wildcard values
503 may only be used as part of the final component of the target or source,
504 and only match existing files.
507 need not necessarily be used to describe existing files.
508 Expansion is in directory order, not alphabetically as done in the shell.
510 Each target may have associated with it one or more lines of shell commands,
511 normally used to create the target.
512 Each of the lines in this script
514 be preceded by a tab.
515 (For historical reasons, spaces are not accepted.)
516 While targets can occur in many dependency lines if desired,
517 by default only one of these rules may be followed by a creation script.
520 operator is used, however, all rules may include scripts,
521 and the respective scripts are executed in the order found.
523 Each line is treated as a separate shell command,
524 unless the end of line is escaped with a backslash
526 in which case that line and the next are combined.
527 If the first characters of the command are any combination of
532 the command is treated specially.
533 .Bl -tag -offset indent -width indent
535 causes the command not to be echoed before it is executed.
537 causes the command to be executed even when
540 This is similar to the effect of the
543 except that the effect can be limited to a single line of a script.
545 in compatibility mode
546 causes any non-zero exit status of the command line to be ignored.
551 is run in jobs mode with
553 the entire script for the target is fed to a single instance of the shell.
554 In compatibility (non-jobs) mode, each command is run in a separate process.
555 If the command contains any shell meta characters
556 .Pq Ql #=|^(){};&<>*?[]:$`\e\en ,
557 it is passed to the shell; otherwise
559 attempts direct execution.
560 If a line starts with
562 and the shell has ErrCtl enabled,
563 failure of the command line is ignored as in compatibility mode.
566 affects the entire job;
567 the script stops at the first command line that fails,
568 but the target is not deemed to have failed.
570 Makefiles should be written so that the mode of
572 operation does not change their behavior.
573 For example, any command which uses
577 without the intention of changing the directory for subsequent commands
578 should be put in parentheses so it executes in a subshell.
579 To force the use of a single shell, escape the line breaks so as to make
580 the whole script one command.
582 .Bd -literal -offset indent
583 avoid-chdir-side-effects:
584 @echo "Building $@ in $$(pwd)"
585 @(cd ${.CURDIR} && ${MAKE} $@)
586 @echo "Back in $$(pwd)"
588 ensure-one-shell-regardless-of-mode:
589 @echo "Building $@ in $$(pwd)"; \e
590 (cd ${.CURDIR} && ${MAKE} $@); \e
591 echo "Back in $$(pwd)"
596 changes the current working directory to
598 before executing any targets,
599 each child process starts with that as its current working directory.
600 .Sh VARIABLE ASSIGNMENTS
601 Variables in make behave much like macros in the C preprocessor.
603 Variable assignments have the form
604 .Sq Ar NAME Ar op Ar value ,
606 .Bl -tag -offset Ds -width Ds
608 is a single-word variable name,
609 consisting, by tradition, of all upper-case letters,
611 is one of the variable assignment operators described below, and
613 is interpreted according to the variable assignment operator.
622 .Ss Variable assignment operators
623 The five operators that assign values to variables are:
626 Assign the value to the variable.
627 Any previous value is overwritten.
629 Append the value to the current value of the variable,
630 separating them by a single space.
632 Assign the value to the variable if it is not already defined.
634 Expand the value, then assign it to the variable.
637 References to undefined variables are
640 This can cause problems when variable modifiers are used.
641 .\" See var-op-expand.mk, the section with LATER and INDIRECT.
643 Expand the value and pass it to the shell for execution,
644 then assign the output from the child's standard output to the variable.
645 Any newlines in the result are replaced with spaces.
647 .Ss Expansion of variables
648 In most contexts where variables are expanded,
650 expands to a single dollar sign.
651 In other contexts (most variable modifiers, string literals in conditions),
653 expands to a single dollar sign.
655 References to variables have the form
656 .Cm \&${ Ns Ar name Ns Oo Ns Cm \&: Ns Ar modifiers Oc Ns Cm \&}
658 .Cm \&$( Ns Ar name Ns Oo Ns Cm \&: Ns Ar modifiers Oc Ns Cm \&) .
659 If the variable name consists of only a single character
660 and the expression contains no modifiers,
661 the surrounding curly braces or parentheses are not required.
662 This shorter form is not recommended.
664 If the variable name contains a dollar, the name itself is expanded first.
665 This allows almost arbitrary variable names, however names containing dollar,
666 braces, parentheses or whitespace are really best avoided.
668 If the result of expanding a nested variable expression contains a dollar sign
670 the result is subject to further expansion.
672 Variable substitution occurs at four distinct times, depending on where
673 the variable is being used.
676 Variables in dependency lines are expanded as the line is read.
678 Variables in conditionals are expanded individually,
679 but only as far as necessary to determine the result of the conditional.
681 Variables in shell commands are expanded when the shell command is
685 loop index variables are expanded on each loop iteration.
686 Note that other variables are not expanded when composing the body of a loop,
687 so the following example code:
688 .Bd -literal -offset indent
701 .Bd -literal -offset indent
706 After the loop is executed:
707 .Bl -tag -offset indent -width indent
710 .Ql ${:U1} ${:U2} ${:U3} ,
722 .Ql ${:U3} ${:U3} ${:U3}
728 The four different classes of variables (in order of increasing precedence)
731 .It Environment variables
732 Variables defined as part of
736 Variables defined in the makefile or in included makefiles.
737 .It Command line variables
738 Variables defined as part of the command line.
740 Variables that are defined specific to a certain target.
743 Local variables can be set on a dependency line, unless
744 .Va .MAKE.TARGET_LOCAL_VARIABLES
748 (which already has had global variables expanded)
749 is the variable value.
751 .Bd -literal -offset indent
752 COMPILER_WRAPPERS= ccache distcc icecc
754 ${OBJS}: .MAKE.META.CMP_FILTER=${COMPILER_WRAPPERS:S,^,N,}
759 are impacted by that filter (in
762 simply enabling/disabling any of the compiler wrappers does not render all
763 of those targets out-of-date.
766 target-local variable assignments behave differently in that;
767 .Bl -tag -width Ds -offset indent
769 Only appends to a previous local assignment
770 for the same target and variable.
772 Is redundant with respect to global variables,
773 which have already been expanded.
776 The seven built-in local variables are:
777 .Bl -tag -width ".Va .ARCHIVE" -offset indent
779 The list of all sources for this target; also known as
782 The name of the archive file; also known as
785 In suffix-transformation rules, the name/path of the source from which the
786 target is to be transformed (the
788 source); also known as
790 It is not defined in explicit rules.
792 The name of the archive member; also known as
795 The list of sources for this target that were deemed out-of-date; also
799 The name of the target with suffix (if declared in
801 removed; also known as
804 The name of the target; also known as
806 For compatibility with other makes this is an alias for
808 in archive member rules.
822 are permitted for backward
823 compatibility with historical makefiles and legacy POSIX make and are
826 Variants of these variables with the punctuation followed immediately by
832 are legacy forms equivalent to using the
837 These forms are accepted for compatibility with
839 makefiles and POSIX but are not recommended.
841 Four of the local variables may be used in sources on dependency lines
842 because they expand to the proper value for each target on the line.
849 .Ss Additional built-in variables
852 sets or knows about the following variables:
854 .\" NB: This list is sorted case-insensitive, ignoring punctuation.
855 .\" NB: To find all built-in variables in make's source code,
856 .\" NB: search for Var_*, Global_*, SetVarObjdir, GetBooleanExpr,
857 .\" NB: and the implementation of Var_SetWithFlags.
858 .\" NB: Last synced on 2023-01-01.
860 The list of all targets encountered in the makefiles.
861 If evaluated during makefile parsing,
862 lists only those targets encountered thus far.
864 A path to the directory where
867 Refer to the description of
871 Is used in error handling, see
872 .Va MAKE_PRINT_VAR_ON_ERROR .
874 Is used in error handling, see
875 .Va MAKE_PRINT_VAR_ON_ERROR .
876 .It Va .ERROR_META_FILE
877 Is used in error handling in
880 .Va MAKE_PRINT_VAR_ON_ERROR .
882 Is used in error handling, see
883 .Va MAKE_PRINT_VAR_ON_ERROR .
884 .It Va .INCLUDEDFROMDIR
885 The directory of the file this makefile was included from.
886 .It Va .INCLUDEDFROMFILE
887 The filename of the file this makefile was included from.
888 .\" .INCLUDES is intentionally undocumented, as it is obsolete.
889 .\" .LIBS is intentionally undocumented, as it is obsolete.
891 The machine hardware name, see
894 The machine processor architecture name, see
905 The preferred variable to use is the environment variable
907 because it is more compatible with other make variants
908 and cannot be confused with the special target with the same name.
909 .It Va .MAKE.ALWAYS_PASS_JOB_QUEUE
912 whether to pass the descriptors of the job token queue
913 even if the target is not tagged with
917 for backwards compatability with
920 .\" '.MAKE.cmd_filtered' is intentionally undocumented,
921 .\" as it is an internal implementation detail.
922 .It Va .MAKE.DEPENDFILE
923 Names the makefile (default
925 from which generated dependencies are read.
926 .It Va .MAKE.DIE_QUIETLY
929 do not print error information at the end.
930 .It Va .MAKE.EXPAND_VARIABLES
931 A boolean that controls the default behavior of the
934 If true, variable values printed with
936 are fully expanded; if false, the raw variable contents (which may
937 include additional unexpanded variable references) are shown.
938 .It Va .MAKE.EXPORTED
939 The list of variables exported by
942 The top-level makefile that is currently read,
943 as given in the command line.
945 The environment variable
947 may contain anything that
951 Anything specified on
953 command line is appended to the
955 variable, which is then added to the environment for all programs that
959 The numeric group ID of the user running
962 .It Va .MAKE.JOB.PREFIX
967 the output for each target is prefixed with a token
968 .Dl --- Ar target Li ---
969 the first part of which can be controlled via
970 .Va .MAKE.JOB.PREFIX .
973 is empty, no token is printed.
977 .Ql ${.newline}---${.MAKE:T}[${.MAKE.PID}]
978 would produce tokens like
979 .Dl ---make[1234] Ar target Li ---
980 making it easier to track the degree of parallelism being achieved.
986 The recursion depth of
988 The top-level instance of
990 has level 0, and each child make has its parent level plus 1.
991 This allows tests like:
992 .Li .if ${.MAKE.LEVEL} == 0
993 to protect things which should only be evaluated in the top-level instance of
995 .It Va .MAKE.LEVEL.ENV
996 The name of the environment variable that stores the level of nested calls to
998 .It Va .MAKE.MAKEFILE_PREFERENCE
999 The ordered list of makefile names
1006 .It Va .MAKE.MAKEFILES
1007 The list of makefiles read by
1009 which is useful for tracking dependencies.
1010 Each makefile is recorded only once, regardless of the number of times read.
1011 .It Va .MAKE.META.BAILIWICK
1014 mode, provides a list of prefixes which
1015 match the directories controlled by
1017 If a file that was generated outside of
1019 but within said bailiwick is missing,
1020 the current target is considered out-of-date.
1021 .It Va .MAKE.META.CMP_FILTER
1024 mode, it can (very rarely!) be useful to filter command
1025 lines before comparison.
1026 This variable can be set to a set of modifiers that are applied to
1027 each line of the old and new command that differ, if the filtered
1028 commands still differ, the target is considered out-of-date.
1029 .It Va .MAKE.META.CREATED
1032 mode, this variable contains a list of all the meta files
1034 If not empty, it can be used to trigger processing of
1035 .Va .MAKE.META.FILES .
1036 .It Va .MAKE.META.FILES
1039 mode, this variable contains a list of all the meta files
1040 used (updated or not).
1041 This list can be used to process the meta files to extract dependency
1043 .It Va .MAKE.META.IGNORE_FILTER
1044 Provides a list of variable modifiers to apply to each pathname.
1045 Ignore if the expansion is an empty string.
1046 .It Va .MAKE.META.IGNORE_PATHS
1047 Provides a list of path prefixes that should be ignored;
1048 because the contents are expected to change over time.
1049 The default list includes:
1050 .Sq Pa /dev /etc /proc /tmp /var/run /var/tmp
1051 .It Va .MAKE.META.IGNORE_PATTERNS
1052 Provides a list of patterns to match against pathnames.
1053 Ignore any that match.
1054 .It Va .MAKE.META.PREFIX
1055 Defines the message printed for each meta file updated in
1058 The default value is:
1059 .Dl Building ${.TARGET:H:tA}/${.TARGET:T}
1061 Processed after reading all makefiles.
1062 Affects the mode that
1065 It can contain these keywords:
1066 .Bl -tag -width indent
1080 mode, where meta files are created for each target
1081 to capture the command run, the output generated, and if
1083 is available, the system calls which are of interest to
1085 The captured output can be useful when diagnosing errors.
1086 .It Cm curdirOk= Ns Ar bf
1093 This can be overridden by setting
1095 to a value which represents true.
1096 .It Cm missing-meta= Ns Ar bf
1101 file makes the target out-of-date.
1102 .It Cm missing-filemon= Ns Ar bf
1105 is true, missing filemon data makes the target out-of-date.
1110 For debugging, it can be useful to include the environment
1117 mode, print a clue about the target being built.
1118 This is useful if the build is otherwise running silently.
1119 The message printed is the expanded value of
1120 .Va .MAKE.META.PREFIX .
1122 Some makefiles have commands which are simply not stable.
1123 This keyword causes them to be ignored for
1124 determining whether a target is out of date in
1129 .It Cm silent= Ns Ar bf
1132 is true, when a .meta file is created, mark the target
1134 .It Cm randomize-targets
1135 In both compat and parallel mode, do not make the targets in the usual order,
1136 but instead randomize their order.
1137 This mode can be used to detect undeclared dependencies between files.
1140 Used to create files in a separate directory, see
1142 .It Va MAKE_OBJDIR_CHECK_WRITABLE
1143 Used to force a separate directory for the created files,
1144 even if that directory is not writable, see
1146 .It Va MAKEOBJDIRPREFIX
1147 Used to create files in a separate directory, see
1150 The name of the operating system, see
1153 .It Va .MAKEOVERRIDES
1154 This variable is used to record the names of variables assigned to
1155 on the command line, so that they may be exported as part of
1157 This behavior can be disabled by assigning an empty value to
1158 .Sq Va .MAKEOVERRIDES
1160 Extra variables can be exported from a makefile
1161 by appending their names to
1162 .Sq Va .MAKEOVERRIDES .
1164 is re-exported whenever
1165 .Sq Va .MAKEOVERRIDES
1167 .It Va .MAKE.PATH_FILEMON
1172 support, this is set to the path of the device node.
1173 This allows makefiles to test for this support.
1179 The parent process ID of
1182 .It Va MAKE_PRINT_VAR_ON_ERROR
1185 stops due to an error, it sets
1186 .Sq Va .ERROR_TARGET
1187 to the name of the target that failed,
1189 to the commands of the failed target,
1197 .Sq Va .ERROR_META_FILE
1198 to the path of the meta file (if any) describing the failed target.
1199 It then prints its name and the value of
1201 as well as the value of any variables named in
1202 .Sq Va MAKE_PRINT_VAR_ON_ERROR .
1203 .It Va .MAKE.SAVE_DOLLARS
1206 are preserved when doing
1209 The default is false, for backwards compatibility.
1210 Set to true for compatability with other makes.
1215 per normal evaluation rules.
1216 .It Va .MAKE.TARGET_LOCAL_VARIABLES
1219 apparent variable assignments in dependency lines are
1220 treated as normal sources.
1222 The numeric ID of the user running
1225 .\" 'MAKE_VERSION' is intentionally undocumented
1226 .\" since it is only defined in the bmake distribution,
1227 .\" but not in NetBSD's native make.
1228 .\" '.meta.%d.lcwd' is intentionally undocumented
1229 .\" since it is an internal implementation detail.
1230 .\" '.meta.%d.ldir' is intentionally undocumented
1231 .\" since it is an internal implementation detail.
1232 .\" 'MFLAGS' is intentionally undocumented
1233 .\" since it is obsolete.
1235 This variable is simply assigned a newline character as its value.
1237 This allows expansions using the
1239 modifier to put a newline between
1240 iterations of the loop rather than a space.
1241 For example, in case of an error,
1243 prints the variable names and their values using:
1244 .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1246 A path to the directory where the targets are built.
1247 Its value is determined by trying to
1249 to the following directories in order and using the first match:
1252 .Cm ${MAKEOBJDIRPREFIX} Ns Cm ${.CURDIR}
1255 .Sq Ev MAKEOBJDIRPREFIX
1256 is set in the environment or on the command line.)
1262 is set in the environment or on the command line.)
1264 .Cm ${.CURDIR} Ns Pa /obj. Ns Cm ${MACHINE}
1266 .Cm ${.CURDIR} Ns Pa /obj
1268 .Pa /usr/obj/ Ns Cm ${.CURDIR}
1273 Variable expansion is performed on the value before it is used,
1274 so expressions such as
1275 .Cm ${.CURDIR:S,^/usr/src,/var/obj,}
1277 This is especially useful with
1281 may be modified in the makefile via the special target
1285 changes to the specified directory if it exists, and sets
1289 to that directory before executing any targets.
1291 Except in the case of an explicit
1295 checks that the specified directory is writable and ignores it if not.
1296 This check can be skipped by setting the environment variable
1297 .Sq Ev MAKE_OBJDIR_CHECK_WRITABLE
1301 The directory name of the current makefile being parsed.
1303 The basename of the current makefile being parsed.
1306 are both set only while the makefiles are being parsed.
1307 To retain their current values,
1308 assign them to a variable using assignment with expansion
1311 The space-separated list of directories that
1314 To update this search list, use the special target
1316 rather than modifying the variable directly.
1318 Is set in POSIX mode, see the special
1321 .\" XXX: There is no make variable named 'PWD',
1322 .\" XXX: make only reads and writes the environment variable 'PWD'.
1324 Alternate path to the current directory.
1328 to the canonical path given by
1330 However, if the environment variable
1332 is set and gives a path to the current directory,
1339 This behavior is disabled if
1340 .Sq Ev MAKEOBJDIRPREFIX
1343 contains a variable transform.
1345 is set to the value of
1347 for all programs which
1351 The pathname of the shell used to run target scripts.
1354 The list of known suffixes.
1357 The space-separated list of directories that
1359 searches for makefiles, referred to as the system include path.
1360 To update this search list, use the special target
1362 rather than modifying the variable which is read-only.
1364 The list of targets explicitly specified on the command line, if any.
1368 list of directories that
1371 This variable is supported for compatibility with old make programs only, use
1375 .Ss Variable modifiers
1376 The general format of a variable expansion is:
1379 .D1 Ic \&${ Ar variable\| Oo Ic \&: Ar modifier\| Oo Ic \&: No ... Oc Oc Ic \&}
1382 Each modifier begins with a colon.
1383 To escape a colon, precede it with a backslash
1386 A list of indirect modifiers can be specified via a variable, as follows:
1388 .Bd -literal -offset indent
1389 .Ar modifier_variable\^ Li \&= Ar modifier Ns Oo Ic \&: Ns No ... Oc
1392 .Ic \&${ Ar variable Ic \&:${ Ar modifier_variable Ic \&} Oo Ic \&: No ... Oc Ic \&}
1396 In this case, the first modifier in the
1397 .Ar modifier_variable
1398 does not start with a colon,
1399 since that colon already occurs in the referencing variable.
1400 If any of the modifiers in the
1401 .Ar modifier_variable
1402 contains a dollar sign
1404 these must be doubled to avoid early expansion.
1406 Some modifiers interpret the expression value as a single string,
1407 others treat the expression value as a whitespace-separated list of words.
1408 When splitting a string into words,
1409 whitespace can be escaped using double quotes, single quotes and backslashes,
1411 The quotes and backslashes are retained in the words.
1413 The supported modifiers are:
1416 Replaces each word with its suffix.
1418 Replaces each word with its dirname.
1419 .It Cm \&:M\| Ns Ar pattern
1420 Selects only those words that match
1422 The standard shell wildcard characters
1429 The wildcard characters may be escaped with a backslash
1431 As a consequence of the way values are split into words, matched,
1432 and then joined, the construct
1434 removes all leading and trailing whitespace
1435 and normalizes the inter-word spacing to a single space.
1436 .It Cm \&:N\| Ns Ar pattern
1437 This is the opposite of
1439 selecting all words which do
1444 Orders the words lexicographically.
1446 Orders the words numerically.
1447 A number followed by one of
1452 is multiplied by the appropriate factor, which is 1024 for
1458 Both upper- and lower-case letters are accepted.
1460 Orders the words in reverse lexicographical order.
1462 Orders the words in reverse numerical order.
1465 The results are different each time you are referring to the
1466 modified variable; use the assignment with expansion
1468 to prevent such behavior.
1470 .Bd -literal -offset indent
1471 LIST= uno due tre quattro
1472 RANDOM_LIST= ${LIST:Ox}
1473 STATIC_RANDOM_LIST:= ${LIST:Ox}
1476 @echo "${RANDOM_LIST}"
1477 @echo "${RANDOM_LIST}"
1478 @echo "${STATIC_RANDOM_LIST}"
1479 @echo "${STATIC_RANDOM_LIST}"
1481 may produce output similar to:
1482 .Bd -literal -offset indent
1489 Quotes every shell meta-character in the value, so that it can be passed
1490 safely to the shell.
1492 Quotes every shell meta-character in the value, and also doubles
1494 characters so that it can be passed
1495 safely through recursive invocations of
1497 This is equivalent to
1498 .Sq Cm \&:S/\e\&$/&&/g:Q .
1500 Replaces each word with everything but its suffix.
1501 .It Cm \&:range Ns Oo Cm = Ns Ar count Oc
1502 The value is an integer sequence representing the words of the original
1503 value, or the supplied
1505 .It Cm \&:gmtime Ns Oo Cm = Ns Ar timestamp Oc
1506 The value is interpreted as a format string for
1510 producing the formatted timestamp.
1513 value is not provided or is 0, the current time is used.
1515 Computes a 32-bit hash of the value and encodes it as 8 hex digits.
1516 .It Cm \&:localtime Ns Oo Cm = Ns Ar timestamp Oc
1517 The value is interpreted as a format string for
1521 producing the formatted timestamp.
1524 value is not provided or is 0, the current time is used.
1525 .It Cm \&:mtime Ns Oo Cm = Ns Ar timestamp Oc
1528 with each word as pathname;
1543 failure will cause an error.
1545 Attempts to convert the value to an absolute path using
1547 If that fails, the value is unchanged.
1549 Converts the value to lower-case letters.
1550 .It Cm \&:ts Ns Ar c
1551 When joining the words after a modifier that treats the value as words,
1552 the words are normally separated by a space.
1553 This modifier changes the separator to the character
1557 is omitted, no separator is used.
1558 The common escapes (including octal numeric codes) work as expected.
1560 Converts the value to upper-case letters.
1562 Causes subsequent modifiers to treat the value as a single word
1563 (possibly containing embedded whitespace).
1567 Causes the value to be treated as a list of words.
1571 .It Cm \&:S\| No \&/ Ar old_string\| No \&/ Ar new_string\| No \&/ Op Cm 1gW
1573 Modifies the first occurrence of
1575 in each word of the value, replacing it with
1579 is appended to the last delimiter of the pattern,
1580 all occurrences in each word are replaced.
1583 is appended to the last delimiter of the pattern,
1584 only the first occurrence is affected.
1587 is appended to the last delimiter of the pattern,
1588 the value is treated as a single word.
1594 is anchored at the beginning of each word.
1597 ends with a dollar sign
1599 it is anchored at the end of each word.
1606 (without the anchoring
1610 Any character may be used as the delimiter for the parts of the modifier
1612 The anchoring, ampersand and delimiter characters can be escaped with a
1620 may contain nested expressions.
1621 To prevent a dollar sign from starting a nested expression,
1622 escape it with a backslash.
1624 .It Cm \&:C\| No \&/ Ar pattern\| No \&/ Ar replacement\| No \&/ Op Cm 1gW
1628 modifier works like the
1630 modifier except that the old and new strings, instead of being
1631 simple strings, are an extended regular expression
1638 Normally, the first occurrence of the pattern
1640 in each word of the value is substituted with
1644 modifier causes the substitution to apply to at most one word; the
1646 modifier causes the substitution to apply to as many instances of the
1649 as occur in the word or words it is found in; the
1651 modifier causes the value to be treated as a single word
1652 (possibly containing embedded whitespace).
1660 are subjected to variable expansion before being parsed as
1661 regular expressions.
1663 Replaces each word with its last path component (basename).
1665 Removes adjacent duplicate words (like
1668 .It Cm \&:\&?\| Ar true_string\| Cm \&: Ar false_string
1670 If the variable name (not its value), when parsed as a
1672 conditional expression, evaluates to true, return as its value the
1674 otherwise return the
1676 Since the variable name is used as the expression,
1677 \&:\&? must be the first modifier after the variable name
1678 .No itself Ns \^\(em\^ Ns
1679 which, of course, usually contains variable expansions.
1680 A common error is trying to use expressions like
1681 .Dl ${NUMBERS:M42:?match:no}
1682 which actually tests defined(NUMBERS).
1683 To determine if any words match
1685 you need to use something like:
1686 .Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} .
1687 .It Cm :\| Ns Ar old_string\| Ns Cm = Ns Ar new_string
1691 It can only be the last modifier specified,
1698 is treated as a regular character, not as the end of the modifier.
1702 does not contain the pattern matching character
1704 and the word ends with
1707 that suffix is replaced with
1710 Otherwise, the first
1714 matches a possibly empty substring of arbitrary characters,
1715 and if the whole pattern is found in the word,
1716 the matching part is replaced with
1718 and the first occurrence of
1722 (if any) is replaced with the substring matched by the
1729 may contain nested expressions.
1730 To prevent a dollar sign from starting a nested expression,
1731 escape it with a backslash.
1733 .It Cm \&:@ Ar varname\| Cm @ Ar string\| Cm @
1735 This is the loop expansion mechanism from the OSF Development
1736 Environment (ODE) make.
1739 loops, expansion occurs at the time of reference.
1740 For each word in the value, assign the word to the variable named
1744 The ODE convention is that
1746 should start and end with a period, for example:
1747 .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1749 However, a single-letter variable is often more readable:
1750 .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1751 .It Cm \&:_ Ns Oo Cm = Ns Ar var Oc
1752 Saves the current variable value in
1756 for later reference.
1758 .Bd -literal -offset indent
1759 M_cmpv.units = 1 1000 1000000
1760 M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
1761 \\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
1763 .Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
1768 is used to save the result of the
1770 modifier which is later referenced using the index values from
1772 .It Cm \&:U\| Ns Ar newval
1773 If the variable is undefined,
1776 If the variable is defined, the existing value is returned.
1777 This is another ODE make feature.
1778 It is handy for setting per-target CFLAGS for instance:
1779 .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1780 If a value is only required if the variable is undefined, use:
1781 .Dl ${VAR:D:Unewval}
1782 .It Cm \&:D\| Ns Ar newval
1783 If the variable is defined,
1787 The name of the variable is the value.
1789 The path of the node which has the same name as the variable is the value.
1790 If no such node exists or its path is null, the name of the variable is used.
1791 In order for this modifier to work, the name (node) must at least have
1792 appeared on the right-hand side of a dependency.
1794 .It Cm \&:\&! Ar cmd\| Cm \&!
1796 The output of running
1800 The value is run as a command, and the output becomes the new value.
1801 .It Cm \&::= Ns Ar str
1802 The variable is assigned the value
1805 This modifier and its variations are useful in obscure situations
1806 such as wanting to set a variable
1807 at a point where a target's shell commands are being parsed.
1808 These assignment modifiers always expand to nothing.
1812 helps avoid false matches with the
1816 modifier and since substitution always occurs, the
1818 form is vaguely appropriate.
1819 .It Cm \&::?= Ns Ar str
1822 but only if the variable does not already have a value.
1823 .It Cm \&::+= Ns Ar str
1827 .It Cm \&::!= Ns Ar cmd
1828 Assign the output of
1831 .It Cm \&:\&[ Ns Ar range Ns Cm \&]
1832 Selects one or more words from the value,
1833 or performs other operations related to the way in which the
1834 value is split into words.
1836 An empty value, or a value that consists entirely of white-space,
1837 is treated as a single word.
1838 For the purposes of the
1840 modifier, the words are indexed both forwards using positive integers
1841 (where index 1 represents the first word),
1842 and backwards using negative integers
1843 (where index \-1 represents the last word).
1847 is subjected to variable expansion, and the expanded result is
1848 then interpreted as follows:
1849 .Bl -tag -width index
1852 Selects a single word from the value.
1854 .It Ar start Ns Cm \&.. Ns Ar end
1855 Selects all words from
1862 selects all words from the second word to the last word.
1867 the words are output in reverse order.
1870 selects all the words from last to first.
1871 If the list is already ordered,
1872 this effectively reverses the list,
1873 but it is more efficient to use
1876 .Sq Cm \&:O:[-1..1] .
1879 Causes subsequent modifiers to treat the value as a single word
1880 (possibly containing embedded whitespace).
1881 Analogous to the effect of
1890 Causes subsequent modifiers to treat the value as a sequence of words
1891 delimited by whitespace.
1892 Analogous to the effect of
1897 Returns the number of words in the value.
1902 offers directives for including makefiles, conditionals and for loops.
1903 All these directives are identified by a line beginning with a single dot
1905 character, followed by the keyword of the directive, such as
1910 Files are included with either
1911 .Cm \&.include \&< Ns Ar file Ns Cm \&>
1913 .Cm \&.include \&\*q Ns Ar file Ns Cm \&\*q .
1914 Variables between the angle brackets or double quotes are expanded
1915 to form the file name.
1916 If angle brackets are used, the included makefile is expected to be in
1917 the system makefile directory.
1918 If double quotes are used, the including makefile's directory and any
1919 directories specified using the
1921 option are searched before the system makefile directory.
1923 For compatibility with other make variants,
1924 .Sq Cm include Ar file No ...
1925 (without leading dot)
1928 If the include statement is written as
1932 errors locating and/or opening include files are ignored.
1934 If the include statement is written as
1936 not only are errors locating and/or opening include files ignored,
1937 but stale dependencies within the included file are ignored just like in
1938 .Va .MAKE.DEPENDFILE .
1939 .Ss Exporting variables
1940 The directives for exporting and unexporting variables are:
1942 .It Ic .export Ar variable No ...
1943 Export the specified global variable.
1944 If no variable list is provided, all globals are exported
1945 except for internal variables (those that start with
1947 This is not affected by the
1949 flag, so should be used with caution.
1950 For compatibility with other make programs,
1951 .Cm export Ar variable\| Ns Cm \&= Ns Ar value
1952 (without leading dot) is also accepted.
1954 Appending a variable name to
1956 is equivalent to exporting a variable.
1957 .It Ic .export-env Ar variable No ...
1960 except that the variable is not appended to
1961 .Va .MAKE.EXPORTED .
1962 This allows exporting a value to the environment which is different from that
1966 .It Ic .export-literal Ar variable No ...
1969 except that variables in the value are not expanded.
1970 .It Ic .unexport Ar variable No ...
1973 The specified global
1976 .Va .MAKE.EXPORTED .
1977 If no variable list is provided, all globals are unexported,
1981 .It Ic .unexport-env
1982 Unexport all globals previously exported and
1983 clear the environment inherited from the parent.
1984 This operation causes a memory leak of the original environment,
1985 so should be used sparingly.
1988 being 0 would make sense.
1989 Also note that any variables which originated in the parent environment
1990 should be explicitly preserved if desired.
1992 .Bd -literal -offset indent
1993 .Li .if ${.MAKE.LEVEL} == 0
2000 Would result in an environment containing only
2002 which is the minimal useful environment.
2003 .\" TODO: Check the below sentence, environment variables don't start with '.'.
2006 is also pushed into the new environment.
2009 The directives for printing messages to the output are:
2011 .It Ic .info Ar message
2012 The message is printed along with the name of the makefile and line number.
2013 .It Ic .warning Ar message
2014 The message prefixed by
2016 is printed along with the name of the makefile and line number.
2017 .It Ic .error Ar message
2018 The message is printed along with the name of the makefile and line number,
2023 The directives for conditionals are:
2024 .ds maybenot Oo Ic \&! Oc Ns
2026 .It Ic .if \*[maybenot] Ar expression Op Ar operator expression No ...
2027 Test the value of an expression.
2028 .It Ic .ifdef \*[maybenot] Ar variable Op Ar operator variable No ...
2029 Test whether a variable is defined.
2030 .It Ic .ifndef \*[maybenot] Ar variable Op Ar operator variable No ...
2031 Test whether a variable is not defined.
2032 .It Ic .ifmake \*[maybenot] Ar target Op Ar operator target No ...
2033 Test the target being requested.
2034 .It Ic .ifnmake \*[maybenot] Ar target Op Ar operator target No ...
2035 Test the target being requested.
2037 Reverse the sense of the last conditional.
2038 .It Ic .elif \*[maybenot] Ar expression Op Ar operator expression No ...
2043 .It Ic .elifdef \*[maybenot] Ar variable Op Ar operator variable No ...
2048 .It Ic .elifndef \*[maybenot] Ar variable Op Ar operator variable No ...
2053 .It Ic .elifmake \*[maybenot] Ar target Op Ar operator target No ...
2058 .It Ic .elifnmake \*[maybenot] Ar target Op Ar operator target No ...
2064 End the body of the conditional.
2069 may be any one of the following:
2074 Logical AND; of higher precedence than
2079 only evaluates a conditional as far as is necessary to determine its value.
2080 Parentheses can be used to override the operator precedence.
2081 The boolean operator
2083 may be used to logically negate an entire conditional.
2084 It is of higher precedence than
2089 may be any of the following function call expressions:
2092 .It Ic defined Li \&( Ar varname Li \&)
2094 Evaluates to true if the variable
2098 .It Ic make Li \&( Ar target Li \&)
2100 Evaluates to true if the target was specified as part of
2102 command line or was declared the default target (either implicitly or
2105 before the line containing the conditional.
2107 .It Ic empty Li \&( Ar varname Oo Li : Ar modifiers Oc Li \&)
2109 Evaluates to true if the expansion of the variable,
2110 after applying the modifiers, results in an empty string.
2112 .It Ic exists Li \&( Ar pathname Li \&)
2114 Evaluates to true if the given pathname exists.
2115 If relative, the pathname is searched for on the system search path (see
2118 .It Ic target Li \&( Ar target Li \&)
2120 Evaluates to true if the target has been defined.
2122 .It Ic commands Li \&( Ar target Li \&)
2124 Evaluates to true if the target has been defined
2125 and has commands associated with it.
2129 may also be an arithmetic or string comparison.
2130 Variable expansion is performed on both sides of the comparison.
2131 If both sides are numeric and neither is enclosed in quotes,
2132 the comparison is done numerically, otherwise lexicographically.
2133 A string is interpreted as hexadecimal integer if it is preceded by
2135 otherwise it is a decimal floating-point number;
2136 octal numbers are not supported.
2138 All comparisons may use the operators
2142 Numeric comparisons may also use the operators
2149 If the comparison has neither a comparison operator nor a right side,
2150 the expression evaluates to true if it is nonempty
2151 and its numeric value (if any) is not zero.
2155 is evaluating one of these conditional expressions, and it encounters
2156 a (whitespace separated) word it doesn't recognize, either the
2160 function is applied to it, depending on the form of the conditional.
2168 function is applied.
2169 Similarly, if the form is
2175 function is applied.
2177 If the conditional evaluates to true,
2178 parsing of the makefile continues as before.
2179 If it evaluates to false, the following lines are skipped.
2180 In both cases, this continues until the corresponding
2186 For loops are typically used to apply a set of rules to a list of files.
2187 The syntax of a for loop is:
2189 .Bl -tag -compact -width Ds
2190 .It Ic \&.for Ar variable Oo Ar variable No ... Oc Ic in Ar expression
2191 .It Aq Ar make-lines
2197 is expanded and then split into words.
2198 On each iteration of the loop, one word is taken and assigned to each
2202 are substituted into the
2204 inside the body of the for loop.
2205 The number of words must come out even; that is, if there are three
2206 iteration variables, the number of words provided must be a multiple
2211 is encountered within a
2213 loop, it causes early termination of the loop, otherwise a parse error.
2214 .\" TODO: Describe limitations with defined/empty.
2215 .Ss Other directives
2217 .It Ic .undef Ar variable No ...
2218 Un-define the specified global variables.
2219 Only global variables can be un-defined.
2222 Comments begin with a hash
2224 character, anywhere but in a shell
2225 command line, and continue to the end of an unescaped new line.
2226 .Sh SPECIAL SOURCES (ATTRIBUTES)
2227 .Bl -tag -width .IGNOREx
2229 Target is never out of date, but always execute commands anyway.
2231 Ignore any errors from the commands associated with this target, exactly
2232 as if they all were preceded by a dash
2234 .\" .It Ic .INVISIBLE
2239 Mark all sources of this target as being up to date.
2241 Execute the commands associated with this target even if the
2245 options were specified.
2246 Normally used to mark recursive
2249 Create a meta file for the target, even if it is flagged as
2254 Usage in conjunction with
2256 is the most likely case.
2259 mode, the target is out-of-date if the meta file is missing.
2261 Do not create a meta file for the target.
2262 Meta files are also not created for
2269 Ignore differences in commands when deciding if target is out of date.
2270 This is useful if the command contains a value which always changes.
2271 If the number of commands change, though,
2272 the target is still considered out of date.
2273 The same effect applies to any command line that uses the variable
2275 which can be used for that purpose even when not otherwise needed or desired:
2276 .Bd -literal -offset indent
2278 skip-compare-for-some:
2279 @echo this is compared
2280 @echo this is not ${.OODATE:M.NOMETA_CMP}
2281 @echo this is also compared
2286 pattern suppresses any expansion of the unwanted variable.
2288 Do not search for the target in the directories specified by
2293 selects the first target it encounters as the default target to be built
2294 if no target was specified.
2295 This source prevents this target from being selected.
2297 If a target is marked with this attribute and
2299 can't figure out how to create it, it ignores this fact and assumes
2300 the file isn't needed or already exists.
2302 The target does not correspond to an actual file;
2303 it is always considered to be out of date,
2304 and is not created with the
2307 Suffix-transformation rules are not applied to
2313 is interrupted, it normally removes any partially made targets.
2314 This source prevents the target from being removed.
2319 Do not echo any of the commands associated with this target, exactly
2320 as if they all were preceded by an at sign
2323 Turn the target into
2326 When the target is used as a source for another target, the other target
2327 acquires the commands, sources, and attributes (except for
2331 If the target already has commands, the
2333 target's commands are appended
2338 but instead of appending, prepend the
2340 target commands to the target.
2344 appears in a dependency line, the sources that precede it are
2345 made before the sources that succeed it in the line.
2346 Since the dependents of files are not made until the file itself
2347 could be made, this also stops the dependents being built unless they
2348 are needed for another branch of the dependency tree.
2361 the output is always
2367 The ordering imposed by
2369 is only relevant for parallel makes.
2372 Special targets may not be included with other targets, i.e. they must be
2373 the only target specified.
2374 .Bl -tag -width .BEGINx
2376 Any command lines attached to this target are executed before anything
2381 rule for any target (that was used only as a source) that
2383 can't figure out any other way to create.
2384 Only the shell script is used.
2387 variable of a target that inherits
2389 commands is set to the target's own name.
2390 .It Ic .DELETE_ON_ERROR
2391 If this target is present in the makefile, it globally causes make to
2392 delete targets whose commands fail.
2393 (By default, only targets whose commands are interrupted during
2394 execution are deleted.
2395 This is the historical behavior.)
2396 This setting can be used to help prevent half-finished or malformed
2397 targets from being left around and corrupting future rebuilds.
2399 Any command lines attached to this target are executed after everything
2400 else is done successfully.
2402 Any command lines attached to this target are executed when another target fails.
2405 variable is set to the target that failed.
2407 .Va MAKE_PRINT_VAR_ON_ERROR .
2409 Mark each of the sources with the
2412 If no sources are specified, this is the equivalent of specifying the
2418 is interrupted, the commands for this target are executed.
2420 If no target is specified when
2422 is invoked, this target is built.
2424 This target provides a way to specify flags for
2426 at the time when the makefiles are read.
2427 The flags are as if typed to the shell, though the
2431 .\" XXX: NOT YET!!!!
2432 .\" .It Ic .NOTPARALLEL
2433 .\" The named targets are executed in non parallel mode.
2434 .\" If no targets are
2435 .\" specified, all targets are executed in non parallel mode.
2439 attribute to any specified sources.
2441 Disable parallel mode.
2445 for compatibility with other pmake variants.
2447 clear the read-only attribute from the global variables specified as sources.
2449 The source is a new value for
2453 changes the current working directory to it and updates the value of
2456 In parallel mode, the named targets are made in sequence.
2457 This ordering does not add targets to the list of targets to be made.
2459 Since the dependents of a target do not get built until the target itself
2460 could be built, unless
2462 is built by another part of the dependency graph,
2463 the following is a dependency loop:
2469 .\" XXX: NOT YET!!!!
2470 .\" .It Ic .PARALLEL
2471 .\" The named targets are executed in parallel mode.
2472 .\" If no targets are
2473 .\" specified, all targets are executed in parallel mode.
2475 The sources are directories which are to be searched for files not
2476 found in the current directory.
2477 If no sources are specified,
2478 any previously specified directories are removed from the search path.
2479 If the source is the special
2481 target, the current working directory is searched last.
2482 .It Ic .PATH. Ns Ar suffix
2485 but applies only to files with a particular suffix.
2486 The suffix must have been previously declared with
2491 attribute to any specified sources.
2493 If this is the first non-comment line in the main makefile,
2500 is included if it exists,
2501 to provide POSIX-compatible default rules.
2508 contributes to the default rules.
2512 attribute to any specified sources.
2513 If no sources are specified, the
2515 attribute is applied to every target in the file.
2517 set the read-only attribute on the global variables specified as sources.
2521 uses to execute commands in jobs mode.
2522 The sources are a set of
2523 .Ar field\| Ns Cm \&= Ns Ar value
2525 .Bl -tag -width ".Li hasErrCtls"
2527 This is the minimal specification, used to select one of the built-in
2534 Specifies the absolute path to the shell.
2536 Indicates whether the shell supports exit on error.
2538 The command to turn on error checking.
2540 The command to disable error checking.
2542 The command to turn on echoing of commands executed.
2544 The command to turn off echoing of commands executed.
2546 The output to filter after issuing the
2549 It is typically identical to
2552 The flag to pass the shell to enable error checking.
2554 The flag to pass the shell to enable command echoing.
2556 The string literal to pass the shell that results in a single newline
2557 character when used outside of any quoting characters.
2561 \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e
2562 check="set \-e" ignore="set +e" \e
2563 echo="set \-v" quiet="set +v" filter="set +v" \e
2564 echoFlag=v errFlag=e newline="'\en'"
2569 attribute to any specified sources.
2570 If no sources are specified, the
2572 attribute is applied to every
2573 command in the file.
2575 This target gets run when a dependency file contains stale entries, having
2577 set to the name of that dependency file.
2579 Each source specifies a suffix to
2581 If no sources are specified, any previously specified suffixes are deleted.
2582 It allows the creation of suffix-transformation rules.
2588 cc \-o ${.TARGET} \-c ${.IMPSRC}
2591 The sources are directories which are to be added to the system
2594 searches for makefiles.
2595 If no sources are specified,
2596 any previously specified directories are removed from the system
2601 uses the following environment variables, if they exist:
2607 .Ev MAKEOBJDIRPREFIX ,
2613 .Ev MAKEOBJDIRPREFIX
2616 may only be set in the environment or on the command line to
2618 and not as makefile variables;
2619 see the description of
2623 .Bl -tag -width /usr/share/mk -compact
2625 list of dependencies
2627 first default makefile if no makefile is specified on the command line
2629 second default makefile if no makefile is specified on the command line
2633 system makefile directory
2636 The basic make syntax is compatible between different make variants;
2637 however the special variables, variable modifiers and conditionals are not.
2639 An incomplete list of changes in older versions of
2642 The way that .for loop variables are substituted changed after
2644 so that they still appear to be variable expansions.
2645 In particular this stops them being treated as syntax, and removes some
2646 obscure problems using them in .if statements.
2648 The way that parallel makes are scheduled changed in
2650 so that .ORDER and .WAIT apply recursively to the dependent nodes.
2651 The algorithms used may change again in the future.
2652 .Ss Other make dialects
2653 Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
2654 support most of the features of
2656 as described in this manual.
2658 .Bl -bullet -offset indent
2664 declarations and most functionality pertaining to parallelization.
2665 (GNU make supports parallelization but lacks the features needed to
2666 control it effectively.)
2668 Directives, including for loops and conditionals and most of the
2669 forms of include files.
2670 (GNU make has its own incompatible and less powerful syntax for
2672 .\" The "less powerful" above means that GNU make does not have the
2673 .\" make(target), target(target) and commands(target) functions.
2675 All built-in variables that begin with a dot.
2677 Most of the special sources and targets that begin with a dot,
2678 with the notable exception of
2684 Variable modifiers, except for the
2686 string substitution, which does not portably support globbing with
2688 and historically only works on declared suffixes.
2692 variable even in its short form; most makes support this functionality
2693 but its name varies.
2696 Some features are somewhat more portable, such as assignment with
2703 functionality is based on an older feature
2705 found in GNU make and many versions of SVR4 make; however,
2706 historically its behavior is too ill-defined (and too buggy) to rely
2713 variables are more or less universally portable, as is the
2716 Basic use of suffix rules (for files only in the current directory,
2717 not trying to chain transformations together, etc.) is also reasonably
2721 .Xr style.Makefile 5
2729 implementation is based on Adam de Boor's pmake program,
2730 which was written for Sprite at Berkeley.
2731 It was designed to be a parallel distributed make running jobs on different
2732 machines using a daemon called
2735 Historically the target/dependency
2737 has been used to FoRCe rebuilding (since the target/dependency
2738 does not exist ... unless someone creates an
2744 syntax is difficult to parse.
2745 For instance, finding the end of a variable's use should involve scanning
2746 each of the modifiers, using the correct terminator for each field.
2749 just counts {} and () in order to find the end of a variable expansion.
2751 There is no way of escaping a space character in a filename.
2753 In jobs mode, when a target fails;
2755 will put an error token into the job token pool.
2756 This will cause all other instances of
2758 using that token pool to abort the build and exit with error code 6.
2759 Sometimes the attempt to suppress a cascade of unnecessary errors,
2760 can result in a seemingly unexplained
2761 .Ql *** Error code 6