2015-08-31 22:41:35 -04:00
|
|
|
.SILENT:
|
|
|
|
|
|
|
|
OUTDIR?=build
|
2015-09-22 16:07:41 -04:00
|
|
|
RESOURCESDIR=$(OUTDIR)/resources
|
|
|
|
TEMPDIR?=$(OUTDIR)/xepbuild
|
2015-09-01 00:15:10 -04:00
|
|
|
XMLDEPS=xep.xsl xep.xsd xep.ent xep.dtd ref.xsl $(OUTDIR)
|
2015-09-22 16:07:41 -04:00
|
|
|
TEXMLDEPS=xep2texml.xsl $(TEMPDIR) $(XMLDEPS) $(RESOURCESDIR)/xmpp.pdf $(RESOURCESDIR)/xmpp-text.pdf
|
|
|
|
XMPPIMAGESURL=https://xmpp.org/images
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2015-08-31 22:41:35 -04:00
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help:
|
|
|
|
@echo 'XEP makefile targets:'
|
|
|
|
@echo ' '
|
|
|
|
@echo ' help - (this message)'
|
2015-09-01 00:15:10 -04:00
|
|
|
@echo ' all - build all XEPs (html and pdfs)'
|
|
|
|
@echo ' pdf - build all XEPs'
|
|
|
|
@echo ' html - build all XEPs'
|
2015-08-31 22:41:35 -04:00
|
|
|
@echo ' clean - recursively unlink the build tree'
|
2015-09-28 13:07:47 -04:00
|
|
|
@echo ' preview - builds html whenever an XEP changes (requires inotify-tools)'
|
2015-09-01 00:15:10 -04:00
|
|
|
@echo ' xep-xxxx - build xep-xxxx.html and xep-xxxx.pdf'
|
|
|
|
@echo ' xep-xxxx.html - build xep-xxxx.html'
|
|
|
|
@echo ' xep-xxxx.pdf - build xep-xxxx.html'
|
2015-08-31 22:41:35 -04:00
|
|
|
@echo ' '
|
|
|
|
@echo 'Output directory: "$(OUTDIR)/"'
|
|
|
|
|
|
|
|
.PHONY: all
|
2015-09-01 00:15:10 -04:00
|
|
|
all: html pdfs
|
|
|
|
|
|
|
|
.PHONY: html
|
|
|
|
html: $(patsubst %.xml, $(OUTDIR)/%.html, $(wildcard *.xml))
|
|
|
|
|
|
|
|
.PHONY: pdf
|
|
|
|
pdf: $(patsubst %.xml, $(OUTDIR)/%.pdf, $(wildcard *.xml))
|
2015-08-31 22:41:35 -04:00
|
|
|
|
|
|
|
.PHONY: xep-%
|
2015-09-22 15:03:35 -04:00
|
|
|
xep-%: $(OUTDIR)/xep-%.html $(OUTDIR)/xep-%.pdf ;
|
2015-09-01 00:15:10 -04:00
|
|
|
|
|
|
|
.PHONY: xep-%.html
|
2015-09-22 15:03:35 -04:00
|
|
|
xep-%.html: $(OUTDIR)/xep-%.html ;
|
2015-09-01 00:15:10 -04:00
|
|
|
|
|
|
|
.PHONY: xep-%.pdf
|
2015-09-22 15:03:35 -04:00
|
|
|
xep-%.pdf: $(OUTDIR)/xep-%.pdf ;
|
2015-08-31 22:41:35 -04:00
|
|
|
|
2015-09-01 00:15:10 -04:00
|
|
|
$(OUTDIR)/%.html: %.xml $(XMLDEPS)
|
2015-09-10 14:06:50 -04:00
|
|
|
xsltproc --path $(CURDIR) xep.xsl "$<" > "$@" && echo "Finished building $@"
|
2015-08-31 22:41:35 -04:00
|
|
|
|
2015-09-01 00:15:10 -04:00
|
|
|
$(OUTDIR)/%.pdf: %.xml $(TEMPDIR)/%.xml.texml $(TEMPDIR)/%.xml.texml.tex $(TEXMLDEPS)
|
|
|
|
cd $(TEMPDIR); xelatex $(TEMPDIR)/$<.texml.tex
|
|
|
|
mv $(TEMPDIR)/$<.texml.pdf $(OUTDIR)/$(patsubst %.xml.pdf,%.pdf,$<.pdf)
|
2015-09-10 14:06:50 -04:00
|
|
|
echo "Finished building $(patsubst %.xml.pdf,%.pdf,$<.pdf)"
|
2015-09-01 00:15:10 -04:00
|
|
|
|
|
|
|
$(TEMPDIR)/%.xml.texml: %.xml $(TEXMLDEPS) $(TEMPDIR)
|
|
|
|
xsltproc -o $(TEMPDIR)/$<.texml xep2texml.xsl "$<"
|
|
|
|
|
|
|
|
$(TEMPDIR)/%.xml.texml.tex: $(TEMPDIR)/%.xml.texml $(OUTDIR) $(TEMPDIR)
|
|
|
|
texml -e utf8 $< $<.tex
|
2015-09-10 14:12:30 -04:00
|
|
|
sed -i -e 's|\([\s"]\)\([^"]http\://[^ "]*\)|\1\\path{\2}|g' \
|
|
|
|
-e 's|\\hyperref\[#\([^}]*\)\]|\\hyperref\[\1\]|g' \
|
|
|
|
-e 's|\\pageref{#\([^}]*\)}|\\pageref{\1}|g' $<.tex
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2015-09-22 16:07:41 -04:00
|
|
|
$(RESOURCESDIR)/xmpp-text.pdf: $(RESOURCESDIR)
|
|
|
|
curl -o $@ $(XMPPIMAGESURL)/xmpp-text.pdf
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2015-09-22 16:07:41 -04:00
|
|
|
$(RESOURCESDIR)/xmpp.pdf: $(RESOURCESDIR)
|
|
|
|
curl -o $@ $(XMPPIMAGESURL)/images/xmpp.pdf
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2015-09-22 16:07:41 -04:00
|
|
|
$(TEMPDIR) $(OUTDIR) $(RESOURCESDIR):
|
|
|
|
mkdir -p $@
|
2015-08-31 22:41:35 -04:00
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
rm -rf $(OUTDIR)
|
2015-09-28 13:07:47 -04:00
|
|
|
|
|
|
|
.PHONY: preview
|
|
|
|
preview:
|
|
|
|
inotifywait -m -e close_write,moved_to --format '%e %f' . | \
|
|
|
|
while read -r event file; do \
|
|
|
|
if [ "$${file: -4}" == ".xml" ]; then \
|
|
|
|
xsltproc --path $(CURDIR) xep.xsl "$${file}" > "$(OUTDIR)/$${file: :8}.html" && echo "Built $${file: :8}.html $${event}"; \
|
|
|
|
fi \
|
|
|
|
done
|