Merge bmake-20230208

Merge commit 'f4d51098686d961fc03dc5aa327619d0af3c9dcd'
This commit is contained in:
Simon J. Gerraty 2023-02-09 17:21:33 -08:00
commit dc1b8c9a84
12 changed files with 151 additions and 48 deletions

View file

@ -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> 2023-01-26 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20230126 * VERSION (_MAKE_VERSION): 20230126

View file

@ -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 PROG= bmake
@ -201,13 +201,13 @@ install: install-mk
.endif .endif
beforeinstall: beforeinstall:
test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m 775 -d ${DESTDIR}${BINDIR} test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${BINDIR}
test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m 775 -d ${DESTDIR}${MANDEST} test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${MANDEST}
install-mk: install-mk:
.if exists(${MKSRC}/install-mk) .if exists(${MKSRC}/install-mk)
test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m 775 -d ${DESTDIR}${SHARE_MK} test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${SHARE_MK}
sh ${MKSRC}/install-mk -v -m 644 ${DESTDIR}${SHARE_MK} sh ${MKSRC}/install-mk -v -m ${NONBINMODE} ${DESTDIR}${SHARE_MK}
.else .else
@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false @echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
.endif .endif

View file

@ -1,2 +1,2 @@
# keep this compatible with sh and make # keep this compatible with sh and make
_MAKE_VERSION=20230126 _MAKE_VERSION=20230208

View file

@ -49,13 +49,13 @@
# fail on many systems. We ignore '-b', '-B' and '-c' options. # fail on many systems. We ignore '-b', '-B' and '-c' options.
# #
# AUTHOR: # AUTHOR:
# Simon J. Gerraty <sjg@quick.com.au> # Simon J. Gerraty <sjg@crufty.net>
# #
# RCSid: # 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 # This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY. # be of use. There is absolutely NO WARRANTY.
@ -65,7 +65,7 @@
# left intact. # left intact.
# #
# Please send copies of changes and bug-fixes to: # Please send copies of changes and bug-fixes to:
# sjg@quick.com.au # sjg@crufty.net
# #
set -- `getopt B:bpxCNcsdo:g:m:i:f: $*` set -- `getopt B:bpxCNcsdo:g:m:i:f: $*`
@ -76,39 +76,41 @@ Mydir=`dirname $0`
owner=: owner=:
group=: group=:
mode=: mode=:
MODE=0
strip=: strip=:
mkdirs= mkdirs=
compare=: compare=:
newer=: newer=:
chflags=: chflags=:
LS1= LS_1=
CP_P= CP_p=
while [ $# -gt 1 ] while :
do do
case $1 in case "$1" in
--) shift; break;; --) shift; break;;
-p) CP_P=-p;; -p) CP_p=-p;;
-x) set -x;; -x) set -x;;
-B) OLD_EXT=$2; shift;; -B) OLD_EXT=$2; shift;;
-C) compare=Different;; -C) compare=Different;;
-N) newer=Newer; -N) newer=Newer;
# check if /bin/ls supports -1 # 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;; -o) owner="${CHOWN:-chown} $2 "; shift;;
-g) group="${CHGRP:-chgrp} $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};; -s) strip=${STRIP:-strip};;
-d) mkdirs="mkdir -p";; -d) mkdirs="mkdir -p";;
-i) ignore_err="$ignore_err$2"; shift;; -i) ignore_err="$ignore_err$2"; shift;;
-f) chflags="${CHFLAGS:-chflags} $2 "; shift;; -f) chflags="${CHFLAGS:-chflags} $2 "; shift;;
*) break;;
esac esac
shift shift
done done
Newer() { Newer() {
n=`/bin/ls -t$LS1 $* 2>/dev/null | head -1` n=`'ls' -t$LS_1 $* 2> /dev/null | head -1`
[ $1 = $n ] [ $1 = $n ]
} }
@ -132,7 +134,7 @@ Setem() {
$group $1 || Err g $group $1 || Err g
$owner $1 || Err o $owner $1 || Err o
$mode $1 || Err m $mode $1 || Err m
$chflags $1 || Err f $chflags $1 || Err f
return 0 return 0
} }
@ -140,19 +142,40 @@ Setem() {
# after any calls to add_path() # after any calls to add_path()
args="$*" args="$*"
# all this just for chown! add_path () {
add_path () { [ -d $1 ] && eval ${2:-PATH}="\$${2:-PATH}:$1"; } test -d $1 || return
add_path /etc case ":$PATH:" in
add_path /usr/etc *:$1:*) return;;
esac
PATH=$PATH:$1
}
add_path /sbin add_path /sbin
add_path /usr/sbin add_path /usr/sbin
case "$owner" in
:) ;;
*)
add_path /etc
add_path /usr/etc
;;
esac
# restore saved $* # restore saved $*
set -- $args set -- $args
# make directories if needed # make directories if needed
# and ensure mode etc are as desired # and ensure mode etc are as desired
if [ "$mkdirs" ]; then 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 $* for d in $*
do do
[ ! -d $d ] && $mkdirs $d [ ! -d $d ] && $mkdirs $d
@ -196,6 +219,6 @@ do
$newer $f $t || continue $newer $f $t || continue
$compare $f $t || continue $compare $f $t || continue
[ -f $t ] && { mv -f $t $t.old || exit 1; } [ -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 done
exit 0 exit 0

View file

@ -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> 2023-01-20 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20230120 * install-mk (MK_VERSION): 20230120

View file

@ -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 # @(#) Copyright (c) 1996-2009, Simon J. Gerraty
# #
@ -34,6 +34,8 @@ config.status: config.recheck
config.status: config.gen config.status: config.gen
.endif .endif
beforebuild: .NOTMAIN config.status
config.recheck: .NOTMAIN ${CONFIGURE_DEPS} config.gen config.recheck: .NOTMAIN ${CONFIGURE_DEPS} config.gen
./config.status --recheck ./config.status --recheck
@touch $@ @touch $@

View file

@ -28,6 +28,10 @@
# -g "group" # -g "group"
# Use "group" for installed files. # Use "group" for installed files.
# #
# -U "umask"
# Use "umask" so directories are created with suitable
# mode (default is 022).
#
# var=val # var=val
# Set "var" to "val". See below. # Set "var" to "val". See below.
# #
@ -55,9 +59,9 @@
# Simon J. Gerraty <sjg@crufty.net> # Simon J. Gerraty <sjg@crufty.net>
# RCSid: # 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 # This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY. # be of use. There is absolutely NO WARRANTY.
@ -70,7 +74,7 @@
# sjg@crufty.net # sjg@crufty.net
# #
MK_VERSION=20230120 MK_VERSION=20230127
OWNER= OWNER=
GROUP= GROUP=
MODE=444 MODE=444
@ -79,6 +83,8 @@ ECHO=:
SKIP= SKIP=
cp_f=-f cp_f=-f
umask 022
while : while :
do do
case "$1" in case "$1" in
@ -91,6 +97,7 @@ do
-v) ECHO=echo; shift;; -v) ECHO=echo; shift;;
-q) ECHO=:; shift;; -q) ECHO=:; shift;;
-n) ECHO=echo SKIP=:; shift;; -n) ECHO=echo SKIP=:; shift;;
-U) umask $2; shift;;
--) shift; break;; --) shift; break;;
*) break;; *) break;;
esac esac

