# $Id$ # default includes sminclude mtools # some sane default values : ${PCATEGORIE="dev-haskell"} : ${DESCRIPTION="${PNAME}"} : ${HOMEPAGE="http://hackage.haskell.org/package/${PNAME/#haskell-/}"} # some sane default dependencies SDEPEND="${SDEPEND} >= dev-lang/ghc-6.12" # default SRCFILE SRCDIR and SRC_URI : ${SRCFILE="${PNAME/#haskell-/}-${PVER}.tar.gz"} : ${SRCDIR="${BUILDDIR}/${PNAME/#haskell-/}-${PVER}"} SRC_URI=( ${SRC_URI[*]} http://hackage.haskell.org/packages/archive/${PNAME/#haskell-/}/${PVER}/${SRCFILE} 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="${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() { local ver ver=$(ghc --numeric-version) echo "${ver}" } haskell_ghc_setup_script() { local setup if [[ -e Setup.lhs ]] then setup="Setup.lhs" elif [[ -e Setup.hs ]] then setup="Setup.hs" else die "unkown setup script" fi echo "${setup}" } haskell_install_register() { runhaskell $(haskell_ghc_setup_script) register --gen-script || die runhaskell $(haskell_ghc_setup_script) unregister --gen-script || die minstalldir /usr/share/haskell/${PNAME} || die minstallexec register.sh /usr/share/haskell/${PNAME} || die minstallexec unregister.sh /usr/share/haskell/${PNAME} || die } haskell_src_prepare() { munpack ${SRCFILE} || die } haskell_src_configure() { 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 \ --libdir=/usr/$(mlibdir) \ --libsubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \ --datadir=/usr/share \ --datasubdir=ghc-$(haskell_ghc_version)/${PNAME/#haskell-/}-${PVER} \ ${configure_opts} \ || die } haskell_src_build() { runhaskell $(haskell_ghc_setup_script) build || die } haskell_src_compile() { cd ${SRCDIR} haskell_src_configure || die haskell_src_build || die } haskell_src_install() { cd ${SRCDIR} runhaskell $(haskell_ghc_setup_script) copy --destdir=${BINDIR} || die # create register scripts haskell_feature register && haskell_install_register || die # install docs local i for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ FAQ LICENSE NEWS README TODO prologue.txt do if [ -f ${SRCDIR}/${i} ] then minstalldocs ${i} || die fi done } haskell_preinstall() { if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]] then echo "unregister haskell module ${HASKELL_PNAME} ..." ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh fi } haskell_postinstall() { if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh ]] then echo "register haskell module ${HASKELL_PNAME} ..." ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/register.sh fi } # haskell_preremove() # { # if [[ -x ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh ]] # then # echo "unregister haskell module ${HASKELL_PNAME} ..." # ${MROOT}/usr/share/haskell/${HASKELL_PNAME}/unregister.sh # fi # } # 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