aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bdrewery@FreeBSD.org>2026-03-07 16:38:47 +0000
committerBryan Drewery <bdrewery@FreeBSD.org>2026-03-09 14:38:40 +0000
commite2ed7ee02f6bda705a7c8df3c512c6a43db56830 (patch)
treeec3dc8d8f4c21f90040a8584b03cc28a291560eb
parentb4daeded66b5e950ed8e618d66915b863c2414b1 (diff)
bsd.progs.mk: Fix incremental META_MODE for prog sources
This fixes recursed builds not having meta mode enabled for them which disabled dependency and and command change tracking. We only want common objects marked .NOMETA when recursing, not non-common objects. The common code expects _PROGS_COMMON_SRCS does not contain the prog source or else it will be marked .NOMETA. Add comments explaining the intent and cases being covered. Fixes: 4ea5e107b1 ("<bsd.progs.mk>: Allow using SRCS for common sources") Differential Revision: https://reviews.freebsd.org/D55711 Reviewed by: vexeduxr, sjg
-rw-r--r--share/mk/bsd.progs.mk27
1 files changed, 25 insertions, 2 deletions
diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk
index 007e8a843944..2c6f6df33279 100644
--- a/share/mk/bsd.progs.mk
+++ b/share/mk/bsd.progs.mk
@@ -14,6 +14,7 @@
# we really only use PROGS below...
PROGS += ${PROGS_CXX}
+_save_srcs:= ${SRCS:U}
.if defined(PROG)
# just one of many
PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE CSTD CXXSTD DPSRCS MAN \
@@ -91,8 +92,29 @@ $v =
# Find common sources among the PROGS to depend on them before building
# anything. This allows parallelization without them each fighting over
# the same objects.
-_PROGS_COMMON_SRCS= ${DPSRCS} ${SRCS}
-_PROGS_ALL_SRCS= ${SRCS}
+#
+# There are 3 cases to consider.
+# 1. No common sources.
+# SRCS=
+# SRCS.prog1= prog1.c
+# SRCS.prog2= prog2.c
+# 2. Common sources in all SRCS.$prog.
+# SRCS=
+# SRCS.prog1= prog1.c common.c
+# SRCS.prog2= prog2.c common.c
+# 3. Common sources in SRCS.
+# SRCS= common.c
+# SRCS.prog1= prog1.c
+# SRCS.prog2= prog2.c
+# The intent is:
+# a. Only build common objects in the parent make before recursing.
+# b. When recursing only build non-common objects.
+# c. When recursing disable meta mode for common objects so they are not
+# inspected.
+# _PROGS_COMMON_SRCS is expected to only contain common sources both
+# in the parent and when recursing.
+_PROGS_COMMON_SRCS:= ${DPSRCS} ${_save_srcs}
+_PROGS_ALL_SRCS:= ${_save_srcs}
.for p in ${PROGS}
.for s in ${SRCS.${p}}
.if ${_PROGS_ALL_SRCS:M${s}} && !${_PROGS_COMMON_SRCS:M${s}}
@@ -115,6 +137,7 @@ _PROGS_COMMON_OBJS+= ${_PROGS_COMMON_SRCS:N*.[dhly]:${OBJS_SRCS_FILTER:ts:}:S/$/
${_PROGS_COMMON_OBJS}: .NOMETA
.endif
.endif
+.undef _save_srcs
.if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
# tell progs.mk we might want to install things