1 .\" $NetBSD: make.1,v 1.360 2023/01/26 20:48:17 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.
270 The value is saved in
272 Turns compatibility mode off, unless the
274 option is also specified.
275 When compatibility mode is off, all commands associated with a
276 target are executed in a single shell invocation as opposed to the
277 traditional one shell invocation per line.
278 This can break traditional scripts which change directories on each
279 command invocation and then expect to start with a fresh environment
281 It is more efficient to correct the scripts rather than turn backwards
284 Continue processing after errors are encountered, but only on those targets
285 that do not depend on the target whose creation caused the error.
286 .It Fl m Ar directory
287 Specify a directory in which to search for
289 and makefiles included via the
290 .Li \&< Ns Ar file Ns Li \&> Ns -style
294 option can be used multiple times to form a search path.
295 This path overrides the default system include path
297 Furthermore, the system include path is appended to the search path used for
298 .Li \*q Ns Ar file Ns Li \*q Ns -style
299 include statements (see the
302 The system include path can be referenced via the read-only variable
305 If a directory name in the
309 environment variable) starts with the string
312 searches for the specified file or directory named in the remaining part
313 of the argument string.
314 The search starts with the current directory
315 and then works upward towards the root of the file system.
316 If the search is successful, the resulting directory replaces the
323 to easily search in the current source tree for customized
325 files (e.g., by using
329 Display the commands that would have been executed, but do not
330 actually execute them unless the target depends on the
332 special source (see below) or the command is prefixed with
335 Display the commands that would have been executed,
336 but do not actually execute any of them;
337 useful for debugging top-level makefiles
338 without descending into subdirectories.
340 Do not execute any commands,
341 instead exit 0 if the specified targets are up to date, and 1 otherwise.
343 Do not use the built-in rules specified in the system makefile.
345 Stop processing if an error is encountered.
346 This is the default behavior and the opposite of
349 Do not echo any commands as they are executed.
350 Equivalent to specifying
352 before each command line in the makefile.
353 .It Fl T Ar tracefile
357 append a trace record to
359 for each job started and completed.
361 Rather than re-building a target as specified in the makefile, create it
362 or update its modification time to make it appear up-to-date.
366 Do not build any targets.
367 Multiple instances of this option may be specified;
368 the variables are printed one per line,
369 with a blank line for each null or undefined variable.
370 The value printed is extracted from the global scope after all
371 makefiles have been read.
373 By default, the raw variable contents (which may
374 include additional unexpanded variable references) are shown.
379 it is not interpreted as a variable name but rather as an expression.
380 Its value is expanded before printing.
381 The value is also expanded before printing if
382 .Va .MAKE.EXPAND_VARIABLES
383 is set to true and the
385 option has not been used to override it.
387 Note that loop-local and target-local variables, as well as values
388 taken temporarily by global variables during makefile processing, are
389 not accessible via this option.
392 debug mode can be used to see these at the cost of generating
393 substantial extraneous output.
397 but all printed variables are always expanded to their complete value.
398 The last occurrence of
402 decides whether all variables are expanded or not.
404 Treat any warnings during makefile parsing as errors.
406 Print entering and leaving directory messages, pre and post processing.
408 Don't export variables passed on the command line to the environment
410 Variables passed on the command line are still exported via the
412 environment variable.
413 This option may be useful on systems which have a small limit on the
414 size of command arguments.
415 .It Ar variable\| Ns Cm \&= Ns Ar value
416 Set the value of the variable
420 Normally, all values passed on the command line are also exported to
421 sub-makes in the environment.
424 flag disables this behavior.
425 Variable assignments should follow options for POSIX compatibility
426 but no ordering is enforced.
429 There are several different types of lines in a makefile: dependency
430 specifications, shell commands, variable assignments, include statements,
431 conditional directives, for loops, other directives, and comments.
433 Lines may be continued from one line to the next
434 by ending them with a backslash
436 The trailing newline character and initial whitespace on the following
437 line are compressed into a single space.
438 .Sh FILE DEPENDENCY SPECIFICATIONS
439 Dependency lines consist of one or more targets, an operator, and zero
441 This creates a relationship where the targets
443 on the sources and are customarily created from them.
444 A target is considered out of date if it does not exist,
445 or if its modification time is less than that of any of its sources.
446 An out-of-date target is re-created, but not until all sources
447 have been examined and themselves re-created as needed.
448 Three operators may be used:
451 Many dependency lines may name this target but only one may have
452 attached shell commands.
453 All sources named in all dependency lines are considered together,
454 and if needed the attached shell commands are run to create or
455 re-create the target.
458 is interrupted, the target is removed.
460 The same, but the target is always re-created whether or not it is out
463 Any dependency line may have attached shell commands, but each one
464 is handled independently: its sources are considered and the attached
465 shell commands are run if the target is out of date with respect to
466 (only) those sources.
467 Thus, different groups of the attached shell commands may be run
468 depending on the circumstances.
471 for dependency lines with no sources, the attached shell
472 commands are always run.
475 the target is not removed if
480 All dependency lines mentioning a particular target must use the same
483 Targets and sources may contain the shell wildcard values
494 may only be used as part of the final component of the target or source,
495 and only match existing files.
498 need not necessarily be used to describe existing files.
499 Expansion is in directory order, not alphabetically as done in the shell.
501 Each target may have associated with it one or more lines of shell commands,
502 normally used to create the target.
503 Each of the lines in this script
505 be preceded by a tab.
506 (For historical reasons, spaces are not accepted.)
507 While targets can occur in many dependency lines if desired,
508 by default only one of these rules may be followed by a creation script.
511 operator is used, however, all rules may include scripts,
512 and the respective scripts are executed in the order found.
514 Each line is treated as a separate shell command,
515 unless the end of line is escaped with a backslash
517 in which case that line and the next are combined.
518 If the first characters of the command are any combination of
523 the command is treated specially.
524 .Bl -tag -offset indent -width indent
526 causes the command not to be echoed before it is executed.
528 causes the command to be executed even when
531 This is similar to the effect of the
534 except that the effect can be limited to a single line of a script.
536 in compatibility mode
537 causes any non-zero exit status of the command line to be ignored.
542 is run in jobs mode with
544 the entire script for the target is fed to a single instance of the shell.
545 In compatibility (non-jobs) mode, each command is run in a separate process.
546 If the command contains any shell meta characters
547 .Pq Ql #=|^(){};&<>*?[]:$`\e\en ,
548 it is passed to the shell; otherwise
550 attempts direct execution.
551 If a line starts with
553 and the shell has ErrCtl enabled,
554 failure of the command line is ignored as in compatibility mode.
557 affects the entire job;
558 the script stops at the first command line that fails,
559 but the target is not deemed to have failed.
561 Makefiles should be written so that the mode of
563 operation does not change their behavior.
564 For example, any command which uses
568 without the intention of changing the directory for subsequent commands
569 should be put in parentheses so it executes in a subshell.
570 To force the use of a single shell, escape the line breaks so as to make
571 the whole script one command.
573 .Bd -literal -offset indent
574 avoid-chdir-side-effects:
575 @echo "Building $@ in $$(pwd)"
576 @(cd ${.CURDIR} && ${MAKE} $@)
577 @echo "Back in $$(pwd)"
579 ensure-one-shell-regardless-of-mode:
580 @echo "Building $@ in $$(pwd)"; \e
581 (cd ${.CURDIR} && ${MAKE} $@); \e
582 echo "Back in $$(pwd)"
587 changes the current working directory to
589 before executing any targets,
590 each child process starts with that as its current working directory.
591 .Sh VARIABLE ASSIGNMENTS
592 Variables in make behave much like macros in the C preprocessor.
594 Variable assignments have the form
595 .Sq Ar NAME Ar op Ar value ,
597 .Bl -tag -offset Ds -width Ds
599 is a single-word variable name,
600 consisting, by tradition, of all upper-case letters,
602 is one of the variable assignment operators described below, and
604 is interpreted according to the variable assignment operator.
613 .Ss Variable assignment operators
614 The five operators that assign values to variables are:
617 Assign the value to the variable.
618 Any previous value is overwritten.
620 Append the value to the current value of the variable,
621 separating them by a single space.
623 Assign the value to the variable if it is not already defined.
625 Expand the value, then assign it to the variable.
628 References to undefined variables are
631 This can cause problems when variable modifiers are used.
632 .\" See var-op-expand.mk, the section with LATER and INDIRECT.
634 Expand the value and pass it to the shell for execution,
635 then assign the output from the child's standard output to the variable.
636 Any newlines in the result are replaced with spaces.
638 .Ss Expansion of variables
639 In most contexts where variables are expanded,
641 expands to a single dollar sign.
642 In other contexts (most variable modifiers, string literals in conditions),
644 expands to a single dollar sign.
646 References to variables have the form
647 .Cm \&${ Ns Ar name Ns Oo Ns Cm \&: Ns Ar modifiers Oc Ns Cm \&}
649 .Cm \&$( Ns Ar name Ns Oo Ns Cm \&: Ns Ar modifiers Oc Ns Cm \&) .
650 If the variable name consists of only a single character
651 and the expression contains no modifiers,
652 the surrounding curly braces or parentheses are not required.
653 This shorter form is not recommended.
655 If the variable name contains a dollar, the name itself is expanded first.
656 This allows almost arbitrary variable names, however names containing dollar,
657 braces, parentheses or whitespace are really best avoided.
659 If the result of expanding a nested variable expression contains a dollar sign
661 the result is subject to further expansion.
663 Variable substitution occurs at four distinct times, depending on where
664 the variable is being used.
667 Variables in dependency lines are expanded as the line is read.
669 Variables in conditionals are expanded individually,
670 but only as far as necessary to determine the result of the conditional.
672 Variables in shell commands are expanded when the shell command is
676 loop index variables are expanded on each loop iteration.
677 Note that other variables are not expanded when composing the body of a loop,
678 so the following example code:
679 .Bd -literal -offset indent
692 .Bd -literal -offset indent
697 After the loop is executed:
698 .Bl -tag -offset indent -width indent
701 .Ql ${:U1} ${:U2} ${:U3} ,
713 .Ql ${:U3} ${:U3} ${:U3}
719 The four different classes of variables (in order of increasing precedence)
722 .It Environment variables
723 Variables defined as part of
727 Variables defined in the makefile or in included makefiles.
728 .It Command line variables
729 Variables defined as part of the command line.
731 Variables that are defined specific to a certain target.
734 Local variables can be set on a dependency line, unless
735 .Va .MAKE.TARGET_LOCAL_VARIABLES
739 (which already has had global variables expanded)
740 is the variable value.
742 .Bd -literal -offset indent
743 COMPILER_WRAPPERS= ccache distcc icecc
745 ${OBJS}: .MAKE.META.CMP_FILTER=${COMPILER_WRAPPERS:S,^,N,}
750 are impacted by that filter (in
753 simply enabling/disabling any of the compiler wrappers does not render all
754 of those targets out-of-date.
757 target-local variable assignments behave differently in that;
758 .Bl -tag -width Ds -offset indent
760 Only appends to a previous local assignment
761 for the same target and variable.
763 Is redundant with respect to global variables,
764 which have already been expanded.
767 The seven built-in local variables are:
768 .Bl -tag -width ".Va .ARCHIVE" -offset indent
770 The list of all sources for this target; also known as
773 The name of the archive file; also known as
776 In suffix-transformation rules, the name/path of the source from which the
777 target is to be transformed (the
779 source); also known as
781 It is not defined in explicit rules.
783 The name of the archive member; also known as
786 The list of sources for this target that were deemed out-of-date; also
790 The file prefix of the target, containing only the file portion, no suffix
791 or preceding directory components; also known as
793 The suffix must be one of the known suffixes declared with
795 or it is not recognized.
797 The name of the target; also known as
799 For compatibility with other makes this is an alias for
801 in archive member rules.
815 are permitted for backward
816 compatibility with historical makefiles and legacy POSIX make and are
819 Variants of these variables with the punctuation followed immediately by
825 are legacy forms equivalent to using the
830 These forms are accepted for compatibility with
832 makefiles and POSIX but are not recommended.
834 Four of the local variables may be used in sources on dependency lines
835 because they expand to the proper value for each target on the line.
842 .Ss Additional built-in variables
845 sets or knows about the following variables:
847 .\" NB: This list is sorted case-insensitive, ignoring punctuation.
848 .\" NB: To find all built-in variables in make's source code,
849 .\" NB: search for Var_*, Global_*, SetVarObjdir, GetBooleanExpr,
850 .\" NB: and the implementation of Var_SetWithFlags.
851 .\" NB: Last synced on 2023-01-01.
853 The list of all targets encountered in the makefiles.
854 If evaluated during makefile parsing,
855 lists only those targets encountered thus far.
857 A path to the directory where
860 Refer to the description of
864 Is used in error handling, see
865 .Va MAKE_PRINT_VAR_ON_ERROR .
867 Is used in error handling, see
868 .Va MAKE_PRINT_VAR_ON_ERROR .
869 .It Va .ERROR_META_FILE
870 Is used in error handling in
873 .Va MAKE_PRINT_VAR_ON_ERROR .
875 Is used in error handling, see
876 .Va MAKE_PRINT_VAR_ON_ERROR .
877 .It Va .INCLUDEDFROMDIR
878 The directory of the file this makefile was included from.
879 .It Va .INCLUDEDFROMFILE
880 The filename of the file this makefile was included from.
881 .\" .INCLUDES is intentionally undocumented, as it is obsolete.
882 .\" .LIBS is intentionally undocumented, as it is obsolete.
884 The machine hardware name, see
887 The machine processor architecture name, see
898 The preferred variable to use is the environment variable
900 because it is more compatible with other make variants
901 and cannot be confused with the special target with the same name.
902 .It Va .MAKE.ALWAYS_PASS_JOB_QUEUE
905 whether to pass the descriptors of the job token queue
906 even if the target is not tagged with
910 for backwards compatability with
913 .\" '.MAKE.cmd_filtered' is intentionally undocumented,
914 .\" as it is an internal implementation detail.
915 .It Va .MAKE.DEPENDFILE
916 Names the makefile (default
918 from which generated dependencies are read.
919 .It Va .MAKE.DIE_QUIETLY
922 do not print error information at the end.
923 .It Va .MAKE.EXPAND_VARIABLES
924 A boolean that controls the default behavior of the
927 If true, variable values printed with
929 are fully expanded; if false, the raw variable contents (which may
930 include additional unexpanded variable references) are shown.
931 .It Va .MAKE.EXPORTED
932 The list of variables exported by
935 The top-level makefile that is currently read,
936 as given in the command line.
938 The environment variable
940 may contain anything that
944 Anything specified on
946 command line is appended to the
948 variable, which is then added to the environment for all programs that
952 The numeric group ID of the user running
955 .It Va .MAKE.JOB.PREFIX
960 the output for each target is prefixed with a token
961 .Dl --- Ar target Li ---
962 the first part of which can be controlled via
963 .Va .MAKE.JOB.PREFIX .
966 is empty, no token is printed.
970 .Ql ${.newline}---${.MAKE:T}[${.MAKE.PID}]
971 would produce tokens like
972 .Dl ---make[1234] Ar target Li ---
973 making it easier to track the degree of parallelism being achieved.
979 The recursion depth of
981 The top-level instance of
983 has level 0, and each child make has its parent level plus 1.
984 This allows tests like:
985 .Li .if ${.MAKE.LEVEL} == 0
986 to protect things which should only be evaluated in the top-level instance of
988 .It Va .MAKE.LEVEL.ENV
989 The name of the environment variable that stores the level of nested calls to
991 .It Va .MAKE.MAKEFILE_PREFERENCE
992 The ordered list of makefile names
999 .It Va .MAKE.MAKEFILES
1000 The list of makefiles read by
1002 which is useful for tracking dependencies.
1003 Each makefile is recorded only once, regardless of the number of times read.
1004 .It Va .MAKE.META.BAILIWICK
1007 mode, provides a list of prefixes which
1008 match the directories controlled by
1010 If a file that was generated outside of
1012 but within said bailiwick is missing,
1013 the current target is considered out-of-date.
1014 .It Va .MAKE.META.CMP_FILTER
1017 mode, it can (very rarely!) be useful to filter command
1018 lines before comparison.
1019 This variable can be set to a set of modifiers that are applied to
1020 each line of the old and new command that differ, if the filtered
1021 commands still differ, the target is considered out-of-date.
1022 .It Va .MAKE.META.CREATED
1025 mode, this variable contains a list of all the meta files
1027 If not empty, it can be used to trigger processing of
1028 .Va .MAKE.META.FILES .
1029 .It Va .MAKE.META.FILES
1032 mode, this variable contains a list of all the meta files
1033 used (updated or not).
1034 This list can be used to process the meta files to extract dependency
1036 .It Va .MAKE.META.IGNORE_FILTER
1037 Provides a list of variable modifiers to apply to each pathname.
1038 Ignore if the expansion is an empty string.
1039 .It Va .MAKE.META.IGNORE_PATHS
1040 Provides a list of path prefixes that should be ignored;
1041 because the contents are expected to change over time.
1042 The default list includes:
1043 .Sq Pa /dev /etc /proc /tmp /var/run /var/tmp
1044 .It Va .MAKE.META.IGNORE_PATTERNS
1045 Provides a list of patterns to match against pathnames.
1046 Ignore any that match.
1047 .It Va .MAKE.META.PREFIX
1048 Defines the message printed for each meta file updated in
1051 The default value is:
1052 .Dl Building ${.TARGET:H:tA}/${.TARGET:T}
1054 Processed after reading all makefiles.
1055 Affects the mode that
1058 It can contain these keywords:
1059 .Bl -tag -width indent
1073 mode, where meta files are created for each target
1074 to capture the command run, the output generated, and if
1076 is available, the system calls which are of interest to
1078 The captured output can be useful when diagnosing errors.
1079 .It Cm curdirOk= Ns Ar bf
1086 This can be overridden by setting
1088 to a value which represents true.
1089 .It Cm missing-meta= Ns Ar bf
1094 file makes the target out-of-date.
1095 .It Cm missing-filemon= Ns Ar bf
1098 is true, missing filemon data makes the target out-of-date.
1103 For debugging, it can be useful to include the environment
1110 mode, print a clue about the target being built.
1111 This is useful if the build is otherwise running silently.
1112 The message printed is the expanded value of
1113 .Va .MAKE.META.PREFIX .
1115 Some makefiles have commands which are simply not stable.
1116 This keyword causes them to be ignored for
1117 determining whether a target is out of date in
1122 .It Cm silent= Ns Ar bf
1125 is true, when a .meta file is created, mark the target
1127 .It Cm randomize-targets
1128 In both compat and parallel mode, do not make the targets in the usual order,
1129 but instead randomize their order.
1130 This mode can be used to detect undeclared dependencies between files.
1133 Used to create files in a separate directory, see
1135 .It Va MAKE_OBJDIR_CHECK_WRITABLE
1136 Used to force a separate directory for the created files,
1137 even if that directory is not writable, see
1139 .It Va MAKEOBJDIRPREFIX
1140 Used to create files in a separate directory, see
1143 The name of the operating system, see
1146 .It Va .MAKEOVERRIDES
1147 This variable is used to record the names of variables assigned to
1148 on the command line, so that they may be exported as part of
1150 This behavior can be disabled by assigning an empty value to
1151 .Sq Va .MAKEOVERRIDES
1153 Extra variables can be exported from a makefile
1154 by appending their names to
1155 .Sq Va .MAKEOVERRIDES .
1157 is re-exported whenever
1158 .Sq Va .MAKEOVERRIDES
1160 .It Va .MAKE.PATH_FILEMON
1165 support, this is set to the path of the device node.
1166 This allows makefiles to test for this support.
1172 The parent process ID of
1175 .It Va MAKE_PRINT_VAR_ON_ERROR
1178 stops due to an error, it sets
1179 .Sq Va .ERROR_TARGET
1180 to the name of the target that failed,
1182 to the commands of the failed target,
1190 .Sq Va .ERROR_META_FILE
1191 to the path of the meta file (if any) describing the failed target.
1192 It then prints its name and the value of
1194 as well as the value of any variables named in
1195 .Sq Va MAKE_PRINT_VAR_ON_ERROR .
1196 .It Va .MAKE.SAVE_DOLLARS
1199 are preserved when doing
1202 The default is false, for backwards compatibility.
1203 Set to true for compatability with other makes.
1208 per normal evaluation rules.
1209 .It Va .MAKE.TARGET_LOCAL_VARIABLES
1212 apparent variable assignments in dependency lines are
1213 treated as normal sources.
1215 The numeric ID of the user running
1218 .\" 'MAKE_VERSION' is intentionally undocumented
1219 .\" since it is only defined in the bmake distribution,
1220 .\" but not in NetBSD's native make.
1221 .\" '.meta.%d.lcwd' is intentionally undocumented
1222 .\" since it is an internal implementation detail.
1223 .\" '.meta.%d.ldir' is intentionally undocumented
1224 .\" since it is an internal implementation detail.
1225 .\" 'MFLAGS' is intentionally undocumented
1226 .\" since it is obsolete.
1228 This variable is simply assigned a newline character as its value.
1230 This allows expansions using the
1232 modifier to put a newline between
1233 iterations of the loop rather than a space.
1234 For example, in case of an error,
1236 prints the variable names and their values using:
1237 .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1239 A path to the directory where the targets are built.
1240 Its value is determined by trying to
1242 to the following directories in order and using the first match:
1245 .Cm ${MAKEOBJDIRPREFIX} Ns Cm ${.CURDIR}
1248 .Sq Ev MAKEOBJDIRPREFIX
1249 is set in the environment or on the command line.)
1255 is set in the environment or on the command line.)
1257 .Cm ${.CURDIR} Ns Pa /obj. Ns Cm ${MACHINE}
1259 .Cm ${.CURDIR} Ns Pa /obj
1261 .Pa /usr/obj/ Ns Cm ${.CURDIR}
1266 Variable expansion is performed on the value before it is used,
1267 so expressions such as
1268 .Cm ${.CURDIR:S,^/usr/src,/var/obj,}
1270 This is especially useful with
1274 may be modified in the makefile via the special target
1278 changes to the specified directory if it exists, and sets
1282 to that directory before executing any targets.
1284 Except in the case of an explicit
1288 checks that the specified directory is writable and ignores it if not.
1289 This check can be skipped by setting the environment variable
1290 .Sq Ev MAKE_OBJDIR_CHECK_WRITABLE
1294 The directory name of the current makefile being parsed.
1296 The basename of the current makefile being parsed.
1299 are both set only while the makefiles are being parsed.
1300 To retain their current values,
1301 assign them to a variable using assignment with expansion
1304 The space-separated list of directories that
1307 To update this search list, use the special target
1309 rather than modifying the variable directly.
1311 Is set in POSIX mode, see the special
1314 .\" XXX: There is no make variable named 'PWD',
1315 .\" XXX: make only reads and writes the environment variable 'PWD'.
1317 Alternate path to the current directory.
1321 to the canonical path given by
1323 However, if the environment variable
1325 is set and gives a path to the current directory,
1332 This behavior is disabled if
1333 .Sq Ev MAKEOBJDIRPREFIX
1336 contains a variable transform.
1338 is set to the value of
1340 for all programs which
1344 The pathname of the shell used to run target scripts.
1347 The list of known suffixes.
1350 The space-separated list of directories that
1352 searches for makefiles, referred to as the system include path.
1353 To update this search list, use the special target
1355 rather than modifying the variable which is read-only.
1357 The list of targets explicitly specified on the command line, if any.
1361 list of directories that
1364 This variable is supported for compatibility with old make programs only, use
1368 .Ss Variable modifiers
1369 The general format of a variable expansion is:
1372 .D1 Ic \&${ Ar variable\| Oo Ic \&: Ar modifier\| Oo Ic \&: No ... Oc Oc Ic \&}
1375 Each modifier begins with a colon.
1376 To escape a colon, precede it with a backslash
1379 A list of indirect modifiers can be specified via a variable, as follows:
1381 .Bd -literal -offset indent
1382 .Ar modifier_variable\^ Li \&= Ar modifier Ns Oo Ic \&: Ns No ... Oc
1385 .Ic \&${ Ar variable Ic \&:${ Ar modifier_variable Ic \&} Oo Ic \&: No ... Oc Ic \&}
1389 In this case, the first modifier in the
1390 .Ar modifier_variable
1391 does not start with a colon,
1392 since that colon already occurs in the referencing variable.
1393 If any of the modifiers in the
1394 .Ar modifier_variable
1395 contains a dollar sign
1397 these must be doubled to avoid early expansion.
1399 Some modifiers interpret the expression value as a single string,
1400 others treat the expression value as a whitespace-separated list of words.
1401 When splitting a string into words,
1402 whitespace can be escaped using double quotes, single quotes and backslashes,
1404 The quotes and backslashes are retained in the words.
1406 The supported modifiers are:
1409 Replaces each word with its suffix.
1411 Replaces each word with its dirname.
1412 .It Cm \&:M\| Ns Ar pattern
1413 Selects only those words that match
1415 The standard shell wildcard characters
1422 The wildcard characters may be escaped with a backslash
1424 As a consequence of the way values are split into words, matched,
1425 and then joined, the construct
1427 removes all leading and trailing whitespace
1428 and normalizes the inter-word spacing to a single space.
1429 .It Cm \&:N\| Ns Ar pattern
1430 This is the opposite of
1432 selecting all words which do
1437 Orders the words lexicographically.
1439 Orders the words numerically.
1440 A number followed by one of
1445 is multiplied by the appropriate factor, which is 1024 for
1451 Both upper- and lower-case letters are accepted.
1453 Orders the words in reverse lexicographical order.
1455 Orders the words in reverse numerical order.
1458 The results are different each time you are referring to the
1459 modified variable; use the assignment with expansion
1461 to prevent such behavior.
1463 .Bd -literal -offset indent
1464 LIST= uno due tre quattro
1465 RANDOM_LIST= ${LIST:Ox}
1466 STATIC_RANDOM_LIST:= ${LIST:Ox}
1469 @echo "${RANDOM_LIST}"
1470 @echo "${RANDOM_LIST}"
1471 @echo "${STATIC_RANDOM_LIST}"
1472 @echo "${STATIC_RANDOM_LIST}"
1474 may produce output similar to:
1475 .Bd -literal -offset indent
1482 Quotes every shell meta-character in the value, so that it can be passed
1483 safely to the shell.
1485 Quotes every shell meta-character in the value, and also doubles
1487 characters so that it can be passed
1488 safely through recursive invocations of
1490 This is equivalent to
1491 .Sq Cm \&:S/\e\&$/&&/g:Q .
1493 Replaces each word with everything but its suffix.
1494 .It Cm \&:range Ns Oo Cm = Ns Ar count Oc
1495 The value is an integer sequence representing the words of the original
1496 value, or the supplied
1498 .It Cm \&:gmtime Ns Oo Cm = Ns Ar timestamp Oc
1499 The value is interpreted as a format string for
1503 producing the formatted timestamp.
1506 value is not provided or is 0, the current time is used.
1508 Computes a 32-bit hash of the value and encodes it as 8 hex digits.
1509 .It Cm \&:localtime Ns Oo Cm = Ns Ar timestamp Oc
1510 The value is interpreted as a format string for
1514 producing the formatted timestamp.
1517 value is not provided or is 0, the current time is used.
1519 Attempts to convert the value to an absolute path using
1521 If that fails, the value is unchanged.
1523 Converts the value to lower-case letters.
1524 .It Cm \&:ts Ns Ar c
1525 When joining the words after a modifier that treats the value as words,
1526 the words are normally separated by a space.
1527 This modifier changes the separator to the character
1531 is omitted, no separator is used.
1532 The common escapes (including octal numeric codes) work as expected.
1534 Converts the value to upper-case letters.
1536 Causes subsequent modifiers to treat the value as a single word
1537 (possibly containing embedded whitespace).
1541 Causes the value to be treated as a list of words.
1545 .It Cm \&:S\| No \&/ Ar old_string\| No \&/ Ar new_string\| No \&/ Op Cm 1gW
1547 Modifies the first occurrence of
1549 in each word of the value, replacing it with
1553 is appended to the last delimiter of the pattern,
1554 all occurrences in each word are replaced.
1557 is appended to the last delimiter of the pattern,
1558 only the first occurrence is affected.
1561 is appended to the last delimiter of the pattern,
1562 the value is treated as a single word.
1568 is anchored at the beginning of each word.
1571 ends with a dollar sign
1573 it is anchored at the end of each word.
1580 (without the anchoring
1584 Any character may be used as the delimiter for the parts of the modifier
1586 The anchoring, ampersand and delimiter characters can be escaped with a
1594 may contain nested expressions.
1595 To prevent a dollar sign from starting a nested expression,
1596 escape it with a backslash.
1598 .It Cm \&:C\| No \&/ Ar pattern\| No \&/ Ar replacement\| No \&/ Op Cm 1gW
1602 modifier works like the
1604 modifier except that the old and new strings, instead of being
1605 simple strings, are an extended regular expression
1612 Normally, the first occurrence of the pattern
1614 in each word of the value is substituted with
1618 modifier causes the substitution to apply to at most one word; the
1620 modifier causes the substitution to apply to as many instances of the
1623 as occur in the word or words it is found in; the
1625 modifier causes the value to be treated as a single word
1626 (possibly containing embedded whitespace).
1634 are subjected to variable expansion before being parsed as
1635 regular expressions.
1637 Replaces each word with its last path component (basename).
1639 Removes adjacent duplicate words (like
1642 .It Cm \&:\&?\| Ar true_string\| Cm \&: Ar false_string
1644 If the variable name (not its value), when parsed as a
1646 conditional expression, evaluates to true, return as its value the
1648 otherwise return the
1650 Since the variable name is used as the expression,
1651 \&:\&? must be the first modifier after the variable name
1652 .No itself Ns \^\(em\^ Ns
1653 which, of course, usually contains variable expansions.
1654 A common error is trying to use expressions like
1655 .Dl ${NUMBERS:M42:?match:no}
1656 which actually tests defined(NUMBERS).
1657 To determine if any words match
1659 you need to use something like:
1660 .Dl ${"${NUMBERS:M42}" != \&"\&":?match:no} .
1661 .It Cm :\| Ns Ar old_string\| Ns Cm = Ns Ar new_string
1665 It can only be the last modifier specified,
1672 is treated as a regular character, not as the end of the modifier.
1676 does not contain the pattern matching character
1678 and the word ends with
1681 that suffix is replaced with
1684 Otherwise, the first
1688 matches a possibly empty substring of arbitrary characters,
1689 and if the whole pattern is found in the word,
1690 the matching part is replaced with
1692 and the first occurrence of
1696 (if any) is replaced with the substring matched by the
1703 may contain nested expressions.
1704 To prevent a dollar sign from starting a nested expression,
1705 escape it with a backslash.
1707 .It Cm \&:@ Ar varname\| Cm @ Ar string\| Cm @
1709 This is the loop expansion mechanism from the OSF Development
1710 Environment (ODE) make.
1713 loops, expansion occurs at the time of reference.
1714 For each word in the value, assign the word to the variable named
1718 The ODE convention is that
1720 should start and end with a period, for example:
1721 .Dl ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
1723 However, a single-letter variable is often more readable:
1724 .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
1725 .It Cm \&:_ Ns Oo Cm = Ns Ar var Oc
1726 Saves the current variable value in
1730 for later reference.
1732 .Bd -literal -offset indent
1733 M_cmpv.units = 1 1000 1000000
1734 M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
1735 \\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
1737 .Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
1742 is used to save the result of the
1744 modifier which is later referenced using the index values from
1746 .It Cm \&:U\| Ns Ar newval
1747 If the variable is undefined,
1750 If the variable is defined, the existing value is returned.
1751 This is another ODE make feature.
1752 It is handy for setting per-target CFLAGS for instance:
1753 .Dl ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
1754 If a value is only required if the variable is undefined, use:
1755 .Dl ${VAR:D:Unewval}
1756 .It Cm \&:D\| Ns Ar newval
1757 If the variable is defined,
1761 The name of the variable is the value.
1763 The path of the node which has the same name as the variable is the value.
1764 If no such node exists or its path is null, the name of the variable is used.
1765 In order for this modifier to work, the name (node) must at least have
1766 appeared on the right-hand side of a dependency.
1768 .It Cm \&:\&! Ar cmd\| Cm \&!
1770 The output of running
1774 The value is run as a command, and the output becomes the new value.
1775 .It Cm \&::= Ns Ar str
1776 The variable is assigned the value
1779 This modifier and its variations are useful in obscure situations
1780 such as wanting to set a variable
1781 at a point where a target's shell commands are being parsed.
1782 These assignment modifiers always expand to nothing.
1786 helps avoid false matches with the
1790 modifier and since substitution always occurs, the
1792 form is vaguely appropriate.
1793 .It Cm \&::?= Ns Ar str
1796 but only if the variable does not already have a value.
1797 .It Cm \&::+= Ns Ar str
1801 .It Cm \&::!= Ns Ar cmd
1802 Assign the output of
1805 .It Cm \&:\&[ Ns Ar range Ns Cm \&]
1806 Selects one or more words from the value,
1807 or performs other operations related to the way in which the
1808 value is split into words.
1810 An empty value, or a value that consists entirely of white-space,
1811 is treated as a single word.
1812 For the purposes of the
1814 modifier, the words are indexed both forwards using positive integers
1815 (where index 1 represents the first word),
1816 and backwards using negative integers
1817 (where index \-1 represents the last word).
1821 is subjected to variable expansion, and the expanded result is
1822 then interpreted as follows:
1823 .Bl -tag -width index
1826 Selects a single word from the value.
1828 .It Ar start Ns Cm \&.. Ns Ar end
1829 Selects all words from
1836 selects all words from the second word to the last word.
1841 the words are output in reverse order.
1844 selects all the words from last to first.
1845 If the list is already ordered,
1846 this effectively reverses the list,
1847 but it is more efficient to use
1850 .Sq Cm \&:O:[-1..1] .
1853 Causes subsequent modifiers to treat the value as a single word
1854 (possibly containing embedded whitespace).
1855 Analogous to the effect of
1864 Causes subsequent modifiers to treat the value as a sequence of words
1865 delimited by whitespace.
1866 Analogous to the effect of
1871 Returns the number of words in the value.
1876 offers directives for including makefiles, conditionals and for loops.
1877 All these directives are identified by a line beginning with a single dot
1879 character, followed by the keyword of the directive, such as
1884 Files are included with either
1885 .Cm \&.include \&< Ns Ar file Ns Cm \&>
1887 .Cm \&.include \&\*q Ns Ar file Ns Cm \&\*q .
1888 Variables between the angle brackets or double quotes are expanded
1889 to form the file name.
1890 If angle brackets are used, the included makefile is expected to be in
1891 the system makefile directory.
1892 If double quotes are used, the including makefile's directory and any
1893 directories specified using the
1895 option are searched before the system makefile directory.
1897 For compatibility with other make variants,
1898 .Sq Cm include Ar file No ...
1899 (without leading dot)
1902 If the include statement is written as
1906 errors locating and/or opening include files are ignored.
1908 If the include statement is written as
1910 not only are errors locating and/or opening include files ignored,
1911 but stale dependencies within the included file are ignored just like in
1912 .Va .MAKE.DEPENDFILE .
1913 .Ss Exporting variables
1914 The directives for exporting and unexporting variables are:
1916 .It Ic .export Ar variable No ...
1917 Export the specified global variable.
1918 If no variable list is provided, all globals are exported
1919 except for internal variables (those that start with
1921 This is not affected by the
1923 flag, so should be used with caution.
1924 For compatibility with other make programs,
1925 .Cm export Ar variable\| Ns Cm \&= Ns Ar value
1926 (without leading dot) is also accepted.
1928 Appending a variable name to
1930 is equivalent to exporting a variable.
1931 .It Ic .export-env Ar variable No ...
1934 except that the variable is not appended to
1935 .Va .MAKE.EXPORTED .
1936 This allows exporting a value to the environment which is different from that
1940 .It Ic .export-literal Ar variable No ...
1943 except that variables in the value are not expanded.
1944 .It Ic .unexport Ar variable No ...
1947 The specified global
1950 .Va .MAKE.EXPORTED .
1951 If no variable list is provided, all globals are unexported,
1955 .It Ic .unexport-env
1956 Unexport all globals previously exported and
1957 clear the environment inherited from the parent.
1958 This operation causes a memory leak of the original environment,
1959 so should be used sparingly.
1962 being 0 would make sense.
1963 Also note that any variables which originated in the parent environment
1964 should be explicitly preserved if desired.
1966 .Bd -literal -offset indent
1967 .Li .if ${.MAKE.LEVEL} == 0
1974 Would result in an environment containing only
1976 which is the minimal useful environment.
1977 .\" TODO: Check the below sentence, environment variables don't start with '.'.
1980 is also pushed into the new environment.
1983 The directives for printing messages to the output are:
1985 .It Ic .info Ar message
1986 The message is printed along with the name of the makefile and line number.
1987 .It Ic .warning Ar message
1988 The message prefixed by
1990 is printed along with the name of the makefile and line number.
1991 .It Ic .error Ar message
1992 The message is printed along with the name of the makefile and line number,
1997 The directives for conditionals are:
1998 .ds maybenot Oo Ic \&! Oc Ns
2000 .It Ic .if \*[maybenot] Ar expression Op Ar operator expression No ...
2001 Test the value of an expression.
2002 .It Ic .ifdef \*[maybenot] Ar variable Op Ar operator variable No ...
2003 Test whether a variable is defined.
2004 .It Ic .ifndef \*[maybenot] Ar variable Op Ar operator variable No ...
2005 Test whether a variable is not defined.
2006 .It Ic .ifmake \*[maybenot] Ar target Op Ar operator target No ...
2007 Test the target being requested.
2008 .It Ic .ifnmake \*[maybenot] Ar target Op Ar operator target No ...
2009 Test the target being requested.
2011 Reverse the sense of the last conditional.
2012 .It Ic .elif \*[maybenot] Ar expression Op Ar operator expression No ...
2017 .It Ic .elifdef \*[maybenot] Ar variable Op Ar operator variable No ...
2022 .It Ic .elifndef \*[maybenot] Ar variable Op Ar operator variable No ...
2027 .It Ic .elifmake \*[maybenot] Ar target Op Ar operator target No ...
2032 .It Ic .elifnmake \*[maybenot] Ar target Op Ar operator target No ...
2038 End the body of the conditional.
2043 may be any one of the following:
2048 Logical AND; of higher precedence than
2053 only evaluates a conditional as far as is necessary to determine its value.
2054 Parentheses can be used to override the operator precedence.
2055 The boolean operator
2057 may be used to logically negate an entire conditional.
2058 It is of higher precedence than
2063 may be any of the following function call expressions:
2066 .It Ic defined Li \&( Ar varname Li \&)
2068 Evaluates to true if the variable
2072 .It Ic make Li \&( Ar target Li \&)
2074 Evaluates to true if the target was specified as part of
2076 command line or was declared the default target (either implicitly or
2079 before the line containing the conditional.
2081 .It Ic empty Li \&( Ar varname Oo Li : Ar modifiers Oc Li \&)
2083 Evaluates to true if the expansion of the variable,
2084 after applying the modifiers, results in an empty string.
2086 .It Ic exists Li \&( Ar pathname Li \&)
2088 Evaluates to true if the given pathname exists.
2089 If relative, the pathname is searched for on the system search path (see
2092 .It Ic target Li \&( Ar target Li \&)
2094 Evaluates to true if the target has been defined.
2096 .It Ic commands Li \&( Ar target Li \&)
2098 Evaluates to true if the target has been defined
2099 and has commands associated with it.
2103 may also be an arithmetic or string comparison.
2104 Variable expansion is performed on both sides of the comparison.
2105 If both sides are numeric and neither is enclosed in quotes,
2106 the comparison is done numerically, otherwise lexicographically.
2107 A string is interpreted as hexadecimal integer if it is preceded by
2109 otherwise it is a decimal floating-point number;
2110 octal numbers are not supported.
2112 All comparisons may use the operators
2116 Numeric comparisons may also use the operators
2123 If the comparison has neither a comparison operator nor a right side,
2124 the expression evaluates to true if it is nonempty
2125 and its numeric value (if any) is not zero.
2129 is evaluating one of these conditional expressions, and it encounters
2130 a (whitespace separated) word it doesn't recognize, either the
2134 function is applied to it, depending on the form of the conditional.
2142 function is applied.
2143 Similarly, if the form is
2149 function is applied.
2151 If the conditional evaluates to true,
2152 parsing of the makefile continues as before.
2153 If it evaluates to false, the following lines are skipped.
2154 In both cases, this continues until the corresponding
2160 For loops are typically used to apply a set of rules to a list of files.
2161 The syntax of a for loop is:
2163 .Bl -tag -compact -width Ds
2164 .It Ic \&.for Ar variable Oo Ar variable No ... Oc Ic in Ar expression
2165 .It Aq Ar make-lines
2171 is expanded and then split into words.
2172 On each iteration of the loop, one word is taken and assigned to each
2176 are substituted into the
2178 inside the body of the for loop.
2179 The number of words must come out even; that is, if there are three
2180 iteration variables, the number of words provided must be a multiple
2185 is encountered within a
2187 loop, it causes early termination of the loop, otherwise a parse error.
2188 .\" TODO: Describe limitations with defined/empty.
2189 .Ss Other directives
2191 .It Ic .undef Ar variable No ...
2192 Un-define the specified global variables.
2193 Only global variables can be un-defined.
2196 Comments begin with a hash
2198 character, anywhere but in a shell
2199 command line, and continue to the end of an unescaped new line.
2200 .Sh SPECIAL SOURCES (ATTRIBUTES)
2201 .Bl -tag -width .IGNOREx
2203 Target is never out of date, but always execute commands anyway.
2205 Ignore any errors from the commands associated with this target, exactly
2206 as if they all were preceded by a dash
2208 .\" .It Ic .INVISIBLE
2213 Mark all sources of this target as being up to date.
2215 Execute the commands associated with this target even if the
2219 options were specified.
2220 Normally used to mark recursive
2223 Create a meta file for the target, even if it is flagged as
2228 Usage in conjunction with
2230 is the most likely case.
2233 mode, the target is out-of-date if the meta file is missing.
2235 Do not create a meta file for the target.
2236 Meta files are also not created for
2243 Ignore differences in commands when deciding if target is out of date.
2244 This is useful if the command contains a value which always changes.
2245 If the number of commands change, though,
2246 the target is still considered out of date.
2247 The same effect applies to any command line that uses the variable
2249 which can be used for that purpose even when not otherwise needed or desired:
2250 .Bd -literal -offset indent
2252 skip-compare-for-some:
2253 @echo this is compared
2254 @echo this is not ${.OODATE:M.NOMETA_CMP}
2255 @echo this is also compared
2260 pattern suppresses any expansion of the unwanted variable.
2262 Do not search for the target in the directories specified by
2267 selects the first target it encounters as the default target to be built
2268 if no target was specified.
2269 This source prevents this target from being selected.
2271 If a target is marked with this attribute and
2273 can't figure out how to create it, it ignores this fact and assumes
2274 the file isn't needed or already exists.
2276 The target does not correspond to an actual file;
2277 it is always considered to be out of date,
2278 and is not created with the
2281 Suffix-transformation rules are not applied to
2287 is interrupted, it normally removes any partially made targets.
2288 This source prevents the target from being removed.
2293 Do not echo any of the commands associated with this target, exactly
2294 as if they all were preceded by an at sign
2297 Turn the target into
2300 When the target is used as a source for another target, the other target
2301 acquires the commands, sources, and attributes (except for
2305 If the target already has commands, the
2307 target's commands are appended
2312 but instead of appending, prepend the
2314 target commands to the target.
2318 appears in a dependency line, the sources that precede it are
2319 made before the sources that succeed it in the line.
2320 Since the dependents of files are not made until the file itself
2321 could be made, this also stops the dependents being built unless they
2322 are needed for another branch of the dependency tree.
2335 the output is always
2341 The ordering imposed by
2343 is only relevant for parallel makes.
2346 Special targets may not be included with other targets, i.e. they must be
2347 the only target specified.
2348 .Bl -tag -width .BEGINx
2350 Any command lines attached to this target are executed before anything
2355 rule for any target (that was used only as a source) that
2357 can't figure out any other way to create.
2358 Only the shell script is used.
2361 variable of a target that inherits
2363 commands is set to the target's own name.
2364 .It Ic .DELETE_ON_ERROR
2365 If this target is present in the makefile, it globally causes make to
2366 delete targets whose commands fail.
2367 (By default, only targets whose commands are interrupted during
2368 execution are deleted.
2369 This is the historical behavior.)
2370 This setting can be used to help prevent half-finished or malformed
2371 targets from being left around and corrupting future rebuilds.
2373 Any command lines attached to this target are executed after everything
2374 else is done successfully.
2376 Any command lines attached to this target are executed when another target fails.
2379 variable is set to the target that failed.
2381 .Va MAKE_PRINT_VAR_ON_ERROR .
2383 Mark each of the sources with the
2386 If no sources are specified, this is the equivalent of specifying the
2392 is interrupted, the commands for this target are executed.
2394 If no target is specified when
2396 is invoked, this target is built.
2398 This target provides a way to specify flags for
2400 at the time when the makefiles are read.
2401 The flags are as if typed to the shell, though the
2405 .\" XXX: NOT YET!!!!
2406 .\" .It Ic .NOTPARALLEL
2407 .\" The named targets are executed in non parallel mode.
2408 .\" If no targets are
2409 .\" specified, all targets are executed in non parallel mode.
2413 attribute to any specified sources.
2415 Disable parallel mode.
2419 for compatibility with other pmake variants.
2421 clear the read-only attribute from the global variables specified as sources.
2423 The source is a new value for
2427 changes the current working directory to it and updates the value of
2430 In parallel mode, the named targets are made in sequence.
2431 This ordering does not add targets to the list of targets to be made.
2433 Since the dependents of a target do not get built until the target itself
2434 could be built, unless
2436 is built by another part of the dependency graph,
2437 the following is a dependency loop:
2443 .\" XXX: NOT YET!!!!
2444 .\" .It Ic .PARALLEL
2445 .\" The named targets are executed in parallel mode.
2446 .\" If no targets are
2447 .\" specified, all targets are executed in parallel mode.
2449 The sources are directories which are to be searched for files not
2450 found in the current directory.
2451 If no sources are specified,
2452 any previously specified directories are removed from the search path.
2453 If the source is the special
2455 target, the current working directory is searched last.
2456 .It Ic .PATH. Ns Ar suffix
2459 but applies only to files with a particular suffix.
2460 The suffix must have been previously declared with
2465 attribute to any specified sources.
2467 If this is the first non-comment line in the main makefile,
2474 is included if it exists,
2475 to provide POSIX-compatible default rules.
2482 contributes to the default rules.
2486 attribute to any specified sources.
2487 If no sources are specified, the
2489 attribute is applied to every target in the file.
2491 set the read-only attribute on the global variables specified as sources.
2495 uses to execute commands in jobs mode.
2496 The sources are a set of
2497 .Ar field\| Ns Cm \&= Ns Ar value
2499 .Bl -tag -width ".Li hasErrCtls"
2501 This is the minimal specification, used to select one of the built-in
2508 Specifies the absolute path to the shell.
2510 Indicates whether the shell supports exit on error.
2512 The command to turn on error checking.
2514 The command to disable error checking.
2516 The command to turn on echoing of commands executed.
2518 The command to turn off echoing of commands executed.
2520 The output to filter after issuing the
2523 It is typically identical to
2526 The flag to pass the shell to enable error checking.
2528 The flag to pass the shell to enable command echoing.
2530 The string literal to pass the shell that results in a single newline
2531 character when used outside of any quoting characters.
2535 \&.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \e
2536 check="set \-e" ignore="set +e" \e
2537 echo="set \-v" quiet="set +v" filter="set +v" \e
2538 echoFlag=v errFlag=e newline="'\en'"
2543 attribute to any specified sources.
2544 If no sources are specified, the
2546 attribute is applied to every
2547 command in the file.
2549 This target gets run when a dependency file contains stale entries, having
2551 set to the name of that dependency file.
2553 Each source specifies a suffix to
2555 If no sources are specified, any previously specified suffixes are deleted.
2556 It allows the creation of suffix-transformation rules.
2562 cc \-o ${.TARGET} \-c ${.IMPSRC}
2565 The sources are directories which are to be added to the system
2568 searches for makefiles.
2569 If no sources are specified,
2570 any previously specified directories are removed from the system
2575 uses the following environment variables, if they exist:
2581 .Ev MAKEOBJDIRPREFIX ,
2587 .Ev MAKEOBJDIRPREFIX
2590 may only be set in the environment or on the command line to
2592 and not as makefile variables;
2593 see the description of
2597 .Bl -tag -width /usr/share/mk -compact
2599 list of dependencies
2601 first default makefile if no makefile is specified on the command line
2603 second default makefile if no makefile is specified on the command line
2607 system makefile directory
2610 The basic make syntax is compatible between different make variants;
2611 however the special variables, variable modifiers and conditionals are not.
2613 An incomplete list of changes in older versions of
2616 The way that .for loop variables are substituted changed after
2618 so that they still appear to be variable expansions.
2619 In particular this stops them being treated as syntax, and removes some
2620 obscure problems using them in .if statements.
2622 The way that parallel makes are scheduled changed in
2624 so that .ORDER and .WAIT apply recursively to the dependent nodes.
2625 The algorithms used may change again in the future.
2626 .Ss Other make dialects
2627 Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not
2628 support most of the features of
2630 as described in this manual.
2632 .Bl -bullet -offset indent
2638 declarations and most functionality pertaining to parallelization.
2639 (GNU make supports parallelization but lacks the features needed to
2640 control it effectively.)
2642 Directives, including for loops and conditionals and most of the
2643 forms of include files.
2644 (GNU make has its own incompatible and less powerful syntax for
2646 .\" The "less powerful" above means that GNU make does not have the
2647 .\" make(target), target(target) and commands(target) functions.
2649 All built-in variables that begin with a dot.
2651 Most of the special sources and targets that begin with a dot,
2652 with the notable exception of
2658 Variable modifiers, except for the
2660 string substitution, which does not portably support globbing with
2662 and historically only works on declared suffixes.
2666 variable even in its short form; most makes support this functionality
2667 but its name varies.
2670 Some features are somewhat more portable, such as assignment with
2677 functionality is based on an older feature
2679 found in GNU make and many versions of SVR4 make; however,
2680 historically its behavior is too ill-defined (and too buggy) to rely
2687 variables are more or less universally portable, as is the
2690 Basic use of suffix rules (for files only in the current directory,
2691 not trying to chain transformations together, etc.) is also reasonably
2695 .Xr style.Makefile 5
2703 implementation is based on Adam de Boor's pmake program,
2704 which was written for Sprite at Berkeley.
2705 It was designed to be a parallel distributed make running jobs on different
2706 machines using a daemon called
2709 Historically the target/dependency
2711 has been used to FoRCe rebuilding (since the target/dependency
2712 does not exist ... unless someone creates an
2718 syntax is difficult to parse.
2719 For instance, finding the end of a variable's use should involve scanning
2720 each of the modifiers, using the correct terminator for each field.
2723 just counts {} and () in order to find the end of a variable expansion.
2725 There is no way of escaping a space character in a filename.