git: 34a3834eadd0 - main - Merge bmake-20260313

From: Simon J. Gerraty <sjg_at_FreeBSD.org>
Date: Mon, 06 Apr 2026 18:35:14 UTC
The branch main has been updated by sjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=34a3834eadd03bec7703b8fbf9123f27b1114986

commit 34a3834eadd03bec7703b8fbf9123f27b1114986
Merge: c5961b6fcfe0 fe271bdb43cf
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2026-04-06 18:29:01 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2026-04-06 18:32:43 +0000

    Merge bmake-20260313
    
    Merge commit 'fe271bdb43cf88ee129d94c0e286fe618fd28e89'

 contrib/bmake/ChangeLog                            |  82 ++++++++++++++++
 contrib/bmake/LICENSE                              |   4 +-
 contrib/bmake/Makefile                             |  19 ++--
 contrib/bmake/VERSION                              |   2 +-
 contrib/bmake/bmake.1                              | 105 +++++++++------------
 contrib/bmake/bmake.cat1                           |  70 +++++++-------
 contrib/bmake/job.c                                |  59 +++++++++++-
 contrib/bmake/job.h                                |   3 +-
 contrib/bmake/main.c                               |  21 +++--
 contrib/bmake/make.1                               | 105 +++++++++------------
 contrib/bmake/make.c                               |   5 +-
 contrib/bmake/make.h                               |  16 +++-
 contrib/bmake/meta.c                               |  77 +++++----------
 contrib/bmake/mk/ChangeLog                         |  38 ++++++++
 contrib/bmake/mk/dirdeps.mk                        |   7 +-
 contrib/bmake/mk/install-mk                        |   4 +-
 contrib/bmake/mk/meta.autodep.mk                   |   4 +-
 contrib/bmake/mk/meta.stage.mk                     |   9 +-
 contrib/bmake/mk/meta2deps.py                      |  19 ++--
 contrib/bmake/mk/meta2deps.sh                      |   6 +-
 contrib/bmake/mk/rust.mk                           |  21 +++--
 contrib/bmake/mk/sys.dirdeps.mk                    |  15 ++-
 contrib/bmake/mk/sys.mk                            |   5 +-
 contrib/bmake/mk/sys.vars.mk                       |  38 ++++----
 contrib/bmake/os.sh                                |   8 +-
 contrib/bmake/parse.c                              |  54 ++---------
 contrib/bmake/str.h                                |  58 ++++++------
 contrib/bmake/suff.c                               |  12 +--
 contrib/bmake/unit-tests/Makefile                  |  33 +++++--
 contrib/bmake/unit-tests/cmd-errors-jobs.exp       |  12 +--
 contrib/bmake/unit-tests/cmd-errors-lint.exp       |   6 +-
 contrib/bmake/unit-tests/cmd-errors.exp            |   6 +-
 contrib/bmake/unit-tests/cond-func-exists.mk       |  16 +++-
 contrib/bmake/unit-tests/cond-undef-lint.mk        |   4 +-
 contrib/bmake/unit-tests/directive-dinclude.mk     |   2 +-
 contrib/bmake/unit-tests/directive-export-gmake.mk |  11 ++-
 .../bmake/unit-tests/directive-hyphen-include.mk   |   2 +-
 .../bmake/unit-tests/directive-include-guard.mk    |   2 +-
 contrib/bmake/unit-tests/directive-include.mk      |   2 +-
 contrib/bmake/unit-tests/directive-sinclude.mk     |   2 +-
 contrib/bmake/unit-tests/gnode-submake.exp         |  20 ++--
 contrib/bmake/unit-tests/gnode-submake.mk          |   4 +-
 contrib/bmake/unit-tests/lint.exp                  |   2 +-
 contrib/bmake/unit-tests/moderrs.exp               |  80 ++++++++--------
 contrib/bmake/unit-tests/opt-chdir.mk              |   6 +-
 contrib/bmake/unit-tests/opt-debug-graph1.exp      |   1 +
 contrib/bmake/unit-tests/opt-debug-graph2.exp      |   1 +
 contrib/bmake/unit-tests/opt-debug-graph3.exp      |   1 +
 contrib/bmake/unit-tests/opt-debug-jobs.exp        |   1 +
 contrib/bmake/unit-tests/opt-jobs-internal.exp     |   8 +-
 contrib/bmake/unit-tests/opt-jobs-internal.mk      |  27 ++++--
 contrib/bmake/unit-tests/opt-where-am-i.mk         |   6 +-
 contrib/bmake/unit-tests/opt.exp                   |  14 +--
 contrib/bmake/unit-tests/opt.mk                    |   4 +-
 contrib/bmake/unit-tests/sh-errctl.exp             |   1 +
 contrib/bmake/unit-tests/suff-main-several.exp     |   1 +
 contrib/bmake/unit-tests/suff-transform-debug.exp  |   1 +
 contrib/bmake/unit-tests/var-recursive.exp         |   2 +-
 contrib/bmake/unit-tests/var-scope-local.exp       |  10 ++
 contrib/bmake/unit-tests/var-scope-local.mk        |  47 ++++++++-
 contrib/bmake/unit-tests/varmisc.exp               |  18 ++--
 contrib/bmake/unit-tests/varmod-assign.exp         |  12 +--
 contrib/bmake/unit-tests/varmod-hash.exp           |   6 +-
 contrib/bmake/unit-tests/varmod-loop-delete.exp    |  12 ++-
 contrib/bmake/unit-tests/varmod-loop-delete.mk     |  48 +++++++++-
 contrib/bmake/unit-tests/varmod-select-words.exp   |  24 ++---
 contrib/bmake/unit-tests/varmod-subst-regex.exp    |  30 +++---
 contrib/bmake/unit-tests/varmod-subst-regex.mk     |  47 +++++----
 contrib/bmake/unit-tests/varmod-subst.exp          |   7 +-
 contrib/bmake/unit-tests/varmod-subst.mk           |  18 +++-
 .../unit-tests/varname-dot-make-save_dollars.mk    |  12 +--
 .../bmake/unit-tests/varname-make_stack_trace.exp  |  22 +++--
 .../bmake/unit-tests/varname-make_stack_trace.mk   |  36 ++++++-
 contrib/bmake/var.c                                |  70 ++++++++------
 usr.bin/bmake/Makefile                             |  19 ++--
 usr.bin/bmake/Makefile.config                      |   2 +-
 usr.bin/bmake/unit-tests/Makefile                  |  33 +++++--
 77 files changed, 1000 insertions(+), 617 deletions(-)

