zine/Makefile

103 lines
2.4 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
2020-05-29 05:15:44 +00:00
ISSUES != find ./issues/* -type d
2019-09-23 23:28:54 +00:00
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
2019-10-03 03:22:32 +00:00
PHP != command -v php 2> /dev/null
# default target
help:
2019-10-01 16:39:29 +00:00
$(info all - build all formats)
2019-10-03 03:22:32 +00:00
$(info pdf - generate all issues as pdf - requires xelatex)
2019-10-01 16:39:29 +00:00
$(info html - generate all issues as html)
$(info epub - generate all issues as epub)
$(info clean - remove build artifacts)
2019-10-03 03:22:32 +00:00
$(info serve - start local php test server - requires php)
$(info note: all builds require pandoc)
2019-10-01 16:39:29 +00:00
all: dep-pandoc pdf html epub
2019-10-01 16:39:29 +00:00
pdf: dep-xelatex $(DEST_PDF_FILES)
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/%
2019-10-01 16:39:29 +00:00
$(info building $@)
2019-09-23 23:28:54 +00:00
@$(PANDOC) \
2019-09-23 14:21:43 +00:00
--file-scope \
--from markdown \
--to latex \
2020-06-04 01:59:47 +00:00
--standalone \
2019-09-23 14:21:43 +00:00
--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 $@" \
2020-06-04 01:59:47 +00:00
--variable geometry:margin=.75in \
--pdf-engine xelatex \
2019-09-23 14:21:43 +00:00
--output $@ \
$</*.md
2019-09-23 23:28:54 +00:00
$(DEST_DIR)/issue-%.html: issues/%
2019-10-01 16:39:29 +00:00
$(info building $@)
2019-09-23 23:28:54 +00:00
@$(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/%
2019-10-01 16:39:29 +00:00
$(info building $@)
2019-09-23 23:28:54 +00:00
@$(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-10-01 16:39:29 +00:00
$(info removing build artifacts)
2019-10-03 03:22:32 +00:00
@rm $(DEST_DIR)/issue-*
serve: dep-php
$(info starting local php server)
@$(PHP) -S localhost:9000 -t $(DEST_DIR)
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
2019-10-03 03:22:32 +00:00
dep-php:
ifndef PHP
$(error missing dependency 'php'. please install and try again)
endif
.PHONY: clean serve help dep-pandoc dep-xelatex dep-php
2019-09-23 14:44:02 +00:00