-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
57 lines (48 loc) · 1.21 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
SHELL := /bin/bash
MLC=polyc
ifeq (, $(shell which rlwrap))
REPL=poly
else
REPL=rlwrap poly
endif
FLAGS=
REP2REP_TMP:=$(shell mktemp)
TEST_TMP:=$(shell mktemp)
REP2REP_VERSION:=$(shell git describe --all --long | rev | cut -d'-' -f 1 | rev)
all: rep2rep
rep2rep: dist/rep2rep
dist/rep2rep: $(REP2REP_TMP)
mkdir -p dist
$(MLC) $(FLAGS) -o $@ $<
.PHONY:$(REP2REP_TMP)
$(REP2REP_TMP): base.sml src/main.sml
echo "use \""$<"\";" >> $@;
for f in $(filter-out base.sml,$^); do \
tmp=$$(dirname $$f)/$$(basename $$f .sml); \
tmp=$$(sed "s/^src\///" <<< $$tmp); \
tmp=$$(sed "s/\//\./g" <<< $$tmp); \
echo "import \"$$tmp\";" >> $@ ; \
done
base.sml:
echo 'val REP2REP_VERSION="'$(REP2REP_VERSION)'";' >> base.sml
echo 'val BASE="./src/";' >> base.sml
echo 'use "src/util/rep2replib.sml";' >> base.sml
test: tests/test
$<
tests/test: $(TEST_TMP)
$(MLC) $(FLAGS) -o $@ $<
.PHONY:$(TEST_TMP)
$(TEST_TMP): base.sml tests/tests.sml
echo "use\""$<"\";" >> $@;
for f in $(filter-out base.sml,$^); do \
tmp=$$(dirname $$f)/$$(basename $$f); \
tmp=$$(sed "s/^src\///" <<< $$tmp); \
echo "use \"$$tmp\";" >> $@ ; \
done
.PHONY:clean
clean:
rm -rf dist
rm -rf base.sml
.PHONY:repl
repl: base.sml
$(REPL) --use $<