diff --cc contrib/bmake/Makefile
index ba2b2e742d35,000000000000..9aed55e67b6f
mode 100644,000000..100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@@ -1,266 -1,0 +1,273 @@@
- #	$Id: Makefile,v 1.133 2025/03/08 20:12:56 sjg Exp $
++#	$Id: Makefile,v 1.137 2026/03/13 15:37:22 sjg Exp $
 +
 +PROG = bmake
 +
 +SRCS = \
 +	arch.c \
 +	buf.c \
 +	compat.c \
 +	cond.c \
 +	dir.c \
 +	for.c \
 +	hash.c \
 +	job.c \
 +	lst.c \
 +	main.c \
 +	make.c \
 +	make_malloc.c \
 +	meta.c \
 +	metachar.c \
 +	parse.c \
 +	str.c \
 +	suff.c \
 +	targ.c \
 +	trace.c \
 +	util.c \
 +	var.c
 +
 +.MAIN: all
 +
- MAN = ${PROG}.1
- SRCS.${MAN} = ${srcdir}/make.1
- 
 +.-include "VERSION"
 +.-include "Makefile.inc"
 +
 +# this file gets generated by configure
 +.-include "Makefile.config"
 +
 +.if !empty(LIBOBJS)
 +SRCS += ${LIBOBJS:T:.o=.c}
 +.endif
 +
 +# just in case
 +prefix ?= /usr
 +srcdir ?= ${.PARSEDIR}
 +srcdir := ${srcdir}
 +
++MAN ?= ${PROG}.1
++SRCS.${MAN} ?= ${srcdir}/make.1
++
 +DEFAULT_SYS_PATH ?= ${prefix}/share/mk
 +
 +CPPFLAGS += -DUSE_META
 +CFLAGS += ${CPPFLAGS}
 +CFLAGS += -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
 +CFLAGS += -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
 +CFLAGS += ${COPTS.${.ALLSRC:M*.c:T:u}}
 +COPTS.main.c += "-DMAKE_VERSION=\"${_MAKE_VERSION}\""
 +
