--- trunk/core/include/haskell.sminc 2010/06/30 16:41:22 5494 +++ trunk/core/include/haskell.sminc 2010/07/01 15:34:38 5543 @@ -9,7 +9,7 @@ : ${HOMEPAGE="http://hackage.haskell.org/package/${PNAME/#haskell-/}"} # some sane default dependencies -DEPEND="${DEPEND} +SDEPEND="${SDEPEND} >= dev-lang/ghc-6.12" # default SRCFILE SRCDIR and SRC_URI @@ -21,9 +21,58 @@ mirror://${PNAME}/${SRCFILE} ) +# possible features which are supported atm +HASKELL_POSSIBLE_FEATURES="split-objs shared register haddock" +# default haskell features +HASKELL_FEATURES="split-objs shared register" + HASKELL_PNAME="${PNAME}" -SPECIAL_VARS="HASKELL_PNAME" -SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} haskell_preinstall haskell_postinstall haskell_preremove" +SPECIAL_VARS="${SPECIAL_VARS} HASKELL_PNAME" +SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} haskell_preinstall haskell_postinstall haskell_preremove haskell_postremove" + +haskell_feature() +{ + local search="$1" + local feature + for feature in ${HASKELL_FEATURES} + do + # feature was found + [[ ${search} = ${feature} ]] && return 0 + done + + # feature was *not* found + return 1 +} + +haskell_feature_is_supported() +{ + local search="$1" + local feature + for feature in ${HASKELL_POSSIBLE_FEATURES} + do + # feature was found + [[ ${search} = ${feature} ]] && return 0 + done + + # feature was *not* found + return 1 +} + +haskell_disable_feature() +{ + local feature="$1" + haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!" + echo -e "${COLBLUE}--- ${COLRED} disabled haskell feature '${feature}'${COLDEFAULT}" + export HASKELL_FEATURES="${HASKELL_FEATURES/${feature}/}" +} + +haskell_enable_feature() +{ + local feature="$1" + haskell_feature_is_supported "${feature}" || die "haskell feature '${feature}' not supported!" + echo -e "${COLBLUE}--- ${COLGREEN} enabled haskell feature '${feature}'${COLDEFAULT}" + export HASKELL_FEATURES+=" ${feature}" +} haskell_ghc_version() { @@ -67,6 +116,9 @@ { local configure_opts="$@" + haskell_feature split-objs && configure_opts+=" --enable-split-objs" + haskell_feature shared && configure_opts+=" --enable-shared" + runhaskell $(haskell_ghc_setup_script) configure \ --ghc \ --prefix=/usr \ @@ -78,21 +130,25 @@ || die } +haskell_src_build() +{ + runhaskell $(haskell_ghc_setup_script) build || die +} + haskell_src_compile() { cd ${SRCDIR} haskell_src_configure || die - runhaskell $(haskell_ghc_setup_script) build || die + haskell_src_build || die } haskell_src_install() { cd ${SRCDIR} - runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die # create register scripts - haskell_install_register || die + haskell_feature register && haskell_install_register || die # install docs local i @@ -133,4 +189,23 @@ # fi # } -export_inherits haskell src_prepare src_compile src_install preinstall postinstall #preremove +# to be on the safe side, fix all broken packages afer a package remove +haskell_postremove() +{ + if [[ -x $(which ghc-pkg) ]] + then + local broken="$(ghc-pkg check --simple-output)" + if [[ ! -z ${broken} ]] + then + echo "fixing broken haskell modules:" + local pkg + for pkg in ${broken} + do + echo " unregister ${pkg} ..." + ghc-pkg unregister ${pkg} + done + fi + fi +} + +export_inherits haskell src_prepare src_compile src_install preinstall postinstall postremove #preremove