zine/Makefile

91 lines
2.1 KiB
Makefile
Raw Normal View History

# customizable output dir
2019-09-23 23:28:54 +00:00
DEST_DIR ?= dist
# find all issues and determine required output files
2019-09-23 23:28:54 +00:00
ISSUES != find . -path "./issues/*" -type d
DEST_PDF_FILES := $(ISSUES:./issues/%=$(DEST_DIR)/issue-%.pdf)
DEST_HTML_FILES := $(ISSUES:./issues/%=$(DEST_DIR)/issue-%.html)
DEST_EPUB_FILES := $(ISSUES:./issues/%=$(DEST_DIR)/issue-%.epub)
2019-09-23 14:21:43 +00:00
# deps
2019-09-23 14:21:43 +00:00
PANDOC != command -v pandoc 2> /dev/null
XELATEX != command -v xelatex 2> /dev/null
# default target
help:
@echo "Targets:"
@echo -e "\tall - build all formats"
@echo -e "\tpdf - generate all issues as pdf"
@echo -e "\thtml - generate all issues as html"
@echo -e "\tepub - generate all issues as epub"
@echo -e "\tclean - remove build artifacts"
all: pdf html epub dep-pandoc
pdf: $(DEST_PDF_FILES) dep-xelatex
2019-09-23 14:21:43 +00:00
html: $(DEST_HTML_FILES)
epub: $(DEST_EPUB_FILES)
2019-09-23 14:21:43 +00:00
2019-09-23 23:28:54 +00:00
$(DEST_DIR)/issue-%.pdf: issues/%
@echo "building $@"
@$(PANDOC) \
2019-09-23 14:21:43 +00:00
--file-scope \
--from markdown \
--to latex \
--pdf-engine xelatex \
--table-of-contents \
2019-09-24 01:05:57 +00:00
--lua-filter increase-header-levels.lua \
2019-09-23 14:21:43 +00:00
--variable title:"tildeverse zine $@" \
--standalone \
--output $@ \
$</*.md
2019-09-23 23:28:54 +00:00
$(DEST_DIR)/issue-%.html: issues/%
@echo "building $@"
@$(PANDOC) \
2019-09-23 14:44:02 +00:00
--file-scope \
--from markdown \
--to html \
--standalone \
--table-of-contents \
--lua-filter header-permalinks.lua \
--lua-filter increase-header-levels.lua \
2019-09-23 14:44:02 +00:00
--metadata title:"tildeverse zine $@" \
--variable include-before:"<div class=\"container\">" \
--variable include-after:"</div>" \
2019-09-23 14:44:02 +00:00
--css https://tilde.team/css/hacker.css \
--output $@ \
$</*.md
2019-09-23 23:28:54 +00:00
$(DEST_DIR)/issue-%.epub: issues/%
@echo "building $@"
@$(PANDOC) \
2019-09-23 16:25:21 +00:00
--file-scope \
--from markdown \
--to epub \
--standalone \
--table-of-contents \
--lua-filter increase-header-levels.lua \
--metadata title:"tildeverse zine $@" \
--output $@ \
$</*.md
2019-09-23 14:44:02 +00:00
clean:
2019-09-23 23:28:54 +00:00
@echo "removing build artifacts"
@rm $(DEST_DIR)/*.{pdf,html,epub}
dep-pandoc:
ifndef PANDOC
$(error missing dependency 'pandoc'. please install and try again)
endif
dep-xelatex:
ifndef XELATEX
$(error missing dependency 'xelatex'. please install and try again)
endif
2019-09-23 14:44:02 +00:00
.PHONY: clean help dep-pandoc dep-xelatex
2019-09-23 14:44:02 +00:00