- .for x in FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH
++# bmake defaults to the traditional behavior
++MAKE_SAVE_DOLLARS_DEFAULT ?= no
++
++VARS.main += FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH \
++	MAKE_SAVE_DOLLARS_DEFAULT \
++
++.for x in ${VARS.main}
 +.ifdef $x
 +COPTS.main.c += "-D$x=\"${$x}\""
 +.endif
 +.endfor
 +
 +# meta mode can be useful even without filemon
 +# should be set by now
 +USE_FILEMON ?= no
 +.if ${USE_FILEMON:tl} != "no"
 +.PATH:	${srcdir}/filemon
 +SRCS += filemon_${USE_FILEMON}.c
 +COPTS.meta.c += -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu}
 +COPTS.job.c += ${COPTS.meta.c}
 +
 +.if ${USE_FILEMON} == "dev"
 +FILEMON_H ?= /usr/include/dev/filemon/filemon.h
 +.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
 +COPTS.filemon_dev.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
 +.endif
 +.elif ${USE_FILEMON} == "ktrace"
 +COPTS.filemon_ktrace.c += -Wno-error=unused-parameter
 +.endif
 +
 +.endif				# USE_FILEMON
 +
 +.PATH:	${srcdir}
 +
 +# start-delete1 for bsd.after-import.mk
 +# we skip a lot of this when building as part of FreeBSD etc.
 +
 +# list of OS's which are derrived from BSD4.4
 +BSD44_LIST = NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
 +# we are...
 +OS := ${.MAKE.OS:U${uname -s:L:sh}}
 +# are we 4.4BSD ?
 +isBSD44 := ${BSD44_LIST:M${OS}}
 +
 +.if ${isBSD44} == "" && ${OS:NCygwin:NDarwin:NLinux} != ""
 +MANTARGET ?= cat
 +.if ${MACHINE} == "sun386"
 +# even I don't have one of these anymore :-)
 +CFLAGS += -DPORTAR
 +.elif ${OS} != "SunOS"
 +# assume the worst
 +SRCS += sigcompat.c
 +CFLAGS += -DSIGNAL_FLAGS=SA_RESTART
 +.endif
 +.else
 +MANTARGET ?= man
 +.endif
 +
 +# turn this on by default - ignored if we are root
 +WITH_INSTALL_AS_USER =
 +
 +# suppress with -DWITHOUT_*
 +OPTIONS_DEFAULT_YES += \
 +	AUTOCONF_MK \
 +	INSTALL_MK \
 +	PROG_LINK \
 +	TESTS \
 +
 +OPTIONS_DEFAULT_NO += \
 +	GEN_MAN \
 +	PROG_VERSION \
 +
 +.if ${PROG} != "make" || ${srcdir} != ${.CURDIR} || !exists(${srcdir}/${MAN})
 +WITH_GEN_MAN = 1
 +.endif
 +
 +# process options now
 +.include <own.mk>
 +
 +.if ${MK_PROG_VERSION} == "yes"
 +PROG_NAME = ${PROG}-${_MAKE_VERSION}
 +.if ${MK_PROG_LINK} == "yes"
 +SYMLINKS += ${PROG_NAME} ${BINDIR}/${PROG}
 +.endif
 +.endif
 +
 +EXTRACT_MAN = no
 +# end-delete1
 +
 +.if make(obj) || make(clean)
 +SUBDIR.${MK_TESTS} += unit-tests
 +.endif
 +
 +MAN1 = ${MAN}
 +
 +.if ${MK_GEN_MAN:Uno} == "yes"
 +
 +# we use this to generate ${MAN}
 +.include <${srcdir}/mk/genfiles.mk>
 +
 +.if ${PROG} != "make"
 +CLEANFILES += my.history
 +SED_CMDS.${MAN} += \
 +	-e '/^.Dt/s/MAKE/${PROG:tu}/' \
 +	-e '/^.Nm/s/make/${PROG}/' \
 +
 +.endif
 +
 +.if ${CLEANFILES:U:Mmy.history} != ""
 +${MAN}: my.history
 +my.history:
 +	@(echo ".Nm"; \
 +	echo "is derived from NetBSD"; \
 +	echo ".Xr make 1 ."; \
 +	echo "It uses autoconf to facilitate portability to other platforms."; \
 +	echo ".Pp") > $@
 +
 +SED_CMDS.${MAN} += \
 +	-e '/^.Sh HISTORY/rmy.history' \
 +	-e '/^.Sh HISTORY/,/BUGS/s,^.Nm,make,' \
 +
 +.endif
 +
 +.if ${.MAKE.OS:N*BSD} != ""
 +# assume .Nx is not supported
 +SED_CMDS.${MAN} += -e 's/^\.Nx/NetBSD/'
 +.endif
 +
 +# watch out for a late change of PROG
 +.if !empty(SRCS.${MAN})
 +.NOPATH: ${MAN}
 +${MAN}:	${SRCS.${MAN}} _GENFILES_USE
 +
 +all man beforeinstall: ${MAN}
 +_mfromdir = .
 +.endif
 +.endif				# MK_GEN_MAN
 +
 +MANTARGET ?= cat
 +MANDEST ?= ${MANDIR}/${MANTARGET}1
 +
 +.if ${MANTARGET} == "cat"
 +_mfromdir = ${srcdir}
 +.endif
 +
 +.include <prog.mk>
 +
 +CPPFLAGS += -DMAKE_NATIVE -DHAVE_CONFIG_H
 +COPTS.var.c += -Wno-cast-qual
 +COPTS.job.c += -Wno-format-nonliteral
 +COPTS.parse.c += -Wno-format-nonliteral
 +COPTS.var.c += -Wno-format-nonliteral
 +
 +# Force these
 +SHAREDIR = ${SHAREDIR.bmake:U${prefix}/share}
 +BINDIR = ${BINDIR.bmake:U${prefix}/bin}
 +MANDIR = ${MANDIR.bmake:U${SHAREDIR}/man}
 +
