-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
48 lines (37 loc) · 1.16 KB
/
Makefile
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
# Executables used in the build process
MOON?=moon
MOONC?=moonc
# Directories
MANUAL_DIR=manual
MANUAL_SRC=$(MANUAL_DIR)/src
# TODO read in from the book.toml?
MANUAL_BUILD_DIR=docs
MOON_DIR=moon
LUA_OUT_DIR=lua
# Files
MANUAL_SRC_FILES:=$(wildcard $(MANUAL_SRC)/*.md)
MOON_FILES:=$(shell find $(MOON_DIR) -name '*.moon' -type f)
LUA_FILES:=$(patsubst moon/%,lua/%,$(patsubst %.moon,%.lua,$(MOON_FILES)))
.PHONY: all clean book-watch
all: $(MANUAL_BUILD_DIR) $(LUA_FILES)
clean:
rm -rf $(LUA_FILES) && \
pushd $(MANUAL_DIR) && \
mdbook clean
$(MANUAL_BUILD_DIR): $(MANUAL_SRC_FILES)
cd $(MANUAL_DIR) && \
mdbook build
book-watch: $(MANUAL_SRC_FILES)
cd $(MANUAL_DIR) && \
mdbook watch -o
manual/src/options.md: manual/options-builder.moon options.sha256
@echo "Regenerating options"
$(MOON) manual/options-builder.moon $(optionsFile) $@
# Shenanigans to trigger rebuild of manual/options.md every time the Nix-built
# options JSON changes
options.sha256: FORCE
@$(if $(filter-out $(shell cat $@ 2>/dev/null),$(shell sha256sum $(optionsFile))),sha256sum $(optionsFile) > $@)
FORCE:
lua/%.lua: moon/%.moon
@test -d $(@D) || mkdir -pm 755 $(@D)
$(MOONC) -o $@ $<