aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2024-03-14 04:54:47 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2024-03-14 04:56:57 +0000
commitc59c3bf34db360695f07735bebc76a768cac5afc (patch)
tree3413cf2c3efcfaecf20301f1309a875c732c3757
parentab8f59ceaf7028d4e420820deeac180b4f743524 (diff)
parent368b06ce6b0135d6de13f7265f6dcbaeb791b3bb (diff)
downloadsrc-c59c3bf34db360695f07735bebc76a768cac5afc.tar.gz
src-c59c3bf34db360695f07735bebc76a768cac5afc.zip
Merge bmake-20240309
Merge commit '368b06ce6b0135d6de13f7265f6dcbaeb791b3bb'
-rw-r--r--contrib/bmake/ChangeLog57
-rw-r--r--contrib/bmake/Makefile7
-rw-r--r--contrib/bmake/VERSION2
-rw-r--r--contrib/bmake/arch.c8
-rw-r--r--contrib/bmake/bmake.122
-rw-r--r--contrib/bmake/bmake.cat12564
-rwxr-xr-xcontrib/bmake/boot-strap17
-rw-r--r--contrib/bmake/compat.c8
-rw-r--r--contrib/bmake/cond.c66
-rw-r--r--contrib/bmake/config.h.in3
-rwxr-xr-xcontrib/bmake/configure24
-rw-r--r--contrib/bmake/configure.in5
-rw-r--r--contrib/bmake/for.c6
-rwxr-xr-xcontrib/bmake/import.sh2
-rwxr-xr-xcontrib/bmake/install-sh4
-rw-r--r--contrib/bmake/job.c8
-rw-r--r--contrib/bmake/main.c39
-rw-r--r--contrib/bmake/make-conf.h50
-rw-r--r--contrib/bmake/make.122
-rw-r--r--contrib/bmake/make.h5
-rw-r--r--contrib/bmake/mk/ChangeLog80
-rw-r--r--contrib/bmake/mk/FILES2
-rw-r--r--contrib/bmake/mk/auto.dep.mk6
-rw-r--r--contrib/bmake/mk/auto.obj.mk4
-rw-r--r--contrib/bmake/mk/autoconf.mk21
-rw-r--r--contrib/bmake/mk/autodep.mk91
-rw-r--r--contrib/bmake/mk/cc-wrap.mk4
-rw-r--r--contrib/bmake/mk/ccm.dep.mk60
-rw-r--r--contrib/bmake/mk/compiler.mk6
-rw-r--r--contrib/bmake/mk/cython.mk4
-rw-r--r--contrib/bmake/mk/dep.mk19
-rw-r--r--contrib/bmake/mk/dirdeps-cache-update.mk4
-rw-r--r--contrib/bmake/mk/dirdeps-options.mk4
-rw-r--r--contrib/bmake/mk/dirdeps-targets.mk7
-rw-r--r--contrib/bmake/mk/doc.mk9
-rw-r--r--contrib/bmake/mk/dpadd.mk6
-rw-r--r--contrib/bmake/mk/files.mk4
-rw-r--r--contrib/bmake/mk/host-target.mk16
-rw-r--r--contrib/bmake/mk/inc.mk4
-rw-r--r--contrib/bmake/mk/init.mk29
-rwxr-xr-xcontrib/bmake/mk/install-mk4
-rw-r--r--contrib/bmake/mk/install-new.mk4
-rwxr-xr-xcontrib/bmake/mk/install-sh4
-rw-r--r--contrib/bmake/mk/java.mk3
-rw-r--r--contrib/bmake/mk/jobs.mk4
-rw-r--r--contrib/bmake/mk/ldorder.mk4
-rw-r--r--contrib/bmake/mk/lib.mk28
-rw-r--r--contrib/bmake/mk/libnames.mk4
-rw-r--r--contrib/bmake/mk/libs.mk4
-rw-r--r--contrib/bmake/mk/links.mk4
-rw-r--r--contrib/bmake/mk/man.mk22
-rw-r--r--contrib/bmake/mk/manifest.mk4
-rw-r--r--contrib/bmake/mk/meta.autodep.mk14
-rw-r--r--contrib/bmake/mk/meta.stage.mk6
-rw-r--r--contrib/bmake/mk/meta.subdir.mk4
-rw-r--r--contrib/bmake/mk/meta.sys.mk12
-rwxr-xr-xcontrib/bmake/mk/meta2deps.py13
-rwxr-xr-xcontrib/bmake/mk/meta2deps.sh4
-rw-r--r--contrib/bmake/mk/mkopt.sh4
-rwxr-xr-xcontrib/bmake/mk/newlog.sh4
-rw-r--r--contrib/bmake/mk/obj.mk11
-rw-r--r--contrib/bmake/mk/options.mk4
-rw-r--r--contrib/bmake/mk/own.mk30
-rw-r--r--contrib/bmake/mk/posix.mk4
-rw-r--r--contrib/bmake/mk/prlist.mk4
-rw-r--r--contrib/bmake/mk/prog.mk46
-rw-r--r--contrib/bmake/mk/progs.mk4
-rw-r--r--contrib/bmake/mk/rst2htm.mk4
-rw-r--r--contrib/bmake/mk/scripts.mk4
-rw-r--r--contrib/bmake/mk/srctop.mk4
-rwxr-xr-xcontrib/bmake/mk/stage-install.sh4
-rw-r--r--contrib/bmake/mk/subdir.mk131
-rw-r--r--contrib/bmake/mk/suffixes.mk195
-rw-r--r--contrib/bmake/mk/sys.clean-env.mk4
-rw-r--r--contrib/bmake/mk/sys.debug.mk4
-rw-r--r--contrib/bmake/mk/sys.dependfile.mk4
-rw-r--r--contrib/bmake/mk/sys.dirdeps.mk9
-rw-r--r--contrib/bmake/mk/sys.mk19
-rw-r--r--contrib/bmake/mk/sys.vars.mk4
-rw-r--r--contrib/bmake/mk/sys/Generic.mk182
-rw-r--r--contrib/bmake/mk/target-flags.mk4
-rw-r--r--contrib/bmake/mk/warnings.mk4
-rw-r--r--contrib/bmake/mk/whats.mk4
-rw-r--r--contrib/bmake/mk/yacc.mk4
-rw-r--r--contrib/bmake/parse.c22
-rw-r--r--contrib/bmake/suff.c8
-rw-r--r--contrib/bmake/targ.c5
-rw-r--r--contrib/bmake/unit-tests/Makefile11
-rw-r--r--contrib/bmake/unit-tests/var-scope-local.exp14
-rw-r--r--contrib/bmake/unit-tests/var-scope-local.mk19
-rw-r--r--contrib/bmake/unit-tests/varmod-indirect.mk28
-rw-r--r--contrib/bmake/unit-tests/varmod.exp10
-rw-r--r--contrib/bmake/unit-tests/varmod.mk5
-rw-r--r--contrib/bmake/var.c75
94 files changed, 1938 insertions, 2395 deletions
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index 4bd41562fb30..fc1da62fbe54 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,60 @@
+2024-03-10 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * boot-strap: tests can take a long time; use a cookie to
+ skip them if bmake has not been updated since tests last
+ ran successfully.
+
+ * Makefile: Cygwin handles MANTARGET man
+
+ * unit-tests/Makefile: set BROKEN_TESTS for Cygwin
+
+2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION (_MAKE_VERSION): 20240309
+ Merge with NetBSD make, pick up
+ o set .ERROR_EXIT to the exit status of .ERROR_TARGET
+ this allows a .ERROR target to ignore the case of
+ .ERROR_EXIT==6 which just means that the build actually
+ failed somewhere else.
+
+2024-03-04 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION (_MAKE_VERSION): 20240303
+
+ * var.c: on IRIX we need both inttypes.h and stdint.h
+
+2024-03-01 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION (_MAKE_VERSION): 20240301
+ Merge with NetBSD make, pick up
+ o export variables with value from target scope
+ when appropriate.
+
+2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION (_MAKE_VERSION): 20240212
+ Merge with NetBSD make, pick up
+ o remove unneeded conditional-compilation toggles
+ INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
+ GMAKEEXPORT NO_REGEX and SUNSHCMD
+
+ * configure.in: add check for regex.h
+
+ * var.c: replace use of NO_REGEX with HAVE_REGEX_H
+
+2024-02-04 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION (_MAKE_VERSION): 20240204
+ Merge with NetBSD make, pick up
+ o var.c: fix some lint (-dL) mode parsing issues
+
+2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION: (_MAKE_VERSION): 20240202
+ Merge with NetBSD make, pick up
+ o make.1: note that arg to :D and :U can be empty
+ o var.c: $$ is not a parse error when .MAKE.SAVE_DOLLARS=no
+
2024-01-08 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240108
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index 22e92b4da9ac..3332dcdeaf2d 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.125 2023/05/17 00:15:46 sjg Exp $
+# $Id: Makefile,v 1.126 2024/03/10 17:46:44 sjg Exp $
PROG= bmake
@@ -90,9 +90,8 @@ OS := ${.MAKE.OS:U${uname -s:L:sh}}
# are we 4.4BSD ?
isBSD44:=${BSD44_LIST:M${OS}}
-.if ${isBSD44} == "" && ${OS:NDarwin:NLinux} != ""
-MANTARGET= cat
-INSTALL?=${srcdir}/install-sh
+.if ${isBSD44} == "" && ${OS:NCYGWIN*:NDarwin:NLinux} != ""
+MANTARGET?= cat
.if ${MACHINE} == "sun386"
# even I don't have one of these anymore :-)
CFLAGS+= -DPORTAR
diff --git a/contrib/bmake/VERSION b/contrib/bmake/VERSION
index ca636f3ab1e2..5d6ca326700a 100644
--- a/contrib/bmake/VERSION
+++ b/contrib/bmake/VERSION
@@ -1,2 +1,2 @@
# keep this compatible with sh and make
-_MAKE_VERSION=20240108
+_MAKE_VERSION=20240309
diff --git a/contrib/bmake/arch.c b/contrib/bmake/arch.c
index b90452149c99..caec2e148690 100644
--- a/contrib/bmake/arch.c
+++ b/contrib/bmake/arch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.214 2023/11/19 22:50:11 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.215 2024/02/07 06:43:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -147,7 +147,7 @@ struct ar_hdr {
#include "dir.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: arch.c,v 1.214 2023/11/19 22:50:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.215 2024/02/07 06:43:02 rillig Exp $");
typedef struct List ArchList;
typedef struct ListNode ArchListNode;
@@ -1026,11 +1026,7 @@ Arch_FindLib(GNode *gn, SearchPath *path)
gn->path = Dir_FindFile(libName, path);
free(libName);
-#ifdef LIBRARIES
Var_Set(gn, TARGET, gn->name);
-#else
- Var_Set(gn, TARGET, GNode_Path(gn));
-#endif
}
/* ARGSUSED */
diff --git a/contrib/bmake/bmake.1 b/contrib/bmake/bmake.1
index 55d910b3b204..d4e937424286 100644
--- a/contrib/bmake/bmake.1
+++ b/contrib/bmake/bmake.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.372 2023/12/24 16:48:30 sjg Exp $
+.\" $NetBSD: make.1,v 1.375 2024/03/10 02:53:37 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd December 24, 2023
+.Dd March 9, 2024
.Dt BMAKE 1
.Os
.Sh NAME
@@ -879,6 +879,9 @@ Is used in error handling, see
.It Va .ERROR_CWD
Is used in error handling, see
.Va MAKE_PRINT_VAR_ON_ERROR .
+.It Va .ERROR_EXIT
+Is used in error handling, see
+.Va MAKE_PRINT_VAR_ON_ERROR .
.It Va .ERROR_META_FILE
Is used in error handling in
.Dq meta
@@ -1185,6 +1188,8 @@ When
stops due to an error, it sets
.Sq Va .ERROR_TARGET
to the name of the target that failed,
+.Sq Va .ERROR_EXIT
+to the exit status of the failed target,
.Sq Va .ERROR_CMD
to the commands of the failed target,
and in
@@ -1775,8 +1780,9 @@ modifier which is later referenced using the index values from
.Ql :range .
.It Cm \&:U\| Ns Ar newval
If the variable is undefined,
+the optional
.Ar newval
-is the value.
+(which may be empty) is the value.
If the variable is defined, the existing value is returned.
This is another ODE make feature.
It is handy for setting per-target CFLAGS for instance:
@@ -1786,7 +1792,7 @@ If a value is only required if the variable is undefined, use:
.It Cm \&:D\| Ns Ar newval
If the variable is defined,
.Ar newval
-is the value.
+(which may be empty) is the value.
.It Cm \&:L
The name of the variable is the value.
.It Cm \&:P
@@ -2405,11 +2411,9 @@ Any command lines attached to this target are executed after everything
else is done successfully.
.It Ic .ERROR
Any command lines attached to this target are executed when another target fails.
-The
-.Va .ERROR_TARGET
-variable is set to the target that failed.
-See also
-.Va MAKE_PRINT_VAR_ON_ERROR .
+See
+.Va MAKE_PRINT_VAR_ON_ERROR
+for the variables that will be set.
.It Ic .IGNORE
Mark each of the sources with the
.Ic .IGNORE
diff --git a/contrib/bmake/bmake.cat1 b/contrib/bmake/bmake.cat1
index 61138ea0f2b6..7c50930807f4 100644
--- a/contrib/bmake/bmake.cat1
+++ b/contrib/bmake/bmake.cat1
@@ -1,1762 +1,924 @@
-BMAKE(1) FreeBSD General Commands Manual BMAKE(1)
+is a program designed to simplify the maintenance of other pro-
+grams. Its input is a list of specifications as to the files
+upon which programs and other files depend. If no option is
+given, tries to open then in order to find the specifications.
+If the file exists, it is read, see This manual page is intended
+as a reference document only. For a more thorough description of
+and makefiles, please refer to (from 1993). prepends the con-
+tents of the environment variable to the command line arguments
+before parsing them. The options are as follows: Try to be back-
+wards compatible by executing a single shell per command and by
+making the sources of a dependency line in sequence. Change to
+before reading the makefiles or doing anything else. If multiple
+options are specified, each is interpreted relative to the previ-
+ous one: is equivalent to Define to be 1, in the global scope.
+Turn on debugging, and specify which portions of are to print de-
+bugging information. Unless the flags are preceded by they are
+added to the environment variable and are passed on to any child
+make processes. By default, debugging information is printed to
+standard error, but this can be changed using the debugging flag.
+The debugging output is always unbuffered; in addition, if debug-
+ging is enabled but debugging output is not directed to standard
+output, the standard output is line buffered. The available are:
+Print all possible debugging information; equivalent to specify-
+ing all of the debugging flags. Print debugging information
+about archive searching and caching. Print debugging information
+about the current working directory. Print debugging information
+about conditional evaluation. Print debugging information about
+directory searching and caching. Print debugging information
+about failed commands and targets. Specify where debugging out-
+put is written. This must be the last flag, because it consumes
+the remainder of the argument. If the character immediately af-
+ter the flag is the file is opened in append mode; otherwise the
+file is overwritten. If the file name is or debugging output is
+written to the standard output or standard error output respec-
+tively (and the option has no effect). Otherwise, the output is
+written to the named file. If the file name ends with the is re-
+placed by the pid. Print debugging information about loop evalu-
+ation. Print the input graph before making anything. Print the
+input graph after making everything, or before exiting on error.
+Print the input graph before exiting on error. Print debugging
+information about hash table operations. Print debugging infor-
+mation about running multiple shells. Turn on lint checks. This
+throws errors for variable assignments that do not parse cor-
+rectly, at the time of assignment, so the file and line number
+are available. Print commands in Makefiles regardless of whether
+or not they are prefixed by or other flags. Also known as behav-
+ior. Print debugging information about mode decisions about tar-
+gets. Print debugging information about making targets, includ-
+ing modification dates. Don't delete the temporary command
+scripts created when running commands. These temporary scripts
+are created in the directory referred to by the environment vari-
+able, or in if is unset or set to the empty string. The tempo-
+rary scripts are created by and have names of the form This can
+create many files in or so use with care. Print debugging infor-
+mation about makefile parsing. Print debugging information about
+suffix-transformation rules. Print debugging information about
+target list maintenance. Force the option to print raw values of
+variables, overriding the default behavior set via Print debug-
+ging information about variable assignment and expansion. Run
+shell commands with so the actual commands are printed as they
+are executed. Let environment variables override global vari-
+ables within makefiles. Specify a makefile to read instead of
+the default or If is standard input is read. Multiple makefiles
+may be specified, and are read in the order specified. Specify a
+directory in which to search for makefiles and included make-
+files. The system makefile directory (or directories, see the
+option) is automatically included as part of this list. Ignore
+non-zero exit of shell commands in the makefile. Equivalent to
+specifying before each command line in the makefile. This option
+should be specified by the user. When the option is in use in a
+recursive build, this option is passed by a make to child makes
+to allow all the make processes in the build to cooperate to
+avoid overloading the system. Specify the maximum number of jobs
+that may have running at any one time. If is a floating point
+number, or ends with then the value is multiplied by the number
+of CPUs reported online by The value of is saved in Turns compat-
+ibility mode off, unless the option is also specified. When com-
+patibility mode is off, all commands associated with a target are
+executed in a single shell invocation as opposed to the tradi-
+tional one shell invocation per line. This can break traditional
+scripts which change directories on each command invocation and
+then expect to start with a fresh environment on the next line.
+It is more efficient to correct the scripts rather than turn
+backwards compatibility on. A job token pool with tokens is used
+to control the total number of jobs running. Each instance of
+will wait for a token from the pool before running a new job.
+Continue processing after errors are encountered, but only on
+those targets that do not depend on the target whose creation
+caused the error. Specify a directory in which to search for and
+makefiles included via the include statement. The option can be
+used multiple times to form a search path. This path overrides
+the default system include path Furthermore, the system include
+path is appended to the search path used for include statements
+(see the option). The system include path can be referenced via
+the read-only variable If a directory name in the argument (or
+the environment variable) starts with the string searches for the
+specified file or directory named in the remaining part of the
+argument string. The search starts with the current directory
+and then works upward towards the root of the file system. If
+the search is successful, the resulting directory replaces the
+specification in the argument. This feature allows to easily
+search in the current source tree for customized files (e.g., by
+using as an argument). Display the commands that would have been
+executed, but do not actually execute them unless the target de-
+pends on the special source (see below) or the command is pre-
+fixed with Display the commands that would have been executed,
+but do not actually execute any of them; useful for debugging
+top-level makefiles without descending into subdirectories. Do
+not execute any commands, instead exit 0 if the specified targets
+are up to date, and 1 otherwise. Do not use the built-in rules
+specified in the system makefile. Stop processing if an error is
+encountered. This is the default behavior and the opposite of Do
+not echo any commands as they are executed. Equivalent to speci-
+fying before each command line in the makefile. When used with
+the flag, append a trace record to for each job started and com-
+pleted. Rather than re-building a target as specified in the
+makefile, create it or update its modification time to make it
+appear up-to-date. Print the value of Do not build any targets.
+Multiple instances of this option may be specified; the variables
+are printed one per line, with a blank line for each null or un-
+defined variable. The value printed is extracted from the global
+scope after all makefiles have been read. By default, the raw
+variable contents (which may include additional unexpanded vari-
+able references) are shown. If contains a it is not interpreted
+as a variable name but rather as an expression. Its value is ex-
+panded before printing. The value is also expanded before print-
+ing if is set to true and the option has not been used to over-
+ride it. Note that loop-local and target-local variables, as
+well as values taken temporarily by global variables during make-
+file processing, are not accessible via this option. The debug
+mode can be used to see these at the cost of generating substan-
+tial extraneous output. Like but all printed variables are al-
+ways expanded to their complete value. The last occurrence of or
+decides whether all variables are expanded or not. Treat any
+warnings during makefile parsing as errors. Print entering and
+leaving directory messages, pre and post processing. Don't ex-
+port variables passed on the command line to the environment in-
+dividually. Variables passed on the command line are still ex-
+ported via the environment variable. This option may be useful
+on systems which have a small limit on the size of command argu-
+ments. Set the value of the variable to Normally, all values
+passed on the command line are also exported to sub-makes in the
+environment. The flag disables this behavior. Variable assign-
+ments should follow options for POSIX compatibility but no order-
+ing is enforced. There are several different types of lines in a
+makefile: dependency specifications, shell commands, variable as-
+signments, include statements, conditional directives, for loops,
+other directives, and comments. Lines may be continued from one
+line to the next by ending them with a backslash The trailing
+newline character and initial whitespace on the following line
+are compressed into a single space. Dependency lines consist of
+one or more targets, an operator, and zero or more sources. This
+creates a relationship where the targets on the sources and are
+customarily created from them. A target is considered out of
+date if it does not exist, or if its modification time is less
+than that of any of its sources. An out-of-date target is re-
+created, but not until all sources have been examined and them-
+selves re-created as needed. Three operators may be used: Many
+dependency lines may name this target but only one may have at-
+tached shell commands. All sources named in all dependency lines
+are considered together, and if needed the attached shell com-
+mands are run to create or re-create the target. If is inter-
+rupted, the target is removed. The same, but the target is al-
+ways re-created whether or not it is out of date. Any dependency
+line may have attached shell commands, but each one is handled
+independently: its sources are considered and the attached shell
+commands are run if the target is out of date with respect to
+(only) those sources. Thus, different groups of the attached
+shell commands may be run depending on the circumstances. Fur-
+thermore, unlike for dependency lines with no sources, the at-
+tached shell commands are always run. Also unlike the target is
+not removed if is interrupted. All dependency lines mentioning a
+particular target must use the same operator. Targets and
+sources may contain the shell wildcard values and The values and
+may only be used as part of the final component of the target or
+source, and only match existing files. The value need not neces-
+sarily be used to describe existing files. Expansion is in di-
+rectory order, not alphabetically as done in the shell. Each
+target may have associated with it one or more lines of shell
+commands, normally used to create the target. Each of the lines
+in this script be preceded by a tab. (For historical reasons,
+spaces are not accepted.) While targets can occur in many depen-
+dency lines if desired, by default only one of these rules may be
+followed by a creation script. If the operator is used, however,
+all rules may include scripts, and the respective scripts are ex-
+ecuted in the order found. Each line is treated as a separate
+shell command, unless the end of line is escaped with a backslash
+in which case that line and the next are combined. If the first
+characters of the command are any combination of or the command
+is treated specially. causes the command not to be echoed before
+it is executed. causes the command to be executed even when is
+given. This is similar to the effect of the special source, ex-
+cept that the effect can be limited to a single line of a script.
+in compatibility mode causes any non-zero exit status of the com-
+mand line to be ignored. When is run in jobs mode with the en-
+tire script for the target is fed to a single instance of the
+shell. In compatibility (non-jobs) mode, each command is run in
+a separate process. If the command contains any shell meta char-
+acters it is passed to the shell; otherwise attempts direct exe-
+cution. If a line starts with and the shell has ErrCtl enabled,
+failure of the command line is ignored as in compatibility mode.
+Otherwise affects the entire job; the script stops at the first
+command line that fails, but the target is not deemed to have
+failed. Makefiles should be written so that the mode of opera-
+tion does not change their behavior. For example, any command
+which uses or without the intention of changing the directory for
+subsequent commands should be put in parentheses so it executes
+in a subshell. To force the use of a single shell, escape the
+line breaks so as to make the whole script one command. For ex-
+ample: avoid-chdir-side-effects: @echo "Building $@ in
+$$(pwd)" @(cd ${.CURDIR} && ${MAKE} $@) @echo
+"Back in $$(pwd)"
+
+ensure-one-shell-regardless-of-mode: @echo "Building $@
+in $$(pwd)"; \ (cd ${.CURDIR} && ${MAKE} $@); \
+ echo "Back in $$(pwd)" Since changes the current working
+directory to before executing any targets, each child process
+starts with that as its current working directory. Variables in
+make behave much like macros in the C preprocessor. Variable as-
+signments have the form where: is a single-word variable name,
+consisting, by tradition, of all upper-case letters, is one of
+the variable assignment operators described below, and is inter-
+preted according to the variable assignment operator. Whitespace
+around and is discarded. The five operators that assign values
+to variables are: Assign the value to the variable. Any previous
+value is overwritten. Append the value to the current value of
+the variable, separating them by a single space. Assign the
+value to the variable if it is not already defined. Expand the
+value, then assign it to the variable. References to undefined
+variables are expanded. This can cause problems when variable
+modifiers are used. Expand the value and pass it to the shell
+for execution, then assign the output from the child's standard
+output to the variable. Any newlines in the result are replaced
+with spaces. In most contexts where variables are expanded, ex-
+pands to a single dollar sign. In other contexts (most variable
+modifiers, string literals in conditions), expands to a single
+dollar sign. References to variables have the form or If the
+variable name consists of only a single character and the expres-
+sion contains no modifiers, the surrounding curly braces or
+parentheses are not required. This shorter form is not recom-
+mended. If the variable name contains a dollar, the name itself
+is expanded first. This allows almost arbitrary variable names,
+however names containing dollar, braces, parentheses or white-
+space are really best avoided. If the result of expanding a
+nested variable expression contains a dollar sign the result is
+subject to further expansion. Variable substitution occurs at
+four distinct times, depending on where the variable is being
+used. Variables in dependency lines are expanded as the line is
+read. Variables in conditionals are expanded individually, but
+only as far as necessary to determine the result of the condi-
+tional. Variables in shell commands are expanded when the shell
+command is executed. loop index variables are expanded on each
+loop iteration. Note that other variables are not expanded when
+composing the body of a loop, so the following example code: .for
+i in 1 2 3 a+= ${i} j= ${i} b+= ${j} .endfor
+
+all: @echo ${a} @echo ${b} prints: 1 2 3 3 3 3
+After the loop is executed: contains which expands to contains
+which expands to contains which expands to and further to The
+four different classes of variables (in order of increasing
+precedence) are: Variables defined as part of environment. Vari-
+ables defined in the makefile or in included makefiles. Vari-
+ables defined as part of the command line. Variables that are
+defined specific to a certain target. Local variables can be set
+on a dependency line, unless is set to The rest of the line
+(which already has had global variables expanded) is the variable
+value. For example: COMPILER_WRAPPERS= ccache distcc icecc
+
+${OBJS}: .MAKE.META.CMP_FILTER=${COMPILER_WRAPPERS:S,^,N,} Only
+the targets are impacted by that filter (in mode) and simply en-
+abling/disabling any of the compiler wrappers does not render all
+of those targets out-of-date. target-local variable assignments
+behave differently in that; Only appends to a previous local as-
+signment for the same target and variable. Is redundant with re-
+spect to global variables, which have already been expanded. The
+seven built-in local variables are: The list of all sources for
+this target; also known as The name of the archive file; also
+known as In suffix-transformation rules, the name/path of the
+source from which the target is to be transformed (the source);
+also known as It is not defined in explicit rules. The name of
+the archive member; also known as The list of sources for this
+target that were deemed out-of-date; also known as The name of
+the target with suffix (if declared in removed; also known as The
+name of the target; also known as For compatibility with other
+makes this is an alias for in archive member rules. The shorter
+forms and are permitted for backward compatibility with histori-
+cal makefiles and legacy POSIX make and are not recommended.
+Variants of these variables with the punctuation followed immedi-
+ately by or e.g. are legacy forms equivalent to using the and
+modifiers. These forms are accepted for compatibility with make-
+files and POSIX but are not recommended. Four of the local vari-
+ables may be used in sources on dependency lines because they ex-
+pand to the proper value for each target on the line. These
+variables are and In addition, sets or knows about the following
+variables: The list of all targets encountered in the makefiles.
+If evaluated during makefile parsing, lists only those targets
+encountered thus far. A path to the directory where was exe-
+cuted. Refer to the description of for more details. Is used in
+error handling, see Is used in error handling, see Is used in er-
+ror handling, see Is used in error handling in mode, see Is used
+in error handling, see The directory of the file this makefile
+was included from. The filename of the file this makefile was
+included from. The machine hardware name, see The machine
+processor architecture name, see The name that was executed with
+The same as for compatibility. The preferred variable to use is
+the environment variable because it is more compatible with other
+make variants and cannot be confused with the special target with
+the same name. Names the makefile (default from which generated
+dependencies are read. If set to do not print error information
+at the end. A boolean that controls the default behavior of the
+option. If true, variable values printed with are fully ex-
+panded; if false, the raw variable contents (which may include
+additional unexpanded variable references) are shown. The list
+of variables exported by The top-level makefile that is currently
+read, as given in the command line. The environment variable may
+contain anything that may be specified on command line. Anything
+specified on command line is appended to the variable, which is
+then added to the environment for all programs that executes.
+The numeric group ID of the user running It is read-only. If is
+run with the output for each target is prefixed with a token the
+first part of which can be controlled via If is empty, no token
+is printed. For example, setting to would produce tokens like
+making it easier to track the degree of parallelism being
+achieved. The argument to the option. A read-only boolean that
+indicates whether the option supports use of The recursion depth
+of The top-level instance of has level 0, and each child make has
+its parent level plus 1. This allows tests like: to protect
+things which should only be evaluated in the top-level instance
+of The name of the environment variable that stores the level of
+nested calls to The ordered list of makefile names (default that
+looks for. The list of makefiles read by which is useful for
+tracking dependencies. Each makefile is recorded only once, re-
+gardless of the number of times read. In mode, provides a list
+of prefixes which match the directories controlled by If a file
+that was generated outside of but within said bailiwick is miss-
+ing, the current target is considered out-of-date. In mode, it
+can (very rarely!) be useful to filter command lines before com-
+parison. This variable can be set to a set of modifiers that are
+applied to each line of the old and new command that differ, if
+the filtered commands still differ, the target is considered out-
+of-date. In mode, this variable contains a list of all the meta
+files updated. If not empty, it can be used to trigger process-
+ing of In mode, this variable contains a list of all the meta
+files used (updated or not). This list can be used to process
+the meta files to extract dependency information. Provides a
+list of variable modifiers to apply to each pathname. Ignore if
+the expansion is an empty string. Provides a list of path pre-
+fixes that should be ignored; because the contents are expected
+to change over time. The default list includes: Provides a list
+of patterns to match against pathnames. Ignore any that match.
+Defines the message printed for each meta file updated in mode.
+The default value is: Processed after reading all makefiles. Af-
+fects the mode that runs in. It can contain these keywords: Like
+puts into mode. Puts into mode, where meta files are created for
+each target to capture the command run, the output generated, and
+if is available, the system calls which are of interest to The
+captured output can be useful when diagnosing errors. By de-
+fault, does not create files in This can be overridden by setting
+to a value which represents true. If is true, a missing file
+makes the target out-of-date. If is true, missing filemon data
+makes the target out-of-date. Do not use For debugging, it can
+be useful to include the environment in the file. If in mode,
+print a clue about the target being built. This is useful if the
+build is otherwise running silently. The message printed is the
+expanded value of Some makefiles have commands which are simply
+not stable. This keyword causes them to be ignored for determin-
+ing whether a target is out of date in mode. See also If is
+true, when a .meta file is created, mark the target In both com-
+pat and parallel mode, do not make the targets in the usual or-
+der, but instead randomize their order. This mode can be used to
+detect undeclared dependencies between files. Used to create
+files in a separate directory, see Used to force a separate di-
+rectory for the created files, even if that directory is not
+writable, see Used to create files in a separate directory, see
+The name of the operating system, see It is read-only. This
+variable is used to record the names of variables assigned to on
+the command line, so that they may be exported as part of This
+behavior can be disabled by assigning an empty value to within a
+makefile. Extra variables can be exported from a makefile by ap-
+pending their names to is re-exported whenever is modified. If
+was built with support, this is set to the path of the device
+node. This allows makefiles to test for this support. The
+process ID of It is read-only. The parent process ID of It is
+read-only. When stops due to an error, it sets to the name of
+the target that failed, to the exit status of the failed target,
+to the commands of the failed target, and in mode, it also sets
+to the and to the path of the meta file (if any) describing the
+failed target. It then prints its name and the value of as well
+as the value of any variables named in If true, are preserved
+when doing assignments. The default is false, for backwards com-
+patibility. Set to true for compatability with other makes. If
+set to false, becomes per normal evaluation rules. If set to ap-
+parent variable assignments in dependency lines are treated as
+normal sources. The numeric ID of the user running It is read-
+only. This variable is simply assigned a newline character as
+its value. It is read-only. This allows expansions using the
+modifier to put a newline between iterations of the loop rather
+than a space. For example, in case of an error, prints the vari-
+able names and their values using: A path to the directory where
+the targets are built. Its value is determined by trying to to
+the following directories in order and using the first match:
+(Only if is set in the environment or on the command line.)
+(Only if is set in the environment or on the command line.)
+Variable expansion is performed on the value before it is used,
+so expressions such as may be used. This is especially useful
+with may be modified in the makefile via the special target In
+all cases, changes to the specified directory if it exists, and
+sets and to that directory before executing any targets. Except
+in the case of an explicit target, checks that the specified di-
+rectory is writable and ignores it if not. This check can be
+skipped by setting the environment variable to The directory name
+of the current makefile being parsed. The basename of the cur-
+rent makefile being parsed. This variable and are both set only
+while the makefiles are being parsed. To retain their current
+values, assign them to a variable using assignment with expansion
+The space-separated list of directories that searches for files.
+To update this search list, use the special target rather than
+modifying the variable directly. Is set in POSIX mode, see the
+special target. Alternate path to the current directory. nor-
+mally sets to the canonical path given by However, if the envi-
+ronment variable is set and gives a path to the current direc-
+tory, sets to the value of instead. This behavior is disabled if
+is set or contains a variable transform. is set to the value of
+for all programs which executes. The pathname of the shell used
+to run target scripts. It is read-only. The list of known suf-
+fixes. It is read-only. The space-separated list of directories
+that searches for makefiles, referred to as the system include
+path. To update this search list, use the special target rather
+than modifying the variable which is read-only. The list of tar-
+gets explicitly specified on the command line, if any. The
+colon-separated list of directories that searches for files.
+This variable is supported for compatibility with old make pro-
+grams only, use instead. The general format of a variable expan-
+sion is: Each modifier begins with a colon. To escape a colon,
+precede it with a backslash A list of indirect modifiers can be
+specified via a variable, as follows:
+
+In this case, the first modifier in the does not start with a
+colon, since that colon already occurs in the referencing vari-
+able. If any of the modifiers in the contains a dollar sign
+these must be doubled to avoid early expansion. Some modifiers
+interpret the expression value as a single string, others treat
+the expression value as a whitespace-separated list of words.
+When splitting a string into words, whitespace can be escaped us-
+ing double quotes, single quotes and backslashes, like in the
+shell. The quotes and backslashes are retained in the words.
+The supported modifiers are: Replaces each word with its suffix.
+Replaces each word with its dirname. Selects only those words
+that match The standard shell wildcard characters and may be
+used. The wildcard characters may be escaped with a backslash As
+a consequence of the way values are split into words, matched,
+and then joined, the construct removes all leading and trailing
+whitespace and normalizes the inter-word spacing to a single
+space. This is the opposite of selecting all words which do
+match Orders the words lexicographically. Orders the words nu-
+merically. A number followed by one of or is multiplied by the
+appropriate factor, which is 1024 for 1048576 for or 1073741824
+for Both upper- and lower-case letters are accepted. Orders the
+words in reverse lexicographical order. Orders the words in re-
+verse numerical order. Shuffles the words. The results are dif-
+ferent each time you are referring to the modified variable; use
+the assignment with expansion to prevent such behavior. For ex-
+ample, LIST= uno due tre quattro RAN-
+DOM_LIST= ${LIST:Ox} STATIC_RAN-
+DOM_LIST:= ${LIST:Ox}
+
+all: @echo "${RANDOM_LIST}" @echo "${RAN-
+DOM_LIST}" @echo "${STATIC_RANDOM_LIST}" @echo
+"${STATIC_RANDOM_LIST}" may produce output similar to: quattro
+due tre uno tre due quattro uno due uno quattro tre due uno quat-
+tro tre Quotes every shell meta-character in the value, so that
+it can be passed safely to the shell. Quotes every shell meta-
+character in the value, and also doubles characters so that it
+can be passed safely through recursive invocations of This is
+equivalent to Replaces each word with everything but its suffix.
+The value is an integer sequence representing the words of the
+original value, or the supplied The value is interpreted as a
+format string for using producing the formatted timestamp. Note:
+the format should only be used with If a value is not provided or
+is 0, the current time is used. Computes a 32-bit hash of the
+value and encodes it as 8 hex digits. The value is interpreted
+as a format string for using producing the formatted timestamp.
+If a value is not provided or is 0, the current time is used.
+Call with each word as pathname; use as the new value. If fails;
+use or current time. If is set to then failure will cause an er-
+ror. Attempts to convert the value to an absolute path using If
+that fails, the value is unchanged. Converts the value to lower-
+case letters. When joining the words after a modifier that
+treats the value as words, the words are normally separated by a
+space. This modifier changes the separator to the character If
+is omitted, no separator is used. The common escapes (including
+octal numeric codes) work as expected. Converts the value to up-
+per-case letters. Causes subsequent modifiers to treat the value
+as a single word (possibly containing embedded whitespace). See
+also Causes the value to be treated as a list of words. See also
+Modifies the first occurrence of in each word of the value, re-
+placing it with If a is appended to the last delimiter of the
+pattern, all occurrences in each word are replaced. If a is ap-
+pended to the last delimiter of the pattern, only the first oc-
+currence is affected. If a is appended to the last delimiter of
+the pattern, the value is treated as a single word. If begins
+with a caret is anchored at the beginning of each word. If ends
+with a dollar sign it is anchored at the end of each word. In-
+side an ampersand is replaced by (without the anchoring or Any
+character may be used as the delimiter for the parts of the modi-
+fier string. The anchoring, ampersand and delimiter characters
+can be escaped with a backslash Both and may contain nested ex-
+pressions. To prevent a dollar sign from starting a nested ex-
+pression, escape it with a backslash. The modifier works like
+the modifier except that the old and new strings, instead of be-
+ing simple strings, are an extended regular expression (see and
+an Normally, the first occurrence of the pattern in each word of
+the value is substituted with The modifier causes the substitu-
+tion to apply to at most one word; the modifier causes the sub-
+stitution to apply to as many instances of the search pattern as
+occur in the word or words it is found in; the modifier causes
+the value to be treated as a single word (possibly containing em-
+bedded whitespace). As for the modifier, the and are subjected
+to variable expansion before being parsed as regular expressions.
+Replaces each word with its last path component (basename). Re-
+moves adjacent duplicate words (like If the variable name (not
+its value), when parsed as a conditional expression, evaluates to
+true, return as its value the otherwise return the Since the
+variable name is used as the expression, :? must be the first
+modifier after the variable name which, of course, usually con-
+tains variable expansions. A common error is trying to use ex-
+pressions like which actually tests defined(NUMBERS). To deter-
+mine if any words match you need to use something like: This is
+the style substitution. It can only be the last modifier speci-
+fied, as a in either or is treated as a regular character, not as
+the end of the modifier. If does not contain the pattern match-
+ing character and the word ends with or equals it, that suffix is
+replaced with Otherwise, the first in matches a possibly empty
+substring of arbitrary characters, and if the whole pattern is
+found in the word, the matching part is replaced with and the
+first occurrence of in (if any) is replaced with the substring
+matched by the Both and may contain nested expressions. To pre-
+vent a dollar sign from starting a nested expression, escape it
+with a backslash. This is the loop expansion mechanism from the
+OSF Development Environment (ODE) make. Unlike loops, expansion
+occurs at the time of reference. For each word in the value, as-
+sign the word to the variable named and evaluate The ODE conven-
+tion is that should start and end with a period, for example:
+However, a single-letter variable is often more readable: Saves
+the current variable value in or the named for later reference.
+Example usage: M_cmpv.units = 1 1000 1000000 M_cmpv = S,.,
+,g:_:range:@i@+ $${_:[-$$i]} \ \*
+$${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
+
+
+Here is used to save the result of the modifier which is later
+referenced using the index values from If the variable is unde-
+fined, the optional (which may be empty) is the value. If the
+variable is defined, the existing value is returned. This is an-
+other ODE make feature. It is handy for setting per-target
+CFLAGS for instance: If a value is only required if the variable
+is undefined, use: If the variable is defined, (which may be
+empty) is the value. The name of the variable is the value. The
+path of the node which has the same name as the variable is the
+value. If no such node exists or its path is null, the name of
+the variable is used. In order for this modifier to work, the
+name (node) must at least have appeared on the right-hand side of
+a dependency. The output of running is the value. The value is
+run as a command, and the output becomes the new value. The
+variable is assigned the value after substitution. This modifier
+and its variations are useful in obscure situations such as want-
+ing to set a variable at a point where a target's shell commands
+are being parsed. These assignment modifiers always expand to
+nothing. The helps avoid false matches with the style modifier
+and since substitution always occurs, the form is vaguely appro-
+priate. As for but only if the variable does not already have a
+value. Append to the variable. Assign the output of to the
+variable. Selects one or more words from the value, or performs
+other operations related to the way in which the value is split
+into words. An empty value, or a value that consists entirely of
+white-space, is treated as a single word. For the purposes of
+the modifier, the words are indexed both forwards using positive
+integers (where index 1 represents the first word), and backwards
+using negative integers (where index -1 represents the last
+word). The is subjected to variable expansion, and the expanded
+result is then interpreted as follows: Selects a single word from
+the value. Selects all words from to inclusive. For example,
+selects all words from the second word to the last word. If is
+greater than the words are output in reverse order. For example,
+selects all the words from last to first. If the list is already
+ordered, this effectively reverses the list, but it is more effi-
+cient to use instead of Causes subsequent modifiers to treat the
+value as a single word (possibly containing embedded whitespace).
+Analogous to the effect of in Bourne shell. Means the same as
+Causes subsequent modifiers to treat the value as a sequence of
+words delimited by whitespace. Analogous to the effect of in
+Bourne shell. Returns the number of words in the value. offers
+directives for including makefiles, conditionals and for loops.
+All these directives are identified by a line beginning with a
+single dot character, followed by the keyword of the directive,
+such as or Files are included with either or Variables between
+the angle brackets or double quotes are expanded to form the file
+name. If angle brackets are used, the included makefile is ex-
+pected to be in the system makefile directory. If double quotes
+are used, the including makefile's directory and any directories
+specified using the option are searched before the system make-
+file directory. For compatibility with other make variants,
+(without leading dot) is also accepted. If the include statement
+is written as or as errors locating and/or opening include files
+are ignored. If the include statement is written as not only are
+errors locating and/or opening include files ignored, but stale
+dependencies within the included file are ignored just like in
+The directives for exporting and unexporting variables are: Ex-
+port the specified global variable. If no variable list is pro-
+vided, all globals are exported except for internal variables
+(those that start with This is not affected by the flag, so
+should be used with caution. For compatibility with other make
+programs, (without leading dot) is also accepted. Appending a
+variable name to is equivalent to exporting a variable. The same
+as except that the variable is not appended to This allows ex-
+porting a value to the environment which is different from that
+used by internally. The same as except that variables in the
+value are not expanded. The opposite of The specified global is
+removed from If no variable list is provided, all globals are un-
+exported, and deleted. Unexport all globals previously exported
+and clear the environment inherited from the parent. This opera-
+tion causes a memory leak of the original environment, so should
+be used sparingly. Testing for being 0 would make sense. Also
+note that any variables which originated in the parent environ-
+ment should be explicitly preserved if desired. For example:
+PATH := ${PATH} Would result in an environment containing only
+which is the minimal useful environment. Actually is also pushed
+into the new environment. The directives for printing messages
+to the output are: The message is printed along with the name of
+the makefile and line number. The message prefixed by is printed
+along with the name of the makefile and line number. The message
+is printed along with the name of the makefile and line number,
+exits immediately. The directives for conditionals are: Test the
+value of an expression. Test whether a variable is defined.
+Test whether a variable is not defined. Test the target being
+requested. Test the target being requested. Reverse the sense
+of the last conditional. A combination of followed by A combina-
+tion of followed by A combination of followed by A combination of
+followed by A combination of followed by End the body of the con-
+ditional. The may be any one of the following: Logical OR. Log-
+ical AND; of higher precedence than only evaluates a conditional
+as far as is necessary to determine its value. Parentheses can
+be used to override the operator precedence. The boolean opera-
+tor may be used to logically negate an expression, typically a
+function call. It is of higher precedence than The value of may
+be any of the following function call expressions: Evaluates to
+true if the variable has been defined. Evaluates to true if the
+target was specified as part of command line or was declared the
+default target (either implicitly or explicitly, see before the
+line containing the conditional. Evaluates to true if the expan-
+sion of the variable, after applying the modifiers, results in an
+empty string. Evaluates to true if the given pathname exists.
+If relative, the pathname is searched for on the system search
+path (see Evaluates to true if the target has been defined.
+Evaluates to true if the target has been defined and has commands
+associated with it. may also be an arithmetic or string compari-
+son. Variable expansion is performed on both sides of the com-
+parison. If both sides are numeric and neither is enclosed in
+quotes, the comparison is done numerically, otherwise lexico-
+graphically. A string is interpreted as a hexadecimal integer if
+it is preceded by otherwise it is interpreted as a decimal float-
+ing-point number; octal numbers are not supported. All compar-
+isons may use the operators and Numeric comparisons may also use
+the operators and If the comparison has neither a comparison op-
+erator nor a right side, the expression evaluates to true if it
+is nonempty and its numeric value (if any) is not zero. When is
+evaluating one of these conditional expressions, and it encoun-
+ters a (whitespace-separated) word it doesn't recognize, either
+the or function is applied to it, depending on the form of the
+conditional. If the form is or the function is applied. Simi-
+larly, if the form is or the function is applied. If the condi-
+tional evaluates to true, parsing of the makefile continues as
+before. If it evaluates to false, the following lines until the
+corresponding variant, or are skipped. For loops are typically
+used to apply a set of rules to a list of files. The syntax of a
+for loop is: The is expanded and then split into words. On each
+iteration of the loop, one word is taken and assigned to each in
+order, and these are substituted into the inside the body of the
+for loop. The number of words must come out even; that is, if
+there are three iteration variables, the number of words provided
+must be a multiple of three. If is encountered within a loop, it
+causes early termination of the loop, otherwise a parse error.
+Un-define the specified global variables. Only global variables
+can be un-defined. Comments begin with a hash character, any-
+where but in a shell command line, and continue to the end of an
+unescaped new line. Target is never out of date, but always exe-
+cute commands anyway. Ignore any errors from the commands asso-
+ciated with this target, exactly as if they all were preceded by
+a dash Mark all sources of this target as being up to date. Exe-
+cute the commands associated with this target even if the or op-
+tions were specified. Normally used to mark recursive Create a
+meta file for the target, even if it is flagged as or Usage in
+conjunction with is the most likely case. In mode, the target is
+out-of-date if the meta file is missing. Do not create a meta
+file for the target. Meta files are also not created for or tar-
+gets. Ignore differences in commands when deciding if target is
+out of date. This is useful if the command contains a value
+which always changes. If the number of commands change, though,
+the target is still considered out of date. The same effect ap-
+plies to any command line that uses the variable which can be
+used for that purpose even when not otherwise needed or desired:
+
+skip-compare-for-some: @echo this is compared
+ @echo this is not ${.OODATE:M.NOMETA_CMP} @echo
+this is also compared
+
+The pattern suppresses any expansion of the unwanted variable.
+Do not search for the target in the directories specified by Nor-
+mally selects the first target it encounters as the default tar-
+get to be built if no target was specified. This source prevents
+this target from being selected. If a target is marked with this
+attribute and can't figure out how to create it, it ignores this
+fact and assumes the file isn't needed or already exists. The
+target does not correspond to an actual file; it is always con-
+sidered to be out of date, and is not created with the option.
+Suffix-transformation rules are not applied to targets. When is
+interrupted, it normally removes any partially made targets.
+This source prevents the target from being removed. Synonym for
+Do not echo any of the commands associated with this target, ex-
+actly as if they all were preceded by an at sign Turn the target
+into version of a macro. When the target is used as a source for
+another target, the other target acquires the commands, sources,
+and attributes (except for of the source. If the target already
+has commands, the target's commands are appended to them. Like
+but instead of appending, prepend the target commands to the tar-
+get. If appears in a dependency line, the sources that precede
+it are made before the sources that succeed it in the line.
+Since the dependents of files are not made until the file itself
+could be made, this also stops the dependents being built unless
+they are needed for another branch of the dependency tree. So
+given: x: a .WAIT b echo x a: echo a b: b1
+ echo b b1: echo b1
+
+the output is always The ordering imposed by is only relevant for
+parallel makes. Special targets may not be included with other
+targets, i.e. they must be the only target specified. Any com-
+mand lines attached to this target are executed before anything
+else is done. This is sort of a rule for any target (that was
+used only as a source) that can't figure out any other way to
+create. Only the shell script is used. The variable of a target
+that inherits commands is set to the target's own name. If this
+target is present in the makefile, it globally causes make to
+delete targets whose commands fail. (By default, only targets
+whose commands are interrupted during execution are deleted.
+This is the historical behavior.) This setting can be used to
+help prevent half-finished or malformed targets from being left
+around and corrupting future rebuilds. Any command lines at-
+tached to this target are executed after everything else is done
+successfully. Any command lines attached to this target are exe-
+cuted when another target fails. See for the variables that will
+be set. Mark each of the sources with the attribute. If no
+sources are specified, this is the equivalent of specifying the
+option. If is interrupted, the commands for this target are exe-
+cuted. If no target is specified when is invoked, this target is
+built. This target provides a way to specify flags for at the
+time when the makefiles are read. The flags are as if typed to
+the shell, though the option has no effect. Apply the attribute
+to any specified sources. Disable parallel mode. Synonym for
+for compatibility with other pmake variants. clear the read-only
+attribute from the global variables specified as sources. The
+source is a new value for If it exists, changes the current work-
+ing directory to it and updates the value of In parallel mode,
+the named targets are made in sequence. This ordering does not
+add targets to the list of targets to be made. Since the depen-
+dents of a target do not get built until the target itself could
+be built, unless is built by another part of the dependency
+graph, the following is a dependency loop: .ORDER: b a b: a The
+sources are directories which are to be searched for files not
+found in the current directory. If no sources are specified, any
+previously specified directories are removed from the search
+path. If the source is the special target, the current working
+directory is searched last. Like but applies only to files with
+a particular suffix. The suffix must have been previously de-
+clared with Apply the attribute to any specified sources. If
+this is the first non-comment line in the main makefile, the
+variable is set to the value and the makefile is included if it
+exists, to provide POSIX-compatible default rules. If is run
+with the flag, only contributes to the default rules. Apply the
+attribute to any specified sources. If no sources are specified,
+the attribute is applied to every target in the file. set the
+read-only attribute on the global variables specified as sources.
+Sets the shell that uses to execute commands. The sources are a
+set of pairs. This is the minimal specification, used to select
+one of the built-in shell specs; and Specifies the absolute path
+to the shell. Indicates whether the shell supports exit on er-
+ror. The command to turn on error checking. The command to dis-
+able error checking. The command to turn on echoing of commands
+executed. The command to turn off echoing of commands executed.
+The output to filter after issuing the command. It is typically
+identical to The flag to pass the shell to enable error checking.
+The flag to pass the shell to enable command echoing. The string
+literal to pass the shell that results in a single newline char-
+acter when used outside of any quoting characters. Example:
+.SHELL: name=ksh path=/bin/ksh hasErrCtl=true \
+ check="set -e" ignore="set +e" \ echo="set -v"
+quiet="set +v" filter="set +v" \ echoFlag=v errFlag=e
+newline="'\n'" Apply the attribute to any specified sources. If
+no sources are specified, the attribute is applied to every com-
+mand in the file. This target gets run when a dependency file
+contains stale entries, having set to the name of that dependency
+file. Each source specifies a suffix to If no sources are speci-
+fied, any previously specified suffixes are deleted. It allows
+the creation of suffix-transformation rules. Example: .SUFFIXES:
+.c .o .c.o: cc -o ${.TARGET} -c ${.IMPSRC} The sources
+are directories which are to be added to the system include path
+which searches for makefiles. If no sources are specified, any
+previously specified directories are removed from the system in-
+clude path. uses the following environment variables, if they
+exist: and and may only be set in the environment or on the com-
+mand line to and not as makefile variables; see the description
+of for more details. list of dependencies first default makefile
+if no makefile is specified on the command line second default
+makefile if no makefile is specified on the command line system
+makefile system makefile directory The basic make syntax is com-
+patible between different make variants; however the special
+variables, variable modifiers and conditionals are not. An in-
+complete list of changes in older versions of The way that .for
+loop variables are substituted changed after NetBSD 5.0 so that
+they still appear to be variable expansions. In particular this
+stops them being treated as syntax, and removes some obscure
+problems using them in .if statements. The way that parallel
+makes are scheduled changed in NetBSD 4.0 so that .ORDER and
+.WAIT apply recursively to the dependent nodes. The algorithms
+used may change again in the future. Other make dialects (GNU
+make, SVR4 make, POSIX make, etc.) do not support most of the
+features of as described in this manual. Most notably: The and
+declarations and most functionality pertaining to paralleliza-
+tion. (GNU make supports parallelization but lacks the features
+needed to control it effectively.) Directives, including for
+loops and conditionals and most of the forms of include files.
+(GNU make has its own incompatible and less powerful syntax for
+conditionals.) All built-in variables that begin with a dot.
+Most of the special sources and targets that begin with a dot,
+with the notable exception of and Variable modifiers, except for
+the string substitution, which does not portably support globbing
+with and historically only works on declared suffixes. The vari-
+able even in its short form; most makes support this functional-
+ity but its name varies. Some features are somewhat more
+portable, such as assignment with and The functionality is based
+on an older feature found in GNU make and many versions of SVR4
+make; however, historically its behavior is too ill-defined (and
+too buggy) to rely upon. The and variables are more or less uni-
+versally portable, as is the variable. Basic use of suffix rules
+(for files only in the current directory, not trying to chain
+transformations together, etc.) is also reasonably portable. is
+derived from NetBSD It uses autoconf to facilitate portability to
+other platforms. A make command appeared in This make implemen-
+tation is based on Adam de Boor's pmake program, which was writ-
+ten for Sprite at Berkeley. It was designed to be a parallel
+distributed make running jobs on different machines using a dae-
+mon called Historically the target/dependency has been used to
+FoRCe rebuilding (since the target/dependency does not exist ...
+unless someone creates an file). The make syntax is difficult to
+parse. For instance, finding the end of a variable's use should
+involve scanning each of the modifiers, using the correct termi-
+nator for each field. In many places make just counts {} and ()
+in order to find the end of a variable expansion. There is no
+way of escaping a space character in a filename. In jobs mode,
+when a target fails; make will put an error token into the job
+token pool. This will cause all other instances of make using
+that token pool to abort the build and exit with error code 6.
+Sometimes the attempt to suppress a cascade of unnecessary er-
+rors, can result in a seemingly unexplained
-NAME
- bmake -- maintain program dependencies
-SYNOPSIS
- bmake [-BeikNnqrSstWwX] [-C directory] [-D variable] [-d flags]
- [-f makefile] [-I directory] [-J private] [-j max_jobs]
- [-m directory] [-T file] [-V variable] [-v variable]
- [variable=value] [target ...]
-DESCRIPTION
- bmake is a program designed to simplify the maintenance of other pro-
- grams. Its input is a list of specifications as to the files upon which
- programs and other files depend. If no -f makefile option is given,
- bmake tries to open `makefile' then `Makefile' in order to find the spec-
- ifications. If the file `.depend' exists, it is read, see mkdep(1).
- This manual page is intended as a reference document only. For a more
- thorough description of bmake and makefiles, please refer to PMake - A
- Tutorial (from 1993).
- bmake prepends the contents of the MAKEFLAGS environment variable to the
- command line arguments before parsing them.
- The options are as follows:
- -B Try to be backwards compatible by executing a single shell per
- command and by making the sources of a dependency line in se-
- quence.
- -C directory
- Change to directory before reading the makefiles or doing any-
- thing else. If multiple -C options are specified, each is inter-
- preted relative to the previous one: -C / -C etc is equivalent to
- -C /etc.
- -D variable
- Define variable to be 1, in the global scope.
- -d [-]flags
- Turn on debugging, and specify which portions of bmake are to
- print debugging information. Unless the flags are preceded by
- `-', they are added to the MAKEFLAGS environment variable and are
- passed on to any child make processes. By default, debugging in-
- formation is printed to standard error, but this can be changed
- using the F debugging flag. The debugging output is always un-
- buffered; in addition, if debugging is enabled but debugging out-
- put is not directed to standard output, the standard output is
- line buffered. The available flags are:
- A Print all possible debugging information; equivalent to
- specifying all of the debugging flags.
- a Print debugging information about archive searching and
- caching.
- C Print debugging information about the current working di-
- rectory.
- c Print debugging information about conditional evaluation.
- d Print debugging information about directory searching and
- caching.
- e Print debugging information about failed commands and
- targets.
-
- F[+]filename
- Specify where debugging output is written. This must be
- the last flag, because it consumes the remainder of the
- argument. If the character immediately after the F flag
- is `+', the file is opened in append mode; otherwise the
- file is overwritten. If the file name is `stdout' or
- `stderr', debugging output is written to the standard
- output or standard error output respectively (and the `+'
- option has no effect). Otherwise, the output is written
- to the named file. If the file name ends with `.%d', the
- `%d' is replaced by the pid.
-
- f Print debugging information about loop evaluation.
-
- g1 Print the input graph before making anything.
-
- g2 Print the input graph after making everything, or before
- exiting on error.
-
- g3 Print the input graph before exiting on error.
-
- h Print debugging information about hash table operations.
-
- j Print debugging information about running multiple
- shells.
-
- L Turn on lint checks. This throws errors for variable as-
- signments that do not parse correctly, at the time of as-
- signment, so the file and line number are available.
-
- l Print commands in Makefiles regardless of whether or not
- they are prefixed by `@' or other "quiet" flags. Also
- known as "loud" behavior.
-
- M Print debugging information about "meta" mode decisions
- about targets.
-
- m Print debugging information about making targets, includ-
- ing modification dates.
-
- n Don't delete the temporary command scripts created when
- running commands. These temporary scripts are created in
- the directory referred to by the TMPDIR environment vari-
- able, or in /tmp if TMPDIR is unset or set to the empty
- string. The temporary scripts are created by mkstemp(3),
- and have names of the form makeXXXXXX. NOTE: This can
- create many files in TMPDIR or /tmp, so use with care.
-
- p Print debugging information about makefile parsing.
-
- s Print debugging information about suffix-transformation
- rules.
-
- t Print debugging information about target list mainte-
- nance.
-
- V Force the -V option to print raw values of variables,
- overriding the default behavior set via
- .MAKE.EXPAND_VARIABLES.
-
- v Print debugging information about variable assignment and
- expansion.
-
- x Run shell commands with -x so the actual commands are
- printed as they are executed.
-
- -e Let environment variables override global variables within make-
- files.
-
- -f makefile
- Specify a makefile to read instead of the default makefile or
- Makefile. If makefile is `-', standard input is read. Multiple
- makefiles may be specified, and are read in the order specified.
-
- -I directory
- Specify a directory in which to search for makefiles and included
- makefiles. The system makefile directory (or directories, see
- the -m option) is automatically included as part of this list.
-
- -i Ignore non-zero exit of shell commands in the makefile. Equiva-
- lent to specifying `-' before each command line in the makefile.
-
- -J private
- This option should not be specified by the user.
-
- When the -j option is in use in a recursive build, this option is
- passed by a make to child makes to allow all the make processes
- in the build to cooperate to avoid overloading the system.
-
- -j max_jobs
- Specify the maximum number of jobs that bmake may have running at
- any one time. If max_jobs is a floating point number, or ends
- with `C', then the value is multiplied by the number of CPUs re-
- ported online by sysconf(3). The value of max_jobs is saved in
- .MAKE.JOBS. Turns compatibility mode off, unless the -B option
- is also specified. When compatibility mode is off, all commands
- associated with a target are executed in a single shell invoca-
- tion as opposed to the traditional one shell invocation per line.
- This can break traditional scripts which change directories on
- each command invocation and then expect to start with a fresh en-
- vironment on the next line. It is more efficient to correct the
- scripts rather than turn backwards compatibility on.
-
- A job token pool with max_jobs tokens is used to control the to-
- tal number of jobs running. Each instance of bmake will wait for
- a token from the pool before running a new job.
-
- -k Continue processing after errors are encountered, but only on
- those targets that do not depend on the target whose creation
- caused the error.
-
- -m directory
- Specify a directory in which to search for sys.mk and makefiles
- included via the <file>-style include statement. The -m option
- can be used multiple times to form a search path. This path
- overrides the default system include path /usr/share/mk. Fur-
- thermore, the system include path is appended to the search path
- used for "file"-style include statements (see the -I option).
- The system include path can be referenced via the read-only vari-
- able .SYSPATH.
-
- If a directory name in the -m argument (or the MAKESYSPATH envi-
- ronment variable) starts with the string `.../', bmake searches
- for the specified file or directory named in the remaining part
- of the argument string. The search starts with the current di-
- rectory and then works upward towards the root of the file sys-
- tem. If the search is successful, the resulting directory re-
- places the `.../' specification in the -m argument. This feature
- allows bmake to easily search in the current source tree for cus-
- tomized sys.mk files (e.g., by using `.../mk/sys.mk' as an argu-
- ment).
-
- -n Display the commands that would have been executed, but do not
- actually execute them unless the target depends on the .MAKE spe-
- cial source (see below) or the command is prefixed with `+'.
-
- -N Display the commands that would have been executed, but do not
- actually execute any of them; useful for debugging top-level
- makefiles without descending into subdirectories.
-
- -q Do not execute any commands, instead exit 0 if the specified tar-
- gets are up to date, and 1 otherwise.
-
- -r Do not use the built-in rules specified in the system makefile.
-
- -S Stop processing if an error is encountered. This is the default
- behavior and the opposite of -k.
-
- -s Do not echo any commands as they are executed. Equivalent to
- specifying `@' before each command line in the makefile.
-
- -T tracefile
- When used with the -j flag, append a trace record to tracefile
- for each job started and completed.
-
- -t Rather than re-building a target as specified in the makefile,
- create it or update its modification time to make it appear up-
- to-date.
-
- -V variable
- Print the value of variable. Do not build any targets. Multiple
- instances of this option may be specified; the variables are
- printed one per line, with a blank line for each null or unde-
- fined variable. The value printed is extracted from the global
- scope after all makefiles have been read.
-
- By default, the raw variable contents (which may include addi-
- tional unexpanded variable references) are shown. If variable
- contains a `$', it is not interpreted as a variable name but
- rather as an expression. Its value is expanded before printing.
- The value is also expanded before printing if
- .MAKE.EXPAND_VARIABLES is set to true and the -dV option has not
- been used to override it.
-
- Note that loop-local and target-local variables, as well as val-
- ues taken temporarily by global variables during makefile pro-
- cessing, are not accessible via this option. The -dv debug mode
- can be used to see these at the cost of generating substantial
- extraneous output.
-
- -v variable
- Like -V, but all printed variables are always expanded to their
- complete value. The last occurrence of -V or -v decides whether
- all variables are expanded or not.
-
- -W Treat any warnings during makefile parsing as errors.
-
- -w Print entering and leaving directory messages, pre and post pro-
- cessing.
-
- -X Don't export variables passed on the command line to the environ-
- ment individually. Variables passed on the command line are
- still exported via the MAKEFLAGS environment variable. This op-
- tion may be useful on systems which have a small limit on the
- size of command arguments.
-
- variable=value
- Set the value of the variable variable to value. Normally, all
- values passed on the command line are also exported to sub-makes
- in the environment. The -X flag disables this behavior. Vari-
- able assignments should follow options for POSIX compatibility
- but no ordering is enforced.
-
- There are several different types of lines in a makefile: dependency
- specifications, shell commands, variable assignments, include statements,
- conditional directives, for loops, other directives, and comments.
-
- Lines may be continued from one line to the next by ending them with a
- backslash (`\'). The trailing newline character and initial whitespace
- on the following line are compressed into a single space.
-
-FILE DEPENDENCY SPECIFICATIONS
- Dependency lines consist of one or more targets, an operator, and zero or
- more sources. This creates a relationship where the targets "depend" on
- the sources and are customarily created from them. A target is consid-
- ered out of date if it does not exist, or if its modification time is
- less than that of any of its sources. An out-of-date target is re-cre-
- ated, but not until all sources have been examined and themselves re-cre-
- ated as needed. Three operators may be used:
-
- : Many dependency lines may name this target but only one may have
- attached shell commands. All sources named in all dependency lines
- are considered together, and if needed the attached shell commands
- are run to create or re-create the target. If bmake is inter-
- rupted, the target is removed.
-
- ! The same, but the target is always re-created whether or not it is
- out of date.
-
- :: Any dependency line may have attached shell commands, but each one
- is handled independently: its sources are considered and the at-
- tached shell commands are run if the target is out of date with re-
- spect to (only) those sources. Thus, different groups of the at-
- tached shell commands may be run depending on the circumstances.
- Furthermore, unlike :, for dependency lines with no sources, the
- attached shell commands are always run. Also unlike :, the target
- is not removed if bmake is interrupted.
-
- All dependency lines mentioning a particular target must use the same op-
- erator.
-
- Targets and sources may contain the shell wildcard values `?', `*', `[]',
- and `{}'. The values `?', `*', and `[]' may only be used as part of the
- final component of the target or source, and only match existing files.
- The value `{}' need not necessarily be used to describe existing files.
- Expansion is in directory order, not alphabetically as done in the shell.
-
-SHELL COMMANDS
- Each target may have associated with it one or more lines of shell com-
- mands, normally used to create the target. Each of the lines in this
- script must be preceded by a tab. (For historical reasons, spaces are
- not accepted.) While targets can occur in many dependency lines if de-
- sired, by default only one of these rules may be followed by a creation
- script. If the `::' operator is used, however, all rules may include
- scripts, and the respective scripts are executed in the order found.
-
- Each line is treated as a separate shell command, unless the end of line
- is escaped with a backslash `\', in which case that line and the next are
- combined. If the first characters of the command are any combination of
- `@', `+', or `-', the command is treated specially.
-
- @ causes the command not to be echoed before it is executed.
-
- + causes the command to be executed even when -n is given.
- This is similar to the effect of the .MAKE special source,
- except that the effect can be limited to a single line of a
- script.
-
- - in compatibility mode causes any non-zero exit status of
- the command line to be ignored.
-
- When bmake is run in jobs mode with -j max_jobs, the entire script for
- the target is fed to a single instance of the shell. In compatibility
- (non-jobs) mode, each command is run in a separate process. If the com-
- mand contains any shell meta characters (`#=|^(){};&<>*?[]:$`\\n'), it is
- passed to the shell; otherwise bmake attempts direct execution. If a
- line starts with `-' and the shell has ErrCtl enabled, failure of the
- command line is ignored as in compatibility mode. Otherwise `-' affects
- the entire job; the script stops at the first command line that fails,
- but the target is not deemed to have failed.
-
- Makefiles should be written so that the mode of bmake operation does not
- change their behavior. For example, any command which uses "cd" or
- "chdir" without the intention of changing the directory for subsequent
- commands should be put in parentheses so it executes in a subshell. To
- force the use of a single shell, escape the line breaks so as to make the
- whole script one command. For example:
-
- avoid-chdir-side-effects:
- @echo "Building $@ in $$(pwd)"
- @(cd ${.CURDIR} && ${MAKE} $@)
- @echo "Back in $$(pwd)"
-
- ensure-one-shell-regardless-of-mode:
- @echo "Building $@ in $$(pwd)"; \
- (cd ${.CURDIR} && ${MAKE} $@); \
- echo "Back in $$(pwd)"
-
- Since bmake changes the current working directory to `.OBJDIR' before ex-
- ecuting any targets, each child process starts with that as its current
- working directory.
-VARIABLE ASSIGNMENTS
- Variables in make behave much like macros in the C preprocessor.
- Variable assignments have the form `NAME op value', where:
- NAME is a single-word variable name, consisting, by tradition,
- of all upper-case letters,
- op is one of the variable assignment operators described be-
- low, and
- value is interpreted according to the variable assignment opera-
- tor.
- Whitespace around NAME, op and value is discarded.
- Variable assignment operators
- The five operators that assign values to variables are:
- = Assign the value to the variable. Any previous value is over-
- written.
- += Append the value to the current value of the variable, separating
- them by a single space.
- ?= Assign the value to the variable if it is not already defined.
- := Expand the value, then assign it to the variable.
- NOTE: References to undefined variables are not expanded. This
- can cause problems when variable modifiers are used.
- != Expand the value and pass it to the shell for execution, then as-
- sign the output from the child's standard output to the variable.
- Any newlines in the result are replaced with spaces.
- Expansion of variables
- In most contexts where variables are expanded, `$$' expands to a single
- dollar sign. In other contexts (most variable modifiers, string literals
- in conditions), `\$' expands to a single dollar sign.
- References to variables have the form ${name[:modifiers]} or
- $(name[:modifiers]). If the variable name consists of only a single
- character and the expression contains no modifiers, the surrounding curly
- braces or parentheses are not required. This shorter form is not recom-
- mended.
- If the variable name contains a dollar, the name itself is expanded
- first. This allows almost arbitrary variable names, however names con-
- taining dollar, braces, parentheses or whitespace are really best
- avoided.
- If the result of expanding a nested variable expression contains a dollar
- sign (`$'), the result is subject to further expansion.
- Variable substitution occurs at four distinct times, depending on where
- the variable is being used.
- 1. Variables in dependency lines are expanded as the line is read.
- 2. Variables in conditionals are expanded individually, but only as far
- as necessary to determine the result of the conditional.
- 3. Variables in shell commands are expanded when the shell command is
- executed.
- 4. .for loop index variables are expanded on each loop iteration. Note
- that other variables are not expanded when composing the body of a
- loop, so the following example code:
- .for i in 1 2 3
- a+= ${i}
- j= ${i}
- b+= ${j}
- .endfor
- all:
- @echo ${a}
- @echo ${b}
- prints:
- 1 2 3
- 3 3 3
- After the loop is executed:
- a contains `${:U1} ${:U2} ${:U3}', which expands to `1 2
- 3'.
- j contains `${:U3}', which expands to `3'.
- b contains `${j} ${j} ${j}', which expands to `${:U3}
- ${:U3} ${:U3}' and further to `3 3 3'.
- Variable classes
- The four different classes of variables (in order of increasing prece-
- dence) are:
- Environment variables
- Variables defined as part of bmake's environment.
- Global variables
- Variables defined in the makefile or in included makefiles.
- Command line variables
- Variables defined as part of the command line.
- Local variables
- Variables that are defined specific to a certain target.
- Local variables can be set on a dependency line, unless
- .MAKE.TARGET_LOCAL_VARIABLES is set to `false'. The rest of the line
- (which already has had global variables expanded) is the variable value.
- For example:
- COMPILER_WRAPPERS= ccache distcc icecc
- ${OBJS}: .MAKE.META.CMP_FILTER=${COMPILER_WRAPPERS:S,^,N,}
- Only the targets `${OBJS}' are impacted by that filter (in "meta" mode)
- and simply enabling/disabling any of the compiler wrappers does not ren-
- der all of those targets out-of-date.
- NOTE: target-local variable assignments behave differently in that;
- += Only appends to a previous local assignment for the same
- target and variable.
- := Is redundant with respect to global variables, which have
- already been expanded.
- The seven built-in local variables are:
- .ALLSRC The list of all sources for this target; also known as
- `>'.
- .ARCHIVE The name of the archive file; also known as `!'.
-
- .IMPSRC In suffix-transformation rules, the name/path of the
- source from which the target is to be transformed (the
- "implied" source); also known as `<'. It is not defined
- in explicit rules.
-
- .MEMBER The name of the archive member; also known as `%'.
-
- .OODATE The list of sources for this target that were deemed out-
- of-date; also known as `?'.
-
- .PREFIX The name of the target with suffix (if declared in
- .SUFFIXES) removed; also known as `*'.
-
- .TARGET The name of the target; also known as `@'. For compati-
- bility with other makes this is an alias for .ARCHIVE in
- archive member rules.
-
- The shorter forms (`>', `!', `<', `%', `?', `*', and `@') are permitted
- for backward compatibility with historical makefiles and legacy POSIX
- make and are not recommended.
-
- Variants of these variables with the punctuation followed immediately by
- `D' or `F', e.g. `$(@D)', are legacy forms equivalent to using the `:H'
- and `:T' modifiers. These forms are accepted for compatibility with AT&T
- System V UNIX makefiles and POSIX but are not recommended.
-
- Four of the local variables may be used in sources on dependency lines
- because they expand to the proper value for each target on the line.
- These variables are `.TARGET', `.PREFIX', `.ARCHIVE', and `.MEMBER'.
-
- Additional built-in variables
- In addition, bmake sets or knows about the following variables:
-
- .ALLTARGETS
- The list of all targets encountered in the makefiles. If evalu-
- ated during makefile parsing, lists only those targets encoun-
- tered thus far.
-
- .CURDIR
- A path to the directory where bmake was executed. Refer to the
- description of `PWD' for more details.
-
- .ERROR_CMD
- Is used in error handling, see MAKE_PRINT_VAR_ON_ERROR.
-
- .ERROR_CWD
- Is used in error handling, see MAKE_PRINT_VAR_ON_ERROR.
-
- .ERROR_META_FILE
- Is used in error handling in "meta" mode, see
- MAKE_PRINT_VAR_ON_ERROR.
-
- .ERROR_TARGET
- Is used in error handling, see MAKE_PRINT_VAR_ON_ERROR.
-
- .INCLUDEDFROMDIR
- The directory of the file this makefile was included from.
-
- .INCLUDEDFROMFILE
- The filename of the file this makefile was included from.
-
- MACHINE
- The machine hardware name, see uname(1).
-
- MACHINE_ARCH
- The machine processor architecture name, see uname(1).
-
- MAKE The name that bmake was executed with (argv[0]).
-
- .MAKE The same as MAKE, for compatibility. The preferred variable to
- use is the environment variable MAKE because it is more compati-
- ble with other make variants and cannot be confused with the spe-
- cial target with the same name.
-
- .MAKE.DEPENDFILE
- Names the makefile (default `.depend') from which generated de-
- pendencies are read.
-
- .MAKE.DIE_QUIETLY
- If set to `true', do not print error information at the end.
-
- .MAKE.EXPAND_VARIABLES
- A boolean that controls the default behavior of the -V option.
- If true, variable values printed with -V are fully expanded; if
- false, the raw variable contents (which may include additional
- unexpanded variable references) are shown.
-
- .MAKE.EXPORTED
- The list of variables exported by bmake.
-
- MAKEFILE
- The top-level makefile that is currently read, as given in the
- command line.
-
- .MAKEFLAGS
- The environment variable `MAKEFLAGS' may contain anything that
- may be specified on bmake's command line. Anything specified on
- bmake's command line is appended to the .MAKEFLAGS variable,
- which is then added to the environment for all programs that
- bmake executes.
-
- .MAKE.GID
- The numeric group ID of the user running bmake. It is read-only.
-
- .MAKE.JOB.PREFIX
- If bmake is run with -j, the output for each target is prefixed
- with a token
- --- target ---
- the first part of which can be controlled via .MAKE.JOB.PREFIX.
- If .MAKE.JOB.PREFIX is empty, no token is printed. For example,
- setting .MAKE.JOB.PREFIX to
- `${.newline}---${.MAKE:T}[${.MAKE.PID}]' would produce tokens
- like
- ---make[1234] target ---
- making it easier to track the degree of parallelism being
- achieved.
-
- .MAKE.JOBS
- The argument to the -j option.
-
- .MAKE.JOBS.C
- A read-only boolean that indicates whether the -j option supports
- use of `C'.
-
- .MAKE.LEVEL
- The recursion depth of bmake. The top-level instance of bmake
- has level 0, and each child make has its parent level plus 1.
- This allows tests like: .if ${.MAKE.LEVEL} == 0 to protect things
- which should only be evaluated in the top-level instance of
- bmake.
-
- .MAKE.LEVEL.ENV
- The name of the environment variable that stores the level of
- nested calls to bmake.
-
- .MAKE.MAKEFILE_PREFERENCE
- The ordered list of makefile names (default `makefile',
- `Makefile') that bmake looks for.
-
- .MAKE.MAKEFILES
- The list of makefiles read by bmake, which is useful for tracking
- dependencies. Each makefile is recorded only once, regardless of
- the number of times read.
-
- .MAKE.META.BAILIWICK
- In "meta" mode, provides a list of prefixes which match the di-
- rectories controlled by bmake. If a file that was generated out-
- side of .OBJDIR but within said bailiwick is missing, the current
- target is considered out-of-date.
-
- .MAKE.META.CMP_FILTER
- In "meta" mode, it can (very rarely!) be useful to filter command
- lines before comparison. This variable can be set to a set of
- modifiers that are applied to each line of the old and new com-
- mand that differ, if the filtered commands still differ, the tar-
- get is considered out-of-date.
-
- .MAKE.META.CREATED
- In "meta" mode, this variable contains a list of all the meta
- files updated. If not empty, it can be used to trigger process-
- ing of .MAKE.META.FILES.
-
- .MAKE.META.FILES
- In "meta" mode, this variable contains a list of all the meta
- files used (updated or not). This list can be used to process
- the meta files to extract dependency information.
-
- .MAKE.META.IGNORE_FILTER
- Provides a list of variable modifiers to apply to each pathname.
- Ignore if the expansion is an empty string.
-
- .MAKE.META.IGNORE_PATHS
- Provides a list of path prefixes that should be ignored; because
- the contents are expected to change over time. The default list
- includes: `/dev /etc /proc /tmp /var/run /var/tmp'
-
- .MAKE.META.IGNORE_PATTERNS
- Provides a list of patterns to match against pathnames. Ignore
- any that match.
-
- .MAKE.META.PREFIX
- Defines the message printed for each meta file updated in "meta
- verbose" mode. The default value is:
- Building ${.TARGET:H:tA}/${.TARGET:T}
-
- .MAKE.MODE
- Processed after reading all makefiles. Affects the mode that
- bmake runs in. It can contain these keywords:
-
- compat Like -B, puts bmake into "compat" mode.
-
- meta Puts bmake into "meta" mode, where meta files are created
- for each target to capture the command run, the output
- generated, and if filemon(4) is available, the system
- calls which are of interest to bmake. The captured out-
- put can be useful when diagnosing errors.
-
- curdirOk=bf
- By default, bmake does not create .meta files in
- `.CURDIR'. This can be overridden by setting bf to a
- value which represents true.
-
- missing-meta=bf
- If bf is true, a missing .meta file makes the target out-
- of-date.
-
- missing-filemon=bf
- If bf is true, missing filemon data makes the target out-
- of-date.
-
- nofilemon
- Do not use filemon(4).
-
- env For debugging, it can be useful to include the environ-
- ment in the .meta file.
-
- verbose
- If in "meta" mode, print a clue about the target being
- built. This is useful if the build is otherwise running
- silently. The message printed is the expanded value of
- .MAKE.META.PREFIX.
-
- ignore-cmd
- Some makefiles have commands which are simply not stable.
- This keyword causes them to be ignored for determining
- whether a target is out of date in "meta" mode. See also
- .NOMETA_CMP.
-
- silent=bf
- If bf is true, when a .meta file is created, mark the
- target .SILENT.
-
- randomize-targets
- In both compat and parallel mode, do not make the targets
- in the usual order, but instead randomize their order.
- This mode can be used to detect undeclared dependencies
- between files.
-
- MAKEOBJDIR
- Used to create files in a separate directory, see .OBJDIR.
-
- MAKE_OBJDIR_CHECK_WRITABLE
- Used to force a separate directory for the created files, even if
- that directory is not writable, see .OBJDIR.
-
- MAKEOBJDIRPREFIX
- Used to create files in a separate directory, see .OBJDIR.
-
- .MAKE.OS
- The name of the operating system, see uname(1). It is read-only.
-
- .MAKEOVERRIDES
- This variable is used to record the names of variables assigned
- to on the command line, so that they may be exported as part of
- `MAKEFLAGS'. This behavior can be disabled by assigning an empty
- value to `.MAKEOVERRIDES' within a makefile. Extra variables can
- be exported from a makefile by appending their names to
- `.MAKEOVERRIDES'. `MAKEFLAGS' is re-exported whenever
- `.MAKEOVERRIDES' is modified.
-
- .MAKE.PATH_FILEMON
- If bmake was built with filemon(4) support, this is set to the
- path of the device node. This allows makefiles to test for this
- support.
-
- .MAKE.PID
- The process ID of bmake. It is read-only.
-
- .MAKE.PPID
- The parent process ID of bmake. It is read-only.
-
- MAKE_PRINT_VAR_ON_ERROR
- When bmake stops due to an error, it sets `.ERROR_TARGET' to the
- name of the target that failed, `.ERROR_CMD' to the commands of
- the failed target, and in "meta" mode, it also sets `.ERROR_CWD'
- to the getcwd(3), and `.ERROR_META_FILE' to the path of the meta
- file (if any) describing the failed target. It then prints its
- name and the value of `.CURDIR' as well as the value of any vari-
- ables named in `MAKE_PRINT_VAR_ON_ERROR'.
-
- .MAKE.SAVE_DOLLARS
- If true, `$$' are preserved when doing `:=' assignments. The de-
- fault is false, for backwards compatibility. Set to true for
- compatability with other makes. If set to false, `$$' becomes
- `$' per normal evaluation rules.
-
- .MAKE.TARGET_LOCAL_VARIABLES
- If set to `false', apparent variable assignments in dependency
- lines are treated as normal sources.
-
- .MAKE.UID
- The numeric ID of the user running bmake. It is read-only.
-
- .newline
- This variable is simply assigned a newline character as its
- value. It is read-only. This allows expansions using the :@
- modifier to put a newline between iterations of the loop rather
- than a space. For example, in case of an error, bmake prints the
- variable names and their values using:
- ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
-
- .OBJDIR
- A path to the directory where the targets are built. Its value
- is determined by trying to chdir(2) to the following directories
- in order and using the first match:
-
- 1. ${MAKEOBJDIRPREFIX}${.CURDIR}
-
- (Only if `MAKEOBJDIRPREFIX' is set in the environment or on
- the command line.)
-
- 2. ${MAKEOBJDIR}
-
- (Only if `MAKEOBJDIR' is set in the environment or on the
- command line.)
-
- 3. ${.CURDIR}/obj.${MACHINE}
-
- 4. ${.CURDIR}/obj
-
- 5. /usr/obj/${.CURDIR}
-
- 6. ${.CURDIR}
-
- Variable expansion is performed on the value before it is used,
- so expressions such as ${.CURDIR:S,^/usr/src,/var/obj,} may be
- used. This is especially useful with `MAKEOBJDIR'.
-
- `.OBJDIR' may be modified in the makefile via the special target
- `.OBJDIR'. In all cases, bmake changes to the specified direc-
- tory if it exists, and sets `.OBJDIR' and `PWD' to that directory
- before executing any targets.
-
- Except in the case of an explicit `.OBJDIR' target, bmake checks
- that the specified directory is writable and ignores it if not.
- This check can be skipped by setting the environment variable
- `MAKE_OBJDIR_CHECK_WRITABLE' to "no".
-
- .PARSEDIR
- The directory name of the current makefile being parsed.
-
- .PARSEFILE
- The basename of the current makefile being parsed. This variable
- and `.PARSEDIR' are both set only while the makefiles are being
- parsed. To retain their current values, assign them to a vari-
- able using assignment with expansion `:='.
-
- .PATH The space-separated list of directories that bmake searches for
- files. To update this search list, use the special target
- `.PATH' rather than modifying the variable directly.
-
- %POSIX Is set in POSIX mode, see the special `.POSIX' target.
-
- PWD Alternate path to the current directory. bmake normally sets
- `.CURDIR' to the canonical path given by getcwd(3). However, if
- the environment variable `PWD' is set and gives a path to the
- current directory, bmake sets `.CURDIR' to the value of `PWD' in-
- stead. This behavior is disabled if `MAKEOBJDIRPREFIX' is set or
- `MAKEOBJDIR' contains a variable transform. `PWD' is set to the
- value of `.OBJDIR' for all programs which bmake executes.
-
- .SHELL The pathname of the shell used to run target scripts. It is
- read-only.
-
- .SUFFIXES
- The list of known suffixes. It is read-only.
-
- .SYSPATH
- The space-separated list of directories that bmake searches for
- makefiles, referred to as the system include path. To update
- this search list, use the special target `.SYSPATH' rather than
- modifying the variable which is read-only.
-
- .TARGETS
- The list of targets explicitly specified on the command line, if
- any.
-
- VPATH The colon-separated (":") list of directories that bmake searches
- for files. This variable is supported for compatibility with old
- make programs only, use `.PATH' instead.
-
- Variable modifiers
- The general format of a variable expansion is:
-
- ${variable[:modifier[:...]]}
-
- Each modifier begins with a colon. To escape a colon, precede it with a
- backslash `\'.
-
- A list of indirect modifiers can be specified via a variable, as follows:
-
- modifier_variable = modifier[:...]
-
- ${variable:${modifier_variable}[:...]}
-
- In this case, the first modifier in the modifier_variable does not start
- with a colon, since that colon already occurs in the referencing vari-
- able. If any of the modifiers in the modifier_variable contains a dollar
- sign (`$'), these must be doubled to avoid early expansion.
-
- Some modifiers interpret the expression value as a single string, others
- treat the expression value as a whitespace-separated list of words. When
- splitting a string into words, whitespace can be escaped using double
- quotes, single quotes and backslashes, like in the shell. The quotes and
- backslashes are retained in the words.
-
- The supported modifiers are:
-
- :E Replaces each word with its suffix.
-
- :H Replaces each word with its dirname.
-
- :Mpattern
- Selects only those words that match pattern. The standard shell
- wildcard characters (`*', `?', and `[]') may be used. The wildcard
- characters may be escaped with a backslash (`\'). As a consequence
- of the way values are split into words, matched, and then joined,
- the construct `${VAR:M*}' removes all leading and trailing white-
- space and normalizes the inter-word spacing to a single space.
-
- :Npattern
- This is the opposite of `:M', selecting all words which do not match
- pattern.
-
- :O Orders the words lexicographically.
-
- :On Orders the words numerically. A number followed by one of `k', `M'
- or `G' is multiplied by the appropriate factor, which is 1024 for
- `k', 1048576 for `M', or 1073741824 for `G'. Both upper- and lower-
- case letters are accepted.
-
- :Or Orders the words in reverse lexicographical order.
-
- :Orn
- Orders the words in reverse numerical order.
-
- :Ox Shuffles the words. The results are different each time you are re-
- ferring to the modified variable; use the assignment with expansion
- `:=' to prevent such behavior. For example,
-
- LIST= uno due tre quattro
- RANDOM_LIST= ${LIST:Ox}
- STATIC_RANDOM_LIST:= ${LIST:Ox}
-
- all:
- @echo "${RANDOM_LIST}"
- @echo "${RANDOM_LIST}"
- @echo "${STATIC_RANDOM_LIST}"
- @echo "${STATIC_RANDOM_LIST}"
- may produce output similar to:
-
- quattro due tre uno
- tre due quattro uno
- due uno quattro tre
- due uno quattro tre
-
- :Q Quotes every shell meta-character in the value, so that it can be
- passed safely to the shell.
-
- :q Quotes every shell meta-character in the value, and also doubles `$'
- characters so that it can be passed safely through recursive invoca-
- tions of bmake. This is equivalent to `:S/\$/&&/g:Q'.
-
- :R Replaces each word with everything but its suffix.
-
- :range[=count]
- The value is an integer sequence representing the words of the orig-
- inal value, or the supplied count.
-
- :gmtime[=timestamp]
- The value is interpreted as a format string for strftime(3), using
- gmtime(3), producing the formatted timestamp. Note: the `%s' format
- should only be used with `:localtime'. If a timestamp value is not
- provided or is 0, the current time is used.
-
- :hash
- Computes a 32-bit hash of the value and encodes it as 8 hex digits.
-
- :localtime[=timestamp]
- The value is interpreted as a format string for strftime(3), using
- localtime(3), producing the formatted timestamp. If a timestamp
- value is not provided or is 0, the current time is used.
-
- :mtime[=timestamp]
- Call stat(2) with each word as pathname; use `st_mtime' as the new
- value. If stat(2) fails; use timestamp or current time. If
- timestamp is set to `error', then stat(2) failure will cause an er-
- ror.
-
- :tA Attempts to convert the value to an absolute path using realpath(3).
- If that fails, the value is unchanged.
-
- :tl Converts the value to lower-case letters.
-
- :tsc
- When joining the words after a modifier that treats the value as
- words, the words are normally separated by a space. This modifier
- changes the separator to the character c. If c is omitted, no sepa-
- rator is used. The common escapes (including octal numeric codes)
- work as expected.
-
- :tu Converts the value to upper-case letters.
-
- :tW Causes subsequent modifiers to treat the value as a single word
- (possibly containing embedded whitespace). See also `:[*]'.
-
- :tw Causes the value to be treated as a list of words. See also `:[@]'.
-
- :S/old_string/new_string/[1gW]
- Modifies the first occurrence of old_string in each word of the
- value, replacing it with new_string. If a `g' is appended to the
- last delimiter of the pattern, all occurrences in each word are re-
- placed. If a `1' is appended to the last delimiter of the pattern,
- only the first occurrence is affected. If a `W' is appended to the
- last delimiter of the pattern, the value is treated as a single
- word. If old_string begins with a caret (`^'), old_string is an-
- chored at the beginning of each word. If old_string ends with a
- dollar sign (`$'), it is anchored at the end of each word. Inside
- new_string, an ampersand (`&') is replaced by old_string (without
- the anchoring `^' or `$'). Any character may be used as the delim-
- iter for the parts of the modifier string. The anchoring, ampersand
- and delimiter characters can be escaped with a backslash (`\').
-
- Both old_string and new_string may contain nested expressions. To
- prevent a dollar sign from starting a nested expression, escape it
- with a backslash.
-
- :C/pattern/replacement/[1gW]
- The :C modifier works like the :S modifier except that the old and
- new strings, instead of being simple strings, are an extended regu-
- lar expression pattern (see regex(3)) and an ed(1)-style
- replacement. Normally, the first occurrence of the pattern pattern
- in each word of the value is substituted with replacement. The `1'
- modifier causes the substitution to apply to at most one word; the
- `g' modifier causes the substitution to apply to as many instances
- of the search pattern pattern as occur in the word or words it is
- found in; the `W' modifier causes the value to be treated as a sin-
- gle word (possibly containing embedded whitespace).
-
- As for the :S modifier, the pattern and replacement are subjected to
- variable expansion before being parsed as regular expressions.
-
- :T Replaces each word with its last path component (basename).
-
- :u Removes adjacent duplicate words (like uniq(1)).
-
- :?true_string:false_string
- If the variable name (not its value), when parsed as a .if condi-
- tional expression, evaluates to true, return as its value the
- true_string, otherwise return the false_string. Since the variable
- name is used as the expression, :? must be the first modifier after
- the variable name itself--which, of course, usually contains vari-
- able expansions. A common error is trying to use expressions like
- ${NUMBERS:M42:?match:no}
- which actually tests defined(NUMBERS). To determine if any words
- match "42", you need to use something like:
- ${"${NUMBERS:M42}" != "":?match:no}.
-
- :old_string=new_string
- This is the AT&T System V UNIX style substitution. It can only be
- the last modifier specified, as a `:' in either old_string or
- new_string is treated as a regular character, not as the end of the
- modifier.
-
- If old_string does not contain the pattern matching character `%',
- and the word ends with old_string or equals it, that suffix is re-
- placed with new_string.
-
- Otherwise, the first `%' in old_string matches a possibly empty sub-
- string of arbitrary characters, and if the whole pattern is found in
- the word, the matching part is replaced with new_string, and the
- first occurrence of `%' in new_string (if any) is replaced with the
- substring matched by the `%'.
-
- Both old_string and new_string may contain nested expressions. To
- prevent a dollar sign from starting a nested expression, escape it
- with a backslash.
-
- :@varname@string@
- This is the loop expansion mechanism from the OSF Development Envi-
- ronment (ODE) make. Unlike .for loops, expansion occurs at the time
- of reference. For each word in the value, assign the word to the
- variable named varname and evaluate string. The ODE convention is
- that varname should start and end with a period, for example:
- ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@}
-
- However, a single-letter variable is often more readable:
- ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
-
- :_[=var]
- Saves the current variable value in `$_' or the named var for later
- reference. Example usage:
-
- M_cmpv.units = 1 1000 1000000
- M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \
- \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
-
- .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
-
- Here `$_' is used to save the result of the `:S' modifier which is
- later referenced using the index values from `:range'.
-
- :Unewval
- If the variable is undefined, newval is the value. If the variable
- is defined, the existing value is returned. This is another ODE
- make feature. It is handy for setting per-target CFLAGS for in-
- stance:
- ${_${.TARGET:T}_CFLAGS:U${DEF_CFLAGS}}
- If a value is only required if the variable is undefined, use:
- ${VAR:D:Unewval}
-
- :Dnewval
- If the variable is defined, newval is the value.
-
- :L The name of the variable is the value.
-
- :P The path of the node which has the same name as the variable is the
- value. If no such node exists or its path is null, the name of the
- variable is used. In order for this modifier to work, the name
- (node) must at least have appeared on the right-hand side of a de-
- pendency.
-
- :!cmd!
- The output of running cmd is the value.
-
- :sh The value is run as a command, and the output becomes the new value.
-
- ::=str
- The variable is assigned the value str after substitution. This
- modifier and its variations are useful in obscure situations such as
- wanting to set a variable at a point where a target's shell commands
- are being parsed. These assignment modifiers always expand to noth-
- ing.
-
- The `::' helps avoid false matches with the AT&T System V UNIX style
- `:=' modifier and since substitution always occurs, the `::=' form
- is vaguely appropriate.
-
- ::?=str
- As for ::= but only if the variable does not already have a value.
-
- ::+=str
- Append str to the variable.
-
- ::!=cmd
- Assign the output of cmd to the variable.
-
- :[range]
- Selects one or more words from the value, or performs other opera-
- tions related to the way in which the value is split into words.
-
- An empty value, or a value that consists entirely of white-space, is
- treated as a single word. For the purposes of the `:[]' modifier,
- the words are indexed both forwards using positive integers (where
- index 1 represents the first word), and backwards using negative in-
- tegers (where index -1 represents the last word).
-
- The range is subjected to variable expansion, and the expanded re-
- sult is then interpreted as follows:
-
- index Selects a single word from the value.
-
- start..end
- Selects all words from start to end, inclusive. For example,
- `:[2..-1]' selects all words from the second word to the last
- word. If start is greater than end, the words are output in
- reverse order. For example, `:[-1..1]' selects all the words
- from last to first. If the list is already ordered, this ef-
- fectively reverses the list, but it is more efficient to use
- `:Or' instead of `:O:[-1..1]'.
-
- * Causes subsequent modifiers to treat the value as a single
- word (possibly containing embedded whitespace). Analogous to
- the effect of $* in Bourne shell.
-
- 0 Means the same as `:[*]'.
-
- @ Causes subsequent modifiers to treat the value as a sequence
- of words delimited by whitespace. Analogous to the effect of
- $@ in Bourne shell.
-
- # Returns the number of words in the value.
-
-DIRECTIVES
- bmake offers directives for including makefiles, conditionals and for
- loops. All these directives are identified by a line beginning with a
- single dot (`.') character, followed by the keyword of the directive,
- such as include or if.
-
- File inclusion
- Files are included with either .include <file> or .include "file". Vari-
- ables between the angle brackets or double quotes are expanded to form
- the file name. If angle brackets are used, the included makefile is ex-
- pected to be in the system makefile directory. If double quotes are
- used, the including makefile's directory and any directories specified
- using the -I option are searched before the system makefile directory.
-
- For compatibility with other make variants, `include file ...' (without
- leading dot) is also accepted.
-
- If the include statement is written as .-include or as .sinclude, errors
- locating and/or opening include files are ignored.
-
- If the include statement is written as .dinclude, not only are errors lo-
- cating and/or opening include files ignored, but stale dependencies
- within the included file are ignored just like in .MAKE.DEPENDFILE.
-
- Exporting variables
- The directives for exporting and unexporting variables are:
-
- .export variable ...
- Export the specified global variable. If no variable list is
- provided, all globals are exported except for internal variables
- (those that start with `.'). This is not affected by the -X
- flag, so should be used with caution. For compatibility with
- other make programs, export variable=value (without leading dot)
- is also accepted.
-
- Appending a variable name to .MAKE.EXPORTED is equivalent to ex-
- porting a variable.
-
- .export-env variable ...
- The same as `.export', except that the variable is not appended
- to .MAKE.EXPORTED. This allows exporting a value to the environ-
- ment which is different from that used by bmake internally.
-
- .export-literal variable ...
- The same as `.export-env', except that variables in the value are
- not expanded.
-
- .unexport variable ...
- The opposite of `.export'. The specified global variable is re-
- moved from .MAKE.EXPORTED. If no variable list is provided, all
- globals are unexported, and .MAKE.EXPORTED deleted.
-
- .unexport-env
- Unexport all globals previously exported and clear the environ-
- ment inherited from the parent. This operation causes a memory
- leak of the original environment, so should be used sparingly.
- Testing for .MAKE.LEVEL being 0 would make sense. Also note that
- any variables which originated in the parent environment should
- be explicitly preserved if desired. For example:
-
- .if ${.MAKE.LEVEL} == 0
- PATH := ${PATH}
- .unexport-env
- .export PATH
- .endif
-
- Would result in an environment containing only `PATH', which is
- the minimal useful environment. Actually `.MAKE.LEVEL' is also
- pushed into the new environment.
-
- Messages
- The directives for printing messages to the output are:
-
- .info message
- The message is printed along with the name of the makefile and
- line number.
-
- .warning message
- The message prefixed by `warning:' is printed along with the name
- of the makefile and line number.
-
- .error message
- The message is printed along with the name of the makefile and
- line number, bmake exits immediately.
-
- Conditionals
- The directives for conditionals are:
-
- .if [!]expression [operator expression ...]
- Test the value of an expression.
-
- .ifdef [!]variable [operator variable ...]
- Test whether a variable is defined.
-
- .ifndef [!]variable [operator variable ...]
- Test whether a variable is not defined.
-
- .ifmake [!]target [operator target ...]
- Test the target being requested.
-
- .ifnmake [!]target [operator target ...]
- Test the target being requested.
-
- .else Reverse the sense of the last conditional.
-
- .elif [!]expression [operator expression ...]
- A combination of `.else' followed by `.if'.
-
- .elifdef [!]variable [operator variable ...]
- A combination of `.else' followed by `.ifdef'.
-
- .elifndef [!]variable [operator variable ...]
- A combination of `.else' followed by `.ifndef'.
-
- .elifmake [!]target [operator target ...]
- A combination of `.else' followed by `.ifmake'.
-
- .elifnmake [!]target [operator target ...]
- A combination of `.else' followed by `.ifnmake'.
-
- .endif End the body of the conditional.
-
- The operator may be any one of the following:
-
- || Logical OR.
-
- && Logical AND; of higher precedence than `||'.
-
- bmake only evaluates a conditional as far as is necessary to determine
- its value. Parentheses can be used to override the operator precedence.
- The boolean operator `!' may be used to logically negate an expression,
- typically a function call. It is of higher precedence than `&&'.
-
- The value of expression may be any of the following function call expres-
- sions:
-
- defined(varname)
- Evaluates to true if the variable varname has been defined.
-
- make(target)
- Evaluates to true if the target was specified as part of bmake's
- command line or was declared the default target (either implic-
- itly or explicitly, see .MAIN) before the line containing the
- conditional.
-
- empty(varname[:modifiers])
- Evaluates to true if the expansion of the variable, after apply-
- ing the modifiers, results in an empty string.
-
- exists(pathname)
- Evaluates to true if the given pathname exists. If relative, the
- pathname is searched for on the system search path (see .PATH).
-
- target(target)
- Evaluates to true if the target has been defined.
-
- commands(target)
- Evaluates to true if the target has been defined and has commands
- associated with it.
-
- Expression may also be an arithmetic or string comparison. Variable ex-
- pansion is performed on both sides of the comparison. If both sides are
- numeric and neither is enclosed in quotes, the comparison is done numeri-
- cally, otherwise lexicographically. A string is interpreted as a hexa-
- decimal integer if it is preceded by 0x, otherwise it is interpreted as a
- decimal floating-point number; octal numbers are not supported.
-
- All comparisons may use the operators `==' and `!='. Numeric comparisons
- may also use the operators `<', `<=', `>' and `>='.
-
- If the comparison has neither a comparison operator nor a right side, the
- expression evaluates to true if it is nonempty and its numeric value (if
- any) is not zero.
-
- When bmake is evaluating one of these conditional expressions, and it en-
- counters a (whitespace-separated) word it doesn't recognize, either the
- "make" or "defined" function is applied to it, depending on the form of
- the conditional. If the form is `.ifdef', `.ifndef' or `.if', the
- "defined" function is applied. Similarly, if the form is `.ifmake' or
- `.ifnmake', the "make" function is applied.
-
- If the conditional evaluates to true, parsing of the makefile continues
- as before. If it evaluates to false, the following lines until the cor-
- responding `.elif' variant, `.else' or `.endif' are skipped.
-
- For loops
- For loops are typically used to apply a set of rules to a list of files.
- The syntax of a for loop is:
-
- .for variable [variable ...] in expression
- <make-lines>
- .endfor
-
- The expression is expanded and then split into words. On each iteration
- of the loop, one word is taken and assigned to each variable, in order,
- and these variables are substituted into the make-lines inside the body
- of the for loop. The number of words must come out even; that is, if
- there are three iteration variables, the number of words provided must be
- a multiple of three.
-
- If `.break' is encountered within a .for loop, it causes early termina-
- tion of the loop, otherwise a parse error.
-
- Other directives
- .undef variable ...
- Un-define the specified global variables. Only global variables
- can be un-defined.
-
-COMMENTS
- Comments begin with a hash (`#') character, anywhere but in a shell com-
- mand line, and continue to the end of an unescaped new line.
-
-SPECIAL SOURCES (ATTRIBUTES)
- .EXEC Target is never out of date, but always execute commands any-
- way.
-
- .IGNORE Ignore any errors from the commands associated with this tar-
- get, exactly as if they all were preceded by a dash (`-').
-
- .MADE Mark all sources of this target as being up to date.
-
- .MAKE Execute the commands associated with this target even if the -n
- or -t options were specified. Normally used to mark recursive
- bmakes.
-
- .META Create a meta file for the target, even if it is flagged as
- .PHONY, .MAKE, or .SPECIAL. Usage in conjunction with .MAKE is
- the most likely case. In "meta" mode, the target is out-of-
- date if the meta file is missing.
-
- .NOMETA Do not create a meta file for the target. Meta files are also
- not created for .PHONY, .MAKE, or .SPECIAL targets.
-
- .NOMETA_CMP
- Ignore differences in commands when deciding if target is out
- of date. This is useful if the command contains a value which
- always changes. If the number of commands change, though, the
- target is still considered out of date. The same effect ap-
- plies to any command line that uses the variable .OODATE, which
- can be used for that purpose even when not otherwise needed or
- desired:
-
-
- skip-compare-for-some:
- @echo this is compared
- @echo this is not ${.OODATE:M.NOMETA_CMP}
- @echo this is also compared
-
- The :M pattern suppresses any expansion of the unwanted vari-
- able.
-
- .NOPATH Do not search for the target in the directories specified by
- .PATH.
-
- .NOTMAIN Normally bmake selects the first target it encounters as the
- default target to be built if no target was specified. This
- source prevents this target from being selected.
-
- .OPTIONAL
- If a target is marked with this attribute and bmake can't fig-
- ure out how to create it, it ignores this fact and assumes the
- file isn't needed or already exists.
-
- .PHONY The target does not correspond to an actual file; it is always
- considered to be out of date, and is not created with the -t
- option. Suffix-transformation rules are not applied to .PHONY
- targets.
-
- .PRECIOUS
- When bmake is interrupted, it normally removes any partially
- made targets. This source prevents the target from being re-
- moved.
-
- .RECURSIVE
- Synonym for .MAKE.
-
- .SILENT Do not echo any of the commands associated with this target,
- exactly as if they all were preceded by an at sign (`@').
-
- .USE Turn the target into bmake's version of a macro. When the tar-
- get is used as a source for another target, the other target
- acquires the commands, sources, and attributes (except for
- .USE) of the source. If the target already has commands, the
- .USE target's commands are appended to them.
-
- .USEBEFORE
- Like .USE, but instead of appending, prepend the .USEBEFORE
- target commands to the target.
-
- .WAIT If .WAIT appears in a dependency line, the sources that precede
- it are made before the sources that succeed it in the line.
- Since the dependents of files are not made until the file it-
- self could be made, this also stops the dependents being built
- unless they are needed for another branch of the dependency
- tree. So given:
-
- x: a .WAIT b
- echo x
- a:
- echo a
- b: b1
- echo b
- b1:
- echo b1
-
- the output is always `a', `b1', `b', `x'.
-
- The ordering imposed by .WAIT is only relevant for parallel
- makes.
-
-SPECIAL TARGETS
- Special targets may not be included with other targets, i.e. they must be
- the only target specified.
-
- .BEGIN Any command lines attached to this target are executed before
- anything else is done.
-
- .DEFAULT
- This is sort of a .USE rule for any target (that was used only
- as a source) that bmake can't figure out any other way to cre-
- ate. Only the shell script is used. The .IMPSRC variable of a
- target that inherits .DEFAULT's commands is set to the target's
- own name.
-
- .DELETE_ON_ERROR
- If this target is present in the makefile, it globally causes
- make to delete targets whose commands fail. (By default, only
- targets whose commands are interrupted during execution are
- deleted. This is the historical behavior.) This setting can be
- used to help prevent half-finished or malformed targets from be-
- ing left around and corrupting future rebuilds.
-
- .END Any command lines attached to this target are executed after ev-
- erything else is done successfully.
-
- .ERROR Any command lines attached to this target are executed when an-
- other target fails. The .ERROR_TARGET variable is set to the
- target that failed. See also MAKE_PRINT_VAR_ON_ERROR.
-
- .IGNORE Mark each of the sources with the .IGNORE attribute. If no
- sources are specified, this is the equivalent of specifying the
- -i option.
-
- .INTERRUPT
- If bmake is interrupted, the commands for this target are exe-
- cuted.
-
- .MAIN If no target is specified when bmake is invoked, this target is
- built.
-
- .MAKEFLAGS
- This target provides a way to specify flags for bmake at the
- time when the makefiles are read. The flags are as if typed to
- the shell, though the -f option has no effect.
-
- .NOPATH Apply the .NOPATH attribute to any specified sources.
-
- .NOTPARALLEL
- Disable parallel mode.
-
- .NO_PARALLEL
- Synonym for .NOTPARALLEL, for compatibility with other pmake
- variants.
-
- .NOREADONLY
- clear the read-only attribute from the global variables speci-
- fied as sources.
-
- .OBJDIR The source is a new value for `.OBJDIR'. If it exists, bmake
- changes the current working directory to it and updates the
- value of `.OBJDIR'.
-
- .ORDER In parallel mode, the named targets are made in sequence. This
- ordering does not add targets to the list of targets to be made.
-
- Since the dependents of a target do not get built until the tar-
- get itself could be built, unless `a' is built by another part
- of the dependency graph, the following is a dependency loop:
-
- .ORDER: b a
- b: a
-
- .PATH The sources are directories which are to be searched for files
- not found in the current directory. If no sources are speci-
- fied, any previously specified directories are removed from the
- search path. If the source is the special .DOTLAST target, the
- current working directory is searched last.
-
- .PATH.suffix
- Like .PATH but applies only to files with a particular suffix.
- The suffix must have been previously declared with .SUFFIXES.
-
- .PHONY Apply the .PHONY attribute to any specified sources.
-
- .POSIX If this is the first non-comment line in the main makefile, the
- variable %POSIX is set to the value `1003.2' and the makefile
- `<posix.mk>' is included if it exists, to provide POSIX-compati-
- ble default rules. If bmake is run with the -r flag, only
- `posix.mk' contributes to the default rules.
-
- .PRECIOUS
- Apply the .PRECIOUS attribute to any specified sources. If no
- sources are specified, the .PRECIOUS attribute is applied to ev-
- ery target in the file.
-
- .READONLY
- set the read-only attribute on the global variables specified as
- sources.
-
- .SHELL Sets the shell that bmake uses to execute commands. The sources
- are a set of field=value pairs.
-
- name This is the minimal specification, used to select
- one of the built-in shell specs; sh, ksh, and csh.
-
- path Specifies the absolute path to the shell.
-
- hasErrCtl Indicates whether the shell supports exit on error.
-
- check The command to turn on error checking.
-
- ignore The command to disable error checking.
-
- echo The command to turn on echoing of commands executed.
-
- quiet The command to turn off echoing of commands exe-
- cuted.
-
- filter The output to filter after issuing the quiet com-
- mand. It is typically identical to quiet.
-
- errFlag The flag to pass the shell to enable error checking.
-
- echoFlag The flag to pass the shell to enable command echo-
- ing.
-
- newline The string literal to pass the shell that results in
- a single newline character when used outside of any
- quoting characters.
- Example:
-
- .SHELL: name=ksh path=/bin/ksh hasErrCtl=true \
- check="set -e" ignore="set +e" \
- echo="set -v" quiet="set +v" filter="set +v" \
- echoFlag=v errFlag=e newline="'\n'"
-
- .SILENT Apply the .SILENT attribute to any specified sources. If no
- sources are specified, the .SILENT attribute is applied to every
- command in the file.
-
- .STALE This target gets run when a dependency file contains stale en-
- tries, having .ALLSRC set to the name of that dependency file.
-
- .SUFFIXES
- Each source specifies a suffix to bmake. If no sources are
- specified, any previously specified suffixes are deleted. It
- allows the creation of suffix-transformation rules.
-
- Example:
-
- .SUFFIXES: .c .o
- .c.o:
- cc -o ${.TARGET} -c ${.IMPSRC}
-
- .SYSPATH
- The sources are directories which are to be added to the system
- include path which bmake searches for makefiles. If no sources
- are specified, any previously specified directories are removed
- from the system include path.
-
-ENVIRONMENT
- bmake uses the following environment variables, if they exist: MACHINE,
- MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX, MAKESYSPATH,
- PWD, and TMPDIR.
-
- MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on
- the command line to bmake and not as makefile variables; see the descrip-
- tion of `.OBJDIR' for more details.
-
-FILES
- .depend list of dependencies
- makefile first default makefile if no makefile is specified on the
- command line
- Makefile second default makefile if no makefile is specified on the
- command line
- sys.mk system makefile
- /usr/share/mk system makefile directory
-
-COMPATIBILITY
- The basic make syntax is compatible between different make variants; how-
- ever the special variables, variable modifiers and conditionals are not.
-
- Older versions
- An incomplete list of changes in older versions of bmake:
-
- The way that .for loop variables are substituted changed after NetBSD 5.0
- so that they still appear to be variable expansions. In particular this
- stops them being treated as syntax, and removes some obscure problems us-
- ing them in .if statements.
-
- The way that parallel makes are scheduled changed in NetBSD 4.0 so that
- .ORDER and .WAIT apply recursively to the dependent nodes. The algo-
- rithms used may change again in the future.
-
- Other make dialects
- Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not sup-
- port most of the features of bmake as described in this manual. Most no-
- tably:
-
- +o The .WAIT and .ORDER declarations and most functionality per-
- taining to parallelization. (GNU make supports parallelization
- but lacks the features needed to control it effectively.)
-
- +o Directives, including for loops and conditionals and most of
- the forms of include files. (GNU make has its own incompatible
- and less powerful syntax for conditionals.)
-
- +o All built-in variables that begin with a dot.
-
- +o Most of the special sources and targets that begin with a dot,
- with the notable exception of .PHONY, .PRECIOUS, and .SUFFIXES.
-
- +o Variable modifiers, except for the `:old=new' string substitu-
- tion, which does not portably support globbing with `%' and
- historically only works on declared suffixes.
-
- +o The $> variable even in its short form; most makes support this
- functionality but its name varies.
-
- Some features are somewhat more portable, such as assignment with +=, ?=,
- and !=. The .PATH functionality is based on an older feature VPATH found
- in GNU make and many versions of SVR4 make; however, historically its be-
- havior is too ill-defined (and too buggy) to rely upon.
-
- The $@ and $< variables are more or less universally portable, as is the
- $(MAKE) variable. Basic use of suffix rules (for files only in the cur-
- rent directory, not trying to chain transformations together, etc.) is
- also reasonably portable.
-
-SEE ALSO
- mkdep(1)
-
-HISTORY
- bmake is derived from NetBSD make(1). It uses autoconf to facilitate
- portability to other platforms.
-
- A make command appeared in Version 7 AT&T UNIX. This make implementation
- is based on Adam de Boor's pmake program, which was written for Sprite at
- Berkeley. It was designed to be a parallel distributed make running jobs
- on different machines using a daemon called "customs".
-
- Historically the target/dependency FRC has been used to FoRCe rebuilding
- (since the target/dependency does not exist ... unless someone creates an
- FRC file).
-
-BUGS
- The make syntax is difficult to parse. For instance, finding the end of
- a variable's use should involve scanning each of the modifiers, using the
- correct terminator for each field. In many places make just counts {}
- and () in order to find the end of a variable expansion.
-
- There is no way of escaping a space character in a filename.
-
- In jobs mode, when a target fails; make will put an error token into the
- job token pool. This will cause all other instances of make using that
- token pool to abort the build and exit with error code 6. Sometimes the
- attempt to suppress a cascade of unnecessary errors, can result in a
- seemingly unexplained `*** Error code 6'
-
-FreeBSD 13.0 December 24, 2023 FreeBSD 13.0
diff --git a/contrib/bmake/boot-strap b/contrib/bmake/boot-strap
index 00fa04a0e08b..b025de52a82b 100755
--- a/contrib/bmake/boot-strap
+++ b/contrib/bmake/boot-strap
@@ -133,7 +133,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: boot-strap,v 1.59 2023/11/26 18:19:43 sjg Exp $
+# $Id: boot-strap,v 1.61 2024/03/10 17:51:10 sjg Exp $
#
# @(#) Copyright (c) 2001 Simon J. Gerraty
#
@@ -329,6 +329,14 @@ FindHereOrAbove() {
)
}
+# is $1 newer than $2 ...
+is_newer() {
+ case `'ls' -1td "$@" 2> /dev/null | head -1` in
+ $1) return 0;;
+ esac
+ return 1
+}
+
# is $1 missing from $2 (or PATH) ?
no_path() {
eval "__p=\$${2:-PATH}"
@@ -428,13 +436,18 @@ op_build() {
chmod 755 make-bootstrap.sh || exit 1
./make-bootstrap.sh || exit 1
case "$op" in
- build) op_test;;
+ build) rm -f tested; op_test;;
esac
}
op_test() {
[ -x bmake ] || op_build
+ case "$op" in
+ test) ;;
+ *) is_newer bmake tested || return;;
+ esac
Bmake test TEST_MAKE=$objdir/bmake "$@" || exit 1
+ touch tested
}
op_clean() {
diff --git a/contrib/bmake/compat.c b/contrib/bmake/compat.c
index 6f55880cbc54..05c6ea0e7ec8 100644
--- a/contrib/bmake/compat.c
+++ b/contrib/bmake/compat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $ */
+/* $NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
#include "pathnames.h"
/* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 sjg Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -329,7 +329,7 @@ Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln)
meta_compat_start();
#endif
- Var_ReexportVars();
+ Var_ReexportVars(gn);
compatChild = cpid = vfork();
if (cpid < 0)
@@ -393,6 +393,8 @@ Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln)
meta_job_error(NULL, gn, false, status);
#endif
gn->made = ERROR;
+ if (WIFEXITED(reason))
+ gn->exit_status = status;
if (opts.keepgoing) {
/*
* Abort the current target,
diff --git a/contrib/bmake/cond.c b/contrib/bmake/cond.c
index 843abc9a92f8..f8d31fc9c160 100644
--- a/contrib/bmake/cond.c
+++ b/contrib/bmake/cond.c
@@ -1,4 +1,4 @@
-/* $NetBSD: cond.c,v 1.359 2023/12/29 12:59:43 rillig Exp $ */
+/* $NetBSD: cond.c,v 1.362 2024/02/07 07:21:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
#include "dir.h"
/* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: cond.c,v 1.359 2023/12/29 12:59:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.362 2024/02/07 07:21:22 rillig Exp $");
/*
* Conditional expressions conform to this grammar:
@@ -394,7 +394,7 @@ CondParser_StringExpr(CondParser *par, const char *start,
{
VarEvalMode emode;
const char *p;
- bool atStart;
+ bool atStart; /* true means an expression outside quotes */
emode = doEval && quoted ? VARE_WANTRES
: doEval ? VARE_UNDEFERR
@@ -411,11 +411,6 @@ CondParser_StringExpr(CondParser *par, const char *start,
}
par->p = p;
- /*
- * If the '$' started the string literal (which means no quotes), and
- * the expression is followed by a space, a comparison operator or
- * the end of the expression, we are done.
- */
if (atStart && is_separator(par->p[0]))
return false;
@@ -509,26 +504,12 @@ EvalTruthy(CondParser *par, const char *value, bool quoted)
{
double num;
- /* For .ifxxx "...", check for non-empty string. */
if (quoted)
return value[0] != '\0';
-
- /* For .ifxxx <number>, compare against zero */
if (TryParseNumber(value, &num))
return num != 0.0;
-
- /*
- * For .if ${...}, check for non-empty string. This is different
- * from the evaluation function from that .if variant, which would
- * test whether a variable of the given name were defined.
- */
- /*
- * XXX: Whitespace should count as empty, just as in
- * CondParser_FuncCallEmpty.
- */
if (par->plain)
return value[0] != '\0';
-
return par->evalBare(value) != par->negateEvalBare;
}
@@ -867,12 +848,13 @@ CondParser_Term(CondParser *par, bool doEval)
{
CondResult res;
Token t;
+ bool neg = false;
- t = CondParser_Token(par, doEval);
- if (t == TOK_TRUE)
- return CR_TRUE;
- if (t == TOK_FALSE)
- return CR_FALSE;
+ while ((t = CondParser_Token(par, doEval)) == TOK_NOT)
+ neg = !neg;
+
+ if (t == TOK_TRUE || t == TOK_FALSE)
+ return neg == (t == TOK_FALSE) ? CR_TRUE : CR_FALSE;
if (t == TOK_LPAREN) {
res = CondParser_Or(par, doEval);
@@ -880,16 +862,7 @@ CondParser_Term(CondParser *par, bool doEval)
return CR_ERROR;
if (CondParser_Token(par, doEval) != TOK_RPAREN)
return CR_ERROR;
- return res;
- }
-
- if (t == TOK_NOT) {
- res = CondParser_Term(par, doEval);
- if (res == CR_TRUE)
- res = CR_FALSE;
- else if (res == CR_FALSE)
- res = CR_TRUE;
- return res;
+ return neg == (res == CR_FALSE) ? CR_TRUE : CR_FALSE;
}
return CR_ERROR;
@@ -937,20 +910,6 @@ CondParser_Or(CondParser *par, bool doEval)
return res;
}
-static CondResult
-CondParser_Eval(CondParser *par)
-{
- CondResult res;
-
- DEBUG1(COND, "CondParser_Eval: %s\n", par->p);
-
- res = CondParser_Or(par, true);
- if (res != CR_ERROR && CondParser_Token(par, false) != TOK_EOF)
- return CR_ERROR;
-
- return res;
-}
-
/*
* Evaluate the condition, including any side effects from the
* expressions in the condition. The condition consists of &&, ||, !,
@@ -974,7 +933,10 @@ CondEvalExpression(const char *cond, bool plain,
par.curr = TOK_NONE;
par.printedError = false;
- rval = CondParser_Eval(&par);
+ DEBUG1(COND, "CondParser_Eval: %s\n", par.p);
+ rval = CondParser_Or(&par, true);
+ if (par.curr != TOK_EOF)
+ rval = CR_ERROR;
if (rval == CR_ERROR && eprint && !par.printedError)
Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond);
diff --git a/contrib/bmake/config.h.in b/contrib/bmake/config.h.in
index 85fc10cf30b6..3834761a6b87 100644
--- a/contrib/bmake/config.h.in
+++ b/contrib/bmake/config.h.in
@@ -95,6 +95,9 @@
/* Define to 1 if you have the `realpath' function. */
#undef HAVE_REALPATH
+/* Define to 1 if you have the <regex.h> header file. */
+#undef HAVE_REGEX_H
+
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
diff --git a/contrib/bmake/configure b/contrib/bmake/configure
index 2898a27bb98e..0b4084b26ed4 100755
--- a/contrib/bmake/configure
+++ b/contrib/bmake/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.71 for bmake 20240101.
+# Generated by GNU Autoconf 2.71 for bmake 20240212.
#
# Report bugs to <sjg@NetBSD.org>.
#
@@ -610,8 +610,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bmake'
PACKAGE_TARNAME='bmake'
-PACKAGE_VERSION='20240101'
-PACKAGE_STRING='bmake 20240101'
+PACKAGE_VERSION='20240212'
+PACKAGE_STRING='bmake 20240212'
PACKAGE_BUGREPORT='sjg@NetBSD.org'
PACKAGE_URL=''
@@ -1291,7 +1291,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures bmake 20240101 to adapt to many kinds of systems.
+\`configure' configures bmake 20240212 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1353,7 +1353,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of bmake 20240101:";;
+ short | recursive ) echo "Configuration of bmake 20240212:";;
esac
cat <<\_ACEOF
@@ -1463,7 +1463,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-bmake configure 20240101
+bmake configure 20240212
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1970,7 +1970,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by bmake $as_me 20240101, which was
+It was created by bmake $as_me 20240212, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
@@ -5214,6 +5214,12 @@ then :
printf "%s\n" "#define HAVE_RANLIB_H 1" >>confdefs.h
fi
+ac_fn_c_check_header_compile "$LINENO" "regex.h" "ac_cv_header_regex_h" "$ac_includes_default"
+if test "x$ac_cv_header_regex_h" = xyes
+then :
+ printf "%s\n" "#define HAVE_REGEX_H 1" >>confdefs.h
+
+fi
ac_fn_c_check_header_compile "$LINENO" "sys/mman.h" "ac_cv_header_sys_mman_h" "$ac_includes_default"
if test "x$ac_cv_header_sys_mman_h" = xyes
then :
@@ -7588,7 +7594,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by bmake $as_me 20240101, which was
+This file was extended by bmake $as_me 20240212, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7652,7 +7658,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
-bmake config.status 20240101
+bmake config.status 20240212
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
diff --git a/contrib/bmake/configure.in b/contrib/bmake/configure.in
index ad652e53024b..7979a0c0bb5c 100644
--- a/contrib/bmake/configure.in
+++ b/contrib/bmake/configure.in
@@ -1,11 +1,11 @@
dnl
dnl RCSid:
-dnl $Id: configure.in,v 1.101 2024/01/04 23:04:07 sjg Exp $
+dnl $Id: configure.in,v 1.103 2024/02/16 17:54:38 sjg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
AC_PREREQ([2.71])
-AC_INIT([bmake],[20240101],[sjg@NetBSD.org])
+AC_INIT([bmake],[20240212],[sjg@NetBSD.org])
AC_CONFIG_HEADERS(config.h)
dnl make srcdir absolute
@@ -250,6 +250,7 @@ AC_CHECK_HEADERS( \
paths.h \
poll.h \
ranlib.h \
+ regex.h \
sys/mman.h \
sys/select.h \
sys/socket.h \
diff --git a/contrib/bmake/for.c b/contrib/bmake/for.c
index b8e8099816b0..a995caa6be70 100644
--- a/contrib/bmake/for.c
+++ b/contrib/bmake/for.c
@@ -1,4 +1,4 @@
-/* $NetBSD: for.c,v 1.177 2023/11/19 22:50:11 rillig Exp $ */
+/* $NetBSD: for.c,v 1.178 2024/01/21 15:02:17 rillig Exp $ */
/*
* Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
#include "make.h"
/* "@(#)for.c 8.1 (Berkeley) 6/6/93" */
-MAKE_RCSID("$NetBSD: for.c,v 1.177 2023/11/19 22:50:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.178 2024/01/21 15:02:17 rillig Exp $");
typedef struct ForLoop {
@@ -434,7 +434,7 @@ static void
ForLoop_SubstVarShort(ForLoop *f, unsigned int firstItem, Buffer *body,
const char *p, const char **inout_mark)
{
- const char ch = *p;
+ char ch = *p;
const char **vars;
size_t i;
diff --git a/contrib/bmake/import.sh b/contrib/bmake/import.sh
index 7295a9a982d5..c409dcfe869e 100755
--- a/contrib/bmake/import.sh
+++ b/contrib/bmake/import.sh
@@ -86,12 +86,14 @@ post=$SB/tmp/bmake-post.sh
# this is similar to what generates the mail to bmake-announce
gen_import_F() {
echo Import bmake-$VERSION
+ echo
if [ -s $post ]; then
last=`sed -n '/ tag/s,.*/,bmake-,p' $post`
else
last="last import"
fi
+ echo Intersting/relevant changes since $last; echo
for C in ChangeLog */ChangeLog
do
$GIT diff --staged $C |
diff --git a/contrib/bmake/install-sh b/contrib/bmake/install-sh
index 1fa52a59de7e..aa35fa94c83a 100755
--- a/contrib/bmake/install-sh
+++ b/contrib/bmake/install-sh
@@ -53,8 +53,10 @@
# Simon J. Gerraty <sjg@crufty.net>
#
+# SPDX-License-Identifier: BSD-2-Clause
+#
# RCSid:
-# $Id: install-sh,v 1.25 2023/07/15 05:33:38 sjg Exp $
+# $Id: install-sh,v 1.26 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 1993-2023 Simon J. Gerraty
#
diff --git a/contrib/bmake/job.c b/contrib/bmake/job.c
index 21582bb918eb..4cce19e89f87 100644
--- a/contrib/bmake/job.c
+++ b/contrib/bmake/job.c
@@ -1,4 +1,4 @@
-/* $NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $ */
+/* $NetBSD: job.c,v 1.467 2024/03/10 02:53:37 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -154,7 +154,7 @@
#include "trace.h"
/* "@(#)job.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.467 2024/03/10 02:53:37 sjg Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@@ -1449,7 +1449,7 @@ JobExec(Job *job, char **argv)
/* Pre-emptively mark job running, pid still zero though */
job->status = JOB_ST_RUNNING;
- Var_ReexportVars();
+ Var_ReexportVars(job->node);
cpid = vfork();
if (cpid == -1)
@@ -2076,6 +2076,8 @@ JobReapChild(pid_t pid, WAIT_T status, bool isJobs)
job->status = JOB_ST_FINISHED;
job->exit_status = WAIT_STATUS(status);
+ if (WIFEXITED(status))
+ job->node->exit_status = WEXITSTATUS(status);
JobFinish(job, status);
}
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index 79e2e5e0b4e7..25ec3630e649 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.609 2024/01/07 01:33:57 sjg Exp $ */
+/* $NetBSD: main.c,v 1.612 2024/03/10 02:53:37 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.609 2024/01/07 01:33:57 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.612 2024/03/10 02:53:37 sjg Exp $");
#if defined(MAKE_NATIVE)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -698,20 +698,6 @@ Main_ParseArgLine(const char *line)
if (p[0] == '\0')
return;
-#ifndef POSIX
- {
- /*
- * $MAKE may simply be naming the make(1) binary
- */
- char *cp;
-
- if (!(cp = strrchr(line, '/')))
- cp = line;
- if ((cp = strstr(cp, "make")) &&
- strcmp(cp, "make") == 0)
- return;
- }
-#endif
{
FStr argv0 = Var_Value(SCOPE_GLOBAL, ".MAKE");
buf = str_concat3(argv0.str, " ", p);
@@ -1450,20 +1436,11 @@ main_Init(int argc, char **argv)
#endif
Dir_Init();
-#ifdef POSIX
{
char *makeflags = explode(getenv("MAKEFLAGS"));
Main_ParseArgLine(makeflags);
free(makeflags);
}
-#else
- /*
- * First snag any flags out of the MAKE environment variable.
- * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's
- * in a different format).
- */
- Main_ParseArgLine(getenv("MAKE"));
-#endif
if (getcwd(curdir, MAXPATHLEN) == NULL) {
(void)fprintf(stderr, "%s: getcwd: %s.\n",
@@ -1776,7 +1753,7 @@ Cmd_Exec(const char *cmd, char **error)
return bmake_strdup("");
}
- Var_ReexportVars();
+ Var_ReexportVars(SCOPE_GLOBAL);
switch (cpid = vfork()) {
case 0:
@@ -2078,10 +2055,13 @@ static void
SetErrorVars(GNode *gn)
{
StringListNode *ln;
+ char sts[16];
/*
* We can print this even if there is no .ERROR target.
*/
+ snprintf(sts, sizeof(sts), "%d", gn->exit_status);
+ Global_Set(".ERROR_EXIT", sts);
Global_Set(".ERROR_TARGET", gn->name);
Global_Delete(".ERROR_CMD");
@@ -2155,13 +2135,8 @@ Main_ExportMAKEFLAGS(bool first)
"${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}",
SCOPE_CMDLINE, VARE_WANTRES);
/* TODO: handle errors */
- if (flags[0] != '\0') {
-#ifdef POSIX
+ if (flags[0] != '\0')
setenv("MAKEFLAGS", flags, 1);
-#else
- setenv("MAKE", flags, 1);
-#endif
- }
}
char *
diff --git a/contrib/bmake/make-conf.h b/contrib/bmake/make-conf.h
index dcf5b3162dea..4bba07a405e4 100644
--- a/contrib/bmake/make-conf.h
+++ b/contrib/bmake/make-conf.h
@@ -1,4 +1,4 @@
-/* $NetBSD: config.h,v 1.28 2020/12/11 22:53:08 rillig Exp $ */
+/* $NetBSD: config.h,v 1.29 2024/02/07 06:43:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -73,20 +73,6 @@
*/
/*
- * INCLUDES
- * LIBRARIES
- * These control the handling of the .INCLUDES and .LIBS variables.
- *
- * If INCLUDES is defined, the .INCLUDES variable will be filled
- * from the search paths of those suffixes which are marked by
- * .INCLUDES dependency lines. Similarly for LIBRARIES and .LIBS.
- *
- * See varname-dot-include.mk and varname-dot-libs.mk for more details.
- */
-#define INCLUDES
-#define LIBRARIES
-
-/*
* LIBSUFF
* Is the suffix used to denote libraries and is used by the Suff module
* to find the search path on which to seek any -l<xx> targets.
@@ -108,40 +94,6 @@
*/
#define RECHECK
-/*
- * POSIX
- * Adhere to the POSIX 1003.2 draft for the make(1) program.
- * - Use MAKEFLAGS instead of MAKE to pick arguments from the
- * environment.
- */
-#define POSIX
-
-/*
- * SYSVINCLUDE
- * Recognize system V like include directives [include "filename"]
- * (required by POSIX 2018)
- * SYSVVARSUB
- * Recognize system V like ${VAR:x=y} variable substitutions
- * (required by POSIX 2018)
- */
-#define SYSVINCLUDE
-#define SYSVVARSUB
-
-/*
- * GMAKEEXPORT
- * Recognize gmake like variable export directives [export <VAR>=<VALUE>]
- */
-#define GMAKEEXPORT
-
-/*
- * SUNSHCMD
- * Recognize SunOS and Solaris:
- * VAR :sh= CMD # Assign VAR to the command substitution of CMD
- * ${VAR:sh} # Return the command substitution of the value
- * # of ${VAR}
- */
-#define SUNSHCMD
-
#if defined(MAKE_NATIVE) && !defined(__ELF__)
# ifndef RANLIBMAG
# define RANLIBMAG "__.SYMDEF"
diff --git a/contrib/bmake/make.1 b/contrib/bmake/make.1
index b76d20973f1a..069c115ecb8b 100644
--- a/contrib/bmake/make.1
+++ b/contrib/bmake/make.1
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.372 2023/12/24 16:48:30 sjg Exp $
+.\" $NetBSD: make.1,v 1.375 2024/03/10 02:53:37 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd December 24, 2023
+.Dd March 9, 2024
.Dt MAKE 1
.Os
.Sh NAME
@@ -879,6 +879,9 @@ Is used in error handling, see
.It Va .ERROR_CWD
Is used in error handling, see
.Va MAKE_PRINT_VAR_ON_ERROR .
+.It Va .ERROR_EXIT
+Is used in error handling, see
+.Va MAKE_PRINT_VAR_ON_ERROR .
.It Va .ERROR_META_FILE
Is used in error handling in
.Dq meta
@@ -1196,6 +1199,8 @@ When
stops due to an error, it sets
.Sq Va .ERROR_TARGET
to the name of the target that failed,
+.Sq Va .ERROR_EXIT
+to the exit status of the failed target,
.Sq Va .ERROR_CMD
to the commands of the failed target,
and in
@@ -1786,8 +1791,9 @@ modifier which is later referenced using the index values from
.Ql :range .
.It Cm \&:U\| Ns Ar newval
If the variable is undefined,
+the optional
.Ar newval
-is the value.
+(which may be empty) is the value.
If the variable is defined, the existing value is returned.
This is another ODE make feature.
It is handy for setting per-target CFLAGS for instance:
@@ -1797,7 +1803,7 @@ If a value is only required if the variable is undefined, use:
.It Cm \&:D\| Ns Ar newval
If the variable is defined,
.Ar newval
-is the value.
+(which may be empty) is the value.
.It Cm \&:L
The name of the variable is the value.
.It Cm \&:P
@@ -2416,11 +2422,9 @@ Any command lines attached to this target are executed after everything
else is done successfully.
.It Ic .ERROR
Any command lines attached to this target are executed when another target fails.
-The
-.Va .ERROR_TARGET
-variable is set to the target that failed.
-See also
-.Va MAKE_PRINT_VAR_ON_ERROR .
+See
+.Va MAKE_PRINT_VAR_ON_ERROR
+for the variables that will be set.
.It Ic .IGNORE
Mark each of the sources with the
.Ic .IGNORE
diff --git a/contrib/bmake/make.h b/contrib/bmake/make.h
index 1b9147b383b0..86c198cb55f0 100644
--- a/contrib/bmake/make.h
+++ b/contrib/bmake/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.327 2023/12/17 09:02:26 rillig Exp $ */
+/* $NetBSD: make.h,v 1.329 2024/03/10 02:53:37 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -527,6 +527,7 @@ typedef struct GNode {
const char *fname;
/* Line number where the GNode got defined, 1-based */
unsigned lineno;
+ int exit_status;
} GNode;
/*
@@ -1034,7 +1035,7 @@ char *Var_Subst(const char *, GNode *, VarEvalMode);
void Var_Expand(FStr *, GNode *, VarEvalMode);
void Var_Stats(void);
void Var_Dump(GNode *);
-void Var_ReexportVars(void);
+void Var_ReexportVars(GNode *);
void Var_Export(VarExportMode, const char *);
void Var_ExportVars(const char *);
void Var_UnExport(bool, const char *);
diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog
index 447c8cf9c955..c37feedf4353 100644
--- a/contrib/bmake/mk/ChangeLog
+++ b/contrib/bmake/mk/ChangeLog
@@ -1,3 +1,83 @@
+2024-03-09 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20240309
+
+ * meta.sys.mk: _metaError: if .ERROR_EXIT == 6, we do not
+ want to save the .ERROR_META_FILE
+
+2024-02-20 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20240220
+
+ * sys.dirdeps.mk, dirdeps-targets.mk, init.mk:
+ do not set .MAIN: dirdeps in sys.dirdeps.mk
+ dirdeps-targets.mk will do that for top-level builds
+ and init.mk will do it for others.
+ This allows a Makefile which has no need of 'dirdeps' to
+ set .MAIN for itself and "just work".
+
+2024-02-18 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * bsd.*.mk: for makefiles that get a bsd. symlink,
+ use _this in multiple inclusion tags since .PARSEFILE will not
+ DTRT when such a makefile is included directly by Makefile and
+ automatically (without bsd. prefix).
+ Since we cannot guarantee that our sys.mk will be used, we provide
+ a default _this in each makefile that gets a bsd. prefix such that
+ the value is the same regardless of bsd. prefix.
+
+ * subdir.mk: drop the !target guard on $SUBDIR_TARGETS
+
+2024-02-12 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20240212
+
+ * SPDX-License-Identifier: BSD-2-Clause
+ Add SPDX-License-Identifier to inidicate that I consider
+ my copyright on any of these makefiles equivalent to BSD-2-Clause
+
+ * autoconf.mk: allow for configure.ac as currently recommended
+
+ * subdir.mk: support @auto
+ which is replaced with each subdir that
+ has a [Mm]akefile.
+
+ * subdir.mk: include local.subdir.mk if it exists.
+
+ * subdir.mk: rework to handle .WAIT
+
+2024-02-11 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * subdir.mk: _SUBDIRUSE report the target we are entering subdirs for.
+
+2024-02-10 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * prog.mk: treat empty SRCS the same as undefined
+
+2024-02-02 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * Avoid undefined errors in lint (-dL) mode
+
+ * man.mk (CMT2DOC_FLAGS): note that -mm does mdoc(7)
+
+2024-01-28 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20240128
+
+ * FILES: add ccm.dep.mk for C++ modules
+ add suffixes.mk for common location for generic SUFFIX rules.
+
+ * auto.dep.mk autodep.mk meta.autodep.mk: include ccm.dep.mk
+ replace OBJ_EXTENSIONS with OBJ_SUFFIXES
+
+ * autodep.mk: leverage CXX_SUFFIXES for __depsrcs
+ and update style (spaces around = etc)
+
+ * init.mk: add OBJS_SRCS_FILTER to filter SRCS when
+ setting OBJS
+
+ * meta2deps.py: handle multiple ./ embedded in path better.
+
2024-01-05 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240105
diff --git a/contrib/bmake/mk/FILES b/contrib/bmake/mk/FILES
index 6840d816477e..efe9691ffe58 100644
--- a/contrib/bmake/mk/FILES
+++ b/contrib/bmake/mk/FILES
@@ -7,6 +7,7 @@ autoconf.mk
autodep.mk
auto.dep.mk
cc-wrap.mk
+ccm.dep.mk
compiler.mk
cython.mk
dep.mk
@@ -45,6 +46,7 @@ scripts.mk
srctop.mk
stage-install.sh
subdir.mk
+suffixes.mk
sys.mk
sys.clean-env.mk
sys.debug.mk
diff --git a/contrib/bmake/mk/auto.dep.mk b/contrib/bmake/mk/auto.dep.mk
index c30b37f44053..400789a37366 100644
--- a/contrib/bmake/mk/auto.dep.mk
+++ b/contrib/bmake/mk/auto.dep.mk
@@ -1,6 +1,7 @@
+# SPDX-License-Identifier: BSD-2-Clause
#
# RCSid:
-# $Id: auto.dep.mk,v 1.10 2021/12/11 18:57:41 sjg Exp $
+# $Id: auto.dep.mk,v 1.12 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2010-2021, Simon J. Gerraty
#
@@ -85,4 +86,7 @@ ${DEPENDFILE}: ${OBJS} ${POBJS} ${SOBJS}
done > $@
.endif
+
+.-include <ccm.dep.mk>
+
.endif
diff --git a/contrib/bmake/mk/auto.obj.mk b/contrib/bmake/mk/auto.obj.mk
index 0405b5e6441d..cfe60ef9c4d6 100644
--- a/contrib/bmake/mk/auto.obj.mk
+++ b/contrib/bmake/mk/auto.obj.mk
@@ -1,4 +1,6 @@
-# $Id: auto.obj.mk,v 1.16 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: auto.obj.mk,v 1.17 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2004, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/autoconf.mk b/contrib/bmake/mk/autoconf.mk
index b50c7187ed1c..24532c4e9eab 100644
--- a/contrib/bmake/mk/autoconf.mk
+++ b/contrib/bmake/mk/autoconf.mk
@@ -1,6 +1,8 @@
-# $Id: autoconf.mk,v 1.18 2023/03/22 15:37:19 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
#
-# @(#) Copyright (c) 1996-2009, Simon J. Gerraty
+# $Id: autoconf.mk,v 1.20 2024/02/17 17:26:57 sjg Exp $
+#
+# @(#) Copyright (c) 1996-2024, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -52,7 +54,7 @@ CLEANFILES+= config.recheck config.gen config.status *.meta \
# this is not quite per the autoconf manual,
# and is extremely convoluted - but all utterly necessary!
-.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes"
+.if make(autoconf-input) || make(configure) || make(config.h.in) || ${MK_AUTO_AUTOCONF:Uno} == "yes"
AUTOCONF ?= autoconf
AUTOHEADER ?= autoheader
@@ -73,14 +75,23 @@ ACLOCAL += aclocal.m4
.if exists(${.CURDIR}/acconfig.h)
ACCONFIG += acconfig.h
.endif
+.if exists(${.CURDIR}/configure.ac)
+CONFIGURE_SRC = ${.CURDIR}/configure.ac
+.else
+CONFIGURE_SRC ?= ${.CURDIR}/configure.in
+.endif
-config.h.in: .NOTMAIN ${.CURDIR}/configure.in ${ACCONFIG}
+config.h.in: .NOTMAIN ${CONFIGURE_SRC} ${ACCONFIG}
(cd ${.CURDIR} && ${AUTOHEADER})
-configure: .NOTMAIN ${.CURDIR}/configure.in ${ACLOCAL}
+configure: .NOTMAIN ${CONFIGURE_SRC} ${ACLOCAL}
(cd ${.CURDIR} && ${AUTOCONF})
AUTOCONF_INPUTS += configure
+.if exists(${.CURDIR}/config.h.in)
+AUTOCONF_INPUTS += config.h.in
+.endif
+
autoconf-input: .NOTMAIN ${AUTOCONF_INPUTS}
.endif
diff --git a/contrib/bmake/mk/autodep.mk b/contrib/bmake/mk/autodep.mk
index 9104da2e2567..88a2643bccff 100644
--- a/contrib/bmake/mk/autodep.mk
+++ b/contrib/bmake/mk/autodep.mk
@@ -1,8 +1,9 @@
+# SPDX-License-Identifier: BSD-2-Clause
#
# RCSid:
-# $Id: autodep.mk,v 1.40 2021/12/08 05:56:50 sjg Exp $
+# $Id: autodep.mk,v 1.43 2024/02/17 17:26:57 sjg Exp $
#
-# @(#) Copyright (c) 1999-2010, Simon J. Gerraty
+# @(#) Copyright (c) 1999-2024, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -32,59 +33,58 @@ DEPENDFILE?= .depend
.endif
.endfor
+# should have been set by sys.mk
+CXX_SUFFIXES ?= .cc .ccm .cpp .cxx .C
+
# it does nothing if SRCS is not defined or is empty
.if defined(SRCS) && !empty(SRCS)
-DEPSRCS?=${SRCS}
-__depsrcs=${DEPSRCS:M*.c}
-__depsrcs+=${DEPSRCS:M*.y}
-__depsrcs+=${DEPSRCS:M*.l}
-__depsrcs+=${DEPSRCS:M*.s}
-__depsrcs+=${DEPSRCS:M*.S}
-__depsrcs+=${DEPSRCS:M*.cc}
-__depsrcs+=${DEPSRCS:M*.cpp}
-__depsrcs+=${DEPSRCS:M*.C}
-__depsrcs+=${DEPSRCS:M*.cxx}
-__depsrcs+=${DEPSRCS:M*.pc}
+DEPSRCS ?= ${SRCS}
+__depsrcs = ${DEPSRCS:M*.c}
+__depsrcs += ${DEPSRCS:M*.y}
+__depsrcs += ${DEPSRCS:M*.l}
+__depsrcs += ${DEPSRCS:M*.s}
+__depsrcs += ${DEPSRCS:M*.S}
+__depsrcs += ${DEPSRCS:M*.pc}
+.for s in ${CXX_SUFFIXES}
+__depsrcs += ${DEPSRCS:M*$s}
+.endfor
.for s in ${__depsrcs}
${s:T:R}.d: $s
.endfor
-__depsrcs:=${__depsrcs:T:R:S/$/.d/g}
+__depsrcs := ${__depsrcs:T:R:S/$/.d/g}
# we also need to handle makefiles where the .d's from __depsrcs
# don't match those from OBJS
# we avoid using := here, since the modifier applied to OBJS
# can cause trouble if there are any undefined vars in OBJS.
-__dependsrcsx?= ${__depsrcs} ${OBJS:S/.o/.d/}
-__dependsrcs= ${__dependsrcsx:O:u}
+__dependsrcsx ?= ${__depsrcs} ${OBJS:S/.o/.d/}
+__dependsrcs = ${__dependsrcsx:O:u}
# clean up any .c files we may have generated
-#__gensrcs:= ${DEPSRCS:M*.y} ${DEPSRCS:M*.l}
-#CLEANFILES+= ${__gensrcs:T:R:S/$/.c/g}
+#__gensrcs := ${DEPSRCS:M*.y} ${DEPSRCS:M*.l}
+#CLEANFILES += ${__gensrcs:T:R:S/$/.c/g}
# set this to -MMD to ignore /usr/include
# actually it ignores <> so may not be a great idea
-CFLAGS_MD?=-MD
+CFLAGS_MD ?= -MD
# -MF etc not available on all gcc versions.
# we "fix" the .o later
.if ${COMPILER_TYPE:Ugcc} == "gcc" && ${COMPILER_VERSION:U0} < 30000
-CFLAGS_MF=
+CFLAGS_MF =
.endif
-CFLAGS_MF?=-MF ${.TARGET:T:R}.d -MT ${.TARGET:T:R}.o
-CFLAGS+= ${CFLAGS_MD} ${CFLAGS_MF}
+CFLAGS_MF ?= -MF ${.TARGET:T:R}.d -MT ${.TARGET:T:R}.o
+CFLAGS += ${CFLAGS_MD} ${CFLAGS_MF}
RM?= rm
-MAKE_SHELL?= sh
+MAKE_SHELL ?= sh
# watch out for people who don't use CPPFLAGS
-CPPFLAGS_MD=${CFLAGS:M-[IUD]*} ${CPPFLAGS}
-CXXFLAGS_MD=${CXXFLAGS:M-[IUD]*} ${CPPFLAGS}
+CPPFLAGS_MD = ${CFLAGS:M-[IUD]*} ${CPPFLAGS}
+CXXFLAGS_MD = ${CXXFLAGS:M-[IUD]*} ${CPPFLAGS}
# just in case these need to be different
-CC_MD?=${CC}
-CXX_MD?=${CXX}
-
-# should have been set by sys.mk
-CXX_SUFFIXES?= .cc .cpp .cxx .C
+CC_MD ?= ${CC}
+CXX_MD ?= ${CXX}
# so we can do an explicit make depend, but not otherwise
.if make(depend)
@@ -114,7 +114,9 @@ CXX_SUFFIXES?= .cc .cpp .cxx .C
${CXX_SUFFIXES:%=%.d}:
@echo updating dependencies for $<
@${MAKE_SHELL} -ec "${CXX_MD} -M ${CXXFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; }
+
.else
+
.y.d:
${YACC} ${YFLAGS} $<
${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} y.tab.c > $@ || { ${RM} -f y.tab.c $@; false; }
@@ -133,6 +135,7 @@ ${CXX_SUFFIXES:%=%.d}:
${CXX_SUFFIXES:%=%.d}:
${CXX_MD} ${CFLAGS_MD:S/D//} ${CXXFLAGS_MD} $< > $@ || { ${RM} -f $@; false; }
+
.endif
.if !target(depend)
@@ -152,47 +155,47 @@ ${PROG} ${_LIBS}: ${DEPENDFILE}
.ORDER: beforedepend ${DEPENDFILE} afterdepend
.if ${.OBJDIR} != ${.CURDIR}
-__depfiles= *.d
+__depfiles = *.d
.else
-__depfiles= ${__dependsrcs}
+__depfiles = ${__dependsrcs}
.endif
-DEPCLEANFILES= ${DEPENDFILE} ${__depfiles} y.tab.d *.tmp.d
+DEPCLEANFILES = ${DEPENDFILE} ${__depfiles} y.tab.d *.tmp.d
cleandir: cleanautodepend
cleanautodepend:
${RM} -f ${DEPCLEANFILES}
-CLEANFILES+= ${DEPCLEANFILES}
+CLEANFILES += ${DEPCLEANFILES}
.if defined(__dependsrcs) && !empty(__dependsrcs)
.if make(depend) || !(make(clean*) || make(destroy*) || make(obj) || make(*install) || make(install-*))
# this ensures we do the right thing if only building a shared or
# profiled lib
-OBJ_EXTENSIONS?=.o .po .so .So
-MDLIB_SED= -e '/:/s,^\([^\.:]*\)\.[psS]*o,${OBJ_EXTENSIONS:S,^,\1,},'
+OBJ_SUFFIXES ?= .o .po .so .So
+MDLIB_SED = -e '/:/s,^\([^\.:]*\)\.[psS]*o,${OBJ_SUFFIXES:S,^,\1,},'
.ifdef NOMD_SED
.ifdef LIB
-MD_SED=sed ${MDLIB_SED}
+MD_SED = sed ${MDLIB_SED}
.else
-MD_SED=cat
+MD_SED = cat
.endif
.else
# arrange to put some variable names into ${DEPENDFILE}
.ifdef LIB
-MD_SED=sed ${MDLIB_SED}
+MD_SED = sed ${MDLIB_SED}
.else
-MD_SED=sed
+MD_SED = sed
.endif
-SUBST_DEPVARS+= SB TOP BACKING SRC SRCDIR BASE BASEDIR
+SUBST_DEPVARS += SB TOP BACKING SRC SRCDIR BASE BASEDIR
.for v in ${SUBST_DEPVARS}
.if defined(${v}) && !empty(${v})
-MD_SED+= -e 's,${$v},$${$v},'
+MD_SED += -e 's,${$v},$${$v},'
.endif
.endfor
.endif
.if (${MD_SED} == "sed")
-MD_SED=cat
+MD_SED = cat
.endif
# this will be done whenever make finishes successfully
@@ -219,4 +222,6 @@ beforedepend:
afterdepend:
.endif
+.-include <ccm.dep.mk>
+
.endif
diff --git a/contrib/bmake/mk/cc-wrap.mk b/contrib/bmake/mk/cc-wrap.mk
index 2052e76b7075..7c1d6165e9df 100644
--- a/contrib/bmake/mk/cc-wrap.mk
+++ b/contrib/bmake/mk/cc-wrap.mk
@@ -1,4 +1,6 @@
-# $Id: cc-wrap.mk,v 1.6 2022/02/16 17:41:52 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: cc-wrap.mk,v 1.7 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2022, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/ccm.dep.mk b/contrib/bmake/mk/ccm.dep.mk
new file mode 100644
index 000000000000..1809a72e7310
--- /dev/null
+++ b/contrib/bmake/mk/ccm.dep.mk
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# RCSid:
+# $Id: ccm.dep.mk,v 1.3 2024/02/17 17:26:57 sjg Exp $
+#
+# @(#) Copyright (c) 2024, Simon J. Gerraty
+#
+# This file is provided in the hope that it will
+# be of use. There is absolutely NO WARRANTY.
+# Permission to copy, redistribute or otherwise
+# use this file is hereby granted provided that
+# the above copyright notice and this notice are
+# left intact.
+#
+# Please send copies of changes and bug-fixes to:
+# sjg@crufty.net
+#
+
+# C++ Modules need extra help - at least in a clean tree
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
+
+# These should all be set by now
+CCM_SUFFIXES ?= ${.SUFFIXES:M*.c*m}
+PCM ?= .pcm
+OBJ_SUFFIXES ?= ${.SUFFIXES:M*o}
+
+.ccm_srcs := ${CCM_SUFFIXES:@s@${SRCS:M*$s}@}
+.if !empty(.ccm_srcs)
+.ccm_srcs += ${CXX_SUFFIXES:@s@${SRCS:M*$s}@}
+# this is likely overkill, but
+# with .dinclude it should not matter
+.ccm_depend: ${.ccm_srcs}
+ @rm -f ${.TARGET}
+.for s r e in ${.ccm_srcs:@x@$x ${x:T:R} ${x:E}@}
+ @mlist=`sed -n '/^import/s,.*[[:space:]]\([^[:space:];]*\);.*,\1,p' ${.ALLSRC:M*$s}`; \
+ for o in ${OBJ_SUFFIXES:O:u}; do \
+ for m in $$mlist; do \
+ echo $r$$o: $$m${PCM}; \
+ done; \
+ done >> ${.TARGET}
+.endfor
+
+.if make(depend)
+x != echo; rm -f .ccm_depend
+.endif
+
+.if !make(.ccm_depend)
+.if !exists(.ccm_depend)
+# ugly, but it does the trick
+x != echo; ${.MAKE} -B -C ${.CURDIR} -f ${MAKEFILE} .ccm_depend
+.endif
+
+CLEANFILES += .ccm_depend
+# the ${.OBJDIR}/ is necessary!
+.dinclude <${.OBJDIR}/.ccm_depend>
+.endif
+.endif
+.endif
diff --git a/contrib/bmake/mk/compiler.mk b/contrib/bmake/mk/compiler.mk
index 4f942d1f9f7e..e7a13f0f11d7 100644
--- a/contrib/bmake/mk/compiler.mk
+++ b/contrib/bmake/mk/compiler.mk
@@ -1,4 +1,6 @@
-# $Id: compiler.mk,v 1.12 2023/10/03 18:47:48 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: compiler.mk,v 1.14 2024/02/19 00:05:50 sjg Exp $
#
# @(#) Copyright (c) 2019, Simon J. Gerraty
#
@@ -27,7 +29,7 @@ _v != (${CC} --version) 2> /dev/null | \
.if empty(COMPILER_TYPE)
.if ${_v:Mclang} != ""
COMPILER_TYPE = clang
-.elif ${_v:M[Gg][Cc][Cc]} != "" || ${_v:MFoundation*} != "" || ${CC:T:M*gcc*} != ""
+.elif ${_v:M[Gg][Cc][Cc]} != "" || ${_v:MFoundation*} != "" || ${CC:Ucc:T:M*gcc*} != ""
COMPILER_TYPE = gcc
.endif
.endif
diff --git a/contrib/bmake/mk/cython.mk b/contrib/bmake/mk/cython.mk
index d3c229c7269a..3c28eb0a4525 100644
--- a/contrib/bmake/mk/cython.mk
+++ b/contrib/bmake/mk/cython.mk
@@ -1,5 +1,7 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
# RCSid:
-# $Id: cython.mk,v 1.8 2020/08/19 17:51:53 sjg Exp $
+# $Id: cython.mk,v 1.9 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/dep.mk b/contrib/bmake/mk/dep.mk
index ea73846f5fd8..ebc624ff163c 100644
--- a/contrib/bmake/mk/dep.mk
+++ b/contrib/bmake/mk/dep.mk
@@ -1,7 +1,10 @@
-# $Id: dep.mk,v 1.18 2021/12/08 05:56:50 sjg Exp $
+# $Id: dep.mk,v 1.22 2024/02/19 00:06:19 sjg Exp $
-.if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
# handle Proc*C as well...
.if defined(SRCS)
@@ -9,13 +12,18 @@ __${.PARSEFILE}__: .NOTMAIN
.include <proc.mk>
.endif
+.if ${MAKE_VERSION:U0} >= 20211212
+OBJ_SUFFIXES += ${.SUFFIXES:M*o}
+.else
# it would be nice to be able to query .SUFFIXES
-OBJ_EXTENSIONS+= .o .po .lo .So
+OBJ_SUFFIXES += .o .po .lo ${PICO}
+.endif
+OBJ_SUFFIXES += ${PCM}
# explicit dependencies help short-circuit .SUFFIX searches
SRCS_DEP_FILTER+= N*.[hly]
.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}}
-.for e in ${OBJ_EXTENSIONS:O:u}
+.for e in ${OBJ_SUFFIXES:O:u}
.if !target(${s:T:R}$e)
${s:T:R}$e: $s
.endif
@@ -94,6 +102,7 @@ depend: beforedepend .depend _SUBDIRUSE afterdepend
${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \
esac
.endif
+.-include <ccm.dep.mk>
.else
.depend:
.endif
diff --git a/contrib/bmake/mk/dirdeps-cache-update.mk b/contrib/bmake/mk/dirdeps-cache-update.mk
index e442efd1d497..9e7cb8281110 100644
--- a/contrib/bmake/mk/dirdeps-cache-update.mk
+++ b/contrib/bmake/mk/dirdeps-cache-update.mk
@@ -1,4 +1,6 @@
-# $Id: dirdeps-cache-update.mk,v 1.22 2020/09/10 00:14:38 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: dirdeps-cache-update.mk,v 1.23 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2020, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/dirdeps-options.mk b/contrib/bmake/mk/dirdeps-options.mk
index 9a97615bbeb8..e12dcec40ac7 100644
--- a/contrib/bmake/mk/dirdeps-options.mk
+++ b/contrib/bmake/mk/dirdeps-options.mk
@@ -1,4 +1,6 @@
-# $Id: dirdeps-options.mk,v 1.21 2022/09/06 22:18:45 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: dirdeps-options.mk,v 1.22 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2018-2022, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/dirdeps-targets.mk b/contrib/bmake/mk/dirdeps-targets.mk
index 821ae50e3ffa..9e3fb814fada 100644
--- a/contrib/bmake/mk/dirdeps-targets.mk
+++ b/contrib/bmake/mk/dirdeps-targets.mk
@@ -1,5 +1,7 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
# RCSid:
-# $Id: dirdeps-targets.mk,v 1.25 2023/05/11 05:07:28 sjg Exp $
+# $Id: dirdeps-targets.mk,v 1.27 2024/02/25 19:12:13 sjg Exp $
#
# @(#) Copyright (c) 2019-2020 Simon J. Gerraty
#
@@ -40,6 +42,9 @@
# pickup customizations
.-include <local.dirdeps-targets.mk>
+# this is what we are here for
+.MAIN: dirdeps
+
# for DIRDEPS_BUILD this is how we prime the pump
# include . to allow any directory to work as a target
DIRDEPS_TARGETS_DIRS ?= targets targets/pseudo
diff --git a/contrib/bmake/mk/doc.mk b/contrib/bmake/mk/doc.mk
index 06dd517473ca..34202371fc5c 100644
--- a/contrib/bmake/mk/doc.mk
+++ b/contrib/bmake/mk/doc.mk
@@ -1,7 +1,10 @@
-# $Id: doc.mk,v 1.8 2021/12/08 05:56:50 sjg Exp $
+# $Id: doc.mk,v 1.9 2024/02/19 00:06:19 sjg Exp $
-.if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
.include <init.mk>
diff --git a/contrib/bmake/mk/dpadd.mk b/contrib/bmake/mk/dpadd.mk
index a4c73c1854fc..4e430b97b3b8 100644
--- a/contrib/bmake/mk/dpadd.mk
+++ b/contrib/bmake/mk/dpadd.mk
@@ -1,4 +1,6 @@
-# $Id: dpadd.mk,v 1.31 2023/11/25 01:07:49 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: dpadd.mk,v 1.33 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2004-2023, Simon J. Gerraty
#
@@ -254,7 +256,7 @@ SHLDADD+= -L${__lib:H}
# Now for the bits we actually need
__dpadd_incs=
.for __lib in ${__dpadd_libs:u}
-.if (make(${PROG}_p) || defined(NEED_GPROF)) && exists(${__lib:R}_p.a)
+.if (make(${PROG:U}_p) || defined(NEED_GPROF)) && exists(${__lib:R}_p.a)
__ldadd=-l${__lib:T:R:S,lib,,}
LDADD := ${LDADD:S,^${__ldadd}$,${__ldadd}_p,g}
.endif
diff --git a/contrib/bmake/mk/files.mk b/contrib/bmake/mk/files.mk
index 513ab1fd819e..e8de8600d2c6 100644
--- a/contrib/bmake/mk/files.mk
+++ b/contrib/bmake/mk/files.mk
@@ -1,4 +1,6 @@
-# $Id: files.mk,v 1.7 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: files.mk,v 1.8 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2017, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/host-target.mk b/contrib/bmake/mk/host-target.mk
index d8abea17fdac..0316cacb2713 100644
--- a/contrib/bmake/mk/host-target.mk
+++ b/contrib/bmake/mk/host-target.mk
@@ -1,5 +1,19 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
# RCSid:
-# $Id: host-target.mk,v 1.19 2023/09/21 06:44:53 sjg Exp $
+# $Id: host-target.mk,v 1.20 2024/02/17 17:26:57 sjg Exp $
+#
+# @(#) Copyright (c) 2007-2023 Simon J. Gerraty
+#
+# This file is provided in the hope that it will
+# be of use. There is absolutely NO WARRANTY.
+# Permission to copy, redistribute or otherwise
+# use this file is hereby granted provided that
+# the above copyright notice and this notice are
+# left intact.
+#
+# Please send copies of changes and bug-fixes to:
+# sjg@crufty.net
# Host platform information; may be overridden
.if !target(__${.PARSEFILE}__)
diff --git a/contrib/bmake/mk/inc.mk b/contrib/bmake/mk/inc.mk
index 5fc14b32d88d..9ea93bd1573d 100644
--- a/contrib/bmake/mk/inc.mk
+++ b/contrib/bmake/mk/inc.mk
@@ -1,4 +1,6 @@
-# $Id: inc.mk,v 1.8 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: inc.mk,v 1.9 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2008, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/init.mk b/contrib/bmake/mk/init.mk
index b0d365754d86..86dc577371cb 100644
--- a/contrib/bmake/mk/init.mk
+++ b/contrib/bmake/mk/init.mk
@@ -1,6 +1,8 @@
-# $Id: init.mk,v 1.30 2023/10/03 16:25:01 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
#
-# @(#) Copyright (c) 2002, Simon J. Gerraty
+# $Id: init.mk,v 1.37 2024/02/25 19:12:13 sjg Exp $
+#
+# @(#) Copyright (c) 2002-2024, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -13,8 +15,11 @@
# sjg@crufty.net
#
-.if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
.if ${MAKE_VERSION:U0} > 20100408
_this_mk_dir := ${.PARSEDIR:tA}
@@ -27,10 +32,16 @@ _this_mk_dir := ${.PARSEDIR}
.include <own.mk>
.include <compiler.mk>
-.MAIN: all
-
# should have been set by sys.mk
-CXX_SUFFIXES?= .cc .cpp .cxx .C
+CXX_SUFFIXES ?= .cc .cpp .cxx .C
+CCM_SUFFIXES ?= .ccm
+PCM ?= .pcm
+# ${PICO} is used for PIC object files.
+PICO ?= .pico
+
+# SRCS which do not end up in OBJS
+NO_OBJS_SRCS_SUFFIXES ?= .h ${CCM_SUFFIXES} .sh
+OBJS_SRCS_FILTER += ${NO_OBJS_SRCS_SUFFIXES:@x@N*$x@:ts:}
.if defined(PROG_CXX) || ${SRCS:Uno:${CXX_SUFFIXES:S,^,N*,:ts:}} != ${SRCS:Uno:N/}
_CCLINK ?= ${CXX}
@@ -82,9 +93,13 @@ _SKIP_BUILD = not building at level 0
.endif
.elif ${.TARGETS:U:Nall} == ""
_SKIP_BUILD = not building at level 0
+# first .MAIN is what counts
+.MAIN: dirdeps
.endif
.endif
+.MAIN: all
+
.if !defined(.PARSEDIR)
# no-op is the best we can do if not bmake.
.WAIT:
diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk
index 357afd171e8c..c9941bb4247e 100755
--- a/contrib/bmake/mk/install-mk
+++ b/contrib/bmake/mk/install-mk
@@ -59,7 +59,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.244 2024/01/05 23:16:34 sjg Exp $
+# $Id: install-mk,v 1.250 2024/03/10 02:57:17 sjg Exp $
#
# @(#) Copyright (c) 1994-2023 Simon J. Gerraty
#
@@ -74,7 +74,7 @@
# sjg@crufty.net
#
-MK_VERSION=20240105
+MK_VERSION=20240309
OWNER=
GROUP=
MODE=444
diff --git a/contrib/bmake/mk/install-new.mk b/contrib/bmake/mk/install-new.mk
index d312bdc26d46..0f2e395a8238 100644
--- a/contrib/bmake/mk/install-new.mk
+++ b/contrib/bmake/mk/install-new.mk
@@ -1,4 +1,6 @@
-# $Id: install-new.mk,v 1.4 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: install-new.mk,v 1.5 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2009, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/install-sh b/contrib/bmake/mk/install-sh
index 1fa52a59de7e..aa35fa94c83a 100755
--- a/contrib/bmake/mk/install-sh
+++ b/contrib/bmake/mk/install-sh
@@ -53,8 +53,10 @@
# Simon J. Gerraty <sjg@crufty.net>
#
+# SPDX-License-Identifier: BSD-2-Clause
+#
# RCSid:
-# $Id: install-sh,v 1.25 2023/07/15 05:33:38 sjg Exp $
+# $Id: install-sh,v 1.26 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 1993-2023 Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/java.mk b/contrib/bmake/mk/java.mk
index 3a4e7911e536..752aea121953 100644
--- a/contrib/bmake/mk/java.mk
+++ b/contrib/bmake/mk/java.mk
@@ -1,6 +1,7 @@
+# SPDX-License-Identifier: BSD-2-Clause
#
# RCSid:
-# $Id: java.mk,v 1.16 2021/12/08 05:56:50 sjg Exp $
+# $Id: java.mk,v 1.17 2024/02/17 17:26:57 sjg Exp $
# @(#) Copyright (c) 1998-2001, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/jobs.mk b/contrib/bmake/mk/jobs.mk
index 404ce6c3dadd..f39f1eb178ae 100644
--- a/contrib/bmake/mk/jobs.mk
+++ b/contrib/bmake/mk/jobs.mk
@@ -1,4 +1,6 @@
-# $Id: jobs.mk,v 1.16 2023/11/29 15:59:50 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: jobs.mk,v 1.17 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2012-2023, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/ldorder.mk b/contrib/bmake/mk/ldorder.mk
index 5ae54385993e..b612b1b9d3be 100644
--- a/contrib/bmake/mk/ldorder.mk
+++ b/contrib/bmake/mk/ldorder.mk
@@ -1,4 +1,6 @@
-# $Id: ldorder.mk,v 1.26 2021/12/08 05:56:50 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: ldorder.mk,v 1.27 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2015, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/lib.mk b/contrib/bmake/mk/lib.mk
index 9c1c2b446d41..95f95118c028 100644
--- a/contrib/bmake/mk/lib.mk
+++ b/contrib/bmake/mk/lib.mk
@@ -1,7 +1,10 @@
-# $Id: lib.mk,v 1.81 2023/10/03 18:18:57 sjg Exp $
+# $Id: lib.mk,v 1.84 2024/02/19 00:06:19 sjg Exp $
-.if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
.include <init.mk>
@@ -30,10 +33,9 @@ SHLIB_FULLVERSION := ${SHLIB_FULLVERSION}
# add additional suffixes not exported.
# .po is used for profiling object files.
-# ${PICO} is used for PIC object files.
-PICO?= .pico
-.SUFFIXES: .out .a .ln ${PICO} .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h
-.SUFFIXES: .sh .m4 .m
+.SUFFIXES: .out .a .ln ${PICO} ${PCM} .po .o .s .S .c ${CXX_SUFFIXES} \
+ ${CCM_SUFFIXES} .m .F .f .r .y .l .cl .p .h \
+ .sh .m4 .m
CFLAGS+= ${COPTS}
@@ -267,6 +269,10 @@ SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age
.c.o:
${COMPILE.c} ${.IMPSRC}
+# precompiled C++ Modules
+${CCM_SUFFIXES:%=%${PCM}}:
+ ${COMPILE.pcm} ${.IMPSRC}
+
# for the normal .a we do not want to strip symbols
${CXX_SUFFIXES:%=%.o}:
${COMPILE.cc} ${.IMPSRC}
@@ -380,6 +386,8 @@ _LIBS+= ${libLDORDER_INC}
.include <ldorder.mk>
.endif
+# avoid -dL errors
+LDADD_LDORDER ?=
.if !defined(_SKIP_BUILD)
realbuild: ${_LIBS}
@@ -387,11 +395,13 @@ realbuild: ${_LIBS}
all: _SUBDIRUSE
-.for s in ${SRCS:N*.h:M*/*}
+OBJS_SRCS = ${SRCS:${OBJS_SRCS_FILTER}}
+
+.for s in ${OBJS_SRCS:M*/*}
${.o ${PICO} .po .lo:L:@o@${s:T:R}$o@}: $s
.endfor
-OBJS+= ${SRCS:T:N*.h:R:S/$/.o/g}
+OBJS+= ${OBJS_SRCS:T:R:S/$/.o/g}
.NOPATH: ${OBJS}
.if ${MK_LIBTOOL} == "yes"
diff --git a/contrib/bmake/mk/libnames.mk b/contrib/bmake/mk/libnames.mk
index 8140360714df..f2d99d337675 100644
--- a/contrib/bmake/mk/libnames.mk
+++ b/contrib/bmake/mk/libnames.mk
@@ -1,4 +1,6 @@
-# $Id: libnames.mk,v 1.9 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: libnames.mk,v 1.10 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2007-2009, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/libs.mk b/contrib/bmake/mk/libs.mk
index 9f0079d6e511..fef339c03bce 100644
--- a/contrib/bmake/mk/libs.mk
+++ b/contrib/bmake/mk/libs.mk
@@ -1,4 +1,6 @@
-# $Id: libs.mk,v 1.6 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: libs.mk,v 1.7 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2006, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/links.mk b/contrib/bmake/mk/links.mk
index 6bf0db080c23..cbf9685ccd37 100644
--- a/contrib/bmake/mk/links.mk
+++ b/contrib/bmake/mk/links.mk
@@ -1,4 +1,6 @@
-# $Id: links.mk,v 1.7 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: links.mk,v 1.8 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2005, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/man.mk b/contrib/bmake/mk/man.mk
index be1b7d98cd04..13c4d8e866f0 100644
--- a/contrib/bmake/mk/man.mk
+++ b/contrib/bmake/mk/man.mk
@@ -1,7 +1,10 @@
-# $Id: man.mk,v 1.26 2023/12/30 02:10:38 sjg Exp $
+# $Id: man.mk,v 1.29 2024/02/19 00:06:19 sjg Exp $
-.if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
OPTIONS_DEFAULT_NO += CMT2DOC
@@ -55,15 +58,18 @@ MANALL ?= ${MAN}
.if ${MK_CMT2DOC} == "yes"
# use cmt2doc.py to extract manpages from source
-CMT2DOC?= cmt2doc.py
-CMT2DOC_OPTS?= ${CMT2DOC_ORGOPT} -pmS${.TARGET:E}
-CMT2DOC_SUFFIXES+= .c .h .sh .pl .py
+CMT2DOC ?= cmt2doc.py
+# -m produces man(7)
+# -mm produces mdoc(7)
+CMT2DOC_FLAGS ?= -pm
+CMT2DOC_OPTS ?= ${CMT2DOC_ORGOPT} -S${.TARGET:E}
+CMT2DOC_SUFFIXES += .c .h .sh .pl .py
.SUFFIXES: ${CMT2DOC_SUFFIXES}
${CMT2DOC_SUFFIXES:@s@${MAN_SUFFIXES:@m@$s$m@}@}:
@echo "${CMT2DOC} ${.IMPSRC} > ${.TARGET:T}"
- @${CMT2DOC} ${CMT2DOC_OPTS} ${.IMPSRC} > ${.TARGET:T}.new && \
+ @${CMT2DOC} ${CMT2DOC_FLAGS} ${CMT2DOC_OPTS} ${.IMPSRC} > ${.TARGET:T}.new && \
mv ${.TARGET:T}.new ${.TARGET:T}
.endif
@@ -111,7 +117,7 @@ _stage_man = stage_files
STAGE_TARGETS += ${_stage_man}
.for _page _as in ${MANALL:@x@$x ${x:T:S/.cat/./}@}
${_stage_man}.man${_as:E}: ${_page}
-.if target(${_page:T}${MCOMPRESS_EXT})
+.if target(${_page:T}${MCOMPRESS_EXT:Umanz})
${_man_stage}.man${_as:E}: ${_page:T}${MCOMPRESS_EXT}
.endif
STAGE_DIR.man${_as:E} ?= ${STAGE_OBJTOP}${MANDIR}/${MANTARGET}${_as:E}${MANSUBDIR}
diff --git a/contrib/bmake/mk/manifest.mk b/contrib/bmake/mk/manifest.mk
index 1e2f728f094e..d619d17432bd 100644
--- a/contrib/bmake/mk/manifest.mk
+++ b/contrib/bmake/mk/manifest.mk
@@ -1,4 +1,6 @@
-# $Id: manifest.mk,v 1.3 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: manifest.mk,v 1.4 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/meta.autodep.mk b/contrib/bmake/mk/meta.autodep.mk
index 11b5f17f4edc..9824570ecc43 100644
--- a/contrib/bmake/mk/meta.autodep.mk
+++ b/contrib/bmake/mk/meta.autodep.mk
@@ -1,4 +1,6 @@
-# $Id: meta.autodep.mk,v 1.60 2024/01/09 23:42:22 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: meta.autodep.mk,v 1.62 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
@@ -24,16 +26,16 @@ PICO?= .pico
.if defined(SRCS)
.if ${MAKE_VERSION:U0} >= 20211212
-OBJ_EXTENSIONS += ${.SUFFIXES:M*o}
+OBJ_SUFFIXES += ${.SUFFIXES:M*o}
.else
# it would be nice to be able to query .SUFFIXES
-OBJ_EXTENSIONS += .o .po .lo ${PICO}
+OBJ_SUFFIXES += .o .po .lo ${PICO}
.endif
# explicit dependencies help short-circuit .SUFFIX searches
SRCS_DEP_FILTER+= N*.[hly]
.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}}
-.for e in ${OBJ_EXTENSIONS:O:u}
+.for e in ${OBJ_SUFFIXES:O:u}
.if !target(${s:T:R}$e)
${s:T:R}$e: $s
.endif
@@ -190,7 +192,7 @@ DEPEND_SUFFIXES += .c .h .cpp .hpp .cxx .hxx .cc .hh
@case "${.MAKE.META.FILES:T:M*.po.*}" in \
*.po.*) mv $@.${.MAKE.PID} $@;; \
*) { cat $@.${.MAKE.PID}; \
- sed ${OBJ_EXTENSIONS:N.o:N.po:@o@-e 's,\$o:,.o:,'@} \
+ sed ${OBJ_SUFFIXES:N.o:N.po:@o@-e 's,\$o:,.o:,'@} \
-e 's,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \
rm -f $@.${.MAKE.PID};; \
esac
@@ -331,4 +333,6 @@ _reldir_failed: .NOMETA
.ERROR: _reldir_failed
.endif
+.-include <ccm.dep.mk>
+
.endif
diff --git a/contrib/bmake/mk/meta.stage.mk b/contrib/bmake/mk/meta.stage.mk
index 168e46d22a82..345df6aae16b 100644
--- a/contrib/bmake/mk/meta.stage.mk
+++ b/contrib/bmake/mk/meta.stage.mk
@@ -1,4 +1,6 @@
-# $Id: meta.stage.mk,v 1.67 2023/04/17 01:22:10 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: meta.stage.mk,v 1.69 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2011-2017, Simon J. Gerraty
#
@@ -212,7 +214,7 @@ stage_files.$s: .dirdep
STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*}
stage_files: .dirdep
.endif
- @${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s:O}
+ @${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@:U} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s:O}
@touch $@
.endif
.endif
diff --git a/contrib/bmake/mk/meta.subdir.mk b/contrib/bmake/mk/meta.subdir.mk
index d9caae4edbcc..e2ece24515a4 100644
--- a/contrib/bmake/mk/meta.subdir.mk
+++ b/contrib/bmake/mk/meta.subdir.mk
@@ -1,4 +1,6 @@
-# $Id: meta.subdir.mk,v 1.13 2021/01/05 22:24:37 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: meta.subdir.mk,v 1.14 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2010, Simon J. Gerraty
diff --git a/contrib/bmake/mk/meta.sys.mk b/contrib/bmake/mk/meta.sys.mk
index ba213dd49da4..6e4216ab5383 100644
--- a/contrib/bmake/mk/meta.sys.mk
+++ b/contrib/bmake/mk/meta.sys.mk
@@ -1,4 +1,6 @@
-# $Id: meta.sys.mk,v 1.51 2023/05/11 20:05:32 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: meta.sys.mk,v 1.54 2024/03/10 15:53:51 sjg Exp $
#
# @(#) Copyright (c) 2010-2023, Simon J. Gerraty
@@ -82,6 +84,7 @@ META2DEPS := ${META2DEPS}
MAKE_PRINT_VAR_ON_ERROR += \
.ERROR_TARGET \
+ .ERROR_EXIT \
.ERROR_META_FILE \
.MAKE.LEVEL \
MAKEFILE \
@@ -98,10 +101,13 @@ SB = ${SRCTOP:H}
ERROR_LOGDIR ?= ${SB}/error
meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
-# we are not interested in make telling us a failure happened elsewhere
.ERROR: _metaError
+# We are interested here in the target(s) that caused the build to fail.
+# We want to ignore targets that were "aborted" due to failure
+# elsewhere per the message below or a sub-make may just exit 6.
_metaError: .NOMETA .NOTMAIN
- -@[ "${.ERROR_META_FILE}" ] && { \
+ -@[ ${.ERROR_EXIT:U0} = 6 ] && exit 0; \
+ [ "${.ERROR_META_FILE}" ] && { \
grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \
mkdir -p ${meta_error_log:H}; \
cp ${.ERROR_META_FILE} ${meta_error_log}; \
diff --git a/contrib/bmake/mk/meta2deps.py b/contrib/bmake/mk/meta2deps.py
index d7820ec71b5b..f188d0f01de8 100755
--- a/contrib/bmake/mk/meta2deps.py
+++ b/contrib/bmake/mk/meta2deps.py
@@ -36,8 +36,10 @@ We only pay attention to a subset of the information in the
"""
"""
+SPDX-License-Identifier: BSD-2-Clause
+
RCSid:
- $Id: meta2deps.py,v 1.45 2023/01/18 01:35:24 sjg Exp $
+ $Id: meta2deps.py,v 1.47 2024/02/17 17:26:57 sjg Exp $
Copyright (c) 2011-2020, Simon J. Gerraty
Copyright (c) 2011-2017, Juniper Networks, Inc.
@@ -74,8 +76,10 @@ import stat
def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
"""
Return an absolute path, resolving via cwd or last_dir if needed.
+
+ Cleanup any leading ``./`` and trailing ``/.``
"""
- if path.endswith('/.'):
+ while path.endswith('/.'):
path = path[0:-2]
if len(path) > 0 and path[0] == '/':
if os.path.exists(path):
@@ -86,7 +90,9 @@ def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
if path == '.':
return cwd
if path.startswith('./'):
- return cwd + path[1:]
+ while path.startswith('./'):
+ path = path[1:]
+ return cwd + path
if last_dir == cwd:
last_dir = None
for d in [last_dir, cwd]:
@@ -144,6 +150,7 @@ def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr):
return None
if (path.find('/') < 0 or
path.find('./') > 0 or
+ path.find('/../') > 0 or
path.endswith('/..')):
path = cleanpath(path)
return path
diff --git a/contrib/bmake/mk/meta2deps.sh b/contrib/bmake/mk/meta2deps.sh
index d590a383f82e..4c1b674f7b63 100755
--- a/contrib/bmake/mk/meta2deps.sh
+++ b/contrib/bmake/mk/meta2deps.sh
@@ -75,8 +75,10 @@
# RCSid:
-# $Id: meta2deps.sh,v 1.20 2023/01/18 01:35:24 sjg Exp $
+# $Id: meta2deps.sh,v 1.21 2024/02/17 17:26:57 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
#
diff --git a/contrib/bmake/mk/mkopt.sh b/contrib/bmake/mk/mkopt.sh
index 91dd8f0d9cbe..24320c257250 100644
--- a/contrib/bmake/mk/mkopt.sh
+++ b/contrib/bmake/mk/mkopt.sh
@@ -1,6 +1,8 @@
#!/bin/sh
-# $Id: mkopt.sh,v 1.15 2022/06/06 21:34:21 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: mkopt.sh,v 1.16 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2014-2022, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/newlog.sh b/contrib/bmake/mk/newlog.sh
index 526d1700d98f..5c65e5dd5fb6 100755
--- a/contrib/bmake/mk/newlog.sh
+++ b/contrib/bmake/mk/newlog.sh
@@ -76,7 +76,9 @@
#
# RCSid:
-# $Id: newlog.sh,v 1.26 2021/04/30 16:29:02 sjg Exp $
+# $Id: newlog.sh,v 1.27 2024/02/17 17:26:57 sjg Exp $
+#
+# SPDX-License-Identifier: BSD-2-Clause
#
# @(#) Copyright (c) 1993-2016 Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/obj.mk b/contrib/bmake/mk/obj.mk
index 0df5a087f972..eac8e9e05891 100644
--- a/contrib/bmake/mk/obj.mk
+++ b/contrib/bmake/mk/obj.mk
@@ -1,4 +1,6 @@
-# $Id: obj.mk,v 1.17 2021/12/08 05:56:50 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: obj.mk,v 1.19 2024/02/19 00:06:19 sjg Exp $
#
# @(#) Copyright (c) 1999-2010, Simon J. Gerraty
#
@@ -13,8 +15,11 @@
# sjg@crufty.net
#
-.if !target(__${.PARSEFILE:S,bsd.,,}__)
-__${.PARSEFILE:S,bsd.,,}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
.include <init.mk>
diff --git a/contrib/bmake/mk/options.mk b/contrib/bmake/mk/options.mk
index bf78ba24f1ca..363fc53baf14 100644
--- a/contrib/bmake/mk/options.mk
+++ b/contrib/bmake/mk/options.mk
@@ -1,4 +1,6 @@
-# $Id: options.mk,v 1.19 2021/10/03 16:29:51 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: options.mk,v 1.20 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2012, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/own.mk b/contrib/bmake/mk/own.mk
index 5f0eb0d09f2a..efadd3469a8d 100644
--- a/contrib/bmake/mk/own.mk
+++ b/contrib/bmake/mk/own.mk
@@ -1,7 +1,10 @@
-# $Id: own.mk,v 1.45 2023/12/30 02:10:38 sjg Exp $
+# $Id: own.mk,v 1.47 2024/02/19 00:06:19 sjg Exp $
-.if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
.if !target(__init.mk__)
.include "init.mk"
@@ -37,27 +40,6 @@ libprefix?= /usr
# FreeBSD at least does not set this
MACHINE_ARCH?= ${MACHINE}
# we need to make sure these are defined too in case sys.mk fails to.
-COMPILE.s?= ${CC} ${AFLAGS} -c
-LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS}
-COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
-LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
-COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
-LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
-CXXFLAGS?= ${CFLAGS}
-COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
-LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
-COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
-LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
-COMPILE.f?= ${FC} ${FFLAGS} -c
-LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS}
-COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
-LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
-COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c
-LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
-LEX.l?= ${LEX} ${LFLAGS}
-COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
-LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
-YACC.y?= ${YACC} ${YFLAGS}
# for suffix rules
IMPFLAGS?= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}}
diff --git a/contrib/bmake/mk/posix.mk b/contrib/bmake/mk/posix.mk
index 60b2fe0d9346..b7cb9ef32108 100644
--- a/contrib/bmake/mk/posix.mk
+++ b/contrib/bmake/mk/posix.mk
@@ -1,4 +1,6 @@
-# $Id: posix.mk,v 1.2 2022/03/25 23:55:37 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: posix.mk,v 1.3 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2022, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/prlist.mk b/contrib/bmake/mk/prlist.mk
index 3308a9522c89..b6912a8d9601 100644
--- a/contrib/bmake/mk/prlist.mk
+++ b/contrib/bmake/mk/prlist.mk
@@ -1,4 +1,6 @@
-# $Id: prlist.mk,v 1.5 2021/12/08 05:56:50 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: prlist.mk,v 1.6 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2006, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/prog.mk b/contrib/bmake/mk/prog.mk
index 9afa908d507f..aac2a4d3da28 100644
--- a/contrib/bmake/mk/prog.mk
+++ b/contrib/bmake/mk/prog.mk
@@ -1,7 +1,10 @@
-# $Id: prog.mk,v 1.40 2023/10/02 21:35:43 sjg Exp $
+# $Id: prog.mk,v 1.44 2024/02/19 00:06:19 sjg Exp $
-.if !target(__${.PARSEFILE}__)
-__${.PARSEFILE}__: .NOTMAIN
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
.include <init.mk>
@@ -11,7 +14,7 @@ _sect:=${MAN:E}
MAN${_sect}=${MAN}
.endif
-.SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0
+.SUFFIXES: .out .o .c ${CXX_SUFFIXES} .y .l ${CCM_SUFFIXES} ${PCM}
CFLAGS+= ${COPTS}
@@ -62,14 +65,21 @@ LDADD_LAST+= ${LDADD_LIBC_P}
.if defined(SHAREDSTRINGS)
CLEANFILES+=strings
.c.o:
- ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c -
- @${CC} ${CFLAGS} -c x.c -o ${.TARGET}
+ @${COMPILE.c:N-c} -E ${.IMPSRC} | xstr -c -
+ @${COMPILE.c} x.c -o ${.TARGET}
@rm -f x.c
-${CXX_SUFFIXES:%=%.o}:
- ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c -
+# precompiled C++ Modules
+${CCM_SUFFIXES:%=%${PCM}}:
+ @${COMIPILE.cc:N-c} -E ${.IMPSRC} | xstr -c -
+ @mv -f x.c x.cc
+ @${COMPILE.pcm} x.cc -o ${.TARGET}
+ @rm -f x.cc
+
+${CXX_SUFFIXES:N.c*m:%=%.o}:
+ @${COMIPILE.cc:N-c} -E ${.IMPSRC} | xstr -c -
@mv -f x.c x.cc
- @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET}
+ @${COMPILE.cc} x.cc -o ${.TARGET}
@rm -f x.cc
.endif
@@ -81,12 +91,19 @@ _SUPCXX?= -lstdc++ -lm
.if defined(PROG)
BINDIR ?= ${prefix}/bin
-SRCS?= ${PROG}.c
-.for s in ${SRCS:N*.h:N*.sh:M*/*}
+.if empty(SRCS)
+# init.mk handling of QUALIFIED_VAR_LIST means
+# SRCS will be defined - even if empty.
+SRCS = ${PROG}.c
+.endif
+
+SRCS ?= ${PROG}.c
+OBJS_SRCS = ${SRCS:${OBJS_SRCS_FILTER}}
+.for s in ${OBJS_SRCS:M*/*}
${.o .po .lo:L:@o@${s:T:R}$o@}: $s
.endfor
-.if !empty(SRCS:N*.h:N*.sh)
-OBJS+= ${SRCS:T:N*.h:N*.sh:R:S/$/.o/g}
+.if !empty(OBJS_SRCS)
+OBJS+= ${OBJS_SRCS:T:R:S/$/.o/g}
LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
.endif
@@ -111,6 +128,9 @@ ${PROG}: ldorder
.include <ldorder.mk>
.endif
+# avoid -dL errors
+LDADD_LDORDER ?=
+LDSTATIC ?=
.if defined(DESTDIR) && exists(${LIBCRT0}) && ${LIBCRT0} != "/dev/null"
diff --git a/contrib/bmake/mk/progs.mk b/contrib/bmake/mk/progs.mk
index 16c381a50bf9..815449f331b5 100644
--- a/contrib/bmake/mk/progs.mk
+++ b/contrib/bmake/mk/progs.mk
@@ -1,4 +1,6 @@
-# $Id: progs.mk,v 1.16 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: progs.mk,v 1.17 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2006, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/rst2htm.mk b/contrib/bmake/mk/rst2htm.mk
index d7e98d087fd1..4da16f144e9e 100644
--- a/contrib/bmake/mk/rst2htm.mk
+++ b/contrib/bmake/mk/rst2htm.mk
@@ -1,4 +1,6 @@
-# $Id: rst2htm.mk,v 1.14 2023/09/19 22:27:28 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: rst2htm.mk,v 1.15 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2009, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/scripts.mk b/contrib/bmake/mk/scripts.mk
index 5ea2474e65a3..36d8f2901397 100644
--- a/contrib/bmake/mk/scripts.mk
+++ b/contrib/bmake/mk/scripts.mk
@@ -1,4 +1,6 @@
-# $Id: scripts.mk,v 1.4 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: scripts.mk,v 1.5 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2006, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/srctop.mk b/contrib/bmake/mk/srctop.mk
index 91594c7a98e4..ba4034e6d802 100644
--- a/contrib/bmake/mk/srctop.mk
+++ b/contrib/bmake/mk/srctop.mk
@@ -1,4 +1,6 @@
-# $Id: srctop.mk,v 1.4 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: srctop.mk,v 1.5 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2012, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/stage-install.sh b/contrib/bmake/mk/stage-install.sh
index 97d50871f95c..d9182e32feff 100755
--- a/contrib/bmake/mk/stage-install.sh
+++ b/contrib/bmake/mk/stage-install.sh
@@ -37,7 +37,9 @@
#
# RCSid:
-# $Id: stage-install.sh,v 1.10 2021/11/17 07:06:31 sjg Exp $
+# $Id: stage-install.sh,v 1.11 2024/02/17 17:26:57 sjg Exp $
+#
+# SPDX-License-Identifier: BSD-2-Clause
#
# @(#) Copyright (c) 2013-2020, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/subdir.mk b/contrib/bmake/mk/subdir.mk
index 1d5001acd2a2..4ae21065c865 100644
--- a/contrib/bmake/mk/subdir.mk
+++ b/contrib/bmake/mk/subdir.mk
@@ -1,14 +1,42 @@
-# $Id: subdir.mk,v 1.16 2017/02/08 22:16:59 sjg Exp $
-# skip missing directories...
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: subdir.mk,v 1.22 2024/02/19 00:06:19 sjg Exp $
+#
+# @(#) Copyright (c) 2002-2024, Simon J. Gerraty
+#
+# This file is provided in the hope that it will
+# be of use. There is absolutely NO WARRANTY.
+# Permission to copy, redistribute or otherwise
+# use this file is hereby granted provided that
+# the above copyright notice and this notice are
+# left intact.
+#
+# Please send copies of changes and bug-fixes to:
+# sjg@crufty.net
-# $NetBSD: bsd.subdir.mk,v 1.11 1996/04/04 02:05:06 jtc Exp $
-# @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91
+# if SUBDIR=@auto replace that with each subdir that has
+# a [Mm]akefile.
+#
+# Unless SUBDIR_MUST_EXIST is defined, missing subdirs
+# are ignored (to allow for sparse checkout).
+#
+# If you use _SUBDIRUSE for a target you may need to add it to
+# SUBDIR_TARGETS.
-.if ${.MAKE.LEVEL} == 0 && ${.MAKE.MODE:Uno:Mmeta*} != ""
+# should be set properly in sys.mk
+_this ?= ${.PARSEFILE:S,bsd.,,}
+
+.if !target(__${_this}__)
+__${_this}__: .NOTMAIN
+
+.if defined(SUBDIR)
+
+.if ${.MAKE.LEVEL} == 0 && ${MK_DIRDEPS_BUILD:Uno} == "yes"
.include <meta.subdir.mk>
# keep everyone happy
_SUBDIRUSE:
.elif !commands(_SUBDIRUSE) && !defined(NO_SUBDIR) && !defined(NOSUBDIR)
+.-include <local.subdir.mk>
.-include <${.CURDIR}/Makefile.inc>
.if !target(.MAIN)
.MAIN: all
@@ -16,49 +44,28 @@ _SUBDIRUSE:
ECHO_DIR ?= echo
.ifdef SUBDIR_MUST_EXIST
-MISSING_DIR=echo "Missing ===> ${.CURDIR}/$${entry}"; exit 1
+MISSING_DIR=echo "Missing ===> ${.CURDIR}/$$_dir"; exit 1
.else
-MISSING_DIR=echo "Skipping ===> ${.CURDIR}/$${entry}"; continue
+MISSING_DIR=echo "Skipping ===> ${.CURDIR}/$$_dir"; exit 0
.endif
-_SUBDIRUSE: .USE
-.if defined(SUBDIR)
+# the actual implementation
+# our target should be of the form ${_target}-${_dir}
+_SUBDIR_USE: .USE
@Exists() { test -f $$1; }; \
- for entry in ${SUBDIR}; do \
- (set -e; \
- if Exists ${.CURDIR}/$${entry}.${MACHINE}/[mM]akefile; then \
- _newdir_="$${entry}.${MACHINE}"; \
- elif Exists ${.CURDIR}/$${entry}/[mM]akefile; then \
- _newdir_="$${entry}"; \
- else \
- ${MISSING_DIR}; \
- fi; \
- if test X"${_THISDIR_}" = X""; then \
- _nextdir_="$${_newdir_}"; \
- else \
- _nextdir_="$${_THISDIR_}/$${_newdir_}"; \
- fi; \
- ${ECHO_DIR} "===> $${_nextdir_}"; \
- cd ${.CURDIR}/$${_newdir_}; \
- ${.MAKE} _THISDIR_="$${_nextdir_}" \
- ${.TARGET:S/realinstall/install/:S/.depend/depend/}) || exit 1; \
- done
-
-${SUBDIR}::
- @set -e; _r=${.CURDIR}/; \
- if test -z "${.TARGET:M/*}"; then \
- if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \
- _newdir_=${.TARGET}.${MACHINE}; \
- else \
- _newdir_=${.TARGET}; \
- fi; \
+ _dir=${.TARGET:C/^.*-//} \
+ _target=${.TARGET:C/-.*//:S/real//:S/.depend/depend/}; \
+ if ! Exists ${.CURDIR}/$$_dir/[mM]akefile; then \
+ ${MISSING_DIR}; \
+ fi; \
+ if test X"${_THISDIR_}" = X""; then \
+ _nextdir_="$$_dir"; \
else \
- _r= _newdir_=${.TARGET}; \
+ _nextdir_="$${_THISDIR_}/$$_dir"; \
fi; \
- ${ECHO_DIR} "===> $${_newdir_}"; \
- cd $${_r}$${_newdir_}; \
- ${.MAKE} _THISDIR_="$${_newdir_}" all
-.endif
+ ${ECHO_DIR} "===> $${_nextdir_} ($$_target)"; \
+ (cd ${.CURDIR}/$$_dir && \
+ ${.MAKE} _THISDIR_="$${_nextdir_}" $$_target)
.if !target(install)
.if !target(beforeinstall)
@@ -73,26 +80,54 @@ afterinstall: realinstall
realinstall: beforeinstall _SUBDIRUSE
.endif
-.if defined(SRCS)
-etags: ${SRCS}
- -cd ${.CURDIR}; etags `echo ${.ALLSRC:N*.h} | sed 's;${.CURDIR}/;;'`
-.endif
+# the interface from others
+# this may require additions to SUBDIR_TAREGTS
+_SUBDIRUSE: .USE subdir-${.TARGET}
SUBDIR_TARGETS += \
all \
clean \
cleandir \
includes \
+ install \
depend \
lint \
obj \
+ realinstall \
tags \
etags
+.if ${SUBDIR} == "@auto"
+SUBDIR = ${echo ${.CURDIR}/*/[Mm]akefile:L:sh:H:T:O:N\*}
+.endif
+
+__subdirs =
+.for d in ${SUBDIR}
+.if $d != ".WAIT" && exists(${.CURDIR}/$d.${MACHINE})
+__subdirs += $d.${MACHINE}
+.else
+__subdirs += $d
+.endif
+.endfor
+
.for t in ${SUBDIR_TARGETS:O:u}
-$t: _SUBDIRUSE
+__subdir_$t =
+.for d in ${__subdirs}
+.if $d == ".WAIT"
+__subdir_$t += $d
+.elif !commands($t-$d)
+$t-$d: .PHONY .MAKE _SUBDIR_USE
+__subdir_$t += $t-$d
+.endif
+.endfor
+subdir-$t: .PHONY ${__subdir_$t}
+$t: subdir-$t
.endfor
+.else
+_SUBDIRUSE:
+.endif # SUBDIR
+
.include <own.mk>
.if make(destroy*)
.include <obj.mk>
@@ -100,3 +135,5 @@ $t: _SUBDIRUSE
.endif
# make sure this exists
all:
+
+.endif
diff --git a/contrib/bmake/mk/suffixes.mk b/contrib/bmake/mk/suffixes.mk
new file mode 100644
index 000000000000..4c4c85e68220
--- /dev/null
+++ b/contrib/bmake/mk/suffixes.mk
@@ -0,0 +1,195 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: suffixes.mk,v 1.3 2024/02/17 17:26:57 sjg Exp $
+#
+# @(#) Copyright (c) 2024, Simon J. Gerraty
+#
+# This file is provided in the hope that it will
+# be of use. There is absolutely NO WARRANTY.
+# Permission to copy, redistribute or otherwise
+# use this file is hereby granted provided that
+# the above copyright notice and this notice are
+# left intact.
+#
+# Please send copies of changes and bug-fixes to:
+# sjg@crufty.net
+#
+
+# some reasonable defaults
+.SUFFIXES: .out .a .ln .o ${PICO} ${PCM} .s .S .c ${CXX_SUFFIXES} \
+ ${CCM_SUFFIXES} .F .f .r .y .l .cl .p .h \
+ .sh .m4 .cpp-out
+
+#
+AFLAGS ?=
+ARFLAGS ?= r
+.if ${MACHINE_ARCH} == "sparc64"
+AFLAGS+= -Wa,-Av9a
+.endif
+AS ?= as
+CC ?= cc
+CFLAGS ?= ${DBG}
+CXX ?= c++
+CXXFLAGS ?= ${CFLAGS}
+CXXFLAGS ?= ${CFLAGS}
+DBG ?= -O2
+FC ?= f77
+FFLAGS ?= -O
+INSTALL ?= install
+LD ?= ld
+LEX ?= lex
+LFLAGS ?=
+NM ?= nm
+OBJC ?= ${CC}
+OBJCFLAGS ?= ${CFLAGS}
+PC ?= pc
+PFLAGS ?=
+RFLAGS ?=
+SIZE ?= size
+YACC ?= yacc
+YFLAGS ?=
+
+COMPILE.s ?= ${CC} ${AFLAGS} -c
+LINK.s ?= ${CC} ${AFLAGS} ${LDFLAGS}
+COMPILE.S ?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
+LINK.S ?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.c ?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
+LINK.c ?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.cc ?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
+COMPILE.pcm ?= ${COMPILE.cc:N-c} --precompile -c
+LINK.cc ?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.m ?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
+LINK.m ?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.f ?= ${FC} ${FFLAGS} -c
+LINK.f ?= ${FC} ${FFLAGS} ${LDFLAGS}
+COMPILE.F ?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
+LINK.F ?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
+COMPILE.r ?= ${FC} ${FFLAGS} ${RFLAGS} -c
+LINK.r ?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
+LEX.l ?= ${LEX} ${LFLAGS}
+COMPILE.p ?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
+LINK.p ?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
+YACC.y ?= ${YACC} ${YFLAGS}
+LEX.l ?= ${LEX} ${LFLAGS}
+
+# C
+.c:
+ ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.c.o:
+ ${COMPILE.c} ${.IMPSRC}
+.c.a:
+ ${COMPILE.c} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.c.ln:
+ ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
+
+# C++
+${CXX_SUFFIXES}:
+ ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+${CXX_SUFFIXES:%=%.o}:
+ ${COMPILE.cc} ${.IMPSRC}
+${CXX_SUFFIXES:%=%.a}:
+ ${COMPILE.cc} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# C++ precompiled modules
+${CCM_SUFFIXES:%=%${PCM}}:
+ @${COMPILE.pcm} ${.IMPSRC}
+
+# Fortran/Ratfor
+.f:
+ ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.f.o:
+ ${COMPILE.f} ${.IMPSRC}
+.f.a:
+ ${COMPILE.f} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.F:
+ ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.F.o:
+ ${COMPILE.F} ${.IMPSRC}
+.F.a:
+ ${COMPILE.F} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+.r:
+ ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.r.o:
+ ${COMPILE.r} ${.IMPSRC}
+.r.a:
+ ${COMPILE.r} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Pascal
+.p:
+ ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.p.o:
+ ${COMPILE.p} ${.IMPSRC}
+.p.a:
+ ${COMPILE.p} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Assembly
+.s:
+ ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.s.o:
+ ${COMPILE.s} ${.IMPSRC}
+.s.a:
+ ${COMPILE.s} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+.S:
+ ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
+.S.o:
+ ${COMPILE.S} ${.IMPSRC}
+.S.a:
+ ${COMPILE.S} ${.IMPSRC}
+ ${AR} ${ARFLAGS} $@ $*.o
+ rm -f $*.o
+
+# Lex
+.l:
+ ${LEX.l} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
+ rm -f lex.yy.c
+.l.c:
+ ${LEX.l} ${.IMPSRC}
+ mv lex.yy.c ${.TARGET}
+.l.o:
+ ${LEX.l} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} lex.yy.c
+ rm -f lex.yy.c
+
+# Yacc
+.y:
+ ${YACC.y} ${.IMPSRC}
+ ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
+ rm -f y.tab.c
+.y.c:
+ ${YACC.y} ${.IMPSRC}
+ mv y.tab.c ${.TARGET}
+.y.o:
+ ${YACC.y} ${.IMPSRC}
+ ${COMPILE.c} -o ${.TARGET} y.tab.c
+ rm -f y.tab.c
+
+# Shell
+.sh:
+ rm -f ${.TARGET}
+ cp ${.IMPSRC} ${.TARGET}
+ chmod a+x ${.TARGET}
+
+
+# this often helps with debugging
+.c.cpp-out:
+ @${COMPILE.c:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
+
+${CXX_SUFFIXES:%=%.cpp-out}:
+ @${COMPILE.cc:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
diff --git a/contrib/bmake/mk/sys.clean-env.mk b/contrib/bmake/mk/sys.clean-env.mk
index 1d0119d6d37a..6cdb42718da0 100644
--- a/contrib/bmake/mk/sys.clean-env.mk
+++ b/contrib/bmake/mk/sys.clean-env.mk
@@ -1,4 +1,6 @@
-# $Id: sys.clean-env.mk,v 1.25 2022/09/09 17:44:29 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: sys.clean-env.mk,v 1.26 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2009, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/sys.debug.mk b/contrib/bmake/mk/sys.debug.mk
index 7fde27c24fdb..3b253ad73ed4 100644
--- a/contrib/bmake/mk/sys.debug.mk
+++ b/contrib/bmake/mk/sys.debug.mk
@@ -1,4 +1,6 @@
-# $Id: sys.debug.mk,v 1.2 2020/08/19 17:51:53 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: sys.debug.mk,v 1.3 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2009, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/sys.dependfile.mk b/contrib/bmake/mk/sys.dependfile.mk
index 49232646d569..3c13b1c92bff 100644
--- a/contrib/bmake/mk/sys.dependfile.mk
+++ b/contrib/bmake/mk/sys.dependfile.mk
@@ -1,4 +1,6 @@
-# $Id: sys.dependfile.mk,v 1.10 2023/05/10 19:23:26 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: sys.dependfile.mk,v 1.11 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2012-2023, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/sys.dirdeps.mk b/contrib/bmake/mk/sys.dirdeps.mk
index a3d22d7c2e82..1e3363c22339 100644
--- a/contrib/bmake/mk/sys.dirdeps.mk
+++ b/contrib/bmake/mk/sys.dirdeps.mk
@@ -1,4 +1,6 @@
-# $Id: sys.dirdeps.mk,v 1.12 2023/05/14 16:16:03 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: sys.dirdeps.mk,v 1.14 2024/02/25 19:12:13 sjg Exp $
#
# @(#) Copyright (c) 2012-2023, Simon J. Gerraty
#
@@ -31,9 +33,10 @@ _PARSEDIR ?= ${.PARSEDIR:tA}
.if ${.MAKE.LEVEL} == 0
# make sure dirdeps target exists and do it first
+# init.mk will set .MAIN to 'dirdeps' if appropriate
+# as will dirdeps-targets.mk for top-level builds.
+# This allows a Makefile to have more control.
dirdeps:
-# first .MAIN is what counts
-.MAIN: dirdeps
.NOPATH: dirdeps
all: dirdeps .WAIT
.endif
diff --git a/contrib/bmake/mk/sys.mk b/contrib/bmake/mk/sys.mk
index 365989158022..b950d991e321 100644
--- a/contrib/bmake/mk/sys.mk
+++ b/contrib/bmake/mk/sys.mk
@@ -1,4 +1,6 @@
-# $Id: sys.mk,v 1.57 2023/07/14 16:30:37 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: sys.mk,v 1.60 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2003-2023, Simon J. Gerraty
#
@@ -46,6 +48,11 @@ _TARGETS := ${.TARGETS}
# Popular suffixes for C++
CXX_SUFFIXES += .cc .cpp .cxx .C
CXX_SUFFIXES := ${CXX_SUFFIXES:O:u}
+# and C++ Modules
+CCM_SUFFIXES += .ccm
+CCM_SUFFIXES := ${CCM_SUFFIXES:O:u}
+# precompiled modules
+PCM ?= .pcm
SYS_MK ?= ${.PARSEDIR:tA}/${.PARSEFILE}
SYS_MK := ${SYS_MK}
@@ -152,14 +159,8 @@ Mkdirs= Mkdirs() { \
mkdir $$d || exit $$?; \
done; }
-# this often helps with debugging
-.SUFFIXES: .cpp-out
-
-.c.cpp-out:
- @${COMPILE.c:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
-
-${CXX_SUFFIXES:%=%.cpp-out}:
- @${COMPILE.cc:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$'
+# pick up generic suffix rules
+.include <suffixes.mk>
# late customizations
.-include <local.sys.mk>
diff --git a/contrib/bmake/mk/sys.vars.mk b/contrib/bmake/mk/sys.vars.mk
index 974f24ca00b8..d8e0dd4f2930 100644
--- a/contrib/bmake/mk/sys.vars.mk
+++ b/contrib/bmake/mk/sys.vars.mk
@@ -1,4 +1,6 @@
-# $Id: sys.vars.mk,v 1.15 2023/05/16 16:41:52 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: sys.vars.mk,v 1.16 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2003-2023, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/sys/Generic.mk b/contrib/bmake/mk/sys/Generic.mk
index 22f6dcc0a84f..d9c958ffff94 100644
--- a/contrib/bmake/mk/sys/Generic.mk
+++ b/contrib/bmake/mk/sys/Generic.mk
@@ -1,9 +1,7 @@
-# $Id: Generic.mk,v 1.19 2022/03/25 23:43:06 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: Generic.mk,v 1.21 2024/02/17 17:26:57 sjg Exp $
#
-
-# some reasonable defaults
-.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h
-.SUFFIXES: .sh .m4
.LIBS: .a
@@ -27,178 +25,4 @@ MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}}
TSORT += -q
.endif
-ARFLAGS ?= r
-
-AS ?= as
-AFLAGS ?=
-.if ${MACHINE_ARCH} == "sparc64"
-AFLAGS+= -Wa,-Av9a
-.endif
-COMPILE.s ?= ${CC} ${AFLAGS} -c
-LINK.s ?= ${CC} ${AFLAGS} ${LDFLAGS}
-COMPILE.S ?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp
-LINK.S ?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS}
-
-CC ?= cc
-DBG ?= -O2
-CFLAGS ?= ${DBG}
-COMPILE.c ?= ${CC} ${CFLAGS} ${CPPFLAGS} -c
-LINK.c ?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}
-
-CXX ?= c++
-CXXFLAGS ?= ${CFLAGS}
-COMPILE.cc ?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c
-LINK.cc ?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS}
-
-OBJC ?= ${CC}
-OBJCFLAGS ?= ${CFLAGS}
-COMPILE.m ?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c
-LINK.m ?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS}
-
-CPP ?= cpp
-CPPFLAGS ?=
-
-FC ?= f77
-FFLAGS ?= -O
-RFLAGS ?=
-COMPILE.f ?= ${FC} ${FFLAGS} -c
-LINK.f ?= ${FC} ${FFLAGS} ${LDFLAGS}
-COMPILE.F ?= ${FC} ${FFLAGS} ${CPPFLAGS} -c
-LINK.F ?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS}
-COMPILE.r ?= ${FC} ${FFLAGS} ${RFLAGS} -c
-LINK.r ?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS}
-
-INSTALL ?= install
-
-LEX ?= lex
-LFLAGS ?=
-LEX.l ?= ${LEX} ${LFLAGS}
-
-LD ?= ld
-LDFLAGS ?=
-
-LINT ?= lint
-LINTFLAGS ?= -chapbxzF
-
-NM ?= nm
-
-PC ?= pc
-PFLAGS ?=
-COMPILE.p ?= ${PC} ${PFLAGS} ${CPPFLAGS} -c
-LINK.p ?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS}
-
-SIZE ?= size
-
-YACC ?= yacc
-YFLAGS ?=
-YACC.y ?= ${YACC} ${YFLAGS}
-
-# C
-.c:
- ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.c.o:
- ${COMPILE.c} ${.IMPSRC}
-.c.a:
- ${COMPILE.c} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-.c.ln:
- ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC}
-
-# C++
-${CXX_SUFFIXES}:
- ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-${CXX_SUFFIXES:%=%.o}:
- ${COMPILE.cc} ${.IMPSRC}
-${CXX_SUFFIXES:%=%.a}:
- ${COMPILE.cc} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-
-# Fortran/Ratfor
-.f:
- ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.f.o:
- ${COMPILE.f} ${.IMPSRC}
-.f.a:
- ${COMPILE.f} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-
-.F:
- ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.F.o:
- ${COMPILE.F} ${.IMPSRC}
-.F.a:
- ${COMPILE.F} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-
-.r:
- ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.r.o:
- ${COMPILE.r} ${.IMPSRC}
-.r.a:
- ${COMPILE.r} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-
-# Pascal
-.p:
- ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.p.o:
- ${COMPILE.p} ${.IMPSRC}
-.p.a:
- ${COMPILE.p} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-
-# Assembly
-.s:
- ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.s.o:
- ${COMPILE.s} ${.IMPSRC}
-.s.a:
- ${COMPILE.s} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-.S:
- ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS}
-.S.o:
- ${COMPILE.S} ${.IMPSRC}
-.S.a:
- ${COMPILE.S} ${.IMPSRC}
- ${AR} ${ARFLAGS} $@ $*.o
- rm -f $*.o
-
-# Lex
-.l:
- ${LEX.l} ${.IMPSRC}
- ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll
- rm -f lex.yy.c
-.l.c:
- ${LEX.l} ${.IMPSRC}
- mv lex.yy.c ${.TARGET}
-.l.o:
- ${LEX.l} ${.IMPSRC}
- ${COMPILE.c} -o ${.TARGET} lex.yy.c
- rm -f lex.yy.c
-
-# Yacc
-.y:
- ${YACC.y} ${.IMPSRC}
- ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS}
- rm -f y.tab.c
-.y.c:
- ${YACC.y} ${.IMPSRC}
- mv y.tab.c ${.TARGET}
-.y.o:
- ${YACC.y} ${.IMPSRC}
- ${COMPILE.c} -o ${.TARGET} y.tab.c
- rm -f y.tab.c
-# Shell
-.sh:
- rm -f ${.TARGET}
- cp ${.IMPSRC} ${.TARGET}
- chmod a+x ${.TARGET}
diff --git a/contrib/bmake/mk/target-flags.mk b/contrib/bmake/mk/target-flags.mk
index 789f09b23115..d31e200f7ebf 100644
--- a/contrib/bmake/mk/target-flags.mk
+++ b/contrib/bmake/mk/target-flags.mk
@@ -36,8 +36,10 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
# RCSid:
-# $Id: target-flags.mk,v 1.10 2020/08/19 17:51:53 sjg Exp $
+# $Id: target-flags.mk,v 1.11 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 1998-2002, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/warnings.mk b/contrib/bmake/mk/warnings.mk
index 18d3273c9465..8fd9a2ea2048 100644
--- a/contrib/bmake/mk/warnings.mk
+++ b/contrib/bmake/mk/warnings.mk
@@ -1,5 +1,7 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
# RCSid:
-# $Id: warnings.mk,v 1.17 2023/02/16 17:55:52 sjg Exp $
+# $Id: warnings.mk,v 1.18 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2002-2023, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/whats.mk b/contrib/bmake/mk/whats.mk
index 16086e54d924..81708c2225b1 100644
--- a/contrib/bmake/mk/whats.mk
+++ b/contrib/bmake/mk/whats.mk
@@ -1,4 +1,6 @@
-# $Id: whats.mk,v 1.11 2023/01/29 17:29:13 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: whats.mk,v 1.12 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 2014-2020, Simon J. Gerraty
#
diff --git a/contrib/bmake/mk/yacc.mk b/contrib/bmake/mk/yacc.mk
index cdb8a657b542..30e377d1991c 100644
--- a/contrib/bmake/mk/yacc.mk
+++ b/contrib/bmake/mk/yacc.mk
@@ -1,4 +1,6 @@
-# $Id: yacc.mk,v 1.8 2022/06/22 04:51:06 sjg Exp $
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: yacc.mk,v 1.9 2024/02/17 17:26:57 sjg Exp $
#
# @(#) Copyright (c) 1999-2011, Simon J. Gerraty
diff --git a/contrib/bmake/parse.c b/contrib/bmake/parse.c
index 824def432753..d6d1c9ba9874 100644
--- a/contrib/bmake/parse.c
+++ b/contrib/bmake/parse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.717 2024/02/07 06:43:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.717 2024/02/07 06:43:02 rillig Exp $");
/* Detects a multiple-inclusion guard in a makefile. */
typedef enum {
@@ -183,9 +183,7 @@ typedef enum ParseSpecial {
SP_PARALLEL, /* .PARALLEL; not mentioned in the manual page */
SP_PATH, /* .PATH or .PATH.suffix */
SP_PHONY, /* .PHONY */
-#ifdef POSIX
SP_POSIX, /* .POSIX; not mentioned in the manual page */
-#endif
SP_PRECIOUS, /* .PRECIOUS */
SP_READONLY, /* .READONLY */
SP_SHELL, /* .SHELL */
@@ -305,9 +303,7 @@ static const struct {
{ ".PARALLEL", SP_PARALLEL, OP_NONE },
{ ".PATH", SP_PATH, OP_NONE },
{ ".PHONY", SP_PHONY, OP_PHONY },
-#ifdef POSIX
{ ".POSIX", SP_POSIX, OP_NONE },
-#endif
{ ".PRECIOUS", SP_PRECIOUS, OP_PRECIOUS },
{ ".READONLY", SP_READONLY, OP_NONE },
{ ".RECURSIVE", SP_ATTRIBUTE, OP_MAKE },
@@ -1321,7 +1317,6 @@ HandleDependencySourcesEmpty(ParseSpecial special, SearchPathList *paths)
case SP_SYSPATH:
ClearPaths(special, paths);
break;
-#ifdef POSIX
case SP_POSIX:
if (posix_state == PS_NOW_OR_NEVER) {
/*
@@ -1333,7 +1328,6 @@ HandleDependencySourcesEmpty(ParseSpecial special, SearchPathList *paths)
IncludeFile("posix.mk", true, false, true);
}
break;
-#endif
default:
break;
}
@@ -1715,7 +1709,6 @@ AdjustVarassignOp(const char *name, const char *nameEnd, const char *op,
} else {
type = VAR_NORMAL;
-#ifdef SUNSHCMD
while (op > name && ch_isspace(op[-1]))
op--;
@@ -1723,7 +1716,6 @@ AdjustVarassignOp(const char *name, const char *nameEnd, const char *op,
op -= 3;
type = VAR_SHELL;
}
-#endif
}
va.varname = bmake_strsedup(name, nameEnd < op ? nameEnd : op);
@@ -1785,12 +1777,10 @@ Parse_IsVar(const char *p, VarAssign *out_var)
if (ch == '\0')
return false;
-#ifdef SUNSHCMD
if (ch == ':' && p[0] == 's' && p[1] == 'h') {
p += 2;
continue;
}
-#endif
if (ch == '=')
eq = p - 1;
else if (*p == '=' &&
@@ -2217,7 +2207,6 @@ IsInclude(const char *dir, bool sysv)
}
-#ifdef SYSVINCLUDE
/* Check if the line is a SYSV include directive. */
static bool
IsSysVInclude(const char *line)
@@ -2273,9 +2262,7 @@ ParseTraditionalInclude(char *line)
free(all_files);
}
-#endif
-#ifdef GMAKEEXPORT
/* Parse "export <variable>=<value>", and actually export it. */
static void
ParseGmakeExport(char *line)
@@ -2306,7 +2293,6 @@ ParseGmakeExport(char *line)
setenv(variable, value, 1);
free(value);
}
-#endif
/*
* When the end of the current file or .for loop is reached, continue reading
@@ -2923,20 +2909,16 @@ ParseLine(char *line)
return;
}
-#ifdef SYSVINCLUDE
if (IsSysVInclude(line)) {
ParseTraditionalInclude(line);
return;
}
-#endif
-#ifdef GMAKEEXPORT
if (strncmp(line, "export", 6) == 0 && ch_isspace(line[6]) &&
strchr(line, ':') == NULL) {
ParseGmakeExport(line);
return;
}
-#endif
if (Parse_VarAssign(line, true, SCOPE_GLOBAL))
return;
diff --git a/contrib/bmake/suff.c b/contrib/bmake/suff.c
index e5f6ee83e86a..de00cc4e8581 100644
--- a/contrib/bmake/suff.c
+++ b/contrib/bmake/suff.c
@@ -1,4 +1,4 @@
-/* $NetBSD: suff.c,v 1.377 2024/01/05 23:22:06 rillig Exp $ */
+/* $NetBSD: suff.c,v 1.378 2024/02/07 06:43:02 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -115,7 +115,7 @@
#include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
-MAKE_RCSID("$NetBSD: suff.c,v 1.377 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.378 2024/02/07 06:43:02 rillig Exp $");
typedef List SuffixList;
typedef ListNode SuffixListNode;
@@ -856,15 +856,11 @@ Suff_ExtendPaths(void)
for (ln = sufflist.first; ln != NULL; ln = ln->next) {
Suffix *suff = ln->datum;
if (!Lst_IsEmpty(&suff->searchPath->dirs)) {
-#ifdef INCLUDES
if (suff->include)
SearchPath_AddAll(includesPath,
suff->searchPath);
-#endif
-#ifdef LIBRARIES
if (suff->library)
SearchPath_AddAll(libsPath, suff->searchPath);
-#endif
SearchPath_AddAll(suff->searchPath, &dirSearchPath);
} else {
SearchPath_Free(suff->searchPath);
diff --git a/contrib/bmake/targ.c b/contrib/bmake/targ.c
index a3e234a959ff..14c7faba1f2b 100644
--- a/contrib/bmake/targ.c
+++ b/contrib/bmake/targ.c
@@ -1,4 +1,4 @@
-/* $NetBSD: targ.c,v 1.179 2022/12/06 00:12:44 rillig Exp $ */
+/* $NetBSD: targ.c,v 1.180 2024/03/10 02:53:37 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -107,7 +107,7 @@
#include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: targ.c,v 1.179 2022/12/06 00:12:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.180 2024/03/10 02:53:37 sjg Exp $");
/*
* All target nodes that appeared on the left-hand side of one of the
@@ -201,6 +201,7 @@ GNode_New(const char *name)
gn->suffix = NULL;
gn->fname = NULL;
gn->lineno = 0;
+ gn->exit_status = 0;
#ifdef CLEANUP
Lst_Append(&allNodes, gn);
diff --git a/contrib/bmake/unit-tests/Makefile b/contrib/bmake/unit-tests/Makefile
index 111e6325a667..6c41bf811dcf 100644
--- a/contrib/bmake/unit-tests/Makefile
+++ b/contrib/bmake/unit-tests/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.210 2024/01/08 18:28:08 sjg Exp $
+# $Id: Makefile,v 1.211 2024/03/10 17:46:44 sjg Exp $
#
# $NetBSD: Makefile,v 1.342 2024/01/07 02:07:44 sjg Exp $
#
@@ -474,6 +474,15 @@ BROKEN_TESTS+= sh-flags
BROKEN_TESTS+= varmod-localtime
.endif
+.if ${.MAKE.OS:NCYGWIN*} == ""
+BROKEN_TESTS+= \
+ export \
+ opt-chdir \
+ opt-keep-going-indirect \
+
+.endif
+
+
.if ${.MAKE.OS:NDarwin} == ""
BROKEN_TESTS+= shell-ksh
.endif
diff --git a/contrib/bmake/unit-tests/var-scope-local.exp b/contrib/bmake/unit-tests/var-scope-local.exp
index c2e345d8fed8..eddf5985a0ed 100644
--- a/contrib/bmake/unit-tests/var-scope-local.exp
+++ b/contrib/bmake/unit-tests/var-scope-local.exp
@@ -60,12 +60,12 @@ dir/subdir/inference-rule-chain.ir-to: * = <dir/subdir/inference-rule-chain>
: Making var-scope-local.c out of nothing.
: Making var-scope-local.o from var-scope-local.c.
: Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".".
-: Making var-scope-local-assign.o with VAR="local".
-: Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
-: Making var-scope-local-append-global.o with VAR="global+local".
-: Making var-scope-local-default.o with VAR="global".
-: Making var-scope-local-subst.o with VAR="global+local".
-: Making var-scope-local-shell.o with VAR="output".
-: var-scope-local-use.o uses .USE VAR="global"
+Making var-scope-local-assign.o with make 'local' and env 'local'.
+Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
+Making var-scope-local-append-global.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-default.o with make 'global' and env 'global'.
+Making var-scope-local-subst.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-shell.o with make 'output' and env 'output'.
+Making .USE var-scope-local-use.o with make 'global' and env 'global'.
: all overwritten
exit status 0
diff --git a/contrib/bmake/unit-tests/var-scope-local.mk b/contrib/bmake/unit-tests/var-scope-local.mk
index 5c4f5634b230..7a031373e7da 100644
--- a/contrib/bmake/unit-tests/var-scope-local.mk
+++ b/contrib/bmake/unit-tests/var-scope-local.mk
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.9 2023/12/20 09:03:09 rillig Exp $
+# $NetBSD: var-scope-local.mk,v 1.11 2024/03/05 23:07:58 rillig Exp $
#
# Tests for target-local variables, such as ${.TARGET} or $@. These variables
# are relatively short-lived as they are created just before making the
@@ -199,13 +199,14 @@ var-scope-local-append-global.o \
var-scope-local-default.o \
var-scope-local-subst.o \
var-scope-local-shell.o:
- : Making ${.TARGET} with VAR="${VAR}".
+ @echo "Making ${.TARGET} with make '"${VAR:Q}"' and env '$$VAR'."
# Target-local variables are enabled by default. Force them to be enabled
# just in case a test above has disabled them.
.MAKE.TARGET_LOCAL_VARIABLES= yes
VAR= global
+.export VAR
# If the sources of a dependency line look like a variable assignment, make
# treats them as such. There is only a single variable assignment per
@@ -213,7 +214,7 @@ VAR= global
# irrelevant.
#
# expect-reset
-# expect: : Making var-scope-local-assign.o with VAR="local".
+# expect: Making var-scope-local-assign.o with make 'local' and env 'local'.
var-scope-local-assign.o: VAR= local
# Assignments using '+=' do *not* look up the global value, instead they only
@@ -223,7 +224,7 @@ var-scope-local-append.o: VAR+= local
# behaves as expected. Note that the expression '${.TARGET}' is not resolved
# when parsing the dependency line, its evaluation is deferred until the
# target is actually made.
-# expect: : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
+# expect: Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
var-scope-local-append.o: VAR += to ${.TARGET}
# To access the value of a global variable, use an expression. This
# expression is expanded before parsing the whole dependency line. Since the
@@ -233,7 +234,7 @@ var-scope-local-append.o: VAR += to ${.TARGET}
# not influence the parsing of the variable assignment. The effective
# variable assignment, after expanding the whole line first, is thus
# 'VAR= global+local'.
-# expect: : Making var-scope-local-append-global.o with VAR="global+local".
+# expect: Making var-scope-local-append-global.o with make 'global+local' and env 'global+local'.
var-scope-local-append-global.o: VAR= ${VAR}+local
var-scope-local-default.o: VAR ?= first
@@ -241,7 +242,7 @@ var-scope-local-default.o: VAR ?= second
# XXX: '?=' does look at the global variable. That's a long-standing
# inconsistency between the assignment operators '+=' and '?='. See
# Var_AppendExpand and VarAssign_Eval.
-# expect: : Making var-scope-local-default.o with VAR="global".
+# expect: Making var-scope-local-default.o with make 'global' and env 'global'.
# Using the variable assignment operator ':=' provides another way of
# accessing a global variable and extending it with local modifications. The
@@ -249,7 +250,7 @@ var-scope-local-default.o: VAR ?= second
# dependency line as a whole. After that, the parser sees the variable
# assignment as 'VAR := ${VAR}+local' and searches for the variable 'VAR' in
# the usual scopes, picking up the variable from the global scope.
-# expect: : Making var-scope-local-subst.o with VAR="global+local".
+# expect: Making var-scope-local-subst.o with make 'global+local' and env 'global+local'.
var-scope-local-subst.o: VAR := $${VAR}+local
# The variable assignment operator '!=' assigns the output of the shell
@@ -261,9 +262,9 @@ var-scope-local-shell.o: VAR != echo output
# While VAR=use will be set for a .USE node, it will never be seen since only
# the ultimate target's context is searched; the variable assignments from the
# .USE target are not copied to the ultimate target's.
-# expect: : var-scope-local-use.o uses .USE VAR="global"
+# expect: Making .USE var-scope-local-use.o with make 'global' and env 'global'.
a_use: .USE VAR=use
- : ${.TARGET} uses .USE VAR="${VAR}"
+ @echo "Making .USE ${.TARGET} with make '"${VAR:Q}"' and env '$$VAR'."
all: var-scope-local-use.o
var-scope-local-use.o: a_use
diff --git a/contrib/bmake/unit-tests/varmod-indirect.mk b/contrib/bmake/unit-tests/varmod-indirect.mk
index 66714c75dca3..99e7215aa639 100644
--- a/contrib/bmake/unit-tests/varmod-indirect.mk
+++ b/contrib/bmake/unit-tests/varmod-indirect.mk
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.14 2023/11/19 22:32:44 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.18 2024/02/04 10:03:10 rillig Exp $
#
# Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
# These can be used for very basic purposes like converting a string to either
@@ -255,4 +255,28 @@ _:= before ${UNDEF:${:UZ}} after
. error
.endif
-all:
+
+# In parse-only mode, the indirect modifiers must not be evaluated.
+#
+# Before var.c 1.1098 from 2024-02-04, the expression for an indirect modifier
+# was partially evaluated (only the variable value, without applying any
+# modifiers) and then interpreted as modifiers to the main expression.
+#
+# The expression ${:UZ} starts with the value "", and in parse-only mode, the
+# modifier ':UZ' does not modify the expression value. This results in an
+# empty string for the indirect modifiers, generating no warning.
+.if 0 && ${VAR:${:UZ}}
+.endif
+# The expression ${M_invalid} starts with the value "Z", which is an unknown
+# modifier. Trying to apply this unknown modifier generated a warning.
+M_invalid= Z
+.if 0 && ${VAR:${M_invalid}}
+.endif
+# The ':S' modifier does not change the expression value in parse-only mode,
+# keeping the "Z", which is then skipped in parse-only mode.
+.if 0 && ${VAR:${M_invalid:S,^,N*,:ts:}}
+.endif
+# The ':@' modifier does not change the expression value in parse-only mode,
+# keeping the "Z", which is then skipped in parse-only mode.
+.if 0 && ${VAR:${M_invalid:@m@N*$m@:ts:}}
+.endif
diff --git a/contrib/bmake/unit-tests/varmod.exp b/contrib/bmake/unit-tests/varmod.exp
index 19577fa495c7..9ba0cb1d278b 100644
--- a/contrib/bmake/unit-tests/varmod.exp
+++ b/contrib/bmake/unit-tests/varmod.exp
@@ -1,8 +1,8 @@
-make: "varmod.mk" line 98: To escape a dollar, use \$, not $$, at "$$:L} != """
-make: "varmod.mk" line 98: Invalid variable name ':', at "$:L} != """
-make: "varmod.mk" line 104: Dollar followed by nothing
-make: "varmod.mk" line 114: Missing delimiter ':' after modifier "P"
-make: "varmod.mk" line 116: Missing argument for ".error"
+make: "varmod.mk" line 101: To escape a dollar, use \$, not $$, at "$$:L} != """
+make: "varmod.mk" line 101: Invalid variable name ':', at "$:L} != """
+make: "varmod.mk" line 107: Dollar followed by nothing
+make: "varmod.mk" line 117: Missing delimiter ':' after modifier "P"
+make: "varmod.mk" line 119: Missing argument for ".error"
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
diff --git a/contrib/bmake/unit-tests/varmod.mk b/contrib/bmake/unit-tests/varmod.mk
index 8e4c43bdfec7..45707ab9b886 100644
--- a/contrib/bmake/unit-tests/varmod.mk
+++ b/contrib/bmake/unit-tests/varmod.mk
@@ -1,4 +1,4 @@
-# $NetBSD: varmod.mk,v 1.9 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: varmod.mk,v 1.10 2024/02/03 00:20:23 sjg Exp $
#
# Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
#
@@ -56,6 +56,9 @@
# | `u` | strict | | yes |
# | `from=to` | greedy | SysV, fallback | N/A |
+# These tests assume
+.MAKE.SAVE_DOLLARS = yes
+
DOLLAR1= $$
DOLLAR2= ${:U\$}
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c
index 38f0d9b6913d..54d6ef57c497 100644
--- a/contrib/bmake/var.c
+++ b/contrib/bmake/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $ */
+/* $NetBSD: var.c,v 1.1101 2024/03/01 17:53:30 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -125,16 +125,17 @@
#include <sys/stat.h>
#include <sys/types.h>
-#ifndef NO_REGEX
-#include <regex.h>
-#endif
#include "make.h"
#include <errno.h>
+#ifdef HAVE_REGEX_H
+#include <regex.h>
+#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#elif defined(HAVE_STDINT_H)
+#endif
+#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef HAVE_LIMITS_H
@@ -147,7 +148,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1101 2024/03/01 17:53:30 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -600,7 +601,7 @@ MayExport(const char *name)
}
static bool
-ExportVarEnv(Var *v)
+ExportVarEnv(Var *v, GNode *scope)
{
const char *name = v->name.str;
char *val = v->val.data;
@@ -620,7 +621,13 @@ ExportVarEnv(Var *v)
/* XXX: name is injected without escaping it */
expr = str_concat3("${", name, "}");
- val = Var_Subst(expr, SCOPE_GLOBAL, VARE_WANTRES);
+ val = Var_Subst(expr, scope, VARE_WANTRES);
+ if (scope != SCOPE_GLOBAL) {
+ /* we will need to re-export the global version */
+ v = VarFind(name, SCOPE_GLOBAL, false);
+ if (v != NULL)
+ v->exported = false;
+ }
/* TODO: handle errors */
setenv(name, val, 1);
free(val);
@@ -667,19 +674,21 @@ ExportVarLiteral(Var *v)
* Internal variables are not exported.
*/
static bool
-ExportVar(const char *name, VarExportMode mode)
+ExportVar(const char *name, GNode *scope, VarExportMode mode)
{
Var *v;
if (!MayExport(name))
return false;
- v = VarFind(name, SCOPE_GLOBAL, false);
+ v = VarFind(name, scope, false);
+ if (v == NULL && scope != SCOPE_GLOBAL)
+ v = VarFind(name, SCOPE_GLOBAL, false);
if (v == NULL)
return false;
if (mode == VEM_ENV)
- return ExportVarEnv(v);
+ return ExportVarEnv(v, scope);
else if (mode == VEM_PLAIN)
return ExportVarPlain(v);
else
@@ -691,7 +700,7 @@ ExportVar(const char *name, VarExportMode mode)
* re-exported.
*/
void
-Var_ReexportVars(void)
+Var_ReexportVars(GNode *scope)
{
char *xvarnames;
@@ -715,7 +724,7 @@ Var_ReexportVars(void)
HashIter_Init(&hi, &SCOPE_GLOBAL->vars);
while (HashIter_Next(&hi) != NULL) {
Var *var = hi.entry->value;
- ExportVar(var->name.str, VEM_ENV);
+ ExportVar(var->name.str, scope, VEM_ENV);
}
return;
}
@@ -728,7 +737,7 @@ Var_ReexportVars(void)
size_t i;
for (i = 0; i < varnames.len; i++)
- ExportVar(varnames.words[i], VEM_ENV);
+ ExportVar(varnames.words[i], scope, VEM_ENV);
Words_Free(varnames);
}
free(xvarnames);
@@ -746,7 +755,7 @@ ExportVars(const char *varnames, bool isExport, VarExportMode mode)
for (i = 0; i < words.len; i++) {
const char *varname = words.words[i];
- if (!ExportVar(varname, mode))
+ if (!ExportVar(varname, SCOPE_GLOBAL, mode))
continue;
if (var_exportedVars == VAR_EXPORTED_NONE)
@@ -971,7 +980,7 @@ Var_SetWithFlags(GNode *scope, const char *name, const char *val,
DEBUG4(VAR, "%s: %s = %s%s\n",
scope->name, name, val, ValueDescription(val));
if (v->exported)
- ExportVar(name, VEM_PLAIN);
+ ExportVar(name, scope, VEM_PLAIN);
}
if (scope == SCOPE_CMDLINE) {
@@ -1352,7 +1361,6 @@ ModifyWord_Root(Substring word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED)
SepBuf_AddRange(buf, word.start, end);
}
-#ifdef SYSVVARSUB
struct ModifyWord_SysVSubstArgs {
GNode *scope;
Substring lhsPrefix;
@@ -1392,7 +1400,6 @@ ModifyWord_SysVSubst(Substring word, SepBuf *buf, void *data)
FStr_Done(&rhs);
}
-#endif
static const char *
Substring_Find(Substring haystack, Substring needle)
@@ -1470,7 +1477,7 @@ nosub:
SepBuf_AddSubstring(buf, word);
}
-#ifndef NO_REGEX
+#ifdef HAVE_REGEX_H
/* Print the error caused by a regcomp or regexec call. */
static void
RegexError(int reerr, const regex_t *pat, const char *str)
@@ -1580,7 +1587,6 @@ ok:
}
#endif
-
struct ModifyWord_LoopArgs {
GNode *scope;
const char *var; /* name of the temporary variable */
@@ -2282,6 +2288,9 @@ ModifyWords(ModChain *ch,
size_t i;
Substring word;
+ if (!ModChain_ShouldEval(ch))
+ return;
+
if (oneBigWord) {
SepBuf_Init(&result, ch->sep);
/* XXX: performance: Substring_InitStr calls strlen */
@@ -2814,8 +2823,7 @@ ApplyModifier_Mtime(const char **pp, ModChain *ch)
goto invalid_argument;
*pp = p;
}
- if (ModChain_ShouldEval(ch))
- ModifyWords(ch, ModifyWord_Mtime, &args, ch->oneBigWord);
+ ModifyWords(ch, ModifyWord_Mtime, &args, ch->oneBigWord);
return args.rc;
invalid_argument:
@@ -2894,7 +2902,7 @@ ApplyModifier_Subst(const char **pp, ModChain *ch)
return AMR_OK;
}
-#ifndef NO_REGEX
+#ifdef HAVE_REGEX_H
/* :C,from,to, */
static ApplyModifierResult
@@ -3560,8 +3568,7 @@ ApplyModifier_WordFunc(const char **pp, ModChain *ch,
return AMR_UNKNOWN;
(*pp)++;
- if (ModChain_ShouldEval(ch))
- ModifyWords(ch, modifyWord, NULL, ch->oneBigWord);
+ ModifyWords(ch, modifyWord, NULL, ch->oneBigWord);
return AMR_OK;
}
@@ -3600,7 +3607,6 @@ ApplyModifier_Unique(const char **pp, ModChain *ch)
return AMR_OK;
}
-#ifdef SYSVVARSUB
/* Test whether the modifier has the form '<lhs>=<rhs>'. */
static bool
IsSysVModifier(const char *p, char startc, char endc)
@@ -3672,9 +3678,7 @@ done:
FStr_Done(&rhs);
return AMR_OK;
}
-#endif
-#ifdef SUNSHCMD
/* :sh */
static ApplyModifierResult
ApplyModifier_SunShell(const char **pp, ModChain *ch)
@@ -3697,7 +3701,6 @@ ApplyModifier_SunShell(const char **pp, ModChain *ch)
return AMR_OK;
}
-#endif
/*
* In cases where the evaluation mode and the definedness are the "standard"
@@ -3779,7 +3782,7 @@ ApplyModifier(const char **pp, ModChain *ch)
return ApplyModifier_Words(pp, ch);
case '_':
return ApplyModifier_Remember(pp, ch);
-#ifndef NO_REGEX
+#ifdef HAVE_REGEX_H
case 'C':
return ApplyModifier_Regex(pp, ch);
#endif
@@ -3815,10 +3818,8 @@ ApplyModifier(const char **pp, ModChain *ch)
return ApplyModifier_Range(pp, ch);
case 'S':
return ApplyModifier_Subst(pp, ch);
-#ifdef SUNSHCMD
case 's':
return ApplyModifier_SunShell(pp, ch);
-#endif
case 'T':
return ApplyModifier_WordFunc(pp, ch, ModifyWord_Tail);
case 't':
@@ -3870,7 +3871,7 @@ ApplyModifiersIndirect(ModChain *ch, const char **pp)
DEBUG3(VAR, "Indirect modifier \"%s\" from \"%.*s\"\n",
mods.str, (int)(p - *pp), *pp);
- if (mods.str[0] != '\0') {
+ if (ModChain_ShouldEval(ch) && mods.str[0] != '\0') {
const char *modsp = mods.str;
ApplyModifiers(expr, &modsp, '\0', '\0');
if (Expr_Str(expr) == var_Error || *modsp != '\0') {
@@ -3907,12 +3908,10 @@ ApplySingleModifier(const char **pp, ModChain *ch)
res = ApplyModifier(&p, ch);
-#ifdef SYSVVARSUB
if (res == AMR_UNKNOWN) {
assert(p == mod);
res = ApplyModifier_SysV(&p, ch);
}
-#endif
if (res == AMR_UNKNOWN) {
/*
@@ -4155,12 +4154,12 @@ IsShortVarnameValid(char varname, const char *start)
if (!opts.strict)
return false; /* XXX: Missing error message */
- if (varname == '$')
+ if (varname == '$' && save_dollars)
Parse_Error(PARSE_FATAL,
"To escape a dollar, use \\$, not $$, at \"%s\"", start);
else if (varname == '\0')
Parse_Error(PARSE_FATAL, "Dollar followed by nothing");
- else
+ else if (save_dollars)
Parse_Error(PARSE_FATAL,
"Invalid variable name '%c', at \"%s\"", varname, start);
@@ -4287,7 +4286,7 @@ ParseVarnameLong(
bool dynamic = false;
const char *p = *pp;
- const char *const start = p;
+ const char *start = p;
char endc = startc == '(' ? ')' : '}';
p += 2; /* skip "${" or "$(" or "y(" */