-
Notifications
You must be signed in to change notification settings - Fork 8
/
compile-and-install-suitesparse.bash
executable file
·85 lines (72 loc) · 1.81 KB
/
compile-and-install-suitesparse.bash
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
#!/bin/bash
set -e
# fake sudo function to be used by docker build
sudo () {
[[ $EUID = 0 ]] || set -- command sudo "$@"
"$@"
}
# the first argument is the "mkl" option
BLAS_LIB=${1:-""}
# options
PREFIX="/usr/local"
INCDIR=$PREFIX/include/suitesparse
LIBDIR=$PREFIX/lib/suitesparse
# install dependencies
sudo apt-get update -y &&
sudo apt-get install -y --no-install-recommends \
cmake \
curl \
g++ \
git \
make
if [ "${BLAS_LIB}" = "mkl" ]; then
bash zscripts/install-intel-mkl-and-ifort-debian.bash
else
sudo apt-get install -y --no-install-recommends \
liblapacke-dev \
libopenblas-dev
fi
# source Intel oneAPI vars (ifort)
if [ "${BLAS_LIB}" = "mkl" ]; then
source /opt/intel/oneapi/setvars.sh
export | grep -i MKLROOT
fi
# set cmake options
CMAKE_OPTIONS="-DBLA_VENDOR=OpenBLAS -DBLA_SIZEOF_INTEGER=4 -DNFORTRAN=ON"
if [ "${BLAS_LIB}" = "mkl" ]; then
CMAKE_OPTIONS="-DBLA_VENDOR=Intel10_64lp -DBLA_SIZEOF_INTEGER=4 -DNFORTRAN=ON"
fi
# download the source code
cd /tmp
if ! [ -d "SuiteSparse" ]; then
git clone https://github.com/DrTimothyAldenDavis/SuiteSparse.git
fi
cd SuiteSparse
# function to compile and copy results to local directories
action () {
local dir=$1
cd $dir
make clean
CMAKE_OPTIONS=${CMAKE_OPTIONS} make local
CMAKE_OPTIONS=${CMAKE_OPTIONS} make install
cd ..
}
# compile and copy results to local directories
action SuiteSparse_config
action AMD
action CAMD
action CCOLAMD
action COLAMD
action CHOLMOD
action UMFPACK
action BTF
action KLU
# copy include files
sudo mkdir -p $INCDIR/
sudo cp -av include/suitesparse/*.h $INCDIR/
# copy libray files
sudo mkdir -p $LIBDIR/
sudo cp -av lib/* /usr/local/lib/suitesparse
# update ldconfig
echo "${LIBDIR}" | sudo tee /etc/ld.so.conf.d/suitesparse.conf >/dev/null
sudo ldconfig