-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
163 lines (132 loc) · 5.96 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
###################################################################################################
# make "for release version"
# make d "debug version"
# make p "profiling version"
# make clean "remove object files and executable"
###################################################################################################
.PHONY: r d p lr ld lp all install install-bin clean distclean
all: r
## Configurable options ###########################################################################
## Cplex library location (configure these variables)
LINUX_CPLEXLIBDIR ?= /w/63/fbacchus/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic
LINUX_CPLEXINCDIR ?= /w/63/fbacchus/CPLEX_Studio1210/cplex/include
## Cplex libary on mac vm
LINUXVM_CPLEXLIBDIR ?= /home/fbacchus/CPLEX_Studio1210/cplex/lib/x86-64_linux/static_pic
LINUXVM_CPLEXINCDIR ?= /home/fbacchus/CPLEX_Studio1210/cplex/include
#
#If you want to build on macos
DARWIN_CPLEXLIBDIR ?= /Users/fbacchus/Applications/IBM/ILOG/CPLEX_Studio1210/cplex/lib/x86-64_osx/static_pic/
DARWIN_CPLEXINCDIR ?= /Users/fbacchus/Applications/IBM/ILOG/CPLEX_Studio1210/cplex/include
ifeq "$(shell uname)" "Linux"
CPLEXLIBDIR =$(LINUX_CPLEXLIBDIR)
CPLEXINCDIR =$(LINUX_CPLEXINCDIR)
endif
ifeq "$(shell uname)" "Darwin"
CPLEXLIBDIR =$(DARWIN_CPLEXLIBDIR)
CPLEXINCDIR =$(DARWIN_CPLEXINCDIR)
endif
ifeq "$(shell hostname)" "ubuntu-vm"
CPLEXLIBDIR =$(LINUXVM_CPLEXLIBDIR)
CPLEXINCDIR =$(LINUXVM_CPLEXINCDIR)
endif
# Directory to store object files, libraries, executables, and dependencies:
BUILD_DIR ?= build
# Include debug-symbols in release builds?
#MAXHS_RELSYM ?= -g
MAXHS_REL ?= -O3 -DNDEBUG -DNCONTRACTS -DNTRACING
#MAXHS_REL += -DLOGGING
#MAXHS_REL += -DQUITE
#MAXHS_DEB ?= -O0 -DDEBUG -D_GLIBCXX_DEBUG -ggdb
MAXHS_DEB ?= -O0 -DDEBUG -ggdb
MAXHS_PRF ?= -O3 -DNDEBUG
ifneq "$(CXX)" "clang++"
MAXHS_REL += -flto
endif
# Target file names
MAXHS = maxhs# Name of Maxhs main executable.
MAXHS_SLIB = lib$(MAXHS).a# Name of Maxhs static library.
#-DIL_STD is a IBM/CPLEX issue
MAXHS_CXXFLAGS = -DIL_STD -I. -I$(CPLEXINCDIR)
MAXHS_CXXFLAGS += -Wall -Wno-parentheses -Wextra -Wno-deprecated
MAXHS_CXXFLAGS += -std=c++14
MAXHS_LDFLAGS = -Wall -lz -L$(CPLEXLIBDIR) -lcplex -lpthread -ldl -flto
ECHO=@echo
ifeq ($(VERB),)
VERB=@
else
VERB=
endif
MAXHS_SRCS = $(wildcard maxhs/core/*.cc) $(wildcard maxhs/ifaces/*.cc) $(wildcard maxhs/utils/*.cc) \
$(wildcard minisat/utils/*.cc)
SATSOLVER_SRCS = $(wildcard cadical/src/*.cpp)
OBJS = $(filter-out %Main.o, $(MAXHS_SRCS:.cc=.o))
ALLOBJS = $(MAXHS_SRCS:.cc=.o)
OBJS += $(filter-out %cadical.o %mobical.o, $(SATSOLVER_SRCS:.cpp=.o))
ALLOBJS += $(SATSOLVER_SRCS:.cpp=.o)
r: $(BUILD_DIR)/release/bin/$(MAXHS)
d: $(BUILD_DIR)/debug/bin/$(MAXHS)
p: $(BUILD_DIR)/profile/bin/$(MAXHS)
lr: $(BUILD_DIR)/release/lib/$(MAXHS_SLIB)
ld: $(BUILD_DIR)/debug/lib/$(MAXHS_SLIB)
lp: $(BUILD_DIR)/profile/lib/$(MAXHS_SLIB)
## Build-type Compile-flags:
$(BUILD_DIR)/release/%.o: MAXHS_CXXFLAGS +=$(MAXHS_REL) $(MAXHS_RELSYM)
$(BUILD_DIR)/debug/%.o: MAXHS_CXXFLAGS +=$(MAXHS_DEB)
$(BUILD_DIR)/profile/%.o: MAXHS_CXXFLAGS +=$(MAXHS_PRF) -pg
## Build-type Link-flags:
$(BUILD_DIR)/profile/bin/$(MAXHS): MAXHS_LDFLAGS += -pg
ifeq "$(shell uname)" "Linux"
$(BUILD_DIR)/release/bin/$(MAXHS): MAXHS_LDFLAGS += --static -z muldefs
endif
$(BUILD_DIR)/release/bin/$(MAXHS): MAXHS_LDFLAGS += $(MAXHS_RELSYM)
## Executable dependencies
$(BUILD_DIR)/release/bin/$(MAXHS): $(BUILD_DIR)/release/maxhs/core/Main.o $(foreach o,$(OBJS),$(BUILD_DIR)/release/$(o))
$(BUILD_DIR)/debug/bin/$(MAXHS): $(BUILD_DIR)/debug/maxhs/core/Main.o $(foreach o,$(OBJS),$(BUILD_DIR)/debug/$(o))
#$(BUILD_DIR)/debug/bin/$(MAXHS): $(BUILD_DIR)/debug/maxhs/core/Main.o $(BUILD_DIR)/debug/lib/$(MAXHS_SLIB)
#$(BUILD_DIR)/profile/bin/$(MAXHS): $(BUILD_DIR)/profile/maxhs/core/Main.o $(BUILD_DIR)/profile/lib/$(MAXHS_SLIB)
## Library dependencies
#$(BUILD_DIR)/release/lib/$(MAXHS_SLIB): $(foreach o,$(OBJS),$(BUILD_DIR)/release/$(o))
#$(BUILD_DIR)/debug/lib/$(MAXHS_SLIB): $(foreach o,$(OBJS),$(BUILD_DIR)/debug/$(o))
#$(BUILD_DIR)/profile/lib/$(MAXHS_SLIB): $(foreach o,$(OBJS),$(BUILD_DIR)/profile/$(o))
## Compile rules
$(BUILD_DIR)/release/%.o: %.cc
$(ECHO) Compiling: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(CXX) $(MAXHS_CXXFLAGS) $(CXXFLAGS) -c -o $@ $< -MMD -MF $(BUILD_DIR)/release/$*.d
$(BUILD_DIR)/release/%.o: %.cpp
$(ECHO) Compiling: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(CXX) $(MAXHS_CXXFLAGS) $(CXXFLAGS) -c -o $@ $< -MMD -MF $(BUILD_DIR)/release/$*.d
$(BUILD_DIR)/profile/%.o: %.cc
$(ECHO) Compiling: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(CXX) $(MAXHS_CXXFLAGS) $(CXXFLAGS) -c -o $@ $< -MMD -MF $(BUILD_DIR)/profile/$*.d
$(BUILD_DIR)/profile/%.o: %.cpp
$(ECHO) Compiling: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(CXX) $(MAXHS_CXXFLAGS) $(CXXFLAGS) -c -o $@ $< -MMD -MF $(BUILD_DIR)/release/$*.d
$(BUILD_DIR)/debug/%.o: %.cc
$(ECHO) Compiling: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(CXX) $(MAXHS_CXXFLAGS) $(CXXFLAGS) -c -o $@ $< -MMD -MF $(BUILD_DIR)/debug/$*.d
$(BUILD_DIR)/debug/%.o: %.cpp
$(ECHO) Compiling: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(CXX) $(MAXHS_CXXFLAGS) $(CXXFLAGS) -c -o $@ $< -MMD -MF $(BUILD_DIR)/release/$*.d
## Linking rule
$(BUILD_DIR)/release/bin/$(MAXHS) $(BUILD_DIR)/debug/bin/$(MAXHS) $(BUILD_DIR)/profile/bin/$(MAXHS):
$(ECHO) Linking Binary: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(CXX) $^ $(MAXHS_LDFLAGS) $(LDFLAGS) -o $@
## Static Library rule
%/lib/$(MAXHS_SLIB):
$(ECHO) Linking Static Library: $@
$(VERB) mkdir -p $(dir $@)
$(VERB) $(AR) -rcs $@ $^
clean:
rm -f $(foreach t, release debug profile, $(foreach o, $(ALLOBJS), $(BUILD_DIR)/$t/$o)) \
$(foreach t, release debug profile, $(foreach d, $(ALLOBJS:.o=.d), $(BUILD_DIR)/$t/$d)) \
$(foreach t, release debug profile, $(BUILD_DIR)/$t/bin/$(MAXHS))\
## Include generated dependencies
DEPS = $(foreach b, release, $(foreach d, $(ALLOBJS:.o=.d), $(BUILD_DIR)/$b/$d))
-include $(DEPS)