-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
62 lines (47 loc) · 2.12 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
SHELL := bash
.SHELLFLAGS := -o pipefail -c
HOST_SCHEME_FLAGS := --r7rs
HOST_SCHEME_COMPILED_DIR := ./compiled/
HOST_SCHEME_COMPILE_MODULE := guild compile $(HOST_SCHEME_FLAGS)
HOST_SCHEME_RUN_PROGRAM := guile $(HOST_SCHEME_FLAGS) --no-auto-compile
COMPILER_SOURCES := $(wildcard *.scm)
COMPILER_BINARIES := $(COMPILER_SOURCES:%.scm=$(HOST_SCHEME_COMPILED_DIR)%.go)
RUN_COMPILER := $(HOST_SCHEME_RUN_PROGRAM) -L . -C $(HOST_SCHEME_COMPILED_DIR) driver.scm
.PHONY : help
help : ## Display this help
help : Makefile test-compiler/test-compiler.mk test-unit/test-unit.mk tools/tools.mk
@echo "Targets:"
@sed -nE 's/^([[:alnum:]-]+)[[:space:]]*:[^#]*##[[:space:]]*(.*)$$/ \1: \2/p' $^ \
| column -t -s " "
.PHONY : compile
compile : ## Compiles a scheme file from standard input and outputs WAT to standard output
compile : $(COMPILER_BINARIES)
$(RUN_COMPILER) $<
.PHONY : compile-compiler
compile-compiler : ## Compiles the compiler with host scheme
compile-compiler : $(COMPILER_BINARIES)
$(HOST_SCHEME_COMPILED_DIR) :
mkdir -p $@
COMPILER_DEPENDENCIES := $(HOST_SCHEME_COMPILED_DIR)module-dependencies.mk
include tools/tools.mk
$(COMPILER_DEPENDENCIES) : $(COMPILER_SOURCES) $(TOOL_SCHEME_DEPENDENCIES) | $(HOST_SCHEME_COMPILED_DIR)
$(RUN_TOOL_SCHEME_DEPENDENCIES) $(COMPILER_SOURCES) \
| sed -e 's|\([^[:space:]]*\)\.scm|$(HOST_SCHEME_COMPILED_DIR)\1\.go|g' \
| tee [email protected] && mv -f [email protected] $@
include $(COMPILER_DEPENDENCIES)
$(COMPILER_BINARIES) : $(HOST_SCHEME_COMPILED_DIR)%.go : %.scm | $(HOST_SCHEME_COMPILED_DIR)
GUILE_LOAD_COMPILED_PATH=$(HOST_SCHEME_COMPILED_DIR) $(HOST_SCHEME_COMPILE_MODULE) -o $@ $<
include test-compiler/test-compiler.mk
include test-unit/test-unit.mk
.PHONY : test
test : ## Executes all tests
test : test-unit test-compiler
.PHONY : clean
clean : ## Removes test outputs, compiled tools and forces compiler re-compilation
clean : clean-test clean-compiler clean-tools
.PHONY : clean-compiler
clean-compiler : ## Forces compiler re-compilation
-rm -rf $(HOST_SCHEME_COMPILED_DIR)
.PHONY : clean-test
clean-test : ## Removes all test build artefacts and results
clean-test : clean-test-unit clean-test-compiler