1
0
mirror of https://github.com/moparisthebest/xeps synced 2024-11-23 09:42:20 -05:00

Fix Makefile dependencies on directories

Most jobs depend on build or one of its subdirectories. By default,
this causes make to take the timestamp of the `build` directory (or
the respective subdirectory) into account when calculating whether
a job needs rebuilding.

This is a problem, because the modified timestamp of `build` updates
whenever a file is put into it. Effectively, this breaks incremental
builds.

Luckily, GNU(?) Make supports Order-only Dependencies, prefixed with
a pipe (`|`) symbol in the dependency list. That means that the
dependencies are not taken into account for freshness checks, but
will be built before the target (if they are non-fresh).

This commit introduces usage of Order-only Dependencies for the
output directories, which fixes incremental building.
This commit is contained in:
Jonas Schäfer 2020-06-13 14:38:11 +02:00
parent 34ab0af5a0
commit a694dd21ab

View File

@ -3,7 +3,7 @@
OUTDIR?=build OUTDIR?=build
REFSDIR?=$(OUTDIR)/refs REFSDIR?=$(OUTDIR)/refs
EXAMPLESDIR?=$(OUTDIR)/examples EXAMPLESDIR?=$(OUTDIR)/examples
XMLDEPS=xep.xsd xep.ent xep.dtd ref.xsl $(OUTDIR) XMLDEPS=xep.xsd xep.ent xep.dtd ref.xsl
TEXMLDEPS=xep2texml.xsl $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf TEXMLDEPS=xep2texml.xsl $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf
XEPDIRS=. inbox XEPDIRS=. inbox
HTMLDEPS=xep.xsl $(CSSTARGETS) $(JSTARGETS) HTMLDEPS=xep.xsl $(CSSTARGETS) $(JSTARGETS)
@ -100,13 +100,13 @@ $(OUTDIR)/xep.xsl: xep.xsl $(OUTDIR)
$(OUTDIR)/xeplist.xml: $(wildcard *.xml) $(wildcard inbox/*.xml) $(OUTDIR)/xeplist.xml: $(wildcard *.xml) $(wildcard inbox/*.xml)
./tools/extract-metadata.py > $@ ./tools/extract-metadata.py > $@
$(EXAMPLESDIR)/%.xml: xep-%.xml $(XMLDEPS) examples.xsl $(EXAMPLESDIR) $(EXAMPLESDIR)/%.xml: xep-%.xml $(XMLDEPS) examples.xsl | $(EXAMPLESDIR)
xsltproc --path $(CURDIR) examples.xsl "$<" > "$@" && echo "Finished building $@" xsltproc --path $(CURDIR) examples.xsl "$<" > "$@" && echo "Finished building $@"
$(REFSDIR)/reference.XSF.XEP-%.xml: xep-%.xml $(XMLDEPS) ref.xsl $(REFSDIR) $(REFSDIR)/reference.XSF.XEP-%.xml: xep-%.xml $(XMLDEPS) ref.xsl | $(REFSDIR)
xsltproc --path $(CURDIR) ref.xsl "$<" > "$@" && echo "Finished building $@" xsltproc --path $(CURDIR) ref.xsl "$<" > "$@" && echo "Finished building $@"
$(xep_htmls): $(OUTDIR)/xep-%.html: xep-%.xml $(XMLDEPS) $(HTMLDEPS) $(xep_htmls): $(OUTDIR)/xep-%.html: xep-%.xml $(XMLDEPS) $(HTMLDEPS) | $(OUTDIR)
xmllint --nonet --noout --noent --loaddtd --valid "$<" xmllint --nonet --noout --noent --loaddtd --valid "$<"
# Check for non-data URIs # Check for non-data URIs
! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true ! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
@ -114,7 +114,7 @@ $(xep_htmls): $(OUTDIR)/xep-%.html: xep-%.xml $(XMLDEPS) $(HTMLDEPS)
# Actually build the HTML # Actually build the HTML
xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" xep.xsl "$<" > "$@" && echo "Finished building $@" xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" xep.xsl "$<" > "$@" && echo "Finished building $@"
$(proto_xep_htmls): $(OUTDIR)/inbox/%.html: inbox/%.xml $(XMLDEPS) $(proto_HTMLDEPS) $(proto_xep_htmls): $(OUTDIR)/inbox/%.html: inbox/%.xml $(XMLDEPS) $(proto_HTMLDEPS) | $(OUTDIR)
xmllint --nonet --noout --noent --loaddtd --valid "$<" xmllint --nonet --noout --noent --loaddtd --valid "$<"
# Check for non-data URIs # Check for non-data URIs
! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true ! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
@ -122,7 +122,7 @@ $(proto_xep_htmls): $(OUTDIR)/inbox/%.html: inbox/%.xml $(XMLDEPS) $(proto_HTMLD
# Actually build the HTML # Actually build the HTML
xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" xep.xsl "$<" > "$@" && echo "Finished building $@" xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" xep.xsl "$<" > "$@" && echo "Finished building $@"
$(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf: $(OUTDIR) $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf: | $(OUTDIR)
cp "resources/$(notdir $@)" "$@" cp "resources/$(notdir $@)" "$@"
$(OUTDIR)/%.pdf: %.xml $(XMLDEPS) $(TEXMLDEPS) $(OUTDIR)/%.pdf: %.xml $(XMLDEPS) $(TEXMLDEPS)
@ -140,16 +140,16 @@ $(OUTDIR)/%.pdf: %.xml $(XMLDEPS) $(TEXMLDEPS)
done done
echo "Finished building $@" echo "Finished building $@"
$(JSTARGETS): $(OUTDIR) $(JSTARGETS): | $(OUTDIR)
cp "$(notdir $@)" "$@" cp "$(notdir $@)" "$@"
$(CSSTARGETS): $(OUTDIR) $(CSSTARGETS): | $(OUTDIR)
cp "$(notdir $@)" "$@" cp "$(notdir $@)" "$@"
$(proto_JSTARGETS): $(OUTDIR)/inbox $(proto_JSTARGETS): | $(OUTDIR)/inbox
cp "$(notdir $@)" "$@" cp "$(notdir $@)" "$@"
$(proto_CSSTARGETS): $(OUTDIR)/inbox $(proto_CSSTARGETS): | $(OUTDIR)/inbox
cp "$(notdir $@)" "$@" cp "$(notdir $@)" "$@"
$(EXAMPLESDIR) $(REFSDIR) $(OUTDIR) $(OUTDIR)/inbox: $(EXAMPLESDIR) $(REFSDIR) $(OUTDIR) $(OUTDIR)/inbox: