2012-02-18 07:25:51 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# bin/compile BUILD_DIR CACHE_DIR
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2012-02-18 07:44:56 +00:00
|
|
|
source $(dirname $0)/../scripts/functions
|
2012-02-18 07:25:51 +00:00
|
|
|
|
|
|
|
BUILD_DIR=$1
|
2012-04-13 08:39:54 +00:00
|
|
|
loginfo "BUILD_DIR=$BUILD_DIR"
|
2012-02-18 07:25:51 +00:00
|
|
|
CACHE_DIR=$2
|
2012-04-13 08:39:54 +00:00
|
|
|
loginfo "CACHE_DIR=$CACHE_DIR"
|
2012-02-18 07:25:51 +00:00
|
|
|
|
2012-04-13 07:53:17 +00:00
|
|
|
|
2012-04-13 08:39:54 +00:00
|
|
|
## CHECK BUILDPACK_GHC_BASE_URL is set
|
|
|
|
setIfUnset BUILDPACK_GHC_BASE_URL "http://www.haskell.org/ghc/dist"
|
|
|
|
setIfUnset GHC_BOOTSTRAP_VERSION "7.0.4"
|
|
|
|
setIfUnset HASKELL_PLATFORM_BASE_URL "http://lambda.haskell.org/platform/download"
|
|
|
|
setIfUnset HASKELL_PLATFORM_VERSION "2011.4.0.0"
|
2012-04-13 07:53:17 +00:00
|
|
|
|
|
|
|
arch=$(uname -m)
|
|
|
|
ghcver=$GHC_BOOTSTRAP_VERSION
|
|
|
|
bsdir=$CACHE_DIR/bootstrap
|
2012-04-13 08:39:54 +00:00
|
|
|
ghcurl="$BUILDPACK_GHC_BASE_URL/$ghcver/ghc-$ghcver-$arch-unknown-linux.tar.gz"
|
|
|
|
platformver="$HASKELL_PLATFORM_VERSION"
|
|
|
|
platformurl="$HASKELL_PLATFORM_BASE_URL/$platver/haskell-platform-$platformver-tar.gz"
|
2012-04-13 07:53:17 +00:00
|
|
|
|
|
|
|
loginfo "bootstrap directory: ${bsdir}";
|
|
|
|
loginfo "bootstrap URL: $ghcurl";
|
|
|
|
|
2012-04-13 08:39:54 +00:00
|
|
|
if [ -f "$bsdir.ghc.downloaded" ]; then
|
2012-04-13 07:53:17 +00:00
|
|
|
loginfo "already downloaded GHC bootstrap version ${ghcver}";
|
|
|
|
else
|
|
|
|
loginfo "downloading GHC $ghcver from $ghcurl";
|
|
|
|
$(downloadAndExtract $bsdir $ghcurl) && \
|
2012-04-13 08:39:54 +00:00
|
|
|
touch $bsdir.ghc.downloaded;
|
2012-04-13 07:53:17 +00:00
|
|
|
fi
|
2012-04-13 08:39:54 +00:00
|
|
|
# GHC source is downloaded
|
2012-04-13 07:53:17 +00:00
|
|
|
|
2012-04-13 08:39:54 +00:00
|
|
|
if [ -f "$bsdir.ghc.compiled" ]; then
|
2012-04-13 07:53:17 +00:00
|
|
|
loginfo "already compiled GHC bootstrap version ${ghcver}";
|
2012-02-18 07:25:51 +00:00
|
|
|
else
|
2012-04-13 07:53:17 +00:00
|
|
|
$(configureMakeInstall $bsdir/ghc-$ghcver $BUILD_DIR/bootstrap/ghc-$ghcver) && \
|
2012-04-13 08:39:54 +00:00
|
|
|
touch $bsdir.ghc.compiled;
|
|
|
|
fi
|
|
|
|
# GHC is compiled
|
|
|
|
|
|
|
|
if [ -f "$bsdir.platform.downloaded" ]; then
|
|
|
|
loginfo "already downloaded GHC bootstrap version ${platformver}";
|
|
|
|
else
|
|
|
|
loginfo "downloading GHC $platformver from $platformurl";
|
|
|
|
$(downloadAndExtract $bsdir $platformurl) && \
|
|
|
|
touch $bsdir.platform.downloaded;
|
|
|
|
fi
|
|
|
|
# Haskell Platform source is downloaded
|
|
|
|
|
|
|
|
if [ -f "$bsdir.platform.compiled" ]; then
|
|
|
|
loginfo "already compiled GHC bootstrap version ${platformver}";
|
|
|
|
else
|
|
|
|
$(configureMakeInstall $bsdir/platform-$platformver $BUILD_DIR/bootstrap/platform-$platformver) && \
|
|
|
|
touch $bsdir.platform.compiled;
|
2012-02-18 07:25:51 +00:00
|
|
|
fi
|
2012-04-13 08:39:54 +00:00
|
|
|
# Haskell platform is compiled is compiled
|