Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-19.03 112 lines 3.4 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 | while read f; do \ 13 echo $$f ;\ 14 xmlformat --config-file "$$XMLFORMAT_CONFIG" -i $$f ;\ 15 done 16 17.PHONY: fix-misc-xml 18fix-misc-xml: 19 find . -iname '*.xml' -type f \ 20 -exec ../nixos/doc/varlistentry-fixer.rb {} ';' 21 22.PHONY: clean 23clean: 24 rm -f ${MD_TARGETS} .version manual-full.xml functions/library/locations.xml functions/library/generated 25 rm -rf ./out/ ./highlightjs 26 27.PHONY: validate 28validate: manual-full.xml 29 jing "$$RNG" manual-full.xml 30 31out/html/index.html: manual-full.xml style.css highlightjs 32 mkdir -p out/html 33 xsltproc ${xsltFlags} \ 34 --nonet --xinclude \ 35 --output $@ \ 36 "$$XSL/docbook/xhtml/docbook.xsl" \ 37 ./manual-full.xml 38 39 mkdir -p out/html/highlightjs/ 40 cp -r highlightjs out/html/ 41 42 cp ./overrides.css out/html/ 43 cp ./style.css out/html/style.css 44 45 mkdir -p out/html/images/callouts 46 cp "$$XSL/docbook/images/callouts/"*.svg out/html/images/callouts/ 47 chmod u+w -R out/html/ 48 49out/epub/manual.epub: manual-full.xml 50 mkdir -p out/epub/scratch 51 xsltproc ${xsltFlags} --nonet \ 52 --output out/epub/scratch/ \ 53 "$$XSL/docbook/epub/docbook.xsl" \ 54 ./manual-full.xml 55 56 cp ./overrides.css out/epub/scratch/OEBPS 57 cp ./style.css out/epub/scratch/OEBPS 58 mkdir -p out/epub/scratch/OEBPS/images/callouts/ 59 cp "$$XSL/docbook/images/callouts/"*.svg out/epub/scratch/OEBPS/images/callouts/ 60 echo "application/epub+zip" > mimetype 61 zip -0Xq "out/epub/manual.epub" mimetype 62 rm mimetype 63 cd "out/epub/scratch/" && zip -Xr9D "../manual.epub" * 64 rm -rf "out/epub/scratch/" 65 66highlightjs: 67 mkdir -p highlightjs 68 cp -r "$$HIGHLIGHTJS/highlight.pack.js" highlightjs/ 69 cp -r "$$HIGHLIGHTJS/LICENSE" highlightjs/ 70 cp -r "$$HIGHLIGHTJS/mono-blue.css" highlightjs/ 71 cp -r "$$HIGHLIGHTJS/loader.js" highlightjs/ 72 73 74manual-full.xml: ${MD_TARGETS} .version functions/library/locations.xml functions/library/generated *.xml **/*.xml **/**/*.xml 75 xmllint --nonet --xinclude --noxincludenode manual.xml --output manual-full.xml 76 77.version: 78 nix-instantiate --eval \ 79 -E '(import ../lib).version' > .version 80 81function_locations := $(shell nix-build --no-out-link ./lib-function-locations.nix) 82 83functions/library/locations.xml: 84 ln -s $(function_locations) ./functions/library/locations.xml 85 86functions/library/generated: 87 nix-build ./lib-function-docs.nix \ 88 --arg locationsXml $(function_locations)\ 89 --out-link ./functions/library/generated 90 91%.section.xml: %.section.md 92 pandoc $^ -w docbook+smart \ 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|\(<[^ ]* \)|\1xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" |' \ 100 | cat > $@ 101 102%.chapter.xml: %.chapter.md 103 pandoc $^ -w docbook+smart \ 104 --top-level-division=chapter \ 105 -f markdown+smart \ 106 | sed -e 's|<ulink url=|<link xlink:href=|' \ 107 -e 's|</ulink>|</link>|' \ 108 -e 's|<sect. id=|<section xml:id=|' \ 109 -e 's|</sect[0-9]>|</section>|' \ 110 -e '1s| id=| xml:id=|' \ 111 -e '1s|\(<[^ ]* \)|\1|' \ 112 | cat > $@