-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.in
97 lines (69 loc) · 1.96 KB
/
Makefile.in
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
SRCS=RMC.cpp PathCache.cpp SMTify.cpp
include config.mk
# Files that force rebuilding everything
CONFIG_FILES=Makefile config.mk
OBJDIR=build
DEFINES :=
INCLUDE_PATHS :=
LIB_PATHS :=
LIBS :=
ifneq ($(CFG_DISABLE_Z3),1)
DEFINES += -DUSE_Z3=1
LIBS += -lz3
ifneq ($(CFG_DISABLE_Z3_OPT),1)
DEFINES += -DUSE_Z3_OPTIMIZER=1
endif
ifdef CFG_Z3_LOCATION
INCLUDE_PATHS += -I "$(CFG_Z3_LOCATION)/include"
LIB_PATHS += -L "$(CFG_Z3_LOCATION)/lib"
endif
endif
ifeq ($(CFG_DISABLE_OPTIMIZE),1)
OPT_LEVEL=-O0
else
OPT_LEVEL=-O2
endif
LLVM_FLAGS:=$(shell $(CFG_LLVM_CONFIG) --cxxflags | sed s/-fno-exceptions//)
CXXFLAGS=-Wall -Wno-unused-function -g \
$(LLVM_FLAGS) $(INCLUDE_PATHS) $(DEFINES) $(OPT_LEVEL) -fPIC
ifeq ($(CFG_OSTYPE),apple-darwin)
LD_ARGS=-rdynamic -dynamiclib -Wl,-flat_namespace -Wl,-undefined,suppress
else
LD_ARGS=-shared
endif
all: RMC.so run-rmc
# Rebuilding the makefile
# FIXME: this doesn't work quite as expected; I need to figure out how
# to make it restart everything once the makefile is regenerated
Makefile config.mk: config.stamp
config.stamp: configure Makefile.in
./configure $(CFG_CONFIGURE_ARGS)
make $(MAKECMDGOALS)
# Generic rules and build stuff
ifdef VERBOSE
Q :=
E =
else
Q := @
E = echo $(1)
endif
CXX=$(CFG_CC)
OBJ_FILES=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
DEP_FLAGS=-MMD -MP -MF $(@:.o=.d) -MT $@
$(OBJDIR)/%.o: %.cpp $(CONFIG_FILES)
@mkdir -p $(dir $@)
@$(call E, COMPILE $@)
$(Q)$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEP_FLAGS) -c -o $@ $<
-include $(patsubst %.cpp, $(OBJDIR)/%.d, $(SRCS))
RMC.so: $(OBJ_FILES) $(CONFIG_FILES)
@$(call E, LINK $@)
$(Q)$(CXX) $(LIB_PATHS) $(LD_ARGS) $(OBJ_FILES) -o $@ $(LIBS)
# Scripts that need to have some variables set in them. Should make
# this more general. Autoconf would make this easy...
run-rmc: scripts/run-rmc.in $(CONFIG_FILES)
@$(call E, CREATE $@)
@rm -f $@
$(Q)sed "s|@CFG_LLVM_CONFIG@|$(CFG_LLVM_CONFIG)|" $< > $@
$(Q)chmod +x-w $@
clean:
rm -rf *~ *.so $(OBJDIR) run-rmc