-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfigure
executable file
·181 lines (149 loc) · 6.31 KB
/
configure
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
#!/bin/bash
## TraME-Rcpp config script
# get working directory
WDIR=${PWD}
TRAME_BUILD_PATH=${WDIR}/src
# set build and optimization flags
TRAME_OPT_FLAGS="-O3 -Wall"
if [[ !($OSTYPE == darwin*) ]] ; then
echo "TraME: using OpenMP"
TRAME_OPT_FLAGS="${TRAME_OPT_FLAGS} -fopenmp -DTRAME_USE_OMP"
fi
# switch between OSX and Linux
if [[ $OSTYPE == darwin* ]] ; then
# look for any Gurobi directories, then choose the latest one
grb_dirs=( /Library/gurobi* )
nmb_dirs=${#grb_dirs[@]}
grb_latest=${grb_dirs[$nmb_dirs-1]}
# 'grb_dirs' will always be non-empty; in the case where no Gurobi directories are detected,
# grb_dirs will contain just '/Library/gurobi*', which is not an actual directory, so we need
# the following sanity check
if [[ !("${TRAME_LP}" == "glpk") && -d $grb_latest ]] ; then
grb_lib_path=( "$grb_latest/mac64/lib/libgurobi*.so" )
grb_lib_latest=${grb_lib_path[0]}
grb_lib_name=$(basename ${grb_lib_latest})
grb_lib_num=${grb_lib_name//[^0-9]/}
LP_INCLUDE_PATH="-DTRAME_USE_GUROBI -I$grb_latest/mac64/include"
LP_LIB_PATH="-L$grb_latest/mac64/lib"
LP_LIBS="-lgurobi${grb_lib_num}"
LP_LIB_RPATH="-Wl,-rpath,$grb_latest/mac64/lib"
echo ""
echo "TraME: using Gurobi. LP_INCLUDE_PATH set to ${LP_INCLUDE_PATH}"
else
# look for GLPK, or download it
if [ -f ${WDIR}/glpk_tmp/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I${WDIR}/glpk_tmp/include"
LP_LIB_PATH="-L${WDIR}/glpk_tmp/lib"
elif [ -f /usr/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/usr/include"
LP_LIB_PATH="-L/usr/lib"
elif [ -f /usr/local/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/usr/local/include"
LP_LIB_PATH="-L/usr/local/lib"
elif [ -f /opt/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/opt/include"
LP_LIB_PATH="-L/opt/lib"
elif [ -f /opt/local/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/opt/local/include"
LP_LIB_PATH="-L/opt/local/lib"
else
echo ""
echo "TraME: cannot find a linear programming solver. Downloading and building GLPK."
echo ""
mkdir ${WDIR}/glpk_tmp
cd glpk_tmp
curl -O http://ftp.gnu.org/gnu/glpk/glpk-4.63.tar.gz > /dev/null 2>&1
tar -xzf glpk-4.63.tar.gz > /dev/null 2>&1
cd glpk-4.63
./configure --prefix=${WDIR}/glpk_tmp > /dev/null 2>&1
make > /dev/null 2>&1
make PREFIX=${WDIR}/glpk_tmp install > /dev/null 2>&1
cd ${WDIR}
rm -f ${WDIR}/glpk_tmp/glpk-4.63.tar.gz
rm -rf ${WDIR}/glpk_tmp/glpk-4.63
echo ""
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I${WDIR}/glpk_tmp/include"
LP_LIB_PATH="-L${WDIR}/glpk_tmp/lib"
fi
LP_LIBS="-lglpk"
LP_LIB_RPATH=
echo ""
echo "TraME: using GLPK. LP_INCLUDE_PATH set to ${LP_INCLUDE_PATH}"
fi
elif [[ $OSTYPE == *linux* ]] ; then
# look for any Gurobi directories, then choose the latest one
grb_dirs=( /opt/gurobi* )
nmb_dirs=${#grb_dirs[@]}
grb_latest=${grb_dirs[$nmb_dirs-1]}
# 'grb_dirs' will always be non-empty; in the case where no Gurobi directories are detected,
# grb_dirs will contain just '/Library/gurobi*', which is not an actual directory, so we need
# the following sanity check
if [[ !("${TRAME_LP}" == "glpk") && -d $grb_latest ]] ; then
grb_lib_path=( "$grb_latest/linux64/lib/libgurobi*.so" )
grb_lib_latest=${grb_lib_path[0]}
grb_lib_name=$(basename ${grb_lib_latest})
grb_lib_num=${grb_lib_name//[^0-9]/}
LP_INCLUDE_PATH="-DTRAME_USE_GUROBI -I$grb_latest/linux64/include"
LP_LIB_PATH="-L$grb_latest/linux64/lib"
LP_LIBS="-lgurobi${grb_lib_num}"
LP_LIB_RPATH="-Wl,-rpath,$grb_latest/linux64/lib"
echo ""
echo "TraME: using Gurobi. LP_INCLUDE_PATH set to ${LP_INCLUDE_PATH}"
else
# look for GLPK, or download it
if [ -f ${WDIR}/glpk_tmp/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I${WDIR}/glpk_tmp/include"
LP_LIB_PATH="-L${WDIR}/glpk_tmp/lib"
elif [ -f /usr/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/usr/include"
LP_LIB_PATH="-L/usr/lib"
elif [ -f /usr/local/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/usr/local/include"
LP_LIB_PATH="-L/usr/local/lib"
elif [ -f /opt/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/opt/include"
LP_LIB_PATH="-L/opt/lib"
elif [ -f /opt/local/include/glpk.h ]; then
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I/opt/local/include"
LP_LIB_PATH="-L/opt/local/lib"
else
echo ""
echo "TraME: cannot find a linear programming solver. Downloading and building GLPK."
echo ""
mkdir ${WDIR}/glpk_tmp
cd glpk_tmp
curl -O http://ftp.gnu.org/gnu/glpk/glpk-4.63.tar.gz > /dev/null 2>&1
tar -xzf glpk-4.63.tar.gz > /dev/null 2>&1
cd glpk-4.63
./configure --prefix=${WDIR}/glpk_tmp > /dev/null 2>&1
make > /dev/null 2>&1
make PREFIX=${WDIR}/glpk_tmp install > /dev/null 2>&1
cd ${WDIR}
rm -f ${WDIR}/glpk_tmp/glpk-4.63.tar.gz
rm -rf ${WDIR}/glpk_tmp/glpk-4.63
echo ""
LP_INCLUDE_PATH="-DTRAME_USE_GLPK -I${WDIR}/glpk_tmp/include"
LP_LIB_PATH="-L${WDIR}/glpk_tmp/lib"
fi
LP_LIBS="-lglpk"
LP_LIB_RPATH=
echo ""
echo "TraME: using GLPK. LP_INCLUDE_PATH set to ${LP_INCLUDE_PATH}"
fi
else
LP_INCLUDE_PATH=
LP_LIB_PATH=
LP_LIBS=
LP_LIB_RPATH=
fi
# create Makefile
sed -e "s|@CC@|${CC}|" \
-e "s|@CXX@|${CXX}|" \
-e "s|@FC@|${FC}|" \
-e "s|@TRAME_OPT_FLAGS@|${TRAME_OPT_FLAGS}|" \
-e "s|@TRAME_BUILD_PATH@|${TRAME_BUILD_PATH}|" \
-e "s|@LP_INCLUDE_PATH@|${LP_INCLUDE_PATH}|" \
-e "s|@LP_LIB_PATH@|${LP_LIB_PATH}|" \
-e "s|@LP_LIBS@|${LP_LIBS}|" \
-e "s|@LP_LIB_RPATH@|${LP_LIB_RPATH}|" \
src/Makevars.in > src/Makevars