Commit 70f105b123 for perl
commit 70f105b123b9ecfcf0dcc8713bdd569020d7c50f
Author: Yves Orton <demerphq@gmail.com>
Date: Thu Sep 17 12:47:02 2026 +0200
build: prevent recursive dependency generation loop
The generated dependency makefile uses README as a sentinel prerequisite. When
README is newer after a checkout, the recursive MAKEDEPEND= pass repeatedly
rebuilds the same target.
Guard the recursive make invocation with the MAKEDEPEND value. The outer pass
still regenerates dependencies, while the recursive pass terminates without
invoking itself again. The guard uses the shell test syntax already supported
by the portable build.
diff --git a/Makefile.SH b/Makefile.SH
index 71ea87042e..5534a9cc1e 100755
--- a/Makefile.SH
+++ b/Makefile.SH
@@ -1496,15 +1496,18 @@ cscope.out cscope: $(c) $(h)
# $(FIRSTMAKEFILE) is generated by the makedepend script.
# The makedepend script uses the makedependfile script.
-
-# Need to unset MAKEDEPEND during recursion to go out of loop.
-# The README below ensures that the dependency list is never empty and
-# that when MAKEDEPEND is empty $(FIRSTMAKEFILE) doesn't need rebuilding.
+#
+# We need to unset MAKEDEPEND during recursion to prevent an infinite loop.
+# The shell guard prevents a newer README from making that recursive invocation
+# call itself forever.
+# Note, this isn't particularly obvious: make itself adds $(FIRSTMAKEFILE) as
+# a dependency (because make just read it) without it being the default nor
+# mentioned on the command-line
MAKEDEPEND = Makefile makedependfile makedepend
$(FIRSTMAKEFILE): README $(MAKEDEPEND)
- $(MAKE) depend MAKEDEPEND=
+ @test -z "$(MAKEDEPEND)" || $(MAKE) depend MAKEDEPEND=
!NO!SUBS!
# Targets generating the underlying file from the scripts defined in SH variable.