summaryrefslogtreecommitdiff
blob: 5b20643f6c23cf9703f5e8c1b3fc37ac57e3d7f9 (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
54
DTDS = book.dtd gleps.dtd glsa.dtd guide.dtd metadata.dtd metadoc.dtd	\
       project.dtd staffing-needs.dtd userinfo.dtd

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

ifdef ($(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 *.dtd .depend

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

$(TARBALL): Makefile LICENCE DONATING 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 $< $@

metadata.rnc: metadata.dtd
	trang -I dtd -O rnc -i no-generate-start $< $@
	echo 'start = catmetadata | pkgmetadata' >> $@

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

-include .depend