Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 86 lines (82 sloc) 2.22 KB
#!/usr/bin/env sh
if [ "$GHC_TOP-x" == "-x" ]; then
echo "GHC_TOP environment variable must be set first"
exit 1
fi
case "$1" in
'list')
ls -l "$GHC_TOP/Versions" | awk '/dr.*/ { print $NF }'
;;
'init')
mkdir -p $GHC_TOP/Versions
mkdir -p $GHC_TOP/System
rm -rf $GHC_TOP/Common
mkdir -p $GHC_TOP/Common
curl http://www.haskell.org/cabal/release/cabal-install-1.18.0.2/cabal-install-1.18.0.2.tar.gz >> $GHC_TOP/Common/cabal-install.tar.gz
pushd .
cd $GHC_TOP/Common
tar -zxf cabal-install.tar.gz
mv cabal-install-1.18.0.2 cabal-install
popd
;;
'use')
rm -f "$GHC_TOP/Current"
rm -f "$GHC_TOP/Cabal"
ln -s "$GHC_TOP/Versions/$2" "$GHC_TOP/Current"
ln -s "$GHC_TOP/System/$2" "$GHC_TOP/Cabal"
;;
'site')
if [ -d "$GHC_TOP/Site" ]; then
ls -la $GHC_TOP/Site | awk -F '/' '{ print $NF }';
else
echo 'no active sites'
fi
;;
'env')
echo "Home: $GHC_TOP"
echo "Active Site: `ghc-env site`"
echo "Active Compiler: `ghc-env active`"
echo "Environment:"
set | grep --colour=never GHC_
set | grep --colour=never CABAL_
;;
'full-install')
PWD = "`pwd`"
cd "$3"
./configure --prefix=$GHC_TOP/Versions/$2
make install
ghc-env install
;;
'install')
case "$(uname -s)" in
Darwin) if [ ! "$4" ]; then
echo "You need to tweak/check your gcc toolchain. OSX >= 10.7 requires tweaking the GHC settings file and setting 'C compiler command' to the correct path."
echo "You can then run 'ghc-env install-ghc' to complete the installation."
else
echo "use sed to fix the setting file ourselves!!"
fi
;;
*) ghc-env install-ghc
esac
;;
'install-ghc')
ghc-env use "$2"
PWD="`pwd`"
cd $GHC_TOP/Common/cabal-install
env VERBOSE=-v PREFIX="$GHC_TOP/System/$2" ./bootstrap.sh
cd $PWD
cabal update
ghc-env install-dev
;;
'install-dev')
cabal install cabal-install --force-reinstalls
cabal install happy
cabal install ghc-mod
;;
'active')
ls -la $GHC_TOP/Current | awk -F '/' '{ print $NF }'
;;
*)
echo "Usage: $0 { list | use (version) | site | env | full-install | install | active }"
;;
esac