Skip to content

Commit 9bbb08f

Browse files
committed
Update share/mk files from bmake
Update to the latest makefiles etc from bmake. Mostly this just replaces sjg license with an SPDX tag. There are also some improvements to meta2deps* and optimizations to leverage POSIX shell features in some target scripts. Default isPOSIX_SHELL to ':' in sys.mk to enable these. Use :sh1 in M_type if possible. bsd.progs.mk has diverged too much to touch beyond making the SPDX tag update. Reviewed by: stevek Differential Revision: https://reviews.freebsd.org/D54150
1 parent cc1e4aa commit 9bbb08f

18 files changed

+232
-199
lines changed

share/mk/auto.obj.mk

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
# SPDX-License-Identifier: BSD-2-Clause
2-
#
3-
# $Id: auto.obj.mk,v 1.20 2025/05/17 15:29:55 sjg Exp $
1+
# $Id: auto.obj.mk,v 1.21 2025/08/09 22:42:24 sjg Exp $
42
#
53
# @(#) Copyright (c) 2004-2025, Simon J. Gerraty
64
#
7-
# This file is provided in the hope that it will
8-
# be of use. There is absolutely NO WARRANTY.
9-
# Permission to copy, redistribute or otherwise
10-
# use this file is hereby granted provided that
11-
# the above copyright notice and this notice are
12-
# left intact.
5+
# SPDX-License-Identifier: BSD-2-Clause
136
#
147
# Please send copies of changes and bug-fixes to:
158

share/mk/bsd.progs.mk

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
#
33
# @(#) Copyright (c) 2006, Simon J. Gerraty
44
#
5-
# This file is provided in the hope that it will
6-
# be of use. There is absolutely NO WARRANTY.
7-
# Permission to copy, redistribute or otherwise
8-
# use this file is hereby granted provided that
9-
# the above copyright notice and this notice are
10-
# left intact.
5+
# SPDX-License-Identifier: BSD-2-Clause
116
#
127
# Please send copies of changes and bug-fixes to:
138

share/mk/dirdeps-options.mk

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
# SPDX-License-Identifier: BSD-2-Clause
2-
#
3-
# $Id: dirdeps-options.mk,v 1.22 2024/02/17 17:26:57 sjg Exp $
1+
# $Id: dirdeps-options.mk,v 1.23 2025/08/09 22:42:24 sjg Exp $
42
#
53
# @(#) Copyright (c) 2018-2022, Simon J. Gerraty
64
#
7-
# This file is provided in the hope that it will
8-
# be of use. There is absolutely NO WARRANTY.
9-
# Permission to copy, redistribute or otherwise
10-
# use this file is hereby granted provided that
11-
# the above copyright notice and this notice are
12-
# left intact.
5+
# SPDX-License-Identifier: BSD-2-Clause
136
#
147
# Please send copies of changes and bug-fixes to:
158

share/mk/dirdeps-targets.mk

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
# SPDX-License-Identifier: BSD-2-Clause
1+
# $Id: dirdeps-targets.mk,v 1.29 2025/08/09 22:42:24 sjg Exp $
22
#
3-
# RCSid:
4-
# $Id: dirdeps-targets.mk,v 1.28 2024/10/19 00:47:38 sjg Exp $
3+
# @(#) Copyright (c) 2019-2020 Simon J. Gerraty
54
#
6-
# @(#) Copyright (c) 2019-2020 Simon J. Gerraty
5+
# SPDX-License-Identifier: BSD-2-Clause
76
#
8-
# This file is provided in the hope that it will
9-
# be of use. There is absolutely NO WARRANTY.
10-
# Permission to copy, redistribute or otherwise
11-
# use this file is hereby granted provided that
12-
# the above copyright notice and this notice are
13-
# left intact.
14-
#
15-
# Please send copies of changes and bug-fixes to:
16-
7+
# Please send copies of changes and bug-fixes to:
8+
179
#
1810

1911
##

share/mk/gendirdeps.mk

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# $Id: gendirdeps.mk,v 1.51 2025/01/05 01:16:19 sjg Exp $
1+
# $Id: gendirdeps.mk,v 1.54 2025/08/12 21:36:43 sjg Exp $
22

33
# SPDX-License-Identifier: BSD-2-Clause
44
#
5-
# Copyright (c) 2011-2020, Simon J. Gerraty
5+
# Copyright (c) 2011-2025, Simon J. Gerraty
66
# Copyright (c) 2010-2018, Juniper Networks, Inc.
77
# All rights reserved.
88
#
@@ -76,6 +76,12 @@
7676
#
7777
.MAIN: all
7878

