-
Notifications
You must be signed in to change notification settings - Fork 0
/
psopt_installer.sh
executable file
·249 lines (205 loc) · 4.66 KB
/
psopt_installer.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
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
#!/bin/bash
#
# PSOPT Installer
# Copyright (C) 2018, Flavio Santes <flavio.santes at 1byt3.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
psopt_dir="$HOME/psopt_bundle"
psopt_vars="set_variables.sh"
psopt_src="psopt"
psopt_url="https://github.com/flavio-santes/psopt.git"
download_cmd=""
os_name=""
binary_dir="$psopt_dir/binary"
configure_cmd="./configure --prefix=$binary_dir"
root_dir=$PWD
debian_pkgs()
{
sudo apt-get install -y \
gcc g++ gfortran \
make patch \
libf2c2-dev \
libopenblas-dev \
liblapack-dev \
gnuplot wget git unzip cmake
}
redhat_pkgs()
{
sudo yum install -y \
gcc gcc-c++ gcc-gfortran \
make patch \
f2c \
openblas-devel \
lapack-devel \
gnuplot wget git unzip cmake
}
configure_os()
{
case $(uname) in
Linux)
if [ -e "/etc/debian_version" ]
then
os_name="Debian"
debian_pkgs
elif [ -e "/etc/redhat-release" ] || [ -e "/etc/fedora-release" ]
then
os_name="CentOS"
redhat_pkgs
else
echo "Unsupported OS :("
exit 1
fi
download_cmd="wget -O"
;;
*)
echo "Unsupported OS :("
exit 1
;;
esac
mkdir -p "$root_dir/tmp"
mkdir -p "$psopt_dir"
cd $psopt_dir/
cp $root_dir/scripts/$psopt_vars .
source $psopt_vars
}
clean_all()
{
cd "$root_dir/"
rm -rf "tmp"
mkdir -p "$root_dir/tmp"
rm -rf "$psopt_dir"
mkdir -p "$psopt_dir"
}
install_metis()
{
cd $root_dir/tmp
tar zxf $root_dir/packages/metis-5.1.0.tar.gz
cd $root_dir/tmp/metis-5.1.0
patch -p0 < $root_dir/patches/METIS_type_size.diff
make config shared=1 prefix=$binary_dir
make
make install
}
install_mumps()
{
cd $root_dir/tmp
tar zxf $root_dir/packages/MUMPS_5.1.2.tar.gz
cd MUMPS_5.1.2
patch -p0 < $root_dir/patches/MUMPS_Makefiles.diff
make
cp -R include $binary_dir/include/mumps
cp libseq/*.h $binary_dir/include/mumps
cp lib/libdmumps.so $binary_dir/lib
cp lib/libmumps_common.so $binary_dir/lib
cp libseq/libmpiseq.so $binary_dir/lib
}
install_ipopt()
{
cd $root_dir/tmp
tar zxf $root_dir/packages/Ipopt-3.12.3.tgz
cd $root_dir/tmp/Ipopt-3.12.3
$configure_cmd \
--disable-static \
--with-mumps-lib \
coin_skip_warn_cxxflags=yes
make
make install
}
install_colpack()
{
cd $root_dir/tmp
tar zxf $root_dir/packages/ColPack-1.0.9.tar.gz
cd ColPack-1.0.9
patch -p0 < $root_dir/patches/ColPack_utilities_extra.diff
$configure_cmd \
--disable-static
make
make install
}
install_adol_c()
{
cd $root_dir/tmp
tar zxf $root_dir/packages/ADOL-C-2.5.2.tgz
cd ADOL-C-2.5.2
$configure_cmd \
--with-colpack="$psopt_dir" \
--disable-static \
--enable-sparse
make
make install
}
install_lusol()
{
cd "$root_dir/tmp"
unzip "$root_dir/packages/lusol.zip"
cd lusol/csrc
patch -p0 < $root_dir/patches/LUSOL_max.diff
cp "$root_dir/scripts/Makefile_lusol" Makefile
make -f Makefile
mkdir -p $binary_dir/lib
mkdir -p $binary_dir/include/lusol
cp lib*.so $binary_dir/lib
cp *.h $binary_dir/include/lusol
chmod 644 -R $binary_dir/include/lusol/*.h
}
install_cxsparse()
{
cd $root_dir/tmp
tar zxf $root_dir/packages/SuiteSparse-4.4.3.tar.gz
cd SuiteSparse
patch -p0 < $root_dir/patches/CXSparse_Makefile.diff
cd CXSparse
make library
incs=$binary_dir/include/cxsparse
mkdir -p $incs
cp Include/cs.h $incs
cp ../SuiteSparse_config/SuiteSparse_config.h $incs
cp Lib/libcxsparse.* $binary_dir/lib
}
install_psopt()
{
cd $psopt_dir
git clone $psopt_url --branch fixes $psopt_src
cd $psopt_src
patch -p0 < $root_dir/patches/PSOPT_delete_unused_files.diff
patch -p0 < $root_dir/patches/PSOPT_src_plot.diff
patch -p0 < $root_dir/patches/PSOPT_Makefile.diff
patch -p0 < $root_dir/patches/PSOPT_Makefile_newlibs.diff
export GIT_AUTHOR_NAME="PSOPT Installer"
export GIT_AUTHOR_EMAIL="psopt"
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"
export GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
git add .
git commit -m "installer: save local changes"
make all
}
set -e
case $1 in
clean)
clean_all
;;
*)
clean_all
configure_os
install_metis
install_mumps
install_ipopt
install_colpack
install_adol_c
install_lusol
install_cxsparse
install_psopt
;;
esac