-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
86 lines (64 loc) · 1.6 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
CFLAGS=-std=c11 -g -Wall -Wextra
SRCS=$(wildcard src/*.c)
OBJS=$(SRCS:.c=.o)
CC = clang
LDFLAGS =
MKFILE_PATH = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
#RUSTD = 1
#Debug = 1
ifdef RUSTD
CFLAGS += -DRUSTD
LIBNAME = libfor_test.so
RUSTLIB = for_test/target/debug/$(LIBNAME)
RUSTLIBPATH = $(MKFILE_PATH)dynlib/$(LIBNAME)
else
LDFLAGS += -static
CFLAGS += -static
endif
ifdef Debug
CFLAGS += -DDebug -g3
ASFLAG += -g3
endif
lemola_cc: $(OBJS) $(RUSTLIBPATH)
$(CC) $(OBJS) $(RUSTLIBPATH) -o $@ $(LDFLAGS)
$(OBJS): src/lemola_cc.h
# $(CC) -c $(SRCS) $(CFLAGS)
src.s: lemola_cc src.c
./lemola_cc src.c
a.out: src.s lemola_cc tmp.c
$(CC) src.s $(ASFLAG)
src2.s: lemola_cc src2.c
./lemola_cc src2.c -o src2.s
a2.out: src2.s lemola_cc
$(CC) src2.s -o a2.out $(ASFLAG)
$(RUSTLIBPATH): for_test/src/lib.rs for_test/Cargo.toml for_test/.cargo/config.toml
cd for_test && \
cargo build && \
cd .. && \
cp $(RUSTLIB) $(MKFILE_PATH)dynlib/
.PHONY: clean
clean:
rm -f ./lemola_cc src.s a.out test/tmp test/src.s test/tmp.c \
src/lemola_cc.o src/main.o src/parser.o src/tokenizer.o src/code_gen.o
.PHONY: test_old
test_old: lemola_cc
./test/test.sh
.PHONY: test
test: lemola_cc test/test.c test/test_utils.c
cd test && \
../lemola_cc test.c && \
$(CC) -c test_utils.c -g3 && \
$(CC) src.s test_utils.o -o tmp -g3 && \
./tmp
test3: lemola_cc test/test3.c test/test.c test/test_utils.c
cd test && \
../lemola_cc test.c && \
clang src.s test3.c -o tmp && \
./tmp
test_all: test test_old
.PHONY: rev_asm
rev_asm: a.out
objdump -d -M intel a.out | less
run: a.out
./a.out
echo $$?