- ${OBJS}: config.h
++${OBJS}: .META config.h
++${PROG}: .META
 +
 +# start-delete2 for bsd.after-import.mk
 +
 +# make sure that MAKE_VERSION gets updated.
 +main.o: ${srcdir}/VERSION
 +
 +.if ${MK_AUTOCONF_MK} == "yes"
 +CONFIGURE_DEPS += ${.CURDIR}/VERSION
 +# we do not need or want the generated makefile
 +CONFIGURE_ARGS += --without-makefile
 +AUTOCONF_GENERATED_MAKEFILE = Makefile.config
 +.include <autoconf.mk>
 +.endif
 +SHARE_MK ?= ${SHAREDIR}/mk
 +MKSRC = ${srcdir}/mk
 +INSTALL ?= ${srcdir}/install-sh
 +
 +.if ${MK_INSTALL_MK} == "yes"
 +install: install-mk
 +.endif
 +
 +beforeinstall:
 +	test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${BINDIR}
 +	test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${MANDEST}
 +
 +install-mk:
 +.if exists(${MKSRC}/install-mk)
 +	test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${SHARE_MK}
 +	sh ${MKSRC}/install-mk -v -m ${NONBINMODE} ${DESTDIR}${SHARE_MK}
 +.else
 +	@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
 +.endif
 +# end-delete2
 +
 +# A simple unit-test driver to help catch regressions
 +TEST_MAKE ?= ${.OBJDIR}/${PROG:T}
 +accept test: .NOMETA
 +	cd ${.CURDIR}/unit-tests && \
 +	MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}}
 +
 +
 +.if make(test) && ${MK_AUTO_OBJ} == "yes"
 +# The test target above visits unit-tests with -r -m /
 +# which prevents MK_AUTO_OBJ doing its job
 +# so do it here
 +.if defined(MAKEOBJDIRPREFIX) || ${MAKEOBJDIR:U:M*/*} != ""
 +_utobj = ${.OBJDIR}/unit-tests
 +.else
 +_utobj = ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj}
 +.endif
 +utobj: .NOMETA
 +	@test -d ${_utobj} && exit 0; \
 +	echo "[Creating ${_utobj}...]"; \
 +	umask ${OBJDIR_UMASK:U002}; \
 +	mkdir -p ${_utobj}
 +test: utobj
 +.endif
diff --cc contrib/bmake/mk/meta2deps.sh
index d9c20464cafe,000000000000..66e16b81d776
mode 100755,000000..100755
--- a/contrib/bmake/mk/meta2deps.sh
+++ b/contrib/bmake/mk/meta2deps.sh
@@@ -1,485 -1,0 +1,485 @@@
 +#!/bin/sh
 +
 +# NAME:
 +#	meta2deps.sh - extract useful info from .meta files
 +#
 +# SYNOPSIS:
 +#	meta2deps.sh SB="SB" "meta" ...
 +#
 +# DESCRIPTION:
 +#	This script looks each "meta" file and extracts the
 +#	information needed to deduce build and src dependencies.
 +#
 +#	To do this, we extract the 'CWD' record as well as all the
 +#	syscall traces which describe 'R'ead, 'C'hdir and 'E'xec
 +#	syscalls.
 +#
 +#	The typical meta file looks like::
 +#.nf
 +#
 +#	# Meta data file "path"
 +#	CMD "command-line"
 +#	CWD "cwd"
 +#	TARGET "target"
 +#	-- command output --
 +#	-- filemon acquired metadata --
 +#	# buildmon version 2
 +#	V 2
 +#	E "pid" "path"
 +#	R "pid" "path"
 +#	C "pid" "cwd"
 +#	R "pid" "path"
 +#	X "pid" "status"
 +#.fi
 +#
 +#	The fact that all the syscall entry lines start with a single
 +#	character make these files quite easy to process using sed(1).
 +#
 +#	To simplify the logic the 'CWD' line is made to look like a
 +#	normal 'C'hdir entry, and "cwd" is remembered so that it can
 +#	be prefixed to any "path" which is not absolute.
 +#
 +#	If the "path" being read ends in '.srcrel' it is the content
 +#	of (actually the first line of) that file that we are
 +#	interested in.
 +#
 +#	Any "path" which lies outside of the sandbox "SB" is generally
 +#	not of interest and is ignored.
 +#
 +#	The output, is a set of absolute paths with "SB" like:
 +#.nf
 +#
 +#	$SB/obj-i386/bsd/include
 +#	$SB/obj-i386/bsd/lib/csu/i386
 +#	$SB/obj-i386/bsd/lib/libc
 +#	$SB/src/bsd/include
 +#	$SB/src/bsd/sys/i386/include
 +#	$SB/src/bsd/sys/sys
 +#	$SB/src/pan-release/rtsock
 +#	$SB/src/pfe-shared/include/jnx
 +#.fi
 +#
 +#	Which can then be further processed by 'gendirdeps.mk'
 +#
 +#	If we are passed 'DPDEPS='"dpdeps", then for each src file
 +#	outside of "CURDIR" we read, we output a line like:
 +#.nf
 +#
 +#	DPDEPS_$path += $RELDIR
 +#.fi
 +#
 +#	with "$path" geting turned into reldir's, so that we can end
 +#	up with a list of all the directories which depend on each src
 +#	file in another directory.  This can allow for efficient yet
 +#	complete testing of changes.
 +
 +
 +# RCSid:
- #	$Id: meta2deps.sh,v 1.25 2025/11/11 18:08:02 sjg Exp $
++#	$Id: meta2deps.sh,v 1.26 2025/12/08 17:34:02 sjg Exp $
 +
 +# SPDX-License-Identifier: BSD-2-Clause
 +#
 +# Copyright (c) 2011-2025, Simon J. Gerraty
 +# Copyright (c) 2010-2013, Juniper Networks, Inc.
 +# All rights reserved.
 +#
 +# Redistribution and use in source and binary forms, with or without
 +# modification, are permitted provided that the following conditions
 +# are met:
 +# 1. Redistributions of source code must retain the above copyright
 +#    notice, this list of conditions and the following disclaimer.
 +# 2. Redistributions in binary form must reproduce the above copyright
 +#    notice, this list of conditions and the following disclaimer in the
 +#    documentation and/or other materials provided with the distribution.
 +#
 +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 +
 +case ",$DEBUG_SH," in
 +*,meta2deps*) set -x;;
 +esac
 +
 +meta2src() {
 +    cat /dev/null "$@" |
 +    sed -n '/^R .*\.[chyl]$/s,^..[0-9]* ,,p' |
 +    sort -u
 +}
 +
 +meta2dirs() {
 +    cat /dev/null "$@" |
 +    sed -n '/^R .*\/.*\.[a-z0-9][^\/]*$/s,^..[0-9]* \(.*\)/[^/]*$,\1,p' |
 +    sort -u
 +}
 +
 +add_list() {
 +    sep=' '
 +    suffix=
 +    while :
 +    do
 +	case "$1" in
 +	"|") sep="$1"; shift;;
 +	-s) suffix="$2"; shift 2;;
 +	*) break;;
 +	esac
 +    done
 +    name=$1
 +    shift
 +    eval list="\$$name"
 +    for top in "$@"
 +    do
 +	case "$sep$list$sep" in
 +	*"$sep$top$suffix$sep"*) continue;;
 +	esac
 +	list="${list:+$list$sep}$top$suffix"
 +    done
 +    eval "$name=\"$list\""
 +}
 +
 +# some Linux systems have deprecated egrep in favor of grep -E
 +# but not everyone supports that
 +case "`echo bmake | egrep 'a|b' 2>&1`" in
 +bmake) ;;
 +*) egrep() { grep -E "$@"; }
 +esac
 +
 +_excludes_f() {
 +    egrep -v "$EXCLUDES"
 +}
 +
 +error() {
 +    echo "ERROR: $@" >&2
 +    exit 1
 +}
 +
 +meta2deps() {
 +    DPDEPS=
 +    SRCTOPS=$SRCTOP
 +    OBJROOTS=
 +    EXCLUDES=
 +    while :
 +    do
 +	case "$1" in
 +	*=*) eval export "$1"; shift;;
 +	-a) MACHINE_ARCH=$2; shift 2;;
 +	-m) MACHINE=$2; shift 2;;
 +	-C) CURDIR=$2; shift 2;;
 +	-H) HOST_TARGET=$2; shift 2;;
 +	-S) add_list SRCTOPS $2; shift 2;;
 +	-O) add_list OBJROOTS $2; shift 2;;
 +	-X) add_list EXCLUDES '|' $2; shift 2;;
 +	-R) RELDIR=$2; shift 2;;
 +	-T) TARGET_SPEC=$2; shift 2;;
 +	*) break;;
 +	esac
 +    done
 +
 +    _th= _o=
 +    case "$MACHINE" in
 +    host) _ht=$HOST_TARGET;;
 +    esac
 +
 +    for o in $OBJROOTS
 +    do
 +	case "$MACHINE,/$o/" in
 +	host,*$HOST_TARGET*) ;;
 +	*$MACHINE*|*${TARGET_SPEC:-$MACHINE}*) ;;
 +	*) add_list _o $o; continue;;
 +	esac
 +	for x in $_ht $TARGET_SPEC $MACHINE
 +	do
 +	    case "$o" in
 +	    "") continue;;
 +	    */$x/) add_list _o ${o%$x/}; o=;;
 +	    */$x) add_list _o ${o%$x}; o=;;
 +	    *$x/) add_list _o ${o%$x/}; o=;;
 +	    *$x) add_list _o ${o%$x}; o=;;
 +	    esac
 +	done
 +    done
 +    OBJROOTS="$_o"
 +
 +    case "$OBJTOP" in
 +    "")
 +	for o in $OBJROOTS
 +	do
 +	    OBJTOP=$o${TARGET_SPEC:-$MACHINE}
 +	    break
 +	done
 +	;;
 +    esac
 +    src_re=
 +    obj_re=
 +    add_list '|' -s '/*' src_re $SRCTOPS
 +    add_list '|' -s '*' obj_re $OBJROOTS
 +
 +    [ -z "$RELDIR" ] && unset DPDEPS
 +    tf=/tmp/m2d$$-$USER
 +    rm -f $tf.*
 +    trap 'rm -f $tf.*; trap 0' 0
 +
 +    > $tf.dirdep
 +    > $tf.qual
 +    > $tf.srcdep
 +    > $tf.srcrel
 +    > $tf.dpdeps
 +
 +    seenit=
 +    seensrc=
 +    lpid=
 +    case "$EXCLUDES" in
 +    "") _excludes=cat;;
 +    *) _excludes=_excludes_f;;
 +    esac
 +    # handle @list files
 +    case "$@" in
 +    *@[!.]*)
 +	for f in "$@"
 +	do
 +	    case "$f" in
 +	    *.meta) cat $f;;
 +	    @*) xargs cat < ${f#@};;
 +	    *) cat $f;;
 +	    esac
 +	done
 +	;;
 +    *) cat /dev/null "$@";;
 +    esac 2> /dev/null |
 +    sed -e 's,^CWD,C C,;/^[#CREFLMVWX] /!d' -e "s,',,g" |
 +    $_excludes | ( version=no epids= xpids= eof_token=no
 +    while read op pid path path2
 +    do
 +	: op=$op pid=$pid path=$path path2=$path2
 +	# first a sanity check - filemon on Linux is not very reliable
 +	# path2 should only be non-empty for op L or M
 +	# and it should not contain spaces.
-         # It will also be non-empty for # Meta line
-         # which tells us which meta_file we are processing
++	# It will also be non-empty for # Meta line
++	# which tells us which meta_file we are processing
 +	case "$op,$path2" in
 +	\#*,*.meta) # new file, reset some vars
 +	    version=no epids= xpids= eof_token=no lpid=
 +	    meta_file=`set -- $path2; echo $2`
 +	    continue
 +	    ;;
 +	\#*) ;;			# ok
 +	[LM],) error "missing path2 in: '$op $pid $path'";;
 +	[LMX],*" "*) error "wrong number of words in: '$op $pid $path $path2'";;
 +	*,|[LMX],*) ;;		# ok
 +	*) error "wrong number of words in: '$op $pid $path $path2'";;
 +	esac
 +	# we track cwd and ldir (of interest) per pid
 +	# CWD is bmake's cwd
 +	: lpid=$lpid,pid=$pid
 +	case "$lpid,$pid" in
 +	,C) CWD=$path cwd=$path ldir=$path
 +	    if [ -z "$SB" ]; then
 +		SB=`echo $CWD | sed 's,/obj.*,,'`
 +	    fi
 +	    SRCTOP=${SRCTOP:-$SB/src}
 +	    case "$verion" in
 +	    no) ;;		# ignore
 +	    0) error "no filemon data: $meta_file";;
 +	    *) ;;
 +	    esac
 +	    version=0
 +	    case "$eof_token" in
 +	    no) ;;		# ignore
 +	    0) error "truncated filemon data: $meta_file";;
 +	    esac
 +	    eof_token=0
 +	    continue
 +	    ;;
 +	$pid,$pid) ;;
 +	[1-9]*)
 +	    case "$lpid" in
 +	    "") ;;
 +	    *) eval ldir_$lpid=$ldir;;
 +	    esac
 +	    eval ldir=\${ldir_$pid:-$CWD} cwd=\${cwd_$pid:-$CWD}
 +	    lpid=$pid
 +	    ;;
 +	esac
 +
 +	: op=$op path=$path
 +	case "$op,$path" in
 +	V,*) version=$pid; continue;;
 +	W,*srcrel|*.dirdep) continue;;
 +	C,*)
 +	    case "$path" in
 +	    /*) cwd=$path;;
 +	    *) cwd=`cd $cwd/$path 2> /dev/null && /bin/pwd`;;
 +	    esac
 +	    # watch out for temp dirs that no longer exist
 +	    test -d ${cwd:-/dev/null/no/such} || cwd=$CWD
 +	    eval cwd_$pid=$cwd
 +	    continue
 +	    ;;
 +	F,*) # $path is new pid
 +	    eval cwd_$path=$cwd ldir_$path=$ldir
 +	    continue
 +	    ;;
 +	\#,bye) eof_token=1; continue;;
 +	\#*) continue;;
 +	*)  dir=${path%/*}
 +	    case "$op" in
 +	    E)	# setid apps get no tracing so we won't see eXit
 +		case `'ls' -l $path 2> /dev/null | sed 's, .*,,'` in
 +		*s*) ;;
 +		*) epids="$epids $pid";;
 +		esac
 +		;;
 +	    X) xpids="$xpids $pid"; continue;;
 +	    esac
 +	    case "$path" in
 +	    $src_re|$obj_re) ;;
 +	    /*/stage/*) ;;
 +	    /*) continue;;
 +	    *)
 +		rlist="$ldir/$path $cwd/$path"
 +		case "$op,$path" in
 +		[ML],../*) rlist="$rlist $path2/$path `dirname $path2`/$path";;
 +		esac
 +		for path in $rlist
 +		do
 +		    test -e $path && break
 +		done
 +		dir=${path%/*}
 +		;;
 +	    esac
 +	    ;;
 +	esac
 +	# avoid repeating ourselves...
 +	case "$DPDEPS,$seensrc," in
 +	,*)
 +	    case ",$seenit," in
 +	    *,$dir,*) continue;;
 +	    esac
 +	    ;;
 +	*,$path,*) continue;;
 +	esac
 +	# canonicalize if needed
 +	case "/$dir/" in
 +	*/../*|*/./*)
 +	    rdir=$dir
 +	    dir=`cd $dir 2> /dev/null && /bin/pwd`
 +	    seen="$rdir,$dir"
 +	    ;;
 +	*)  seen=$dir;;
 +	esac
 +	case "$dir" in
 +	${CURDIR:-.}|"") continue;;
 +	$src_re)
 +	    # avoid repeating ourselves...
 +	    case "$DPDEPS,$seensrc," in
 +	    ,*)
 +		case ",$seenit," in
 +		*,$dir,*) continue;;
 +		esac
 +		;;
 +	    esac
 +	    ;;
 +	*)
 +	    case ",$seenit," in
 +	    *,$dir,*) continue;;
 +	    esac
 +	    ;;
 +	esac
 +	if [ -d $path ]; then
 +	    case "$path" in
 +	    */..) ldir=${dir%/*};;
 +	    *) ldir=$path;;
 +	    esac
 +	    continue
 +	fi
 +	[ -f $path ] || continue
 +	case "$dir" in
 +	$CWD) continue;;		# ignore
 +	$src_re)
 +	    seenit="$seenit,$seen"
 +	    echo $dir >> $tf.srcdep
 +	    case "$DPDEPS,$reldir,$seensrc," in
 +	    ,*) ;;
 +	    *)	seensrc="$seensrc,$path"
 +		echo "DPDEPS_$dir/${path##*/} += $RELDIR" >> $tf.dpdeps
 +		;;
 +	    esac
 +	    continue
 +	    ;;
 +	esac
 +	# if there is a .dirdep we cannot skip
 +	# just because we've seen the dir before.
 +	if [ -s $path.dirdep ]; then
 +	    # this file contains:
 +	    # '# ${RELDIR}.<machine>'
 +	    echo $path.dirdep >> $tf.qual
 +	    continue
 +	elif [ -s $dir.dirdep ]; then
 +	    echo $dir.dirdep >> $tf.qual
 +	    seenit="$seenit,$seen"
 +	    continue
 +	fi
 +	seenit="$seenit,$seen"
 +	case "$dir" in
 +	$obj_re)
 +	    echo $dir;;
 +	esac
 +    done > $tf.dirdep
 +    : version=$version
 +    case "$version" in
 +    0) error "no filemon data: $meta_file";;
 +    esac
 +    : eof_token=$eof_token
 +    case "$eof_token" in
 +    0) error "truncated filemon data: $meta_file";;
 +    esac
 +    for p in $epids
 +    do
 +	: p=$p
 +	case " $xpids " in
 +	*" $p "*) ;;
 +	*) error "missing eXit for pid $p: $meta_file";;
 +	esac
 +    done ) || exit 1
 +    _nl=echo
 +    for f in $tf.dirdep $tf.qual $tf.srcdep
 +    do
 +	[ -s $f ] || continue
 +	case $f in
 +	*qual) # a list of .dirdep files
 +	    # we can prefix everything with $OBJTOP to
 +	    # tell gendirdeps.mk that these are
 +	    # DIRDEP entries, since they are already
 +	    # qualified with .<machine> as needed.
 +	    # We strip .$MACHINE though
 +	    xargs cat < $f | sort -u |
 +	    sed "s,^# ,,;s,^,$OBJTOP/,;s,\.${TARGET_SPEC:-$MACHINE}\$,,;s,\.$MACHINE\$,,"
 +	    ;;
 +	*)  sort -u $f;;
 +	esac
 +	_nl=:
 +    done
 +    if [ -s $tf.dpdeps ]; then
 +	case "$DPDEPS" in
 +	*/*) ;;
 +	*) echo > $DPDEPS;;		# the echo is needed!
 +	esac
 +	sort -u $tf.dpdeps |
 +	sed "s,${SRCTOP}/,,;s,${SB_BACKING_SB:-$SB}/src/,," >> $DPDEPS
 +    fi
 +    # ensure we produce _something_ else egrep -v gets upset
 +    $_nl
 +}
 +
 +case /$0 in
 +*/meta2dep*) meta2deps "$@";;
 +*/meta2dirs*) meta2dirs "$@";;
 +*/meta2src*) meta2src "$@";;
 +esac
diff --cc contrib/bmake/os.sh
index 86ec86bc4929,f854e83967bb..f854e83967bb
mode 100755,100644..100644
--- a/contrib/bmake/os.sh
+++ b/contrib/bmake/os.sh
diff --cc usr.bin/bmake/Makefile
index a8bcdfd9f859,000000000000..8d23bb8dd203
mode 100644,000000..100644
--- a/usr.bin/bmake/Makefile
+++ b/usr.bin/bmake/Makefile
@@@ -1,203 -1,0 +1,210 @@@
 +# This is a generated file, do NOT edit!
 +# See contrib/bmake/bsd.after-import.mk
 +#
 +
 +SRCTOP?= ${.CURDIR:H:H}
 +
 +# look here first for config.h
 +CFLAGS+= -I${.CURDIR}
 +
 +# for after-import
 +CLEANDIRS+= FreeBSD
 +CLEANFILES+= bootstrap
 +
- #	$Id: Makefile,v 1.133 2025/03/08 20:12:56 sjg Exp $
++#	$Id: Makefile,v 1.137 2026/03/13 15:37:22 sjg Exp $
 +
 +PROG?= ${.CURDIR:T}
 +
 +SRCS= \
 +	arch.c \
 +	buf.c \
 +	compat.c \
 +	cond.c \
 +	dir.c \
 +	for.c \
 +	hash.c \
 +	job.c \
 +	lst.c \
 +	main.c \
 +	make.c \
 +	make_malloc.c \
 +	meta.c \
 +	metachar.c \
 +	parse.c \
 +	str.c \
 +	suff.c \
 +	targ.c \
 +	trace.c \
 +	util.c \
 +	var.c
 +
 +.MAIN: all
 +
