-
Notifications
You must be signed in to change notification settings - Fork 101
/
configure
executable file
·496 lines (426 loc) · 13.1 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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
#!/bin/bash
##=============================================================================
## 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] [--experimental]"
echo
echo " --cleanup remove all build directories"
echo
echo " --prefix=[PREFIX] GraphLab Installation target directory. Defaults to /usr/local"
echo
echo " --ide=[Xcode] Specify the ide to use when building GraphLab."
echo
echo " --no_openmp Disables OpenMP. Disabled by default on Mac."
echo
echo " --no_mpi Disables MPI (disables distributed execution)."
echo
echo " --no_jvm Disable JVM features including HDFS integration."
echo
echo " --experimental Turns on undocumented experimental capabilities. "
echo
echo " --noc++11 Turns off C++11"
echo
echo " --distribution Compiles for public distribution"
echo
echo " --vid32 Switch to 32bit vertex ids."
echo
echo " --mac_gcc49 Forces GCC 4.9 on Mac. Builtin Clang otherwise"
echo
echo " -D var=value Specify definitions to be passed on to cmake."
exit 1
} # end of print help
function run_cleanup {
#!/bin/bash
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 configure.deps
else
echo "Doing nothing!";
fi
exit 1
} # 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
}
##=============================================================================
## Main configuration processing
## Define some defaults which are modified by the script and whatever
## is defined in configure.deps
RELEASE_DIR=release
DEBUG_DIR=debug
INSTALL_DIR=/usr/local
EXPERIMENTAL=false
GRAPHLAB_HOME=$PWD
DEPS_PREFIX=$PWD/deps/local
NO_OPENMP=false
NOCPP11=false
NO_MPI=false
CPP11=false
VID32=false
DISTRIBUTION=false
CFLAGS=""
## The defaults can be overwritten be editing the configure.deps file
if [ -f configure.deps ]; then
# 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 ;;
--no_openmp) no_openmp=1 ;;
--no_mpi) no_mpi=1 ;;
--no_jvm) no_jvm=1 ;;
--experimental) experimental=1 ;;
--noc++11) nocpp11=1 ;;
--distribution) distribution=1 ;;
--vid32) vid32=1 ;;
--mac_gcc49) mac_gcc49=1 ;;
--mac_clang) mac_clang=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 ]; then
run_cleanup
fi
# Extra generator setting (passed in as an argument)
if [[ -n $ide ]]; then
GENERATOR="-G $ide"
fi
if [ $no_openmp ]; then
NO_OPENMP=true
fi
if [ $no_mpi ]; then
NO_MPI=true
fi
if [ $experimental ]; then
EXPERIMENTAL=true
fi
if [ $nocpp11 ]; then
NOCPP11=true
fi
if [ $distribution ]; then
DISTRIBUTION=true
fi
if [ $vid32 ]; then
VID32=true
fi
if [[ -n $prefix ]]; then
INSTALL_DIR=$prefix
fi
if [ $mac_gcc49 ] && [ $mac_clang ]; then
echo "mac_gcc49 and mac_clang cannot both be specified"
exit 1
fi
# mac compiler detection
if [[ $OSTYPE == darwin* ]]; then
if [ -z $mac_gcc49 ] && [ -z $mac_clang ]; then
echo "Autodetecting compiler"
if [ `which gcc-4.9` ]; then
echo "GCC detected"
mac_gcc49=1
else
echo "Clang detected"
mac_clang=1
fi
fi
# Compiler Detection
if [ $mac_gcc49 ]; then
CC=gcc-4.9
CXX=g++-4.9
elif [ $mac_clang ] ; then
CC=clang
CXX=clang++
NO_OPENMP=true
fi
fi
# all other cases
# 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
# Test java
if [[ -z $JAVAC ]]; then
JAVAC=javac
fi
if ! $JAVAC -version >> /dev/null; then
JAVAC=""
fi
if [[ -n $no_jvm ]]; then
echo "JVM disabled"
JAVAC=""
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 2.8.3"
check_version $currentversion "2.8.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 2.8.3"
check_version $currentversion "2.8.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 $GRAPHLAB_HOME/deps directory. The GraphLab compilation "
echo "process will be directed to use $GRAPHLAB_HOME/deps/cmake."
pushd .
mkdir deps
cd deps
# get the cmake software page
rm -f software.html
download_file "http://www.cmake.org/cmake/resources/software.html" software.html
# look for the first tar.gz I can download
cmakedownload=`grep -m 1 -o -e "href=\"http://www\\.cmake.*\\.tar\\.gz\"" software.html | grep -o -e "http.*\\.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
echo "CMAKE=$CMAKE" >> configure.deps
fi
## ============================================================================
# Set up node.js and JS build dependencies
if [ -f $DEPS_PREFIX/bin/node ]; then
#test nodejs version
echo "Testing existing node version..."
currentversion=`$DEPS_PREFIX/bin/node --version | awk -F "patch" '{print $1;}' | tr -dc '[0-9].'`
echo "Detected ${currentversion}. Required 0.10.28"
check_version $currentversion "0.10.28"
if [ $? -ne 2 ]; then
echo "Node.js version is good"
NODEJS=$DEPS_PREFIX/bin/node
NPM=$DEPS_PREFIX/bin/npm
fi
fi
if [ -z $NODEJS ]; then
echo "This script will now proceed to download Node.js and install in deps."
pushd .
mkdir deps
cd deps
# get the nodejs git repo
download_file "http://nodejs.org/dist/v0.10.28/node-v0.10.28.tar.gz" node-v0.10.28.tar.gz
tar -xzvf node-v0.10.28.tar.gz
cd node-v0.10.28
./configure --prefix=$DEPS_PREFIX
make -j2
make install
popd
NODEJS=$DEPS_PREFIX/bin/node
NPM=$DEPS_PREFIX/bin/npm
echo "NODEJS=$NODEJS" >> configure.deps
echo "NPM=$NPM" >> configure.deps
fi
if [ -f $DEPS_PREFIX/bin/jsx ]; then
#test jsx version
echo "Testing existing node version..."
currentversion=`$NODEJS $DEPS_PREFIX/bin/jsx --version | awk -F "patch" '{print $1;}' | tr -dc '[0-9].'`
echo "Detected ${currentversion}. Required 0.11.1"
check_version $currentversion "0.11.1"
if [ $? -ne 2 ]; then
echo "JSX version is good"
JSX_COMPILER="${DEPS_PREFIX}/bin/jsx"
fi
fi
if [ -z $JSX_COMPILER ]; then
echo "This script will now proceed to download react-tools and install in deps."
# install react-tools (jsx compiler)
$NPM install -g [email protected]
JSX_COMPILER="${DEPS_PREFIX}/bin/jsx"
echo "JSX_COMPILER=$JSX_COMPILER" >> configure.deps
fi
## ============================================================================
# Regenerate the configure.deps
echo -e "# Release build directory:" >> configure.deps
echo -e "\t RELEASE_DIR=$RELEASE_DIR" >> configure.deps
echo -e "# Debug build directory (optimization disabled):" >> configure.deps
echo -e "\t DEBUG_DIR=$DEBUG_DIR" >> configure.deps
echo -e "# Directory in which graphlab is installed (prefix):" >> configure.deps
echo -e "\t INSTALL_DIR=$INSTALL_DIR" >> configure.deps
echo -e "# Is experimental (research) code enabled:" >> configure.deps
echo -e "\t EXPERIMENTAL=$EXPERIMENTAL" >> configure.deps
echo -e "# The graphlab home directory: " >> configure.deps
echo -e "\t GRAPHLAB_HOME=$GRAPHLAB_HOME" >> configure.deps
echo -e "# The directory in which graphlab installs external dependencies:" >> configure.deps
echo -e "\t DEPS_PREFIX=$DEPS_PREFIX" >> configure.deps
echo -e "# Use OpenMP? This can accelerate some graph building code: " >> configure.deps
echo -e "\t NO_OPENMP=$NO_OPENMP" >> configure.deps
echo -e "# Use MPI? Without MPI GraphLab cannot run distributed: " >> configure.deps
echo -e "\t NO_MPI=$NO_MPI" >> configure.deps
echo -e "# The c compiler to use: " >> configure.deps
echo -e "\t CC=$CC" >> configure.deps
echo -e "# The c++ compiler to use: " >> configure.deps
echo -e "\t CXX=$CXX" >> configure.deps
echo -e "# Any addition user defined CFLAGS: " >> configure.deps
echo -e "\t CFLAGS=$CFLAGS" >> configure.deps
echo -e "# The Java compiler: " >> configure.deps
echo -e "\t JAVAC=$JAVAC" >> configure.deps
echo -e "# The cmake binary used to geneate the project:" >> configure.deps
echo -e "\t CMAKE=$CMAKE" >> configure.deps
mkdir -p deps/local/lib
mkdir doc
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
if [[ -n $JAVAC ]]; then
$JAVAC -version | tee -a $LOG_FILE
fi
echo "======================= Config File ================================"
cat configure.deps | tee -a $LOG_FILE
### Add addition config flags =================================================
CFLAGS="$CFLAGS -D NO_OPENMP:BOOL=$NO_OPENMP"
CFLAGS="$CFLAGS -D NO_MPI:BOOL=$NO_MPI"
CFLAGS="$CFLAGS -D CMAKE_INSTALL_PREFIX:STRING=$INSTALL_DIR"
CFLAGS="$CFLAGS -D EXPERIMENTAL:BOOL=$EXPERIMENTAL"
CFLAGS="$CFLAGS -D NOCPP11:BOOL=$NOCPP11"
CFLAGS="$CFLAGS -D VID32:BOOL=$VID32"
CFLAGS="$CFLAGS -D DISTRIBUTION:BOOL=$DISTRIBUTION"
if [ -z $JAVAC ]; then
CFLAGS="$CFLAGS -D NO_JAVAC:BOOL=1"
fi
if [ -n $CC ] ; then
CCCMD=`which $CC`
CFLAGS="$CFLAGS -D CMAKE_C_COMPILER=$CCCMD"
fi
if [ -n $CXX ] ; then
CXXCMD=`which $CXX`
CFLAGS="$CFLAGS -D CMAKE_CXX_COMPILER=$CXXCMD"
fi
## ============================================================================
# Run Cmake
set -e
set -o pipefail
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 $GRAPHLAB_HOME
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 $GRAPHLAB_HOME