View file

@ -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 # @(#) 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 # this script is done in multiple lines so we can
# use the token ${.OODATE:MNO_META_CMP} # use the token ${.OODATE:MNO_META_CMP}
# to prevent the variable parts making this constantly out-of-date # 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,};' > $@ echo 'extern const char ${WHAT_LINE_IDS:@i@${what_var}_$i[]@:ts,};' > $@
.for i in ${WHAT_LINE_IDS} .for i in ${WHAT_LINE_IDS}
.if ${WHAT_NOCMP_LINE_IDS:M$i} != "" .if ${WHAT_NOCMP_LINE_IDS:M$i} != ""

View file

@ -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. # 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 . error
.endif .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 # In the parameterized form, having the variable name on the right side of
# the = assignment operator is confusing. In almost all other situations # the = assignment operator looks confusing. In almost all other situations,
# the variable name is on the left-hand side of the = operator. Luckily # the variable name is on the left-hand side of the = operator, therefore
# this modifier is only rarely needed. # '_=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" .if ${1 2 3:L:@var@${var:_=SAVED:}@} != "1 2 3"
. error . error
.elif ${SAVED} != "3" .elif ${SAVED} != "3"
. error . error
.endif .endif
# The ':_' modifier takes a variable name as optional argument. This variable
# name can refer to other variables, though this was rather an implementation # The ':_' modifier takes a variable name as optional argument. Before var.c
# oversight than an intended feature. The variable name stops at the first # 1.867 from 2021-03-14, this variable name could refer to other variables,
# '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable # such as in 'VAR.$p'. It was not possible to refer to 'VAR.${param}' though,
# names. # 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 # TODO: Warn about the unusual variable name '$S'.
# in var.c 1.867 from 2021-03-14.
S= INDIRECT_VARNAME S= INDIRECT_VARNAME
.if ${value:L:@var@${var:_=$S}@} != "value" .if ${value:L:@var@${var:_=$S}@} != "value"
. error . error
@ -32,4 +64,15 @@ S= INDIRECT_VARNAME
. error . error
.endif .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: all:

View file

@ -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 * Copyright (c) 1988, 1989, 1990, 1993
@ -147,7 +147,7 @@
#include "metachar.h" #include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ /* "@(#)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 * 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; *pp = mod + 1;
if (Expr_ShouldEval(expr)) 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); FStr_Done(&name);
return AMR_OK; return AMR_OK;

View file

@ -12,7 +12,7 @@ CFLAGS+= -I${.CURDIR}
CLEANDIRS+= FreeBSD CLEANDIRS+= FreeBSD
CLEANFILES+= bootstrap CLEANFILES+= bootstrap
# $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?= ${.CURDIR:T} PROG?= ${.CURDIR:T}

View file

@ -7,7 +7,7 @@ SRCTOP?= ${.CURDIR:H:H}
# things set by configure # things set by configure
_MAKE_VERSION?=20230126 _MAKE_VERSION?=20230208
prefix?= /usr prefix?= /usr
srcdir= ${SRCTOP}/contrib/bmake srcdir= ${SRCTOP}/contrib/bmake