git: 148ee8457000 - main - Merge bmake-20230622

From: Simon J. Gerraty <sjg_at_FreeBSD.org>
Date: Tue, 27 Jun 2023 20:59:20 UTC
The branch main has been updated by sjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=148ee84570001f46b7b667c86573d378101c3801

commit 148ee84570001f46b7b667c86573d378101c3801
Merge: b374a3921d97 3e39ce563b9b
Author:     Simon J. Gerraty <sjg@FreeBSD.org>
AuthorDate: 2023-06-27 20:38:02 +0000
Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
CommitDate: 2023-06-27 20:57:58 +0000

    Merge bmake-20230622
    
    Merge commit '3e39ce563b9ba25883e5aa37d9799eda9e57c1e0'

 contrib/bmake/ChangeLog                            |  71 +++
 contrib/bmake/FILES                                |   6 +-
 contrib/bmake/Makefile                             |   6 +-
 contrib/bmake/VERSION                              |   2 +-
 contrib/bmake/boot-strap                           |   2 +-
 contrib/bmake/buf.c                                |   6 +-
 contrib/bmake/buf.h                                |   4 +-
 contrib/bmake/cond.c                               | 101 +++-
 contrib/bmake/dir.c                                |  14 +-
 contrib/bmake/for.c                                |  40 +-
 contrib/bmake/make.h                               |  19 +-
 contrib/bmake/mk/ChangeLog                         |  46 ++
 contrib/bmake/mk/dirdeps.mk                        |  73 +--
 contrib/bmake/mk/host-target.mk                    |  31 +-
 contrib/bmake/mk/install-mk                        |   4 +-
 contrib/bmake/mk/meta.autodep.mk                   |   5 +-
 contrib/bmake/mk/sys.dirdeps.mk                    |  46 +-
 contrib/bmake/mk/sys.vars.mk                       |  11 +-
 contrib/bmake/os.sh                                |  16 +-
 contrib/bmake/parse.c                              | 106 +++-
 contrib/bmake/str.c                                | 116 +++--
 contrib/bmake/str.h                                |   9 +-
 contrib/bmake/unit-tests/Makefile                  |  17 +-
 contrib/bmake/unit-tests/cmdline-undefined.exp     |  24 +-
 contrib/bmake/unit-tests/cmdline-undefined.mk      |  14 +-
 contrib/bmake/unit-tests/cond-cmp-numeric-eq.exp   |   4 +-
 contrib/bmake/unit-tests/cond-cmp-numeric-eq.mk    |   4 +-
 contrib/bmake/unit-tests/cond-cmp-unary.exp        |   2 +-
 contrib/bmake/unit-tests/cond-cmp-unary.mk         |  11 +-
 contrib/bmake/unit-tests/cond-eof.exp              |   6 +-
 contrib/bmake/unit-tests/cond-eof.mk               |  10 +-
 contrib/bmake/unit-tests/cond-func-defined.exp     |  10 +-
 contrib/bmake/unit-tests/cond-func-defined.mk      |   8 +-
 contrib/bmake/unit-tests/cond-func-empty.exp       |   4 +-
 contrib/bmake/unit-tests/cond-func-empty.mk        |   7 +-
 contrib/bmake/unit-tests/cond-func-make.exp        |   1 +
 contrib/bmake/unit-tests/cond-func-make.mk         |   7 +-
 contrib/bmake/unit-tests/cond-func.exp             |  18 +-
 contrib/bmake/unit-tests/cond-func.mk              |  12 +-
 contrib/bmake/unit-tests/cond-op-and-lint.exp      |   2 +-
 contrib/bmake/unit-tests/cond-op-and-lint.mk       |   3 +-
 contrib/bmake/unit-tests/cond-op-and.exp           |   8 +-
 contrib/bmake/unit-tests/cond-op-and.mk            |   6 +-
 contrib/bmake/unit-tests/cond-op-not.exp           |  12 +-
 contrib/bmake/unit-tests/cond-op-not.mk            |   8 +-
 contrib/bmake/unit-tests/cond-op-or-lint.exp       |   2 +-
 contrib/bmake/unit-tests/cond-op-or-lint.mk        |   3 +-
 contrib/bmake/unit-tests/cond-op-or.exp            |   8 +-
 contrib/bmake/unit-tests/cond-op-or.mk             |   6 +-
 contrib/bmake/unit-tests/cond-op-parentheses.exp   |   4 +-
 contrib/bmake/unit-tests/cond-op-parentheses.mk    |   4 +-
 contrib/bmake/unit-tests/cond-op.exp               |  37 +-
 contrib/bmake/unit-tests/cond-op.mk                |  28 +-
 contrib/bmake/unit-tests/cond-token-number.exp     |   8 +-
 contrib/bmake/unit-tests/cond-token-number.mk      |   6 +-
 contrib/bmake/unit-tests/cond-token-plain.exp      |  30 +-
 contrib/bmake/unit-tests/cond-token-plain.mk       |  13 +-
 contrib/bmake/unit-tests/cond-token-string.exp     |  20 +-
 contrib/bmake/unit-tests/cond-token-string.mk      |  14 +-
 contrib/bmake/unit-tests/cond-token-var.exp        |   8 +-
 contrib/bmake/unit-tests/cond-token-var.mk         |   8 +-
 contrib/bmake/unit-tests/cond-undef-lint.exp       |  14 +-
 contrib/bmake/unit-tests/cond-undef-lint.mk        |   9 +-
 .../bmake/unit-tests/dep-colon-bug-cross-file.exp  |   4 +-
 .../bmake/unit-tests/dep-colon-bug-cross-file.mk   |   4 +-
 contrib/bmake/unit-tests/dep-wildcards.mk          |   8 +-
 contrib/bmake/unit-tests/dep.mk                    |  14 +-
 contrib/bmake/unit-tests/deptgt-begin.exp          |   4 +-
 contrib/bmake/unit-tests/deptgt-begin.mk           |   4 +-
 contrib/bmake/unit-tests/deptgt-delete_on_error.mk |   2 +-
 contrib/bmake/unit-tests/deptgt.exp                |  22 +-
 contrib/bmake/unit-tests/deptgt.mk                 |   5 +-
 contrib/bmake/unit-tests/directive-elif.exp        |  36 +-
 contrib/bmake/unit-tests/directive-elif.mk         |  25 +-
 contrib/bmake/unit-tests/directive-else.exp        |  14 +-
 contrib/bmake/unit-tests/directive-else.mk         |  12 +-
 contrib/bmake/unit-tests/directive-endfor.exp      |   2 +-
 contrib/bmake/unit-tests/directive-endfor.mk       |   3 +-
 contrib/bmake/unit-tests/directive-endif.exp       |   8 +-
 contrib/bmake/unit-tests/directive-endif.mk        |  28 +-
 contrib/bmake/unit-tests/directive-error.exp       |   2 +-
 contrib/bmake/unit-tests/directive-error.mk        |   3 +-
 contrib/bmake/unit-tests/directive-for-break.exp   |   1 +
 contrib/bmake/unit-tests/directive-for-break.mk    |   8 +-
 contrib/bmake/unit-tests/directive-for-empty.exp   |  10 +-
 contrib/bmake/unit-tests/directive-for-empty.mk    |   6 +-
 contrib/bmake/unit-tests/directive-for-errors.exp  |  28 +-
 contrib/bmake/unit-tests/directive-for-errors.mk   |   4 +-
 contrib/bmake/unit-tests/directive-for-escape.exp  | 151 +++---
 contrib/bmake/unit-tests/directive-for-escape.mk   |  10 +-
 .../unit-tests/directive-for-generating-endif.exp  |   8 +-
 .../unit-tests/directive-for-generating-endif.mk   |   6 +-
 contrib/bmake/unit-tests/directive-for-if.exp      |   6 +-
 contrib/bmake/unit-tests/directive-for-if.mk       |   5 +-
 contrib/bmake/unit-tests/directive-for-lines.exp   |  12 +-
 contrib/bmake/unit-tests/directive-for-lines.mk    |   8 +-
 contrib/bmake/unit-tests/directive-for.exp         |  60 +--
 contrib/bmake/unit-tests/directive-for.mk          |  10 +-
 contrib/bmake/unit-tests/directive-if.exp          |  28 +-
 contrib/bmake/unit-tests/directive-if.mk           |  10 +-
 contrib/bmake/unit-tests/directive-ifmake.exp      |  14 +-
 contrib/bmake/unit-tests/directive-ifmake.mk       |   9 +-
 contrib/bmake/unit-tests/directive-ifndef.exp      |   2 +-
 contrib/bmake/unit-tests/directive-ifndef.mk       |  33 +-
 .../bmake/unit-tests/directive-include-fatal.exp   |   2 +-
 .../bmake/unit-tests/directive-include-fatal.mk    |   3 +-
 .../bmake/unit-tests/directive-include-guard.exp   |  88 ++++
 .../bmake/unit-tests/directive-include-guard.mk    | 552 +++++++++++++++++++++
 contrib/bmake/unit-tests/directive-include.exp     |  12 +-
 contrib/bmake/unit-tests/directive-include.mk      |   6 +-
 contrib/bmake/unit-tests/directive-info.exp        |  24 +-
 contrib/bmake/unit-tests/directive-info.mk         |  19 +-
 .../bmake/unit-tests/directive-misspellings.exp    |  84 ++--
 contrib/bmake/unit-tests/directive-misspellings.mk |  46 +-
 contrib/bmake/unit-tests/directive-undef.exp       |   6 +-
 contrib/bmake/unit-tests/directive-undef.mk        |   5 +-
 .../bmake/unit-tests/directive-unexport-env.exp    |   6 +-
 contrib/bmake/unit-tests/directive-unexport-env.mk |   5 +-
 contrib/bmake/unit-tests/directive-unexport.exp    |   8 +-
 contrib/bmake/unit-tests/directive-unexport.mk     |   5 +-
 contrib/bmake/unit-tests/directive-warning.exp     |  14 +-
 contrib/bmake/unit-tests/directive-warning.mk      |   9 +-
 contrib/bmake/unit-tests/doterror.mk               |   3 +-
 contrib/bmake/unit-tests/error.exp                 |   6 +-
 contrib/bmake/unit-tests/error.mk                  |   5 +-
 contrib/bmake/unit-tests/export-env.mk             |   6 +-
 contrib/bmake/unit-tests/forsubst.exp              |   2 -
 contrib/bmake/unit-tests/forsubst.mk               |  22 -
 contrib/bmake/unit-tests/include-main.exp          |  10 +-
 contrib/bmake/unit-tests/include-main.mk           |   6 +-
 contrib/bmake/unit-tests/modmatch.exp              |  17 -
 contrib/bmake/unit-tests/modmatch.mk               |  30 --
 contrib/bmake/unit-tests/modmisc.exp               |   1 -
 contrib/bmake/unit-tests/modmisc.mk                |  10 +-
 contrib/bmake/unit-tests/opt-debug-file.exp        |   6 +-
 contrib/bmake/unit-tests/opt-debug-file.mk         |   5 +-
 contrib/bmake/unit-tests/opt-debug-for.exp         |  12 +-
 contrib/bmake/unit-tests/opt-debug-hash.exp        |   2 +-
 contrib/bmake/unit-tests/opt-debug-hash.mk         |   3 +-
 contrib/bmake/unit-tests/opt-debug-lint.exp        |  14 +-
 contrib/bmake/unit-tests/opt-debug-lint.mk         |   9 +-
 contrib/bmake/unit-tests/opt-debug-parse.exp       |  28 +-
 contrib/bmake/unit-tests/opt-debug-parse.mk        |   5 +-
 .../bmake/unit-tests/opt-warnings-as-errors.exp    |   4 +-
 contrib/bmake/unit-tests/opt-warnings-as-errors.mk |   4 +-
 contrib/bmake/unit-tests/parse.exp                 |   2 +-
 contrib/bmake/unit-tests/parse.mk                  |   3 +-
 contrib/bmake/unit-tests/recursive.exp             |   4 +-
 contrib/bmake/unit-tests/recursive.mk              |   4 +-
 contrib/bmake/unit-tests/var-eval-short.exp        |   8 +-
 contrib/bmake/unit-tests/var-eval-short.mk         |   4 +-
 contrib/bmake/unit-tests/var-op-append.mk          |  19 +-
 contrib/bmake/unit-tests/var-op-assign.exp         |   4 +-
 contrib/bmake/unit-tests/var-op-assign.mk          |   4 +-
 contrib/bmake/unit-tests/var-op-expand.exp         |   6 +-
 contrib/bmake/unit-tests/var-op-expand.mk          |   4 +-
 contrib/bmake/unit-tests/var-op-shell.exp          |   8 +-
 contrib/bmake/unit-tests/var-op-shell.mk           |   6 +-
 contrib/bmake/unit-tests/var-readonly.mk           |   9 +-
 contrib/bmake/unit-tests/var-recursive.exp         |  12 +-
 contrib/bmake/unit-tests/var-recursive.mk          |   4 +-
 contrib/bmake/unit-tests/var-scope-cmdline.exp     |   4 +-
 contrib/bmake/unit-tests/var-scope-cmdline.mk      |   4 +-
 contrib/bmake/unit-tests/vardebug.exp              |   6 +-
 contrib/bmake/unit-tests/vardebug.mk               |   5 +-
 contrib/bmake/unit-tests/varmod-assign-shell.exp   |   2 +-
 contrib/bmake/unit-tests/varmod-assign-shell.mk    |   3 +-
 contrib/bmake/unit-tests/varmod-edge.exp           |  42 +-
 contrib/bmake/unit-tests/varmod-edge.mk            |  23 +-
 contrib/bmake/unit-tests/varmod-gmtime.exp         |  20 +-
 contrib/bmake/unit-tests/varmod-gmtime.mk          |  12 +-
 contrib/bmake/unit-tests/varmod-ifelse.exp         |  24 +-
 contrib/bmake/unit-tests/varmod-ifelse.mk          |  13 +-
 contrib/bmake/unit-tests/varmod-indirect.exp       |  32 +-
 contrib/bmake/unit-tests/varmod-indirect.mk        |  13 +-
 contrib/bmake/unit-tests/varmod-localtime.exp      |  20 +-
 contrib/bmake/unit-tests/varmod-localtime.mk       |  12 +-
 contrib/bmake/unit-tests/varmod-loop-delete.exp    |   2 +-
 contrib/bmake/unit-tests/varmod-loop-delete.mk     |   3 +-
 contrib/bmake/unit-tests/varmod-loop-varname.exp   |  16 +-
 contrib/bmake/unit-tests/varmod-loop-varname.mk    |  10 +-
 contrib/bmake/unit-tests/varmod-match-escape.exp   |   6 +-
 contrib/bmake/unit-tests/varmod-match-escape.mk    |  37 +-
 contrib/bmake/unit-tests/varmod-match.exp          |  12 +-
 contrib/bmake/unit-tests/varmod-match.mk           |  25 +-
 contrib/bmake/unit-tests/varmod-order.exp          |  20 +-
 contrib/bmake/unit-tests/varmod-order.mk           |  13 +-
 contrib/bmake/unit-tests/varmod-range.exp          |  20 +-
 contrib/bmake/unit-tests/varmod-range.mk           |  12 +-
 contrib/bmake/unit-tests/varmod-subst.mk           |  84 +++-
 contrib/bmake/unit-tests/varmod-sysv.exp           |   2 +-
 contrib/bmake/unit-tests/varmod-sysv.mk            |   3 +-
 contrib/bmake/unit-tests/varmod-to-abs.exp         |   4 +-
 contrib/bmake/unit-tests/varmod-to-abs.mk          |   5 +-
 contrib/bmake/unit-tests/varmod-to-separator.exp   |  28 +-
 contrib/bmake/unit-tests/varmod-to-separator.mk    |  14 +-
 contrib/bmake/unit-tests/varmod.exp                |  10 +-
 contrib/bmake/unit-tests/varmod.mk                 |   7 +-
 contrib/bmake/unit-tests/varname-dollar.exp        |   8 +-
 contrib/bmake/unit-tests/varname-dollar.mk         |   6 +-
 contrib/bmake/unit-tests/varname-dot-makeflags.exp |  12 +-
 contrib/bmake/unit-tests/varname-dot-makeflags.mk  |   5 +-
 contrib/bmake/unit-tests/varname-dot-parsedir.exp  |   6 +-
 contrib/bmake/unit-tests/varname-dot-parsedir.mk   |  12 +-
 contrib/bmake/unit-tests/varname-dot-parsefile.exp |   6 +-
 contrib/bmake/unit-tests/varname-dot-parsefile.mk  |  12 +-
 contrib/bmake/unit-tests/varname-makeflags.mk      |  10 +-
 contrib/bmake/unit-tests/varname.exp               |   6 +-
 contrib/bmake/unit-tests/varname.mk                |   5 +-
 contrib/bmake/unit-tests/varparse-dynamic.exp      |   4 +-
 contrib/bmake/unit-tests/varparse-dynamic.mk       |   9 +-
 contrib/bmake/unit-tests/varparse-errors.exp       |   8 +-
 contrib/bmake/unit-tests/varparse-errors.mk        |   6 +-
 contrib/bmake/var.c                                | 115 ++---
 usr.bin/bmake/Makefile                             |   6 +-
 usr.bin/bmake/Makefile.config                      |   2 +-
 usr.bin/bmake/unit-tests/Makefile                  |  17 +-
 217 files changed, 2692 insertions(+), 1119 deletions(-)

