-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathinstall-superlu.sh
executable file
·85 lines (67 loc) · 1.94 KB
/
install-superlu.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
#!/bin/bash
set -e
# The SuperLU version (git tag) to download.
version="6.0.1"
build_type="Release"
shared_libs="OFF"
cleanup=0
# Install into local folder "external", unless the --global-install option is used.
install_prefix="$(pwd)/external"
while [[ "$#" -gt 0 ]]; do
case "${1:-}" in
-g|--global-install)
install_prefix=""
shift 1
;;
-s|--shared-libs)
shared_libs="ON"
shift 1
;;
-c|--cleanup)
cleanup=1
shift 1
;;
esac
done
mkdir -p external
cd external
# Local BLAS lib (ignored if not exist)
lib_BLAS="$(pwd)/lib/libopenblas.a"
local_BLAS=""
if [[ -f "$lib_BLAS" ]]; then
local_BLAS="-D BLAS_LIBRARIES=${lib_BLAS}"
fi
# Download the version specified above. In case the archive or extracted folder
# already exist, they will be re-used. Use the --cleanup option to remove the
# folder (and thus temporary build artifacts and CMake cache) after build.
source="https://github.com/xiaoyeli/superlu/archive/refs/tags/v${version}.tar.gz"
target="superlu-${version}.tar.gz"
if [ ! -f $target ]; then
if [ -x "$(command -v curl)" ]; then
curl -L -o $target $source
elif [ -x "$(command -v wget)" ]; then
wget -O $target $source
else
echo "Please install curl or wget!"
exit 1
fi
fi
if [ ! -d "superlu-${version}" ]; then
tar -xvf $target > /dev/null
fi
cd superlu-${version}
# Set CMake install prefix options.
install_prefix_CONF=""
install_prefix_INST=""
if [ ! -z "$install_prefix" ]; then
install_prefix_CONF="-D CMAKE_INSTALL_PREFIX=$install_prefix"
install_prefix_INST="--prefix $install_prefix"
fi
cmake -B build -D enable_examples=OFF -D enable_tests=OFF -D CMAKE_BUILD_TYPE=$build_type -D BUILD_SHARED_LIBS=$shared_libs $install_prefix_CONF $local_BLAS
cmake --build build --config $build_type --parallel
cmake --install build $install_prefix_INST
cd ../../
if [ $cleanup -eq 1 ]; then
echo "Cleaning up ..."
rm -rf external/superlu-${version}/
fi