forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.unix.mk
256 lines (237 loc) · 8 KB
/
Makefile.unix.mk
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
# ----- You should not need to modify the following, unless the -----
# ----- configuration is not standard. In that case, please tell us -----
# ----- about it. -----
# Unix specific definitions
LIB_PREFIX = lib
DEP_BIN_DIR = $(OR_ROOT)dependencies/install/bin
# C++ relevant directory
INC_DIR = $(OR_ROOT).
SRC_DIR = $(OR_ROOT).
GEN_DIR = $(OR_ROOT)ortools/gen
GEN_PATH = $(subst /,$S,$(GEN_DIR))
OBJ_DIR = $(OR_ROOT)objs
LIB_DIR = $(OR_ROOT)lib
BIN_DIR = $(OR_ROOT)bin
TEST_DIR = $(OR_ROOT)examples/tests
TEST_PATH = $(subst /,$S,$(TEST_DIR))
CC_EX_DIR = $(OR_ROOT)examples/cpp
CC_EX_PATH = $(subst /,$S,$(CC_EX_DIR))
FZ_EX_DIR = $(OR_ROOT)examples/flatzinc
FZ_EX_PATH = $(subst /,$S,$(FZ_EX_DIR))
# Python relevant directory
PYTHON_EX_DIR = $(OR_ROOT)examples/python
PYTHON_EX_PATH = $(subst /,$S,$(PYTHON_EX_DIR))
# Java relevant directory
CLASS_DIR = $(OR_ROOT)classes
JAVA_EX_DIR = $(OR_ROOT)examples/java
JAVA_EX_PATH = $(subst /,$S,$(JAVA_EX_DIR))
# .Net relevant directory
PACKAGE_DIR = $(OR_ROOT)packages
DOTNET_EX_DIR = $(OR_ROOT)examples/dotnet
DOTNET_EX_PATH = $(subst /,$S,$(DOTNET_EX_DIR))
# Contrib examples directory
CONTRIB_EX_DIR = $(OR_ROOT)examples/contrib
CONTRIB_EX_PATH = $(subst /,$S,$(CONTRIB_EX_DIR))
O = o
ifeq ($(PLATFORM),LINUX)
L = so
else # MACOS
L = dylib
endif
E =
J = .jar
D = .dll
PDB = .pdb
EXP = .exp
ARCHIVE_EXT = .tar.gz
FZ_EXE = fzn-or-tools$E
LD_OUT = -o # need the space.
OBJ_OUT = -o # need the space
EXE_OUT = -o # need the space
S = /
CMDSEP = ;
CPSEP = :
COPY = cp
COPYREC = cp -R
DEL = rm -f
DELREC = rm -rf
GREP = grep
MKDIR = mkdir
MKDIR_P = mkdir -p
RENAME = mv
SED = sed
TAR = tar
TOUCH = touch
WHICH = which
CMAKE := $(shell $(WHICH) cmake)
ifeq ($(CMAKE),)
$(error Please add "cmake" to your PATH)
endif
# This is needed to find python.h
PYTHON_VERSION = $(UNIX_PYTHON_VER)
MAJOR_PYTHON_VERSION = $(shell python$(UNIX_PYTHON_VER) -c "from sys import version_info as v; print (str(v[0]))")
MINOR_PYTHON_VERSION = $(shell python$(UNIX_PYTHON_VER) -c "from sys import version_info as v; print (str(v[1]))")
PATH_TO_PYTHON_LIB = $(shell python$(UNIX_PYTHON_VER) -c 'import sysconfig; print (sysconfig.get_paths()["stdlib"])')
PATH_TO_PYTHON_INCLUDE = $(shell python$(UNIX_PYTHON_VER) -c 'import sysconfig; print (sysconfig.get_paths()["platinclude"])')
PYTHON_INC = -I$(PATH_TO_PYTHON_INCLUDE) -I$(PATH_TO_PYTHON_LIB) $(ADD_PYTHON_INC)
PYTHON_INC += $(shell pkg-config --cflags python$(MAJOR_PYTHON_VERSION) 2> /dev/null)
#PYTHON_LNK += $(shell pkg-config --libs python$(MAJOR_PYTHON_VERSION) 2> /dev/null)
#ifeq ("${PYTHON_LNK}","")
#PYTHON_LNK = "-lpython${UNIX_PYTHON_VERSION}"
#endif
# This is needed to find GLPK include files.
ifdef UNIX_GLPK_DIR
GLPK_INC = -I$(UNIX_GLPK_DIR)/include -DUSE_GLPK
GLPK_SWIG = $(GLPK_INC)
endif
# This is needed to find scip include files.
ifdef UNIX_SCIP_DIR
SCIP_INC = -I$(UNIX_SCIP_DIR)/include -DUSE_SCIP -DNO_CONFIG_HEADER
SCIP_SWIG = $(SCIP_INC)
endif
ifdef UNIX_GUROBI_DIR
GUROBI_INC = -I$(UNIX_GUROBI_DIR)/$(GUROBI_PLATFORM)/include -DUSE_GUROBI
GUROBI_SWIG = $(GUROBI_INC)
endif
ifdef UNIX_CPLEX_DIR
CPLEX_INC = -I$(UNIX_CPLEX_DIR)/cplex/include -DUSE_CPLEX
CPLEX_SWIG = $(CPLEX_INC)
endif
ifeq ($(PLATFORM),LINUX)
SWIG_INC = -DSWIGWORDSIZE64
else
SWIG_INC =
endif
SWIG_INC += \
$(GFLAGS_SWIG) $(GLOG_SWIG) $(PROTOBUF_SWIG) $(COIN_SWIG) \
-DUSE_GLOP -DUSE_BOP -DABSL_MUST_USE_RESULT \
$(GLPK_SWIG) $(SCIP_SWIG) $(GUROBI_SWIG) $(CPLEX_SWIG)
# Compilation flags
DEBUG = -O4 -DNDEBUG
JNIDEBUG = -O1 -DNDEBUG
ifeq ($(PLATFORM),LINUX)
CCC = g++ -fPIC -std=c++11 -fwrapv
DYNAMIC_LD = g++ -shared
DYNAMIC_LDFLAGS = -Wl,-rpath,\"\\\$$\$$ORIGIN\"
# This is needed to find libz.a
ZLIB_LNK = -lz
ifdef UNIX_GLPK_DIR
GLPK_LNK = $(UNIX_GLPK_DIR)/lib/libglpk.a
endif
ifdef UNIX_SCIP_DIR
SCIP_LNK = -Wl,-rpath,$(UNIX_SCIP_DIR)/lib -L$(UNIX_SCIP_DIR)/lib -lscip
endif
ifdef UNIX_GUROBI_DIR
ifeq ($(PTRLENGTH),64)
GUROBI_LNK = \
-Wl,-rpath $(UNIX_GUROBI_DIR)/linux64/lib/ \
-L$(UNIX_GUROBI_DIR)/linux64/lib/ -m64 -lc -ldl -lm -lpthread \
-lgurobi$(GUROBI_LIB_VERSION)
else
GUROBI_LNK = \
-Wl,-rpath $(UNIX_GUROBI_DIR)/linux32/lib/ \
-L$(UNIX_GUROBI_DIR)/linux32/lib/ -m32 -lc -ldl -lm -lpthread \
-lgurobi$(GUROBI_LIB_VERSION)
endif
endif
ifdef UNIX_CPLEX_DIR
ifeq ($(PTRLENGTH),64)
CPLEX_LNK = \
-L$(UNIX_CPLEX_DIR)/cplex/lib/x86-64_linux/static_pic -lcplex \
-lm -lpthread -ldl
else
CPLEX_LNK = \
-L$(UNIX_CPLEX_DIR)/cplex/lib/x86_linux/static_pic -lcplex \
-lm -lpthread -ldl
endif
endif
SYS_LNK = -lrt -lpthread
JAVA_INC = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JAVAC_BIN = $(shell $(WHICH) $(JAVA_HOME)/bin/javac)
JAVA_BIN = $(shell $(WHICH) $(JAVA_HOME)/bin/java)
JAR_BIN = $(shell $(WHICH) $(JAVA_HOME)/bin/jar)
JNI_LIB_EXT = so
SWIG_PYTHON_LIB_SUFFIX = so
SWIG_DOTNET_LIB_SUFFIX = so
LINK_CMD = $(DYNAMIC_LD)
PRE_LIB = -L$(OR_ROOT_FULL)/lib -l
POST_LIB =
LINK_FLAGS = \
-Wl,-rpath,'$$ORIGIN' \
-Wl,-rpath,'$$ORIGIN/../lib' \
-Wl,-rpath,'$$ORIGIN/../dependencies/install/lib64' \
-Wl,-rpath,'$$ORIGIN/../dependencies/install/lib'
PYTHON_LDFLAGS = \
-Wl,-rpath,'$$ORIGIN' \
-Wl,-rpath,'$$ORIGIN/../../ortools' \
-Wl,-rpath,'$$ORIGIN/../../ortools/.libs' \
-Wl,-rpath,'$$ORIGIN/../../../../lib' \
-Wl,-rpath,'$$ORIGIN/../../../../dependencies/install/lib64' \
-Wl,-rpath,'$$ORIGIN/../../../../dependencies/install/lib'
endif # ifeq ($(PLATFORM),LINUX)
ifeq ($(PLATFORM),MACOSX)
MAC_VERSION = -mmacosx-version-min=$(MAC_MIN_VERSION)
CCC = clang++ -fPIC -std=c++11 $(MAC_VERSION) -stdlib=libc++
DYNAMIC_LD = clang++ -dynamiclib -undefined dynamic_lookup \
-Wl,-search_paths_first \
-Wl,-headerpad_max_install_names \
-current_version $(OR_TOOLS_MAJOR).$(OR_TOOLS_MINOR) \
-compatibility_version $(OR_TOOLS_MAJOR).$(OR_TOOLS_MINOR)
DYNAMIC_LDFLAGS = -Wl,-rpath,\"@loader_path\"
ZLIB_LNK = -lz
ifdef UNIX_GLPK_DIR
GLPK_LNK = $(UNIX_GLPK_DIR)/lib/libglpk.a
endif
ifdef UNIX_SCIP_DIR
SCIP_LNK = -force_load $(UNIX_SCIP_DIR)/lib/libscipopt.a $(UNIX_SCIP_DIR)/lib/libsoplex.a
endif
ifdef UNIX_GUROBI_DIR
GUROBI_LNK = \
-L$(UNIX_GUROBI_DIR)/mac64/bin/ -lc -ldl -lm -lpthread \
-lgurobi$(GUROBI_LIB_VERSION)
endif
ifdef UNIX_CPLEX_DIR
CPLEX_LNK = \
-force_load $(UNIX_CPLEX_DIR)/cplex/lib/x86-64_osx/static_pic/libcplex.a \
-lm -lpthread -framework CoreFoundation -framework IOKit
endif
SYS_LNK =
SET_COMPILER = CXX="$(CCC)"
JAVA_INC = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/darwin
JAVAC_BIN = $(shell $(WHICH) $(JAVA_HOME)/bin/javac)
JAVA_BIN = $(shell $(WHICH) $(JAVA_HOME)/bin/java)
JAR_BIN = $(shell $(WHICH) $(JAVA_HOME)/bin/jar)
JNI_LIB_EXT = jnilib
SWIG_PYTHON_LIB_SUFFIX = so# To overcome a bug in Mac OS X loader.
SWIG_DOTNET_LIB_SUFFIX = dylib
LINK_CMD = clang++ -dynamiclib \
-Wl,-search_paths_first \
-Wl,-headerpad_max_install_names \
-current_version $(OR_TOOLS_MAJOR).$(OR_TOOLS_MINOR) \
-compatibility_version $(OR_TOOLS_MAJOR).$(OR_TOOLS_MINOR)
PRE_LIB = -L$(OR_ROOT)lib -l
POST_LIB =
LINK_FLAGS = \
-framework CoreFoundation \
-Wl,-rpath,@loader_path \
-Wl,-rpath,@loader_path/../lib \
-Wl,-rpath,@loader_path/../dependencies/install/lib
LDFLAGS = -install_name @rpath/$(LIB_PREFIX)ortools.$L #
PYTHON_LDFLAGS = \
-Wl,-rpath,@loader_path \
-Wl,-rpath,@loader_path/../../ortools \
-Wl,-rpath,@loader_path/../../ortools/.libs \
-Wl,-rpath,@loader_path/../../../../lib \
-Wl,-rpath,@loader_path/../../../../dependencies/install/lib
endif # ifeq ($(PLATFORM),MACOSX)
DEPENDENCIES_INC = -I$(INC_DIR) -I$(GEN_DIR) \
$(GFLAGS_INC) $(GLOG_INC) $(PROTOBUF_INC) \
$(COIN_INC) \
-Wno-deprecated -DUSE_GLOP -DUSE_BOP \
$(GLPK_INC) $(SCIP_INC) $(GUROBI_INC) $(CPLEX_INC)
CFLAGS = $(DEBUG) $(DEPENDENCIES_INC) -DOR_TOOLS_MAJOR=$(OR_TOOLS_MAJOR) -DOR_TOOLS_MINOR=$(OR_TOOLS_MINOR)
JNIFLAGS = $(JNIDEBUG) $(DEPENDENCIES_INC)
LDFLAGS += $(ZLIB_LNK) $(SYS_LNK) $(LINK_FLAGS)
DEPENDENCIES_LNK = $(GLPK_LNK) $(SCIP_LNK) $(GUROBI_LNK) $(CPLEX_LNK)
OR_TOOLS_LNK =
OR_TOOLS_LDFLAGS = $(ZLIB_LNK) $(SYS_LNK) $(LINK_FLAGS)