git: ab492c08fc3c - main - build: don't create duplicate bootstrap-tools targets

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Mon, 06 Oct 2025 17:52:00 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=ab492c08fc3cbf4fb5d569663c0751bc2a41cb1f

commit ab492c08fc3cbf4fb5d569663c0751bc2a41cb1f
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-10-06 17:50:22 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2025-10-06 17:51:29 +0000

    build: don't create duplicate bootstrap-tools targets
    
    The general problem is that we might have a somewhat complicated
    dependency tree depending on bootstrap version requirements.  We could
    document when multiple bootstrap tools might have a shared dependency
    and be careful to add them only once to the list, but that is a little
    more fragile- particularly if we purge some bootstrap tools and need to
    re-work the logic a little bit.
    
    Just avoid redefining the build commands as we're iterating over the
    list so that we can keep the actual requirements intact.
    
    PR:             289997
    Reported by:    dhw, others
    Reviewed by:    imp
    Fixes:  151bd3516b5 ("flua: support our flua modules in [...]")
    Differential Revision:  https://reviews.freebsd.org/D52904
---
 Makefile.inc1 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 6ace6a6b5eaf..9dc4f2db4a6c 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -2842,6 +2842,15 @@ bootstrap-tools: ${_bt}-links .PHONY
     ${_mkesdb} \
     ${_zic} \
     ${LOCAL_BSTOOL_DIRS}
+# We don't enforce any particular uniqueness of targets in the above list; it
+# may be the case that different bootstrap tools may have shared dependencies
+# at different BOOTSTRAPPING points, so we don't object to them using their own
+# conditionals and duplicating them into their ${_foo} variable to ease future
+# maintenance if we purge some entries.  These target names are purposefully
+# unique and this is the only place that should be generating commands for them,
+# but the target may have been defined earlier to express dependencies -- thus,
+# we specifically want commands() here.
+.if !commands(${_bt}-${_tool})
 ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
 	${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
 		cd ${.CURDIR}/${_tool}; \
@@ -2851,8 +2860,8 @@ ${_bt}-${_tool}: ${_bt}-links .PHONY .MAKE
 		fi; \
 		${MAKE} DIRPRFX=${_tool}/ all; \
 		${MAKE} DIRPRFX=${_tool}/ DESTDIR=${WORLDTMP}/legacy install
-
 bootstrap-tools: ${_bt}-${_tool}
+.endif
 .endfor
 .if target(${_bt}-lib/libmd)
 # If we are bootstrapping libmd (e.g. when building on macOS/Linux) add the