Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 596366 Details for
Bug 684688
devmanual: simplify the Makefile
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
0001-Makefile-simplify-generated-rules.patch
0001-Makefile-simplify-generated-rules.patch (text/plain), 4.18 KB, created by
Michael Orlitzky
on 2019-11-16 13:05:32 UTC
(
hide
)
Description:
0001-Makefile-simplify-generated-rules.patch
Filename:
MIME Type:
Creator:
Michael Orlitzky
Created:
2019-11-16 13:05:32 UTC
Size:
4.18 KB
patch
obsolete
>From 4d3d46dd68811926f2e67d1d0fe179dde7773f9f Mon Sep 17 00:00:00 2001 >From: Michael Orlitzky <mjo@gentoo.org> >Date: Sun, 28 Apr 2019 21:10:28 -0400 >Subject: [PATCH 1/1] Makefile: simplify generated rules. > >Our Makefile is GNU-specific, thanks to heavy use of call/eval to >automatically generate rules. In this commit, those generated rules >have been replaced by slightly less (in terms of code volume) >GNU-specific magic. The new magic uses a secondary expansion rule that >allows us to access the target name inside its own prerequisites. The >single resulting SECONDEXPANSION rule seems to be able to replace all >of the generated rules. > >The variables and "clean" targets were also simplified using the full >power of the GNU extensions, which we are assuming anyway. Finally, >two other minor improvements were made: > > 1. The "clean" target was moved to the end of the file. > > 2. The "prereq" rule was split into two separate commands, and > wrapped to a reasonable line length. > >Closes: https://bugs.gentoo.org/684688 >Signed-off-by: Michael Orlitzky <mjo@gentoo.org> >--- > Makefile | 56 ++++++++++++++++++++++++++------------------------------ > 1 file changed, 26 insertions(+), 30 deletions(-) > >diff --git a/Makefile b/Makefile >index 8742a68..d810837 100644 >--- a/Makefile >+++ b/Makefile >@@ -1,40 +1,36 @@ >-ALL_DIRS := $(shell find -name "text.xml" -exec dirname {} +) >-text_files := $(addsuffix /index.html,$(ALL_DIRS)) >-image_files := $(shell find -name "*.svg" | sed -e "s/svg$$/png/") >+HTMLS := $(subst text.xml,index.html,$(shell find ./ -type f -name 'text.xml')) >+IMAGES := $(patsubst %.svg,%.png,$(shell find ./ -type f -name '*.svg')) > >-all: prereq $(text_files) $(image_files) >+all: prereq $(HTMLS) $(IMAGES) > > prereq: >- @type convert >/dev/null 2>&1 || { echo "media-gfx/imagemagick with corefonts, svg and truetype required" >&2; exit 1; }; \ >- type xsltproc >/dev/null 2>&1 || { echo "dev-libs/libxslt is required" >&2; exit 1; } >+ @type convert >/dev/null 2>&1 || \ >+ { echo "media-gfx/imagemagick[corefonts,svg,truetype] required" >&2;\ >+ exit 1; } >+ @type xsltproc >/dev/null 2>&1 || \ >+ { echo "dev-libs/libxslt is required" >&2;\ >+ exit 1; } > > %.png : %.svg > convert $< $@ > >-clean: >- @find . -name "*.png" -exec rm -v {} + >- @find . -name "index.html" -exec rm -v {} + >- >-# Given a directory with text.xml in it, return its immediate children as prerequisites >-# Hypothetical example: >-# INPUT: "./archs" "./archs/amd64 ./archs/x86 ./ebuild-writing ./appendices" >-# OUTPUT: ./archs/amd64/index.html ./archs/amd64/index.html >-define get_prerequisites = >-$(addsuffix /index.html,$(foreach subdir,$(2),$(if $(subst $(1)/,,$(dir $(subdir))),,$(subdir)))) >-endef >- >-# Given a directory with text.xml in it, genereate a complete build rule with prerequisites >-# Hypothetical example: >-# INPUT: "./archs" "./archs/amd64 ./archs/x86 ./ebuild-writing ./appendices" >-# OUTPUT ./archs/index.html: ./archs/text.xml devbook.xsl ./archs/amd64/index.html ./archs/x86/index.html >-# xsltproc devbook.xsl ./archs/text.xml > ./archs/index.html >-define generate_rule = >-$(1)/index.html: $(1)/text.xml devbook.xsl $(call get_prerequisites,$(1),$(2)) >- xsltproc devbook.xsl $$< > $$@ >-endef >+# Secondary expansion allows us to use the automatic variable $@ in >+# the prerequisites. When it is used (and we have no idea when that >+# is, so we assume always) our <include href="foo"> tag induces a >+# dependency on the output of all subdirectories of the current >+# directories. This wacky rule finds all of those subdirectories by >+# looking for text.xml in them, and then replaces "text.xml" in the >+# path with "index.html". >+# >+# 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 $$(subst text.xml,index.html,$$(wildcard $$(dir $$@)*/text.xml)) >+ xsltproc devbook.xsl $< > $@ > >-# This generates individual build rules for all the text files by >-# iterating over all the directories in the file system tree >-$(foreach dir,$(ALL_DIRS),$(eval $(call generate_rule,$(dir),$(filter-out $(dir),$(ALL_DIRS))))) >+clean: >+ rm -f $(HTMLS) $(IMAGES) > > .PHONY: all prereq clean >+ >-- >2.23.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 684688
:
574592
|
596298
|
596366
|
596858