forked from jegonzal/PowerGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·437 lines (369 loc) · 12.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
#!/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 " --no_tcmalloc Disable using tcmalloc instead of malloc."
echo
echo " --experimental Turns on undocumented experimental capabilities. "
echo
echo " --c++11 Turns on C++11 experimental features. "
echo
echo " --vid32 Switch to 32bit vertex ids."
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
## this function is broken
# function check_version {
# local version=$1 check=$2
# local winner=$(echo -e "$version\n$check" | sed '/^$/d' | sort -nr | head -1)
# [[ "$winner" = "$version" ]] && return 0
# return 1
# } # end of check version
## 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
NO_MPI=false
NO_TCMALLOC=false
CPP11=false
VID32=false
CFLAGS=""
# if mac detected, force no_openmp flags by default
if [[ $OSTYPE == darwin* ]]; then
NO_OPENMP=true
fi
## 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 ;;
--no_openmp) no_openmp=1 ;;
--no_mpi) no_mpi=1 ;;
--no_tcmalloc) no_tcmalloc=1 ;;
--no_jvm) no_jvm=1 ;;
--experimental) experimental=1 ;;
--c++11) cpp11=1 ;;
--vid32) vid32=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 [ $no_tcmalloc ]; then
NO_TCMALLOC=true
fi
if [ $experimental ]; then
EXPERIMENTAL=true
fi
if [ $cpp11 ]; then
CPP11=true
fi
if [ $vid32 ]; then
VID32=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
# Test java
if [[ -z $JAVAC ]]; then
JAVAC=javac
fi
# set -e
# set -o pipefail
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 local graphlab/deps directory. The GraphLab compilation "
echo "process will be directed to use graphlab/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
## ============================================================================
# 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 "# Use tcmalloc? Thread-Caching Malloc improves memory allocation: " >> configure.deps
echo -e "\t NO_TCMALLOC=$NO_TCMALLOC" >> 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
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 NO_TCMALLOC:BOOL=$NO_TCMALLOC"
CFLAGS="$CFLAGS -D CMAKE_INSTALL_PREFIX:STRING=$INSTALL_DIR"
CFLAGS="$CFLAGS -D EXPERIMENTAL:BOOL=$EXPERIMENTAL"
CFLAGS="$CFLAGS -D CPP11:BOOL=$CPP11"
CFLAGS="$CFLAGS -D VID32:BOOL=$VID32"
if [ -z $JAVAC ]; then
CFLAGS="$CFLAGS -D NO_JAVAC:BOOL=1"
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
echo "*****************************************************"
echo "* Important Note *"
echo "* -------------- *"
echo "* You do not have to build everything! *"
echo "* *"
echo "* Everything takes a very long time, and a ton of *"
echo "* of memory to build. You can just cd into toolkit *"
echo "* directory you want, and just build that. For *"
echo "* instance, if I just want the release build of *"
echo "* PageRank, I could: *"
echo "* *"
echo "* cd release/toolkits/graph_analytics *"
echo "* make -j2 *"
echo "* *"
echo "* Use at most [RAM in GB] parallel builds. The *"
echo "* compilation consumes a lot of RAM. i.e. if you *"
echo "* 4 GB of RAM, do not do more than make -j4 *"
echo "*****************************************************"