-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
100 lines (74 loc) · 2.44 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Settings
# --------
BUILD_DIR:=.build
DEFN_DIR:=$(BUILD_DIR)/defn
BUILD_LOCAL:=$(BUILD_DIR)/local
LIBRARY_PATH:=$(BUILD_LOCAL)/lib
PKG_CONFIG_PATH:=$(LIBRARY_PATH)/pkgconfig
export LIBRARY_PATH
export PKG_CONFIG_PATH
K_SUBMODULE:=$(BUILD_DIR)/k
PLUGIN_SUBMODULE:=plugin
# need relative path for `pandoc` on MacOS
PANDOC_TANGLE_SUBMODULE:=$(BUILD_DIR)/pandoc-tangle
TANGLER:=$(PANDOC_TANGLE_SUBMODULE)/tangle.lua
LUA_PATH:=$(PANDOC_TANGLE_SUBMODULE)/?.lua;;
export TANGLER
export LUA_PATH
.PHONY: all clean deps k-deps tangle-deps llvm-deps build build-java defn
all: build
clean:
rm -rf $(BUILD_DIR)
git submodule update --init
# Dependencies
# ------------
deps: k-deps tangle-deps
k-deps: $(K_SUBMODULE)/make.timestamp
tangle-deps: $(PANDOC_TANGLE_SUBMODULE)/make.timestamp
$(K_SUBMODULE)/make.timestamp:
@echo "== submodule: $@"
git submodule update --init -- $(K_SUBMODULE)
cd $(K_SUBMODULE) \
&& mvn package -q -DskipTests -U
touch $(K_SUBMODULE)/make.timestamp
$(PANDOC_TANGLE_SUBMODULE)/make.timestamp:
@echo "== submodule: $@"
git submodule update --init -- $(PANDOC_TANGLE_SUBMODULE)
touch $(PANDOC_TANGLE_SUBMODULE)/make.timestamp
K_BIN=$(K_SUBMODULE)/k-distribution/target/release/k/bin
# Definitions
# -----------
java_dir:=$(DEFN_DIR)/java
llvm_dir:=$(DEFN_DIR)/llvm
haskell_dir:=$(DEFN_DIR)/haskell
# Tangle definition from *.md files
$(java_dir)/%.k: %.md
@echo "== tangle: $@"
mkdir -p $(dir $@)
pandoc --from markdown --to "$(TANGLER)" --metadata=code:"$(k_tangler)" $< > $@
$(llvm_dir)/%.k: %.md
@echo "== tangle: $@"
mkdir -p $(dir $@)
pandoc --from markdown --to "$(TANGLER)" --metadata=code:"$(k_tangler)" $< > $@
$(haskell_dir)/%.k: %.md
@echo "== tangle: $@"
mkdir -p $(dir $@)
pandoc --from markdown --to "$(TANGLER)" --metadata=code:"$(k_tangler)" $< > $@
k_tangler:=".k"
k_files:=eei-driver.k eei.k
java_defn:=$(patsubst %,$(java_dir)/%,$(k_files))
llvm_defn:=$(patsubst %,$(llvm_dir)/%,$(k_files))
haskell_defn:=$(patsubst %,$(haskell_dir)/%,$(k_files))
defn: defn-llvm defn-java defn-haskell
defn-llvm: $(llvm_defn)
defn-java: $(java_defn)
defn-haskell: $(haskell_defn)
# Building
# --------
build: build-java
build-java: $(BUILD_DIR)/java/driver-kompiled/timestamp
# Java Backend
$(BUILD_DIR)/java/driver-kompiled/timestamp: $(java_defn)
@echo "== kompile: $@"
$(K_BIN)/kompile --debug --main-module EEI-DRIVER --backend java \
--syntax-module EEI-DRIVER $< --directory $(BUILD_DIR)/java -I $(BUILD_DIR)/java