-
Notifications
You must be signed in to change notification settings - Fork 20
/
madoko.mk
62 lines (45 loc) · 1.04 KB
/
madoko.mk
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
59
60
61
62
MADOKO := madoko
BUILD_DIR := build
MARKDOWN := $(TARGETS:%=%.md)
PDF := $(TARGETS:%=$(BUILD_DIR)/%.pdf)
HTML := $(TARGETS:%=$(BUILD_DIR)/%.html)
# Shortcuts.
.PHONY: pdf html
pdf: $(PDF)
html: $(HTML)
# Build PDF via LaTeX.
$(BUILD_DIR)/%.pdf: %.md $(DEPS)
$(MADOKO) --odir=$(BUILD_DIR) --pdf $<
# Build Web page.
$(BUILD_DIR)/%.html: %.md $(DEPS)
$(MADOKO) --odir=$(BUILD_DIR) $<
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
.PHONY: deploy
deploy: $(PDF)
scp $< $(DEST)
@echo http://$(DEST_PATH)/$(notdir $(PDF))
deploy-html: $(HTML)
scp $< $(DEST)
@echo http://$(DEST_PATH)/$(notdir $(HTML))
# View products.
OS=$(shell uname -s)
ifeq ($(OS),Darwin)
OPEN ?= open
else
OPEN ?= xdg-open
endif
.PHONY: view view-html
view: $(PDF)
$(OPEN) $(PDF)
view-html: $(HTML)
$(OPEN) $(HTML)
# Auto-build based on `livereload`.
.PHONY: watch watch-pdf watch-html
LIVESERVE_ARGS := -w $(MARKDOWN) $(DEPS:%=-w %)
watch-pdf:
liveserve $(LIVESERVE_ARGS) -x 'make pdf' -S
watch-html:
liveserve $(LIVESERVE_ARGS) -x 'make html' $(BUILD_DIR)
watch: watch-pdf