summaryrefslogtreecommitdiff
path: root/Makefile
blob: f61c4c3ed5ea2512dbfc6646fba5ae1a81cb335d (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
MAKEFLAGS += -j1

pdfjs = https://github.com/mozilla/pdf.js/releases/download/v1.9.426/pdfjs-1.9.426-dist.zip

# Default target
all: out/index.html out/main.css out/pdfjs
phony += all

# Boilerplate
phony += FORCE
.DELETE_ON_ERROR:
.SECONDARY:

# Development server
serve: serve-8000
serve-%: all
	dir=$$(mktemp -d -t) && trap 'fusermount -u "$$dir"; rmdir "$$dir"' EXIT && unionfs -o ro out:src "$$dir" && (cd "$$dir" && python3 -m http.server $*)
phony += serve serve-%

# Clean
clean:
	rm -rf out
phony += clean

# Real file rules
out/%.css: src/%.scss
	@mkdir -p $(@D)
	scss --stdin < $< > $@

out/$(notdir $(pdfjs)):
	wget -c --no-use-server-timestamp -O $@ $(pdfjs)
out/pdfjs: out/$(notdir $(pdfjs))
	rm -rf -- $@
	mkdir -- $@ && bsdtar -xf $(abspath $<) -C $@ --exclude '*.pdf' || { rm -rf -- $@; false; }

targets = $(phony) %.css out/pdfjs%
$(sort $(filter-out $(targets),out/index.html $(MAKECMDGOALS))): FORCE
	./bin/sitegen

# Boilerplate
.PHONY: $(phony)