79+
.if ${DEBUG_GENDIRDEPS:Uno:@m@${RELDIR:M$m}@} != ""
80+
_debug.gendirdeps = 1
81+
.else
82+
_debug.gendirdeps = 0
83+
.endif
84+
7985
# keep this simple
8086
.MAKE.MODE = compat
8187

@@ -108,6 +114,9 @@ META_FILES += ${META_XTRAS:N\*.meta}
108114
.endif
109115

110116
.if !empty(META_FILES)
117+
.if ${_debug.gendirdeps} && ${DEBUG_GENDIRDEPS:Mmeta*} != ""
118+
.info ${RELDIR}: META_FILES=${META_FILES}
119+
.endif
111120

112121
.if ${.MAKE.LEVEL} > 0 && !empty(GENDIRDEPS_FILTER)
113122
# so we can compare below
@@ -146,7 +155,7 @@ GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u
146155
META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
147156
META2DEPS := ${META2DEPS}
148157

149-
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" && ${DEBUG_GENDIRDEPS:Uno:Mmeta2d*} != ""
158+
.if ${_debug.gendirdeps} && ${DEBUG_GENDIRDEPS:Mmeta2d*} != ""
150159
_time = time
151160
_sh_x = sh -x
152161
_py_d = -ddd
@@ -260,7 +269,7 @@ dpadd_dir_list += ${f:H:tA}
260269
ddeps != cat ${ddep_list:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
261270
sed ${GENDIRDEPS_SEDCMDS}
262271

263-
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
272+
.if ${_debug.gendirdeps}
264273
.info ${RELDIR}: raw_dir_list='${dir_list}'
265274
.info ${RELDIR}: ddeps='${ddeps}'
266275
.endif
@@ -289,12 +298,13 @@ M2D_OBJROOTS := ${M2D_OBJROOTS:O:u:[-1..1]}
289298
# anything we use from an object dir other than ours
290299
# needs to be qualified with its .<machine> suffix
291300
# (we used the pseudo machine "host" for the HOST_TARGET).
292-
skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@}
301+
skip_ql = ${SRCTOP}* ${_objtops:@o@$o*@}
302+
M_ListToSkip ?= O:u:S,^,N,:ts:
293303
.for o in ${M2D_OBJROOTS:${skip_ql:${M_ListToSkip}}}
294304
# we need := so only skip_ql to this point applies
295305
ql.$o := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
296306
qualdir_list += ${ql.$o}
297-
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
307+
.if ${_debug.gendirdeps}
298308
.info ${RELDIR}: o=$o ${ql.$o qualdir_list:L:@v@$v=${$v}@}
299309
.endif
300310
skip_ql+= $o*
@@ -323,7 +333,7 @@ DIRDEPS += \
323333
GENDIRDEPS_FILTER_MASK += @CMNS
324334
DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:M[${GENDIRDEPS_FILTER_MASK:O:u:ts}]*:ts:}:C,//+,/,g:O:u}
325335

326-
.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
336+
.if ${_debug.gendirdeps}
327337
.info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS}
328338
.info ${RELDIR}: M2D_EXCLUDES=${M2D_EXCLUDES}
329339
.info ${RELDIR}: dir_list='${dir_list}'

share/mk/install-new.mk

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,41 @@
1-
# $Id: install-new.mk,v 1.3 2012/03/24 18:25:49 sjg Exp $
1+
# $Id: install-new.mk,v 1.9 2025/11/19 17:44:15 sjg Exp $
22
#
33
# @(#) Copyright (c) 2009, Simon J. Gerraty
44
#
5-
# This file is provided in the hope that it will
6-
# be of use. There is absolutely NO WARRANTY.
7-
# Permission to copy, redistribute or otherwise
8-
# use this file is hereby granted provided that
9-
# the above copyright notice and this notice are
10-
# left intact.
11-
#
5+
# SPDX-License-Identifier: BSD-2-Clause
6+
#
127
# Please send copies of changes and bug-fixes to:
138
149
#
1510

1611
.if !defined(InstallNew)
1712

