summaryrefslogtreecommitdiff
blob: 915719d71f484e1965fd4af6db85cf78bf16800a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
DTDS = book.dtd devbook.dtd glsa.dtd guide.dtd metadata.dtd mirrors.dtd \
       projects.dtd repositories.dtd

DTDDEPS = $(patsubst %.dtd,%.dep,$(DTDS))
RNCS = $(patsubst %.dtd,%.rnc,$(DTDS))

ifneq ($(PV),)
PN=nxml-gentoo-schemas-$(PV)
else
PN=nxml-gentoo-schemas-$(shell date '+%Y%m%d')
endif

TARBALL=$(PN).tar.xz

.SUFFIXES: .dtd .rnc .dep
.PHONY: depend all clean
.PRECIOUS: $(RNCS) $(DTDS)
.INTERMEDIATE: $(DTDDEPS)

all: .depend $(TARBALL)

depend: .depend

clean:
	rm -f *.dtd *.dep .depend

.depend: $(DTDDEPS)
	cat *.dep > $@

$(TARBALL): Makefile LICENCE schemas.xml $(RNCS)
	mkdir -p $(PN)
	cp $^ $(PN)
	tar cJf $@ $(PN)

.dtd.dep:
	echo > $@
	sed -n -e '/ENTITY/s|<!ENTITY % \w\+ SYSTEM "\(.*\)\.dtd">|\1|p' $< | \
	while read dep; do \
		echo "$(patsubst %.dtd,%.rnc,$<): $$dep.rnc $$dep.dtd" >> $@ || exit 1; \
		echo "$(TARBALL): $$dep.rnc" >> $@ || exit 1; \
		$(MAKE) "$$dep.dep" || exit 1; \
	done

.dtd.rnc:
	trang -I dtd -O rnc $< $@

%.dtd:
	wget -N --no-verbose https://www.gentoo.org/dtd/$@

devbook.dtd:
	wget -N --no-verbose https://devmanual.gentoo.org/$@

-include .depend