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)
|
2017-01-03 16:22:30 -05:00
|
|
|
TEXMLDEPS=xep2texml.xsl $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf
|
2015-09-22 16:07:41 -04:00
|
|
|
XMPPIMAGESURL=https://xmpp.org/images
|
2015-10-10 10:25:21 -04:00
|
|
|
XEPDIRS=. inbox
|
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-11-20 13:49:25 -05:00
|
|
|
@echo ' all - build all XEPs (same as make html)'
|
2015-09-01 00:15:10 -04:00
|
|
|
@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-11-20 13:49:25 -05:00
|
|
|
@echo ' xep-xxxx - build xep-xxxx.html'
|
2017-01-03 16:22:30 -05:00
|
|
|
@echo ' xep-xxxx.pdf - build xep-xxxx.pdf (requires xelatex and texml)'
|
2015-09-01 00:15:10 -04:00
|
|
|
@echo ' xep-xxxx.html - build xep-xxxx.html'
|
2015-08-31 22:41:35 -04:00
|
|
|
@echo ' '
|
|
|
|
@echo 'Output directory: "$(OUTDIR)/"'
|
|
|
|
|
|
|
|
.PHONY: all
|
2015-11-20 13:49:25 -05:00
|
|
|
all: html
|
2015-09-01 00:15:10 -04:00
|
|
|
|
|
|
|
.PHONY: html
|
|
|
|
html: $(patsubst %.xml, $(OUTDIR)/%.html, $(wildcard *.xml))
|
|
|
|
|
2017-01-03 16:22:30 -05:00
|
|
|
.PHONY: pdf
|
|
|
|
pdf: $(patsubst %.xml, $(OUTDIR)/%.pdf, $(wildcard *.xml))
|
|
|
|
|
2015-08-31 22:41:35 -04:00
|
|
|
.PHONY: xep-%
|
2015-11-20 13:49:25 -05:00
|
|
|
xep-%: $(OUTDIR)/xep-%.html ;
|
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
|
|
|
|
2017-01-03 16:22:30 -05:00
|
|
|
.PHONY: xep-%.pdf
|
|
|
|
xep-%.pdf: $(OUTDIR)/xep-%.pdf ;
|
|
|
|
|
2015-11-20 13:49:25 -05:00
|
|
|
.PHONY: dependencies
|
|
|
|
dependencies: $(OUTDIR)/prettify.css $(OUTDIR)/prettify.js $(OUTDIR)/xmpp.css ;
|
2015-08-31 22:41:35 -04:00
|
|
|
|
2015-11-20 13:49:25 -05:00
|
|
|
$(OUTDIR)/%.html: %.xml $(XMLDEPS) dependencies
|
2017-01-01 23:41:57 -05:00
|
|
|
xmllint --nonet --noout --noent --loaddtd --valid "$<"
|
2016-12-01 15:19:03 -05:00
|
|
|
# Check for non-data URIs
|
|
|
|
! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
|
2017-01-03 16:22:30 -05:00
|
|
|
|
2016-12-01 15:19:03 -05:00
|
|
|
# Actually build the HTML
|
2015-09-10 14:06:50 -04:00
|
|
|
xsltproc --path $(CURDIR) xep.xsl "$<" > "$@" && echo "Finished building $@"
|
2015-08-31 22:41:35 -04:00
|
|
|
|
2017-01-05 14:33:54 -05:00
|
|
|
$(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf: $(OUTDIR)
|
2017-01-03 16:22:30 -05:00
|
|
|
cp "resources/$(notdir $@)" "$@"
|
|
|
|
|
|
|
|
$(OUTDIR)/%.pdf: %.xml $(TEXMLDEPS) $(XMLDEPS) dependencies
|
2017-01-01 23:41:57 -05:00
|
|
|
xmllint --nonet --noout --noent --loaddtd --valid "$<"
|
2017-01-03 16:22:30 -05:00
|
|
|
# Check for non-data URIs
|
|
|
|
! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
|
|
|
|
|
|
|
|
xsltproc --path $(CURDIR) xep2texml.xsl "$<" > "$(@:.pdf=.tex.xml)"
|
|
|
|
texml -e utf8 "$(@:.pdf=.tex.xml)" "$(@:.pdf=.tex)"
|
|
|
|
sed -i -e 's|\([\s"]\)\([^"]http://[^ "]*\)|\1\\path{\2}|g' \
|
|
|
|
-e 's|\\hyperref\[#\([^}]*\)\]|\\hyperref\[\1\]|g' \
|
|
|
|
-e 's|\\pageref{#\([^}]*\)}|\\pageref{\1}|g' "$(@:.pdf=.tex)"
|
|
|
|
cd $(OUTDIR); xelatex -interaction=batchmode -no-shell-escape "$(notdir $(basename $@)).tex" && echo "Finished building $@"
|
|
|
|
|
2015-11-20 13:49:25 -05:00
|
|
|
$(OUTDIR)/%.js: %.js
|
|
|
|
cp "$<" "$@"
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2015-11-20 13:49:25 -05:00
|
|
|
$(OUTDIR)/%.css: %.css
|
|
|
|
cp "$<" "$@"
|
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:
|
2015-10-10 10:25:21 -04:00
|
|
|
inotifywait -m -e close_write,moved_to --format '%e %w %f' $(XEPDIRS) | \
|
|
|
|
while read -r event dir file; do \
|
2015-09-28 13:07:47 -04:00
|
|
|
if [ "$${file: -4}" == ".xml" ]; then \
|
2015-10-10 10:25:21 -04:00
|
|
|
xsltproc --path $(CURDIR) xep.xsl "$${dir}/$${file}" > "$(OUTDIR)/$${file%.*}.html" && echo "Built $${file%.*}.html $${event}"; \
|
2015-09-28 13:07:47 -04:00
|
|
|
fi \
|
|
|
|
done
|