Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 684688 | Differences between
and this patch

Collapse All | Expand All

(-)a/GNUmakefile (+33 lines)
Line 0 Link Here
1
HTMLS := $(subst text.xml,index.html,$(shell find ./ -type f -name 'text.xml'))
2
IMAGES := $(patsubst %.svg,%.png,$(shell find ./ -type f -name '*.svg'))
3
4
all: prereq $(HTMLS) $(IMAGES)
5
6
prereq:
7
	@type convert >/dev/null 2>&1 || { echo "media-gfx/imagemagick with corefonts, svg and truetype required" >&2; exit 1; }; \
8
		type xsltproc >/dev/null 2>&1 || { echo "dev-libs/libxslt is required" >&2; exit 1; }
9
10
11
%.png : %.svg
12
	convert $< $@
13
14
clean:
15
	rm -f $(HTMLS) $(IMAGES)
16
17
.PHONY: all prereq clean
18
19
20
# Secondary expansion allows us to use the automatic variable $@ in
21
# the prerequisites. When it is used (and we have no idea when that
22
# is, so we assume always) our <include href="foo"> tag induces a
23
# dependency on the output of all subdirectories of the current
24
# directories. This wacky rule finds all of those subdirectories by
25
# looking for text.xml in them, and then replaces "text.xml" in the
26
# path with "index.html".
27
#
28
# We use the pattern %.html rather than the more-sensible %index.html
29
# because the latter doesn't match our top-level index.html target.
30
#
31
.SECONDEXPANSION:
32
%.html: $$(dir $$@)text.xml devbook.xsl xsl/*.xsl $$(subst text.xml,index.html,$$(wildcard $$(dir $$@)*/text.xml))
33
	xsltproc devbook.xsl $< > $@
(-)a/Makefile (-41 lines)
Lines 1-40 Link Here
1
ALL_DIRS := $(shell find -name "text.xml" -exec dirname {} +)
2
text_files := $(addsuffix /index.html,$(ALL_DIRS))
3
image_files := $(shell find -name "*.svg" | sed -e "s/svg$$/png/")
4
5
all: prereq $(text_files) $(image_files)
6
7
prereq:
8
	@type convert >/dev/null 2>&1 || { echo "media-gfx/imagemagick with corefonts, svg and truetype required" >&2; exit 1; }; \
9
		type xsltproc >/dev/null 2>&1 || { echo "dev-libs/libxslt is required" >&2; exit 1; }
10
11
%.png : %.svg
12
	convert $< $@
13
14
clean:
15
	@find . -name "*.png" -a \! -path "./icons/*" -exec rm -v {} +
16
	@find . -name "index.html" -exec rm -v {} +
17
18
# Given a directory with text.xml in it, return its immediate children as prerequisites
19
# Hypothetical example:
20
# INPUT:  "./archs" "./archs/amd64 ./archs/x86 ./ebuild-writing ./appendices"
21
# OUTPUT: ./archs/amd64/index.html ./archs/amd64/index.html
22
define get_prerequisites =
23
$(addsuffix /index.html,$(foreach subdir,$(2),$(if $(subst $(1)/,,$(dir $(subdir))),,$(subdir))))
24
endef
25
26
# Given a directory with text.xml in it, genereate a complete build rule with prerequisites
27
# Hypothetical example:
28
# INPUT:  "./archs" "./archs/amd64 ./archs/x86 ./ebuild-writing ./appendices"
29
# OUTPUT  ./archs/index.html: ./archs/text.xml devbook.xsl ./archs/amd64/index.html ./archs/x86/index.html
30
#                 xsltproc devbook.xsl ./archs/text.xml > ./archs/index.html
31
define generate_rule =
32
$(1)/index.html: $(1)/text.xml devbook.xsl $(call get_prerequisites,$(1),$(2))
33
	xsltproc devbook.xsl $$< > $$@
34
endef
35
36
# This generates individual build rules for all the text files by
37
# iterating over all the directories in the file system tree
38
$(foreach dir,$(ALL_DIRS),$(eval $(call generate_rule,$(dir),$(filter-out $(dir),$(ALL_DIRS)))))
39
40
.PHONY: all prereq clean
41
- 

Return to bug 684688