-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
62 lines (52 loc) · 2.91 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
BUILD = build
MAKEFILE = Makefile
OUTPUT_FILENAME = Die_Zugspitz-Expedition_zur_Errichtung_eines_vergoldeten_Eisen-Cylinder-Kreuzes
TITLE_NAME = "Die Zugspitz-Expedition zur Errichtung eines vergoldeten Eisen-Cylinder-Kreuzes"
METADATA = metadata.yml
CHAPTERS = chapters/*.md
TOC = --toc --toc-depth=3
IMAGES_FOLDER = images
IMAGES = $(IMAGES_FOLDER)/*
COVER_IMAGE = $(IMAGES_FOLDER)/cover.jpg
LATEX_CLASS = book
MATH_FORMULAS = --webtex
CSS_FILE = blitz.css
CSS_FILE_KINDLE=blitz.css
CSS_FILE_PRINT=print.css
CSS_ARG = --css=$(CSS_FILE)
CSS_ARG_KINDLE = --css=$(CSS_FILE_KINDLE)
CSS_ARG_PRINT = --css=$(CSS_FILE_PRINT)
METADATA_ARG = --metadata-file=$(METADATA)
METADATA_PDF = chapters/preface/metadata_pdf_html.md
PREFACE_EPUB = chapters/preface/preface_epub.md
PREFACE_HTML_PDF = chapters/preface/preface_html_pdf.md
ARGS = $(TOC) $(MATH_FORMULAS) $(CSS_ARG) $(METADATA_ARG) --reference-location=section
ARGS_HTML = $(TOC) $(MATH_FORMULAS) $(CSS_ARG) --reference-location=section --metadata=lang:de
#CALIBRE="../../calibre/Calibre Portable/Calibre/"
#CALIBRE="C:/Program Files/Calibre2/"
CALIBRE=""
PANDOC = "pandoc"
all: book
book: epub html pdf docx
clean:
rm -r $(BUILD)
epub: $(BUILD)/epub/$(OUTPUT_FILENAME).epub
html: $(BUILD)/html/$(OUTPUT_FILENAME).html
pdf: $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf
$(BUILD)/epub/$(OUTPUT_FILENAME).epub: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(CSS_FILE_KINDLE) $(IMAGES) \
$(COVER_IMAGE) $(METADATA) $(PREFACE_EPUB)
mkdir -p $(BUILD)/epub
$(PANDOC) $(ARGS) --epub-chapter-level=2 --from markdown+raw_html+fenced_divs+fenced_code_attributes+bracketed_spans --to epub+raw_html --resource-path=$(IMAGES_FOLDER) --epub-cover-image=$(COVER_IMAGE) -o $@ $(PREFACE_EPUB) $(CHAPTERS)
$(CALIBRE)ebook-polish --add-soft-hyphens -i -p -U $@ $@
$(CALIBRE)ebook-convert $@ $(BUILD)/epub/$(OUTPUT_FILENAME).azw3 --share-not-sync --disable-font-rescaling
$(CALIBRE)ebook-convert $(BUILD)/epub/$(OUTPUT_FILENAME).azw3 $(BUILD)/epub/$(OUTPUT_FILENAME).mobi --share-not-sync --disable-font-rescaling --mobi-file-type both
docx: $(BUILD)/docx/$(OUTPUT_FILENAME).docx
$(BUILD)/docx/$(OUTPUT_FILENAME).docx: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(CSS_FILE_KINDLE) $(IMAGES) \
$(COVER_IMAGE)
mkdir -p $(BUILD)/docx
pandoc $(ARGS_HTML) --from markdown+raw_html+fenced_divs+fenced_code_attributes+bracketed_spans --to docx --resource-path=$(IMAGES_FOLDER) -o $@ $(METADATA_PDF) $(PREFACE_EPUB) $(CHAPTERS)
$(BUILD)/html/$(OUTPUT_FILENAME).html: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES) $(COVER_IMAGE) $(METADATA_PDF)
mkdir -p $(BUILD)/html
cp *.css $(IMAGES_FOLDER)
pandoc $(ARGS_HTML) --self-contained --standalone --resource-path=$(IMAGES_FOLDER) --from markdown+pandoc_title_block+raw_html+fenced_divs+fenced_code_attributes+bracketed_spans+yaml_metadata_block --to=html5 -o $@ $(METADATA_PDF) $(PREFACE_EPUB) $(CHAPTERS)
rm $(IMAGES_FOLDER)/*.css