forked from niedoida/niedoida
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_external_packages
executable file
·309 lines (263 loc) · 9.05 KB
/
build_external_packages
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
#!/usr/bin/env bash
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
export CMAKE_RELEASE=3.21
export CMAKE_VERSION=$CMAKE_RELEASE.6
export CMAKE=cmake-$CMAKE_VERSION
export BOOST_VERSION=1.68.0
export BOOST=boost_1_68_0
export MPICH_VERSION=3.4.2
export MPI=mpich-$MPICH_VERSION
export HYDRA=hydra-$MPICH_VERSION
export OPENBLAS_VERSION=0.3.10
export OPENBLAS=OpenBLAS-$OPENBLAS_VERSION
export ARMADILLO=armadillo-10.1.2
export PETSC=petsc-3.14.2
export YAML_CPP=yaml-cpp-0.6.2
export HDF_RELEASE=1.10
export HDF_VERSION=$HDF_RELEASE.1
export HDF=hdf5-$HDF_VERSION
export YACAS_VERSION=1.8.0
export YACAS=yacas-$YACAS_VERSION
cd external_packages
if [ $? != 0 ]; then
echo 'External packages directory not found' >&2
exit 1
fi
set -e
export EP_PATH=`pwd`
export PATH=$EP_PATH/bin:$PATH
jobs=1
force_build=0
SHORT=fj:
LONG=force,jobs:
# -temporarily store output to be able to check for errors
# -activate advanced mode getopt quoting e.g. via "--options"
# -pass arguments only via -- "$@" to separate them correctly
PARSED=`getopt --options $SHORT --longoptions $LONG --name "$0" -- "$@"`
if [[ $? != 0 ]]; then
# e.g. $? == 1
# then getopt has complained about wrong arguments to stdout
exit 2
fi
# use eval with "$PARSED" to properly handle the quoting
eval set -- "$PARSED"
# now enjoy the options in order and nicely split until we see --
while true; do
case "$1" in
-f|--force)
force_build=1
shift 1
;;
-j|--jobs)
jobs="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Programming error"
exit 3
;;
esac
done
# checking if build is necessary
if [ $force_build -ne 1 ]; then
build_necessary=1
if [ -s checksums.md5 ]; then
build_necessary=0
md5sum *.tar.gz *.tar.bz2 *.tar.xz 2>/dev/null > checksums_cur.md5
diff checksums.md5 checksums_cur.md5 > checksum_diff.md5
fi
if [ -s checksum_diff.md5 ]; then
build_necessary=1
fi
if [ $build_necessary -eq 0 ]; then
exit 0
fi
fi
if [ ! -d bin ]; then
mkdir bin
fi
rm -f -r bin/*
rm -f -r include/*
rm -f -r etc/*
rm -f -r lib/*
rm -f -r share/*
rm -f -r man/*
if [ ! -d bin ]; then
mkdir bin
fi
if [ ! -d lib ]; then
mkdir lib
fi
if [ ! -d include ]; then
mkdir include
fi
if [ ! -f $CMAKE-*.tar.gz ]; then
if [[ "$OSTYPE" == "linux-gnu" ]]; then
wget -o- https://cmake.org/files/v$CMAKE_RELEASE/$CMAKE-linux-x86_64.tar.gz
elif [[ "$OSTYPE" == "darwin"* ]]; then
wget -o- https://cmake.org/files/v$CMAKE_RELEASE/$CMAKE-macos-x86_64.tar.gz
fi
fi
if [ ! -f $MPI.tar.gz ]; then
wget -o- http://www.mpich.org/static/downloads/$MPICH_VERSION/$MPI.tar.gz
fi
if [ ! -f $HYDRA.tar.gz ]; then
wget -o- http://www.mpich.org/static/downloads/$MPICH_VERSION/$HYDRA.tar.gz
fi
if [ ! -f $BOOST.tar.gz ]; then
wget -o- http://downloads.sourceforge.net/project/boost/boost/$BOOST_VERSION/$BOOST.tar.gz
fi
if [[ "$OSTYPE" == "linux-gnu" ]]; then
if [ ! -f $OPENBLAS.tar.gz ]; then
wget -o- http://github.com/xianyi/OpenBLAS/archive/v$OPENBLAS_VERSION.tar.gz
mv v$OPENBLAS_VERSION.tar.gz $OPENBLAS.tar.gz
fi
fi
if [ ! -f $ARMADILLO.tar.xz ]; then
wget -o- https://downloads.sourceforge.net/project/arma/$ARMADILLO.tar.xz
fi
if [ ! -f $PETSC.tar.gz ]; then
wget -o- http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/$PETSC.tar.gz
fi
if [ ! -f $YAML_CPP.tar.gz ]; then
wget -o- https://github.com/jbeder/yaml-cpp/archive/$YAML_CPP.tar.gz
fi
if [ ! -f $HDF.tar.gz ]; then
wget --no-check-certificate -o- http://support.hdfgroup.org/ftp/HDF5/releases/hdf5-$HDF_RELEASE/$HDF/src/$HDF.tar.gz
fi
if [ ! -f $YACAS.tar.gz ]; then
wget -o- https://github.com/grzegorzmazur/yacas/archive/v$YACAS_VERSION.tar.gz
mv v$YACAS_VERSION.tar.gz $YACAS.tar.gz
fi
# install pre-compiled cmake
if [[ "$OSTYPE" == "linux-gnu" ]]; then
tar xzf $CMAKE-linux-x86_64.tar.gz --strip-components=1
elif [[ "$OSTYPE" == "darwin"* ]]; then
tar xzf $CMAKE-macos-x86_64.tar.gz --strip-components=3
fi
# build MPICH2
rm -rf $MPI
tar xzf $MPI.tar.gz
cd $MPI
if [[ "$OSTYPE" == "linux-gnu" ]]; then
./configure --prefix=$EP_PATH --with-device=ch4:ofi --enable-fast=all --disable-shared --enable-fortran=yes --enable-cxx=yes --enable-romio --enable-threads=multiple CFLAGS=-fPIC CXXFLAGS=-fPIC FFLAGS="-fPIC" FCFLAGS="-fPIC" FFLAGS=-fallow-argument-mismatch
elif [[ "$OSTYPE" == "darwin"* ]]; then
CC=/usr/bin/cc CXX=/usr/bin/c++ ./configure --prefix=$EP_PATH --with-device=ch4:ofi --enable-fast=all --disable-shared --enable-fortran=no --enable-cxx=yes --enable-romio --enable-threads=multiple CFLAGS=-fPIC CXXFLAGS=-fPIC
fi
make -j $jobs
make install
cd $EP_PATH
rm -rf $MPI
rm -rf $HYDRA
tar xzf $HYDRA.tar.gz
cd $HYDRA
./configure --prefix=$EP_PATH
make -j $jobs
make install
cd $EP_PATH
rm -rf $HYDRA
# unpack boost
rm -rf $BOOST
tar xzf $BOOST.tar.gz
cd $BOOST
./bootstrap.sh
mkdir -p tools/build/v2
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "
using mpi : : <include>$EP_PATH/include
<library-path>$EP_PATH/lib
<find-static-library>mpi ;
" > tools/build/src/user-config.jam
./b2 --prefix=$EP_PATH -j $jobs --layout=system toolset=gcc link=static cxxflags=-fPIC --with-program_options --with-filesystem --with-thread --with-serialization --with-mpi --with-test --with-math --with-timer --with-regex install
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "
using mpi : : <include>$EP_PATH/include
<library-path>$EP_PATH/lib
<find-static-library>mpi
<find-static-library>pmpi ;
" > tools/build/src/user-config.jam
./b2 --prefix=$EP_PATH -j $jobs --layout=system toolset=clang link=static cxxflags=-fPIC --with-program_options --with-filesystem --with-thread --with-serialization --with-mpi --with-test --with-math --with-timer --with-regex install
fi
cd $EP_PATH
rm -rf $BOOST
if [[ "$OSTYPE" == "linux-gnu" ]]; then
rm -rf $OPENBLAS
tar xf $OPENBLAS.tar.gz
cd $OPENBLAS
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$EP_PATH -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=Off -DDYNAMIC_ARCH=On -DUSE_THREAD=Off ..
make -j $jobs all
make install
cd $EP_PATH
rm -rf $OPENBLAS
fi
rm -rf $ARMADILLO
tar xf $ARMADILLO.tar.xz
cd $ARMADILLO
if [[ "$OSTYPE" == "linux-gnu" ]]; then
patch < ../$ARMADILLO.patch
fi
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$EP_PATH -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_PREFIX_PATH:PATH=$EP_PATH -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:BOOL=OFF ..
make -j $jobs all
make install
cd $EP_PATH
rm -rf $ARMADILLO
# build PETSc
rm -rf $PETSC
tar xzf $PETSC.tar.gz
cd $PETSC
if [[ "$OSTYPE" == "linux-gnu" ]]; then
./config/configure.py --prefix=$EP_PATH --with-openblas=1 --with-openblas-dir=$EP_PATH --with-gnu-copyright-code=0 --with-mpi-dir=$EP_PATH --with-mpiexec=$EP_PATH/bin/mpiexec --with-debugging=0 --with-mpi-shared=0 --with-x=0 --with-x11=0 --with-shared-libraries=0 --LIBS="-lgfortran -lm"
make MAKE_NP=$jobs PETSC_DIR=$EP_PATH/$PETSC PETSC_ARCH=arch-linux2-c-opt all
make PETSC_DIR=$EP_PATH/$PETSC PETSC_ARCH=arch-linux2-c-opt install
elif [[ "$OSTYPE" == "darwin"* ]]; then
./config/configure.py --prefix=$EP_PATH --with-gnu-copyright-code=0 --with-mpi-dir=$EP_PATH --with-mpiexec=$EP_PATH/bin/mpiexec --with-debugging=0 --with-mpi-shared=0 --with-x=0 --with-x11=0 --with-shared-libraries=0
make MAKE_NP=$jobs PETSC_DIR=$EP_PATH/$PETSC PETSC_ARCH=arch-darwin-c-opt all
make PETSC_DIR=$EP_PATH/$PETSC PETSC_ARCH=arch-darwin-c-opt install
fi
cd $EP_PATH
rm -rf $PETSC
rm -rf $YAML_CPP
tar xzf $YAML_CPP.tar.gz
mv yaml-cpp-$YAML_CPP $YAML_CPP
cd $YAML_CPP
mkdir build
cd build
cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=$EP_PATH -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=Off -DYAML_CPP_BUILD_TOOLS=Off -DYAML_CPP_BUILD_CONTRIB=Off ..
make -j $jobs
make install
cd $EP_PATH
rm -rf $YAML_CPP
rm -rf $HDF
tar xzf $HDF.tar.gz
cd $HDF
if [[ "$OSTYPE" == "linux-gnu" ]]; then
./configure --prefix=$EP_PATH --disable-shared --enable-build-mode=production --enable-cxx --enable-static-exec CFLAGS=-fPIC CXXFLAGS=-fPIC
elif [[ "$OSTYPE" == "darwin"* ]]; then
CC=/usr/bin/cc CXX=/usr/bin/c++ ./configure --prefix=$EP_PATH --disable-shared --enable-build-mode=production --enable-cxx --enable-static-exec CFLAGS=-fPIC CXXFLAGS=-fPIC
fi
make -j $jobs all
make install
cd $EP_PATH
rm -rf $HDF
rm -rf $YACAS
tar xzf $YACAS.tar.gz
cd $YACAS
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=$EP_PATH -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_INSTALL_FRAMEWORK_PREFIX=$EP_PATH -DENABLE_CYACAS_GUI=no -DENABLE_CYACAS_KERNEL=no -DCMAKE_BUILD_TYPE=Release ..
make -j $jobs
make install
cd $EP_PATH
rm -rf $YACAS
md5sum *.tar.gz *.tar.bz2 *.tar.xz 2>/dev/null > checksums.md5
echo "Build finished normally"