mirror of
https://github.com/sdiehl/wiwinwlh.git
synced 2024-09-17 14:57:32 +03:00
60 lines
1.4 KiB
Makefile
60 lines
1.4 KiB
Makefile
PANDOC = pandoc
|
|
IFORMAT = markdown
|
|
GHC = ghc
|
|
|
|
HTEMPLATE = resources/page.tmpl
|
|
LTEMPLATE = resources/page.latex
|
|
ETEMPLATE = resources/page.epubt
|
|
|
|
UNICODE_MAP = resources/unicodemapping.tex
|
|
|
|
FLAGS = --standalone --toc --toc-depth=2 --highlight-style tango
|
|
LFLAGS = --top-level-division=chapter -V documentclass=book
|
|
HFLAGS = -c css/style.css -c css/layout.css
|
|
EFLAGS =
|
|
|
|
HTML = tutorial.html
|
|
EPUB = tutorial.epub
|
|
PDF = tutorial.pdf
|
|
|
|
all: $(HTML) $(EPUB) $(PDF)
|
|
html: $(HTML)
|
|
pdf: $(PDF)
|
|
epub: $(epub)
|
|
|
|
includes: includes.hs
|
|
$(GHC) --make $<
|
|
|
|
%.html: %.md includes
|
|
./includes < $< \
|
|
| $(PANDOC) --template $(HTEMPLATE) -s -f $(IFORMAT) -t html $(FLAGS) $(HFLAGS) \
|
|
| sed '/<extensions>/r extensions.html' > $@
|
|
|
|
%.epub: %.md includes
|
|
(cat $(ETEMPLATE); ./includes < $<) \
|
|
| $(PANDOC) -f $(IFORMAT) -t epub $(FLAGS) $(EFLAGS) -o $@
|
|
|
|
%.pdf: %.md includes
|
|
./includes < $< | $(PANDOC) -c -s -f $(IFORMAT) --template $(LTEMPLATE) --include-in-header $(UNICODE_MAP) --pdf-engine=xelatex $(FLAGS) $(LFLAGS) -o $@
|
|
|
|
clean:
|
|
-rm -f $(CHAPTERS) $(HTML) $(PDF) $(EPUB)
|
|
|
|
# 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
|