#------------------------------------------------------------------------- ## Setup file detection function. #------------------------------------------------------------------------- function detect_setup_file() { if [ -r Setup.hs ] ; then echo Setup.hs elif [ -r Setup.lhs ] ; then echo Setup.lhs else message "${PROBLEM_COLOR}Cannot detect setup file!${DEFAULT_COLOR}" return 1 fi } #------------------------------------------------------------------------- ## Section-default build script. #------------------------------------------------------------------------- function default_build_haskell() { local setup_file && setup_file=$(detect_setup_file) && runhaskell $setup_file configure -O2 --enable-shared --enable-executable-dynamic \ --disable-library-vanilla --prefix=${INSTALL_ROOT}/usr \ --docdir=${INSTALL_ROOT}/usr/share/doc/$SPELL --global $OPTS && runhaskell $setup_file build -j${MAKE_NJOBS} || runhaskell $setup_file build && runhaskell $setup_file register --gen-script && runhaskell $setup_file unregister --gen-script && if [[ -f register.sh ]]; then sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh fi && if [[ -f unregister.sh ]]; then sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh fi } #------------------------------------------------------------------------- ## Section-default install script. #------------------------------------------------------------------------- function default_install_haskell() { local setup_file && local cabal_file && local share_dir && setup_file=$(detect_setup_file) && if [[ -f register.sh ]]; then install -D -m744 register.sh "$INSTALL_ROOT/usr/share/haskell/register/${SPELL}.sh" && install -D -m744 unregister.sh "$INSTALL_ROOT/usr/share/haskell/unregister/${SPELL}.sh" fi runhaskell $setup_file install && cabal_file=$(ls *.cabal) && share_dir=${INSTALL_ROOT}/usr/share/${SPELL} && mkdir -vp $share_dir && cp -v $cabal_file $share_dir } function default_build() { default_build_haskell } function default_install() { default_install_haskell }