/
Makefile
96 lines (72 loc) · 2.03 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
OBJECTS = lexer.o source.o location.o token.o expr.o parser.o types.o constants.o builtin.o \
binary.o lacsap.o namedobject.o semantics.o trace.o stack.o utils.o callgraph.o \
schema.o
# If not specified, use clang and enable 32-bit build - debug enabled
USECLANG ?= 1
M32 ?= 1
NDEBUG ?= 0
ifeq (${NDEBUG}, 0)
LLVM_DIR ?= /usr/local/llvm-debug-new
else
LLVM_DIR ?= /usr/local/llvm-new
endif
ifeq (${USECLANG}, 1)
CC = clang
CXX = clang++
endif
LD = ${CXX}
ifeq (${NDEBUG}, 0)
DEBUG ?= -g -O0
else
DEBUG ?= -DNDEBUG=1 -O2
endif
CXXFLAGS = ${DEBUG} -Wall -Werror -Wextra -Wno-unused-parameter -std=c++17
CXXFLAGS += $(shell ${LLVM_DIR}/bin/llvm-config --cxxflags)
CXXFLAGS += -fno-exceptions -fno-rtti
ifeq (${CC},clang)
CXXFLAGS += -Qunused-arguments -fstandalone-debug
endif
ifeq (${M32}, 0)
CXXFLAGS += -DM32_DISABLE=1
endif
#CXX_EXTRA = --analyze
LDFLAGS = -g -rdynamic
ifeq (${CC},clang)
LDFLAGS += -fstandalone-debug -fuse-ld=lld
endif
LDFLAGS += $(shell ${LLVM_DIR}/bin/llvm-config --ldflags)
LLVMLIBS = $(shell ${LLVM_DIR}/bin/llvm-config --libs)
LLVMLIBS += $(shell ${LLVM_DIR}/bin/llvm-config --system-libs)
SOURCES = $(patsubst %.o,%.cpp,${OBJECTS})
all: lacsap .depends tests runtime_lib llvmversion
.cpp.o:
${CXX} ${CXXFLAGS} ${CXX_EXTRA} -c -o $@ $<
lacsap: ${OBJECTS} .depends
${LD} ${LDFLAGS} -o $@ ${OBJECTS} ${LLVMLIBS}
.phony: tests
tests: runtime_lib
${MAKE} -C test CC=${CC} CXX=${CXX} M32=${M32}
.phony: runtime_lib
runtime_lib:
${MAKE} -C runtime CC=${CC} M32=${M32}
.phony: runtests
runtests: fulltests
.phony: fulltests
fulltests: lacsap tests
${MAKE} -C test fulltests M32=${M32}
.phony: fasttests
fasttests: lacsap tests
${MAKE} -C test fasttests M32=${M32}
.phony: debugtests
debugtests: lacsap tests
${MAKE} -C test debugtests M32=${M32}
.phony: llvmversion
llvmversion:
./llvm_version_info.sh > $@
clean:
rm -f ${OBJECTS} libruntime.a llvmversion
make -C test clean
make -C runtime clean .depends
include .depends
.depends: Makefile ${SOURCES}
${CXX} -MM ${CXXFLAGS} ${SOURCES} > $@