Created
October 31, 2013 04:40
-
-
Save tavert/7244436 to your computer and use it in GitHub Desktop.
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
#!/bin/sh | |
# Build a Windows dll of Bonmin MINLP solver in MinGW | |
# (https://projects.coin-or.org/svn/Bonmin/trunk/) | |
# run this script from the top-level Bonmin directory | |
# stop on error | |
set -e | |
# first go through the configure of each subfolder and replace | |
# coin_disable_shared=yes with coin_disable_shared=no | |
# this will stop configure from disabling shared libraries on mingw | |
cp configure configure.orig | |
sed 's/coin_disable_shared=yes/coin_disable_shared=no/g' configure.orig > configure | |
for i in `ls */configure`; do | |
cp $i $i.orig | |
sed 's/coin_disable_shared=yes/coin_disable_shared=no/g' $i.orig > $i | |
done | |
for i in `ls */*/configure`; do | |
cp $i $i.orig | |
sed 's/coin_disable_shared=yes/coin_disable_shared=no/g' $i.orig > $i | |
done | |
# create build folder, run configure | |
builddir=build_dll | |
mkdir -p $builddir | |
cd $builddir | |
mkdir -p lib | |
libdir=`pwd`/lib | |
if test -f config.cache; then | |
# clean up old config.cache, if any present | |
rm config.cache | |
fi | |
../configure -C LD=ld --disable-pthread-mumps --enable-static --enable-shared \ | |
coin_skip_warn_cflags=yes coin_skip_warn_cxxflags=yes | |
# -C caches results so configure runs a bit faster | |
# LD=ld stops COIN_MINGW_LD_FIX macro in BuildTools/coin.m4 from setting it to link | |
# (that macro should probably be checking which compiler you're using before it does that) | |
# --disable-pthread-mumps removes mumps dependency on pthread dll | |
# --enable-static --enable-shared is to build both static and shared libraries | |
# coin_skip_warn_*flags=yes is needed for libtool executable wrappers to build | |
# (some warnings, about variadic macros and incompatible pointer type in argument 2 | |
# of execv (char const **) instead of (char * const *), become errors otherwise) | |
# set ldflags (these will be sent to make via AM_LDFLAGS) | |
ldflags="-no-undefined -avoid-version" | |
# -no-undefined is necessary to build dll's | |
# -avoid-version gets rid of the version numbers in the dll names | |
# run make in each of the subfolders (have to do them each separately because of dll dependencies) | |
for i in Blas Lapack ASL Metis Mumps; do | |
cd $libdir/../ThirdParty/$i | |
# specify dependencies | |
deps= | |
case $i in | |
Lapack) | |
deps="$libdir/libcoinblas.la" | |
;; | |
ASL) | |
# export all symbols for libcoinasl | |
AM_LDFLAGS="$ldflags -Wl,--export-all-symbols" make | |
;; | |
Mumps) | |
deps="$libdir/libcoinmetis.la $libdir/libcoinblas.la" | |
;; | |
esac | |
AM_LDFLAGS="$ldflags $deps" make install | |
done | |
for i in CoinUtils Osi Clp Cgl Cbc Ipopt Bonmin; do | |
cd $libdir/../$i | |
# specify dependencies | |
case $i in | |
CoinUtils) | |
deps="$libdir/libcoinlapack.la" | |
;; | |
Osi) | |
deps="$deps $libdir/libCoinUtils.la" | |
# build libOsi first since libOsiCommonTests depends on it | |
cd src/Osi | |
AM_LDFLAGS="$ldflags $deps" make install | |
deps="$deps $libdir/libOsi.la" | |
cd ../.. | |
;; | |
Clp) | |
deps="$deps $libdir/libcoinmumps.la" | |
# build libClp first since libOsiClp depends on it | |
cd src | |
AM_LDFLAGS="$ldflags $deps" make install-libLTLIBRARIES | |
deps="$deps $libdir/libClp.la" | |
cd .. | |
;; | |
Cgl) | |
deps="$deps $libdir/libOsiClp.la" | |
;; | |
Cbc) | |
deps="$deps $libdir/libCgl.la" | |
# build libCbc first since libOsiCbc depends on it | |
cd src | |
AM_LDFLAGS="$ldflags $deps" make libCbc.la | |
# install directly with libtool since install-libLTLIBRARIES also wants to build libCbcSolver | |
../../libtool --mode=install /bin/install -c libCbc.la $libdir/libCbc.la | |
deps="$deps $libdir/libcoinasl.la $libdir/libCbc.la" | |
cd .. | |
;; | |
Ipopt) | |
# build src/Common, src/LinAlg, src/Algorithm, | |
# src/contrib, and src/Interfaces before src/Apps | |
for d in Common LinAlg Algorithm contrib/CGPenalty \ | |
contrib/LinearSolverLoader Interfaces; do | |
cd $libdir/../Ipopt/src/$d | |
AM_LDFLAGS="$ldflags $deps" make install | |
done | |
deps="$deps $libdir/libipopt.la" | |
cd $libdir/../Ipopt | |
;; | |
Bonmin) | |
# build libbonmin and its dependencies before libbonminampl | |
for d in Interfaces Algorithms CbcBonmin/Heuristics; do | |
cd $libdir/../Bonmin/src/$d | |
AM_LDFLAGS="$ldflags $deps" make install | |
done | |
cd $libdir/../Bonmin/src/CbcBonmin | |
AM_LDFLAGS="$ldflags $deps" make libbonmin.la | |
# install directly with libtool since install-libLTLIBRARIES also wants to build libbonminampl | |
../../../libtool --mode=install /bin/install -c libbonmin.la $libdir/libbonmin.la | |
# libbonminampl isn't using g++ to link, but should be | |
cp Makefile Makefile.orig | |
sed 's/$(LINK)/$(CXXLINK)/' Makefile.orig > Makefile | |
deps="$deps $libdir/libipoptamplinterface.la $libdir/libbonmin.la" | |
cd ../.. | |
;; | |
esac | |
AM_LDFLAGS="$ldflags $deps" make install | |
done | |
# run unit tests | |
for i in CoinUtils Osi Clp Cgl Cbc Ipopt Bonmin; do | |
cd $libdir/../$i/test | |
# copy all dll's temporarily to test folder | |
cp $libdir/../bin/*.dll . | |
cp /mingw/bin/libgcc*.dll . | |
cp /mingw/bin/libstdc++*.dll . | |
cp /mingw/bin/libgfortran*.dll . | |
cp /mingw/bin/libquadmath*.dll . | |
# modify the Makefile to call the libtool wrapper shell scripts instead | |
# of the wrapper executables, which don't quite work from old libtool | |
cp Makefile Makefile.orig | |
sed -e 's|./unitTest\$(EXEEXT)|./unitTest|' \ | |
-e 's|../src/clp\$(EXEEXT) \$(unittestflags)|../src/clp \$(unittestflags)|' \ | |
-e 's|./osiUnitTest\$(EXEEXT)|./osiUnitTest|' \ | |
-e 's|./gamsTest\$(EXEEXT)|./gamsTest|' \ | |
-e 's|../src/cbc\$(EXEEXT) \$(cbcflags)|../src/cbc \$(cbcflags)|' \ | |
-e 's|../src/cbc-generic\$(EXEEXT) \\|../src/cbc-generic \\|' \ | |
-e 's|./CppExample\$(EXEEXT)|./CppExample|' Makefile.orig > Makefile | |
make test | |
rm *.dll | |
done | |
echo All compilation and tests successful! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment