commit:     9e945e68383fc3d338830239fd7339a24635c389
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  3 02:27:07 2024 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sun Nov  3 02:27:07 2024 +0000
URL:        https://gitweb.gentoo.org/proj/devmanual.git/commit/?id=9e945e68

Makefile: Secondary expansion is not needed

Drop .SECONDEXPANSION and use a static pattern rule instead.

The problem addressed by secondary expansion was that % in a "normal"
pattern rule doesn't match the empty string, therefore %index.html
won't match the top-level index.html target. By contract, % in a
static pattern rule matches any part of the target name.

Using a pattern rule like "ind%x.html: t%xt.xml ..." would also be
possible but seems a little hackish.

Signed-off-by: Ulrich Müller <ulm <AT> gentoo.org>

 Makefile | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 042ffa7..c377d5d 100644
--- a/Makefile
+++ b/Makefile
@@ -50,14 +50,9 @@ documents.js: bin/build_search_documents.py $(XMLS)
 %.png : %.svg
        rsvg-convert --output=$@ $<
 
-# Secondary expansion allows us to use the automatic variable $@ in
-# the prerequisites.
-#
-# We use the pattern %.html rather than the more-sensible %index.html
-# because the latter doesn't match our top-level index.html target.
-#
-.SECONDEXPANSION:
-%.html: $$(dir $$@)text.xml devbook.xsl xsl/*.xsl
+# Use a static pattern rule, otherwise %index.html won't match the
+# top-level index.html target.
+$(HTMLS): %index.html: %text.xml devbook.xsl xsl/*.xsl
        xsltproc --param offline "$(OFFLINE)" devbook.xsl $< > $@
 
 eclass-reference/text.xml:

Reply via email to