-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (60 loc) · 1.64 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
TESTS := $(wildcard tests/*.py)
TEST_TARGETS := $(TESTS:tests/%.py=%)
DIRS = bin cache ir mods views
OPTS = --color
CODEGEN = time ./construct.py $(OPTS)
CC = cc
CFLAGS = -g -std=c99 -pedantic -W -Wall -Werror -fstrict-aliasing
ifdef DEBUG
CODEGEN = time ipdb construct.py $(OPTS)
endif
ifdef PROFILE
CODEGEN = time python -m cProfile -s time construct.py $(OPTS)
endif
ifdef VIEW
OPTS := --views $(OPTS)
endif
all: test
debug: CODEGEN = time ipdb construct.py $(OPTS)
debug: remake_tests
editor:
@$(MAKE) -C Editor
profile: CODEGEN = time python -m cProfile -s time construct.py $(OPTS)
profile: remake_tests
setup: $(DIRS) ir/Makefile gc/bluefin.so
$(DIRS):
@mkdir $@
ir/Makefile: .irMakefile
@cp $< $@
gc/bluefin.so: gc/bluefin.cc
@$(MAKE) -C gc bluefin.so
bin/%: tests/%.py setup runtime
@$(CODEGEN) --test -- $< && $@ || echo $@ returned $$?.
$(TEST_TARGETS):
@$(MAKE) bin/$@
Editor/i386/Editor_%.ll.o: Editor/%.py setup runtime
@$(CODEGEN) --i386 --c-header -o Editor/i386/ $<
Editor/arm/Editor_%.ll.o: Editor/%.py setup
@$(CODEGEN) --arm --c-header -o Editor/arm/ $<
# host runtime only
runtime: ir/gc_runtime.o ir/z.o
ir/gc_runtime.o: gc/runtime.c ir
@echo Building GC runtime.
@$(CC) $(CFLAGS) -c -o $@ $<
ir/z.o: z.c ir
@echo Building runtime.
@$(CC) $(CFLAGS) -c -o $@ $<
remake_tests: setup runtime
@$(CODEGEN) --test -- $(TESTS)
test: remake_tests
@echo Running tests...
@for target in $(TEST_TARGETS); do \
bin/$$target || echo $$target returned $$?.; \
done
@echo
@echo Done.
.PHONY: all clean debug editor remake_tests runtime setup test
clean:
@rm -rf -- $(DIRS) *.pyc
@$(MAKE) -C Editor clean
@$(MAKE) -C gc clean