2015-08-31 22:41:35 -04:00
|
|
|
.SILENT:
|
|
|
|
|
|
|
|
OUTDIR?=build
|
2017-01-09 14:14:02 -05:00
|
|
|
REFSDIR?=$(OUTDIR)/refs
|
2017-01-09 14:41:51 -05:00
|
|
|
EXAMPLESDIR?=$(OUTDIR)/examples
|
2017-01-09 14:14:02 -05:00
|
|
|
XMLDEPS=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-10-10 10:25:21 -04:00
|
|
|
XEPDIRS=. inbox
|
2017-01-13 01:33:28 -05:00
|
|
|
HTMLDEPS=xep.xsl $(CSSTARGETS) $(JSTARGETS)
|
2017-08-24 08:31:17 -04:00
|
|
|
|
2019-04-06 04:55:04 -04:00
|
|
|
base_CSSTARGETS=xmpp.css prettify.css
|
2017-08-24 08:31:17 -04:00
|
|
|
CSSTARGETS=$(addprefix $(OUTDIR)/,$(base_CSSTARGETS))
|
|
|
|
proto_CSSTARGETS=$(addprefix $(OUTDIR)/inbox/,$(base_CSSTARGETS))
|
|
|
|
base_JSTARGETS=prettify.js
|
|
|
|
JSTARGETS=$(addprefix $(OUTDIR)/,$(base_JSTARGETS))
|
|
|
|
proto_JSTARGETS=$(addprefix $(OUTDIR)/inbox/,$(base_JSTARGETS))
|
|
|
|
|
|
|
|
proto_HTMLDEPS=xep.xsl $(proto_CSSTARGETS) $(proto_JSTARGETS)
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2017-03-20 10:40:28 -04:00
|
|
|
DO_XELATEX=cd $(OUTDIR); xelatex --interaction=nonstopmode -no-shell-escape "$(notdir $(basename $@)).tex" >/dev/null
|
|
|
|
|
2017-08-23 07:22:06 -04:00
|
|
|
xeps=$(wildcard *.xml)
|
|
|
|
proto_xeps=$(wildcard inbox/*.xml)
|
|
|
|
all_xeps=$(xeps) $(proto_xeps)
|
|
|
|
|
|
|
|
xep_xmls=$(patsubst %.xml,$(OUTDIR)/%.xml,$(xeps))
|
|
|
|
proto_xep_xmls=$(patsubst %.xml,$(OUTDIR)/%.xml,$(proto_xeps))
|
|
|
|
all_xep_xmls=$(xep_xmls) $(proto_xep_xmls)
|
2019-04-10 11:53:43 -04:00
|
|
|
xep_ancillary=$(patsubst %,$(OUTDIR)/%,xep.xsl)
|
2017-08-23 07:22:06 -04:00
|
|
|
|
|
|
|
xep_htmls=$(patsubst %.xml,$(OUTDIR)/%.html,$(xeps))
|
|
|
|
proto_xep_htmls=$(patsubst %.xml,$(OUTDIR)/%.html,$(proto_xeps))
|
|
|
|
all_xep_htmls=$(xep_htmls) $(proto_xep_htmls)
|
|
|
|
|
|
|
|
xep_pdfs=$(patsubst %.xml,$(OUTDIR)/%.pdf,$(xeps))
|
|
|
|
xep_refs=$(patsubst xep-%.xml, $(REFSDIR)/reference.XSF.XEP-%.xml, $(xeps))
|
|
|
|
xep_examples=$(patsubst xep-%.xml, $(EXAMPLESDIR)/%.xml, $(xeps))
|
|
|
|
|
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)'
|
2017-01-09 14:14:02 -05:00
|
|
|
@echo ' refs - build all IETF refs'
|
2015-09-01 00:15:10 -04:00
|
|
|
@echo ' html - build all XEPs'
|
2018-08-30 02:54:49 -04:00
|
|
|
@echo ' inbox-html - build all ProtoXEPs'
|
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)'
|
2017-01-09 14:41:51 -05:00
|
|
|
@echo ' examples - extract all examples'
|
|
|
|
@echo ' xep-xxxx - build HTML, PDF, examples, and reference for the XEP'
|
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
|
|
|
|
2017-08-23 07:26:36 -04:00
|
|
|
.PHONY: xeplist
|
|
|
|
xeplist: $(OUTDIR)/xeplist.xml
|
|
|
|
|
2015-09-01 00:15:10 -04:00
|
|
|
.PHONY: html
|
2017-08-23 07:22:06 -04:00
|
|
|
html: $(xep_htmls)
|
|
|
|
|
|
|
|
.PHONY: xml
|
2019-04-10 11:53:43 -04:00
|
|
|
xml: $(xep_xmls) $(xep_ancillary)
|
2017-08-23 07:22:06 -04:00
|
|
|
|
|
|
|
.PHONY: inbox-html
|
|
|
|
inbox-html: $(proto_xep_htmls)
|
|
|
|
|
|
|
|
.PHONY: inbox-xml
|
2019-05-15 12:07:42 -04:00
|
|
|
inbox-xml: $(OUTDIR)/inbox $(proto_xep_xmls)
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2017-01-03 16:22:30 -05:00
|
|
|
.PHONY: pdf
|
2017-08-23 07:22:06 -04:00
|
|
|
pdf: $(xep_pdfs)
|
2017-01-03 16:22:30 -05:00
|
|
|
|
2017-01-09 14:14:02 -05:00
|
|
|
.PHONY: refs
|
2017-08-23 07:22:06 -04:00
|
|
|
refs: $(xep_refs)
|
2017-01-09 14:14:02 -05:00
|
|
|
|
2017-01-09 14:41:51 -05:00
|
|
|
.PHONY: examples
|
2017-08-23 07:22:06 -04:00
|
|
|
examples: $(xep_examples)
|
2017-01-09 14:41:51 -05:00
|
|
|
|
2015-08-31 22:41:35 -04:00
|
|
|
.PHONY: xep-%
|
2017-01-09 14:41:51 -05:00
|
|
|
xep-%: $(OUTDIR)/xep-%.html $(REFSDIR)/reference.XSF.XEP-%.xml $(OUTDIR)/xep-%.pdf $(EXAMPLESDIR)/%.xml;
|
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 ;
|
|
|
|
|
2019-04-19 18:34:41 -04:00
|
|
|
$(all_xep_xmls): $(OUTDIR)/%.xml: %.xml $(XMLDEPS)
|
|
|
|
xmllint --nonet --noent --loaddtd --dropdtd $< --output $@
|
2019-04-10 11:53:43 -04:00
|
|
|
|
|
|
|
$(OUTDIR)/xep.xsl: xep.xsl $(OUTDIR)
|
2017-08-23 07:22:06 -04:00
|
|
|
cp $< $@
|
|
|
|
|
2017-08-23 07:26:36 -04:00
|
|
|
$(OUTDIR)/xeplist.xml: $(wildcard *.xml) $(wildcard inbox/*.xml)
|
|
|
|
./tools/extract-metadata.py > $@
|
|
|
|
|
2017-01-09 14:41:51 -05:00
|
|
|
$(EXAMPLESDIR)/%.xml: xep-%.xml $(XMLDEPS) examples.xsl $(EXAMPLESDIR)
|
|
|
|
xsltproc --path $(CURDIR) examples.xsl "$<" > "$@" && echo "Finished building $@"
|
|
|
|
|
2017-01-09 14:14:02 -05:00
|
|
|
$(REFSDIR)/reference.XSF.XEP-%.xml: xep-%.xml $(XMLDEPS) ref.xsl $(REFSDIR)
|
|
|
|
xsltproc --path $(CURDIR) ref.xsl "$<" > "$@" && echo "Finished building $@"
|
2015-08-31 22:41:35 -04:00
|
|
|
|
2017-08-24 08:31:17 -04:00
|
|
|
$(xep_htmls): $(OUTDIR)/xep-%.html: xep-%.xml $(XMLDEPS) $(HTMLDEPS)
|
|
|
|
xmllint --nonet --noout --noent --loaddtd --valid "$<"
|
|
|
|
# Check for non-data URIs
|
|
|
|
! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
|
|
|
|
|
|
|
|
# Actually build the HTML
|
|
|
|
xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" xep.xsl "$<" > "$@" && echo "Finished building $@"
|
2017-08-23 10:56:01 -04:00
|
|
|
|
2017-08-24 08:31:17 -04:00
|
|
|
$(proto_xep_htmls): $(OUTDIR)/inbox/%.html: inbox/%.xml $(XMLDEPS) $(proto_HTMLDEPS)
|
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
|
2017-08-23 07:22:06 -04:00
|
|
|
xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" 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 $@)" "$@"
|
|
|
|
|
2017-01-09 14:14:02 -05:00
|
|
|
$(OUTDIR)/%.pdf: %.xml $(XMLDEPS) $(TEXMLDEPS)
|
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)"
|
2017-03-20 10:40:28 -04:00
|
|
|
while ($(DO_XELATEX) ; \
|
|
|
|
grep -q "Rerun to get" $(<:.xml=.log) ) do true; \
|
|
|
|
done
|
|
|
|
echo "Finished building $@"
|
2017-01-03 16:22:30 -05:00
|
|
|
|
2017-01-13 01:33:28 -05:00
|
|
|
$(JSTARGETS): $(OUTDIR)
|
|
|
|
cp "$(notdir $@)" "$@"
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2017-01-13 01:33:28 -05:00
|
|
|
$(CSSTARGETS): $(OUTDIR)
|
|
|
|
cp "$(notdir $@)" "$@"
|
2015-09-01 00:15:10 -04:00
|
|
|
|
2017-08-24 08:31:17 -04:00
|
|
|
$(proto_JSTARGETS): $(OUTDIR)/inbox
|
|
|
|
cp "$(notdir $@)" "$@"
|
|
|
|
|
|
|
|
$(proto_CSSTARGETS): $(OUTDIR)/inbox
|
|
|
|
cp "$(notdir $@)" "$@"
|
|
|
|
|
|
|
|
$(EXAMPLESDIR) $(REFSDIR) $(OUTDIR) $(OUTDIR)/inbox:
|
2017-01-09 15:50:43 -05:00
|
|
|
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
|
2017-05-11 10:11:29 -04:00
|
|
|
|
|
|
|
.PHONY: docker
|
|
|
|
docker:
|
|
|
|
docker build -t xmpp-org/extensions .
|
|
|
|
|
2018-02-08 14:21:48 -05:00
|
|
|
.PHONY: dockerhtml
|
|
|
|
dockerhtml:
|
|
|
|
docker build -t xmpp-org/extensions . --build-arg NCORES=9 --build-arg TARGETS="html inbox-html"
|
|
|
|
|
2017-05-11 10:11:29 -04:00
|
|
|
.PHONY: testdocker
|
|
|
|
testdocker:
|
|
|
|
docker run -d --name tmpxeps -p 3080:80 xmpp-org/extensions
|
|
|
|
|
|
|
|
.PHONY: stopdocker
|
|
|
|
stopdocker:
|
|
|
|
docker stop tmpxeps; docker rm -v tmpxeps
|