-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (85 loc) · 2.49 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
# Global Makefile of SCC.
# Copyright (C) 2020-2021 Renjian Wang
#
# This file is part of SCC.
#
# SCC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SCC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SCC. If not, see <https://www.gnu.org/licenses/>.
# TODO: Windows
DESTDIR = /usr/local/bin
build = build
release = release
range = 1 2 3
ifeq ($(OS),Windows_NT)
targets = "compiler/$(build)/scc.exe" "compiler/$(build)/sc.lang"
ifneq ($(CG),4)
targets += "interpreter/$(build)/sci.exe"
endif
else
targets = "compiler/$(build)/scc" "compiler/$(build)/sc.lang"
ifneq ($(CG),4)
targets += "interpreter/$(build)/sci"
endif
endif
## phony targets
.PHONY : main release install uninstall zip test module_test all clean
main:
"$(MAKE)" -C tools
"$(MAKE)" -C common
"$(MAKE)" -C interpreter
"$(MAKE)" -C compiler
mkdir -p "$(build)"
cp $(targets) "$(build)" #TODO: Windows
release:
"$(MAKE)" release=true -C tools
"$(MAKE)" release=true -C common
"$(MAKE)" release=true -C interpreter
"$(MAKE)" release=true -C compiler
mkdir -p "$(build)" "$(release)"
cp $(targets) "$(build)"
cp $(targets) "$(release)"
install: release
mkdir -p "$(DESTDIR)"
cp "$(release)/scc" "$(release)/sc.lang" "$(release)/sci" -t "$(DESTDIR)"
uninstall:
rm "$(DESTDIR)/scc" "$(DESTDIR)/sci" "$(DESTDIR)/sc.lang"
zip: release
-rm scc.zip
zip -r scc.zip common compiler interpreter -x \*.pyc
test: module_test main
export SCC='$(targets)'; \
mkdir -p test/ncg; \
pytest test/ncg; \
RET=$$?; \
if [ "$$RET" != "0" ] && [ "$$RET" != "5" ]; then \
exit $$RET; \
else \
exit 0; \
fi
# TODO
module_test:
"$(MAKE)" test -C tools
"$(MAKE)" test -C common
"$(MAKE)" unit_test -C compiler
$(foreach i, $(range), "$(MAKE)" module_test CG=$(i) -C compiler &&) true
# $(MAKE) module_test CG= -C compiler
"$(MAKE)" test -C interpreter
# clean & rebuild
all: clean main
clean:
"$(MAKE)" clean -C tools
"$(MAKE)" clean -C common
"$(MAKE)" clean -C interpreter
"$(MAKE)" clean -C compiler
-rm "$(build)/scc" "$(build)/sc.lang" "$(build)/sci"
-rm scc.zip