-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
master: get_ipopt.sh: remove coinbrew and use Ipopt configure directly.
- Loading branch information
Showing
4 changed files
with
142 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
#! /bin/bash -e | ||
#! /usr/bin/env bash | ||
set -e -u | ||
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later | ||
# SPDX-FileCopyrightText: Bradley M. Bell <[email protected]> | ||
# SPDX-FileContributor: 2003-22 Bradley M. Bell | ||
# SPDX-FileContributor: 2003-24 Bradley M. Bell | ||
# ---------------------------------------------------------------------------- | ||
# {xrst_begin get_ipopt.sh} | ||
# {xrst_spell | ||
|
@@ -36,7 +37,7 @@ | |
# Source Directory | ||
# **************** | ||
# The Ipopt source code is downloaded and compiled in the sub-directory | ||
# ``external/Ipopt-`` *version* below the distribution directory. | ||
# ``external/Ipopt.git`` below the distribution directory. | ||
# | ||
# Prefix | ||
# ****** | ||
|
@@ -48,7 +49,7 @@ | |
# This will install the following version of Ipopt | ||
# {xrst_spell_off} | ||
# {xrst_code sh} | ||
version='3.13.2' | ||
ipopt_version='3.13.4' | ||
# {xrst_code} | ||
# {xrst_spell_on} | ||
# | ||
|
@@ -62,84 +63,155 @@ version='3.13.2' | |
# Delete this file if you want to re-run the configuration. | ||
# | ||
# {xrst_end get_ipopt.sh} | ||
# ----------------------------------------------------------------------------- | ||
package='ipopt' | ||
if [ $0 != "bin/get_$package.sh" ] | ||
then | ||
echo "bin/get_$package.sh: must be executed from its parent directory" | ||
exit 1 | ||
fi | ||
# ----------------------------------------------------------------------------- | ||
# bash function that echos and executes a command | ||
echo_eval() { | ||
# ---------------------------------------------------------------------------- | ||
ipopt_url='https://github.com/coin-or/Ipopt' | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# echo_eval | ||
function echo_eval() { | ||
echo $* | ||
eval $* | ||
} | ||
# ----------------------------------------------------------------------------- | ||
coinbrew='https://raw.githubusercontent.com/coin-or/coinbrew/master/coinbrew' | ||
cppad_dir=`pwd` | ||
# ----------------------------------------------------------------------------- | ||
# n_proc | ||
# | ||
# clone_url_name_version | ||
# creates ./name.git from corresponding url and version | ||
# $1 = url | ||
# $2 = name | ||
# $3 = version | ||
function clone_url_name_version() { | ||
if [ ! -e $2.git ] | ||
then | ||
echo_eval git clone $1.git $2.git | ||
fi | ||
echo_eval cd $2.git | ||
echo_eval git reset --hard | ||
echo_eval git fetch origin | ||
echo_eval git checkout --quiet $3 | ||
if [ ! -e build ] | ||
then | ||
echo_eval mkdir build | ||
fi | ||
cd .. | ||
} | ||
# ---------------------------------------------------------------------------- | ||
if [ $0 != 'bin/get_ipopt.sh' ] | ||
then | ||
echo 'bin/get_ipopt.sh: must be executed from its parent directory' | ||
exit 1 | ||
fi | ||
# ---------------------------------------------------------------------------- | ||
# | ||
# n_job | ||
if which nproc >& /dev/null | ||
then | ||
n_job=$(nproc) | ||
else | ||
n_job=$(sysctl -n hw.ncpu) | ||
fi | ||
# ----------------------------------------------------------------------------- | ||
# prefix | ||
eval `grep '^prefix=' bin/get_optional.sh` | ||
if [[ "$prefix" =~ ^[^/] ]] | ||
then | ||
prefix="$cppad_dir/$prefix" | ||
fi | ||
echo "prefix=$prefix" | ||
# ----------------------------------------------------------------------------- | ||
configured_flag="external/$package-${version}.configured" | ||
echo "Executing get_$package.sh" | ||
# | ||
# configured_flag | ||
configured_flag="external/Ipopt-${ipopt_version}.configured" | ||
echo "Executing get_ipopt.sh" | ||
if [ -e "$configured_flag" ] | ||
then | ||
echo "Skipping configuration because $configured_flag exits" | ||
echo_eval cd external | ||
./coinbrew -j $n_job install Ipopt --no-prompt | ||
echo "get_$package.sh: OK" | ||
echo_eval cd external/Ipopt.git/build | ||
make -j $n_job install | ||
echo "get_ipopt.sh: OK" | ||
exit 0 | ||
fi | ||
# ----------------------------------------------------------------------------- | ||
if [ ! -d external ] | ||
# | ||
# prefix | ||
eval `grep '^prefix=' bin/get_optional.sh` | ||
if [[ "$prefix" =~ ^[^/] ]] | ||
then | ||
echo_eval mkdir external | ||
prefix="$(pwd)/$prefix" | ||
fi | ||
echo_eval cd external | ||
# ----------------------------------------------------------------------------- | ||
if [ ! -e coinbrew ] | ||
echo "prefix=$prefix" | ||
# | ||
# external | ||
if [ ! -e external ] | ||
then | ||
echo_eval wget $coinbrew | ||
echo_eval chmod +x coinbrew | ||
mkdir external | ||
fi | ||
if [ ! -e Ipoot ] | ||
echo_eval cd external | ||
# | ||
# configure_all | ||
configure_all="--disable-dependency-tracking" | ||
configure_all+=" --prefix=$prefix" | ||
configure_all+=" --enable-shared" | ||
# | ||
# external/build_type/Ipopt.git | ||
name='Ipopt' | ||
clone_url_name_version $ipopt_url $name "releases/$ipopt_version" | ||
# | ||
# external/build_type/ASL.git | ||
# external/build_type/mumps.git | ||
for name in 'ASL' 'Mumps' | ||
do | ||
# clone_url_name_version | ||
line=$(grep "ThirdParty/$name" 'Ipopt.git/.coin-or/Dependencies') | ||
url=$(echo $line | awk '{print $2}' ) | ||
version=$(echo $line | awk '{print $3}' ) | ||
clone_url_name_version $url $name $version | ||
# | ||
# get.$name | ||
cd $name.git | ||
if [ -e "./get.$name" ] | ||
then | ||
if [ ! -e "./get.$name.done" ] | ||
then | ||
echo_eval ./get.$name | ||
touch ./get.$name.done | ||
fi | ||
fi | ||
cd .. | ||
done | ||
# | ||
# Install ASL | ||
cd ASL.git/build | ||
echo_eval ../configure $configure_all | ||
echo_eval make -j $n_job install | ||
cd ../.. | ||
# | ||
# Install Mumps | ||
configure_mumps="$configure_all" | ||
if [ "$(uname)" == 'Darwin' ] | ||
then | ||
./coinbrew fetch Ipopt@$version --no-prompt | ||
if which brew | ||
then | ||
metis_libdir=$(brew --prefix)/lib | ||
metis_incdir=$(brew --prefix)/include | ||
if [ ! -e "$metis_libdir/libmetis.dylib" ] | ||
then | ||
echo 'MacOS+brew: Cannot find metis library directory' | ||
fi | ||
if [ ! -e "$metis_incdir/metis.h" ] | ||
then | ||
echo 'MacOS+brew: Cannot find metis include directory' | ||
fi | ||
configure_mumps+=" --with-metis-lflags='-L$metis_libdir -lmetis'" | ||
configure_mumps+=" --with-metis-cflags='-I$metis_incdir'" | ||
fi | ||
fi | ||
# ----------------------------------------------------------------------------- | ||
# klugde necessary until coin or mumps fixes this problem | ||
cat << EOF > junk.f | ||
program junk | ||
print*, "Hello World" | ||
end | ||
EOF | ||
if gfortran -c -fallow-argument-mismatch junk.f >& /dev/null | ||
cd Mumps.git/build | ||
echo_eval ../configure $configure_mumps | ||
echo_eval make -j $n_job install | ||
cd ../.. | ||
# | ||
# Install Ipopt | ||
cd Ipopt.git/build | ||
echo_eval ../configure $configure_all --disable-java | ||
echo_eval make -j $n_job install | ||
cd ../.. | ||
# | ||
# configured_flag | ||
cd .. | ||
if ls external/Ipopt-*.configured > /dev/null | ||
then | ||
echo 'Adding -fallow-argument-mismatch to Mumps fortran compiler flags' | ||
ADD_FCFLAGS='ADD_FCFLAGS=-fallow-argument-mismatch' | ||
else | ||
ADD_FCFLAGS='' | ||
rm external/Ipopt-*.configured | ||
fi | ||
# ----------------------------------------------------------------------------- | ||
echo_eval ./coinbrew -j $n_job build Ipopt@$version \ | ||
--prefix=$prefix --test --no-prompt --verbosity=3 $ADD_FCFLAGS | ||
echo_eval ./coinbrew -j $n_job install Ipopt@$version \ | ||
--no-prompt | ||
# ----------------------------------------------------------------------------- | ||
echo_eval touch $cppad_dir/$configured_flag | ||
echo "get_$package.sh: OK" | ||
touch $configured_flag | ||
# ---------------------------------------------------------------------------- | ||
echo 'get_ipopt.sh: OK' | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters