summaryrefslogtreecommitdiff
path: root/repo/www/Makefile
blob: 913aa6561ddce0e1c566077a52ecae00b9a0ae63 (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
# TODO: set dependencies to scripts correctly

TOP_DIR = ../..
OUT_DIR = $(TOP_DIR)/public
TEXT_FILES = md org

dirname = $(patsubst %/,%,$(dir $(1)))

text_patterns = $(foreach ext,$(TEXT_FILES),'$(TOP_DIR)/**.$(ext)')

text_folders = $(sort $(call dirname,$(shell git ls-files $(text_patterns))))

page_folders = $(patsubst $(TOP_DIR)%,$(OUT_DIR)%,$(text_folders))

all: site

dependencies = deps.mk
include $(dependencies)

$(dependencies): generate-deps.py $(text_folders)
	python3 $< "$(TEXT_FILES)" $(OUT_DIR)

site: $(pages) $(indices) $(autoindices)

$(page_folders):
	mkdir -p $@

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

$(indices):
	python3 generate-index.py "$(TEXT_FILES)" $(dir $<) | pandoc -s > $@

# ⚠ When tweaking this rule, check whether it still works for the
#   top-level index.html, i.e. when there is no top-level README.
$(autoindices):                                                         \
$(OUT_DIR)%/index.html: $(TOP_DIR)% generate-index.py | $(OUT_DIR)%
	python3 generate-index.py "$(TEXT_FILES)" $< | pandoc -s > $@

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