|
| 1 | +DIR = dist |
| 2 | +INPUT = book |
| 3 | +OUTPUT = book |
| 4 | +# OUTPUT = book-$(date +%Y-%m-%d) |
| 5 | +DIAGRAM = --require=asciidoctor-diagram |
| 6 | +MATH = --require=asciidoctor-mathematical |
| 7 | +REQUIRES = ${DIAGRAM} ${MATH} |
| 8 | +OUTPUT_FOLDER = --destination-dir=${DIR} |
| 9 | +MANPAGE = --backend=manpage |
| 10 | +HTML = --backend=html5 -a max-width=75em |
| 11 | +RAW_HTML = --backend=html5 -a stylesheet! -a source-highlighter! |
| 12 | +PDF = --backend=pdf --require=asciidoctor-pdf |
| 13 | +EPUB = --backend=epub3 --require=asciidoctor-epub3 |
| 14 | +KINDLE = ${EPUB} -a ebook-format=kf8 |
| 15 | + |
| 16 | +# Public targets |
| 17 | + |
| 18 | +all: html raw_html pdf |
| 19 | +# all: clean manpage html raw_html pdf compressed_pdf epub kindle |
| 20 | + |
| 21 | +manpage: _build/book.1 |
| 22 | + |
| 23 | +html: _build/book.html |
| 24 | + |
| 25 | +raw_html: _build/raw_book.html |
| 26 | + |
| 27 | +pdf: _build/book.pdf |
| 28 | + |
| 29 | +compressed_pdf: _build/compressed_book.pdf |
| 30 | + |
| 31 | +epub: _build/book.epub |
| 32 | + |
| 33 | +kindle: _build/book.mobi |
| 34 | + |
| 35 | +stats: |
| 36 | + wc -w chapters/*.adoc |
| 37 | + |
| 38 | +clean: |
| 39 | + if [ -d ".asciidoctor" ]; \ |
| 40 | + then rm -r .asciidoctor; \ |
| 41 | + fi; \ |
| 42 | + if [ -d "${DIR}" ]; \ |
| 43 | + then rm -r ${DIR}; \ |
| 44 | + fi; \ |
| 45 | + |
| 46 | +# Private targets |
| 47 | + |
| 48 | +_build/book.1: |
| 49 | + asciidoctor ${MANPAGE} ${OUTPUT_FOLDER} --out-file=${OUTPUT}.1 ${INPUT}.adoc; \ |
| 50 | + |
| 51 | +_build/book.html: |
| 52 | + asciidoctor ${HTML} ${REQUIRES} ${OUTPUT_FOLDER} --out-file=${OUTPUT}.html ${INPUT}.adoc; \ |
| 53 | + |
| 54 | +_build/raw_book.html: |
| 55 | + asciidoctor ${RAW_HTML} ${REQUIRES} ${OUTPUT_FOLDER} --out-file=raw_${OUTPUT}.html ${INPUT}.adoc; \ |
| 56 | + |
| 57 | +# https://github.com/asciidoctor/asciidoctor-pdf/blob/master/docs/theming-guide.adoc |
| 58 | +# check _resources/pdfstyles |
| 59 | +_build/book.pdf: |
| 60 | + asciidoctor ${PDF} ${REQUIRES} ${OUTPUT_FOLDER} --out-file=${OUTPUT}.pdf ${INPUT}.adoc; \ |
| 61 | + |
| 62 | +# Courtesy of |
| 63 | +# http://www.smartjava.org/content/compress-pdf-mac-using-command-line-free |
| 64 | +# Requires `brew install ghostscript` |
| 65 | +_build/compressed_book.pdf: _build/book.pdf |
| 66 | + gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=${DIR}/compressed_book.pdf ${DIR}/book.pdf; \ |
| 67 | + |
| 68 | +# check _resources/epubstyles |
| 69 | +_build/book.epub: |
| 70 | + asciidoctor ${EPUB} ${REQUIRES} ${OUTPUT_FOLDER} --out-file=${OUTPUT}.epub ${INPUT}.adoc; \ |
| 71 | + |
| 72 | +_build/book.mobi: |
| 73 | + asciidoctor ${KINDLE} ${REQUIRES} ${OUTPUT_FOLDER} --out-file=${OUTPUT}.mobi ${INPUT}.adoc; \ |
| 74 | + if [ -e "${DIR}/${OUTPUT}-kf8.epub" ]; \ |
| 75 | + then rm ${DIR}/${OUTPUT}-kf8.epub; \ |
| 76 | + fi; \ |
| 77 | + |
0 commit comments