-
Notifications
You must be signed in to change notification settings - Fork 279
/
configure
executable file
·300 lines (259 loc) · 7.55 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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#!/usr/bin/env bash
###########################################
# Lightly adapted from PowerGraph's configure script:
# https://github.com/jegonzal/PowerGraph/blob/a038f975cf2a976abbf4da97eb866b5cad55110c/configure
###########################################
##=============================================================================
## Support code
function download_file {
# detect wget
echo "Downloading $2 from $1 ..."
if [ -z `which wget` ] ; then
if [ -z `which curl` ] ; then
echo "Unable to find either curl or wget! Cannot proceed with
automatic install."
exit 1
fi
curl $1 -o $2
else
wget $1 -O $2
fi
} # end of download file
function print_help {
echo "Usage: ./configure [--prefix=PREFIX]"
echo
echo " --cleanup remove all build directories"
echo
echo " --cleanup-quiet remove all build directories without asking for confirmation"
echo
echo " --release build for release (should be used for all performance testing)"
echo
echo " --prefix=[PREFIX] Clipper Installation target directory. Defaults to /usr/local"
echo
echo " --ide=[Xcode] Specify the ide to use when building Clipper"
echo
echo " --no_tcmalloc Disable using tcmalloc instead of malloc."
echo
echo " -D var=value Specify definitions to be passed on to cmake."
exit 1
} # end of print help
function run_cleanup {
#!/usr/bin/env bash
if [ $# -gt 0 -a "$1" == "-f" ]; then
echo "Force-removing release and debug folders";
rm -rf release debug deps config.log
exit 0
fi
echo "This script completely erases all build folders including dependencies!!!"
echo "Are you sure you want to continue? (yes or no)"
read yesorno;
if [ "$yesorno" == "yes" ]; then
echo "Removing release and debug folders";
rm -rf release debug deps config.log
else
echo "Doing nothing!";
fi
exit 0
} # end of run cleanup
function unknown_option {
echo "Unrecognized option: $1"
echo "To get help, run ./configure --help"
exit 1
} # end of unknown option
## Obtained from forum:
# http://stackoverflow.com/questions/4023830/bash-how-compare-two-strings-in-version-format
# Return 0 if version are equal
# Returns 1 if version 1 is larger
# Returns 2 if version 2 is larger
function check_version {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
RELEASE_DIR=release
DEBUG_DIR=debug
CLIPPER_HOME=$PWD
DEPS_PREFIX=$PWD/deps/local
# ## The defaults can be overwritten be editing the configure.deps file
# if [ -f configure.deps ]; then
# # source configure.deps
# # We delete the configure deps and then recreate it each time using
# # the original values along with any modifications made by the
# # configure logic.
# rm configure.deps
# fi
# Parse command line configure flags ------------------------------------------
while [ $# -gt 0 ]
do case $1 in
--help) print_help=1 ;;
--cleanup) run_cleanup=1 ;;
--cleanup-quiet) run_cleanup_quiet=1 ;;
--no_tcmalloc) no_tcmalloc=1 ;;
--release) release=1 ;;
--prefix=*) prefix=${1##--prefix=} ;;
--ide=*) ide=${1##--ide=} ;;
-D) CFLAGS="$CFLAGS -D $2"; shift ;;
*) unknown_option $1 ;;
esac
shift
done
if [ $print_help ]; then
print_help;
fi
if [ $run_cleanup_quiet ]; then
run_cleanup -f
elif [ $run_cleanup ]; then
run_cleanup
fi
# Extra generator setting (passed in as an argument)
if [[ -n $ide ]]; then
GENERATOR="-G $ide"
fi
if [ $no_tcmalloc ]; then
NO_TCMALLOC=true
fi
if [[ -n $prefix ]]; then
INSTALL_DIR=$prefix
fi
# If not specified we assume gcc and g++ are the default c and c++
# compilers
if [[ -z $CC ]]; then
CC=gcc
fi
if [[ -z $CXX ]]; then
CXX=g++
fi
## Begin logging in config.log
LOG_FILE=config.log
date | tee $LOG_FILE
## ===================================================================
## Setup CMake
# Automatically detect and install a sufficiently new version of
# cmake
## Install cmake
if [ `which cmake` ]; then
#test cmake version
echo "Testing existing cmake version..."
currentversion=`cmake --version | awk -F "patch" '{print $1;}' | tr -dc '[0-9].'`
echo "Detected $currentversion . Required 3.2.3"
check_version $currentversion "3.2.3"
if [ $? -ne 2 ]; then
echo "CMake version is good"
CMAKE="cmake"
fi
fi
# CMake not found and there is a cmake in the deps directory!
if [ -z $CMAKE ] && [ -f $DEPS_PREFIX/bin/cmake ]; then
#test cmake version
echo "Testing existing cmake version..."
currentversion=`$DEPS_PREFIX/bin/cmake --version | awk -F "patch" '{print $1;}' | tr -dc '[0-9].'`
echo "Detected ${currentversion}. Required 3.2.3"
check_version $currentversion "3.2.3"
if [ $? -ne 2 ]; then
echo "CMake version is good"
CMAKE=$DEPS_PREFIX/bin/cmake
fi
fi
if [ -z $CMAKE ]; then
echo "This script will now proceed to download CMake and set it up in"
echo "the local clipper/deps directory. The Clipper compilation "
echo "process will be directed to use graphlab/deps/cmake."
pushd .
mkdir deps
cd deps
cmakedownload="https://cmake.org/files/v3.6/cmake-3.6.3.tar.gz"
if [ -z "$cmakedownload" ] ; then
echo "Unable to locate CMake package. You will have to install it yourself."
exit 1
fi
rm -f cmake.tar.gz
set -e
download_file $cmakedownload cmake.tar.gz
tar -xzvf cmake.tar.gz
# cd into the extracted directory and install
cd cmake-*
./configure --prefix=$DEPS_PREFIX
make -j2
make install
set +e
popd
CMAKE=$DEPS_PREFIX/bin/cmake
fi
mkdir -p deps/local/lib
echo "======================= BUILD CONFIGURATION ========================"
echo "System Information: " | tee -a $LOG_FILE
uname -v | tee -a $LOG_FILE
echo "Compiler Information: " | tee -a $LOG_FILE
$CC --version | tee -a $LOG_FILE
$CXX --version | tee -a $LOG_FILE
$CMAKE --version | tee -a $LOG_FILE
echo "======================= Config File ================================"
# cat configure.deps | tee -a $LOG_FILE
### Add addition config flags =================================================
# CFLAGS="$CFLAGS -D NO_TCMALLOC:BOOL=$NO_TCMALLOC"
# CFLAGS="$CFLAGS -D CMAKE_INSTALL_PREFIX:STRING=$INSTALL_DIR"
## ============================================================================
# Run Cmake
set -e
# set -u
set -o pipefail
if [ $release ];
then
echo -e "\n\n\n======================= Release ========================" \
| tee -a $LOG_FILE
if [ ! -d $RELEASE_DIR ]; then
mkdir $RELEASE_DIR
fi
cd $RELEASE_DIR
rm -f CMakeCache.txt
build_cmd="$CMAKE \
$GENERATOR \
-D CMAKE_BUILD_TYPE=Release \
$CFLAGS \
../"
echo $build_cmd | tee -a "../$LOG_FILE"
eval $build_cmd | tee -a "../$LOG_FILE"
cd $CLIPPER_HOME
else
echo -e "\n\n\n======================= Debug =========================" \
| tee -a $LOG_FILE
if [ ! -d $DEBUG_DIR ]; then
mkdir $DEBUG_DIR
fi
cd $DEBUG_DIR
rm -f CMakeCache.txt
build_cmd="$CMAKE \
$GENERATOR \
-D CMAKE_BUILD_TYPE=Debug \
$CFLAGS \
../"
echo $build_cmd | tee -a ../$LOG_FILE
eval $build_cmd | tee -a ../$LOG_FILE
cd $CLIPPER_HOME
fi
# vim:filetype=sh