at 18.09-beta 2.9 kB view raw
1MD_TARGETS=$(addsuffix .xml, $(basename $(wildcard ./*.md ./**/*.md))) 2 3.PHONY: all 4all: validate format out/html/index.html out/epub/manual.epub 5 6.PHONY: debug 7debug: 8 nix-shell --run "xmloscopy --docbook5 ./manual.xml ./manual-full.xml" 9 10.PHONY: format 11format: 12 find . -iname '*.xml' -type f -print0 | xargs -0 -I{} -n1 \ 13 xmlformat --config-file "$$XMLFORMAT_CONFIG" -i {} 14 15.PHONY: fix-misc-xml 16fix-misc-xml: 17 find . -iname '*.xml' -type f \ 18 -exec ../nixos/doc/varlistentry-fixer.rb {} ';' 19 20.PHONY: clean 21clean: 22 rm -f ${MD_TARGETS} .version manual-full.xml 23 rm -rf ./out/ ./highlightjs 24 25.PHONY: validate 26validate: manual-full.xml 27 jing "$$RNG" manual-full.xml 28 29out/html/index.html: manual-full.xml style.css highlightjs 30 mkdir -p out/html 31 xsltproc ${xsltFlags} \ 32 --nonet --xinclude \ 33 --output $@ \ 34 "$$XSL/docbook/xhtml/docbook.xsl" \ 35 ./manual-full.xml 36 37 mkdir -p out/html/highlightjs/ 38 cp -r highlightjs out/html/ 39 40 cp ./overrides.css out/html/ 41 cp ./style.css out/html/style.css 42 43 mkdir -p out/html/images/callouts 44 cp "$$XSL/docbook/images/callouts/"*.svg out/html/images/callouts/ 45 chmod u+w -R out/html/ 46 47out/epub/manual.epub: manual-full.xml 48 mkdir -p out/epub/scratch 49 xsltproc ${xsltFlags} --nonet \ 50 --output out/epub/scratch/ \ 51 "$$XSL/docbook/epub/docbook.xsl" \ 52 ./manual-full.xml 53 54 cp ./overrides.css out/epub/scratch/OEBPS 55 cp ./style.css out/epub/scratch/OEBPS 56 mkdir -p out/epub/scratch/OEBPS/images/callouts/ 57 cp "$$XSL/docbook/images/callouts/"*.svg out/epub/scratch/OEBPS/images/callouts/ 58 echo "application/epub+zip" > mimetype 59 zip -0Xq "out/epub/manual.epub" mimetype 60 rm mimetype 61 cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" * 62 rm -rf "out/epub/scratch/" 63 64highlightjs: 65 mkdir -p highlightjs 66 cp -r "$$HIGHLIGHTJS/highlight.pack.js" highlightjs/ 67 cp -r "$$HIGHLIGHTJS/LICENSE" highlightjs/ 68 cp -r "$$HIGHLIGHTJS/mono-blue.css" highlightjs/ 69 cp -r "$$HIGHLIGHTJS/loader.js" highlightjs/ 70 71 72manual-full.xml: ${MD_TARGETS} .version *.xml 73 xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml 74 75.version: 76 nix-instantiate --eval \ 77 -E '(import ../lib).version' > .version 78 79%.section.xml: %.section.md 80 pandoc $^ -w docbook+smart \ 81 -f markdown+smart \ 82 | sed -e 's|<ulink url=|<link xlink:href=|' \ 83 -e 's|</ulink>|</link>|' \ 84 -e 's|<sect. id=|<section xml:id=|' \ 85 -e 's|</sect[0-9]>|</section>|' \ 86 -e '1s| id=| xml:id=|' \ 87 -e '1s|\(<[^ ]* \)|\1xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" |' \ 88 | cat > $@ 89 90%.chapter.xml: %.chapter.md 91 pandoc $^ -w docbook+smart \ 92 --top-level-division=chapter \ 93 -f markdown+smart \ 94 | sed -e 's|<ulink url=|<link xlink:href=|' \ 95 -e 's|</ulink>|</link>|' \ 96 -e 's|<sect. id=|<section xml:id=|' \ 97 -e 's|</sect[0-9]>|</section>|' \ 98 -e '1s| id=| xml:id=|' \ 99 -e '1s|\(<[^ ]* \)|\1|' \ 100 | cat > $@