aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2023-02-10 01:21:33 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2023-02-10 01:23:23 +0000
commitdc1b8c9a846e78a87789fe1473350c3260722148 (patch)
tree809c77aa488d8b937f4d0ae0cc40b85cb0f0027d /contrib/bmake
parentcd3193f640e26991d94d87a45ee9b6a953c56fb5 (diff)
parentf4d51098686d961fc03dc5aa327619d0af3c9dcd (diff)
downloadsrc-dc1b8c9a846e78a87789fe1473350c3260722148.tar.gz
src-dc1b8c9a846e78a87789fe1473350c3260722148.zip
Merge bmake-20230208
Merge commit 'f4d51098686d961fc03dc5aa327619d0af3c9dcd'
Diffstat (limited to 'contrib/bmake')
-rw-r--r--contrib/bmake/ChangeLog17
-rw-r--r--contrib/bmake/Makefile10
-rw-r--r--contrib/bmake/VERSION2
-rwxr-xr-xcontrib/bmake/install-sh59
-rw-r--r--contrib/bmake/mk/ChangeLog11
-rw-r--r--contrib/bmake/mk/autoconf.mk4
-rw-r--r--contrib/bmake/mk/install-mk13
-rw-r--r--contrib/bmake/mk/whats.mk4
-rw-r--r--contrib/bmake/unit-tests/varmod-remember.mk69
-rw-r--r--contrib/bmake/var.c6
10 files changed, 149 insertions, 46 deletions
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index d012520dc2bb..dc45a2e59274 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,20 @@
+2023-02-08 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION (_MAKE_VERSION): 20230208
+ Merge with NetBSD make, pick up
+ o var.c: always use SCOPE_GLOBAL for :_ to avoid problems
+ when it has been used within conditional expressions
+
+2023-01-27 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * VERSION (_MAKE_VERSION): 20230127
+
+ * install-sh: if making directories ensure umask is set
+ to match mode.
+
+ * Makefile: use DIRMODE for directories and
+ NONBINMODE for man pages and mk files
+
2023-01-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20230126
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index ad78883ff890..4ad9ac92b266 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,4 +1,4 @@
-# $Id: Makefile,v 1.122 2022/10/08 02:53:30 sjg Exp $
+# $Id: Makefile,v 1.123 2023/01/28 02:49:20 sjg Exp $
PROG= bmake
@@ -201,13 +201,13 @@ install: install-mk
.endif
beforeinstall:
- test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR}
- test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST}
+ test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${BINDIR}
+ test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${MANDEST}
install-mk:
.if exists(${MKSRC}/install-mk)
- test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK}
- sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK}
+ test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${SHARE_MK}
+ sh ${MKSRC}/install-mk -v -m ${NONBINMODE} ${DESTDIR}${SHARE_MK}
.else
@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
.endif
diff --git a/contrib/bmake/VERSION b/contrib/bmake/VERSION
index d57c71f1e797..4d0b127caf7c 100644
--- a/contrib/bmake/VERSION
+++ b/contrib/bmake/VERSION
@@ -1,2 +1,2 @@
# keep this compatible with sh and make
-_MAKE_VERSION=20230126
+_MAKE_VERSION=20230208
diff --git a/contrib/bmake/install-sh b/contrib/bmake/install-sh
index a2473298efcb..1f6720f661a1 100755
--- a/contrib/bmake/install-sh
+++ b/contrib/bmake/install-sh
@@ -49,13 +49,13 @@
# fail on many systems. We ignore '-b', '-B' and '-c' options.
#
# AUTHOR:
-# Simon J. Gerraty <sjg@quick.com.au>
+# Simon J. Gerraty <sjg@crufty.net>
#
# RCSid:
-# $Id: install-sh,v 1.18 2001/03/16 17:33:02 sjg Exp $
+# $Id: install-sh,v 1.22 2023/01/28 16:21:19 sjg Exp $
#
-# @(#) Copyright (c) 1993 Simon J. Gerraty
+# @(#) Copyright (c) 1993-2023 Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -65,7 +65,7 @@
# left intact.
#
# Please send copies of changes and bug-fixes to:
-# sjg@quick.com.au
+# sjg@crufty.net
#
set -- `getopt B:bpxCNcsdo:g:m:i:f: $*`
@@ -76,39 +76,41 @@ Mydir=`dirname $0`
owner=:
group=:
mode=:
+MODE=0
strip=:
mkdirs=
compare=:
newer=:
chflags=:
-LS1=
-CP_P=
+LS_1=
+CP_p=
-while [ $# -gt 1 ]
+while :
do
- case $1 in
+ case "$1" in
--) shift; break;;
- -p) CP_P=-p;;
+ -p) CP_p=-p;;
-x) set -x;;
-B) OLD_EXT=$2; shift;;
-C) compare=Different;;
-N) newer=Newer;
# check if /bin/ls supports -1
- /bin/ls -1 $0 >/dev/null 2>&1 && LS1=1
+ 'ls' -1 $0 > /dev/null 2>&1 && LS_1=1
;;
-o) owner="${CHOWN:-chown} $2 "; shift;;
-g) group="${CHGRP:-chgrp} $2 "; shift;;
- -m) mode="${CHMOD:-chmod} $2 "; shift;;
+ -m) MODE=$2 mode="${CHMOD:-chmod} $2 "; shift;;
-s) strip=${STRIP:-strip};;
-d) mkdirs="mkdir -p";;
-i) ignore_err="$ignore_err$2"; shift;;
-f) chflags="${CHFLAGS:-chflags} $2 "; shift;;
+ *) break;;
esac
shift
done
Newer() {
- n=`/bin/ls -t$LS1 $* 2>/dev/null | head -1`
+ n=`'ls' -t$LS_1 $* 2> /dev/null | head -1`
[ $1 = $n ]
}
@@ -132,7 +134,7 @@ Setem() {
$group $1 || Err g
$owner $1 || Err o
$mode $1 || Err m
- $chflags $1 || Err f
+ $chflags $1 || Err f
return 0
}
@@ -140,19 +142,40 @@ Setem() {
# after any calls to add_path()
args="$*"
-# all this just for chown!
-add_path () { [ -d $1 ] && eval ${2:-PATH}="\$${2:-PATH}:$1"; }
-add_path /etc
-add_path /usr/etc
+add_path () {
+ test -d $1 || return
+ case ":$PATH:" in
+ *:$1:*) return;;
+ esac
+ PATH=$PATH:$1
+}
+
add_path /sbin
add_path /usr/sbin
+case "$owner" in
+:) ;;
+*)
+ add_path /etc
+ add_path /usr/etc
+ ;;
+esac
+
# restore saved $*
set -- $args
# make directories if needed
# and ensure mode etc are as desired
if [ "$mkdirs" ]; then
+ case "$MODE" in
+ [1-7]*)
+ # make sure umask is compatible
+ case "$MODE" in
+ ????*) MODE=`echo $MODE | sed 's,.*\(...\)$,\1,'`;;
+ esac
+ umask `expr 0777 - 0$MODE |
+ sed 's,^,000,;s,^.*\(...\)$,\1,'`;;
+ esac
for d in $*
do
[ ! -d $d ] && $mkdirs $d
@@ -196,6 +219,6 @@ do
$newer $f $t || continue
$compare $f $t || continue
[ -f $t ] && { mv -f $t $t.old || exit 1; }
- { cp $CP_P $f $t && Setem $t; } || exit 1
+ { cp $CP_p $f $t && Setem $t; } || exit 1
done
exit 0
diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog
index 92606f6bfbe5..7e3bd1da6976 100644
--- a/contrib/bmake/mk/ChangeLog
+++ b/contrib/bmake/mk/ChangeLog
@@ -1,3 +1,14 @@
+2023-01-29 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * autoconf.mk: hook config.status to beforebuild.
+
+ * whats.mk: what*.c is NOTMAIN
+
+2023-01-27 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20230127
+ control umask so directories are created with suitable mode.
+
2023-01-20 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20230120
diff --git a/contrib/bmake/mk/autoconf.mk b/contrib/bmake/mk/autoconf.mk
index 6011a8af4df5..fb97e9d3f2f8 100644
--- a/contrib/bmake/mk/autoconf.mk
+++ b/contrib/bmake/mk/autoconf.mk
@@ -1,4 +1,4 @@
-# $Id: autoconf.mk,v 1.16 2021/10/19 17:36:06 sjg Exp $
+# $Id: autoconf.mk,v 1.17 2023/01/29 17:31:16 sjg Exp $
#
# @(#) Copyright (c) 1996-2009, Simon J. Gerraty
#
@@ -34,6 +34,8 @@ config.status: config.recheck
config.status: config.gen
.endif
+beforebuild: .NOTMAIN config.status
+
config.recheck: .NOTMAIN ${CONFIGURE_DEPS} config.gen
./config.status --recheck
@touch $@
diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk
index 51fb68b959a0..c3c868b75186 100644
--- a/contrib/bmake/mk/install-mk
+++ b/contrib/bmake/mk/install-mk
@@ -28,6 +28,10 @@
# -g "group"
# Use "group" for installed files.
#
+# -U "umask"
+# Use "umask" so directories are created with suitable
+# mode (default is 022).
+#
# var=val
# Set "var" to "val". See below.
#
@@ -55,9 +59,9 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.224 2023/01/20 17:34:06 sjg Exp $
+# $Id: install-mk,v 1.226 2023/01/28 16:52:12 sjg Exp $
#
-# @(#) Copyright (c) 1994 Simon J. Gerraty
+# @(#) Copyright (c) 1994-2023 Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -70,7 +74,7 @@
# sjg@crufty.net
#
-MK_VERSION=20230120
+MK_VERSION=20230127
OWNER=
GROUP=
MODE=444
@@ -79,6 +83,8 @@ ECHO=:
SKIP=
cp_f=-f
+umask 022
+
while :
do
case "$1" in
@@ -91,6 +97,7 @@ do
-v) ECHO=echo; shift;;
-q) ECHO=:; shift;;
-n) ECHO=echo SKIP=:; shift;;
+ -U) umask $2; shift;;
--) shift; break;;
*) break;;
esac
diff --git a/contrib/bmake/mk/whats.mk b/contrib/bmake/mk/whats.mk
index e10964463d4a..16086e54d924 100644
--- a/contrib/bmake/mk/whats.mk
+++ b/contrib/bmake/mk/whats.mk
@@ -1,4 +1,4 @@
-# $Id: whats.mk,v 1.10 2020/08/19 17:51:53 sjg Exp $
+# $Id: whats.mk,v 1.11 2023/01/29 17:29:13 sjg Exp $
#
# @(#) Copyright (c) 2014-2020, Simon J. Gerraty
#
@@ -55,7 +55,7 @@ what_location := ${WHAT_LOCATION}
# this script is done in multiple lines so we can
# use the token ${.OODATE:MNO_META_CMP}
# to prevent the variable parts making this constantly out-of-date
-${what_uuid}.c:
+${what_uuid}.c: .NOTMAIN
echo 'extern const char ${WHAT_LINE_IDS:@i@${what_var}_$i[]@:ts,};' > $@
.for i in ${WHAT_LINE_IDS}
.if ${WHAT_NOCMP_LINE_IDS:M$i} != ""
diff --git a/contrib/bmake/unit-tests/varmod-remember.mk b/contrib/bmake/unit-tests/varmod-remember.mk
index 403811759672..e92b2d2c4012 100644
--- a/contrib/bmake/unit-tests/varmod-remember.mk
+++ b/contrib/bmake/unit-tests/varmod-remember.mk
@@ -1,30 +1,62 @@
-# $NetBSD: varmod-remember.mk,v 1.6 2021/03/14 17:27:27 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.9 2023/02/09 22:21:57 rillig Exp $
#
-# Tests for the :_ modifier, which saves the current variable value
+# Tests for the :_ modifier, which saves the current expression value
# in the _ variable or another, to be used later again.
-.if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3"
+
+# The ':_' modifier is typically used in situations where the value of an
+# expression is needed at the same time as a sequence of numbers. In these
+# cases, the value of the expression is saved in the temporary variable '_',
+# from where it is taken later in the same expression.
+ABC= ${A B C:L:_:range:@i@$i=${_:[$i]}@}
+DEF= ${D E F:L:_:range:@i@$i=${_:[$i]}@}
+GHI= ${G H I:L:_:range:@i@$i=${_:[$i]}@}
+
+ABC.global:= ${ABC} # is evaluated in the global scope
+.if ${ABC.global} != "1=A 2=B 3=C"
+. error
+.endif
+
+.if ${DEF} != "1=D 2=E 3=F" # is evaluated in the command line scope
+. error
+.endif
+
+# Before var.c 1.1040 from 2023-02-09, the temporary variable '_' was placed
+# in the scope of the current evaluation, which meant that after the first
+# ':_' modifier had been evaluated in command line scope, all further
+# evaluations in global scope could not overwrite the variable '_' anymore,
+# as the command line scope takes precedence over the global scope.
+# The expression ${GHI} therefore evaluated to '1=D 2=E 3=F', reusing the
+# value of '_' from the previous evaluation in command line scope.
+GHI.global:= ${GHI} # is evaluated in the global scope
+.if ${GHI.global} != "1=G 2=H 3=I"
. error
.endif
+
# In the parameterized form, having the variable name on the right side of
-# the = assignment operator is confusing. In almost all other situations
-# the variable name is on the left-hand side of the = operator. Luckily
-# this modifier is only rarely needed.
+# the = assignment operator looks confusing. In almost all other situations,
+# the variable name is on the left-hand side of the = operator, therefore
+# '_=SAVED' looks like it would copy 'SAVED' to '_'. Luckily, this modifier
+# is only rarely needed.
.if ${1 2 3:L:@var@${var:_=SAVED:}@} != "1 2 3"
. error
.elif ${SAVED} != "3"
. error
.endif
-# The ':_' modifier takes a variable name as optional argument. This variable
-# name can refer to other variables, though this was rather an implementation
-# oversight than an intended feature. The variable name stops at the first
-# '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable
-# names.
+
+# The ':_' modifier takes a variable name as optional argument. Before var.c
+# 1.867 from 2021-03-14, this variable name could refer to other variables,
+# such as in 'VAR.$p'. It was not possible to refer to 'VAR.${param}' though,
+# as that form caused a parse error. The cause for the parse error in
+# '${...:_=VAR.${param}}' is that the variable name is parsed in an ad-hoc
+# manner, stopping at the first ':', ')' or '}', without taking any nested
+# expressions into account. Due to this inconsistency that short expressions
+# are possible but long expressions aren't, the name of the temporary variable
+# is no longer expanded.
#
-# Because of all these edge-casey conditions, this "feature" has been removed
-# in var.c 1.867 from 2021-03-14.
+# TODO: Warn about the unusual variable name '$S'.
S= INDIRECT_VARNAME
.if ${value:L:@var@${var:_=$S}@} != "value"
. error
@@ -32,4 +64,15 @@ S= INDIRECT_VARNAME
. error
.endif
+
+# When a variable using ':_' refers to another variable that also uses ':_',
+# the value of the temporary variable '_' from the inner expression leaks into
+# the evaluation of the outer expression. If the expressions were evaluated
+# independently, the last word of the result would be outer_='outer' instead.
+INNER= ${inner:L:_:@i@$i inner_='$_'@}
+OUTER= ${outer:L:_:@o@$o ${INNER} outer_='$_'@}
+.if ${OUTER} != "outer inner inner_='inner' outer_='inner'"
+.endif
+
+
all:
diff --git a/contrib/bmake/var.c b/contrib/bmake/var.c
index 9657f4b7fa18..a938cefcfd1b 100644
--- a/contrib/bmake/var.c
+++ b/contrib/bmake/var.c
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1039 2023/01/26 20:48:17 sjg Exp $ */
+/* $NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -147,7 +147,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1039 2023/01/26 20:48:17 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -3586,7 +3586,7 @@ ApplyModifier_Remember(const char **pp, ModChain *ch)
*pp = mod + 1;
if (Expr_ShouldEval(expr))
- Var_Set(expr->scope, name.str, Expr_Str(expr));
+ Var_Set(SCOPE_GLOBAL, name.str, Expr_Str(expr));
FStr_Done(&name);
return AMR_OK;