-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
48 lines (32 loc) · 1.04 KB
/
makefile
File metadata and controls
48 lines (32 loc) · 1.04 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
PROG := main.out
PROGSELF := main.self_out
CLEAN_FILES := *.out *.o *.s *.ll *.llvm_ll *.llvm_s *.llvm_out *.self_out
TEST_FILES := operators.c types.c struct.c typedef.c controlflow.c
all: self
self: $(PROGSELF)
make -s PROG=$(PROGSELF) $(TEST_FILES:%.c=tests/%.llvm_exe)
%.self_out: %.c
make $(@:%.self_out=%.llvm_out);\
cp $(@:%.self_out=%.llvm_out) $@
test:
make -s $(TEST_FILES:%.c=tests/%.llvm_exe)
%.o:%.c
gcc -c -o $@ -fno-builtin -fno-gnu-unique -O0 -g -Wall $^
%.out: %.o
g++ -g $^ -o $@ `llvm-config-18 --cxxflags --ldflags --libs all`
%.llvm_ll: $(PROG) %.c
./$(PROG) $*.c > $@
%.llvm_s:%.llvm_ll
llc -o $@ $^
%.llvm_o: %.llvm_s
gcc -c -g -no-pie -x assembler -o $@ $^
%.llvm_out: %.llvm_o
g++ -g -no-pie $^ -o $@ `llvm-config-18 --cxxflags --ldflags --libs all`
%.llvm_exe: %.llvm_out
echo "-----" ;\
./$^; echo "\nResult:" $$?
clean:
rm -f $(CLEAN_FILES); \
cd tests; rm -f $(CLEAN_FILES)
.PHONY: clean test self
.PRECIOUS: %.llvm_out %.llvm_s %.llvm_ll %.out %.o %.s