-
Notifications
You must be signed in to change notification settings - Fork 326
/
configure
executable file
·377 lines (332 loc) · 11.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
#!/bin/bash
##=============================================================================
## Main configuration processing
set -e
RELEASE_DIR=release
DEBUG_DIR=debug
GRAPHLAB_HOME=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
DEPS_PREFIX=$PWD/deps/local
if [[ $OSTYPE == linux* ]]; then
DEFAULT_DATO_DEPS_VERSION=13
elif [[ $OSTYPE == darwin* ]]; then
DEFAULT_DATO_DEPS_VERSION=12
elif [[ $OSTYPE == msys ]]; then
DEFAULT_DATO_DEPS_VERSION=12
fi
## Support code
function download_file {
# detect wget
echo "Downloading $2 from $1 ..."
# if it is a file
if [ -e $1 ] ; then
cp $1 $2
return
fi
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 "Configures the build with the specified toolchain. "
echo
echo "If configure has already been run before, running configure "
echo "will simply reconfigures the build with no changes. "
echo "To rebuild with a new toolchain, it is recommended to clean everything"
echo " (--cleanup) and run configure again"
echo
echo "Usage: ./configure --toolchain=[toolchain] [remaining options]"
echo
echo " --cleanup cleanups everything"
echo
echo " --cleanup_if_invalid cleanups everything if toolchain version is different"
echo
echo " --yes Defaults to yes on a prompt"
echo
echo " --cmake_only Only run cmake without obtaining a new toolchain."
echo
echo " --python_only Only run python dependency installation."
echo
echo " --python3 Use Python 3.4, default is Python 2.7."
echo
echo " --python3.5 Use Python 3.5, default is Python 2.7."
echo
echo " --toolchain=[toolchain] Toolchain is either a dato-deps file on disk, "
echo " or a URL to a toolchain. If toolchain is"
echo " \"default\", a default one is selected"
echo
echo " --cuda Selects a Cuda toolchain if available"
echo
echo " --no_cuda Selects a Cuda-less toolchain if available (default)"
echo
echo " -D var=value Specify CFLAGS definitions to be passed on to cmake."
echo
echo " --R_integration This feature is currently in beta and only works on Linux."
echo
echo "Configure with either default toolchain, or an existing toolchain if there is one."
echo "Example: ./configure"
echo
echo "Cleanup all build directories"
echo "Example: ./configure --cleanup"
echo
echo "Download the default toolchain, and configure with it"
echo "Example: ./configure --toolchain=default"
echo
echo "Configure with a toolchain you have already downloaded"
echo "Example: ./configure --toolchain=dato_deps_linux_gcc_4.9.2.tar.gz"
echo
echo "Configure with a toolchain you download from the internet."
echo "Example: ./configure --toolchain=https://s3-us-west-2.amazonaws.com/dato-deps/1/dato_deps_linux_gcc_4.9.2.tar.gz"
echo
echo "All remaining options will be forwarded to cmake."
exit 1
} # end of print help
function unknown_option {
echo "Unrecognized option: $1"
echo "To get help, run ./configure --help"
exit 1
} # end of unknown option
function run_cleanup {
#!/bin/bash
echo "cleaning up";
rm -rf release debug deps cmake patches description.json deps_version dummy.cpp miniconda.sh
rm -f *.tar.gz
}
function run_cleanup_prompt {
#!/bin/bash
echo "This script completely erases all build folders including dependencies!"
if [[ $default_yes == 1 ]]; then
yesorno="yes"
else
echo "Are you sure you want to continue? (yes or no)"
read yesorno;
fi
if [ "$yesorno" == "yes" ]; then
run_cleanup
else
echo "Doing nothing!";
fi
}
# check for existing toolchain
# we do so by checking for the existance of the compiler in deps/local/bin/cc
has_existing_toolchain=0
if [ -e deps/local/bin/cc ]; then
has_existing_toolchain=1
fi
if [[ $python35 == 1 && $python3 ]]; then
echo "Two versions of Python specified. Pick one."
exit 1
fi
dependency_bad_version=0
if [ -e deps_version ]; then
cur_version=`cat deps_version`
if [[ $cur_version < $DEFAULT_DATO_DEPS_VERSION ]]; then
echo "Your dependency toolchain is out of date. "
echo "Run ./configure --cleanup to get a new dependency version."
dependency_bad_version=1
fi
else
echo "Your dependency toolchain is either using a custom version, or is out of date. "
echo "Run ./configure --cleanup to get a new dependency version."
dependency_bad_version=1
fi
# the three stages
run_toolchain_install=1
run_python_install=1
run_cmake_configure=1
# command flag options
cmake_only=0
python_only=0
cleanup_option=0
cleanup_if_invalid_option=0
toolchain=""
default_yes=0
no_cuda=1
# Parse command line configure flags ------------------------------------------
while [ $# -gt 0 ]
do case $1 in
--toolchain=*) toolchain=${1##--toolchain=} ;;
--cuda) no_cuda=0;;
--no_cuda) no_cuda=1;;
--cleanup) cleanup_option=1;;
--cleanup_if_invalid) cleanup_if_invalid_option=1;;
--yes) default_yes=1;;
--cmake_only) cmake_only=1;;
--python_only) python_only=1;;
--python3) python3=1;;
--python3.5) python35=1;;
--R_integration) R_integration=1;;
--help) print_help ;;
-D) CFLAGS="$CFLAGS -D $2"; shift ;;
*) unknown_option $1 ;;
esac
shift
done
if [[ $cleanup_option == 1 ]]; then
run_cleanup_prompt
exit 1
fi
if [[ $cleanup_if_invalid_option == 1 ]]; then
if [[ $dependency_bad_version == 1 ]]; then
default_yes=1
run_cleanup_prompt
has_existing_toolchain=0
fi
fi
if [[ $has_existing_toolchain == 1 && $toolchain == "" ]]; then
echo
echo "Existing toolchain detected, using existing toolchain to configure."
echo
run_toolchain_install=0
fi
if [[ $cmake_only == 1 ]]; then
run_toolchain_install=0
run_python_install=0
run_cmake_configure=1
fi
if [[ $python_only == 1 ]]; then
run_toolchain_install=0
run_python_install=1
run_cmake_configure=0
fi
if [[ $python3 == 1 ]]; then
CFLAGS="$CFLAGS -D PYTHON_VERSION=\"python3.4m\""
PYTHON_VERSION="python3.4m"
elif [[ $python35 == 1 ]]; then
CFLAGS="$CFLAGS -D PYTHON_VERSION=\"python3.5m\""
PYTHON_VERSION="python3.5m"
else
CFLAGS="$CFLAGS -D PYTHON_VERSION=\"python2.7\""
PYTHON_VERSION="python2.7"
fi
if [[ $run_toolchain_install == 1 ]]; then
run_cleanup
cd ${GRAPHLAB_HOME}
PYTHON_VERSION=${PYTHON_VERSION} ./oss_local_scripts/install_python_toolchain.sh
REMAINING_OPTIONS=$@
if [[ $toolchain == default || $toolchain == "" ]]; then
if [[ $OSTYPE == darwin* ]]; then
toolchain="http://s3-us-west-2.amazonaws.com/dato-deps/$DEFAULT_DATO_DEPS_VERSION/dato_deps_mac_default.tar.gz"
elif [[ $OSTYPE == linux* ]]; then
if [[ $no_cuda == 1 ]]; then
toolchain="http://s3-us-west-2.amazonaws.com/dato-deps/$DEFAULT_DATO_DEPS_VERSION/dato_deps_linux_no_cuda.tar.gz"
else
toolchain="http://s3-us-west-2.amazonaws.com/dato-deps/$DEFAULT_DATO_DEPS_VERSION/dato_deps_linux_default.tar.gz"
fi
elif [[ $OSTYPE == msys ]]; then
toolchain="http://s3-us-west-2.amazonaws.com/dato-deps/$DEFAULT_DATO_DEPS_VERSION/dato_deps_win_default.tar.gz"
else
echo "Unknown toolchain for the operating system"
exit 1
fi
echo $DEFAULT_DATO_DEPS_VERSION > deps_version
fi
filename=`basename $toolchain`
if [[ ! -e $filename ]]; then
download_file $toolchain $filename
tar -xzvf $filename
else
tar -xzvf $filename
fi
fi
if [[ $R_integration == 1 ]]; then
./oss_local_scripts/install_r_toolchain.sh
CFLAGS="$CFLAGS -D R_INTEGRATION:BOOL=\"TRUE\""
else
CFLAGS="$CFLAGS -D R_INTEGRATION:BOOL=\"FALSE\""
fi
if [[ $run_cmake_configure == 0 ]]; then
exit
fi
CC=$PWD/deps/local/bin/cc
CXX=$PWD/deps/local/bin/c++
if [[ $OSTYPE == msys ]]; then
CC=gcc.exe
CXX=g++.exe
fi
CMAKE=$PWD/deps/local/bin/cmake
LINKER=""
if [ -e $PWD/deps/local/bin/ld.gold ]; then
LINKER="-DCMAKE_LINKER=$PWD/deps/local/bin/ld.gold"
elif [ -e $PWD/deps/local/bin/ld ]; then
LINKER="-DCMAKE_LINKER=$PWD/deps/local/bin/ld"
fi
mkdir -p doc
# export LD_LIBRARY_PATH=${PWD}/deps/local/lib:${PWD}/deps/local/lib64:$PWD
echo "======================= BUILD CONFIGURATION ========================"
echo "System Information: "
uname -v
echo "Compiler Information: "
$CC --version
$CXX --version
$CMAKE --version
echo "======================= Config File ================================"
### Add addition config flags =================================================
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
CFLAGS="$CFLAGS $LINKER"
if [[ $OSTYPE == msys ]]; then
CFLAGS="$CFLAGS -G \"MSYS Makefiles\""
AR=`which ar`
AR=`cygpath -m $AR`
CFLAGS="$CFLAGS -D CMAKE_AR=$AR"
# a bunch of stuff needed for python
if [[ $python35 == 1 ]]; then
CFLAGS="$CFLAGS -D PYTHON_LIBRARY:FILEPATH=$PWD/deps/local/lib/python35.dll"
elif [[ $python3 == 1 ]]; then
CFLAGS="$CFLAGS -D PYTHON_LIBRARY:FILEPATH=$PWD/deps/local/lib/python34.dll"
else
CFLAGS="$CFLAGS -D PYTHON_LIBRARY:FILEPATH=$PWD/deps/local/lib/python27.dll"
fi
CFLAGS="$CFLAGS -D PYTHON_EXECUTABLE:FILEPATH=$PWD/deps/conda/bin/python"
export PATH=$PATH:/mingw64/bin
fi
## ============================================================================
# Run Cmake
set -e
set -o pipefail
# Delete the cython make files. If cython files get removed,
# CMake has a tendency to leave the build files around.
# So we just delete them and reconfigure should take care of it.
rm -rf ${RELEASE_DIR}/oss_src/unity/python/sframe/cython
rm -rf ${DEBUG_DIR}/oss_src/unity/python/sframe/cython
echo -e "\n\n\n======================= Release ========================" \
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
eval $build_cmd
cd $GRAPHLAB_HOME
echo -e "\n\n\n======================= Debug =========================" \
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
eval $build_cmd
cd $GRAPHLAB_HOME