No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. .SILENT:
  2. OUTDIR?=build
  3. REFSDIR?=$(OUTDIR)/refs
  4. EXAMPLESDIR?=$(OUTDIR)/examples
  5. XMLDEPS=xep.xsd xep.ent xep.dtd ref.xsl $(OUTDIR)
  6. TEXMLDEPS=xep2texml.xsl $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf
  7. XEPDIRS=. inbox
  8. HTMLDEPS=xep.xsl $(CSSTARGETS) $(JSTARGETS)
  9. base_CSSTARGETS=xmpp.css prettify.css
  10. CSSTARGETS=$(addprefix $(OUTDIR)/,$(base_CSSTARGETS))
  11. proto_CSSTARGETS=$(addprefix $(OUTDIR)/inbox/,$(base_CSSTARGETS))
  12. base_JSTARGETS=prettify.js
  13. JSTARGETS=$(addprefix $(OUTDIR)/,$(base_JSTARGETS))
  14. proto_JSTARGETS=$(addprefix $(OUTDIR)/inbox/,$(base_JSTARGETS))
  15. proto_HTMLDEPS=xep.xsl $(proto_CSSTARGETS) $(proto_JSTARGETS)
  16. DO_XELATEX=cd $(OUTDIR); xelatex --interaction=nonstopmode -no-shell-escape "$(notdir $(basename $@)).tex" >/dev/null
  17. xeps=$(wildcard *.xml)
  18. proto_xeps=$(wildcard inbox/*.xml)
  19. all_xeps=$(xeps) $(proto_xeps)
  20. xep_xmls=$(patsubst %.xml,$(OUTDIR)/%.xml,$(xeps))
  21. proto_xep_xmls=$(patsubst %.xml,$(OUTDIR)/%.xml,$(proto_xeps))
  22. all_xep_xmls=$(xep_xmls) $(proto_xep_xmls)
  23. xep_htmls=$(patsubst %.xml,$(OUTDIR)/%.html,$(xeps))
  24. proto_xep_htmls=$(patsubst %.xml,$(OUTDIR)/%.html,$(proto_xeps))
  25. all_xep_htmls=$(xep_htmls) $(proto_xep_htmls)
  26. xep_pdfs=$(patsubst %.xml,$(OUTDIR)/%.pdf,$(xeps))
  27. xep_refs=$(patsubst xep-%.xml, $(REFSDIR)/reference.XSF.XEP-%.xml, $(xeps))
  28. xep_examples=$(patsubst xep-%.xml, $(EXAMPLESDIR)/%.xml, $(xeps))
  29. .PHONY: help
  30. help:
  31. @echo 'XEP makefile targets:'
  32. @echo ' '
  33. @echo ' help - (this message)'
  34. @echo ' all - build all XEPs (same as make html)'
  35. @echo ' refs - build all IETF refs'
  36. @echo ' html - build all XEPs'
  37. @echo ' clean - recursively unlink the build tree'
  38. @echo ' preview - builds html whenever an XEP changes (requires inotify-tools)'
  39. @echo ' examples - extract all examples'
  40. @echo ' xep-xxxx - build HTML, PDF, examples, and reference for the XEP'
  41. @echo ' xep-xxxx.pdf - build xep-xxxx.pdf (requires xelatex and texml)'
  42. @echo ' xep-xxxx.html - build xep-xxxx.html'
  43. @echo ' '
  44. @echo 'Output directory: "$(OUTDIR)/"'
  45. .PHONY: all
  46. all: html
  47. .PHONY: xeplist
  48. xeplist: $(OUTDIR)/xeplist.xml
  49. .PHONY: html
  50. html: $(xep_htmls)
  51. .PHONY: xml
  52. xml: $(xep_xmls)
  53. .PHONY: inbox-html
  54. inbox-html: $(proto_xep_htmls)
  55. .PHONY: inbox-xml
  56. inbox-xml: $(proto_xep_xmls)
  57. .PHONY: pdf
  58. pdf: $(xep_pdfs)
  59. .PHONY: refs
  60. refs: $(xep_refs)
  61. .PHONY: examples
  62. examples: $(xep_examples)
  63. .PHONY: xep-%
  64. xep-%: $(OUTDIR)/xep-%.html $(REFSDIR)/reference.XSF.XEP-%.xml $(OUTDIR)/xep-%.pdf $(EXAMPLESDIR)/%.xml;
  65. .PHONY: xep-%.html
  66. xep-%.html: $(OUTDIR)/xep-%.html ;
  67. .PHONY: xep-%.pdf
  68. xep-%.pdf: $(OUTDIR)/xep-%.pdf ;
  69. $(all_xep_xmls): $(OUTDIR)/%.xml: %.xml
  70. cp $< $@
  71. $(OUTDIR)/xeplist.xml: $(wildcard *.xml) $(wildcard inbox/*.xml)
  72. ./tools/extract-metadata.py > $@
  73. $(EXAMPLESDIR)/%.xml: xep-%.xml $(XMLDEPS) examples.xsl $(EXAMPLESDIR)
  74. xsltproc --path $(CURDIR) examples.xsl "$<" > "$@" && echo "Finished building $@"
  75. $(REFSDIR)/reference.XSF.XEP-%.xml: xep-%.xml $(XMLDEPS) ref.xsl $(REFSDIR)
  76. xsltproc --path $(CURDIR) ref.xsl "$<" > "$@" && echo "Finished building $@"
  77. $(xep_htmls): $(OUTDIR)/xep-%.html: xep-%.xml $(XMLDEPS) $(HTMLDEPS)
  78. xmllint --nonet --noout --noent --loaddtd --valid "$<"
  79. # Check for non-data URIs
  80. ! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
  81. # Actually build the HTML
  82. xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" xep.xsl "$<" > "$@" && echo "Finished building $@"
  83. $(proto_xep_htmls): $(OUTDIR)/inbox/%.html: inbox/%.xml $(XMLDEPS) $(proto_HTMLDEPS)
  84. xmllint --nonet --noout --noent --loaddtd --valid "$<"
  85. # Check for non-data URIs
  86. ! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
  87. # Actually build the HTML
  88. xsltproc --path $(CURDIR) --param htmlbase "$(if $(findstring inbox,$<),'../','./')" xep.xsl "$<" > "$@" && echo "Finished building $@"
  89. $(OUTDIR)/xmpp.pdf $(OUTDIR)/xmpp-text.pdf: $(OUTDIR)
  90. cp "resources/$(notdir $@)" "$@"
  91. $(OUTDIR)/%.pdf: %.xml $(XMLDEPS) $(TEXMLDEPS)
  92. xmllint --nonet --noout --noent --loaddtd --valid "$<"
  93. # Check for non-data URIs
  94. ! xmllint --nonet --noout --noent --loaddtd --xpath "//img/@src[not(starts-with(., 'data:'))]" $< 2>/dev/null && true
  95. xsltproc --path $(CURDIR) xep2texml.xsl "$<" > "$(@:.pdf=.tex.xml)"
  96. texml -e utf8 "$(@:.pdf=.tex.xml)" "$(@:.pdf=.tex)"
  97. sed -i -e 's|\([\s"]\)\([^"]http://[^ "]*\)|\1\\path{\2}|g' \
  98. -e 's|\\hyperref\[#\([^}]*\)\]|\\hyperref\[\1\]|g' \
  99. -e 's|\\pageref{#\([^}]*\)}|\\pageref{\1}|g' "$(@:.pdf=.tex)"
  100. while ($(DO_XELATEX) ; \
  101. grep -q "Rerun to get" $(<:.xml=.log) ) do true; \
  102. done
  103. echo "Finished building $@"
  104. $(JSTARGETS): $(OUTDIR)
  105. cp "$(notdir $@)" "$@"
  106. $(CSSTARGETS): $(OUTDIR)
  107. cp "$(notdir $@)" "$@"
  108. $(proto_JSTARGETS): $(OUTDIR)/inbox
  109. cp "$(notdir $@)" "$@"
  110. $(proto_CSSTARGETS): $(OUTDIR)/inbox
  111. cp "$(notdir $@)" "$@"
  112. $(EXAMPLESDIR) $(REFSDIR) $(OUTDIR) $(OUTDIR)/inbox:
  113. mkdir -p "$@"
  114. .PHONY: clean
  115. clean:
  116. rm -rf $(OUTDIR)
  117. .PHONY: preview
  118. preview:
  119. inotifywait -m -e close_write,moved_to --format '%e %w %f' $(XEPDIRS) | \
  120. while read -r event dir file; do \
  121. if [ "$${file: -4}" == ".xml" ]; then \
  122. xsltproc --path $(CURDIR) xep.xsl "$${dir}/$${file}" > "$(OUTDIR)/$${file%.*}.html" && echo "Built $${file%.*}.html $${event}"; \
  123. fi \
  124. done
  125. .PHONY: docker
  126. docker:
  127. docker build -t xmpp-org/extensions .
  128. .PHONY: dockerhtml
  129. dockerhtml:
  130. docker build -t xmpp-org/extensions . --build-arg NCORES=9 --build-arg TARGETS="html inbox-html"
  131. .PHONY: testdocker
  132. testdocker:
  133. docker run -d --name tmpxeps -p 3080:80 xmpp-org/extensions
  134. .PHONY: stopdocker
  135. stopdocker:
  136. docker stop tmpxeps; docker rm -v tmpxeps