summaryrefslogtreecommitdiff
path: root/repo/www/Makefile
blob: fdc0112c9371003f66a9fd72140bbefcb015cfa4 (plain)
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
TOP_DIR = ../..
OUT_DIR = $(TOP_DIR)/public
TEXT_FILES = md org

dirname = $(patsubst %/,%,$(dir $(1)))
dirnames = $(sort $(call dirname,$(1)))

text_patterns = $(foreach ext,$(TEXT_FILES),'$(TOP_DIR)/**.$(ext)')
text_folders = $(call dirnames,$(shell git ls-files $(text_patterns)))

all: site

# Maps folders to their contents (files and subfolders).
site_tree = site-tree.json
# Defines $(pages) and $(indices).
dependencies = deps.mk

$(site_tree): $(text_folders)
	./generate-tree.py -o $@ $(TEXT_FILES)

$(dependencies): $(site_tree)
	./generate-deps.py $< $@ $(OUT_DIR)

include $(dependencies)

site: $(pages) $(indices)

# $(text_folders) may be missing some intermediate folders since it
# only contains folders that hold some text files.  Rely on the full
# list of HTML pages and indices.
$(call dirnames,$(pages) $(indices)):
	mkdir -p $@

$(pages):
	pandoc -s $< -o $@

# ⚠ When tweaking this rule, check whether it still works for the
#   top-level index.html.
$(indices): $(OUT_DIR)/%index.html:
	./generate-index.py $(site_tree) "$(patsubst %/,%,$*)" $@

clean:
	-rm $(dependencies)
	-rm -r $(OUT_DIR)