aboutsummaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2025-06-28 02:38:49 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2025-06-28 02:38:49 +0000
commit4f8f2bc2946615330eaa2cc1f6b37d97865fa58a (patch)
treeaa7729a97d1faeb358c9d981caadfad466f997a7 /mk
parent284d1f7d496806b18558ab55e4654fd5e96d6a3e (diff)
Import bmake-20250618vendor/NetBSD/bmake/20250618
Intersting/relevant changes since bmake-20250414 ChangeLog since bmake-20250414 2025-06-18 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250618 Merge with NetBSD make, pick up o parse.c: in a warning without location information, print the stack trace 2025-06-15 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250615 Merge with NetBSD make, pick up o add on-demand inter-process stack traces o job.c,meta.c: do not discard empty lines in the output of a command o job.c: add job prefix if necessary in non-default filtered mode o parse.c,var.c: skip inter-process stack trace when MAKE_STACK_TRACE=no 2025-06-12 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250612 Merge with NetBSD make, pick up o use a common style for unexpected error messages o parse.c: add program name to stack traces from sub-makes add quotes to "in directory" line in stack traces o var.c: check variable names for invalid characters when there are no modifiers to apply. This detects and warns about gmake syntax like: $(addprefix -I, $(LIST)) 2025-06-09 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250606 Merge with NetBSD make, pick up o main.c: fix bug in handling of output of children in jobs mode 2025-05-28 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250528 Merge with NetBSD make, pick up o show contents of MAKEFLAGS in the stack trace. o main.c: delay warning about bogus -J flag, if we end up in compat mode before the call to InitMaxJobs, the warning isn't necessary. 2025-05-25 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250525 Merge with NetBSD make, pick up o main.c: set .CURDIR earlier so it can be reported in some errors. 2025-05-20 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250520 Merge with NetBSD make, pick up o rename variables, remove now-redundant comments o job.c: clean up building the shell commands in parallel mode remove timeout for polling in parallel mode o main.c: clean up error message for malformed internal -J option 2025-05-11 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250511 Merge with NetBSD make, pick up o job.c: rename token pool variables to be more descriptive move ContinueJobs further up, to eliminate a forward declaration error out if writing to an internal pipe fails clean up constant names and function names use uniform debug log messages for the token pool in the debug log, replace magic numbers with identifiers o main.c: clean up error message for malformed internal -J option o make.c: replace bitset in trace output with descriptive node attributes o targ.c: add end marker for -dg1, -dg2 and -dg3 debug log o var.c: fix order of error messages in the ":?" modifier 2025-04-25 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250424 Merge with NetBSD make, pick up o cleanup; replace unsigned int with just unsigned Inline the TMPPAT macro, as it is only needed in a single place o move struct Job from job.h to job.c o job.c: group the code for handling the job token pool avoid excessive values of -j o make.c: fix grammar in debug log message mk/ChangeLog since bmake-20250414 2025-05-28 Simon J Gerraty <sjg@beast.crufty.net> * install-mk (MK_VERSION): 20250528 * add dirdeps2dplibs.mk 2025-05-18 Simon J Gerraty <sjg@beast.crufty.net> * install-mk (MK_VERSION): 20250518 * meta.autodep.mk (META_FILES): re-work to fix filtering. if OPTIMIZE_OBJECT_META_FILES==yes provide a default META_FILE_OBJ_FILTER that selects a valid .SUFFIX to match *o.meta, there's no guarantee that it will be as simple as .o or .So etc. We have to defer evaluation until the target script is run for any of these filters to have any effect. Use :S,${.OBJDIR}/,, rather than :T incase there are objects in sub-dirs. * lib.mk: leverage ${.SUFFIXES} when setting dependencies. * add UPDATE_DEPENDFILE as a dependent option - follows DIRDEPS_BUILD and use MK_UPDATE_DEPENDFILE as default for UPDATE_DEPENDFILE when we think it should be yes. This allows override with -DWITH[OUT]_UPDATE_DEPENDFILE without overriding UPDATE_DEPENDFILE directly - which can lead to trouble. 2025-05-16 Simon J Gerraty <sjg@beast.crufty.net> * install-mk (MK_VERSION): 20250515 * meta2deps.py: resolve the target of a Move or Link first and track the last path resolved, then if the src is a relative path we can easily use that last path to resolve the src correctly. * meta2deps.sh: for a Move or Link add the dir of target path to the list used to resolve the src path.
Diffstat (limited to 'mk')
-rw-r--r--mk/ChangeLog40
-rw-r--r--mk/FILES29
-rw-r--r--mk/auto.obj.mk4
-rw-r--r--mk/dirdeps2dplibs.mk35
-rw-r--r--mk/gendirdeps.mk21
-rw-r--r--[-rwxr-xr-x]mk/install-mk4
-rw-r--r--mk/lib.mk4
-rw-r--r--mk/libs.mk4
-rw-r--r--mk/meta.autodep.mk55
-rwxr-xr-xmk/meta2deps.py23
-rwxr-xr-xmk/meta2deps.sh16
-rw-r--r--mk/mkopt.sh9
-rwxr-xr-xmk/newlog.sh64
-rw-r--r--mk/progs.mk4
-rw-r--r--mk/setopts.sh20
-rw-r--r--mk/sys.mk3
16 files changed, 236 insertions, 99 deletions
diff --git a/mk/ChangeLog b/mk/ChangeLog
index c457d3aab9c2..1822f917a138 100644
--- a/mk/ChangeLog
+++ b/mk/ChangeLog
@@ -1,3 +1,43 @@
+2025-05-28 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20250528
+
+ * add dirdeps2dplibs.mk
+
+2025-05-18 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20250518
+
+ * meta.autodep.mk (META_FILES): re-work to fix filtering.
+ if OPTIMIZE_OBJECT_META_FILES==yes
+ provide a default META_FILE_OBJ_FILTER that selects a valid
+ .SUFFIX to match *o.meta, there's no guarantee that it will be as
+ simple as .o or .So etc.
+ We have to defer evaluation until the target script is run
+ for any of these filters to have any effect.
+ Use :S,${.OBJDIR}/,, rather than :T incase there are objects
+ in sub-dirs.
+
+ * lib.mk: leverage ${.SUFFIXES} when setting dependencies.
+
+ * add UPDATE_DEPENDFILE as a dependent option - follows
+ DIRDEPS_BUILD and use MK_UPDATE_DEPENDFILE as default for
+ UPDATE_DEPENDFILE when we think it should be yes.
+ This allows override with -DWITH[OUT]_UPDATE_DEPENDFILE
+ without overriding UPDATE_DEPENDFILE directly - which can lead to
+ trouble.
+
+2025-05-16 Simon J Gerraty <sjg@beast.crufty.net>
+
+ * install-mk (MK_VERSION): 20250515
+
+ * meta2deps.py: resolve the target of a Move or Link first
+ and track the last path resolved, then if the src is a relative
+ path we can easily use that last path to resolve the src correctly.
+
+ * meta2deps.sh: for a Move or Link add the dir of target path to
+ the list used to resolve the src path.
+
2025-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* init.mk: include Skipping ${RELDIR} when _SKIP_BUILD is not empty.
diff --git a/mk/FILES b/mk/FILES
index 85d8b15dbd44..d036d017c9ce 100644
--- a/mk/FILES
+++ b/mk/FILES
@@ -2,25 +2,32 @@ ChangeLog
FILES
LICENSE
README
+auto.dep.mk
auto.obj.mk
autoconf.mk
autodep.mk
-auto.dep.mk
cc-wrap.mk
ccm.dep.mk
compiler.mk
cython.mk
dep.mk
+dirdeps-cache-update.mk
+dirdeps-options.mk
+dirdeps-targets.mk
+dirdeps.mk
+dirdeps2dplibs.mk
doc.mk
dpadd.mk
files.mk
final.mk
+gendirdeps.mk
genfiles.mk
host-target.mk
host.libnames.mk
inc.mk
init.mk
install-mk
+install-new.mk
install-sh
java.mk
jobs.mk
@@ -31,6 +38,12 @@ libs.mk
links.mk
man.mk
manifest.mk
+meta.autodep.mk
+meta.stage.mk
+meta.subdir.mk
+meta.sys.mk
+meta2deps.py
+meta2deps.sh
mk-files.txt
mkopt.sh
newlog.sh
@@ -50,11 +63,11 @@ srctop.mk
stage-install.sh
subdir.mk
suffixes.mk
-sys.mk
sys.clean-env.mk
sys.debug.mk
sys.dependfile.mk
sys.dirdeps.mk
+sys.mk
sys.vars.mk
sys/AIX.mk
sys/Cygwin.mk
@@ -73,15 +86,3 @@ target-flags.mk
warnings.mk
whats.mk
yacc.mk
-dirdeps.mk
-dirdeps-cache-update.mk
-dirdeps-options.mk
-dirdeps-targets.mk
-gendirdeps.mk
-install-new.mk
-meta2deps.py
-meta2deps.sh
-meta.sys.mk
-meta.autodep.mk
-meta.stage.mk
-meta.subdir.mk
diff --git a/mk/auto.obj.mk b/mk/auto.obj.mk
index 9ae7ebe3af56..4b8c5325b71f 100644
--- a/mk/auto.obj.mk
+++ b/mk/auto.obj.mk
@@ -1,8 +1,8 @@
# SPDX-License-Identifier: BSD-2-Clause
#
-# $Id: auto.obj.mk,v 1.19 2025/03/27 15:51:06 sjg Exp $
+# $Id: auto.obj.mk,v 1.20 2025/05/17 15:29:55 sjg Exp $
#
-# @(#) Copyright (c) 2004, Simon J. Gerraty
+# @(#) Copyright (c) 2004-2025, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
diff --git a/mk/dirdeps2dplibs.mk b/mk/dirdeps2dplibs.mk
new file mode 100644
index 000000000000..cecf70be7477
--- /dev/null
+++ b/mk/dirdeps2dplibs.mk
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# $Id: dirdeps2dplibs.mk,v 1.3 2025/05/29 18:32:53 sjg Exp $
+
+# DIRDEPS generally reflects things *actually used* by RELDIR.
+# dirdeps2dplibs allows us to turn DIRDEPS into a DPLIBS list
+# The order will however be sorted, so some
+# manual tweaking may be needed.
+#
+
+dirdeps2dplibs:
+
+.if ${.MAKE.LEVEL} > 0
+# for customization
+.-include <local.dirdeps2dplibs.mk>
+
+_DEPENDFILE ?= ${.MAKE.DEPENDFILE}
+
+.dinclude "${_DEPENDFILE}"
+
+INCS_DIRS += h include incs
+DIRDEPS2DPLIBS_FILTER += C;/(${INCS_DIRS:O:u:ts|})(\.common.*)*$$;;
+
+dirdeps2dplibs:
+ @echo
+.if ${DEBUG_DIRDEPS2DPLIBS:Uno:@x@${RELDIR:M$x}@} != ""
+ @echo "# DIRDEPS=${DIRDEPS:M*lib*}"
+.endif
+ @echo -n 'DPLIBS += \'; \
+ echo '${DIRDEPS:M*lib*:${DIRDEPS2DPLIBS_FILTER:ts:}:T:O:u:tu:@d@${.newline}${.tab}_{LIB${d:S,^LIB,,}} \\@}' | \
+ sed 's,_{,$${,g'; \
+ echo
+
+
+.endif
diff --git a/mk/gendirdeps.mk b/mk/gendirdeps.mk
index 53e736da3391..b52c9ca0eba3 100644
--- a/mk/gendirdeps.mk
+++ b/mk/gendirdeps.mk
@@ -1,8 +1,8 @@
-# $Id: gendirdeps.mk,v 1.51 2025/01/05 01:16:19 sjg Exp $
+# $Id: gendirdeps.mk,v 1.53 2025/05/20 17:42:49 sjg Exp $
# SPDX-License-Identifier: BSD-2-Clause
#
-# Copyright (c) 2011-2020, Simon J. Gerraty
+# Copyright (c) 2011-2025, Simon J. Gerraty
# Copyright (c) 2010-2018, Juniper Networks, Inc.
# All rights reserved.
#
@@ -76,6 +76,12 @@
#
.MAIN: all
+.if ${DEBUG_GENDIRDEPS:Uno:@m@${RELDIR:M$m}@} != ""
+_debug.gendirdeps = 1
+.else
+_debug.gendirdeps = 0
+.endif
+
# keep this simple
.MAKE.MODE = compat
@@ -108,6 +114,9 @@ META_FILES += ${META_XTRAS:N\*.meta}
.endif
.if !empty(META_FILES)
+.if ${_debug.gendirdeps} && ${DEBUG_GENDIRDEPS:Mmeta*} != ""
+.info ${RELDIR}: META_FILES=${META_FILES}
+.endif
.if ${.MAKE.LEVEL} > 0 && !empty(GENDIRDEPS_FILTER)
# so we can compare below
@@ -146,7 +155,7 @@ GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u
META2DEPS ?= ${.PARSEDIR}/meta2deps.sh
META2DEPS := ${META2DEPS}
-.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" && ${DEBUG_GENDIRDEPS:Uno:Mmeta2d*} != ""
+.if ${_debug.gendirdeps} && ${DEBUG_GENDIRDEPS:Mmeta2d*} != ""
_time = time
_sh_x = sh -x
_py_d = -ddd
@@ -260,7 +269,7 @@ dpadd_dir_list += ${f:H:tA}
ddeps != cat ${ddep_list:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \
sed ${GENDIRDEPS_SEDCMDS}
-.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
+.if ${_debug.gendirdeps}
.info ${RELDIR}: raw_dir_list='${dir_list}'
.info ${RELDIR}: ddeps='${ddeps}'
.endif
@@ -294,7 +303,7 @@ skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@}
# we need := so only skip_ql to this point applies
ql.$o := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,}
qualdir_list += ${ql.$o}
-.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
+.if ${_debug.gendirdeps}
.info ${RELDIR}: o=$o ${ql.$o qualdir_list:L:@v@$v=${$v}@}
.endif
skip_ql+= $o*
@@ -323,7 +332,7 @@ DIRDEPS += \
GENDIRDEPS_FILTER_MASK += @CMNS
DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:M[${GENDIRDEPS_FILTER_MASK:O:u:ts}]*:ts:}:C,//+,/,g:O:u}
-.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != ""
+.if ${_debug.gendirdeps}
.info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS}
.info ${RELDIR}: M2D_EXCLUDES=${M2D_EXCLUDES}
.info ${RELDIR}: dir_list='${dir_list}'
diff --git a/mk/install-mk b/mk/install-mk
index de5056a37042..8d354de17cb9 100755..100644
--- a/mk/install-mk
+++ b/mk/install-mk
@@ -59,7 +59,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.264 2025/03/26 18:30:18 sjg Exp $
+# $Id: install-mk,v 1.266 2025/05/29 01:48:06 sjg Exp $
#
# @(#) Copyright (c) 1994-2025 Simon J. Gerraty
#
@@ -74,7 +74,7 @@
# sjg@crufty.net
#
-MK_VERSION=20250326
+MK_VERSION=20250528
OWNER=
GROUP=
MODE=444
diff --git a/mk/lib.mk b/mk/lib.mk
index 3f6a749a12d1..708a2a1994cc 100644
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -1,4 +1,4 @@
-# $Id: lib.mk,v 1.85 2024/12/12 19:56:36 sjg Exp $
+# $Id: lib.mk,v 1.86 2025/05/20 17:19:37 sjg Exp $
# should be set properly in sys.mk
_this ?= ${.PARSEFILE:S,bsd.,,}
@@ -396,7 +396,7 @@ realbuild: ${_LIBS}
all: _SUBDIRUSE
.for s in ${SRCS:${OBJS_SRCS_PRE_FILTER:ts:}:M*/*}
-${.o .po .lo:L:@o@${s:${OBJS_SRCS_FILTER:ts:}}$o@}: $s
+${.SUFFIXES:U.o .po .lo:M*o:@o@${s:${OBJS_SRCS_FILTER:ts:}}$o@}: $s
.endfor
OBJS_SRCS = ${SRCS:${OBJS_SRCS_FILTER:ts:}}
diff --git a/mk/libs.mk b/mk/libs.mk
index fef339c03bce..6814916657ec 100644
--- a/mk/libs.mk
+++ b/mk/libs.mk
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
-# $Id: libs.mk,v 1.7 2024/02/17 17:26:57 sjg Exp $
+# $Id: libs.mk,v 1.8 2025/05/19 19:15:22 sjg Exp $
#
# @(#) Copyright (c) 2006, Simon J. Gerraty
#
@@ -59,7 +59,7 @@ $v += ${${v}_${LIB}:U${${v}.${LIB}}}
# for meta mode, there can be only one!
.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno}
-UPDATE_DEPENDFILE ?= yes
+UPDATE_DEPENDFILE ?= ${MK_UPDATE_DEPENDFILE:Uyes}
.endif
UPDATE_DEPENDFILE ?= NO
diff --git a/mk/meta.autodep.mk b/mk/meta.autodep.mk
index b94891b1b93f..ce16ac843dc3 100644
--- a/mk/meta.autodep.mk
+++ b/mk/meta.autodep.mk
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
-# $Id: meta.autodep.mk,v 1.65 2025/03/14 20:28:42 sjg Exp $
+# $Id: meta.autodep.mk,v 1.70 2025/05/28 20:03:00 sjg Exp $
#
# @(#) Copyright (c) 2010-2025, Simon J. Gerraty
@@ -22,6 +22,12 @@ __${_this}__: .NOTMAIN
.-include <local.autodep.mk>
+.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+_debug.autodep = 1
+.else
+_debug.autodep = 0
+.endif
+
PICO?= .pico
.if defined(SRCS)
@@ -85,9 +91,9 @@ UPDATE_DEPENDFILE = NO
_bootstrap_dirdeps = yes
.endif
_bootstrap_dirdeps ?= no
-UPDATE_DEPENDFILE ?= yes
+UPDATE_DEPENDFILE ?= ${MK_UPDATE_DEPENDFILE:Uyes}
-.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.if ${_debug.autodep}
.info ${_DEPENDFILE:S,${SRCTOP}/,,} update=${UPDATE_DEPENDFILE}
.endif
@@ -111,7 +117,7 @@ WANT_UPDATE_DEPENDFILE ?= yes
UPDATE_DEPENDFILE = no
.endif
-.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.if ${_debug.autodep}
.info ${_DEPENDFILE:S,${SRCTOP}/,,} update=${UPDATE_DEPENDFILE}
.endif
@@ -207,7 +213,7 @@ CAT_DEPEND = /dev/null
_depend =
.endif
-.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.if ${_debug.autodep}
.info ${_DEPENDFILE:S,${SRCTOP}/,,} _depend=${_depend}
.endif
@@ -253,19 +259,33 @@ _gendirdeps_mutex = ${GENDIRDEPS_MUTEXER} ${GENDIRDEPS_MUTEX:U${_CURDIR}/Makefil
# but we need to behave as if we did.
# Avoid adding glob patterns to .MAKE.META.CREATED though.
.MAKE.META.CREATED += ${META_XTRAS:N*\**:O:u}
-
-.if make(gendirdeps)
-META_FILES = *.meta
-.elif ${OPTIMIZE_OBJECT_META_FILES:Uno:tl} == "no"
-META_FILES = ${.MAKE.META.FILES:T:N.depend*:O:u}
+OPTIMIZE_OBJECT_META_FILES ?= no
+
+.if ${OPTIMIZE_OBJECT_META_FILES} == "yes"
+# If we have lots of .o.meta, ${PICO}.meta etc we need only look at one set.
+# If META_FILE_OBJ_FILTER is not already set, we default it to a
+# .SUFFIX which matches the first *o.meta.
+# There is no guarantee it will be just .o or .So etc,
+META_FILE_OBJ_FILTER ?= \
+ ${.SUFFIXES:M*o:@o@${"${.MAKE.META.FILES:T:M*$o.meta:[1]}":?M*$o.meta:}@:[1]}
+.endif
+
+# parent may have set META_FILE_OBJ_FILTER
+.if ${OPTIMIZE_OBJECT_META_FILES} == "yes" || !empty(META_FILE_OBJ_FILTER)
+META_FILES = \
+ ${.MAKE.META.FILES:N.depend*:N*o.meta} \
+ ${.MAKE.META.FILES:${META_FILE_OBJ_FILTER}}
.else
-# if we have 1000's of .o.meta, ${PICO}.meta etc we need only look at one set
-# it is left as an exercise for the reader to work out what this does
-META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \
- ${.MAKE.META.FILES:T:M*.${.MAKE.META.FILES:M*o.meta:R:E:O:u:[1]}.meta:O:u}
+META_FILES = ${.MAKE.META.FILES:N.depend*}
.endif
+# ensure this is not empty (this will sort after any M and N
+# we use S,${_OBJDIR}/,, rather than :T since some makefiles have
+# objects in subdirs
+META_FILE_FILTER += S,${_OBJDIR}/,,:O:u
+# we have to defer evaluation until the target script runs
+GENDIRDEPS_ENV += META_FILES="${META_FILES:${META_FILE_FILTER:O:u:ts:}}}"
-.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != ""
+.if ${_debug.autodep}
.info ${_DEPENDFILE:S,${SRCTOP}/,,}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} xtras=${META_XTRAS}
.endif
@@ -276,9 +296,6 @@ META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \
.if !empty(GENDIRDEPS_FILTER)
.export GENDIRDEPS_FILTER
.endif
-# export to avoid blowing command line limit
-META_FILES := ${META_XTRAS:U:O:u} ${META_FILES:U:T:O:u:${META_FILE_FILTER:ts:}}
-.export META_FILES
.endif
_this_dir := ${_PARSEDIR}
@@ -301,7 +318,7 @@ ${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.MET
@(cd . && ${GENDIRDEPS_ENV} \
SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS:O:u}' \
DPADD='${FORCE_DPADD:O:u}' ${_gendirdeps_mutex} \
- ${.MAKE} -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE})
+ ${.MAKE} -B -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE})
@test -s $@ && touch $@; :
.endif
diff --git a/mk/meta2deps.py b/mk/meta2deps.py
index 44c752d0e7eb..70b121003988 100755
--- a/mk/meta2deps.py
+++ b/mk/meta2deps.py
@@ -39,9 +39,9 @@ We only pay attention to a subset of the information in the
SPDX-License-Identifier: BSD-2-Clause
RCSid:
- $Id: meta2deps.py,v 1.50 2024/09/27 00:08:36 sjg Exp $
+ $Id: meta2deps.py,v 1.51 2025/05/16 20:03:43 sjg Exp $
- Copyright (c) 2011-2020, Simon J. Gerraty
+ Copyright (c) 2011-2025, Simon J. Gerraty
Copyright (c) 2011-2017, Juniper Networks, Inc.
All rights reserved.
@@ -543,8 +543,8 @@ class MetaFile:
if w[0] in 'ML':
# these are special, tread src as read and
# target as write
- self.parse_path(w[2].strip("'"), cwd, 'R', w)
self.parse_path(w[3].strip("'"), cwd, 'W', w)
+ self.parse_path(w[2].strip("'"), cwd, 'R', w)
continue
elif w[0] in 'ERWS':
path = w[2]
@@ -611,9 +611,19 @@ class MetaFile:
return
# we don't want to resolve the last component if it is
# a symlink
- path = resolve(path, cwd, self.last_dir, self.debug, self.debug_out)
- if not path:
- return
+ npath = resolve(path, cwd, self.last_dir, self.debug, self.debug_out)
+ if not npath:
+ if len(w) > 3 and w[0] in 'ML' and op == 'R' and path.startswith('../'):
+ # we already resolved the target of the M/L
+ # so it makes sense to try and resolve relative to that dir.
+ if os.path.isdir(self.last_path):
+ dir = self.last_path
+ else:
+ dir,junk = os.path.split(self.last_path)
+ npath = resolve(path, cwd, dir, self.debug, self.debug_out)
+ if not npath:
+ return
+ path = npath
dir,base = os.path.split(path)
if dir in self.seen:
if self.debug > 2:
@@ -631,6 +641,7 @@ class MetaFile:
rdir = None
# now put path back together
path = '/'.join([dir,base])
+ self.last_path = path
if self.debug > 1:
print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out)
if op in 'RWS':
diff --git a/mk/meta2deps.sh b/mk/meta2deps.sh
index f031165e1d32..4af15971b84f 100755
--- a/mk/meta2deps.sh
+++ b/mk/meta2deps.sh
@@ -77,10 +77,11 @@
# RCSid:
-# $Id: meta2deps.sh,v 1.21 2024/02/17 17:26:57 sjg Exp $
+# $Id: meta2deps.sh,v 1.22 2025/05/16 20:03:43 sjg Exp $
# SPDX-License-Identifier: BSD-2-Clause
#
+# Copyright (c) 2011-2025, Simon J. Gerraty
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
#
@@ -252,9 +253,9 @@ meta2deps() {
esac 2> /dev/null |
sed -e 's,^CWD,C C,;/^[#CREFLMVX] /!d' -e "s,',,g" |
$_excludes | ( version=no epids= xpids= eof_token=no
- while read op pid path junk
+ while read op pid path path2
do
- : op=$op pid=$pid path=$path
+ : op=$op pid=$pid path=$path path2=$path2
# we track cwd and ldir (of interest) per pid
# CWD is bmake's cwd
case "$lpid,$pid" in
@@ -321,9 +322,14 @@ meta2deps() {
$src_re|$obj_re) ;;
/*/stage/*) ;;
/*) continue;;
- *) for path in $ldir/$path $cwd/$path
+ *)
+ rlist="$ldir/$path $cwd/$path"
+ case "$op,$path" in
+ [ML],../*) rlist="$rlist $path2/$path `dirname $path2`/$path";;
+ esac
+ for path in $rlist
do
- test -e $path && break
+ test -e $path && break
done
dir=${path%/*}
;;
diff --git a/mk/mkopt.sh b/mk/mkopt.sh
index 24320c257250..ec425440570b 100644
--- a/mk/mkopt.sh
+++ b/mk/mkopt.sh
@@ -2,9 +2,9 @@
# SPDX-License-Identifier: BSD-2-Clause
#
-# $Id: mkopt.sh,v 1.16 2024/02/17 17:26:57 sjg Exp $
+# $Id: mkopt.sh,v 1.17 2025/05/22 22:35:14 sjg Exp $
#
-# @(#) Copyright (c) 2014-2022, Simon J. Gerraty
+# @(#) Copyright (c) 2014-2025, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -89,18 +89,19 @@ _mk_opts_defaults() {
# _mk_cmdline_opts opt ...
# look at the command line (saved in _cmdline)
# to see any options we care about are being set with -DWITH*
-# or MK_*= if 'opt' is '*' then all options are of interest.
+# or MK_*= and WITH[OUT]_*= if 'opt' is '*' then all options are of interest.
_cmdline="$0 $@"
_mk_cmdline_opts() {
for _x in $_cmdline
do
case "$_x" in
- -DWITH*|${_MKOPT_PREFIX:-MK_}*)
+ -DWITH*|WITH*=*|${_MKOPT_PREFIX:-MK_}*=*)
for _o in "$@"
do
case "$_x" in
-DWITH_$_o|-DWITHOUT_$_o) eval ${_x#-D}=1;;
-DWITH_$_o=*|-DWITHOUT_$_o=*) eval ${_x#-D};;
+ WITH_$_o=*|WITHOUT_$_o=*) eval "$_x";;
${_MKOPT_PREFIX:-MK_}$_o=*) eval "$_x";;
esac
done
diff --git a/mk/newlog.sh b/mk/newlog.sh
index 5c65e5dd5fb6..fbf347ee2746 100755
--- a/mk/newlog.sh
+++ b/mk/newlog.sh
@@ -15,11 +15,12 @@
#
# -C "compress"
# Compact old logs (other than .0) with "compress"
-# (default is 'gzip' or 'compress' if no 'gzip').
+# (default is "$NEWLOG_COMPRESS" 'gzip' or 'compress' if
+# no 'gzip').
#
# -E "ext"
# If "compress" produces a file extention other than
-# '.Z' or '.gz' we need to know.
+# '.Z' or '.gz' we need to know ("$NEWLOG_EXT").
#
# -G "gens"
# "gens" is a comma separated list of "log":"num" pairs
@@ -39,6 +40,7 @@
# uniquely name it when using the '-S' option.
# If a "log" is saved more than once per second we add
# an extra suffix of our process-id.
+# The default can be set in the env via "$NEWLOG_FMT".
#
# -d The "log" to be rotated/saved is a directory.
# We leave the mode of old directories alone.
@@ -50,21 +52,24 @@
# Set the group of "log" to "group".
#
# -m "mode"
-# Set the mode of "log".
+# Set the mode of "log" ("$NEWLOG_MODE").
#
# -M "mode"
-# Set the mode of old logs (default 444).
+# Set the mode of old logs (default "$NEWLOG_OLD_MODE"
+# or 444).
#
# -n "num"
-# Keep "num" generations of "log".
+# Keep "num" generations of "log" ("$NEWLOG_NUM").
#
# -o "owner"
# Set the owner of "log".
#
-# Regardless of whether '-R' or '-S' is provided, we attempt to
-# choose the correct behavior based on observation of "log.0" if
-# it exists; if it is a symbolic link, we save, otherwise
-# we rotate.
+# The default method for dealing with logs can be set via
+# "$NEWLOG_METHOD" ('save' or 'rotate').
+# Regardless of "$NEWLOG_METHOD" or whether '-R' or '-S' is
+# provided, we attempt to choose the correct behavior based on
+# observation of "log.0" if it exists; if it is a symbolic link,
+# we 'save', otherwise we 'rotate'.
#
# BUGS:
# 'Newlog.sh' tries to avoid being fooled by symbolic links, but
@@ -76,11 +81,11 @@
#
# RCSid:
-# $Id: newlog.sh,v 1.27 2024/02/17 17:26:57 sjg Exp $
+# $Id: newlog.sh,v 1.30 2025/06/01 05:07:48 sjg Exp $
#
# SPDX-License-Identifier: BSD-2-Clause
#
-# @(#) Copyright (c) 1993-2016 Simon J. Gerraty
+# @(#) Copyright (c) 1993-2025 Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -168,6 +173,10 @@ get_mode() {
$STAT -f %Op $1 | sed 's,.*\(....\),\1,'
return
;;
+ Linux,$STAT) # works on Ubuntu
+ $STAT -c %a $1 2> /dev/null &&
+ return
+ ;;
esac
# fallback to find
fmode `find $1 -ls -prune | awk '{ print $3 }'`
@@ -179,21 +188,33 @@ get_mtime_suffix() {
$STAT -t "${2:-$opt_f}" -f %Sm $1
return
;;
+ Linux,*) # works on Ubuntu
+ mtime=`$STAT --format=%Y $1 2> /dev/null`
+ if [ ${mtime:-0} -gt 1 ]; then
+ date --date=@$mtime "+${2:-$opt_f}" 2> /dev/null &&
+ return
+ fi
+ ;;
esac
# this will have to do
date "+${2:-$opt_f}"
}
case /$0 in
-*/newlog*) rotate_func=rotate_log;;
+*/newlog*) rotate_func=${NEWLOG_METHOD:-rotate_log};;
*/save*) rotate_func=save_log;;
-*) rotate_func=rotate_log;;
+*) rotate_func=${NEWLOG_METHOD:-rotate_log};;
+esac
+case "$rotate_func" in
+save|rotate) rotate_func=${rotate_func}_log;;
esac
-opt_n=7
-opt_m=
-opt_M=444
-opt_f=%Y%m%d.%H%M%S
+opt_C=${NEWLOG_COMPRESS}
+opt_E=${NEWLOG_EXT}
+opt_n=${NEWLOG_NUM:-7}
+opt_m=${NEWLOG_MODE}
+opt_M=${NEWLOG_OLD_MODE:-444}
+opt_f=${NEWLOG_FMT:-%Y-%m-%dT%T} # rfc3339
opt_str=dNn:o:g:G:C:M:m:eE:f:RS
. setopts.sh
@@ -241,7 +262,7 @@ case "${opt_R:-0}" in
esac
case "${opt_S:-0}" in
0) ;;
-*) rotate_func=save_log opt_S=;;
+*) rotate_func=save_log;;
esac
# see whether test handles -h or -L
@@ -345,12 +366,7 @@ save_log() {
$ECHO rm $rm_f `'ls' -1td $log.* 2> /dev/null | sed "1,${n}d"`
mode=${opt_m:-`get_mode $log`}
- # this is our default suffix
- opt_S=${opt_S:-`get_mtime_suffix $log $fmt`}
- case "$fmt" in
- ""|$opt_f) suffix=$opt_S;;
- *) suffix=`get_mtime_suffix $log $fmt`;;
- esac
+ suffix=`get_mtime_suffix $log $fmt`
# find a unique name to save current log as
for nlog in $log.$suffix $log.$suffix.$$
diff --git a/mk/progs.mk b/mk/progs.mk
index ada942db8621..fe8cad4b5c26 100644
--- a/mk/progs.mk
+++ b/mk/progs.mk
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
-# $Id: progs.mk,v 1.18 2024/04/09 17:18:24 sjg Exp $
+# $Id: progs.mk,v 1.19 2025/05/19 19:15:22 sjg Exp $
#
# @(#) Copyright (c) 2006, Simon J. Gerraty
#
@@ -68,7 +68,7 @@ $v += ${${v}_${PROG}:U${${v}.${PROG}}}
# for meta mode, there can be only one!
.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno}
-UPDATE_DEPENDFILE ?= yes
+UPDATE_DEPENDFILE ?= ${MK_UPDATE_DEPENDFILE:Uyes}
.endif
UPDATE_DEPENDFILE ?= NO
diff --git a/mk/setopts.sh b/mk/setopts.sh
index 91c65c776438..5fccb0bcb6fe 100644
--- a/mk/setopts.sh
+++ b/mk/setopts.sh
@@ -12,17 +12,17 @@
# This module sets shell variables for each option specified in
# "opt_str".
#
-# If the option is followed by a ``:'' it requires an argument.
+# 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 "o" 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_$o"
+# if set, or "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 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.
@@ -50,9 +50,9 @@
#
# RCSid:
-# $Id: setopts.sh,v 1.13 2023/02/20 19:30:06 sjg Exp $
+# $Id: setopts.sh,v 1.15 2025/06/01 02:10:31 sjg Exp $
#
-# @(#) Copyright (c) 1995-2023 Simon J. Gerraty
+# @(#) Copyright (c) 1995-2025 Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
@@ -87,7 +87,7 @@ set1opt() {
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_dot_$o:-$opt_dot}}$a\"";;
*${o},*) eval "opt_$o=\"\${opt_$o}\${opt_$o:+$opt_comma}$a\"";;
*${o}=*)
case "$a" in
diff --git a/mk/sys.mk b/mk/sys.mk
index cf6ef061f406..d05bd62e10c0 100644
--- a/mk/sys.mk
+++ b/mk/sys.mk
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-2-Clause
#
-# $Id: sys.mk,v 1.61 2024/10/30 23:46:26 sjg Exp $
+# $Id: sys.mk,v 1.62 2025/05/19 19:15:22 sjg Exp $
#
# @(#) Copyright (c) 2003-2023, Simon J. Gerraty
#
@@ -101,6 +101,7 @@ OPTIONS_DEFAULT_DEPENDENT += \
META_MODE/DIRDEPS_BUILD \
STAGING/DIRDEPS_BUILD \
STATIC_DIRDEPS_CACHE/DIRDEPS_CACHE \
+ UPDATE_DEPENDFILE/DIRDEPS_BUILD \
.-include <options.mk>