- MAN= ${PROG}.1
- SRCS.${MAN}= ${srcdir}/make.1
- 
 +.-include "Makefile.inc"
 +
 +# this file gets generated by configure
 +.-include "Makefile.config"
 +
 +.if !empty(LIBOBJS)
 +SRCS+= ${LIBOBJS:T:.o=.c}
 +.endif
 +
 +# just in case
 +prefix?= /usr
 +srcdir?= ${.PARSEDIR}
 +srcdir:= ${srcdir}
 +
++MAN?= ${PROG}.1
++SRCS.${MAN}?= ${srcdir}/make.1
++
 +DEFAULT_SYS_PATH?= ${prefix}/share/mk
 +
 +CPPFLAGS+= -DUSE_META
 +CFLAGS+= ${CPPFLAGS}
 +CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
 +CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
 +CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
 +COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\""
 +
- .for x in FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH
++# bmake defaults to the traditional behavior
++MAKE_SAVE_DOLLARS_DEFAULT?= no
++
++VARS.main+= FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH \
++	MAKE_SAVE_DOLLARS_DEFAULT \
++
++.for x in ${VARS.main}
 +.ifdef $x
 +COPTS.main.c+= "-D$x=\"${$x}\""
 +.endif
 +.endfor
 +
 +# meta mode can be useful even without filemon
 +# should be set by now
 +USE_FILEMON?= no
 +.if ${USE_FILEMON:tl} != "no"
 +.PATH:	${srcdir}/filemon
 +SRCS+= filemon_${USE_FILEMON}.c
 +COPTS.meta.c+= -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu}
 +COPTS.job.c+= ${COPTS.meta.c}
 +
 +.if ${USE_FILEMON} == "dev"
 +FILEMON_H?= /usr/include/dev/filemon/filemon.h
 +.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
 +COPTS.filemon_dev.c+= -DHAVE_FILEMON_H -I${FILEMON_H:H}
 +.endif
 +.elif ${USE_FILEMON} == "ktrace"
 +COPTS.filemon_ktrace.c+= -Wno-error=unused-parameter
 +.endif
 +
*** 1124 LINES SKIPPED ***