Import bmake-20250125

Intersting/relevant changes since bmake-20240711

ChangeLog since bmake-20240711

2025-01-25  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20250125
	Merge with NetBSD make, sync up below change.

	* unit-tests/Makefile: remove $TMPDIR via .END
	to avoid failure in test on NFS - since the temp file for the
	target script is open and thus gets renamed by the server rather
	than removed.

2025-01-20  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20250120
	Merge with NetBSD make, pick up
	o use FORK_FUNCTION so it can be forced to fork when doing coverage.
	o main.c: avoid memory allocation in error path after exec failure.

2025-01-16  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20250116
	Merge with NetBSD make, pick up
	o clarify that undefined expressions are allowed in dependencies
	o simplify code for evaluating the '!=' variable assignment

2025-01-11  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20250111
	Merge with NetBSD make, pick up
	o replace "Malformed conditional" with "Variable is undefined"
	when appropriate

2025-01-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20250110
	Merge with NetBSD make, pick up
	o job.c: remove some unnecessary layers in job handling
	o unit-tests: test expressions based on undefined variables

2025-01-01  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20250101
	Merge with NetBSD make, pick up
	o var.c: reduce pointer indirections when unexporting a variable

2024-12-12  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20241212
	* mk/ updates

2024-11-24  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20241124
	Merge with NetBSD make, pick up
	o var.c: fix confusing error message when overriding a read-only
	variable

2024-11-22  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20241122
	Merge with NetBSD make, pick up
	o unit-tests/Makefile: optimize running of tests skip extra cat
	in 99% of cases.

2024-11-15  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20241114
	Merge with NetBSD make, pick up
	o make.1: note that MAKEOBJPREFIX should be absolute path
	also that it can be set via makefile if suitable care taken.

2024-11-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20241110
	Merge with NetBSD make, pick up
	o make: allow .../ (search here and above) in
	.MAKE.MAKEFILE_PREFERENCE and -f argument.

2024-11-03  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20241101
	Merge with NetBSD make, pick up
	o parse.c: report filename:linenumber in parse debug output

2024-09-21  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240921
	Merge with NetBSD make, pick up
	o make.1: Only list the defaults for MAKEFILE_PREFERENCE once.

	* Makefile: use genfiles.mk to generate ${MAN}
	so that it can be tuned for local site.
	Ensure MAN  is defined before including Makefile.inc

	* Makefile: use MK_GEN_MAN to make it easier to control whether we
	generate ${MAN}

2024-09-16  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240909

	* arch.c: fix NetBSD PR 58597

2024-09-01  Simon J Gerraty  <sjg@beast.crufty.net>

	* Makefile: use SUBDIR.${MK_TESTS} so that we skip
	unit-tests for obj and clean when FreeBSD is building WITHOUT_TESTS

	* VERSION (_MAKE_VERSION): 20240901
	Merge with NetBSD make, pick up
	o reduce line length in error messages
	o var.c: simplify printing of an evaluation stack element

2024-08-29  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240828
	Merge with NetBSD make, pick up
	o add more context to error message about recursive variables
	o treat recursive variables non-fatally - continue parsing to end
	of makefile

2024-08-12  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240808
	Merge with NetBSD make, pick up
	o improve some error messages for better clarify and readability

2024-07-22  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240722
	Merge with NetBSD make, pick up
	o job.c: remove dead code

2024-07-21  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240720
	Merge with NetBSD make, pick up
	o compat.c: do not run commands that have parse or evaluation errors.
	o var.c: remove wrong error message about an undefined variable

mk/ChangeLog since bmake-20240711

2025-01-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* rust.mk: use RUST_LIBS and RUST_PROGS

2025-01-01  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20250101

	* use W flag to :S and :C rather than :tW

2024-12-16  Simon J Gerraty  <sjg@beast.crufty.net>

	* rust.mk: add RUSTFLAGS if needed

2024-12-12  Simon J Gerraty  <sjg@beast.crufty.net>

	* init.mk (OBJS_SRCS_FILTER): apply this as
	${OBJS_SRCS_FILTER:ts:} as we do in FreeBSD.

2024-12-03  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20241202

	* setopts.sh: needed by newlog.sh

2024-11-22  Simon J Gerraty  <sjg@beast.crufty.net>

	* meta.sys.mk: add META_MODE_XTRAS to META_MODE to make it
	easier to add things like 'env' when debugging.

	* install-mk (MK_VERSION): 20241122

	* rust.mk: rename CARGO* to RUST_CARGO* so I don't feel
	like this makefile should be renamed to cargo.mk

2024-11-11  Simon J Gerraty  <sjg@beast.crufty.net>

	* dirdeps.mk: add DIRDEPS_CACHED_ENV to dirdeps-cached and
	DIRDEP_USE_EPILOGUE to _DIRDEP_USE

2024-10-30  Simon J Gerraty  <sjg@beast.crufty.net>

	* meta.sys.mk: if MK_META_ERROR_TARGET is yes and NEWLOG_SH is
	set, and ERROR_LOGDIR already exists, hook _rotateErrorLog to
	.BEGIN target.

2024-10-27  Simon J Gerraty  <sjg@beast.crufty.net>

	* options.mk: add support for DEBUG_OPTIONS (similar to
	DEBUG_DIRDEPS) to allow us to see where options get set.
	Eg. DEBUG_OPTIONS="STAGING*" gives:

	bmake[1]: "mk/options.mk" line 89: sys.mk: MK_STAGING=yes (MK_DIRDEPS_BUILD=no)
	bmake[1]: "mk/options.mk" line 66: local.init.mk: MK_STAGING=yes
	bmake[1]: "mk/options.mk" line 66: local.init.mk: MK_STAGING_PROG=no
	bmake[1]: "mk/options.mk" line 89: own.mk: MK_STAGING_MAN=yes (MK_STAGING=yes)
	bmake[1]: "mk/options.mk" line 89: own.mk: MK_STAGING_PROG=no (MK_STAGING=yes)
	bmake[1]: "mk/options.mk" line 89: own.mk: MK_STAGING_RUST=no (MK_STAGING_PROG=no)

	* own.mk: fix setting of STAGE_OBJTOP (normally set by sys.dirdeps.mk)

2024-10-26  Simon J Gerraty  <sjg@beast.crufty.net>

	* rust.mk: add some documentation and support for staging

2024-10-25  Simon J Gerraty  <sjg@beast.crufty.net>

	* rust.mk: a means of integrating Rust projects into a larger build.

2024-10-18  Simon J Gerraty  <sjg@beast.crufty.net>

	* dirdeps-targets.mk: if DEBUG_DIRDEPS_TARGETS and we found
	STATIC_DIRDEPS_CACHE, report its relative path.

2024-09-30  Simon J Gerraty  <sjg@beast.crufty.net>

	* dirdeps.mk: tweak the debug message for "Loading" a
	Makefile.depend file, always report what the actual makefile is
	with the DIRDEP it is for.
	Remove the redundant "Looking" message.

2024-09-26  Simon J Gerraty  <sjg@beast.crufty.net>

	* meta2deps.py: when raising AssertionError include meta file name
	with $SB trimmed if possible.

2024-09-23  Simon J Gerraty  <sjg@beast.crufty.net>

	* meta2deps.py: replace assert() with raise AssertionError when we
	detect missing eXits, to ensure a meaningful message gets into
	log.

2024-09-21  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240921

	* FILES: add genfiles.mk

2024-09-20  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240920

	* cython.mk: Get PYTHON_VERSION from PYTHON

2024-08-31  Simon J Gerraty  <sjg@beast.crufty.net>

	* subdir.mk: add ${SUBDIR.yes} - allows for SUBDIR.${MK_*}
	  and handle subdir with '-' in its name.

2024-08-23  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240820

	* links.mk: Allow a filter to be applied to SYMLINKS etc.
	It is up to [BUILD_][SYM]LINKS_FILTER to do something sane.
	Also only claim we are making a symlink if the value changed.
This commit is contained in:
Simon J. Gerraty
2025-01-30 15:38:13 -08:00
parent 84691af931
commit 5ad769f660
201 changed files with 3148 additions and 1740 deletions
+139
View File
@@ -1,3 +1,142 @@
2025-01-25 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250125
Merge with NetBSD make, sync up below change.
* unit-tests/Makefile: remove $TMPDIR via .END
to avoid failure in test on NFS - since the temp file for the
target script is open and thus gets renamed by the server rather
than removed.
2025-01-20 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250120
Merge with NetBSD make, pick up
o use FORK_FUNCTION so it can be forced to fork when doing coverage.
o main.c: avoid memory allocation in error path after exec failure.
2025-01-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250116
Merge with NetBSD make, pick up
o clarify that undefined expressions are allowed in dependencies
o simplify code for evaluating the '!=' variable assignment
2025-01-11 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250111
Merge with NetBSD make, pick up
o replace "Malformed conditional" with "Variable is undefined"
when appropriate
2025-01-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250110
Merge with NetBSD make, pick up
o job.c: remove some unnecessary layers in job handling
o unit-tests: test expressions based on undefined variables
2025-01-01 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250101
Merge with NetBSD make, pick up
o var.c: reduce pointer indirections when unexporting a variable
2024-12-12 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20241212
* mk/ updates
2024-11-24 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20241124
Merge with NetBSD make, pick up
o var.c: fix confusing error message when overriding a read-only
variable
2024-11-22 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20241122
Merge with NetBSD make, pick up
o unit-tests/Makefile: optimize running of tests skip extra cat
in 99% of cases.
2024-11-15 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20241114
Merge with NetBSD make, pick up
o make.1: note that MAKEOBJPREFIX should be absolute path
also that it can be set via makefile if suitable care taken.
2024-11-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20241110
Merge with NetBSD make, pick up
o make: allow .../ (search here and above) in
.MAKE.MAKEFILE_PREFERENCE and -f argument.
2024-11-03 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20241101
Merge with NetBSD make, pick up
o parse.c: report filename:linenumber in parse debug output
2024-09-21 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240921
Merge with NetBSD make, pick up
o make.1: Only list the defaults for MAKEFILE_PREFERENCE once.
* Makefile: use genfiles.mk to generate ${MAN}
so that it can be tuned for local site.
Ensure MAN is defined before including Makefile.inc
* Makefile: use MK_GEN_MAN to make it easier to control whether we
generate ${MAN}
2024-09-16 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240909
* arch.c: fix NetBSD PR 58597
2024-09-01 Simon J Gerraty <sjg@beast.crufty.net>
* Makefile: use SUBDIR.${MK_TESTS} so that we skip
unit-tests for obj and clean when FreeBSD is building WITHOUT_TESTS
* VERSION (_MAKE_VERSION): 20240901
Merge with NetBSD make, pick up
o reduce line length in error messages
o var.c: simplify printing of an evaluation stack element
2024-08-29 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240828
Merge with NetBSD make, pick up
o add more context to error message about recursive variables
o treat recursive variables non-fatally - continue parsing to end
of makefile
2024-08-12 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240808
Merge with NetBSD make, pick up
o improve some error messages for better clarify and readability
2024-07-22 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240722
Merge with NetBSD make, pick up
o job.c: remove dead code
2024-07-21 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20240720
Merge with NetBSD make, pick up
o compat.c: do not run commands that have parse or evaluation errors.
o var.c: remove wrong error message about an undefined variable
2024-07-13 Simon J Gerraty <sjg@beast.crufty.net>
* cleanup redundant differences from NetBSD make
+2
View File
@@ -593,6 +593,8 @@ unit-tests/shell-ksh.exp
unit-tests/shell-ksh.mk
unit-tests/shell-sh.exp
unit-tests/shell-sh.mk
unit-tests/suff.exp
unit-tests/suff.mk
unit-tests/suff-add-later.exp
unit-tests/suff-add-later.mk
unit-tests/suff-clear-regular.exp
+84 -55
View File
@@ -1,8 +1,8 @@
# $Id: Makefile,v 1.127 2024/03/19 16:03:23 sjg Exp $
# $Id: Makefile,v 1.132 2024/09/22 19:56:26 sjg Exp $
PROG= bmake
PROG = bmake
SRCS= \
SRCS = \
arch.c \
buf.c \
compat.c \
@@ -25,6 +25,11 @@ SRCS= \
util.c \
var.c
.MAIN: all
MAN = ${PROG}.1
SRCS.${MAN} = ${srcdir}/make.1
.-include "VERSION"
.-include "Makefile.inc"
@@ -32,25 +37,26 @@ SRCS= \
.-include "Makefile.config"
.if !empty(LIBOBJS)
SRCS+= ${LIBOBJS:T:.o=.c}
SRCS += ${LIBOBJS:T:.o=.c}
.endif
# just in case
prefix?= /usr
srcdir?= ${.CURDIR}
prefix ?= /usr
srcdir ?= ${.PARSEDIR}
srcdir := ${srcdir}
DEFAULT_SYS_PATH?= ${prefix}/share/mk
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}\""
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
.ifdef $x
COPTS.main.c+= "-D$x=\"${$x}\""
COPTS.main.c += "-D$x=\"${$x}\""
.endif
.endfor
@@ -60,8 +66,8 @@ 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}
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
@@ -76,65 +82,82 @@ COPTS.filemon_ktrace.c += -Wno-error=unused-parameter
.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
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}}
isBSD44 := ${BSD44_LIST:M${OS}}
.if ${isBSD44} == "" && ${OS:NCygwin:NDarwin:NLinux} != ""
MANTARGET?= cat
MANTARGET ?= cat
.if ${MACHINE} == "sun386"
# even I don't have one of these anymore :-)
CFLAGS+= -DPORTAR
CFLAGS += -DPORTAR
.elif ${OS} != "SunOS"
# assume the worst
SRCS+= sigcompat.c
CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
SRCS += sigcompat.c
CFLAGS += -DSIGNAL_FLAGS=SA_RESTART
.endif
.else
MANTARGET?= man
MANTARGET ?= man
.endif
# turn this on by default - ignored if we are root
WITH_INSTALL_AS_USER=
WITH_INSTALL_AS_USER =
# suppress with -DWITHOUT_*
OPTIONS_DEFAULT_YES+= \
OPTIONS_DEFAULT_YES += \
AUTOCONF_MK \
INSTALL_MK \
PROG_LINK
PROG_LINK \
TESTS \
OPTIONS_DEFAULT_NO+= \
PROG_VERSION
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}
PROG_NAME = ${PROG}-${_MAKE_VERSION}
.if ${MK_PROG_LINK} == "yes"
SYMLINKS+= ${PROG_NAME} ${BINDIR}/${PROG}
SYMLINKS += ${PROG_NAME} ${BINDIR}/${PROG}
.endif
.endif
EXTRACT_MAN=no
# end-delete1
MAN= ${PROG}.1
MAN1= ${MAN}
.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
.if make(${MAN}) || !exists(${srcdir}/${MAN})
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"; \
@@ -142,40 +165,46 @@ my.history:
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}/' \
SED_CMDS.${MAN} += \
-e '/^.Sh HISTORY/rmy.history' \
-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
-e '/^.Sh HISTORY/,/BUGS/s,^.Nm,make,' \
all beforeinstall: ${MAN}
.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
.endif # MK_GEN_MAN
MANTARGET?= cat
MANDEST?= ${MANDIR}/${MANTARGET}1
MANTARGET ?= cat
MANDEST ?= ${MANDIR}/${MANTARGET}1
.if ${MANTARGET} == "cat"
_mfromdir=${srcdir}
_mfromdir = ${srcdir}
.endif
.include <prog.mk>
CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
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}
SHAREDIR = ${SHAREDIR.bmake:U${prefix}/share}
BINDIR = ${BINDIR.bmake:U${prefix}/bin}
MANDIR = ${MANDIR.bmake:U${SHAREDIR}/man}
${OBJS}: config.h
+1 -1
View File
@@ -1,2 +1,2 @@
# keep this compatible with sh and make
_MAKE_VERSION=20240711
_MAKE_VERSION=20250125
+4 -5
View File
@@ -1,4 +1,4 @@
/* $NetBSD: arch.c,v 1.221 2024/07/07 07:50:57 rillig Exp $ */
/* $NetBSD: arch.c,v 1.222 2024/08/06 17:46:01 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.221 2024/07/07 07:50:57 rillig Exp $");
MAKE_RCSID("$NetBSD: arch.c,v 1.222 2024/08/06 17:46:01 rillig Exp $");
typedef struct List ArchList;
typedef struct ListNode ArchListNode;
@@ -314,8 +314,7 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
if (*cp == '\0') {
Parse_Error(PARSE_FATAL,
"No closing parenthesis "
"in archive specification");
"Missing ')' in archive specification");
return false;
}
@@ -416,7 +415,7 @@ Arch_ParseArchive(char **pp, GNodeList *gns, GNode *scope)
static struct ar_hdr *
ArchStatMember(const char *archive, const char *member, bool addToCache)
{
#define AR_MAX_NAME_LEN (sizeof arh.ar_name - 1)
#define AR_MAX_NAME_LEN (sizeof arh.AR_NAME - 1)
FILE *arch;
size_t size; /* Size of archive member */
char magic[SARMAG];
+30 -17
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: make.1,v 1.378 2024/07/01 21:02:26 sjg Exp $
.\" $NetBSD: make.1,v 1.381 2024/11/14 19:30:13 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 July 1, 2024
.Dd November 14, 2024
.Dt BMAKE 1
.Os
.Sh NAME
@@ -60,10 +60,11 @@ If no
.Fl f Ar makefile
option is given,
.Nm
tries to open
.Sq Pa makefile
then
.Sq Pa Makefile
looks for the makefiles listed in
.Va .MAKE.MAKEFILE_PREFERENCE
(default
.Sq Pa makefile ,
.Sq Pa Makefile )
in order to find the specifications.
If the file
.Sq Pa .depend
@@ -233,15 +234,20 @@ so the actual commands are printed as they are executed.
.It Fl e
Let environment variables override global variables within makefiles.
.It Fl f Ar makefile
Specify a makefile to read instead of the default
.Pa makefile
or
.Pa Makefile .
Specify a makefile to read instead of one of the defaults listed in
.Va .MAKE.MAKEFILE_PREFERENCE .
If
.Ar makefile
is
.Ql \&- ,
standard input is read.
If
.Ar makefile
starts with the string
.Ql \&.../ ,
.Nm
searches for the specified path in the rest of the argument
in the current directory and its parents.
Multiple makefiles may be specified, and are read in the order specified.
.It Fl I Ar directory
Specify a directory in which to search for makefiles and included makefiles.
@@ -1159,6 +1165,7 @@ to help debug.
.It Va MAKEOBJDIRPREFIX
Used to create files in a separate directory, see
.Va .OBJDIR .
It should be an absolute path.
.It Va .MAKE.OS
The name of the operating system, see
.Xr uname 1 .
@@ -2636,12 +2643,18 @@ and
.Ev MAKEOBJDIRPREFIX
and
.Ev MAKEOBJDIR
may only be set in the environment or on the command line to
should be set in the environment or on the command line to
.Nm
and not as makefile variables;
see the description of
.Sq Va .OBJDIR
for more details.
It is possible to set these via makefile variables but unless done
very early and the
.Sq Ic .OBJDIR
target is used to reset
.Sq Va .OBJDIR ,
there may be unexpected side effects.
.Sh FILES
.Bl -tag -width /usr/share/mk -compact
.It .depend
@@ -2663,13 +2676,13 @@ An incomplete list of changes in older versions of
.Nm :
.Pp
The way that .for loop variables are substituted changed after
NetBSD 5.0
.Nx 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.
.Pp
The way that parallel makes are scheduled changed in
NetBSD 4.0
.Nx 4.0
so that .ORDER and .WAIT apply recursively to the dependent nodes.
The algorithms used may change again in the future.
.Ss Other make dialects
@@ -2767,21 +2780,21 @@ does not exist ... unless someone creates an
file).
.Sh BUGS
The
make
.Nm
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
.Nm
just counts {} and () in order to find the end of a variable expansion.
.Pp
There is no way of escaping a space character in a filename.
.Pp
In jobs mode, when a target fails;
make
.Nm
will put an error token into the job token pool.
This will cause all other instances of
make
.Nm
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
+20 -14
View File
@@ -13,9 +13,9 @@ DDEESSCCRRIIPPTTIIOONN
bbmmaakkee is a program designed to simplify the maintenance of other
programs. Its input is a list of specifications as to the files upon
which programs and other files depend. If no --ff _m_a_k_e_f_i_l_e option is
given, bbmmaakkee tries to open `_m_a_k_e_f_i_l_e' then `_M_a_k_e_f_i_l_e' in order to find
the specifications. If the file `_._d_e_p_e_n_d' exists, it is read, see
mkdep(1).
given, bbmmaakkee looks for the makefiles listed in _._M_A_K_E_._M_A_K_E_F_I_L_E___P_R_E_F_E_R_E_N_C_E
(default `_m_a_k_e_f_i_l_e', `_M_a_k_e_f_i_l_e') in order to find the specifications. If
the file `_._d_e_p_e_n_d' exists, it is read, see mkdep(1).
This manual page is intended as a reference document only. For a more
thorough description of bbmmaakkee and makefiles, please refer to _P_M_a_k_e _- _A
@@ -138,9 +138,12 @@ DDEESSCCRRIIPPTTIIOONN
makefiles.
--ff _m_a_k_e_f_i_l_e
Specify a makefile to read instead of the default _m_a_k_e_f_i_l_e or
_M_a_k_e_f_i_l_e. If _m_a_k_e_f_i_l_e is `-', standard input is read. Multiple
makefiles may be specified, and are read in the order specified.
Specify a makefile to read instead of one of the defaults listed
in _._M_A_K_E_._M_A_K_E_F_I_L_E___P_R_E_F_E_R_E_N_C_E. If _m_a_k_e_f_i_l_e is `-', standard input
is read. If _m_a_k_e_f_i_l_e starts with the string `.../', bbmmaakkee
searches for the specified path in the rest of the argument in
the current directory and its parents. Multiple makefiles may be
specified, and are read in the order specified.
--II _d_i_r_e_c_t_o_r_y
Specify a directory in which to search for makefiles and included
@@ -765,7 +768,8 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS
debug.
_M_A_K_E_O_B_J_D_I_R_P_R_E_F_I_X
Used to create files in a separate directory, see _._O_B_J_D_I_R.
Used to create files in a separate directory, see _._O_B_J_D_I_R. It
should be an absolute path.
_._M_A_K_E_._O_S
The name of the operating system, see uname(1). It is read-only.
@@ -1691,9 +1695,11 @@ EENNVVIIRROONNMMEENNTT
MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX, MAKESYSPATH,
PWD, and TMPDIR.
MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on
MAKEOBJDIRPREFIX and MAKEOBJDIR should be set in the environment or on
the command line to bbmmaakkee and not as makefile variables; see the
description of `_._O_B_J_D_I_R' for more details.
description of `_._O_B_J_D_I_R' for more details. It is possible to set these
via makefile variables but unless done very early and the `..OOBBJJDDIIRR'
target is used to reset `_._O_B_J_D_I_R', there may be unexpected side effects.
FFIILLEESS
.depend list of dependencies
@@ -1774,17 +1780,17 @@ HHIISSTTOORRYY
_F_R_C file).
BBUUGGSS
The make syntax is difficult to parse. For instance, finding the end of
The bbmmaakkee 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 {}
correct terminator for each field. In many places bbmmaakkee 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
In jobs mode, when a target fails; bbmmaakkee will put an error token into the
job token pool. This will cause all other instances of bbmmaakkee 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 14.1-RELEASE July 1, 2024 FreeBSD 14.1-RELEASE
FreeBSD 14.1-RELEASE-p5 November 14, 2024 FreeBSD 14.1-RELEASE-p5