diff --cc contrib/bmake/Makefile
index 212885f7b900,000000000000..22e92b4da9ac
mode 100644,000000..100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@@ -1,236 -1,0 +1,238 @@@
- #	$Id: Makefile,v 1.124 2023/02/25 20:27:44 sjg Exp $
++#	$Id: Makefile,v 1.125 2023/05/17 00:15:46 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
 +
 +.-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?= ${.CURDIR}
 +
 +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_MACHINE FORCE_MACHINE_ARCH
 +.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
- .endif				# USE_FILEMON == dev
++.elif ${USE_FILEMON} == "ktrace"
++COPTS.filemon_ktrace.c += -Wno-error=unused-parameter
++.endif
 +
 +.endif				# USE_FILEMON
 +
 +.PATH:	${srcdir}
 +
 +.if make(obj) || make(clean)
 +SUBDIR+= unit-tests
 +.endif
 +
 +# 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:NDarwin:NLinux} != ""
 +MANTARGET= cat
 +INSTALL?=${srcdir}/install-sh
 +.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
 +
 +OPTIONS_DEFAULT_NO+= \
 +	PROG_VERSION
 +
 +# 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
 +
 +MAN= ${PROG}.1
 +MAN1= ${MAN}
 +
 +.if ${PROG} != "make"
 +CLEANFILES+= my.history
 +.if make(${MAN}) || !exists(${srcdir}/${MAN})
 +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") > $@
 +
 +.NOPATH: ${MAN}
 +${MAN}:	make.1 my.history
 +	@echo making $@
 +	@sed \
 +	-e '/^.Dt/s/MAKE/${PROG:tu}/' \
 +	-e 's/^.Nx/NetBSD/' \
 +	-e '/^.Nm/s/make/${PROG}/' \
 +	-e '/^.Sh HISTORY/rmy.history' \
 +	-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
 +
 +all beforeinstall: ${MAN}
 +_mfromdir=.
 +.endif
 +.endif
 +
 +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
 +
 +# 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/boot-strap
