This commit is contained in:
commit
c1497d802b
1 changed files with 151 additions and 0 deletions
151
everything
Normal file
151
everything
Normal file
|
@ -0,0 +1,151 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
prefix="/opt/coin-or"
|
||||
|
||||
# get json2 for helping with github APIs later:
|
||||
if [ ! -s "json2" ]; then
|
||||
curl -LsS https://github.com/vi/json2/raw/master/json2 -o json2
|
||||
fi
|
||||
chmod +x json2
|
||||
|
||||
# ensure we can actually run it:
|
||||
./json2 <<< '{}' >/dev/null
|
||||
|
||||
# prepare paths:
|
||||
mkdir -p $prefix/lib/pkgconfig
|
||||
PATH="$prefix/bin:$PATH"
|
||||
PKG_CONFIG_PATH="$prefix/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||
|
||||
# prepare a mapping of coin-or project names to their tar.gz's:
|
||||
declare -A tgzs
|
||||
|
||||
note() {
|
||||
echo -e "\e[1m$@\e[0m" >&2
|
||||
}
|
||||
|
||||
stfu() {
|
||||
"$@" > .stdout 2> .stderr || fail=$?
|
||||
if [[ "$fail" -ne 0 ]]; then
|
||||
echo "command failed with exit status $fail:" >&2
|
||||
echo -E "$@" >&2
|
||||
echo >&2
|
||||
note '$ tail .stdout'
|
||||
tail .stdout >&2
|
||||
echo >&2
|
||||
note '$ tail .stderr'
|
||||
tail .stderr >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_autotool() {
|
||||
if [ -s "$1.tar.gz" ]; then
|
||||
note "skipping downloading $1"
|
||||
return 0
|
||||
fi
|
||||
note "downloading $1"
|
||||
curl -LsS "http://ftp.gnu.org/gnu/${1%-*}/$1.tar.gz" -o "$1.tar.gz"
|
||||
}
|
||||
|
||||
make_autotool() {
|
||||
if [[ $(command -v "${1%-*}") == "$prefix/bin"* ]]; then
|
||||
note "skipping building $1"
|
||||
return 0
|
||||
fi
|
||||
note "building $1"
|
||||
|
||||
# always extract in case configs/caches got messed up (as they do):
|
||||
tar -xzf "$1.tar.gz"
|
||||
pushd "$1" >/dev/null
|
||||
stfu ./configure --prefix=$prefix
|
||||
stfu make
|
||||
stfu make install
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
get_coin() {
|
||||
organ="coin-or"
|
||||
if [ "$1" == "BuildTools" ] || [[ "$1" == "ThirdParty-"* ]]; then
|
||||
organ="coin-or-tools"
|
||||
fi
|
||||
|
||||
curl -LsS "https://api.github.com/repos/$organ/$1/tags" | ./json2 > temp
|
||||
for i in {0..9}; do # check first few tags for a release
|
||||
grep -Eq "^/$i/name=releases" temp || continue
|
||||
url="$(grep -E "^/$i/tarball_url=" temp)"
|
||||
url="${url#*=}"
|
||||
sha="$(grep -E "^/$i/commit/sha=" temp)"
|
||||
sha="${sha#*=}"
|
||||
tgz="$organ-$1-${sha::7}.tar.gz"
|
||||
tgzs["$1"]="$tgz"
|
||||
if [ -s "$tgz" ]; then
|
||||
note "skipping downloading $1"
|
||||
else
|
||||
note "downloading $1"
|
||||
curl -LsS "$url" -o "$tgz"
|
||||
fi
|
||||
return 0
|
||||
done
|
||||
echo "failed to find the latest release of $1" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
with() {
|
||||
withs=()
|
||||
for name in "$@"; do
|
||||
withs+=("--with-$name")
|
||||
if [ "$name" == "asl" ]; then
|
||||
withs+=("--with-$name-lib=$(pkg-config --libs coin$name)")
|
||||
withs+=("--with-$name-incdir=$prefix/include/coin/ThirdParty/")
|
||||
else
|
||||
withs+=("--with-$name-lib=$(pkg-config --libs $name)")
|
||||
withs+=("--with-$name-incdir=$prefix/include/coin/")
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
make_coin() {
|
||||
note "building $1"
|
||||
tgz="${tgzs[$1]}"
|
||||
# always extract in case configs/caches got messed up (as they do):
|
||||
tar -xzf "$tgz"
|
||||
dir="$(tar -tzf "$tgz" | head -1 | cut -f1 -d/)"
|
||||
pushd "$dir" >/dev/null
|
||||
if [[ "$1" == "ThirdParty-"* ]]; then
|
||||
stfu "./get.${1##*-}"
|
||||
fi
|
||||
shift
|
||||
stfu ./configure --prefix=$prefix "${withs[@]}" "$@"
|
||||
stfu make
|
||||
stfu make install
|
||||
popd >/dev/null
|
||||
}
|
||||
|
||||
for autotool in autoconf-2.59 automake-1.9.6 libtool-1.5.22; do
|
||||
get_autotool "$autotool"
|
||||
make_autotool "$autotool"
|
||||
done
|
||||
|
||||
get_coin CoinUtils
|
||||
get_coin Osi
|
||||
get_coin Clp
|
||||
get_coin Cgl
|
||||
get_coin Cbc
|
||||
get_coin Ipopt
|
||||
get_coin Bonmin
|
||||
get_coin ThirdParty-ASL
|
||||
|
||||
with; make_coin ThirdParty-ASL
|
||||
with; make_coin CoinUtils
|
||||
with coinutils; make_coin Osi
|
||||
with coinutils osi; make_coin Clp
|
||||
with coinutils osi clp; make_coin Cgl
|
||||
with coinutils osi clp cgl asl; make_coin Cbc
|
||||
with coinutils osi clp cgl asl cbc; make_coin Ipopt --with-blas="/mingw64/bin/libopenblas.dll"
|
||||
with coinutils osi clp cgl asl cbc ipopt; make_coin Bonmin
|
||||
|
||||
# FIXME: Bonmin needs to be linked with more stuff: (g++ invoked by libtool)
|
||||
# -lipoptamplinterface
|
||||
# -lcoinasl
|
Loading…
Reference in a new issue