aboutsummaryrefslogtreecommitdiff
path: root/docs/makefile
diff options
context:
space:
mode:
Diffstat (limited to 'docs/makefile')
-rw-r--r--docs/makefile32
1 files changed, 32 insertions, 0 deletions
diff --git a/docs/makefile b/docs/makefile
new file mode 100644
index 0000000..e4fcb15
--- /dev/null
+++ b/docs/makefile
@@ -0,0 +1,32 @@
+PANDOC = pandoc
+M4 = m4
+RM = rm -f
+CHROME = chromium --headless --run-all-compositor-stages-before-draw --virtual-time-budget=10000 --print-to-pdf-no-header
+CURL = curl
+PUP = pup
+
+SRCS = $(wildcard *.md)
+HTML_T = $(SRCS:.md=.html)
+PDF_T = $(SRCS:.md=.pdf)
+
+.PRECIOUS: %.toc %.con
+
+all: $(HTML_T)
+
+gen/paged.polyfill.js:
+ $(CURL) -Ls https://unpkg.com/pagedjs/dist/paged.polyfill.js > $@
+
+%.con: %.md
+ $(PANDOC) $< --to=html > $@
+
+%.toc: %.md
+ $(PANDOC) $< -s --toc --to=html 2> /dev/null | $(PUP) '#TOC' | sed -r 's/<(.?)ul>/<\1ol>/g' > $@
+
+%.html: %.con %.toc gen/doc.m4 gen/paged.polyfill.js gen/style.css
+ $(M4) -Igen -DNAME=$(basename $<) gen/doc.m4 > $@
+
+%.pdf: %.html
+ $(CHROME) --print-to-pdf=$@ $< 2> /dev/null
+
+clean:
+ $(RM) $(HTML_T) $(PDF_T) *.toc *.con gen/paged.polyfill.js