-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_k_aug.sh
127 lines (101 loc) · 4.25 KB
/
install_k_aug.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
# Script to install k_aug and add to PATH in .bashrc
# This script worked in Linux Mint 20.1
# Kernel 5.4.0-58-generic
# Variables - directories where you want to install k_aug
main_dir="$HOME/scratch"
sub_dir="k_aug_install"
# This is where you installed ASL
asl_install_dir="$HOME/scratch"
# This is where you installed HSL
hsl_install_dir="$HOME/scratch"
# This is where most libraries are found (don't change unless your set-up is different)
usr_dir="/usr/lib"
#Option to print stuff out (0 or 1)
verbose=0
# The Github repo where k_aug is hosted
repo="https://github.com/dthierry/k_aug.git"
# Just incase this is not yet installed
#sudo apt-get update
sudo apt-get install cmake
# Manual dependency directory entry - not necessary unless the auto install doesn't work
# This is where your (1) asl.h, (2) getstub.h, and (3) arith.h files are located
dir_dep_1=""
dir_dep_2=""
dir_dep_3=""
# Library packages
dir_asl=""
dir_hsl=""
dir_metis=""
dir_blas=""
dir_lapack=""
dir_gfortran=""
# Automatic dependency lookup - finds the directory of the latest version of the file
function find_dir()
{
local __resultvar=$1
if ! [[ ${!__resultvar} ]]; then
eval $__resultvar="$(find $2 -name $3 -printf '%h\n' | sort -d -r | head -n 1)"
fi
}
search_dir=$asl_install_dir
find_dir dir_dep_1 $search_dir "asl.h"
find_dir dir_dep_2 $search_dir "getstub.h"
find_dir dir_dep_3 $search_dir "arith.h"
find_dir dir_asl $search_dir "libcoinasl.so"
search_dir=$hsl_install_dir
find_dir dir_hsl $search_dir "libcoinhsl.so"
search_dir=$usr_dir
find_dir dir_metis $search_dir "libmetis.so"
find_dir dir_blas $search_dir "libblas.so"
find_dir dir_lapack $search_dir "liblapack.so"
find_dir dir_gfortran $search_dir "libgfortran.so"
# Make the scratch folder in the home directory
if ! [[ -d "$main_dir" ]]
then
mkdir "$main_dir"
mkdir "$main_dir/$sub_dir"
else
if ! [[ -d "$main_dir/$sub_dir" ]]
then
mkdir "$main_dir/$sub_dir"
else
rm -rf "$main_dir/$sub_dir"
mkdir "$main_dir/$sub_dir"
fi
fi
cd $main_dir/$sub_dir
git clone $repo
# Change into correct directory
cd k_aug
# Incase you mess up
cp CMakeLists.txt CMakeLists-original.txt
# Change the ASL dependencies
echo "DEP: $dir_dep_1, $dir_dep_2, and $dir_dep_3 are being used for the ASL dependencies"
sed -i "s:include_directories(/usr/local/include/coin-or/asl ):include_directories(${dir_dep_1} ${dir_dep_2} ${dir_dep_3} ):g" CMakeLists.txt
# ASL
echo "ASL: $dir_asl is being used for the ASL library"
sed -i "s:find_library(COINASL NAMES asl \${libaslname} HINTS /usr/local/lib REQUIRED):find_library(COINASL NAMES asl \${libaslname} HINTS /usr/local/lib $dir_asl REQUIRED):g" CMakeLists.txt
# HSL
echo "HSL: $dir_hsl is being used for the HSL library"
sed -i "s:find_library(COINHSL NAMES \${libhslname} HINTS /usr/local/lib REQUIRED):find_library(COINHSL NAMES \${libhslname} HINTS /usr/local/lib $dir_hsl REQUIRED):g" CMakeLists.txt
# metis
echo "METIS: $dir_metis is being used for the Metis library"
sed -i "s:find_library(COINMETIS NAMES metis \${libmetisname} HINTS /usr/local/lib REQUIRED):find_library(COINMETIS NAMES metis \${libmetisname} HINTS /usr/local/lib $dir_metis REQUIRED):g" CMakeLists.txt
# blas
echo "BLAS: $dir_blas is being used for the BLAS library"
sed -i "s:find_library(BLAS NAMES blas \${libblasname} HINTS /usr/lib /usr/local/lib REQUIRED):find_library(BLAS NAMES blas \${libblasname} HINTS /usr/lib /usr/local/lib $dir_blas REQUIRED):g" CMakeLists.txt
# lapack
echo "LAPACK: $dir_lapack is being used for the LAPACK library"
sed -i "s:find_library(LAPACK NAMES lapack \${liblapackname} HINTS /usr/lib /usr/local/lib REQUIRED):find_library(LAPACK NAMES lapack \${liblapackname} HINTS /usr/lib /usr/local/lib $dir_lapack REQUIRED):g" CMakeLists.txt
# gfortran
echo "GFORTRAN: $dir_gfortran is being used for the GFortran library"
sed -i "s:find_library(GFORTRAN NAMES gfortran HINTS /usr/local/opt/gcc/lib/gcc/10 REQUIRED):find_library(GFORTRAN NAMES gfortran HINTS $dir_gfortran REQUIRED):g" CMakeLists.txt
# verbosity update
sed -i "s:set(PRINT_VERBOSE 0):set(PRINT_VERBOSE $verbose):g" CMakeLists.txt
# Make it all!
cmake CMakeLists.txt
make
# Add k_aug executable to path
echo "# Added by install_k_aug.sh" >> $HOME/.bashrc
echo "export PATH=\"\$PATH:$main_dir/$sub_dir/k_aug/bin"\" >> $HOME/.bashrc
# Done!