-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.sh
executable file
·308 lines (267 loc) · 7.43 KB
/
bootstrap.sh
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
#!/bin/bash
#
# Copyright 2021 Huawei Technologies Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
echo '.____ _____________________'
echo '| | \______ \_ _____/'
echo '| | | ___/| __) '
echo '| |___| | | \ '
echo '|_______ \____| \___ / '
echo ' \/ \/ '
echo
echo 'Lightweight Parallel Foundations'
echo
echo 'Copyright (c) 2016-2021 by Huawei Technologies'
echo 'All rights reserved.'
echo
echo
echo "BUILD BOOTSTRAP SCRIPT"
echo "======================"
echo
function FAIL()
{
echo
echo "FATAL ERROR"
echo "======================"
echo
echo $1
echo
echo "Bootstrap.sh aborted."
exit 1
}
function abs_path()
{
dir="$1"
if [ ! -d "$dir" ]; then
readlink -f -m "$dir" || echo $dir
else
pushd $dir > /dev/null
pwd
popd > /dev/null
fi
}
function print_configuration()
{
echo "Configuration Options ${config_name:+for configuration named '${config_name}'}"
echo "------------------------------------------------------"
echo
echo " - Build directory = $builddir"
echo
echo " - Installation directory = $installdir"
echo
echo " - Build configuration = $config"
echo
echo " - Build documentation = $doc"
echo
echo " - Functional Tests = $functests"
echo
echo " - Performance Tests = $perftests"
echo
}
srcdir=`dirname $0`
srcdir=`abs_path $srcdir`
# Take the current directory as build directory
builddir=`pwd`
# Parse command line parameters
installdir="$builddir"
config=Release
doc=OFF
functests=OFF
googletest_license_agreement=FALSE
perftests=OFF
reconfig=no
CMAKE_EXE=cmake
unset mpicxx
unset mpicc
unset mpi_cmake_flags
unset mpiexec
unset extra_flags
unset perf_flags
unset hwloc
unset hwloc_found_flag
for arg
do
case $arg in
--prefix=*)
installdir=`abs_path ${arg#--prefix=}`
shift
;;
--debug)
config=Debug
shift
;;
--debug2)
config=Debug
extra_flags='-DCMAKE_CXX_FLAGS_DEBUG=-g -O0 -D_GLIBCXX_DEBUG=1'
shift
;;
--release)
config=Release
shift
;;
--functests)
functests=ON
cat <<EOF
==============================================================================
*** Use of third party software: Google Testing Framework ***
------------------------------------------------------------------------------
The functional test suite requires Google Testing Framework which comes with
its own license. The license can be viewed via
https://github.com/google/googletest/blob/v1.15.x/LICENSE
Do you agree with the license [yes/no] ?
EOF
read answer
if [ x$answer != xyes ]; then
cat <<EOF
------------------------------------------------------------------------------
The answer was is '$answer'. For agreement, please type 'yes'.
Agreement with Google Testing Framework license is necessary for the
functioning of the test suite. Please do not use the --functests parameter.
==============================================================================
EOF
exit 1
else
cat <<EOF
------------------------------------------------------------------------------
User agrees with Google Testing Framework license. It will be downloaded during
the build.
==============================================================================
EOF
googletest_license_agreement=TRUE
fi
shift
;;
--functests=i-agree-with-googletest-license)
functests=ON
googletest_license_agreement=TRUE
shift
;;
--perftests)
perftests=ON
shift
;;
--perftests=*)
perftests=ON
list=${arg#--perftests=}
perf_flags="-DLPFLIB_PERFTESTS_PROCLIST=${list//,/;}"
shift
;;
--with-mpicxx=*)
mpicxx="${arg#--with-mpicxx=}"
mpi_cmake_flags="${mpi_cmake_flags} -DMPI_CXX_COMPILER=$mpicxx"
shift
;;
--with-mpicc=*)
mpicc="${arg#--with-mpicc=}"
mpi_cmake_flags="${mpi_cmake_flags} -DMPI_C_COMPILER=$mpicc"
shift
;;
--with-mpiexec=*)
mpiexec="${arg#--with-mpiexec=}"
mpi_cmake_flags="${mpi_cmake_flags} -DMPIEXEC=$mpiexec -DMPIEXEC_EXECUTABLE=$mpiexec"
shift;
;;
--without-hwloc)
hwloc_found_flag="-DHWLOC_FOUND=NO"
hwloc=NO
shift
;;
--with-hwloc=*)
hwloc="${arg#--with-hwloc=}"
unset hwloc_found_flag
shift
;;
--with-cmake=*)
CMAKE_EXE="${arg#--with-cmake=}"
shift;
;;
--config-name=*)
config_name="${arg#--config-name=}"
shift
;;
--enable-doc)
doc=ON
shift
;;
--disable-doc)
doc=OFF
shift
;;
--reconfig)
reconfig=yes
shift
;;
--help)
less $srcdir/README
exit 0
;;
--*)
echo "Unrecognized option '$arg'"
exit 1
;;
*) break
;;
esac
done
# Options sanity check
if [ x$functests != xON ]; then
if [ x$perftests == xON ]; then
echo "Option error: setting --perftests also requires setting --functests."
exit 1
fi
fi
if ! command -v ${CMAKE_EXE} &> /dev/null
then
echo "Cannot find cmake (tried \"${CMAKE_EXE}\")."
exit 1
fi
echo
echo
# Configure LPF
if [ $reconfig = no -a -f CMakeCache.txt ]; then
echo "Regenerating LPF build (consider using --reconfig)"
elif [ $reconfig = yes -a -f CMakeCache.txt ]; then
rm -r CMakeCache.txt CMakeFiles
echo "Reconfiguring LPF build"
else
echo "Configuring LPF build"
fi
echo "--------------------------------------------------"
echo
${CMAKE_EXE} -Wno-dev \
-DCMAKE_INSTALL_PREFIX="$installdir" \
-DCMAKE_BUILD_TYPE=$config \
-DLPFLIB_MAKE_DOC=$doc \
-DLPFLIB_MAKE_TEST_DOC=$doc \
-DLPF_ENABLE_TESTS=$functests \
-DGTEST_AGREE_TO_LICENSE=$googletest_license_agreement \
-DLPFLIB_PERFTESTS=$perftests \
-DLPFLIB_CONFIG_NAME=${config_name:-${config}}\
-DLPF_HWLOC="${hwloc}" \
$hwloc_found_flag \
$mpi_cmake_flags \
${extra_flags+"$extra_flags"} \
${perf_flags+"$perf_flags"} \
"$@" $srcdir \
|| { echo FAIL "Failed to configure LPF; Please check your chosen configuration"; exit 1; }
echo
echo
echo "DONE"
echo
print_configuration
echo "--- Note:"
echo "To build this project run 'make', to install 'make install'. If you are"
echo "the lucky owner of a multi-core processor, consider using the '-j' option"
echo "of make."