Skip to content

Commit

Permalink
master: get_ipopt.sh: remove coinbrew and use Ipopt configure directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradbell committed Sep 11, 2024
1 parent 26a7a01 commit bb4f2b7
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 65 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ IF( POLICY CMP0054 )
ENDIF( POLICY CMP0054 )
#
# cppad_version is used by version.sh to get the version number.
SET(cppad_version "20240909")
SET(cppad_version "20240911")
SET(cppad_url "https://coin-or.github.io/CppAD" )
SET(cppad_description "Differentiation of C++ Algorithms" )
IF( NOT DEFINED CMAKE_BUILD_TYPE)
Expand Down
5 changes: 5 additions & 0 deletions appendix/whats_new/2024.xrst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Release Notes for 2024
mm-dd
*****

09-11
=====
The :ref:`get_ipopt.sh@Source Directory` was changed from
``external/Ipopt-``\ *version* to ``external/Ipopt,git`` .

09-09
=====
#. The :ref:`cmake@CMake Command@Visual Studio` instructions were improved.
Expand Down
198 changes: 135 additions & 63 deletions bin/get_ipopt.sh
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
Expand Down Expand Up @@ -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
# ******
Expand All @@ -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}
#
Expand All @@ -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
2 changes: 1 addition & 1 deletion user_guide.xrst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

{xrst_comment BEGIN: Before changing see new_release.sh and check_version.sh}

cppad-20240909: CppAD User's Manual
cppad-20240911: CppAD User's Manual
###################################
{xrst_comment The scripts bin/check_version.sh and bin/new_release.sh
edit version numbers in tables below.}
Expand Down

0 comments on commit bb4f2b7

Please sign in to comment.