#
# Update this to point to your GHC installation, then run the script.
#   It calls GHC to build the Process.hs module.
#
#   It also makes a dir 'hslibs' in this one, and fills it with links to your
#   Haskell libraries, so the XCode project can find them.
#
#   The version numbers are correct for GHC 7.0.3. For other versions you'll
#   need to update the library version numbers, as well as the linker flags
#   in XCode in Project/Edit Project Settings/Other Linker Flags.
# 
#   Run the script like:
#     sh ./CONFIGURE.sh
#
GHC_VERSION=ghc-7.0.3
INSTALL_GHC=/Users/benl/software/ghc-7.0.3/
INSTALL_CABAL=/Users/benl/.cabal

# ------------------------------------------------------------------
echo "** Building Process.hs"
ghc -threaded -rtsopts -Odph -fllvm -optlo-O3 -fno-liberate-case \
    -funfolding-use-threshold100 -funfolding-keeness-factor100 \
    -c Process.hs

# -----------------------------------------------------------------
echo
echo "** Creating hslibs dir, and adding links to Haskell libs."
mkdir hslibs
cd hslibs

LIB_GHC=$INSTALL_GHC/lib/$GHC_VERSION
LIB_CABAL=$INSTALL_CABAL/lib

# These libs come with the GHC install.
ln -s $LIB_GHC/libHSrts_thr.a
ln -s $LIB_GHC/libHSffi.a
ln -s $LIB_GHC/ghc-prim-0.2.0.0/libHSghc-prim-0.2.0.0.a
ln -s $LIB_GHC/integer-gmp-0.2.0.3/libHSinteger-gmp-0.2.0.3.a
ln -s $LIB_GHC/base-4.3.1.0/libHSbase-4.3.1.0.a .
ln -s $LIB_GHC/bytestring-0.9.1.10/libHSbytestring-0.9.1.10.a
ln -s $LIB_GHC/containers-0.4.0.0/libHScontainers-0.4.0.0.a
ln -s $LIB_GHC/pretty-1.0.1.2/libHSpretty-1.0.1.2.a
ln -s $LIB_GHC/template-haskell-2.5.0.0/libHStemplate-haskell-2.5.0.0.a

# These libs are installed by Cabal.
ln -s $LIB_CABAL/vector-0.7.0.1/$GHC_VERSION/libHSvector-0.7.0.1.a
ln -s $LIB_CABAL/repa-2.0.0.1/$GHC_VERSION/libHSrepa-2.0.0.1.a
ln -s $LIB_CABAL/repa-bytestring-2.0.0.1/$GHC_VERSION/libHSrepa-bytestring-2.0.0.1.a
ln -s $LIB_CABAL/primitive-0.3.1/$GHC_VERSION/libHSprimitive-0.3.1.a

cd ..


