This repository was archived by the owner on Dec 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (44 loc) · 1.38 KB
/
Makefile
File metadata and controls
58 lines (44 loc) · 1.38 KB
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
# for reproducible build
SOURCE_DATE_EPOCH := 0
export SOURCE_DATE_EPOCH
FACTIONS := Battle_Brothers Tao Robot_Legions High_Elf_Fleets Orc
# Output directory
OUT := build
PDF := $(addprefix $(OUT)/,$(addsuffix .pdf,$(FACTIONS)))
PYTHONS := $(wildcard *.py)
COMMON := $(wildcard Common/*.yml)
TEX_TEMPLATE := $(wildcard Template/*.tex)
HTML_TEMPLATE := $(wildcard Template/*.html)
TEX_TEMPDIR := $(OUT)/tex
TXT_TEMPDIR := $(OUT)/txt
# don't use built-in rules
.SUFFIXES:
# $(1) is Faction, $(2) is Faction/*.yml
# so out/Faction.pdf will depend on Faction/*.yml *.py Common/*.yml template/*.tex
# and Faction will depend on out/Faction.pdf
define build_pdf =
$(OUT)/$(1).pdf: $(2) $(PYTHONS) $(COMMON) $(TEX_TEMPLATE) $(HTML_TEMPLATE) | $(TEX_TEMPDIR)
@python3 onepagebatch.py -b $(OUT) $(1)
@echo Generating $$@
@cd $(TEX_TEMPDIR) && xelatex -interaction=batchmode -halt-on-error $(1).tex 2>&1 > /dev/null
@mv $(TEX_TEMPDIR)/$(1).pdf $$@
# Handy alias to build a faction, "make Tao" will do "make build/Tao.pdf"
.PHONY : $(1)
$(1): $(OUT)/$(1).pdf
endef
all: $(PDF)
.PHONY: clean
clean:
@echo Removing `find $(OUT)`
@rm -rf $(OUT)
.PHONY: indent
indent:
@python3 indentyaml.py $(FACTIONS) Common
$(OUT):
@mkdir -p $@
$(TEX_TEMPDIR):
@mkdir -p $@
$(TXT_TEMPDIR):
@mkdir -p $@
# rules to build a pdf for each faction
$(foreach d,$(FACTIONS),$(eval $(call build_pdf,$(d),$(wildcard $(d)/*.yml))))