-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (54 loc) · 1.51 KB
/
Copy pathMakefile
File metadata and controls
72 lines (54 loc) · 1.51 KB
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
.SUFFIXES:
PROG = mugicha_exec
LEXS = $(wildcard src/*.l)
YACCS = $(wildcard src/*.y)
LEXC = src/lex.yy.c
YACCC = src/y.tab.c
YACCH = src/y.tab.h
LEXO = src/lex.yy.o
YACCO = src/y.tab.o
CSRCS = $(wildcard src/*.c)
CPPSRCS = $(wildcard src/*.cpp)
OBJS = $(CSRCS:%.c=%.o) $(CPPSRCS:%.cpp=%.o) $(LEXO) $(YACCO)
DEPS = $(CSRCS:%.c=%.d) $(CPPSRCS:%.cpp=%.d)
MUGICHAC = script/mugichac
TESTS = $(wildcard test/*.mugi)
RESULTS = $(TESTS:%.mugi=%.result)
EXPECTS = $(TESTS:%.mugi=%.expect)
DIFFS = $(TESTS:%.mugi=%.diff)
CC = clang
CPP = clang++
CPPFLG = -g -O3 -std=c++11 -fno-exceptions $1 `llvm-config --cppflags`
LDFLG = -ll -ly -g -O3 -std=c++11 -fno-exceptions $1 `llvm-config --ldflags --system-libs --libs core executionengine interpreter mc support nativecodegen`
LEX = lex
YACC = yacc
all: $(PROG)
-include $(DEPS)
$(PROG): $(OBJS)
$(CPP) $(LDFLG) -o $(PROG) $^
$(YACCC): $(YACCS)
$(YACC) $< -o $(YACCC) -d -t
$(LEXC): $(LEXS)
$(LEX) -t $< > $(LEXC)
%.o: %.c $(YACCC) $(LEXC)
$(CC) -c -MMD -MP -o $@ $<
%.o: %.cpp
$(CPP) -c $(CPPFLG) -o $@ $<
clean:
rm -f $(PROG) $(OBJS) $(DEPS) $(YACCO) $(LEXO) $(YACCC) $(LEXC) $(YACCH) $(RESULTS) $(DIFFS)
clean_test_results:
rm -f $(RESULTS) $(DIFFS)
disp_ast:
./mugicha_exec a < sample.mugi
run_interpreter:
./mugicha_exec i < sample.mugi
run_compiler:
$(MUGICHAC) sample.mugi
test: $(DIFFS)
echo "The test is successful."
%.diff: %.result %.expect
diff $(basename $<).result $(basename $<).expect > $@
%.result: %.mugi
$(MUGICHAC) $< > $@
$(TESTS): $(PROG)
touch $@