DTDS = devbook.dtd glsa.dtd metadata.dtd mirrors.dtd \
       projects.dtd repositories.dtd userinfo.dtd

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

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

TARBALL=$(PN).tar.xz

.PHONY: all clean
.PRECIOUS: $(RNCS) $(DTDS)

all: $(TARBALL)

clean:
	rm -f *.dtd

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

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

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

devbook.dtd:
	wget -N --no-verbose \
	  https://gitweb.gentoo.org/proj/devmanual.git/plain/$@