18-
# copy if src and target are different making a backup if desired
19-
CmpCp= CmpCp() { \
13+
# How do we want CmpCpMv to do the final operation?
14+
# the backup (if any) will use the opposite.
15+
CPMV_OP ?= mv
16+
# clear this if not supported
17+
CPMV_f ?= -f
18+
19+
# copy/move if src and target are different making a backup if desired
20+
CmpCpMv= CmpCpMv() { \
2021
src=$$1 target=$$2 _bak=$$3; \
2122
if ! test -s $$target || ! cmp -s $$target $$src; then \
2223
trap "" 1 2 3 15; \
24+
case "/${CPMV_OP}" in */cp) bop=mv;; */mv) bop=cp;; esac; \
2325
if test -s $$target; then \
2426
if test "x$$_bak" != x; then \
2527
rm -f $$target$$_bak; \
26-
mv $$target $$target$$_bak; \
28+
$$bop ${CPMV_f} $$target $$target$$_bak; \
2729
else \
2830
rm -f $$target; \
2931
fi; \
3032
fi; \
31-
cp $$src $$target; \
32-
fi; }
33-
34-
# Replace the file if they are different and make a backup if desired
35-
CmpReplace= CmpReplace() { \
36-
src=$$1 target=$$2 _bak=$$3; \
37-
if ! test -s $$target || ! cmp -s $$target $$src; then \
38-
trap "" 1 2 3 15; \
39-
if test -s $$target; then \
40-
if test "x$$_bak" != x; then \
41-
rm -f $$target$$_bak; \
42-
cp -f $$target $$target$$_bak; \
43-
fi; \
44-
fi; \
45-
mv -f $$src $$target; \
33+
${CPMV_OP} ${CPMV_f} $$src $$target; \
4634
fi; }
4735

4836
# If the .new file is different, we want it.
4937
# Note: this function will work as is for *.new$RANDOM"
50-
InstallNew= ${CmpReplace}; InstallNew() { \
38+
InstallNew= ${CmpCpMv}; InstallNew() { \
5139
_t=-e; _bak=; \
5240
while :; do \
5341
case "$$1" in \
@@ -58,8 +46,12 @@ InstallNew= ${CmpReplace}; InstallNew() { \
5846
done; \
5947
for new in "$$@"; do \
6048
if test $$_t $$new; then \
61-
target=`expr $$new : '\(.*\).new'`; \
62-
CmpReplace $$new $$target $$_bak; \
49+
if ${isPOSIX_SHELL:Ufalse}; then \
50+
target=$${new%.new}; \
51+
else \
52+
target=`expr $$new : '\(.*\).new'`; \
53+
fi; \
54+
CmpCpMv $$new $$target $$_bak; \
6355
fi; \
6456
rm -f $$new; \
6557
done; :; }

share/mk/jobs.mk

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
# SPDX-License-Identifier: BSD-2-Clause
2-
#
3-
# $Id: jobs.mk,v 1.19 2025/02/03 21:18:44 sjg Exp $
1+
# $Id: jobs.mk,v 1.20 2025/08/09 22:42:24 sjg Exp $
42
#
53
# @(#) Copyright (c) 2012-2025, Simon J. Gerraty
64
#
7-
# This file is provided in the hope that it will
8-
# be of use. There is absolutely NO WARRANTY.
9-
# Permission to copy, redistribute or otherwise
10-
# use this file is hereby granted provided that
11-
# the above copyright notice and this notice are
12-
# left intact.
5+
# SPDX-License-Identifier: BSD-2-Clause
136
#
147
# Please send copies of changes and bug-fixes to:
158

share/mk/local.sys.env.mk

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,}
2222
# NskipFoo = ${Foo:${M_ListToSkip}}
2323
M_ListToSkip= O:u:ts::S,:,:N,g:S,^,N,
2424

25+
# :sh1 evaluates command only once and caches the result.
26+
.if ${MAKE_VERSION} < 20251111
27+
M_sh1 = sh
28+
.else
29+
M_sh1 = sh1
30+
.endif
31+
2532
# type should be a builtin in any sh since about 1980,
2633
# AUTOCONF := ${autoconf:L:${M_whence}}
27-
M_type = @x@(type $$x 2> /dev/null); echo;@:sh:[0]:N* found*:[@]:C,[()],,g
34+
M_type = @x@(type $$x 2> /dev/null); echo;@:${M_sh1:Ush}:[0]:N* found*:[@]:C,[()],,g
2835
M_whence = ${M_type}:M/*:[1]
2936

3037
# convert a path to a valid shell variable

0 commit comments

Comments
 (0)