-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
100 lines (72 loc) · 1.81 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
GO_SOURCES = $(wildcard *.go)
goas: $(GO_SOURCES)
go build -o goas .
.PHONY: test
# Check /etc/os-release to prevent non-linux from running this
test: test1 test2 test3 gotest
.PHONY: gotest
gotest:
go test .
T1_SOURCES = $(wildcard t1/*.s)
T1_GNU_OBJS = $(T1_SOURCES:t1/%.s=out/g/1/%.o)
T1_MY_OBJS = $(T1_SOURCES:t1/%.s=out/m/1/%.o)
# dir to save GNU output
out/g/1:
mkdir -p $@
# dir to save my output
out/m/1:
mkdir -p $@
# Test single-source program
.PHONY: test1
test1: $(T1_GNU_OBJS) $(T1_MY_OBJS)
./tool/check-diff 1
@echo ok
out/g/1/%.o: t1/%.s out/g/1 /etc/os-release
as -o $@ $<
out/m/1/%.o: t1/%.s goas out/m/1
./goas -o $@ $<
T2_SOURCES = $(wildcard t2/*.s)
T2_GNU_OBJS = $(T2_SOURCES:t2/%.s=out/g/2/%.o)
T2_MY_OBJS = $(T2_SOURCES:t2/%.s=out/m/2/%.o)
out/g/2:
mkdir -p $@
out/m/2:
mkdir -p $@
# Test asm files generated by babygo's test
.PHONY: test2
test2: $(T2_GNU_OBJS) $(T2_MY_OBJS)
./tool/check-diff 2
@echo ok
out/g/2/%.o: t2/%.s out/g/2 /etc/os-release
as -o $@ $<
out/m/2/%.o: t2/%.s goas out/m/2
./goas -o $@ $<
# Make and run babygo test
run-babygo-test: out/m/2/babygo-test out/m/2/t/text.txt
cd out/m/2 ; ./babygo-test
out/m/2/t/text.txt: out/m/2 t2/t/text.txt
cp -ar t2/t out/m/2/
out/m/2/babygo-test: out/m/2/*.o
mold -o $@ $^
T3_SOURCES = $(wildcard t3/*.s)
T3_GNU_OBJS = $(T3_SOURCES:t3/%.s=out/g/3/%.o)
T3_MY_OBJS = $(T3_SOURCES:t3/%.s=out/m/3/%.o)
# Test asm files generated by babygo's test
test3: $(T3_GNU_OBJS) $(T3_MY_OBJS)
./tool/check-diff 3
@echo ok
out/m/3:
mkdir -p $@
out/g/3:
mkdir -p $@
out/g/3/%.o: t3/%.s out/g/3 /etc/os-release
as -o $@ $<
out/m/3/%.o: t3/%.s goas out/m/3
./goas -o $@ $<
# Make and run babygo 2gen
run-babygo: out/m/3/babygo
cd out/m/3 ; ./babygo version
out/m/3/babygo: out/m/3/*.o
mold -o $@ $^
clean:
rm -rf goas *.o *.bin *.out out