index 40984edcbe62,40984edcbe62..8892f2b1c990
--- a/contrib/bmake/boot-strap
+++ b/contrib/bmake/boot-strap
@@@ -420,7 -420,7 +420,7 @@@ op_build() 
  
  op_test() {
  	[ -x bmake ] || op_build
--	Bmake test "$@" || exit 1
++	Bmake test "$@" TEST_MAKE=$objdir/bmake || exit 1
  }
  
  op_clean() {
diff --cc contrib/bmake/os.sh
index 6bf52420c90f,78b2de95a679..78b2de95a679
mode 100755,100644..100644
--- a/contrib/bmake/os.sh
+++ b/contrib/bmake/os.sh
diff --cc contrib/bmake/unit-tests/directive-include-guard.exp
index 000000000000,487e67e33e77..487e67e33e77
mode 000000,100644..100644
--- a/contrib/bmake/unit-tests/directive-include-guard.exp
+++ b/contrib/bmake/unit-tests/directive-include-guard.exp
diff --cc contrib/bmake/unit-tests/directive-include-guard.mk
index 000000000000,1d19a67944e5..1d19a67944e5
mode 000000,100644..100644
--- a/contrib/bmake/unit-tests/directive-include-guard.mk
+++ b/contrib/bmake/unit-tests/directive-include-guard.mk
diff --cc usr.bin/bmake/Makefile
index ed2f5b3d5e2f,000000000000..fddd0564459d
mode 100644,000000..100644
--- a/usr.bin/bmake/Makefile
+++ b/usr.bin/bmake/Makefile
@@@ -1,179 -1,0 +1,181 @@@
 +# This is a generated file, do NOT edit!
 +# See contrib/bmake/bsd.after-import.mk
 +#
 +# $FreeBSD$
 +
 +SRCTOP?= ${.CURDIR:H:H}
 +
 +# look here first for config.h
 +CFLAGS+= -I${.CURDIR}
 +
 +# for after-import
 +CLEANDIRS+= FreeBSD
 +CLEANFILES+= bootstrap
 +
- #	$Id: Makefile,v 1.124 2023/02/25 20:27:44 sjg Exp $
++#	$Id: Makefile,v 1.125 2023/05/17 00:15:46 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
 +
 +.sinclude "Makefile.inc"
 +
 +# this file gets generated by configure
 +.sinclude "Makefile.config"
 +
 +.if !empty(LIBOBJS)
 +SRCS+= ${LIBOBJS:T:.o=.c}
 +.endif
 +
 +# just in case
 +prefix?= /usr
 +srcdir?= ${.CURDIR}
 +
 +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_MACHINE FORCE_MACHINE_ARCH
 +.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
- .endif				# USE_FILEMON == dev
++.elif ${USE_FILEMON} == "ktrace"
++COPTS.filemon_ktrace.c += -Wno-error=unused-parameter
++.endif
 +
 +.endif				# USE_FILEMON
 +
 +.PATH:	${srcdir}
 +
 +.if make(obj) || make(clean)
 +SUBDIR+= unit-tests
 +.endif
 +
 +
 +MAN= ${PROG}.1
 +MAN1= ${MAN}
 +
 +.if ${PROG} != "make"
 +CLEANFILES+= my.history
 +.if make(${MAN}) || !exists(${srcdir}/${MAN})
 +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") > $@
 +
 +.NOPATH: ${MAN}
 +${MAN}:	make.1 my.history
 +	@echo making $@
 +	@sed \
 +	-e '/^.Dt/s/MAKE/${PROG:tu}/' \
 +	-e 's/^.Nx/NetBSD/' \
 +	-e '/^.Nm/s/make/${PROG}/' \
 +	-e '/^.Sh HISTORY/rmy.history' \
 +	-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
 +
 +all beforeinstall: ${MAN}
 +_mfromdir=.
 +.endif
 +.endif
 +
 +MANTARGET?= cat
 +MANDEST?= ${MANDIR}/${MANTARGET}1
 +
 +.if ${MANTARGET} == "cat"
 +_mfromdir=${srcdir}
 +.endif
 +
 +.include <bsd.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
 +
 +
 +# 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
 +
 +# override some simple things
 +BINDIR= /usr/bin
 +MANDIR= /usr/share/man/man
 +
 +# make sure we get this
 +CFLAGS+= ${COPTS.${.IMPSRC:T}}
 +
 +after-import: ${SRCTOP}/contrib/bmake/bsd.after-import.mk
 +	cd ${.CURDIR} && ${.MAKE} -f ${SRCTOP}/contrib/bmake/bsd.after-import.mk
 +
diff --cc usr.bin/bmake/Makefile.config
index 83920a75165b,000000000000..afaf0a1d15cd
mode 100644,000000..100644
--- a/usr.bin/bmake/Makefile.config
+++ b/usr.bin/bmake/Makefile.config
@@@ -1,28 -1,0 +1,28 @@@
 +# This is a generated file, do NOT edit!
 +# See contrib/bmake/bsd.after-import.mk
 +#
 +# $FreeBSD$
 +
 +SRCTOP?= ${.CURDIR:H:H}
 +
 +# things set by configure
 +
- _MAKE_VERSION?=20230510
++_MAKE_VERSION?=20230622
 +
 +prefix?= /usr
 +srcdir= ${SRCTOP}/contrib/bmake
 +CC?= cc
 +DEFAULT_SYS_PATH?= .../share/mk:/usr/share/mk
 +
 +EGREP = egrep
 +CPPFLAGS+= 
 +CFLAGS+= ${CPPFLAGS} -DHAVE_CONFIG_H
 +LDFLAGS+= 
 +LIBOBJS+=  ${LIBOBJDIR}stresep$U.o
 +LDADD+= 
 +USE_META?= yes
 +USE_FILEMON?= dev
 +FILEMON_H?= /usr/include/dev/filemon/filemon.h
 +BMAKE_PATH_MAX?= 1024
 +# used if MAXPATHLEN not defined
 +CPPFLAGS+= -DBMAKE_PATH_MAX=${BMAKE_PATH_MAX}
diff --cc usr.bin/bmake/unit-tests/Makefile
index cacf343d162f,000000000000..987dceae51ff
mode 100644,000000..100644
--- a/usr.bin/bmake/unit-tests/Makefile
+++ b/usr.bin/bmake/unit-tests/Makefile
@@@ -1,859 -1,0 +1,868 @@@
 +# This is a generated file, do NOT edit!
 +# See contrib/bmake/bsd.after-import.mk
 +#
 +# $FreeBSD$
- # $Id: Makefile,v 1.195 2023/05/10 18:26:24 sjg Exp $
++# $Id: Makefile,v 1.199 2023/06/20 17:27:20 sjg Exp $
 +#
- # $NetBSD: Makefile,v 1.335 2023/05/10 13:03:06 rillig Exp $
++# $NetBSD: Makefile,v 1.339 2023/06/20 09:25:34 rillig Exp $
 +#
 +# Unit tests for make(1)
 +#
 +# The main targets are:
 +#
 +# all:
 +#	run all the tests
 +# test:
 +#	run 'all', and compare to expected results
 +# accept:
 +#	move generated output to expected results
 +#
 +# Settable variables
 +#
 +# TEST_MAKE
 +#	The make program to be tested.
 +#
 +#
 +# Adding a test case
 +#
 +# Each feature should get its own set of tests in its own suitably
 +# named makefile (*.mk), with its own set of expected results (*.exp),
 +# and it should be added to the TESTS list.
 +#
 +
 +.MAIN: all
 +
 +# we use these below but we might be an older make
 +.MAKE.OS?= ${uname -s:L:sh}
 +.MAKE.UID?= ${id -u:L:sh}
 +
 +# for many tests we need a TMPDIR that will not collide
 +# with other users.
 +.if ${.OBJDIR} != ${.CURDIR}
 +# easy
 +TMPDIR:=	${.OBJDIR}/tmp
 +.elif defined(TMPDIR)
 +TMPDIR:=	${TMPDIR}/uid${.MAKE.UID}
 +.else
 +TMPDIR:=	/tmp/uid${.MAKE.UID}
 +.endif
 +# make sure it exists
 +.if !exist(${TMPDIR})
 +_!= mkdir -p ${TMPDIR}
 +.endif
 +
 +# Each test is in a sub-makefile.
 +# Keep the list sorted.
 +# Any test that is commented out must be ignored in
 +# src/tests/usr.bin/make/t_make.sh as well.
 +#TESTS+=		archive
 +#TESTS+=		archive-suffix
 +TESTS+=		cmd-errors
 +TESTS+=		cmd-errors-jobs
 +TESTS+=		cmd-errors-lint
 +TESTS+=		cmd-interrupt
 +TESTS+=		cmdline
 +TESTS+=		cmdline-redirect-stdin
 +TESTS+=		cmdline-undefined
 +TESTS+=		comment
 +TESTS+=		compat-error
 +TESTS+=		cond-cmp-numeric
 +TESTS+=		cond-cmp-numeric-eq
 +TESTS+=		cond-cmp-numeric-ge
 +TESTS+=		cond-cmp-numeric-gt
 +TESTS+=		cond-cmp-numeric-le
 +TESTS+=		cond-cmp-numeric-lt
 +TESTS+=		cond-cmp-numeric-ne
 +TESTS+=		cond-cmp-string
 +TESTS+=		cond-cmp-unary
 +TESTS+=		cond-eof
 +TESTS+=		cond-func
 +TESTS+=		cond-func-commands
 +TESTS+=		cond-func-defined
 +TESTS+=		cond-func-empty
 +TESTS+=		cond-func-exists
 +TESTS+=		cond-func-make
 +TESTS+=		cond-func-make-main
 +TESTS+=		cond-func-target
 +TESTS+=		cond-late
 +TESTS+=		cond-op
 +TESTS+=		cond-op-and
 +TESTS+=		cond-op-and-lint
 +TESTS+=		cond-op-not
 +TESTS+=		cond-op-or
 +TESTS+=		cond-op-or-lint
 +TESTS+=		cond-op-parentheses
 +TESTS+=		cond-short
 +TESTS+=		cond-token-number
 +TESTS+=		cond-token-plain
 +TESTS+=		cond-token-string
 +TESTS+=		cond-token-var
 +TESTS+=		cond-undef-lint
 +TESTS+=		counter
 +TESTS+=		counter-append
 +TESTS+=		dep
 +TESTS+=		dep-colon
 +TESTS+=		dep-colon-bug-cross-file
 +TESTS+=		dep-double-colon
 +TESTS+=		dep-double-colon-indep
 +TESTS+=		dep-duplicate
 +TESTS+=		dep-exclam
 +TESTS+=		dep-none
 +TESTS+=		dep-op-missing
 +TESTS+=		dep-percent
 +TESTS+=		dep-var
 +TESTS+=		dep-wildcards
 +TESTS+=		depsrc
 +TESTS+=		depsrc-end
 +TESTS+=		depsrc-exec
 +TESTS+=		depsrc-ignore
 +TESTS+=		depsrc-made
 +TESTS+=		depsrc-make
 +TESTS+=		depsrc-meta
 +TESTS+=		depsrc-nometa
 +TESTS+=		depsrc-nometa_cmp
 +TESTS+=		depsrc-nopath
 +TESTS+=		depsrc-notmain
 +TESTS+=		depsrc-optional
 +TESTS+=		depsrc-phony
 +TESTS+=		depsrc-precious
 +TESTS+=		depsrc-recursive
 +TESTS+=		depsrc-silent
 +TESTS+=		depsrc-use
 +TESTS+=		depsrc-usebefore
 +TESTS+=		depsrc-usebefore-double-colon
 +TESTS+=		depsrc-wait
 +TESTS+=		deptgt
 +TESTS+=		deptgt-begin
 +TESTS+=		deptgt-begin-fail
 +TESTS+=		deptgt-begin-fail-indirect
 +TESTS+=		deptgt-default
 +TESTS+=		deptgt-delete_on_error
 +TESTS+=		deptgt-end
 +TESTS+=		deptgt-end-fail
 +TESTS+=		deptgt-end-fail-all
 +TESTS+=		deptgt-end-fail-indirect
 +TESTS+=		deptgt-end-jobs
 +TESTS+=		deptgt-error
 +TESTS+=		deptgt-ignore
 +TESTS+=		deptgt-interrupt
 +TESTS+=		deptgt-main
 +TESTS+=		deptgt-makeflags
 +TESTS+=		deptgt-no_parallel
 +TESTS+=		deptgt-nopath
 +TESTS+=		deptgt-notparallel
 +TESTS+=		deptgt-objdir
 +TESTS+=		deptgt-order
 +TESTS+=		deptgt-path
 +TESTS+=		deptgt-path-suffix
 +TESTS+=		deptgt-phony
 +TESTS+=		deptgt-posix
 +TESTS+=		deptgt-precious
 +TESTS+=		deptgt-shell
 +TESTS+=		deptgt-silent
 +TESTS+=		deptgt-silent-jobs
 +TESTS+=		deptgt-stale
 +TESTS+=		deptgt-suffixes
 +TESTS+=		dir
 +TESTS+=		dir-expand-path
 +TESTS+=		directive
 +TESTS+=		directive-dinclude
 +TESTS+=		directive-elif
 +TESTS+=		directive-elifdef
 +TESTS+=		directive-elifmake
 +TESTS+=		directive-elifndef
 +TESTS+=		directive-elifnmake
 +TESTS+=		directive-else
 +TESTS+=		directive-endfor
 +TESTS+=		directive-endif
 +TESTS+=		directive-error
 +TESTS+=		directive-export
 +TESTS+=		directive-export-env
 +TESTS+=		directive-export-impl
 +TESTS+=		directive-export-gmake
 +TESTS+=		directive-export-literal
 +TESTS+=		directive-for
 +TESTS+=		directive-for-break
 +TESTS+=		directive-for-empty
 +TESTS+=		directive-for-errors
 +TESTS+=		directive-for-escape
 +TESTS+=		directive-for-generating-endif
 +TESTS+=		directive-for-if
 +TESTS+=		directive-for-lines
 +TESTS+=		directive-for-null
 +TESTS+=		directive-hyphen-include
 +TESTS+=		directive-if
 +TESTS+=		directive-if-nested
 +TESTS+=		directive-ifdef
 +TESTS+=		directive-ifmake
 +TESTS+=		directive-ifndef
 +TESTS+=		directive-ifnmake
 +TESTS+=		directive-include
 +TESTS+=		directive-include-fatal
++TESTS+=		directive-include-guard
 +TESTS+=		directive-info
 +TESTS+=		directive-misspellings
 +TESTS+=		directive-sinclude
 +TESTS+=		directive-undef
 +TESTS+=		directive-unexport
 +TESTS+=		directive-unexport-env
 +TESTS+=		directive-warning
 +TESTS+=		dollar
 +TESTS+=		doterror
 +TESTS+=		dotwait
 +TESTS+=		error
 +TESTS+=		# escape	# broken by reverting POSIX changes
 +TESTS+=		export
 +TESTS+=		export-all
 +TESTS+=		export-env
 +TESTS+=		export-variants
- TESTS+=		forsubst
 +TESTS+=		gnode-submake
 +TESTS+=		hanoi-include
 +TESTS+=		impsrc
 +TESTS+=		include-main
 +TESTS+=		job-flags
 +#TESTS+=		job-output-long-lines
 +TESTS+=		job-output-null
 +TESTS+=		jobs-empty-commands
 +TESTS+=		jobs-empty-commands-error
 +TESTS+=		jobs-error-indirect
 +TESTS+=		jobs-error-nested
 +TESTS+=		jobs-error-nested-make
 +TESTS+=		lint
 +TESTS+=		make-exported
 +TESTS+=		meta-cmd-cmp
 +TESTS+=		moderrs
- TESTS+=		modmatch
 +TESTS+=		modmisc
 +.if ${.MAKE.UID} > 0
 +TESTS+=		objdir-writable
 +.endif
 +TESTS+=		opt
 +TESTS+=		opt-backwards
 +TESTS+=		opt-chdir
 +TESTS+=		opt-debug
 +TESTS+=		opt-debug-all
 +TESTS+=		opt-debug-archive
 +TESTS+=		opt-debug-curdir
*** 623 LINES SKIPPED ***