Documentation with Make
Documentation requires conversion of different file formats. Asciidoc, Ghostscript and Pandoc are tools to convert documents. This is a typical use case for Make tool.
Generation of this Website
html
%.html: %.asciidoc asciidoc -adata-uri -aicondir=$PWD $< %.txt: %.html w3m $< > $@ %.png: %.html wkhtmltoimage $< $@ %.256.png: %.png convert $< -scale 256 $@ .PHONY: clean clean: find \( -name '*.html' -o -name '*.png' -o -name '*.txt' \) -delete .DEFAULT_GOAL:=index.html wiki/documentation/AsciiDoc.html: wiki/Wiki.256.png index.html: README.html \ wiki/Wiki.html \ wiki/android/Android.html \ wiki/databases/SQLite.html \ wiki/databases/Samba.html \ wiki/debian/Debian.html \ wiki/debian/Devuan.html \ wiki/debian/GNU.html \ wiki/debian/Linux.html \ wiki/debian/SUSE.html \ wiki/documentation/AsciiDoc.html \ wiki/documentation/Make.html \ wiki/programming/Bash.html \ wiki/programming/C.html \ wiki/programming/Cpp.html \ wiki/programming/Java.html \ wiki/programming/Haskell.html \ wiki/programming/Perl.html \ wiki/programming/Qt.html \ wiki/tools/Git.html \ wiki/tools/Jenkins.html \ wiki/tools/Maven.html \ wiki/qemu/QEMU.html \ wiki/qemu/VirtualXPVHD.html \ wiki/web/Apache.html \ wiki/web/Mojolicious.html \ wiki/web/Typo3.html \ wiki/web/XML.html cp $^ . 2>&- || cp $< index.html
Here are some scripts for pdf documents.
pandoc
%.pdf: %.md pandoc $< \ --metadata=papersize=a4 \ --metadata=lang=gb \ --metadata=bookmarks=true \ --metadata=colorlinks=true \ --output $@
This are rules for ps to pdf conversion with gs.
ps2pdf
# include this in a makefile to convert documents # in ${PS2PDF} variable into a ${.DEFAULT_GOAL}.pdf .INTERMEDIATE: pdfmarks ${PS2PDF} ifdef PS2PDF ${.DEFAULT_GOAL}.ps: ${PS2PDF} psmerge $^ > $@ # gs(1): -q switch, to prevent Ghostscript # from writing messages to standard output ${.DEFAULT_GOAL}.pdf: pdfmarks ${.DEFAULT_GOAL}.ps gs -q -sOutputFile=- -sDEVICE=pdfwrite \ -dPrinted=false -dBATCH -dNOPAUSE \ -dPDFSETTINGS=/ebook -DSAFER \ $^ | ./pdf2md5.sh > $@ endif # http://milan.kupcevic.net/ghostscript-ps-pdf/ .ONESHELL: pdfmarks: cat > $@ <<-'EOF' [ /Title (Document title) /Author (Author name) /Subject (Subject description) /Keywords (comma, separated, keywords) /ModDate (D:20061204092842) /CreationDate (D:20061204092842) /Creator (application name or creator note) /Producer (PDF producer name or note) /DOCINFO pdfmark EOF %.ps: %.pdf < $< pdf2ps - - > $@ %.ps: %.BMP convert $< $@ %.ps: %.tif convert $< $@
This script writes zeros into uuid.
pdf2md5
#!/bin/sh # erase uuid and trailer in a pdf document bbe -b /uuid:/:41 -e 'f 5 \x00' | \ tac | \ bbe -e L\ 1 -b '/[</:34' -e 'f 2 \x00' | \ bbe -e L\ 1 -b '/> </:35' -e 'f 3 \x00' | \ tac
ps2pdf
# include this in a makefile to convert documents # in ${PS2PDF} variable into a ${.DEFAULT_GOAL}.pdf .INTERMEDIATE: pdfmarks ${PS2PDF} ifdef PS2PDF ${.DEFAULT_GOAL}.ps: ${PS2PDF} psmerge $^ > $@ # gs(1): -q switch, to prevent Ghostscript # from writing messages to standard output ${.DEFAULT_GOAL}.pdf: pdfmarks ${.DEFAULT_GOAL}.ps gs -q -sOutputFile=- -sDEVICE=pdfwrite \ -dPrinted=false -dBATCH -dNOPAUSE \ -dPDFSETTINGS=/ebook -DSAFER \ $^ | ./pdf2md5.sh > $@ endif # http://milan.kupcevic.net/ghostscript-ps-pdf/ .ONESHELL: pdfmarks: cat > $@ <<-'EOF' [ /Title (Document title) /Author (Author name) /Subject (Subject description) /Keywords (comma, separated, keywords) /ModDate (D:20061204092842) /CreationDate (D:20061204092842) /Creator (application name or creator note) /Producer (PDF producer name or note) /DOCINFO pdfmark EOF %.ps: %.pdf < $< pdf2ps - - > $@ %.ps: %.BMP convert $< $@ %.ps: %.tif convert $< $@