Before

Width:  |  Height:  |  Size: 90 KiB

After

Width:  |  Height:  |  Size: 90 KiB

+2 -3
View File
@@ -1,4 +1,4 @@
# $Id: bsd.after-import.mk,v 1.18 2023/09/18 05:29:23 sjg Exp $
# $Id: bsd.after-import.mk,v 1.19 2024/09/21 22:44:55 sjg Exp $
# This makefile is for use when integrating bmake into a BSD build
# system. Use this makefile after importing bmake.
@@ -61,8 +61,7 @@ MAKEFILE_SED = sed -e '/^MACHINE/d' \
-e '/include.*VERSION/d' \
-e '/^CC=/s,=,?=,' \
-e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \
-e 's,^.-include,.sinclude,' \
-e '/^\..*include *</ { s,<,<bsd.,;/autoconf/d; }' \
-e '/^\..*include *</ { s,<\([a-z]\),<bsd.\1,;/autoconf/d; }' \
-e 's,${SRCTOP},$${SRCTOP},g'
# These are the simple files we want to capture
+9 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: compat.c,v 1.260 2024/07/11 20:09:16 sjg Exp $ */
/* $NetBSD: compat.c,v 1.262 2025/01/19 10:57:10 rillig 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.260 2024/07/11 20:09:16 sjg Exp $");
MAKE_RCSID("$NetBSD: compat.c,v 1.262 2025/01/19 10:57:10 rillig Exp $");
static GNode *curTarg = NULL;
static pid_t compatChild;
@@ -206,7 +206,7 @@ UseShell(const char *cmd MAKE_ATTR_UNUSED)
static int
Compat_Spawn(const char **av)
{
int pid = vfork();
int pid = FORK_FUNCTION();
if (pid < 0)
Fatal("Could not fork");
@@ -251,13 +251,18 @@ Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln)
const char *cmd = cmdp;
char cmd_file[MAXPATHLEN];
size_t cmd_len;
int parseErrorsBefore;
silent = (gn->type & OP_SILENT) != OP_NONE;
errCheck = !(gn->type & OP_IGNORE);
doIt = false;
parseErrorsBefore = parseErrors;
cmdStart = Var_SubstInTarget(cmd, gn);
/* TODO: handle errors */
if (parseErrors != parseErrorsBefore) {
free(cmdStart);
return false;
}
if (cmdStart[0] == '\0') {
free(cmdStart);
+14 -15
View File
@@ -1,4 +1,4 @@
/* $NetBSD: cond.c,v 1.366 2024/07/06 21:21:09 rillig Exp $ */
/* $NetBSD: cond.c,v 1.371 2025/01/11 21:21:33 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.366 2024/07/06 21:21:09 rillig Exp $");
MAKE_RCSID("$NetBSD: cond.c,v 1.371 2025/01/11 21:21:33 rillig Exp $");
/*
* Conditional expressions conform to this grammar:
@@ -221,13 +221,7 @@ ParseWord(const char **pp, bool doEval)
if ((ch == '&' || ch == '|') && depth == 0)
break;
if (ch == '$') {
VarEvalMode emode = doEval
? VARE_EVAL_DEFINED
: VARE_PARSE;
/*
* TODO: make Var_Parse complain about undefined
* variables.
*/
VarEvalMode emode = doEval ? VARE_EVAL : VARE_PARSE;
FStr nestedVal = Var_Parse(&p, SCOPE_CMDLINE, emode);
/* TODO: handle errors */
Buf_AddStr(&word, nestedVal.str);
@@ -242,7 +236,6 @@ ParseWord(const char **pp, bool doEval)
p++;
}
cpp_skip_hspace(&p);
*pp = p;
return Buf_DoneData(&word);
@@ -252,12 +245,14 @@ ParseWord(const char **pp, bool doEval)
static char *
ParseFuncArg(CondParser *par, const char **pp, bool doEval, const char *func)
{
const char *p = *pp;
const char *p = *pp, *argStart, *argEnd;
char *res;
p++; /* skip the '(' */
cpp_skip_hspace(&p);
argStart = p;
res = ParseWord(&p, doEval);
argEnd = p;
cpp_skip_hspace(&p);
if (*p++ != ')') {
@@ -266,7 +261,8 @@ ParseFuncArg(CondParser *par, const char **pp, bool doEval, const char *func)
len++;
Parse_Error(PARSE_FATAL,
"Missing closing parenthesis for %.*s()", len, func);
"Missing ')' after argument '%.*s' for '%.*s'",
(int)(argEnd - argStart), argStart, len, func);
par->printedError = true;
free(res);
return NULL;
@@ -397,7 +393,7 @@ CondParser_StringExpr(CondParser *par, const char *start,
bool atStart; /* true means an expression outside quotes */
emode = doEval && quoted ? VARE_EVAL
: doEval ? VARE_EVAL_DEFINED
: doEval ? VARE_EVAL_DEFINED_LOUD
: VARE_PARSE;
p = par->p;
@@ -734,6 +730,7 @@ CondParser_ComparisonOrLeaf(CondParser *par, bool doEval)
*/
arg = ParseWord(&p, doEval);
assert(arg[0] != '\0');
cpp_skip_hspace(&p);
if (*p == '=' || *p == '!' || *p == '<' || *p == '>') {
free(arg);
@@ -922,6 +919,7 @@ CondEvalExpression(const char *cond, bool plain,
{
CondParser par;
CondResult rval;
int parseErrorsBefore = parseErrors;
cpp_skip_hspace(&cond);
@@ -938,8 +936,9 @@ CondEvalExpression(const char *cond, bool plain,
if (par.curr != TOK_EOF)
rval = CR_ERROR;
if (rval == CR_ERROR && eprint && !par.printedError)
Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond);
if (rval == CR_ERROR && eprint && !par.printedError
&& parseErrors == parseErrorsBefore)
Parse_Error(PARSE_FATAL, "Malformed conditional '%s'", cond);
return rval;
}
+17 -67
View File
@@ -1,4 +1,4 @@
/* $NetBSD: job.c,v 1.480 2024/07/07 07:50:57 rillig Exp $ */
/* $NetBSD: job.c,v 1.485 2025/01/19 10:57:10 rillig 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.480 2024/07/07 07:50:57 rillig Exp $");
MAKE_RCSID("$NetBSD: job.c,v 1.485 2025/01/19 10:57:10 rillig Exp $");
/*
* A shell defines how the commands are run. All commands for a target are
@@ -270,12 +270,6 @@ static enum { /* Why is the make aborting? */
/* Tracks the number of tokens currently "out" to build jobs. */
int jobTokensRunning = 0;
typedef enum JobStartResult {
JOB_RUNNING, /* Job is running */
JOB_ERROR, /* Error in starting the job */
JOB_FINISHED /* The job is already finished */
} JobStartResult;
/*
* Descriptions for various shells.
*
@@ -1280,7 +1274,7 @@ TouchRegular(GNode *gn)
}
/*
* Touch the given target. Called by JobStart when the -t flag was given.
* Touch the given target. Called by Job_Make when the -t flag was given.
*
* The modification date of the file is changed.
* If the file did not exist, it is created.
@@ -1435,9 +1429,9 @@ JobExec(Job *job, char **argv)
Var_ReexportVars(job->node);
cpid = vfork();
cpid = FORK_FUNCTION();
if (cpid == -1)
Punt("Cannot vfork: %s", strerror(errno));
Punt("Cannot fork: %s", strerror(errno));
if (cpid == 0) {
/* Child */
@@ -1628,22 +1622,8 @@ JobWriteShellCommands(Job *job, GNode *gn, bool *out_run)
*out_run = JobWriteCommands(job);
}
/*
* Start a target-creation process going for the target described by gn.
*
* Results:
* JOB_ERROR if there was an error in the commands, JOB_FINISHED
* if there isn't actually anything left to do for the job and
* JOB_RUNNING if the job has been started.
*
* Details:
* A new Job node is created and added to the list of running
* jobs. PMake is forked and a child shell created.
*
* NB: The return value is ignored by everyone.
*/
static JobStartResult
JobStart(GNode *gn, bool special)
void
Job_Make(GNode *gn)
{
Job *job; /* new job descriptor */
char *argv[10]; /* Argument vector to shell */
@@ -1655,14 +1635,14 @@ JobStart(GNode *gn, bool special)
break;
}
if (job >= job_table_end)
Punt("JobStart no job slots vacant");
Punt("Job_Make no job slots vacant");
memset(job, 0, sizeof *job);
job->node = gn;
job->tailCmds = NULL;
job->status = JOB_ST_SET_UP;
job->special = special || gn->type & OP_SPECIAL;
job->special = (gn->type & OP_SPECIAL) != OP_NONE;
job->ignerr = opts.ignoreErrors || gn->type & OP_IGNORE;
job->echo = !(opts.silent || gn->type & OP_SILENT);
@@ -1695,6 +1675,8 @@ JobStart(GNode *gn, bool special)
* virtual targets.
*/
int parseErrorsBefore;
/*
* We're serious here, but if the commands were bogus, we're
* also dead...
@@ -1704,7 +1686,10 @@ JobStart(GNode *gn, bool special)
DieHorribly();
}
parseErrorsBefore = parseErrors;
JobWriteShellCommands(job, gn, &run);
if (parseErrors != parseErrorsBefore)
run = false;
(void)fflush(job->cmdFILE);
} else if (!GNode_ShouldExecute(gn)) {
/*
@@ -1742,7 +1727,7 @@ JobStart(GNode *gn, bool special)
Make_Update(job->node);
}
job->status = JOB_ST_FREE;
return cmdsOK ? JOB_FINISHED : JOB_ERROR;
return;
}
/*
@@ -1755,7 +1740,6 @@ JobStart(GNode *gn, bool special)
JobCreatePipe(job, 3);
JobExec(job, argv);
return JOB_RUNNING;
}
/*
@@ -1953,31 +1937,12 @@ CollectOutput(Job *job, bool finish)
static void
JobRun(GNode *targ)
{
#if 0
/*
* Unfortunately it is too complicated to run .BEGIN, .END, and
* .INTERRUPT job in the parallel job module. As of 2020-09-25,
* unit-tests/deptgt-end-jobs.mk hangs in an endless loop.
*
* Running these jobs in compat mode also guarantees that these
* jobs do not overlap with other unrelated jobs.
*/
GNodeList lst = LST_INIT;
Lst_Append(&lst, targ);
(void)Make_Run(&lst);
Lst_Done(&lst);
JobStart(targ, true);
while (jobTokensRunning != 0) {
Job_CatchOutput();
}
#else
/* Don't let these special jobs overlap with other unrelated jobs. */
Compat_Make(targ, targ);
/* XXX: Replace with GNode_IsError(gn) */
if (targ->made == ERROR) {
if (GNode_IsError(targ)) {
PrintOnError(targ, "\n\nStop.\n");
exit(1);
}
#endif
}
/*
@@ -2133,16 +2098,6 @@ Job_CatchOutput(void)
}
}
/*
* Start the creation of a target. Basically a front-end for JobStart used by
* the Make module.
*/
void
Job_Make(GNode *gn)
{
(void)JobStart(gn, false);
}
static void
InitShellNameAndPath(void)
{
@@ -2921,11 +2876,6 @@ Job_RunTarget(const char *target, const char *fname)
Var_Set(gn, ALLSRC, fname);
JobRun(gn);
/* XXX: Replace with GNode_IsError(gn) */
if (gn->made == ERROR) {
PrintOnError(gn, "\n\nStop.\n");
exit(1);
}
return true;
}
+2 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: job.h,v 1.80 2024/07/07 07:50:57 rillig Exp $ */
/* $NetBSD: job.h,v 1.81 2025/01/03 04:51:42 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -119,7 +119,7 @@ typedef enum JobStatus {
JOB_ST_SET_UP = 1, /* Job is allocated but otherwise invalid */
/* XXX: What about the 2? */
JOB_ST_RUNNING = 3, /* Job is running, pid valid */
JOB_ST_FINISHED = 4 /* Job is done (ie after SIGCHILD) */
JOB_ST_FINISHED = 4 /* Job is done (ie after SIGCHLD) */
} JobStatus;
/*
+25 -19
View File
@@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.632 2024/07/11 20:09:16 sjg Exp $ */
/* $NetBSD: main.c,v 1.638 2025/01/19 12:59:39 rillig 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.632 2024/07/11 20:09:16 sjg Exp $");
MAKE_RCSID("$NetBSD: main.c,v 1.638 2025/01/19 12:59:39 rillig Exp $");
#if defined(MAKE_NATIVE)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1414,7 +1414,8 @@ main_Init(int argc, char **argv)
/* Set some other useful variables. */
{
char buf[64], *ep = getenv(MAKE_LEVEL_ENV);
char buf[64];
const char *ep = getenv(MAKE_LEVEL_ENV);
makelevel = ep != NULL && ep[0] != '\0' ? atoi(ep) : 0;
if (makelevel < 0)
@@ -1658,6 +1659,20 @@ ReadMakefile(const char *fname)
Parse_File("(stdin)", -1);
Var_Set(SCOPE_INTERNAL, "MAKEFILE", "");
} else {
if (strncmp(fname, ".../", 4) == 0) {
name = Dir_FindHereOrAbove(curdir, fname + 4);
if (name != NULL) {
/* Dir_FindHereOrAbove returns dirname */
path = str_concat3(name, "/",
str_basename(fname));
free(name);
fd = open(path, O_RDONLY);
if (fd != -1) {
fname = path;
goto found;
}
}
}
/* if we've chdir'd, rebuild the path name */
if (strcmp(curdir, objdir) != 0 && *fname != '/') {
path = str_concat3(curdir, "/", fname);
@@ -1787,7 +1802,7 @@ Cmd_Exec(const char *cmd, char **error)
Var_ReexportVars(SCOPE_GLOBAL);
switch (cpid = vfork()) {
switch (cpid = FORK_FUNCTION()) {
case 0:
(void)close(pipefds[0]);
(void)dup2(pipefds[1], STDOUT_FILENO);
@@ -1998,23 +2013,14 @@ write_all(int fd, const void *data, size_t n)
/* Print why exec failed, avoiding stdio. */
void MAKE_ATTR_DEAD
execDie(const char *af, const char *av)
execDie(const char *func, const char *arg)
{
Buffer buf;
char msg[1024];
int len;
Buf_Init(&buf);
Buf_AddStr(&buf, progname);
Buf_AddStr(&buf, ": ");
Buf_AddStr(&buf, af);
Buf_AddStr(&buf, "(");
Buf_AddStr(&buf, av);
Buf_AddStr(&buf, ") failed (");
Buf_AddStr(&buf, strerror(errno));
Buf_AddStr(&buf, ")\n");
write_all(STDERR_FILENO, buf.data, buf.len);
Buf_Done(&buf);
len = snprintf(msg, sizeof(msg), "%s: %s(%s) failed (%s)\n",
progname, func, arg, strerror(errno));
write_all(STDERR_FILENO, msg, (size_t)len);
_exit(1);
}
+24 -11
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: make.1,v 1.378 2024/07/01 21:02:26 sjg Exp $
.\" $NetBSD: make.1,v 1.381 2024/11/14 19:30:13 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 July 1, 2024
.Dd November 14, 2024
.Dt MAKE 1
.Os
.Sh NAME
@@ -60,10 +60,11 @@ If no
.Fl f Ar makefile
option is given,
.Nm
tries to open
.Sq Pa makefile
then
.Sq Pa Makefile
looks for the makefiles listed in
.Va .MAKE.MAKEFILE_PREFERENCE
(default
.Sq Pa makefile ,
.Sq Pa Makefile )
in order to find the specifications.
If the file
.Sq Pa .depend
@@ -233,15 +234,20 @@ so the actual commands are printed as they are executed.
.It Fl e
Let environment variables override global variables within makefiles.
.It Fl f Ar makefile
Specify a makefile to read instead of the default
.Pa makefile
or
.Pa Makefile .
Specify a makefile to read instead of one of the defaults listed in
.Va .MAKE.MAKEFILE_PREFERENCE .
If
.Ar makefile
is
.Ql \&- ,
standard input is read.
If
.Ar makefile
starts with the string
.Ql \&.../ ,
.Nm
searches for the specified path in the rest of the argument
in the current directory and its parents.
Multiple makefiles may be specified, and are read in the order specified.
.It Fl I Ar directory
Specify a directory in which to search for makefiles and included makefiles.
@@ -1159,6 +1165,7 @@ to help debug.
.It Va MAKEOBJDIRPREFIX
Used to create files in a separate directory, see
.Va .OBJDIR .
It should be an absolute path.
.It Va .MAKE.OS
The name of the operating system, see
.Xr uname 1 .
@@ -2636,12 +2643,18 @@ and
.Ev MAKEOBJDIRPREFIX
and
.Ev MAKEOBJDIR
may only be set in the environment or on the command line to
should be set in the environment or on the command line to
.Nm
and not as makefile variables;
see the description of
.Sq Va .OBJDIR
for more details.
It is possible to set these via makefile variables but unless done
very early and the
.Sq Ic .OBJDIR
target is used to reset
.Sq Va .OBJDIR ,
there may be unexpected side effects.
.Sh FILES
.Bl -tag -width /usr/share/mk -compact
.It .depend
+18 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.344 2024/07/11 20:09:16 sjg Exp $ */
/* $NetBSD: make.h,v 1.349 2025/01/19 10:57:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -183,6 +183,15 @@ typedef unsigned char bool;
#define false 0
#endif
/*
* In code coverage mode with gcc>=12, calling vfork/exec does not mark any
* further code from the parent process as covered. gcc-10.5.0 is fine, as
* are fork/exec calls, as well as posix_spawn.
*/
#ifndef FORK_FUNCTION
#define FORK_FUNCTION vfork
#endif
#include "lst.h"
#include "make_malloc.h"
#include "str.h"
@@ -716,7 +725,7 @@ typedef struct CmdOpts {
*/
DebugFlags debug;
/* -df: debug output is written here - default stderr */
/* -dF: debug output is written here - default stderr */
FILE *debug_file;
/*
@@ -985,6 +994,12 @@ typedef enum VarEvalMode {
* Parse and evaluate the expression. It is an error if a
* subexpression evaluates to undefined.
*/
VARE_EVAL_DEFINED_LOUD,
/*
* Parse and evaluate the expression. It is a silent error if a
* subexpression evaluates to undefined.
*/
VARE_EVAL_DEFINED,
/*
@@ -1064,7 +1079,7 @@ void Global_Append(const char *, const char *);
void Global_Delete(const char *);
void Global_Set_ReadOnly(const char *, const char *);
const char *EvalStack_Details(void);
void EvalStack_PrintDetails(void);
/* util.c */
typedef void (*SignalProc)(int);
+117
View File
@@ -1,3 +1,120 @@
2025-01-10 Simon J Gerraty <sjg@beast.crufty.net>
* rust.mk: use RUST_LIBS and RUST_PROGS
2025-01-01 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20250101
* use W flag to :S and :C rather than :tW
2024-12-16 Simon J Gerraty <sjg@beast.crufty.net>
* rust.mk: add RUSTFLAGS if needed
2024-12-12 Simon J Gerraty <sjg@beast.crufty.net>
* init.mk (OBJS_SRCS_FILTER): apply this as
${OBJS_SRCS_FILTER:ts:} as we do in FreeBSD.
2024-12-03 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20241202
* setopts.sh: needed by newlog.sh
2024-11-22 Simon J Gerraty <sjg@beast.crufty.net>
* meta.sys.mk: add META_MODE_XTRAS to META_MODE to make it
easier to add things like 'env' when debugging.
* install-mk (MK_VERSION): 20241122
* rust.mk: rename CARGO* to RUST_CARGO* so I don't feel
like this makefile should be renamed to cargo.mk
2024-11-11 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: add DIRDEPS_CACHED_ENV to dirdeps-cached and
DIRDEP_USE_EPILOGUE to _DIRDEP_USE
2024-10-30 Simon J Gerraty <sjg@beast.crufty.net>
* meta.sys.mk: if MK_META_ERROR_TARGET is yes and NEWLOG_SH is
set, and ERROR_LOGDIR already exists, hook _rotateErrorLog to
.BEGIN target.
2024-10-27 Simon J Gerraty <sjg@beast.crufty.net>
* options.mk: add support for DEBUG_OPTIONS (similar to
DEBUG_DIRDEPS) to allow us to see where options get set.
Eg. DEBUG_OPTIONS="STAGING*" gives:
bmake[1]: "mk/options.mk" line 89: sys.mk: MK_STAGING=yes (MK_DIRDEPS_BUILD=no)
bmake[1]: "mk/options.mk" line 66: local.init.mk: MK_STAGING=yes
bmake[1]: "mk/options.mk" line 66: local.init.mk: MK_STAGING_PROG=no
bmake[1]: "mk/options.mk" line 89: own.mk: MK_STAGING_MAN=yes (MK_STAGING=yes)
bmake[1]: "mk/options.mk" line 89: own.mk: MK_STAGING_PROG=no (MK_STAGING=yes)
bmake[1]: "mk/options.mk" line 89: own.mk: MK_STAGING_RUST=no (MK_STAGING_PROG=no)
* own.mk: fix setting of STAGE_OBJTOP (normally set by sys.dirdeps.mk)
2024-10-26 Simon J Gerraty <sjg@beast.crufty.net>
* rust.mk: add some documentation and support for staging
2024-10-25 Simon J Gerraty <sjg@beast.crufty.net>
* rust.mk: a means of integrating Rust projects into a larger build.
2024-10-18 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps-targets.mk: if DEBUG_DIRDEPS_TARGETS and we found
STATIC_DIRDEPS_CACHE, report its relative path.
2024-09-30 Simon J Gerraty <sjg@beast.crufty.net>
* dirdeps.mk: tweak the debug message for "Loading" a
Makefile.depend file, always report what the actual makefile is
with the DIRDEP it is for.
Remove the redundant "Looking" message.
2024-09-26 Simon J Gerraty <sjg@beast.crufty.net>
* meta2deps.py: when raising AssertionError include meta file name
with $SB trimmed if possible.
2024-09-23 Simon J Gerraty <sjg@beast.crufty.net>
* meta2deps.py: replace assert() with raise AssertionError when we
detect missing eXits, to ensure a meaningful message gets into
log.
2024-09-21 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240921
* FILES: add genfiles.mk
2024-09-20 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240920
* cython.mk: Get PYTHON_VERSION from PYTHON
2024-08-31 Simon J Gerraty <sjg@beast.crufty.net>
* subdir.mk: add ${SUBDIR.yes} - allows for SUBDIR.${MK_*}
and handle subdir with '-' in its name.
2024-08-23 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240820
* links.mk: Allow a filter to be applied to SYMLINKS etc.
It is up to [BUILD_][SYM]LINKS_FILTER to do something sane.
Also only claim we are making a symlink if the value changed.
2024-06-22 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20240616
+3
View File
@@ -15,6 +15,7 @@ doc.mk
dpadd.mk
files.mk
final.mk
genfiles.mk
host-target.mk
host.libnames.mk
inc.mk
@@ -42,7 +43,9 @@ prlist.mk
prog.mk
progs.mk
rst2htm.mk
rust.mk
scripts.mk
setopts.sh
srctop.mk
stage-install.sh
subdir.mk
+5 -5
View File
@@ -1,9 +1,9 @@
# $Id: README,v 1.2 2020/08/19 17:51:53 sjg Exp $
# $Id: README,v 1.3 2024/12/10 22:15:02 sjg Exp $
This directory contains some macro's derrived from the NetBSD bsd.*.mk
macros. They have the same names but without the bsd., separate macro
files are needed to ensure we can make them do what we want for
builing things outside of /usr/src. Nearly all the comments below
This directory contains some makefiles derrived from the NetBSD bsd.*.mk
ones. They have the same names but without the bsd., separate
makefiles are needed to ensure we can make them do what we want for
building things outside of /usr/src. Nearly all the comments below
apply.
# $NetBSD: bsd.README,v 1.18 1997/01/13 00:54:23 mark Exp $
+24 -19
View File
@@ -1,9 +1,9 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# RCSid:
# $Id: cython.mk,v 1.9 2024/02/17 17:26:57 sjg Exp $
# $Id: cython.mk,v 1.10 2024/09/20 06:16:41 sjg Exp $
#
# @(#) Copyright (c) 2014, Simon J. Gerraty
# @(#) Copyright (c) 2014-2024, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -19,24 +19,29 @@
# pyprefix is where python bits are
# which may not be where we want to put ours (prefix)
.if exists(/usr/pkg/include)
pyprefix?= /usr/pkg
pyprefix ?= /usr/pkg
.endif
pyprefix?= /usr/local
pyprefix ?= /usr/local
PYTHON_VERSION?= 2.7
PYTHON_H?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h
PYVERSION:= ${PYTHON_VERSION:C,\..*,,}
PYTHON ?= python3
.if empty(PYTHON_VERSION)
PYTHON_VERSION != ${PYTHON} --version | sed 's,Python \([2-9]\.[0-9][0-9]*\).*,\1,'
.export PYTHON_VERSION
.endif
PYTHON_H ?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h
PYVERSION := ${PYTHON_VERSION:C,\..*,,}
CFLAGS+= -I${PYTHON_H:H}
# conf.host_target() is limited to uname -m rather than uname -p
_HOST_MACHINE!= uname -m
# so we cannot assume it will always match HOST_TARGET
_HOST_MACHINE != uname -m
.if ${HOST_TARGET:M*${_HOST_MACHINE}} == ""
PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},}
PY_HOST_TARGET := ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},}
.endif
COMPILE.c?= ${CC} -c ${CFLAGS}
PICO?= .pico
COMPILE.c ?= ${CC} -c ${CFLAGS}
PICO ?= .pico
.SUFFIXES: ${PICO} .c
@@ -47,25 +52,25 @@ PICO?= .pico
.if !empty(CYTHON_MODULE_NAME)
CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so
CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx
CYTHON_SRCS ?= ${CYTHON_MODULE_NAME}.pyx
# this is where we save generated src
CYTHON_SAVEGENDIR?= ${.CURDIR}/gen
CYTHON_SAVEGENDIR ?= ${.CURDIR}/gen
# set this empty if you don't want to handle multiple versions
.if !defined(CYTHON_PYVERSION)
CYTHON_PYVERSION:= ${PYVERSION}
CYTHON_PYVERSION := ${PYVERSION}
.endif
CYTHON_GENSRCS= ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,}
SRCS+= ${CYTHON_GENSRCS}
CYTHON_GENSRCS = ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,}
SRCS += ${CYTHON_GENSRCS}
.SUFFIXES: .pyx .c .So
CYTHON?= ${pyprefix}/bin/cython
CYTHON ?= ${pyprefix}/bin/cython
# if we don't have cython we can use pre-generated srcs
.if ${type ${CYTHON} 2> /dev/null || echo:L:sh:M/*} == ""
.if empty(CYTHON) || !exists(${CYTHON})
.PATH: ${CYTHON_SAVEGENDIR}
.else
@@ -98,6 +103,6 @@ install-cython-module: ${CYTHON_MODULE}
${INSTALL} -d ${DESTDIR}${MODULE_BINDIR}
${INSTALL} -m 755 ${.ALLSRC} ${DESTDIR}${MODULE_BINDIR}
CLEANFILES+= *${PICO} ${CYTHON_MODULE}
CLEANFILES += *${PICO} ${CYTHON_MODULE}
.endif
+4 -1
View File
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# RCSid:
# $Id: dirdeps-targets.mk,v 1.27 2024/02/25 19:12:13 sjg Exp $
# $Id: dirdeps-targets.mk,v 1.28 2024/10/19 00:47:38 sjg Exp $
#
# @(#) Copyright (c) 2019-2020 Simon J. Gerraty
#
@@ -160,6 +160,9 @@ MK_DIRDEPS_CACHE = yes
.endfor
.if defined(STATIC_DIRDEPS_CACHE)
.export STATIC_DIRDEPS_CACHE
.if !empty(DEBUG_DIRDEPS_TARGETS)
.info STATIC_DIRDEPS_CACHE=${STATIC_DIRDEPS_CACHE:S,${SRCTOP}/,,}
.endif
.endif
.endif
+9 -11
View File
@@ -1,4 +1,4 @@
# $Id: dirdeps.mk,v 1.170 2024/06/24 02:21:00 sjg Exp $
# $Id: dirdeps.mk,v 1.175 2025/01/05 01:16:19 sjg Exp $
# SPDX-License-Identifier: BSD-2-Clause
#
@@ -152,7 +152,7 @@
# any other DIRDEP.
#
# This allows for adding TESTS to the build, such that the build
# if any test fails, but without the risk of introducing
# will fail if any test fails, but without the risk of introducing
# circular dependencies.
now_utc ?= ${%s:L:localtime}
@@ -445,6 +445,7 @@ _DIRDEP_USE: .USE .MAKE
TARGET_SPEC=${.TARGET:E} \
MACHINE=${.TARGET:E} \
${DIRDEP_MAKE} -C ${DIRDEP_DIR} ${DIRDEP_TARGETS} || exit 1; \
${DIRDEP_USE_EPILOGUE} \
break; \
done
@@ -568,7 +569,7 @@ BUILD_DIRDEPS = no
dirdeps: dirdeps-cached
dirdeps-cached: ${DIRDEPS_CACHE} .MAKE
@echo "${TRACER}Using ${DIRDEPS_CACHE}"
@MAKELEVEL=${.MAKE.LEVEL} \
@${DIRDEPS_CACHED_ENV} MAKELEVEL=${.MAKE.LEVEL} \
TARGET_SPEC=${TARGET_SPEC} \
${TARGET_SPEC_VARS:@v@$v=${$v}@} \
${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \
@@ -606,10 +607,10 @@ ${DIRDEPS_CACHE}: .META .NOMETA_CMP
BUILD_DIRDEPS_CACHE=yes \
.MAKE.DEPENDFILE=.none \
${"${DEBUG_DIRDEPS:Nno}":?DEBUG_DIRDEPS='${DEBUG_DIRDEPS}':} \
${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \
${.MAKEFLAGS:tW:S,-d ,-d,g:tw:M-d*} \
${.MAKEFLAGS:S,-D ,-D,gW:M*WITH*} \
${.MAKEFLAGS:S,-d ,-d,gW:M-d*} \
3>&1 1>&2 | sed 's,${SRCTOP},_{SRCTOP},g;s,_{SRCTOP}/_{SRCTOP},_{SRCTOP},g;s,_{,$${,g' >> ${.TARGET}.new && \
mv ${.TARGET}.new ${.TARGET}
{ ${BUILD_DIRDEPS_EPILOGUE} mv ${.TARGET}.new ${.TARGET}; }
.endif
.endif
@@ -887,16 +888,13 @@ _m := ${.MAKE.DEPENDFILE_PREFERENCE:T:S;${TARGET_SPEC}$;${d:E};:C;${MACHINE}((,.
.if !empty(_m)
# M_dep_qual_fixes isn't geared to Makefile.depend
_qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes.${d:E}:U${M_dep_qual_fixes}:ts:}}
.if ${_debug_search}
.info Looking for ${_qm}
.endif
# set this "just in case"
# we can skip :tA since we computed the path above
DEP_RELDIR := ${_m:H:S,^${SRCTOP}/,,}
# and reset this
DIRDEPS =
.if ${_debug_reldir} && ${_qm} != ${_m}
.info loading ${_m:S,${SRCTOP}/,,} for ${_dr}
.if ${_debug_search} || ${_debug_reldir}
.info Loading ${_m:S,${SRCTOP}/,,} for ${_dr}
.endif
.include <${_m}>
.else
+2 -2
View File
@@ -1,4 +1,4 @@
# $Id: gendirdeps.mk,v 1.50 2023/11/04 16:47:34 sjg Exp $
# $Id: gendirdeps.mk,v 1.51 2025/01/05 01:16:19 sjg Exp $
# SPDX-License-Identifier: BSD-2-Clause
#
@@ -237,7 +237,7 @@ dir_list != cd ${_OBJDIR} && \
sed ${GENDIRDEPS_SEDCMDS}
.if ${dir_list:M*ERROR\:*} != ""
.warning ${dir_list:tW:C,.*(ERROR),\1,}
.warning ${dir_list:C,.*(ERROR),\1,W}
.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,}
# we are not going to update anything
.else
+26
View File
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: genfiles.mk,v 1.3 2024/09/21 21:14:19 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
#
# Pipe the sources though egrep -v if EXCLUDES.${.TARGET} is defined
# and/or sed if SED_CMDS.${.TARGET} is defined
# Note: this works best in meta mode as any change to EXCLUDES or
# SED_CMDS will make the target out-of-date.
_GENFILES_USE: .USE
@cat ${SRCS.${.TARGET}:U${.ALLSRC:u}} \
${EXCLUDES.${.TARGET}:D| ${EGREP:Uegrep} -v '${EXCLUDS.${.TARGET}:ts|}'} \
${SED_CMDS.${.TARGET}:D| ${SED:Used} ${SED_CMDS.${.TARGET}}} \
> ${.TARGET}
+9 -2
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: init.mk,v 1.38 2024/04/09 17:18:24 sjg Exp $
# $Id: init.mk,v 1.39 2024/12/12 19:56:36 sjg Exp $
#
# @(#) Copyright (c) 2002-2024, Simon J. Gerraty
#
@@ -41,7 +41,14 @@ 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:}
OBJS_SRCS_PRE_FILTER += ${NO_OBJS_SRCS_SUFFIXES:@x@N*$x@}
# makefiles that actually *want* .o's in subdirs
# (it can be useful if multiple SRCS have same basename)
# can just set OBJS_SRCS_FILTER =
# we apply this as ${OBJS_SRCS_FILTER:ts:}
OBJS_SRCS_FILTER ?= T
OBJS_SRCS_FILTER += ${OBJS_SRCS_PRE_FILTER}
OBJS_SRCS_FILTER += R
.if defined(PROG_CXX) || ${SRCS:Uno:${CXX_SUFFIXES:S,^,N*,:ts:}} != ${SRCS:Uno:N/}
_CCLINK ?= ${CXX}
Executable → Regular
+2 -2
View File
@@ -59,7 +59,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
# $Id: install-mk,v 1.255 2024/06/24 02:21:00 sjg Exp $
# $Id: install-mk,v 1.262 2025/01/05 01:16:19 sjg Exp $
#
# @(#) Copyright (c) 1994-2024 Simon J. Gerraty
#
@@ -74,7 +74,7 @@
# sjg@crufty.net
#
MK_VERSION=20240616
MK_VERSION=20250101
OWNER=
GROUP=
MODE=444
+8 -6
View File
@@ -1,4 +1,4 @@
# $Id: lib.mk,v 1.84 2024/02/19 00:06:19 sjg Exp $
# $Id: lib.mk,v 1.85 2024/12/12 19:56:36 sjg Exp $
# should be set properly in sys.mk
_this ?= ${.PARSEFILE:S,bsd.,,}
@@ -395,13 +395,15 @@ realbuild: ${_LIBS}
all: _SUBDIRUSE
OBJS_SRCS = ${SRCS:${OBJS_SRCS_FILTER}}
.for s in ${OBJS_SRCS:M*/*}
${.o ${PICO} .po .lo:L:@o@${s:T:R}$o@}: $s
.for s in ${SRCS:${OBJS_SRCS_PRE_FILTER:ts:}:M*/*}
${.o .po .lo:L:@o@${s:${OBJS_SRCS_FILTER:ts:}}$o@}: $s
.endfor
OBJS+= ${OBJS_SRCS:T:R:S/$/.o/g}
OBJS_SRCS = ${SRCS:${OBJS_SRCS_FILTER:ts:}}
.if !empty(OBJS_SRCS)
OBJS+= ${OBJS_SRCS:S/$/.o/g}
.endif
.NOPATH: ${OBJS}
.if ${MK_LIBTOOL} == "yes"
+17 -17
View File
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: links.mk,v 1.8 2024/02/17 17:26:57 sjg Exp $
# $Id: links.mk,v 1.10 2024/08/23 21:24:27 sjg Exp $
#
# @(#) Copyright (c) 2005, Simon J. Gerraty
# @(#) Copyright (c) 2005-2024, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -16,37 +16,37 @@
#
# some platforms need something special
LN?= ln
ECHO?= echo
LN ?= ln
ECHO ?= echo
LINKS?=
SYMLINKS?=
LINKS ?=
SYMLINKS ?=
__SYMLINK_SCRIPT= \
${ECHO} "$$t -> $$l"; \
__SYMLINK_SCRIPT = \
case `'ls' -l $$t 2> /dev/null` in \
*"> $$l") ;; \
*) \
${ECHO} "$$t -> $$l"; \
mkdir -p `dirname $$t`; \
rm -f $$t; \
${LN} -s $$l $$t;; \
esac
__LINK_SCRIPT= \
__LINK_SCRIPT = \
${ECHO} "$$t -> $$l"; \
mkdir -p `dirname $$t`; \
rm -f $$t; \
${LN} $$l $$t
_SYMLINKS_SCRIPT= \
_SYMLINKS_SCRIPT = \
while test $$\# -ge 2; do \
l=$$1; shift; \
t=${DESTDIR}$$1; shift; \
${__SYMLINK_SCRIPT}; \
done; :;
_LINKS_SCRIPT= \
_LINKS_SCRIPT = \
while test $$\# -ge 2; do \
l=${DESTDIR}$$1; shift; \
t=${DESTDIR}$$1; shift; \
@@ -54,21 +54,21 @@ _LINKS_SCRIPT= \
done; :;
_SYMLINKS_USE: .USE
@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_SYMLINKS_SCRIPT}
@set ${$@_SYMLINKS:U${SYMLINKS}:${SYMLINKS_FILTER:U:ts:}}; ${_SYMLINKS_SCRIPT}
_LINKS_USE: .USE
@set ${$@_LINKS:U${LINKS}}; ${_LINKS_SCRIPT}
@set ${$@_LINKS:U${LINKS}:${LINKS_FILTER:U:ts:}}; ${_LINKS_SCRIPT}
# sometimes we want to ensure DESTDIR is ignored
_BUILD_SYMLINKS_SCRIPT= \
_BUILD_SYMLINKS_SCRIPT = \
while test $$\# -ge 2; do \
l=$$1; shift; \
t=$$1; shift; \
${__SYMLINK_SCRIPT}; \
done; :;
_BUILD_LINKS_SCRIPT= \
_BUILD_LINKS_SCRIPT = \
while test $$\# -ge 2; do \
l=$$1; shift; \
t=$$1; shift; \
@@ -76,7 +76,7 @@ _BUILD_LINKS_SCRIPT= \
done; :;
_BUILD_SYMLINKS_USE: .USE
@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_BUILD_SYMLINKS_SCRIPT}
@set ${$@_SYMLINKS:U${SYMLINKS}:${BUILD_SYMLINKS_FILTER:U:ts:}}; ${_BUILD_SYMLINKS_SCRIPT}
_BUILD_LINKS_USE: .USE
@set ${$@_LINKS:U${LINKS}}; ${_BUILD_LINKS_SCRIPT}
@set ${$@_LINKS:U${LINKS}:${BUILD_LINKS_FILTER:U:ts:}}; ${_BUILD_LINKS_SCRIPT}
+12 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: meta.sys.mk,v 1.54 2024/03/10 15:53:51 sjg Exp $
# $Id: meta.sys.mk,v 1.56 2024/11/22 23:51:48 sjg Exp $
#
# @(#) Copyright (c) 2010-2023, Simon J. Gerraty
@@ -40,6 +40,11 @@ META_MODE += nofilemon
MKDEP_MK ?= auto.dep.mk
.endif
# META_MODE_XTRAS makes it easier to add things like 'env'
# from the command line when debugging
# :U avoids problems from := below
META_MODE += ${META_MODE_XTRAS:U}
.MAKE.MODE ?= ${META_MODE}
_filemon := ${.MAKE.PATH_FILEMON:U/dev/filemon}
@@ -101,6 +106,12 @@ SB = ${SRCTOP:H}
ERROR_LOGDIR ?= ${SB}/error
meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log
.if ${.MAKE.LEVEL} == 0 && !empty(NEWLOG_SH) && exists(${ERROR_LOGDIR})
.BEGIN: _rotateErrorLog
_rotateErrorLog: .NOMETA .NOTMAIN
@${NEWLOG_SH} -d -S -n ${ERROR_LOG_GENS:U4} ${ERROR_LOGDIR}
.endif
.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
+12 -4
View File
@@ -39,7 +39,7 @@
SPDX-License-Identifier: BSD-2-Clause
RCSid:
$Id: meta2deps.py,v 1.47 2024/02/17 17:26:57 sjg Exp $
$Id: meta2deps.py,v 1.50 2024/09/27 00:08:36 sjg Exp $
Copyright (c) 2011-2020, Simon J. Gerraty
Copyright (c) 2011-2017, Juniper Networks, Inc.
@@ -294,6 +294,7 @@ def __init__(self, name, conf={}):
if not _objroot in self.objroots:
self.objroots.append(_objroot)
self.sb = conf.get('SB', '')
# we want the longest match
self.srctops.sort(reverse=True)
self.objroots.sort(reverse=True)
@@ -461,6 +462,10 @@ def parse(self, name=None, file=None):
if self.curdir:
self.seenit(self.curdir) # we ignore this
if self.sb and self.name.startswith(self.sb):
error_name = self.name.replace(self.sb+'/','')
else:
error_name = self.name
interesting = '#CEFLRVX'
for line in f:
self.line += 1
@@ -550,9 +555,9 @@ def parse(self, name=None, file=None):
self.parse_path(path, cwd, w[0], w)
if version == 0:
raise AssertionError('missing filemon data')
raise AssertionError('missing filemon data: {}'.format(error_name))
if not eof_token:
raise AssertionError('truncated filemon data')
raise AssertionError('truncated filemon data: {}'.format(error_name))
setid_pids = []
# self.pids should be empty!
@@ -570,7 +575,8 @@ def parse(self, name=None, file=None):
print("ERROR: missing eXit for {} pid {}".format(path, pid))
for pid in setid_pids:
del self.pids[pid]
assert(len(self.pids) == 0)
if len(self.pids) > 0:
raise AssertionError('bad filemon data - missing eXits: {}'.format(error_name))
if not file:
f.close()
@@ -714,6 +720,8 @@ def main(argv, klass=MetaFile, xopts='', xoptf=None):
'EXCLUDES': [],
}
conf['SB'] = os.getenv('SB', '')
try:
machine = os.environ['MACHINE']
if machine:
+7 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: options.mk,v 1.20 2024/02/17 17:26:57 sjg Exp $
# $Id: options.mk,v 1.22 2024/10/27 17:33:03 sjg Exp $
#
# @(#) Copyright (c) 2012, Simon J. Gerraty
#
@@ -62,6 +62,9 @@ ${OPTION_PREFIX}${o:H} ?= no
${OPTION_PREFIX}${o:H} ?= yes
.endif
.endif
.if defined(DEBUG_OPTIONS) && ${DEBUG_OPTIONS:@x@${o:H:M$x}@} != ""
.info ${.INCLUDEDFROMFILE}: ${OPTION_PREFIX}${o:H}=${${OPTION_PREFIX}${o:H}}
.endif
.endfor
# OPTIONS_DEFAULT_DEPENDENT += FOO_UTILS/FOO
@@ -82,6 +85,9 @@ ${OPTION_PREFIX}${o:H} ?= no
.else
${OPTION_PREFIX}${o:H} ?= ${${OPTION_PREFIX}${o:T}}
.endif
.if defined(DEBUG_OPTIONS) && ${DEBUG_OPTIONS:@x@${o:H:M$x}@} != ""
.info ${.INCLUDEDFROMFILE}: ${OPTION_PREFIX}${o:H}=${${OPTION_PREFIX}${o:H}} (${OPTION_PREFIX}${o:T}=${${OPTION_PREFIX}${o:T}})
.endif
.endfor
# allow displaying/describing set options
+5 -2
View File
@@ -1,4 +1,4 @@
# $Id: own.mk,v 1.48 2024/04/09 21:52:52 sjg Exp $
# $Id: own.mk,v 1.51 2024/11/12 17:40:13 sjg Exp $
# should be set properly in sys.mk
_this ?= ${.PARSEFILE:S,bsd.,,}
@@ -71,6 +71,7 @@ OPTIONS_DEFAULT_NO+= DPADD_MK
# process options
OPTIONS_DEFAULT_NO+= \
DEBUG \
INSTALL_AS_USER \
GPROF \
PROG_LDORDER_MK \
@@ -96,6 +97,7 @@ OPTIONS_DEFAULT_YES+= \
OPTIONS_DEFAULT_DEPENDENT+= \
CATPAGES/MAN \
DEBUG_RUST/DEBUG \
LDORDER_MK/PROG_LDORDER_MK \
OBJDIRS/OBJ \
PICINSTALL/LINKLIB \
@@ -103,6 +105,7 @@ OPTIONS_DEFAULT_DEPENDENT+= \
PROFILE/LINKLIB \
STAGING_MAN/STAGING \
STAGING_PROG/STAGING \
STAGING_RUST/STAGING_PROG \
.include <options.mk>
@@ -248,7 +251,7 @@ TARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS}
.endif
.if ${MK_STAGING} == "yes"
STAGE_ROOT?= ${OBJROOT}/stage
STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/}
STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:@v@${$v}@:ts/}
.endif
.endif
+7 -5
View File
@@ -1,4 +1,4 @@
# $Id: prog.mk,v 1.44 2024/02/19 00:06:19 sjg Exp $
# $Id: prog.mk,v 1.45 2024/12/12 19:56:36 sjg Exp $
# should be set properly in sys.mk
_this ?= ${.PARSEFILE:S,bsd.,,}
@@ -98,12 +98,14 @@ 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
.for s in ${SRCS:${OBJS_SRCS_PRE_FILTER:ts:}:M*/*}
${.o .po .lo:L:@o@${s:${OBJS_SRCS_FILTER:ts:}}$o@}: $s
.endfor
OBJS_SRCS = ${SRCS:${OBJS_SRCS_FILTER:ts:}}
.if !empty(OBJS_SRCS)
OBJS+= ${OBJS_SRCS:T:R:S/$/.o/g}
OBJS+= ${OBJS_SRCS:S/$/.o/g}
LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln}
.endif
+203
View File
@@ -0,0 +1,203 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# RCSid:
# $Id: rust.mk,v 1.37 2025/01/11 03:17:36 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
#
##
# This makefile is used when a build includes one or more Rust projects.
#
# We first include local.rust.mk to allow for customization.
# You can get very fancy - the logic/functionality here is minimal but
# can be extended via local.rust.mk
#
# If RUST_PROJECT_DIR (where we find Cargo.toml) is not set, we will
# make it ${.CURDIR:C,/src.*,,} actually we use
# ${SRCTOP}/${RELDIR:C,/src.*,,} to ensure we don't confuse ${SRCTOP}
# with ${RUST_PROJECT_DIR}/src.
#
# If ${.OBJDIR} is not ${.CURDIR} we will default CARGO_TARGET_DIR
# to ${.OBJDIR}.
#
# First, if ${.CURDIR} is a subdir of ${RUST_PROJECT_DIR} (will happen
# if an Emacs user does 'M-x compile' while visiting a src file) we
# will need to adjust ${.OBJDIR} (and hence CARGO_TARGET_DIR).
#
# We assume that RUST_CARGO will be used to build Rust projects,
# so we default RUST_CARGO_PROJECT_DIR to ${RUST_PROJECT_DIR} and
# provide a _CARGO_USE that we automatically associate with
# targets named 'cargo.*' the default is 'cargo.build'.
#
# _CARGO_USE will chdir to ${RUST_CARGO_PROJECT_DIR} and run
# ${RUST_CARGO} with ENV, FLAGS and ARGS variables derived from
# ${.TARGET:E:tu} so in the case of 'cargo.build' we get:
# RUST_CARGO_BUILD_ENV, RUST_CARGO_BUILD_FLAGS and RUST_CARGO_BUILD_ARGS
#
# _CARGO_USE will "just work" for additional targets like
# 'cargo.test', 'cargo.clippy', ... which will run '${RUST_CARGO} test',
# '${RUST_CARGO} clippy' etc.
#
# If MK_META_MODE is "yes" 'cargo.build' will touch ${.TARGET}
# so the default make rules will not consider it always out-of-date.
# In META MODE, 'bmake' will know if anything changed that should
# cause the target to be re-built.
#
# If MK_STAGING_RUST is "yes" we will stage the binary we
# built to a suitable location under ${STAGE_OBJTOP}.
#
all:
.MAIN: all
# allow for customization
.-include <local.rust.mk>
RUST_CARGO ?= cargo
RUSTC ?= rustc
.if ${.CURDIR} == ${SRCTOP}
RELDIR ?= .
.else
RELDIR ?= ${.CURDIR:S,${SRCTOP}/,,}
.endif
.if empty(RUST_PROJECT_DIR)
# we want this set correctly from anywhere within
# using RELDIR avoids confusing ${SRCTOP} with ${RUST_PROJECT_DIR}/src
RUST_PROJECT_DIR := ${SRCTOP}/${RELDIR:C,/src.*,,}
.if ${RUST_PROJECT_DIR:T:Nsrc:N.} == ""
RUST_PROJECT_DIR := ${RUST_PROJECT_DIR:H}
.endif
.endif
.if ${.OBJDIR} != ${.CURDIR}
.if ${.CURDIR:M${RUST_PROJECT_DIR}/*} != ""
# Our .CURDIR is below RUST_PROJECT_DIR and thus our
# .OBJDIR is likely not what we want either.
# This can easily happen if in Emacs we do 'M-x compile' while
# visiting a src file.
# It is easily fixed.
__objdir := ${.OBJDIR:S,${.CURDIR:S,${RUST_PROJECT_DIR},,},,}
.OBJDIR: ${__objdir}
.endif
# tell cargo where to drop build artifacts
CARGO_TARGET_DIR ?= ${.OBJDIR}
.if !empty(OBJROOT) && exists(${OBJROOT})
CARGO_HOME_RELDIR ?= rust/cargo_home
CARGO_HOME ?= ${OBJROOT}/common/${RUST_CARGO_HOME_RELDIR}
.endif
.elif ${.CURDIR} != ${RUST_PROJECT_DIR}
.OBJDIR: ${RUST_PROJECT_DIR}
.endif
CARGO_TARGET_DIR ?= target
.if ${MK_DIRDEPS_BUILD:Uno} == "no" || ${.MAKE.LEVEL} > 0
.export CARGO_HOME CARGO_TARGET_DIR RUST_PROJECT_DIR RUSTC
all: cargo.build
.if empty(RUST_PROJECT_FILES)
RUST_PROJECT_FILES != find ${RUST_PROJECT_DIR} -type f \( \
-name '*.rs' -o \
-name Cargo.lock -o \
-name Cargo.toml \) | sort
.endif
RUST_CARGO_BUILD_DEPS += ${RUST_PROJECT_FILES:U}
.endif
RUST_CARGO_PROJECT_DIR ?= ${RUST_PROJECT_DIR}
.if ${RUSTC:M/*}
# make sure we find all the other toolchain bits in the same place
RUST_CARGO_ENV += PATH=${RUSTC:H}:${PATH}
# cargo clippy needs extra help finding the sysroot
# https://github.com/rust-lang/rust-clippy/issues/3523
RUST_CARGO_CLIPPY_ENV += RUSTC_SYSROOT=${${RUSTC} --print sysroot:L:sh}
.endif
.if ${LDFLAGS:U:M-[BL]*} != ""
# we may need to tell rustc where to find the native libs needed
# rustc documents a space after -L so put it back
RUST_LDFLAGS := ${LDFLAGS:C/(-[BL]) /\1/gW:M-[BL]*:S/-L/& /:S/-B/-C link-arg=&/}
.endif
.if !empty(RUST_LDFLAGS)
RUSTFLAGS += ${RUST_LDFLAGS}
.endif
.if !empty(RUSTFLAGS)
RUST_CARGO_BUILD_ENV += RUSTFLAGS="${RUSTFLAGS}"
.endif
_CARGO_USE: .USEBEFORE
@(cd ${RUST_CARGO_PROJECT_DIR} && ${RUST_CARGO_ENV} \
${RUST_CARGO_${.TARGET:E:tu}_ENV} \
${RUST_CARGO} ${RUST_CARGO_${.TARGET:E:tu}_FLAGS:U${RUST_CARGO_FLAGS}} \
${.TARGET:E} ${RUST_CARGO_${.TARGET:E:tu}_ARGS})
RUST_CARGO_TARGETS += cargo.build
cargo.build: ${RUST_CARGO_BUILD_DEPS}
.if ${.OBJDIR} != ${RUST_PROJECT_DIR}
test ! -s Cargo.lock || cp -p Cargo.lock ${RUST_CARGO_PROJECT_DIR}
.endif
@${META_COOKIE_TOUCH}
# handle cargo.{run,test,...}
RUST_CARGO_TARGETS += ${.TARGETS:Mcargo.*}
${RUST_CARGO_TARGETS:O:u}: _CARGO_USE
.if ${MK_DEBUG_RUST:Uno} == "no" && \
${DEBUG_RUST_DIRS:Unone:@x@${RELDIR:M$x}@} == ""
RUST_CARGO_BUILD_ARGS += --release
.endif
.if ${RUST_CARGO_BUILD_ARGS:U:M--release} != ""
RUST_CARGO_TARGET = release
.else
RUST_CARGO_TARGET = debug
.endif
# do we want cargo.build to depend on cargo.fmt --check ?
# if user did make cargo.fmt the target would exist by now
.if ${MK_RUST_CARGO_FMT_CHECK:Uno} == "yes" && !target(cargo.fmt)
RUST_CARGO_FMT_CHECK_ARGS ?= --check
RUST_CARGO_FMT_ARGS += ${RUST_CARGO_FMT_CHECK_ARGS}
cargo.fmt: _CARGO_USE
cargo.build: cargo.fmt
.endif
# useful? defaults
RUST_CARGO_CLIPPY_ARGS ?= -- -D warnings --no-deps
# do we want cargo.clippy to be run after cargo.build?
.if ${MK_RUST_CARGO_CLIPPY:Uno} == "yes" && !target(cargo.clippy)
cargo.clippy: _CARGO_USE
cargo.clippy: cargo.build
all: cargo.clippy
.endif
.if !defined(RUST_LIBS)
RUST_PROGS ?= ${RUST_PROJECT_DIR:T}
.endif
.if !empty(RUST_PROGS)
BINDIR ?= ${prefix}/bin
# there could be a target triple involved
RUST_CARGO_TARGET_DIR ?= ${CARGO_TARGET_DIR}
RUST_CARGO_OUTPUT_DIR ?= ${RUST_CARGO_TARGET_DIR}/${RUST_CARGO_TARGET}
RUST_CARGO_BUILD_OUTPUT_LIST := ${RUST_PROGS:S,^,${RUST_CARGO_OUTPUT_DIR}/,}
${RUST_CARGO_BUILD_OUTPUT_LIST}: cargo.build
.endif
# for late customizations
.-include <local.rust.build.mk>
+175
View File
@@ -0,0 +1,175 @@
:
# NAME:
# setopts.sh - set opt_* for shell scripts
#
# SYNOPSIS:
# opt_str=s:a.b^cl,z=
# opt_a=default
#
# . setopts.sh
#
# DESCRIPTION:
# This module sets shell variables for each option specified in
# "opt_str".
#
# If the option is followed by a ``:'' it requires an argument.
# It defaults to an empty string and specifying that option on
# the command line overrides the current value.
#
# If the option is followed by a ``.'' then it is treated as for
# ``:'' except that any argument provided on the command line is
# appended to the current value using the value of "opt_dot" as
# separator (default is a space).
#
# If the option is followed by a ``,'' then it is treated as for
# a ``.'' except that the separator is "opt_comma" (default ,).
#
# If the option is followed by ``='' it requires an argument
# of the form "var=val" which will be evaluated.
#
# If the option is followed by a ``^'' then it is treated as a
# boolean and defaults to 0.
#
# Options that have no qualifier are set to the flag if present
# otherwise they are unset. That is if '-c' is given then
# "opt_c" will be set to '-c'.
#
# If "opt_assign_eval" is set (and to something other than
# 'no'), args of the form "var=val" will be evaluated.
#
# NOTES:
# The implementation uses the getopts builtin if available.
#
# Also it does not work when loaded via a function call as "$@"
# will be the args to that function. In such cases set
# _SETOPTS_DELAY and call 'setopts "$@"; shift $__shift'
# afterwards.
#
# AUTHOR:
# Simon J. Gerraty <sjg@crufty.net>
#
# RCSid:
# $Id: setopts.sh,v 1.13 2023/02/20 19:30:06 sjg Exp $
#
# @(#) Copyright (c) 1995-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
#
# the case checks just skip the sed(1) commands unless needed
case "$opt_str" in
*\^*) # the only ones we need to set are the booleans x,
eval `echo $opt_str | sed -e 's/[^^]*$//' -e 's/[^^]*\([^^]^\)/\1/g' -e 's/\(.\)^/opt_\1=${opt_\1-0}; /g'`
;;
esac
case "$opt_str" in
*[=,.\^]*)
_opt_str=`echo $opt_str | sed -e 's/[=,.]/:/g' -e 's/\^//g'`;;
*) _opt_str=$opt_str;;
esac
opt_append=${opt_append:-" "}
opt_dot=${opt_dot:-$opt_append}
opt_comma=${opt_comma:-,}
set1opt() {
o=$1
a="$2"
case "$opt_str" in
*${o}:*) eval "opt_$o=\"$a\"";;
*${o}.*) eval "opt_$o=\"\${opt_$o}\${opt_$o:+$opt_dot}$a\"";;
*${o},*) eval "opt_$o=\"\${opt_$o}\${opt_$o:+$opt_comma}$a\"";;
*${o}=*)
case "$a" in
*=*) eval "$a";;
*) Myname=${Myname:-`basename $0 .sh`}
echo "$Myname: -$o requires argument of form var=val" >&2
exit 1
;;
esac
;;
*${o}\^*) eval opt_$o=1;;
*) eval opt_$o=-$o;;
esac
}
setopts() {
__shift=$#
# use getopts builtin if we can
case `type getopts 2>&1` in
*builtin*)
: OPTIND=$OPTIND @="$@"
while getopts $_opt_str o
do
case "$o" in
\?) exit 1;;
esac
set1opt $o "$OPTARG"
done
shift $(($OPTIND - 1))
while :
do
case "$1" in
*=*)
case "$opt_assign_eval" in
""|no) break;;
*) eval "$1"; shift;;
esac
;;
*) break;;
esac
done
;;
*) # likely not a POSIX shell either
# getopt(1) isn't as good
set -- `getopt $_opt_str "$@" 2>&1`
case "$1" in
getopt:)
Myname=${Myname:-`basename $0 .sh`}
echo "$*" | tr ':' '\012' | sed -e '/^getopt/d' -e 's/ getopt$//' -e "s/^/$Myname:/" -e 's/ --/:/' -e 's/-.*//' 2>&2
exit 1
;;
esac
while :
do
: 1="$1"
case "$1" in
--) shift; break;;
-*)
# Most shells give you ' ' in IFS whether you
# want it or not, but at least one, doesn't.
# So the following gives us consistency.
o=`IFS=" -"; set -- $1; echo $*` # lose the '-'
set1opt $o "$2"
case "$_opt_str" in
*${o}:*) shift;;
esac
;;
*=*) case "$opt_assign_eval" in
""|no) break;;
*) eval "$1";;
esac
;;
*) break;;
esac
shift
done
;;
esac
# let caller know how many args we consumed
__shift=`expr $__shift - $#`
}
${_SETOPTS_DELAY:+:} setopts "$@"
${_SETOPTS_DELAY:+:} shift $__shift
+6 -4
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: subdir.mk,v 1.24 2024/04/10 01:47:23 sjg Exp $
# $Id: subdir.mk,v 1.27 2024/09/01 05:02:43 sjg Exp $
#
# @(#) Copyright (c) 2002-2024, Simon J. Gerraty
#
@@ -29,7 +29,7 @@ _this ?= ${.PARSEFILE:S,bsd.,,}
.if !target(__${_this}__)
__${_this}__: .NOTMAIN
.if defined(SUBDIR)
.if defined(SUBDIR) || defined(SUBDIR.yes)
.if ${.MAKE.LEVEL} == 0 && ${MK_DIRDEPS_BUILD:Uno} == "yes"
.include <meta.subdir.mk>
@@ -52,7 +52,7 @@ MISSING_DIR=echo "Skipping ===> ${.CURDIR}/$$_dir"; exit 0
# our target should be of the form ${_target}-${_dir}
_SUBDIR_USE: .USE
@Exists() { test -f $$1; }; \
_dir=${.TARGET:C/^.*-//} \
_dir=${.TARGET:C/^[^-]*-//} \
_target=${.TARGET:C/-.*//:S/real//:S/.depend/depend/}; \
if ! Exists ${.CURDIR}/$$_dir/[mM]akefile; then \
${MISSING_DIR}; \
@@ -95,9 +95,11 @@ SUBDIR_TARGETS += \
tags \
etags
.if ${SUBDIR} == "@auto"
.if ${SUBDIR:U} == "@auto"
SUBDIR = ${echo ${.CURDIR}/*/[Mm]akefile:L:sh:H:T:O:N\*}
.endif
# allow for things like SUBDIR.${MK_TESTS}
SUBDIR += ${SUBDIR.yes:U}
__subdirs =
.for d in ${SUBDIR}
+2 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: sys.mk,v 1.60 2024/02/17 17:26:57 sjg Exp $
# $Id: sys.mk,v 1.61 2024/10/30 23:46:26 sjg Exp $
#
# @(#) Copyright (c) 2003-2023, Simon J. Gerraty
#
@@ -97,6 +97,7 @@ OPTIONS_DEFAULT_NO += \
OPTIONS_DEFAULT_DEPENDENT += \
AUTO_OBJ/DIRDEPS_BUILD \
META_ERROR_TARGET/DIRDEPS_BUILD \
META_MODE/DIRDEPS_BUILD \
STAGING/DIRDEPS_BUILD \
STATIC_DIRDEPS_CACHE/DIRDEPS_CACHE \
+6 -1
View File
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
# $Id: sys.vars.mk,v 1.16 2024/02/17 17:26:57 sjg Exp $
# $Id: sys.vars.mk,v 1.17 2024/09/28 04:06:47 sjg Exp $
#
# @(#) Copyright (c) 2003-2023, Simon J. Gerraty
#
@@ -140,3 +140,8 @@ M_mtime = tW:S,^,${STAT:Ustat} -f %m ,:sh
M_mtime = mtime${M_mtime_fallback:U}
.endif
# This line noise allows doing .tab and .bel below
# don't expect sane results if input is more than a single word
M_CharLiteral = L:@c@$${x x:L:$${:Uts$$c}:S/x//Wg}@
.tab := ${\t:${M_CharLiteral}}
.bel := ${\007:${M_CharLiteral}}
Executable → Regular
+5 -3
View File
@@ -17,7 +17,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
# $Id: os.sh,v 1.64 2024/03/19 16:03:23 sjg Exp $
# $Id: os.sh,v 1.66 2024/09/25 18:16:09 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -223,10 +223,11 @@ MACHINE_ARCH=${MACHINE_ARCH:-$MACHINE}
HOST_ARCH=${HOST_ARCH:-$MACHINE_ARCH}
case "$HOST_ARCH" in
x86*64|amd64) MACHINE32_ARCH=i386;;
*64) MACHINE32_ARCH=`echo $MACHINE_ARCH | sed 's,64,32,'`;;
*64) MACHINE32_ARCH=${MACHINE32_ARCH:-`echo $MACHINE_ARCH | sed 's,64,32,'`};;
*) MACHINE32_ARCH=$MACHINE_ARCH;;
esac
HOST_ARCH32=${HOST_ARCH32:-$MACHINE32_ARCH}
export HOST_ARCH HOST_ARCH32
# we mount server:/share/arch/$SHARE_ARCH as /usr/local
SHARE_ARCH_DEFAULT=$OS/$OSMAJOR.X/$HOST_ARCH
SHARE_ARCH=${SHARE_ARCH:-$SHARE_ARCH_DEFAULT}
@@ -238,10 +239,12 @@ HOST_TARGET=`echo ${OS}${OSMAJOR}-$HOST_ARCH | tr -d / | toLower`
HOST_TARGET32=`echo ${OS}${OSMAJOR}-$HOST_ARCH32 | tr -d / | toLower`
export HOST_TARGET HOST_TARGET32
case `echo -e .` in -e*) echo_e=;; *) echo_e=-e;; esac
case `echo -n .` in -n*) echo_n=; echo_c="\c";; *) echo_n=-n; echo_c=;; esac
Echo() {
case "$1" in
-e) shift; echo $echo_e "$@";;
-n) shift; echo $echo_n "$@$echo_c";;
*) echo "$@";;
esac
@@ -269,4 +272,3 @@ case /$0 in
*/host_target32) echo $HOST_TARGET32;;
*/host_target) echo $HOST_TARGET;;
esac
+8 -41
View File
@@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.734 2024/07/09 19:43:01 rillig Exp $ */
/* $NetBSD: parse.c,v 1.738 2025/01/14 21:34:09 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -110,7 +110,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: parse.c,v 1.734 2024/07/09 19:43:01 rillig Exp $");
MAKE_RCSID("$NetBSD: parse.c,v 1.738 2025/01/14 21:34:09 rillig Exp $");
/* Detects a multiple-inclusion guard in a makefile. */
typedef enum {
@@ -400,6 +400,8 @@ PrintStackTrace(bool includingInnermost)
const IncludedFile *entries;
size_t i, n;
EvalStack_PrintDetails();
n = includes.len;
if (n == 0)
return;
@@ -530,7 +532,6 @@ ParseVErrorInternal(FILE *f, bool useVars, const GNode *gn,
PrintLocation(f, useVars, gn);
if (level == PARSE_WARNING)
(void)fprintf(f, "warning: ");
fprintf(f, "%s", EvalStack_Details());
(void)vfprintf(f, fmt, ap);
(void)fprintf(f, "\n");
(void)fflush(f);
@@ -1845,7 +1846,7 @@ VarAssign_EvalShell(const char *name, const char *uvalue, GNode *scope,
char *output, *error;
cmd = FStr_InitRefer(uvalue);
Var_Expand(&cmd, SCOPE_CMDLINE, VARE_EVAL_DEFINED);
Var_Expand(&cmd, SCOPE_CMDLINE, VARE_EVAL);
output = Cmd_Exec(cmd.str, &error);
Var_SetExpand(scope, name, output);
@@ -2621,7 +2622,8 @@ ReadHighLevelLine(void)
if (line == NULL)
return NULL;
DEBUG2(PARSE, "Parsing line %u: %s\n", curFile->lineno, line);
DEBUG3(PARSE, "Parsing %s:%u: %s\n",
curFile->name.str, curFile->lineno, line);
if (curFile->guardState != GS_NO
&& ((curFile->guardState == GS_START && line[0] != '.')
|| curFile->guardState == GS_DONE))
@@ -2842,7 +2844,6 @@ FindSemicolon(char *p)
static void
ParseDependencyLine(char *line)
{
VarEvalMode emode;
char *expanded_line;
const char *shellcmd = NULL;
@@ -2855,41 +2856,7 @@ ParseDependencyLine(char *line)
}
}
/*
* We now know it's a dependency line, so it needs to have all
* variables expanded before being parsed.
*
* XXX: Ideally the dependency line would first be split into
* its left-hand side, dependency operator and right-hand side,
* and then each side would be expanded on its own. This would
* allow for the left-hand side to allow only defined variables
* and to allow variables on the right-hand side to be undefined
* as well.
*
* Parsing the line first would also prevent that targets
* generated from expressions are interpreted as the
* dependency operator, such as in "target${:U\:} middle: source",
* in which the middle is interpreted as a source, not a target.
*/
/*
* In lint mode, allow undefined variables to appear in dependency
* lines.
*
* Ideally, only the right-hand side would allow undefined variables
* since it is common to have optional dependencies. Having undefined
* variables on the left-hand side is more unusual though. Since
* both sides are expanded in a single pass, there is not much choice
* what to do here.
*
* In normal mode, it does not matter whether undefined variables are
* allowed or not since as of 2020-09-14, Var_Parse does not print
* any parse errors in such a case. It simply returns the special
* empty string var_Error, which cannot be detected in the result of
* Var_Subst.
*/
emode = opts.strict ? VARE_EVAL : VARE_EVAL_DEFINED;
expanded_line = Var_Subst(line, SCOPE_CMDLINE, emode);
expanded_line = Var_Subst(line, SCOPE_CMDLINE, VARE_EVAL);
/* TODO: handle errors */
/* Need a fresh list for the target nodes */
+3 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.382 2024/07/07 07:50:57 rillig Exp $ */
/* $NetBSD: suff.c,v 1.383 2025/01/14 21:39:24 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.382 2024/07/07 07:50:57 rillig Exp $");
MAKE_RCSID("$NetBSD: suff.c,v 1.383 2025/01/14 21:39:24 rillig Exp $");
typedef List SuffixList;
typedef ListNode SuffixListNode;
@@ -1343,7 +1343,7 @@ ExpandChildren(GNodeListNode *cln, GNode *pgn)
}
DEBUG1(SUFF, "Expanding \"%s\"...", cgn->name);
expanded = Var_Subst(cgn->name, pgn, VARE_EVAL_DEFINED);
expanded = Var_Subst(cgn->name, pgn, VARE_EVAL);
/* TODO: handle errors */
{
+15 -8
View File
@@ -1,6 +1,6 @@
# $Id: Makefile,v 1.224 2024/07/13 05:27:35 sjg Exp $
# $Id: Makefile,v 1.230 2025/01/30 18:04:20 sjg Exp $
#
# $NetBSD: Makefile,v 1.350 2024/07/07 09:37:00 rillig Exp $
# $NetBSD: Makefile,v 1.355 2025/01/25 22:46:30 sjg Exp $
#
# Unit tests for make(1)
#
@@ -46,6 +46,11 @@ TMPDIR:= /tmp/uid${.MAKE.UID}
.if !exist(${TMPDIR})
_!= mkdir -p ${TMPDIR}
.endif
# and clean it up - outside the context of
# any target that might be using it.
.END: rm-tmpdir
rm-tmpdir: .NOMETA
@rm -rf ${TMPDIR}
# Each test is in a sub-makefile.
# Keep the list sorted.
@@ -314,6 +319,7 @@ TESTS+= shell-custom
TESTS+= shell-ksh
.endif
TESTS+= shell-sh
TESTS+= suff
TESTS+= suff-add-later
TESTS+= suff-clear-regular
TESTS+= suff-clear-single
@@ -575,7 +581,7 @@ SED_CMDS.deptgt-phony= ${STD_SED_CMDS.dd}
SED_CMDS.dir= ${STD_SED_CMDS.dd}
SED_CMDS.directive-include-guard= \
-e '/\.MAKEFLAGS/d' \
-e '/^Parsing line/d' \
-e '/^Parsing .*:[1-9][0-9]*:/d' \
-e '/^SetFilenameVars:/d' \
-e '/^ParseDependency/d' \
-e '/^ParseEOF:/d'
@@ -857,11 +863,12 @@ SED_CMDS.opt-debug-jobs+= -e 's,Command: <shell> -v,Command: <shell>,'
.rawout.out:
@${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
< ${.IMPSRC} > ${.TARGET}.tmp1
@${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
@rm ${.TARGET}.tmp1
@echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
@mv ${.TARGET}.tmp2 ${.TARGET}
< ${.IMPSRC} > ${.TARGET}.tmp
@${POSTPROC.${.PREFIX:T}:D \
${POSTPROC.${.PREFIX:T}} < ${.TARGET}.tmp > ${.TARGET}.post \
&& mv ${.TARGET}.post ${.TARGET}.tmp}
@echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
@mv ${.TARGET}.tmp ${.TARGET}
.if empty(DIFF_FLAGS)
DIFF_ECHO= echo
+12
View File
@@ -18,6 +18,18 @@ list-archive-wildcard: archive-suffix.mk
list-archive-wildcard: archive.mk
list-archive-wildcard: ternary.mk
make: "archive.mk" line 61: Error in source archive spec "libprog.a${UNDEF}(archive.mk) pre post"
in directory <curdir>
make: Fatal errors encountered -- cannot continue
make: stopped making "list-archive-undef-archive" in unit-tests
exit 1
make: "archive.mk" line 68: Error in source archive spec "libprog.a"
in directory <curdir>
make: Fatal errors encountered -- cannot continue
make: stopped making "list-archive-undef-member" in unit-tests
exit 1
Making depend-on-existing-member out-of-date archive.mk
depend-on-existing-member
+19 -1
View File
@@ -1,4 +1,4 @@
# $NetBSD: archive.mk,v 1.13 2024/04/27 20:23:22 rillig Exp $
# $NetBSD: archive.mk,v 1.14 2025/01/10 23:00:38 rillig Exp $
#
# Very basic demonstration of handling archives, based on the description
# in PSD.doc/tutorial.ms.
@@ -21,6 +21,10 @@ all:
@${MAKE} -f ${MAKEFILE} create-archive
@${MAKE} -f ${MAKEFILE} list-archive
@${MAKE} -f ${MAKEFILE} list-archive-wildcard
@${MAKE} -f ${MAKEFILE} list-archive-undef-archive || echo "exit $$?"
@echo
@${MAKE} -f ${MAKEFILE} list-archive-undef-member || echo "exit $$?"
@echo
@${MAKE} -f ${MAKEFILE} depend-on-existing-member
@${MAKE} -f ${MAKEFILE} depend-on-nonexistent-member
@${MAKE} -f ${MAKEFILE} remove-archive
@@ -51,6 +55,20 @@ list-archive: ${ARCHIVE} pre post
list-archive-wildcard: ${ARCHIVE}([at]*.mk) pre post
@printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@}
.if make(list-archive-undef-archive)
# TODO: Be more specific: mention that the variable "UNDEF" is not defined.
# expect+1: Error in source archive spec "libprog.a${UNDEF}(archive.mk) pre post"
list-archive-undef-archive: ${ARCHIVE}$${UNDEF}(archive.mk) pre post
@printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@}
.endif
.if make(list-archive-undef-member)
# TODO: Be more specific: mention that the variable "UNDEF" is not defined.
# expect+1: Error in source archive spec "libprog.a"
list-archive-undef-member: ${ARCHIVE}(archive$${UNDEF}.mk) pre post
@printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@}
.endif
depend-on-existing-member: ${ARCHIVE}(archive.mk) pre post
@echo $@
+67 -9
View File
@@ -1,9 +1,67 @@
: undefined--eol
make: in target "unclosed-expression": Unclosed variable "UNCLOSED"
: unclosed-expression-
make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}'
: unclosed-modifier-
make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
: unknown-modifier--eol
: end-eol
exit status 2
begin undefined-direct
: undefined-direct--eol
end undefined-direct with status 0
begin undefined-indirect
: undefined-direct--eol
end undefined-indirect with status 0
begin parse-error-direct
make: Unclosed variable "UNCLOSED"
in target "parse-error-unclosed-expression"
make: Unclosed expression, expecting '}'
while evaluating variable "UNCLOSED" with value ""
in target "parse-error-unclosed-modifier"
make: Unknown modifier "Z"
while evaluating variable "UNKNOWN" with value ""
in target "parse-error-unknown-modifier"
end parse-error-direct with status 2
begin parse-error-indirect
make: Unclosed variable "UNCLOSED"
in target "parse-error-unclosed-expression"
make: Unclosed expression, expecting '}'
while evaluating variable "UNCLOSED" with value ""
in target "parse-error-unclosed-modifier"
make: Unknown modifier "Z"
while evaluating variable "UNKNOWN" with value ""
in target "parse-error-unknown-modifier"
end parse-error-indirect with status 2
begin begin-direct
(exit 13) # .BEGIN
*** Error code 13 (continuing)
Stop.
make: stopped making "begin-direct" in unit-tests
end begin-direct with status 1
begin begin-indirect
(exit 13) # before-begin
*** Error code 13 (continuing)
Stop.
make: stopped making "begin-indirect" in unit-tests
end begin-indirect with status 1
begin end-direct
(exit 13) # .END
*** Error code 13 (continuing)
Stop.
make: stopped making "end-direct" in unit-tests
end end-direct with status 1
begin end-indirect
(exit 13) # before-end
*** Error code 13 (continuing)
Stop.
make: stopped making "end-indirect" in unit-tests
end end-indirect with status 1
exit status 0
+91 -24
View File
@@ -1,38 +1,105 @@
# $NetBSD: cmd-errors-jobs.mk,v 1.8 2024/07/09 19:43:01 rillig Exp $
# $NetBSD: cmd-errors-jobs.mk,v 1.13 2024/08/29 20:20:35 rillig Exp $
#
# Demonstrate how errors in expressions affect whether the commands
# are actually executed in jobs mode.
.MAKEFLAGS: -j1
RUN= @ run() { \
echo "begin $$*" \
&& ${MAKE} -f ${MAKEFILE} -j1 "$$*" \
&& echo "end $$* with status $$?" \
|| echo "end $$* with status $$?" \
&& echo; \
} && run
all:
${RUN} undefined-direct
${RUN} undefined-indirect
${RUN} parse-error-direct
${RUN} parse-error-indirect
${RUN} begin-direct
${RUN} begin-indirect
${RUN} end-direct
${RUN} end-indirect
all: undefined unclosed-expression unclosed-modifier unknown-modifier end
# Undefined variables in expressions are not an error. They expand to empty
# strings.
# expect: : undefined--eol
undefined:
# expect: : undefined-direct--eol
# expect: end undefined-direct with status 0
# expect: : undefined-direct--eol
# expect: end undefined-indirect with status 0
undefined-indirect: undefined-direct
undefined-direct:
: $@-${UNDEFINED}-eol
unclosed-expression:
# expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED"
# XXX: This command is executed even though it contains parse errors.
# expect: : unclosed-expression-
: $@-${UNCLOSED
unclosed-modifier:
# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}'
# XXX: This command is executed even though it contains parse errors.
# expect: : unclosed-modifier-
: $@-${UNCLOSED:
parse-error-indirect: parse-error-direct
parse-error-direct: parse-error-unclosed-expression
parse-error-direct: parse-error-unclosed-modifier
parse-error-direct: parse-error-unknown-modifier
unknown-modifier:
# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
# XXX: This command is executed even though it contains parse errors.
# expect: : unknown-modifier--eol
: $@-${UNKNOWN:Z}-eol
parse-error-unclosed-expression:
: unexpected $@-${UNCLOSED
# expect: : end-eol
end:
: $@-eol
parse-error-unclosed-modifier:
: unexpected $@-${UNCLOSED:
# expect: exit status 2
parse-error-unknown-modifier:
: unexpected $@-${UNKNOWN:Z}-eol
# expect-not: : unexpected
# expect: make: Unclosed variable "UNCLOSED"
# expect: make: Unclosed expression, expecting '}'
# expect: make: Unknown modifier "Z"
# expect: end parse-error-direct with status 2
# expect: make: Unclosed variable "UNCLOSED"
# expect: make: Unclosed expression, expecting '}'
# expect: make: Unknown modifier "Z"
# expect: end parse-error-indirect with status 2
.if make(begin-direct)
begin-direct:
.BEGIN:
(exit 13) # $@
.endif
# expect: begin begin-direct
# expect: make: stopped making "begin-direct" in unit-tests
# expect: end begin-direct with status 1
.if make(begin-indirect)
begin-indirect:
.BEGIN: before-begin
: Making $@
before-begin:
(exit 13) # $@
.endif
# expect: begin begin-indirect
# expect: *** Error code 13 (continuing)
# expect: make: stopped making "begin-indirect" in unit-tests
# expect: end begin-indirect with status 1
.if make(end-direct)
end-direct:
.END:
(exit 13) # $@
.endif
# expect: begin end-direct
# expect: *** Error code 13 (continuing)
# expect: Stop.
# expect: make: stopped making "end-direct" in unit-tests
# expect: end end-direct with status 1
.if make(end-indirect)
end-indirect:
.END: before-end
: Making $@
before-end:
(exit 13) # $@
.endif
# expect: begin end-indirect
# expect: *** Error code 13 (continuing)
# expect: make: stopped making "end-indirect" in unit-tests
# expect: end end-indirect with status 1
+8 -6
View File
@@ -1,9 +1,11 @@
: undefined
make: in target "unclosed-expression": Unclosed variable "UNCLOSED"
: unclosed-expression
make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}'
: unclosed-modifier
make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
: unknown-modifier
make: Unclosed variable "UNCLOSED"
in target "unclosed-expression"
make: Unclosed expression, expecting '}'
while evaluating variable "UNCLOSED" with value ""
in target "unclosed-modifier"
make: Unknown modifier "Z"
while evaluating variable "UNKNOWN" with value ""
in target "unknown-modifier"
: end
exit status 2
+7 -10
View File
@@ -1,4 +1,4 @@
# $NetBSD: cmd-errors-lint.mk,v 1.4 2024/07/05 18:59:33 rillig Exp $
# $NetBSD: cmd-errors-lint.mk,v 1.6 2024/08/29 20:20:35 rillig Exp $
#
# Demonstrate how errors in expressions affect whether the commands
# are actually executed.
@@ -14,21 +14,18 @@ undefined:
: $@ ${UNDEFINED}
unclosed-expression:
# expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED"
# XXX: This command is executed even though it contains parse errors.
# expect: : unclosed-expression
# expect: make: Unclosed variable "UNCLOSED"
# expect-not: : unclosed-expression
: $@ ${UNCLOSED
unclosed-modifier:
# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}'
# XXX: This command is executed even though it contains parse errors.
# expect: : unclosed-modifier
# expect: make: Unclosed expression, expecting '}'
# expect-not: : unclosed-modifier
: $@ ${UNCLOSED:
unknown-modifier:
# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
# XXX: This command is executed even though it contains parse errors.
# expect: : unknown-modifier
# expect: make: Unknown modifier "Z"
# expect-not: : unknown-modifier
: $@ ${UNKNOWN:Z}
end:
+8 -6
View File
@@ -1,9 +1,11 @@
: undefined--eol
make: in target "unclosed-expression": Unclosed variable "UNCLOSED"
: unclosed-expression-
make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}'
: unclosed-modifier-
make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
: unknown-modifier--eol
make: Unclosed variable "UNCLOSED"
in target "unclosed-expression"
make: Unclosed expression, expecting '}'
while evaluating variable "UNCLOSED" with value ""
in target "unclosed-modifier"
make: Unknown modifier "Z"
while evaluating variable "UNKNOWN" with value ""
in target "unknown-modifier"
: end-eol
exit status 2
+7 -10
View File
@@ -1,4 +1,4 @@
# $NetBSD: cmd-errors.mk,v 1.9 2024/07/09 19:43:01 rillig Exp $
# $NetBSD: cmd-errors.mk,v 1.11 2024/08/29 20:20:35 rillig Exp $
#
# Demonstrate how errors in expressions affect whether the commands
# are actually executed in compat mode.
@@ -12,21 +12,18 @@ undefined:
: $@-${UNDEFINED}-eol
unclosed-expression:
# expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED"
# XXX: This command is executed even though it contains parse errors.
# expect: : unclosed-expression-
# expect: make: Unclosed variable "UNCLOSED"
# expect-not: : unclosed-expression-
: $@-${UNCLOSED
unclosed-modifier:
# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}'
# XXX: This command is executed even though it contains parse errors.
# expect: : unclosed-modifier-
# expect: make: Unclosed expression, expecting '}'
# expect-not: : unclosed-modifier-
: $@-${UNCLOSED:
unknown-modifier:
# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z"
# XXX: This command is executed even though it contains parse errors.
# expect: : unknown-modifier--eol
# expect: make: Unknown modifier "Z"
# expect-not: : unknown-modifier--eol
: $@-${UNKNOWN:Z}-eol
end:
+1
View File
@@ -5,4 +5,5 @@ interrupt-ordinary: ok
interrupt-phony: ok
> cmd-interrupt-precious
interrupt-precious: ok
interrupt-compat expected-fail
exit status 0
+21 -3
View File
@@ -1,4 +1,4 @@
# $NetBSD: cmd-interrupt.mk,v 1.4 2023/03/18 22:20:12 sjg Exp $
# $NetBSD: cmd-interrupt.mk,v 1.5 2024/07/13 15:10:06 rillig Exp $
#
# Tests for interrupting a command.
#
@@ -17,10 +17,16 @@
# See also:
# CompatDeleteTarget
all: clean-before interrupt-ordinary interrupt-phony interrupt-precious clean-after
all: clean-before
all: interrupt-ordinary
all: interrupt-phony
all: interrupt-precious
all: interrupt-compat
all: clean-after
clean-before clean-after: .PHONY
@rm -f cmd-interrupt-ordinary cmd-interrupt-phony cmd-interrupt-precious
@rm -f cmd-interrupt-ordinary cmd-interrupt-phony
@rm -f cmd-interrupt-precious cmd-interrupt-compat
interrupt-ordinary:
@${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-ordinary || true
@@ -37,6 +43,10 @@ interrupt-precious: .PRECIOUS
# The ././ is necessary to work around the file cache.
@echo ${.TARGET}: ${exists(././cmd-interrupt-precious) :? ok : error }
interrupt-compat:
@${MAKE} -f ${MAKEFILE} cmd-interrupt-compat || true
@echo ${.TARGET} ${exists(././cmd-interrupt-compat) :? expected-fail : unexpected-ok }
cmd-interrupt-ordinary:
> ${.TARGET}
@kill -INT ${.MAKE.PID}
@@ -48,3 +58,11 @@ cmd-interrupt-phony: .PHONY
cmd-interrupt-precious: .PRECIOUS
> ${.TARGET}
@kill -INT ${.MAKE.PID}
# When the make process (and not the process group) is interrupted in compat
# mode, it first tries to interrupt the process group of the currently running
# child command, but that fails since there is no such process group, rather
# the child command runs in the same process group as make itself. The child
# command then continues, and after sleeping a bit creates the target file.
cmd-interrupt-compat:
@kill -INT ${.MAKE.PID} && sleep 1 && > ${.TARGET}
+2 -2
View File
@@ -1,7 +1,7 @@
makeobjdir-direct:
show-objdir: <tmpdir>/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
show-objdir: <tmpdir>/cmdline/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5
makeobjdir-indirect:
show-objdir: <tmpdir>/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
show-objdir: <tmpdir>/cmdline/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/
space-and-comment:
value # no comment $
value # no comment $
+6 -2
View File
@@ -1,8 +1,8 @@
# $NetBSD: cmdline.mk,v 1.5 2024/04/23 22:51:28 rillig Exp $
# $NetBSD: cmdline.mk,v 1.7 2024/08/29 17:56:37 sjg Exp $
#
# Tests for command line parsing and related special variables.
TMPBASE?= ${TMPDIR:U/tmp/uid${.MAKE.UID}}
TMPBASE?= ${TMPDIR:U/tmp/uid${.MAKE.UID}}/cmdline
SUB1= a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45 # just a random UUID
SUB2= 6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5 # just a random UUID
MAKE_CMD= env TMPBASE=${TMPBASE}/${SUB1} ${.MAKE} -f ${MAKEFILE} -r
@@ -12,6 +12,7 @@ DIR12= ${TMPBASE}/${SUB1}/${SUB2}
all: prepare-dirs
all: makeobjdir-direct makeobjdir-indirect
all: space-and-comment
all: cleanup
prepare-dirs:
@rm -rf ${DIR2} ${DIR12}
@@ -56,3 +57,6 @@ space-and-comment: .PHONY
@env -i MAKEFLAGS="' VAR= value # no comment '" \
${MAKE} -r -f /dev/null -v VAR \
| sed 's,$$,$$,'
cleanup:
@rm -rf ${TMPBASE}
+2 -2
View File
@@ -1,5 +1,5 @@
make: "cond-cmp-numeric-eq.mk" line 68: Malformed conditional (!(12345 = 12345))
make: "cond-cmp-numeric-eq.mk" line 76: Malformed conditional (!(12345 === 12345))
make: "cond-cmp-numeric-eq.mk" line 68: Malformed conditional '!(12345 = 12345)'
make: "cond-cmp-numeric-eq.mk" line 76: Malformed conditional '!(12345 === 12345)'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
+3 -3
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-cmp-numeric-eq.mk,v 1.7 2023/09/07 05:36:33 rillig Exp $
# $NetBSD: cond-cmp-numeric-eq.mk,v 1.8 2024/08/06 18:00:16 rillig Exp $
#
# Tests for numeric comparisons with the == operator in .if conditions.
@@ -64,7 +64,7 @@
.endif
# There is no = operator for numbers.
# expect+1: Malformed conditional (!(12345 = 12345))
# expect+1: Malformed conditional '!(12345 = 12345)'
.if !(12345 = 12345)
. error
.else
@@ -72,7 +72,7 @@
.endif
# There is no === operator for numbers either.
# expect+1: Malformed conditional (!(12345 === 12345))
# expect+1: Malformed conditional '!(12345 === 12345)'
.if !(12345 === 12345)
. error
.else
+1 -1
View File
@@ -5,7 +5,7 @@ make: "cond-cmp-numeric.mk" line 21: Comparison with '>' requires both operands
CondParser_Eval: !(${:UNaN} == NaN)
Comparing "NaN" == "NaN"
CondParser_Eval: 123 ! 123
make: "cond-cmp-numeric.mk" line 38: Malformed conditional (123 ! 123)
make: "cond-cmp-numeric.mk" line 38: Malformed conditional '123 ! 123'
CondParser_Eval: ${:U 123} < 124
Comparing 123.000000 < 124.000000
CondParser_Eval: ${:U123 } < 124
+2 -2
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-cmp-numeric.mk,v 1.7 2023/03/04 08:07:29 rillig Exp $
# $NetBSD: cond-cmp-numeric.mk,v 1.8 2024/08/06 18:00:16 rillig Exp $
#
# Tests for numeric comparisons in .if conditions.
#
@@ -34,7 +34,7 @@
# whether the operator is valid, leaving the rest of the work to the
# evaluation functions EvalCompareNum and EvalCompareStr. Ensure that this
# parse error is properly reported.
# expect+1: Malformed conditional (123 ! 123)
# expect+1: Malformed conditional '123 ! 123'
.if 123 ! 123
. error
.else
+4 -4
View File
@@ -1,7 +1,7 @@
make: "cond-cmp-string.mk" line 19: Malformed conditional (str != str)
make: "cond-cmp-string.mk" line 44: Malformed conditional ("string" != "str""ing")
make: "cond-cmp-string.mk" line 52: Malformed conditional (!("value" = "value"))
make: "cond-cmp-string.mk" line 60: Malformed conditional (!("value" === "value"))
make: "cond-cmp-string.mk" line 19: Malformed conditional 'str != str'
make: "cond-cmp-string.mk" line 44: Malformed conditional '"string" != "str""ing"'
make: "cond-cmp-string.mk" line 52: Malformed conditional '!("value" = "value")'
make: "cond-cmp-string.mk" line 60: Malformed conditional '!("value" === "value")'
make: "cond-cmp-string.mk" line 118: Comparison with '<' requires both operands 'string' and 'string' to be numeric
make: "cond-cmp-string.mk" line 126: Comparison with '<=' requires both operands 'string' and 'string' to be numeric
make: "cond-cmp-string.mk" line 134: Comparison with '>' requires both operands 'string' and 'string' to be numeric
+5 -5
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-cmp-string.mk,v 1.19 2024/04/23 22:51:28 rillig Exp $
# $NetBSD: cond-cmp-string.mk,v 1.20 2024/08/06 18:00:16 rillig Exp $
#
# Tests for string comparisons in .if conditions.
@@ -15,7 +15,7 @@
# The left-hand side of the comparison must be enclosed in quotes.
# This one is not enclosed in quotes and thus generates an error message.
# expect+1: Malformed conditional (str != str)
# expect+1: Malformed conditional 'str != str'
.if str != str
. error
.endif
@@ -40,7 +40,7 @@
# It is not possible to concatenate two string literals to form a single
# string. In C, Python and the shell this is possible, but not in make.
# expect+1: Malformed conditional ("string" != "str""ing")
# expect+1: Malformed conditional '"string" != "str""ing"'
.if "string" != "str""ing"
. error
.else
@@ -48,7 +48,7 @@
.endif
# There is no = operator for strings.
# expect+1: Malformed conditional (!("value" = "value"))
# expect+1: Malformed conditional '!("value" = "value")'
.if !("value" = "value")
. error
.else
@@ -56,7 +56,7 @@
.endif
# There is no === operator for strings either.
# expect+1: Malformed conditional (!("value" === "value"))
# expect+1: Malformed conditional '!("value" === "value")'
.if !("value" === "value")
. error
.else
+3 -3
View File
@@ -1,6 +1,6 @@
make: "cond-eof.mk" line 17: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2})
make: "cond-eof.mk" line 20: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2})
make: "cond-eof.mk" line 23: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2})
make: "cond-eof.mk" line 17: Malformed conditional '0 ${SIDE_EFFECT} ${SIDE_EFFECT2}'
make: "cond-eof.mk" line 20: Malformed conditional '1 ${SIDE_EFFECT} ${SIDE_EFFECT2}'
make: "cond-eof.mk" line 23: Malformed conditional '(0) ${SIDE_EFFECT} ${SIDE_EFFECT2}'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
+4 -4
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-eof.mk,v 1.6 2023/11/19 21:47:52 rillig Exp $
# $NetBSD: cond-eof.mk,v 1.7 2024/08/06 18:00:16 rillig Exp $
#
# Tests for parsing the end of '.if' conditions, which are represented as the
# token TOK_EOF.
@@ -13,12 +13,12 @@ SIDE_EFFECT2= ${:!echo 'side effect 2' 1>&2!}
# These syntax errors are an edge case that does not occur during normal
# operation. Still, it is easy to avoid evaluating these expressions, just in
# case they have side effects.
# expect+1: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2})
# expect+1: Malformed conditional '0 ${SIDE_EFFECT} ${SIDE_EFFECT2}'
.if 0 ${SIDE_EFFECT} ${SIDE_EFFECT2}
.endif
# expect+1: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2})
# expect+1: Malformed conditional '1 ${SIDE_EFFECT} ${SIDE_EFFECT2}'
.if 1 ${SIDE_EFFECT} ${SIDE_EFFECT2}
.endif
# expect+1: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2})
# expect+1: Malformed conditional '(0) ${SIDE_EFFECT} ${SIDE_EFFECT2}'
.if (0) ${SIDE_EFFECT} ${SIDE_EFFECT2}
.endif
+6 -1
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-func-commands.mk,v 1.5 2020/11/15 14:07:53 rillig Exp $
# $NetBSD: cond-func-commands.mk,v 1.6 2025/01/10 23:00:38 rillig Exp $
#
# Tests for the commands() function in .if conditions.
@@ -33,5 +33,10 @@ target:
. error
.endif
# Expressions in the argument of a function call don't have to be defined.
.if commands(${UNDEF})
. error
.endif
all:
@:;
+2 -2
View File
@@ -1,5 +1,5 @@
make: "cond-func-defined.mk" line 24: Missing closing parenthesis for defined()
make: "cond-func-defined.mk" line 34: Missing closing parenthesis for defined()
make: "cond-func-defined.mk" line 24: Missing ')' after argument 'A' for 'defined'
make: "cond-func-defined.mk" line 34: Missing ')' after argument 'DEF' for 'defined'
make: Fatal errors encountered -- cannot continue
make: stopped making "all" in unit-tests
exit status 1
+8 -3
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-func-defined.mk,v 1.12 2024/04/23 22:51:28 rillig Exp $
# $NetBSD: cond-func-defined.mk,v 1.14 2025/01/10 23:00:38 rillig Exp $
#
# Tests for the defined() function in .if conditions.
@@ -20,7 +20,7 @@ ${:UA B}= variable name with spaces
.endif
# The argument of a function must not directly contain whitespace.
# expect+1: Missing closing parenthesis for defined()
# expect+1: Missing ')' after argument 'A' for 'defined'
.if !defined(A B)
. error
.endif
@@ -30,7 +30,7 @@ ${:UA B}= variable name with spaces
. error
.endif
# expect+1: Missing closing parenthesis for defined()
# expect+1: Missing ')' after argument 'DEF' for 'defined'
.if defined(DEF
. error
.else
@@ -49,6 +49,11 @@ ${:UA B}= variable name with spaces
. endif
.endfor
# Expressions in the argument of a function call don't have to be defined.
.if defined(${UNDEF})
. error
.endif
# Neither of the conditions is true. Before July 2020, the right-hand
# condition was evaluated even though it was irrelevant.
.if defined(UNDEF) && ${UNDEF:Mx} != ""
+1 -2
View File
@@ -1,5 +1,4 @@
make: "cond-func-empty.mk" line 168: Unclosed variable "WORD"
make: "cond-func-empty.mk" line 168: Malformed conditional (empty(WORD)
make: "cond-func-empty.mk" line 167: Unclosed variable "WORD"
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
+6 -3
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-func-empty.mk,v 1.25 2024/06/02 15:31:26 rillig Exp $
# $NetBSD: cond-func-empty.mk,v 1.28 2025/01/11 20:54:45 rillig Exp $
#
# Tests for the empty() function in .if conditions, which tests an
# expression for emptiness.
@@ -163,8 +163,7 @@ ${:U WORD }= variable name with spaces
. error
.endif
# expect+2: Unclosed variable "WORD"
# expect+1: Malformed conditional (empty(WORD)
# expect+1: Unclosed variable "WORD"
.if empty(WORD
. error
.else
@@ -207,6 +206,10 @@ VARNAME= ${VARNAME${:U1}}
.if defined(VARNAME${:U2}) && !empty(VARNAME${:U2})
.endif
# Expressions in the argument of a function call don't have to be defined.
.if !empty(${UNDEF})
. error
.endif
# If the word 'empty' is not followed by '(', it is not a function call but an
# ordinary bare word. This bare word is interpreted as 'defined(empty)', and
+6 -1
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-func-exists.mk,v 1.7 2023/11/19 21:47:52 rillig Exp $
# $NetBSD: cond-func-exists.mk,v 1.8 2025/01/10 23:00:38 rillig Exp $
#
# Tests for the exists() function in .if conditions.
@@ -38,6 +38,11 @@
. error
.endif
# Expressions in the argument of a function call don't have to be defined.
.if exists(${UNDEF})
. error
.endif
# The exists function does not really look up the file in the file system,
# instead it uses a cache that is preloaded very early, before parsing the
# first makefile. At that time, the file did not exist yet.
+6 -1
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-func-make.mk,v 1.5 2023/06/23 04:56:54 rillig Exp $
# $NetBSD: cond-func-make.mk,v 1.6 2025/01/10 23:00:38 rillig Exp $
#
# Tests for the make() function in .if conditions, which tests whether
# the argument has been passed as a target via the command line or later
@@ -25,5 +25,10 @@
. error
.endif
# Expressions in the argument of a function call don't have to be defined.
.if make(${UNDEF})
. error
.endif
via-cmdline via-dot-makeflags:
: $@
+6 -1
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-func-target.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $
# $NetBSD: cond-func-target.mk,v 1.5 2025/01/10 23:00:38 rillig Exp $
#
# Tests for the target() function in .if conditions.
@@ -34,5 +34,10 @@ target:
. error
.endif
# Expressions in the argument of a function call don't have to be defined.
.if target(${UNDEF})
. error
.endif
all:
@:;
+5 -4
View File
@@ -1,12 +1,13 @@
make: "cond-func.mk" line 37: Missing closing parenthesis for defined()
make: "cond-func.mk" line 53: Missing closing parenthesis for defined()
make: "cond-func.mk" line 57: Missing closing parenthesis for defined()
make: "cond-func.mk" line 37: Missing ')' after argument 'A' for 'defined'
make: "cond-func.mk" line 53: Missing ')' after argument 'A' for 'defined'
make: "cond-func.mk" line 57: Missing ')' after argument 'A' for 'defined'
make: "cond-func.mk" line 91: Unknown operator '&'
make: "cond-func.mk" line 107: A plain function name is parsed as defined(...).
make: "cond-func.mk" line 115: A plain function name is parsed as defined(...).
make: "cond-func.mk" line 126: Symbols may start with a function name.
make: "cond-func.mk" line 132: Symbols may start with a function name.
make: "cond-func.mk" line 138: Missing closing parenthesis for defined()
make: "cond-func.mk" line 138: Missing ')' after argument '' for 'defined'
make: "cond-func.mk" line 145: Missing ')' after argument '${:UVARNAME}.param' for 'defined'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
+12 -5
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-func.mk,v 1.15 2024/07/06 21:21:10 rillig Exp $
# $NetBSD: cond-func.mk,v 1.18 2024/08/07 05:48:45 rillig Exp $
#
# Tests for those parts of the functions in .if conditions that are common
# among several functions.
@@ -33,7 +33,7 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces
.endif
# The argument of a function must not directly contain whitespace.
# expect+1: Missing closing parenthesis for defined()
# expect+1: Missing ')' after argument 'A' for 'defined'
.if !defined(A B)
. error
.endif
@@ -49,11 +49,11 @@ ${VARNAME_UNBALANCED_BRACES}= variable name with unbalanced braces
#
# It's not entirely clear why these characters are forbidden.
# The most plausible reason seems to be typo detection.
# expect+1: Missing closing parenthesis for defined()
# expect+1: Missing ')' after argument 'A' for 'defined'
.if !defined(A&B)
. error
.endif
# expect+1: Missing closing parenthesis for defined()
# expect+1: Missing ')' after argument 'A' for 'defined'
.if !defined(A|B)
. error
.endif
@@ -134,9 +134,16 @@ defined-var= # defined but empty
. error
.endif
# expect+1: Missing closing parenthesis for defined()
# expect+1: Missing ')' after argument '' for 'defined'
.if defined(
. error
.else
. error
.endif
# expect+1: Missing ')' after argument '${:UVARNAME}.param' for 'defined'
.if defined(${:UVARNAME}.param extra)
. error
.else
. error
.endif
+3 -1
View File
@@ -1,4 +1,6 @@
make: "cond-late.mk" line 38: while evaluating variable "VAR" with value "${${UNDEF} != "no":?:}": while evaluating condition " != "no"": Bad condition
make: "cond-late.mk" line 38: Bad condition
while evaluating condition " != "no""
while evaluating variable "VAR" with value "${${UNDEF} != "no":?:}"
in directory <curdir>
make: Fatal errors encountered -- cannot continue
make: stopped making "do-parse-time" in unit-tests
+2 -2
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-late.mk,v 1.8 2024/07/04 17:47:54 rillig Exp $
# $NetBSD: cond-late.mk,v 1.9 2024/08/29 20:20:35 rillig Exp $
#
# Using the :? modifier, expressions can contain conditional
# expressions that are evaluated late, at expansion time.
@@ -34,7 +34,7 @@ cond-literal:
.if make(do-parse-time)
VAR= ${${UNDEF} != "no":?:}
# expect+1: while evaluating variable "VAR" with value "${${UNDEF} != "no":?:}": while evaluating condition " != "no"": Bad condition
# expect+1: Bad condition
. if empty(VAR:Mpattern)
. endif
.endif
+3 -3
View File
@@ -1,6 +1,6 @@
make: "cond-op-and.mk" line 36: Malformed conditional (0 || (${DEF} && ${UNDEF}))
make: "cond-op-and.mk" line 41: Malformed conditional (0 || (${UNDEF} && ${UNDEF}))
make: "cond-op-and.mk" line 44: Malformed conditional (0 || (!${UNDEF} && ${UNDEF}))
make: "cond-op-and.mk" line 36: Variable "UNDEF" is undefined
make: "cond-op-and.mk" line 41: Variable "UNDEF" is undefined
make: "cond-op-and.mk" line 44: Variable "UNDEF" is undefined
make: "cond-op-and.mk" line 60: Unknown operator '&'
make: "cond-op-and.mk" line 66: Unknown operator '&'
make: "cond-op-and.mk" line 72: Unknown operator '&'
+4 -4
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-op-and.mk,v 1.10 2024/07/06 21:21:10 rillig Exp $
# $NetBSD: cond-op-and.mk,v 1.12 2025/01/11 21:21:33 rillig Exp $
#
# Tests for the && operator in .if conditions.
@@ -32,15 +32,15 @@
# Test combinations of outer '||' with inner '&&', to ensure that the operands
# of the inner '&&' are only evaluated if necessary.
DEF= defined
# expect+1: Malformed conditional (0 || (${DEF} && ${UNDEF}))
# expect+1: Variable "UNDEF" is undefined
.if 0 || (${DEF} && ${UNDEF})
.endif
.if 0 || (!${DEF} && ${UNDEF})
.endif
# expect+1: Malformed conditional (0 || (${UNDEF} && ${UNDEF}))
# expect+1: Variable "UNDEF" is undefined
.if 0 || (${UNDEF} && ${UNDEF})
.endif
# expect+1: Malformed conditional (0 || (!${UNDEF} && ${UNDEF}))
# expect+1: Variable "UNDEF" is undefined
.if 0 || (!${UNDEF} && ${UNDEF})
.endif
.if 1 || (${DEF} && ${UNDEF})
+1 -1
View File
@@ -3,7 +3,7 @@ make: "cond-op-not.mk" line 39: Not space evaluates to false.
make: "cond-op-not.mk" line 44: Not 0 evaluates to true.
make: "cond-op-not.mk" line 53: Not 1 evaluates to false.
make: "cond-op-not.mk" line 60: Not word evaluates to false.
make: "cond-op-not.mk" line 65: Malformed conditional (!)
make: "cond-op-not.mk" line 65: Malformed conditional '!'
make: Fatal errors encountered -- cannot continue
make: stopped making "all" in unit-tests
exit status 1
+2 -2
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-op-not.mk,v 1.8 2023/06/01 20:56:35 rillig Exp $
# $NetBSD: cond-op-not.mk,v 1.9 2024/08/06 18:00:17 rillig Exp $
#
# Tests for the ! operator in .if conditions, which negates its argument.
@@ -61,7 +61,7 @@
.endif
# A single exclamation mark is a parse error.
# expect+1: Malformed conditional (!)
# expect+1: Malformed conditional '!'
.if !
. error
.else
+3 -3
View File
@@ -1,6 +1,6 @@
make: "cond-op-or.mk" line 36: Malformed conditional (1 && (!${DEF} || ${UNDEF}))
make: "cond-op-or.mk" line 41: Malformed conditional (1 && (!${UNDEF} || ${UNDEF}))
make: "cond-op-or.mk" line 44: Malformed conditional (1 && (${UNDEF} || ${UNDEF}))
make: "cond-op-or.mk" line 36: Variable "UNDEF" is undefined
make: "cond-op-or.mk" line 41: Variable "UNDEF" is undefined
make: "cond-op-or.mk" line 44: Variable "UNDEF" is undefined
make: "cond-op-or.mk" line 60: Unknown operator '|'
make: "cond-op-or.mk" line 66: Unknown operator '|'
make: "cond-op-or.mk" line 72: Unknown operator '|'
+4 -4
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-op-or.mk,v 1.12 2024/07/06 21:21:10 rillig Exp $
# $NetBSD: cond-op-or.mk,v 1.14 2025/01/11 21:21:33 rillig Exp $
#
# Tests for the || operator in .if conditions.
@@ -32,15 +32,15 @@
# Test combinations of outer '&&' with inner '||', to ensure that the operands
# of the inner '||' are only evaluated if necessary.
DEF= defined
# expect+1: Malformed conditional (1 && (!${DEF} || ${UNDEF}))
# expect+1: Variable "UNDEF" is undefined
.if 1 && (!${DEF} || ${UNDEF})
.endif
.if 1 && (${DEF} || ${UNDEF})
.endif
# expect+1: Malformed conditional (1 && (!${UNDEF} || ${UNDEF}))
# expect+1: Variable "UNDEF" is undefined
.if 1 && (!${UNDEF} || ${UNDEF})
.endif
# expect+1: Malformed conditional (1 && (${UNDEF} || ${UNDEF}))
# expect+1: Variable "UNDEF" is undefined
.if 1 && (${UNDEF} || ${UNDEF})
.endif
.if 0 && (!${DEF} || ${UNDEF})
+3 -3
View File
@@ -1,7 +1,7 @@
make: "cond-op-parentheses.mk" line 22: Comparison with '>' requires both operands '3' and '(2' to be numeric
make: "cond-op-parentheses.mk" line 25: Malformed conditional ((3) > 2)
make: "cond-op-parentheses.mk" line 44: Malformed conditional (()
make: "cond-op-parentheses.mk" line 58: Malformed conditional ())
make: "cond-op-parentheses.mk" line 25: Malformed conditional '(3) > 2'
make: "cond-op-parentheses.mk" line 44: Malformed conditional '('
make: "cond-op-parentheses.mk" line 58: Malformed conditional ')'
make: Fatal errors encountered -- cannot continue
make: stopped making "all" in unit-tests
exit status 1
+4 -4
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-op-parentheses.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
# $NetBSD: cond-op-parentheses.mk,v 1.8 2024/08/06 18:00:17 rillig Exp $
#
# Tests for parentheses in .if conditions, which group expressions to override
# the precedence of the operators '!', '&&' and '||'. Parentheses cannot be
@@ -21,7 +21,7 @@
# expect+1: Comparison with '>' requires both operands '3' and '(2' to be numeric
.if 3 > (2)
.endif
# expect+1: Malformed conditional ((3) > 2)
# expect+1: Malformed conditional '(3) > 2'
.if (3) > 2
.endif
@@ -40,7 +40,7 @@
.endif
# An unbalanced opening parenthesis is a parse error.
# expect+1: Malformed conditional (()
# expect+1: Malformed conditional '('
.if (
. error
.else
@@ -54,7 +54,7 @@
# TOK_TRUE, TOK_FALSE or TOK_ERROR. In cond.c 1.241, the return type of that
# function was changed to a properly restricted enum type, to prevent this bug
# from occurring again.
# expect+1: Malformed conditional ())
# expect+1: Malformed conditional ')'
.if )
. error
.else
+7 -7
View File
@@ -1,7 +1,7 @@
make: "cond-op.mk" line 51: Malformed conditional ("!word" == !word)
make: "cond-op.mk" line 72: Malformed conditional (0 ${ERR::=evaluated})
make: "cond-op.mk" line 51: Malformed conditional '"!word" == !word'
make: "cond-op.mk" line 72: Malformed conditional '0 ${ERR::=evaluated}'
make: "cond-op.mk" line 77: A misplaced expression after 0 is not evaluated.
make: "cond-op.mk" line 82: Malformed conditional (1 ${ERR::=evaluated})
make: "cond-op.mk" line 82: Malformed conditional '1 ${ERR::=evaluated}'
make: "cond-op.mk" line 87: A misplaced expression after 1 is not evaluated.
make: "cond-op.mk" line 93: A B C => (A || B) && C A || B && C A || (B && C)
make: "cond-op.mk" line 108: 0 0 0 => 0 0 0
@@ -12,10 +12,10 @@ make: "cond-op.mk" line 108: 1 0 0 => 0 1 1
make: "cond-op.mk" line 108: 1 0 1 => 1 1 1
make: "cond-op.mk" line 108: 1 1 0 => 0 1 1
make: "cond-op.mk" line 108: 1 1 1 => 1 1 1
make: "cond-op.mk" line 120: Malformed conditional (1 &&)
make: "cond-op.mk" line 129: Malformed conditional (0 &&)
make: "cond-op.mk" line 138: Malformed conditional (1 ||)
make: "cond-op.mk" line 148: Malformed conditional (0 ||)
make: "cond-op.mk" line 120: Malformed conditional '1 &&'
make: "cond-op.mk" line 129: Malformed conditional '0 &&'
make: "cond-op.mk" line 138: Malformed conditional '1 ||'
make: "cond-op.mk" line 148: Malformed conditional '0 ||'
make: Fatal errors encountered -- cannot continue
make: stopped making "all" in unit-tests
exit status 1
+8 -8
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-op.mk,v 1.16 2023/06/01 20:56:35 rillig Exp $
# $NetBSD: cond-op.mk,v 1.17 2024/08/06 18:00:17 rillig Exp $
#
# Tests for operators like &&, ||, ! in .if conditions.
#
@@ -47,7 +47,7 @@
# appear unquoted. If any, it must be enclosed in quotes.
# In any case, it is not interpreted as a negation of an unquoted string.
# See CondParser_String.
# expect+1: Malformed conditional ("!word" == !word)
# expect+1: Malformed conditional '"!word" == !word'
.if "!word" == !word
. error
.endif
@@ -68,7 +68,7 @@
# next token, even though in this position of the condition, only comparison
# operators, TOK_AND, TOK_OR or TOK_RPAREN are allowed.
.undef ERR
# expect+1: Malformed conditional (0 ${ERR::=evaluated})
# expect+1: Malformed conditional '0 ${ERR::=evaluated}'
.if 0 ${ERR::=evaluated}
. error
.endif
@@ -78,7 +78,7 @@
.endif
.undef ERR
# expect+1: Malformed conditional (1 ${ERR::=evaluated})
# expect+1: Malformed conditional '1 ${ERR::=evaluated}'
.if 1 ${ERR::=evaluated}
. error
.endif
@@ -116,7 +116,7 @@
# This condition is obviously malformed. It is properly detected and also
# was properly detected before 2021-01-19, but only because the left hand
# side of the '&&' evaluated to true.
# expect+1: Malformed conditional (1 &&)
# expect+1: Malformed conditional '1 &&'
.if 1 &&
. error
.else
@@ -125,7 +125,7 @@
# This obviously malformed condition was not detected as such before cond.c
# 1.238 from 2021-01-19.
# expect+1: Malformed conditional (0 &&)
# expect+1: Malformed conditional '0 &&'
.if 0 &&
. error
.else
@@ -134,7 +134,7 @@
# This obviously malformed condition was not detected as such before cond.c
# 1.238 from 2021-01-19.
# expect+1: Malformed conditional (1 ||)
# expect+1: Malformed conditional '1 ||'
.if 1 ||
. error
.else
@@ -144,7 +144,7 @@
# This condition is obviously malformed. It is properly detected and also
# was properly detected before 2021-01-19, but only because the left hand
# side of the '||' evaluated to false.
# expect+1: Malformed conditional (0 ||)
# expect+1: Malformed conditional '0 ||'
.if 0 ||
. error
.else
+4 -4
View File
@@ -1,7 +1,7 @@
make: "cond-token-number.mk" line 16: Malformed conditional (-0)
make: "cond-token-number.mk" line 27: Malformed conditional (+0)
make: "cond-token-number.mk" line 38: Malformed conditional (!-1)
make: "cond-token-number.mk" line 49: Malformed conditional (!+1)
make: "cond-token-number.mk" line 16: Malformed conditional '-0'
make: "cond-token-number.mk" line 27: Malformed conditional '+0'
make: "cond-token-number.mk" line 38: Malformed conditional '!-1'
make: "cond-token-number.mk" line 49: Malformed conditional '!+1'
make: Fatal errors encountered -- cannot continue
make: stopped making "all" in unit-tests
exit status 1
+5 -5
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-token-number.mk,v 1.10 2023/11/19 21:47:52 rillig Exp $
# $NetBSD: cond-token-number.mk,v 1.11 2024/08/06 18:00:17 rillig Exp $
#
# Tests for number tokens in .if conditions.
#
@@ -12,7 +12,7 @@
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
# expect+1: Malformed conditional (-0)
# expect+1: Malformed conditional '-0'
.if -0
. error
.else
@@ -23,7 +23,7 @@
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
# expect+1: Malformed conditional (+0)
# expect+1: Malformed conditional '+0'
.if +0
. error
.else
@@ -34,7 +34,7 @@
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
# expect+1: Malformed conditional (!-1)
# expect+1: Malformed conditional '!-1'
.if !-1
. error
.else
@@ -45,7 +45,7 @@
# accepted by the condition parser.
#
# See the ch_isdigit call in CondParser_String.
# expect+1: Malformed conditional (!+1)
# expect+1: Malformed conditional '!+1'
.if !+1
. error
.else
+6 -6
View File
@@ -41,7 +41,7 @@ make: "cond-token-plain.mk" line 144: Numbers can be composed from literals and
CondParser_Eval: "" ==
make: "cond-token-plain.mk" line 151: Missing right-hand side of operator '=='
CondParser_Eval: == ""
make: "cond-token-plain.mk" line 160: Malformed conditional (== "")
make: "cond-token-plain.mk" line 160: Malformed conditional '== ""'
CondParser_Eval: \\
make: "cond-token-plain.mk" line 176: The variable '\\' is not defined.
CondParser_Eval: \\
@@ -49,15 +49,15 @@ make: "cond-token-plain.mk" line 182: Now the variable '\\' is defined.
CondParser_Eval: "unquoted\"quoted" != unquoted"quoted
Comparing "unquoted"quoted" != "unquoted"quoted"
CondParser_Eval: $$$$$$$$ != ""
make: "cond-token-plain.mk" line 197: Malformed conditional ($$$$$$$$ != "")
make: "cond-token-plain.mk" line 197: Malformed conditional '$$$$$$$$ != ""'
CondParser_Eval: left == right
make: "cond-token-plain.mk" line 206: Malformed conditional (left == right)
make: "cond-token-plain.mk" line 206: Malformed conditional 'left == right'
CondParser_Eval: ${0:?:} || left == right
CondParser_Eval: 0
make: "cond-token-plain.mk" line 212: Malformed conditional (${0:?:} || left == right)
make: "cond-token-plain.mk" line 212: Malformed conditional '${0:?:} || left == right'
CondParser_Eval: left == right || ${0:?:}
make: "cond-token-plain.mk" line 217: Malformed conditional (left == right || ${0:?:})
make: "cond-token-plain.mk" line 236: Malformed conditional (VAR.${IF_COUNT::+=1} != "")
make: "cond-token-plain.mk" line 217: Malformed conditional 'left == right || ${0:?:}'
make: "cond-token-plain.mk" line 236: Malformed conditional 'VAR.${IF_COUNT::+=1} != ""'
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
+7 -7
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-token-plain.mk,v 1.19 2023/11/19 21:47:52 rillig Exp $
# $NetBSD: cond-token-plain.mk,v 1.20 2024/08/06 18:00:17 rillig Exp $
#
# Tests for plain tokens (that is, string literals without quotes)
# in .if conditions. These are also called bare words.
@@ -156,7 +156,7 @@ VAR= defined
# If the left-hand side is missing, it's a parse error as well, but without
# a specific error message.
# expect+1: Malformed conditional (== "")
# expect+1: Malformed conditional '== ""'
.if == ""
. error
.else
@@ -193,7 +193,7 @@ ${:U\\\\}= backslash
# FIXME: In CondParser_String, Var_Parse returns var_Error without a
# corresponding error message.
# expect+1: Malformed conditional ($$$$$$$$ != "")
# expect+1: Malformed conditional '$$$$$$$$ != ""'
.if $$$$$$$$ != ""
. error
.else
@@ -202,18 +202,18 @@ ${:U\\\\}= backslash
# In a condition in an .if directive, the left-hand side must not be an
# unquoted string literal.
# expect+1: Malformed conditional (left == right)
# expect+1: Malformed conditional 'left == right'
.if left == right
.endif
# Before cond.c 1.276 from 2021-09-21, an expression containing the
# modifier ':?:' allowed unquoted string literals for the rest of the
# condition. This was an unintended implementation mistake.
# expect+1: Malformed conditional (${0:?:} || left == right)
# expect+1: Malformed conditional '${0:?:} || left == right'
.if ${0:?:} || left == right
.endif
# This affected only the comparisons after the expression, so the following
# was still a syntax error.
# expect+1: Malformed conditional (left == right || ${0:?:})
# expect+1: Malformed conditional 'left == right || ${0:?:}'
.if left == right || ${0:?:}
.endif
@@ -232,7 +232,7 @@ ${:U\\\\}= backslash
# for the second time. The right-hand side of a comparison may be a bare
# word, but that side has no risk of being parsed more than once.
#
# expect+1: Malformed conditional (VAR.${IF_COUNT::+=1} != "")
# expect+1: Malformed conditional 'VAR.${IF_COUNT::+=1} != ""'
.if VAR.${IF_COUNT::+=1} != ""
. error
.else
+10 -10
View File
@@ -1,18 +1,18 @@
make: "cond-token-string.mk" line 15: while evaluating "${:Uvalue:Z}"" with value "value": Unknown modifier "Z"
make: "cond-token-string.mk" line 15: Malformed conditional ("" != "${:Uvalue:Z}")
make: "cond-token-string.mk" line 25: xvalue is not defined.
make: "cond-token-string.mk" line 32: Malformed conditional (x${:Uvalue} == "")
make: "cond-token-string.mk" line 42: Expected.
make: "cond-token-string.mk" line 14: Unknown modifier "Z"
while evaluating "${:Uvalue:Z}"" with value "value"
make: "cond-token-string.mk" line 24: xvalue is not defined.
make: "cond-token-string.mk" line 31: Malformed conditional 'x${:Uvalue} == ""'
make: "cond-token-string.mk" line 41: Expected.
CondParser_Eval: "UNDEF"
make: "cond-token-string.mk" line 52: The string literal "UNDEF" is not empty.
make: "cond-token-string.mk" line 51: The string literal "UNDEF" is not empty.
CondParser_Eval: " "
make: "cond-token-string.mk" line 61: The string literal " " is not empty, even though it consists of whitespace only.
make: "cond-token-string.mk" line 60: The string literal " " is not empty, even though it consists of whitespace only.
CondParser_Eval: "${UNDEF}"
make: "cond-token-string.mk" line 71: An undefined variable in quotes expands to an empty string, which then evaluates to false.
make: "cond-token-string.mk" line 70: An undefined variable in quotes expands to an empty string, which then evaluates to false.
CondParser_Eval: "${:Uvalue}"
make: "cond-token-string.mk" line 77: A nonempty expression evaluates to true.
make: "cond-token-string.mk" line 76: A nonempty expression evaluates to true.
CondParser_Eval: "${:U}"
make: "cond-token-string.mk" line 86: An empty variable evaluates to false.
make: "cond-token-string.mk" line 85: An empty variable evaluates to false.
CondParser_Eval: ("${VAR}")
CondParser_Eval: "quoted" == quoted
Comparing "quoted" == "quoted"
+3 -4
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-token-string.mk,v 1.11 2024/07/05 19:47:22 rillig Exp $
# $NetBSD: cond-token-string.mk,v 1.15 2025/01/11 20:54:45 rillig Exp $
#
# Tests for quoted string literals in .if conditions.
#
@@ -10,8 +10,7 @@
# Cover the code in CondParser_String that frees the memory after parsing
# an expression based on an undefined variable.
# expect+2: Malformed conditional ("" != "${:Uvalue:Z}")
# expect+1: while evaluating "${:Uvalue:Z}"" with value "value": Unknown modifier "Z"
# expect+1: Unknown modifier "Z"
.if "" != "${:Uvalue:Z}"
. error
.else
@@ -28,7 +27,7 @@
# The 'x' produces a "Malformed conditional" since the left-hand side of a
# comparison in an .if directive must be either an expression, a
# quoted string literal or a number that starts with a digit.
# expect+1: Malformed conditional (x${:Uvalue} == "")
# expect+1: Malformed conditional 'x${:Uvalue} == ""'
.if x${:Uvalue} == ""
. error
.else
+18 -4
View File
@@ -1,7 +1,21 @@
make: "cond-token-var.mk" line 21: ok
make: "cond-token-var.mk" line 28: Malformed conditional (${UNDEF} == ${DEF})
make: "cond-token-var.mk" line 34: Malformed conditional (${DEF} == ${UNDEF})
make: "cond-token-var.mk" line 44: Malformed conditional (${UNDEF})
make: "cond-token-var.mk" line 23: ok
make: "cond-token-var.mk" line 30: Variable "UNDEF" is undefined
make: "cond-token-var.mk" line 36: Variable "UNDEF" is undefined
make: "cond-token-var.mk" line 46: Variable "UNDEF" is undefined
make: "cond-token-var.mk" line 64: Variable "U" is undefined
make: "cond-token-var.mk" line 69: Variable "U" is undefined
make: "cond-token-var.mk" line 78: Variable "U" is undefined
Var_Parse: ${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3} (eval)
make: "cond-token-var.mk" line 106: Malformed conditional 'x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3}'
Var_Parse: ${DEF}y == "${UNDEF2}" || 0x${UNDEF3} (eval)
make: "cond-token-var.mk" line 111: Malformed conditional 'x${DEF}y == "${UNDEF2}" || 0x${UNDEF3}'
Var_Parse: ${DEF}y == "${DEF}" || 0x${UNDEF3} (eval)
make: "cond-token-var.mk" line 116: Malformed conditional 'x${DEF}y == "${DEF}" || 0x${UNDEF3}'
Global: VAR.param = value of VAR.param
Var_Parse: ${VAR.param$U} (eval-defined-loud)
Var_Parse: $U} (eval)
Global: .MAKEFLAGS = -r -k -d v -d
Global: .MAKEFLAGS = -r -k -d v -d 0
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
+61 -4
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-token-var.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $
# $NetBSD: cond-token-var.mk,v 1.11 2025/01/11 21:21:33 rillig Exp $
#
# Tests for expressions in .if conditions.
#
@@ -13,8 +13,10 @@
# Well, except for the assignment modifiers, these do indeed change the value
# of the variable.
D= defined
DEF= defined
# A defined variable may appear on either side of the comparison.
.if ${DEF} == ${DEF}
# expect+1: ok
@@ -24,13 +26,13 @@ DEF= defined
.endif
# A variable that appears on the left-hand side must be defined.
# expect+1: Malformed conditional (${UNDEF} == ${DEF})
# expect+1: Variable "UNDEF" is undefined
.if ${UNDEF} == ${DEF}
. error
.endif
# A variable that appears on the right-hand side must be defined.
# expect+1: Malformed conditional (${DEF} == ${UNDEF})
# expect+1: Variable "UNDEF" is undefined
.if ${DEF} == ${UNDEF}
. error
.endif
@@ -40,7 +42,7 @@ DEF= defined
.endif
# An undefined variable on its own generates a parse error.
# expect+1: Malformed conditional (${UNDEF})
# expect+1: Variable "UNDEF" is undefined
.if ${UNDEF}
.endif
@@ -49,6 +51,34 @@ DEF= defined
.if ${UNDEF:U}
.endif
# The same as above, for single-letter variables without braces or
# parentheses.
# A defined variable may appear on either side of the comparison.
.if $D == $D
.endif
# A variable on the left-hand side must be defined.
# expect+1: Variable "U" is undefined
.if $U == $D
.endif
# A variable on the right-hand side must be defined.
# expect+1: Variable "U" is undefined
.if $D == $U
.endif
# A defined variable may appear as an expression of its own.
.if $D
.endif
# An undefined variable without a comparison operator generates a parse error.
# expect+1: Variable "U" is undefined
.if $U
.endif
# If the value of the expression is a number, it is compared against
# zero.
.if ${:U0}
@@ -69,3 +99,30 @@ DEF= defined
.if !${:Uanything}
. error
.endif
.MAKEFLAGS: -dv
# The left-hand side of a comparison must not be an unquoted word.
# expect+1: Malformed conditional 'x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3}'
.if x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3}
.endif
# The left-hand side of a comparison must not be an unquoted word.
# expect+1: Malformed conditional 'x${DEF}y == "${UNDEF2}" || 0x${UNDEF3}'
.if x${DEF}y == "${UNDEF2}" || 0x${UNDEF3}
.endif
# The left-hand side of a comparison must not be an unquoted word.
# expect+1: Malformed conditional 'x${DEF}y == "${DEF}" || 0x${UNDEF3}'
.if x${DEF}y == "${DEF}" || 0x${UNDEF3}
.endif
# An expression in a condition must not be based on an undefined variable,
# but undefined variables may occur in the variable name or in modifiers.
#
# expect: Var_Parse: ${VAR.param$U} (eval-defined-loud)
# expect: Var_Parse: $U} (eval)
VAR.param= value of VAR.param
.if ${VAR.param$U}
.endif
.MAKEFLAGS: -d0
+3 -7
View File
@@ -1,10 +1,6 @@
make: "cond-undef-lint.mk" line 25: Variable "UNDEF" is undefined
make: "cond-undef-lint.mk" line 25: Malformed conditional (${UNDEF})
make: "cond-undef-lint.mk" line 43: Variable "UNDEF" is undefined
make: "cond-undef-lint.mk" line 43: Variable "VAR." is undefined
make: "cond-undef-lint.mk" line 43: Malformed conditional (${VAR.${UNDEF}})
make: "cond-undef-lint.mk" line 56: Variable "VAR.defined" is undefined
make: "cond-undef-lint.mk" line 56: Malformed conditional (${VAR.${DEF}})
make: "cond-undef-lint.mk" line 24: Variable "UNDEF" is undefined
make: "cond-undef-lint.mk" line 35: Variable "VAR." is undefined
make: "cond-undef-lint.mk" line 45: Variable "VAR.defined" is undefined
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
+5 -16
View File
@@ -1,4 +1,4 @@
# $NetBSD: cond-undef-lint.mk,v 1.4 2023/06/01 20:56:35 rillig Exp $
# $NetBSD: cond-undef-lint.mk,v 1.8 2025/01/11 21:21:33 rillig Exp $
#
# Tests for defined and undefined variables in .if conditions, in lint mode.
#
@@ -20,7 +20,6 @@ DEF= defined
.endif
# Since the condition fails to evaluate, neither of the branches is taken.
# expect+2: Malformed conditional (${UNDEF})
# expect+1: Variable "UNDEF" is undefined
.if ${UNDEF}
. error
@@ -32,27 +31,17 @@ DEF= defined
# mistake. The variable UNDEF, as used here, can be easily turned into
# an expression that is always defined, using the :U modifier.
#
# The outer expression does not generate an error message since there was
# already an error evaluating this variable's name.
#
# TODO: Suppress the error message "Variable VAR. is undefined". That part
# of the expression must not be evaluated at all.
# expect+3: Variable "UNDEF" is undefined
# expect+2: Variable "VAR." is undefined
# expect+1: Malformed conditional (${VAR.${UNDEF}})
# expect+1: Variable "VAR." is undefined
.if ${VAR.${UNDEF}}
. error
.else
. error
.endif
# The variable VAR.defined is not defined and thus generates an error message.
# The inner variable DEF is defined, but the resulting name VAR.defined
# refers to an undefined variable, thus an error message.
#
# TODO: This pattern looks a lot like CFLAGS.${OPSYS}, which is at least
# debatable. Or would any practical use of CFLAGS.${OPSYS} be via an indirect
# expression, as in the next example?
# expect+2: Variable "VAR.defined" is undefined
# expect+1: Malformed conditional (${VAR.${DEF}})
# expect+1: Variable "VAR.defined" is undefined
.if ${VAR.${DEF}}
. error
.else
+4 -4
View File
@@ -1,4 +1,4 @@
Var_Parse: ${UNDEF1} (eval-defined)
Var_Parse: ${UNDEF1} (eval)
Global: .ALLTARGETS = all
Global: .ALLTARGETS = all ${DEF2}
Global: .ALLTARGETS = all ${DEF2} a-${DEF2}-b
@@ -10,9 +10,9 @@ Global: INDIRECT_3 = indirect
Global: UNDEF1 = undef1
Global: DEF2 = def2
Global: .ALLTARGETS = all ${DEF2} a-${DEF2}-b ${UNDEF3} 1-${INDIRECT_1}-1 $$)
Var_Parse: ${:U\$)}: (eval-defined)
Evaluating modifier ${:U...} on value "" (eval-defined, undefined)
Result of ${:U\$)} is "$)" (eval-defined, defined)
Var_Parse: ${:U\$)}: (eval)
Evaluating modifier ${:U...} on value "" (eval, undefined)
Result of ${:U\$)} is "$)" (eval, defined)
Global: .ALLTARGETS = all ${DEF2} a-${DEF2}-b ${UNDEF3} 1-${INDIRECT_1}-1 $$) undef1
Global: .ALLTARGETS = all ${DEF2} a-${DEF2}-b ${UNDEF3} 1-${INDIRECT_1}-1 $$) undef1 def2
Global: .ALLTARGETS = all ${DEF2} a-${DEF2}-b ${UNDEF3} 1-${INDIRECT_1}-1 $$) undef1 def2 a-def2-b
+5 -15
View File
@@ -1,4 +1,4 @@
# $NetBSD: dep-var.mk,v 1.12 2024/06/02 15:31:26 rillig Exp $
# $NetBSD: dep-var.mk,v 1.13 2025/01/14 21:23:17 rillig Exp $
#
# Tests for variable references in dependency declarations.
#
@@ -7,10 +7,8 @@
.MAKEFLAGS: -dv
# expect: Var_Parse: ${UNDEF1} (eval-defined)
# Even though undefined expressions should lead to errors, no error message is
# generated for this line. The expression ${UNDEF1} simply expands
# to an empty string.
# In a dependency line, an undefined expressions expands to an empty string.
# expect: Var_Parse: ${UNDEF1} (eval)
all: ${UNDEF1}
# Using a double dollar in order to circumvent immediate expression expansion
@@ -21,11 +19,7 @@ all: ${UNDEF1}
# is defined, so everything's fine.
all: $${DEF2} a-$${DEF2}-b
# This variable is not defined at all.
# XXX: The -dv log says later when expanding the sources of 'all':
# Var_Parse: ${UNDEF3} (eval-defined)
# but no error message is generated for this line, just like for UNDEF1.
# The expression ${UNDEF3} simply expands to an empty string.
# This variable is neither defined now nor later.
all: $${UNDEF3}
# Try out how many levels of indirection are really expanded in dependency
@@ -83,14 +77,10 @@ all: $$$$)
# Since 2020-09-13, this generates a parse error in lint mode (-dL), but not
# in normal mode since ParseDependency does not handle any errors after
# calling Var_Parse.
# expect: Var_Parse: ${:U\$)}: (eval-defined)
# expect: Var_Parse: ${:U\$)}: (eval)
# expect: Var_Parse: $INDIRECT_2-2-1 $): (parse)
# expect: Var_Parse: $): (parse)
undef1 def2 a-def2-b 1-2-$$INDIRECT_2-2-1 ${:U\$)}:
@echo ${.TARGET:Q}
.MAKEFLAGS: -d0
# XXX: The exit status is still 0, even though Parse_Error is called with
# PARSE_FATAL in SuffExpandChildren. The exit status is only affected by
# parse errors when they occur in the parsing phase, see Parse_File.
+1 -1
View File
@@ -2,7 +2,7 @@ Global: ignoring delete 'DOLLAR' as it is not found
Command: DOLLAR = $$$$
Global: .MAKEOVERRIDES = VAR DOLLAR
CondParser_Eval: ${DOLLAR} != "\$\$"
Var_Parse: ${DOLLAR} != "\$\$" (eval-defined)
Var_Parse: ${DOLLAR} != "\$\$" (eval-defined-loud)
Comparing "$$" != "$$"
Global: .MAKEFLAGS = -r -k -D VAR -D VAR -d cv -d
Global: .MAKEFLAGS = -r -k -D VAR -D VAR -d cv -d 0
+2 -2
View File
@@ -1,9 +1,9 @@
Parsing line 15: .ORDER: three one
Parsing deptgt-order.mk:15: .ORDER: three one
ParseDependency(.ORDER: three one)
# .ORDER forces 'three' to be made before 'one'
# three, unmade, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS, flags none
# one, unmade, type OP_DEPENDS|OP_PHONY, flags none
Parsing line 16: .MAKEFLAGS: -d0
Parsing deptgt-order.mk:16: .MAKEFLAGS: -d0
ParseDependency(.MAKEFLAGS: -d0)
: 'Making two out of one.'
: 'Making three out of two.'
+18 -10
View File
@@ -1,18 +1,26 @@
make: "deptgt.mk" line 11: warning: Extra target '.PHONY' ignored
make: "deptgt.mk" line 30: Unassociated shell command ": command3 # parse error, since targets == NULL"
Parsing line 36: ${:U}: empty-source
Parsing deptgt.mk:36: ${:U}: empty-source
ParseDependency(: empty-source)
Parsing line 37: : command for empty targets list
Parsing line 38: : empty-source
Parsing deptgt.mk:37: : command for empty targets list
Parsing deptgt.mk:38: : empty-source
ParseDependency(: empty-source)
Parsing line 39: : command for empty targets list
Parsing line 40: .MAKEFLAGS: -d0
Parsing deptgt.mk:39: : command for empty targets list
Parsing deptgt.mk:40: .MAKEFLAGS: -d0
ParseDependency(.MAKEFLAGS: -d0)
make: "deptgt.mk" line 45: while evaluating "${:U:Z}:" with value "": Unknown modifier "Z"
make: "deptgt.mk" line 49: while parsing "${:U:Z}:": Unknown modifier "Z"
make: "deptgt.mk" line 52: warning: Extra target 'ordinary' ignored
make: "deptgt.mk" line 55: warning: Extra target (ordinary) ignored
make: "deptgt.mk" line 58: warning: Special and mundane targets don't mix. Mundane ones ignored
Var_Parse: ${UNDEF}: depsrc-${UNDEF} (eval)
Var_Parse: ${UNDEF} (eval)
Global: .ALLTARGETS = target1 target2 sources empty-source deptgt-
Global: .ALLTARGETS = target1 target2 sources empty-source deptgt- depsrc-
Global: .MAKEFLAGS = -r -k -d p -d 0 -d v -d
Global: .MAKEFLAGS = -r -k -d p -d 0 -d v -d 0
make: "deptgt.mk" line 51: Unknown modifier "Z"
while evaluating "${:U:Z}:" with value ""
make: "deptgt.mk" line 55: Unknown modifier "Z"
while parsing "${:U:Z}:"
make: "deptgt.mk" line 58: warning: Extra target 'ordinary' ignored
make: "deptgt.mk" line 61: warning: Extra target (ordinary) ignored
make: "deptgt.mk" line 64: warning: Special and mundane targets don't mix. Mundane ones ignored
make: Fatal errors encountered -- cannot continue
make: stopped making "target1" in unit-tests
exit status 1
+9 -3
View File
@@ -1,4 +1,4 @@
# $NetBSD: deptgt.mk,v 1.20 2024/07/06 10:14:35 rillig Exp $
# $NetBSD: deptgt.mk,v 1.22 2025/01/10 23:00:38 rillig Exp $
#
# Tests for special targets like .BEGIN or .SUFFIXES in dependency
# declarations.
@@ -39,13 +39,19 @@ ${:U}: empty-source
: command for empty targets list
.MAKEFLAGS: -d0
# An expression based on an undefined variable is allowed on both sides of
# the dependency declaration.
.MAKEFLAGS: -dv
deptgt-${UNDEF}: depsrc-${UNDEF}
.MAKEFLAGS: -d0
# In a dependency declaration, the whole line is expanded before interpreting
# the line.
# expect+1: while evaluating "${:U:Z}:" with value "": Unknown modifier "Z"
# expect+1: Unknown modifier "Z"
${:U:Z}:
# After expanding the line as a whole, each target is parsed but not
# evaluated, separately, in ParseDependencyTargetWord.
# expect+1: while parsing "${:U:Z}:": Unknown modifier "Z"
# expect+1: Unknown modifier "Z"
$${:U:Z}:
# expect+1: warning: Extra target 'ordinary' ignored
+19 -19
View File
@@ -1,19 +1,19 @@
Parsing line 21: UT_VAR= <${REF}>
Parsing directive-export-impl.mk:21: UT_VAR= <${REF}>
Global: UT_VAR = <${REF}>
Parsing line 28: .export UT_VAR
Parsing directive-export-impl.mk:28: .export UT_VAR
Global: .MAKE.EXPORTED = UT_VAR
Parsing line 32: : ${UT_VAR:N*}
Var_Parse: ${UT_VAR:N*} (eval-defined)
Var_Parse: ${REF}> (eval-defined)
Parsing directive-export-impl.mk:32: : ${UT_VAR:N*}
Var_Parse: ${UT_VAR:N*} (eval)
Var_Parse: ${REF}> (eval)
Evaluating modifier ${UT_VAR:N...} on value "<>"
Pattern for ':N' is "*"
ModifyWords: split "<>" into 1 word
Result of ${UT_VAR:N*} is ""
ParseDependency(: )
Parsing line 42: .if ${:!echo "\$UT_VAR"!} != "<>"
Parsing directive-export-impl.mk:42: .if ${:!echo "\$UT_VAR"!} != "<>"
CondParser_Eval: ${:!echo "\$UT_VAR"!} != "<>"
Var_Parse: ${:!echo "\$UT_VAR"!} != "<>" (eval-defined)
Evaluating modifier ${:!...} on value "" (eval-defined, undefined)
Var_Parse: ${:!echo "\$UT_VAR"!} != "<>" (eval-defined-loud)
Evaluating modifier ${:!...} on value "" (eval, undefined)
Modifier part: "echo "$UT_VAR""
Capturing the output of command "echo "$UT_VAR""
Var_Parse: ${.MAKE.EXPORTED:O:u} (eval)
@@ -23,22 +23,22 @@ Evaluating modifier ${.MAKE.EXPORTED:u} on value "UT_VAR"
Result of ${.MAKE.EXPORTED:u} is "UT_VAR"
Var_Parse: ${UT_VAR} (eval)
Var_Parse: ${REF}> (eval)
Result of ${:!echo "\$UT_VAR"!} is "<>" (eval-defined, defined)
Result of ${:!echo "\$UT_VAR"!} is "<>" (eval, defined)
Comparing "<>" != "<>"
Parsing line 50: : ${UT_VAR:N*}
Var_Parse: ${UT_VAR:N*} (eval-defined)
Var_Parse: ${REF}> (eval-defined)
Parsing directive-export-impl.mk:50: : ${UT_VAR:N*}
Var_Parse: ${UT_VAR:N*} (eval)
Var_Parse: ${REF}> (eval)
Evaluating modifier ${UT_VAR:N...} on value "<>"
Pattern for ':N' is "*"
ModifyWords: split "<>" into 1 word
Result of ${UT_VAR:N*} is ""
ParseDependency(: )
Parsing line 54: REF= defined
Parsing directive-export-impl.mk:54: REF= defined
Global: REF = defined
Parsing line 58: .if ${:!echo "\$UT_VAR"!} != "<defined>"
Parsing directive-export-impl.mk:58: .if ${:!echo "\$UT_VAR"!} != "<defined>"
CondParser_Eval: ${:!echo "\$UT_VAR"!} != "<defined>"
Var_Parse: ${:!echo "\$UT_VAR"!} != "<defined>" (eval-defined)
Evaluating modifier ${:!...} on value "" (eval-defined, undefined)
Var_Parse: ${:!echo "\$UT_VAR"!} != "<defined>" (eval-defined-loud)
Evaluating modifier ${:!...} on value "" (eval, undefined)
Modifier part: "echo "$UT_VAR""
Capturing the output of command "echo "$UT_VAR""
Var_Parse: ${.MAKE.EXPORTED:O:u} (eval)
@@ -48,12 +48,12 @@ Evaluating modifier ${.MAKE.EXPORTED:u} on value "UT_VAR"
Result of ${.MAKE.EXPORTED:u} is "UT_VAR"
Var_Parse: ${UT_VAR} (eval)
Var_Parse: ${REF}> (eval)
Result of ${:!echo "\$UT_VAR"!} is "<defined>" (eval-defined, defined)
Result of ${:!echo "\$UT_VAR"!} is "<defined>" (eval, defined)
Comparing "<defined>" != "<defined>"
Parsing line 62: all:
Parsing directive-export-impl.mk:62: all:
ParseDependency(all:)
Global: .ALLTARGETS = all
Parsing line 63: .MAKEFLAGS: -d0
Parsing directive-export-impl.mk:63: .MAKEFLAGS: -d0
ParseDependency(.MAKEFLAGS: -d0)
Global: .MAKEFLAGS = -r -k -d cpv -d
Global: .MAKEFLAGS = -r -k -d cpv -d 0

Some files were not shown because too many files have changed in this diff Show More