-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathinstall-openblas.sh
executable file
·76 lines (61 loc) · 1.75 KB
/
install-openblas.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
#!/bin/bash
set -e
# The OpenBLAS version (git tag) to download.
version="0.3.26"
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
# 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/OpenMathLib/OpenBLAS/archive/refs/tags/v${version}.tar.gz"
target="OpenBLAS-${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 "OpenBLAS-${version}" ]; then
tar -xvf $target > /dev/null
fi
cd OpenBLAS-${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 BUILD_TESTING=OFF -D CMAKE_BUILD_TYPE=$build_type -D BUILD_SHARED_LIBS=$shared_libs $install_prefix_CONF
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/OpenBLAS-${version}/
fi