1
1
mirror of https://github.com/sdiehl/wiwinwlh.git synced 2024-09-11 12:05:25 +03:00
wiwinwlh/Makefile

98 lines
2.4 KiB
Makefile
Raw Normal View History

2014-04-05 04:50:22 +04:00
PANDOC = pandoc
2020-02-05 12:20:41 +03:00
IFORMAT = markdown+raw_tex+raw_attribute+auto_identifiers+implicit_header_references
2019-12-26 19:49:22 +03:00
GHC = ghc
2020-02-17 02:16:49 +03:00
INPUT = tutorial.md
2020-02-01 15:47:31 +03:00
HTEMPLATE = resources/template.html
LTEMPLATE = resources/template.tex
ETEMPLATE = resources/template.epub
2019-12-26 19:49:22 +03:00
2020-01-25 17:27:07 +03:00
FLAGS = --standalone --toc --toc-depth=2 --highlight-style tango
2020-02-11 13:22:43 +03:00
LFLAGS = --top-level-division=chapter
2020-02-17 02:16:49 +03:00
PFLAGS = -V colorlinks
2019-12-26 02:06:23 +03:00
HFLAGS = -c css/style.css -c css/layout.css
2020-02-15 13:13:19 +03:00
DFLAGS =
2019-12-26 02:06:23 +03:00
EFLAGS =
2014-04-05 04:50:22 +04:00
2020-02-17 02:16:49 +03:00
# Targets
2014-04-25 09:00:50 +04:00
HTML = tutorial.html
2019-12-26 19:49:22 +03:00
EPUB = tutorial.epub
PDF = tutorial.pdf
2020-02-17 02:16:49 +03:00
PPDF = tutorial_print.pdf
2020-02-16 15:45:23 +03:00
TEX = tutorial.tex
2020-02-17 02:40:20 +03:00
DOCX = tutorial.tex
2014-04-05 04:50:22 +04:00
2020-02-17 02:16:49 +03:00
# LaTeX
2020-02-01 15:47:31 +03:00
COVER = resources/cover.tex
BACK = resources/back.tex
2020-02-17 02:16:49 +03:00
UNICODE_MAP = resources/unicodemapping.tex
2020-02-01 15:47:31 +03:00
2020-02-17 02:16:49 +03:00
all: $(PDF) $(HTML) $(EPUB)
2019-12-26 19:56:00 +03:00
html: $(HTML)
2020-02-17 02:40:20 +03:00
docx: $(DOCX)
2019-12-26 19:56:00 +03:00
epub: $(epub)
2020-02-17 02:40:20 +03:00
pdf: $(PDF)
2014-04-05 04:50:22 +04:00
2020-02-17 02:16:49 +03:00
# Code snippet preprocessor
includes: includes.hs
2019-12-26 02:06:23 +03:00
$(GHC) --make $<
2020-02-17 02:16:49 +03:00
# .html Target
%.html: %.md includes
./includes < $< \
2019-12-26 19:49:22 +03:00
| $(PANDOC) --template $(HTEMPLATE) -s -f $(IFORMAT) -t html $(FLAGS) $(HFLAGS) \
2020-02-11 10:01:50 +03:00
| sed '/<extensions>/r extensions.html' \
| sed '/<copyright>/r resources/copyright.html' > $@
2014-04-05 04:50:22 +04:00
2020-02-17 02:16:49 +03:00
# .docx Target
2020-02-15 13:13:19 +03:00
%.docx: %.md includes
./includes < $< \
| $(PANDOC) --template $(HTEMPLATE) -s -f $(IFORMAT) -t docx $(FLAGS) $(DFLAGS) > $@
2020-02-17 02:16:49 +03:00
# .epub Target
%.epub: %.md includes
(cat $(ETEMPLATE); ./includes < $<) \
2019-12-26 02:06:23 +03:00
| $(PANDOC) -f $(IFORMAT) -t epub $(FLAGS) $(EFLAGS) -o $@
2020-02-17 02:16:49 +03:00
# .tex Target
2020-02-16 15:21:25 +03:00
%.tex: %.md includes $(COVER) $(BACK)
./includes < $< \
| $(PANDOC) -c -s -f $(IFORMAT) --template $(LTEMPLATE) --include-in-header $(UNICODE_MAP) --pdf-engine=xelatex $(FLAGS) $(LFLAGS) -o $@
2020-02-17 02:16:49 +03:00
# .pdf Target for Print
2020-02-01 15:47:31 +03:00
%.pdf: %.md includes $(COVER) $(BACK)
2020-02-16 15:21:25 +03:00
./includes < $< \
| $(PANDOC) -c -s -f $(IFORMAT) --template $(LTEMPLATE) --include-in-header $(UNICODE_MAP) --pdf-engine=xelatex $(FLAGS) $(LFLAGS) -o $@
2014-06-21 23:18:28 +04:00
2020-02-17 02:16:49 +03:00
# dirty hack
# .pdf Target for Web
webpdf: $(INPUT) includes $(COVER) $(BACK)
./includes < $< \
| $(PANDOC) -c -s -f $(IFORMAT) --template $(LTEMPLATE) --include-in-header $(UNICODE_MAP) --pdf-engine=xelatex $(FLAGS) $(LFLAGS) $(PFLAGS) -o $(PPDF)
2020-02-08 16:35:22 +03:00
links:
brok tutorial.md
2014-04-05 04:50:22 +04:00
clean:
2020-02-16 15:45:23 +03:00
-rm -f $(CHAPTERS) $(HTML) $(PDF) $(EPUB) $(TEX)
# pandoc executable 'includes' is rather large
clean-all:
rm -rf $(CHAPTERS) $(HTML) includes
# NIX BUILD
# Enter nix shell with 'make run-shell' first (then 'make all')
.PHONY : run-shell
run-shell : shell.nix
ifndef NIX_GHC
nix-shell
else
$(error Already in GHC shell!)
endif
shell.nix : wiwinwlh.cabal
cabal2nix --shell . > shell.nix