Newer
Older
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
101
102
103
# Very rudimentary Makefile for the llvm tutorial
# See http://llvm.org/docs/tutorial/
# See also http://koichitamura.blogspot.de/2011/01/since-i-went-to-held-several-weeks-ago.html
# for a necessary "fix" (!)
#
# This Makefile written by Prof. R. C. Moore, fbi.h-da.de
PROGS := ModuleMaker fibonacci toy2 toy3 toy4 toy5 toy6 toy7 toy8 toy9
# Uncomment only one of the next two lines (choose your c++ compiler)
# CC=g++
CC := clang++
# Now, how to compile in LLVM?
# LLVM VERSION 3.9.1 (2017) and possibly LLVM Version 4
# The Tutorial (Chapter 3) does it like this:
# clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy
# based on that, and some experimentation, we got, for LLVM 3.6...
# CFLAGS=-std=c++11 `llvm-config --cxxflags --ldflags --system-libs --libs all` -rdynamic -O3
# Now, for llvm >= 3.7.1, further experience has brought us to....
# At one time, we piped the output of llvm-config to sed s/no-maybe/no/ .
# Hopefully this is no longer necessary... ?
# (sed was used to hide an incompatibility between llvm-config and clang)
LLVM_FLAGS := `llvm-config --cxxflags --ldflags --system-libs --libs all `
CFLAGS := $(LLVM_FLAGS) -rdynamic -O3
## More preliminaries
# See https://www.gnu.org/software/make/manual/html_node/Special-Targets.html
# In this makefile, we want to keep going even if we find errors
.IGNORE :
# Further, we do not want multiple things built at once, even if make called with -j2
.NOTPARALLEL :
# Tell make that the following "targets" are "phony"
# Cf. https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets
.PHONY : all tests clean testclean
## Now, the targets -- the things that will get made!
all: $(PROGS)
$(PROGS): %: %.cpp
$(CC) -g $< $(CFLAGS) -o $@
clean: testclean
$(RM) -fv *~ $(PROGS) ModuleMaker.bc fib test8 test8.o test9
testclean:
rm -fv *~ *.output test8.o test9
testModuleMaker: ModuleMaker
echo && echo "Testing ModuleMaker (expect 5)...\n"
@./ModuleMaker >ModuleMaker.bc
@lli ModuleMaker.bc || echo $$?
# WARNING: testFibonacci broken (with LLVM and clang 3.7.1)
testFibonacci: fibonacci
echo && echo "\n===================> Testing fibonacci (expect 46368)...\n"
-./fibonacci
test2: toy2 tests/test2.kal
echo && echo "\n===================> Testing toy2.. (expecting 1 error)\n"
-./toy2 <tests/test2.kal
test3: toy3 tests/test3.kal
echo && echo "\n===================> Testing toy3...\n"
-./toy3 <tests/test3.kal
test4: toy4 tests/test4.kal
echo && echo "\n===================> Testing toy4...\n"
-./toy4 <tests/test4.kal
test5: toy5 tests/test5.kal
echo && echo "\n===================> Testing toy5...\n"
-./toy5 <tests/test5.kal
test6: toy6 tests/test6.kal
echo && echo "\n===================> Testing toy6...\n"
-./toy6 <tests/test6.kal
test7: toy7 tests/test7.kal
echo && echo "\n===================> Testing toy7...\n"
-./toy7 <tests/test7.kal
test8: toy8 tests/test8.kal toy8.cpp
echo && echo "\n===================> Testing toy8... (expect 42, of course)\n"
-./toy8 <tests/test8.kal
-clang++ tests/test8.cpp test8.o -o test8
-./test8
test9: toy9 tests/test9.kal
echo && echo "\n===================> Testing toy9...\n"
-./toy9 <tests/test9.kal |& clang -x ir - -o test9
-./test9
# WARNING: test9 removed since broken (with LLVM and clang <= 3.9)
# NOTE: fibonacci added BACK to tests since it's working again!
tests: testModuleMaker testFibonacci test2 test3 test4 test5 test6 test7 test8