-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
93 lines (78 loc) · 2.9 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
# First, download llvm (in source form), unpack it, and compile it:
# cd $(HOME)/llvm-3.5.0.src/
# TRIPLE=i686-apple-darwin10
# ./configure --with-gxx-include-dir=/usr/include/c++/4.2.1 --build=$TRIPLE --host=$TRIPLE --target=$TRIPLE
# make
# Download MLKit and install it.
# Update the variables LLVMDIR and MLKITINCLUDEDIR below.
PWD=$(shell pwd)
MLKITINCLUDEDIR=/usr/local/share/mlkit/include
MLKIT=mlkit
LLVMDIR=$(HOME)/llvm-3.5.0.src
LLVMINCLUDEDIR=$(LLVMDIR)/include
LLVMBINDIR=$(LLVMDIR)/Release+Asserts/bin
LLVMCONFIG=$(LLVMBINDIR)/llvm-config
#LLVM_LIBS_GEN=$(shell $(LLVMCONFIG) --libs core --libs bitwriter --libs engine --libs executionengine)
LLVM_LIBS_GEN=$(shell $(LLVMCONFIG) --libs) $(shell $(LLVMCONFIG) --system-libs)
TEST=$(shell $(LLVMCONFIG) --libs core jit native interpreter bitwriter)
#LLVM_LIBNAMES=$(shell $(LLVMCONFIG) --libnames core --libnames bitwriter)
LLVM_LDFLAGS=$(shell $(LLVMCONFIG) --ldflags)
LLVM_CPPFLAGS=$(shell $(LLVMCONFIG) --cppflags)
LLVM_LIBS=LLVMBitWriter,LLVMInterpreter,LLVMX86CodeGen,LLVMSelectionDAG,LLVMAsmPrinter,LLVMX86AsmParser,LLVMMCParser,LLVMX86Disassembler,LLVMX86Desc,LLVMX86Info,LLVMX86AsmPrinter,LLVMX86Utils,LLVMJIT,LLVMRuntimeDyld,LLVMExecutionEngine,LLVMCodeGen,LLVMScalarOpts,LLVMInstCombine,LLVMTransformUtils,LLVMipa,LLVMAnalysis,LLVMTarget,LLVMMC,LLVMObject,LLVMCore,LLVMSupport
LLVM_LIBS2=$(LLVM_LIBS_GEN:-l%=%,)
LIBS="c,LLVMMLKit,$(LLVM_LIBS2)dl"
LIBDIRS="$(LLVMDIR)/Release+Asserts/lib,."
CC="g++"
MLKIT_CC_FLAGS=-g -O2 -m32 -Wall -std=gnu99 -DTAG_VALUES -DTAG_FREE_PAIRS -DENABLE_GC
.PHONY: all
all: libLLVMMLKit.a
$(MLKIT) -cc $(CC) --libs $(LIBS) --libdirs $(LIBDIRS) llvm.mlb
.PHONY: show
show:
@echo "LLVM_LIBS2:"
@echo " $(LLVM_LIBS2)"
@echo "TEST:"
@echo " $(TEST)"
@echo "LLVMDIR:"
@echo " $(LLVMDIR)"
@echo "LLVMBINDIR:"
@echo " $(LLVMBINDIR)"
@echo "LLVMCONFIG"
@echo " $(LLVMCONFIG)"
@echo "LLVM_LIBS_GEN:"
@echo " $(LLVM_LIBS_GEN)"
# @echo "$(LLVM_LIBNAMES)"
@echo "LLVM_LDFLAGS:"
@echo " $(LLVM_LDFLAGS)"
@echo "LLVM_CPPFLAGS:"
@echo " $(LLVM_CPPFLAGS)"
@echo " $(LIBS)"
libLLVMMLKit.a: LLVMMLKit.o
cp -p $< $@
LLVMMLKit.o: llvm_mlkit.c
gcc $(LLVM_CPPFLAGS) $(MLKIT_CC_FLAGS) -I $(MLKITINCLUDEDIR) -c -o $@ $<
miniml: miniml.ll
$(LLVMDIR)/Release+Asserts/bin/llc -O3 miniml.bc -o miniml.s
gcc -O3 miniml.s -o miniml
./miniml
miniml.bc: minimlexe
./minimlexe $@
minimlexe: libLLVMMLKit.a
$(MLKIT) -cc $(CC) --libs $(LIBS) --libdirs $(LIBDIRS) -o $@ test/miniml/miniml.mlb
.PHONY: minimljit
minimljit: minimlexe
./minimlexe -jit
.PHONY: minimlinterp
minimlinterp: minimlexe
./minimlexe -interp
.PHONY: test
test: testexe
./testexe
testexe: libLLVMMLKit.a
$(MLKIT) -cc $(CC) --libs $(LIBS) --libdirs $(LIBDIRS) -o $@ test/unittest/unittest.mlb
test.bc: testexe
./testexe
%.ll: %.bc
$(LLVMDIR)/Release+Asserts/bin/llvm-dis $<
clean:
rm -rf MLB *~ run test/*/MLB test/*/run test/*/*~ *.a *.o *.bc *.ll miniml *.s testexe minimlexe