From 12f59fa61afda8fb1d9de3a0890d9d79732520ea Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Mon, 5 Nov 2007 10:27:49 +0000 Subject: Use new unified ghc ebuild for 6.2.2 and 6.4.2. (Portage version: 2.1.3.16) --- dev-lang/ghc/ChangeLog | 8 +- dev-lang/ghc/files/digest-ghc-6.2.2 | 13 ++ dev-lang/ghc/files/digest-ghc-6.4.2 | 25 +++ dev-lang/ghc/ghc-6.2.2.ebuild | 308 +++++++++++++++++---------- dev-lang/ghc/ghc-6.4.2.ebuild | 410 ++++++++++++++++++++++-------------- 5 files changed, 501 insertions(+), 263 deletions(-) (limited to 'dev-lang/ghc') diff --git a/dev-lang/ghc/ChangeLog b/dev-lang/ghc/ChangeLog index 0ea7614ed83f..9388fea2aa12 100644 --- a/dev-lang/ghc/ChangeLog +++ b/dev-lang/ghc/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for dev-lang/ghc # Copyright 2002-2007 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ChangeLog,v 1.139 2007/11/05 02:18:21 dcoutts Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ChangeLog,v 1.140 2007/11/05 10:27:49 dcoutts Exp $ + + 05 Nov 2007; Duncan Coutts ghc-6.2.2.ebuild, + ghc-6.4.2.ebuild: + Use new unified ghc ebuild for 6.2.2 and 6.4.2. This merges the + functionality of ghc-bin into the ghc ebuild and eliminates virtual/ghc. + To get the binary version emerge with the "binary" USE flag. 05 Nov 2007; Duncan Coutts ghc-6.6.1.ebuild: Add sparc and ppc binaries. Also fix some var quoting QA warnings. diff --git a/dev-lang/ghc/files/digest-ghc-6.2.2 b/dev-lang/ghc/files/digest-ghc-6.2.2 index b077d9b08c69..07a04d24f55f 100644 --- a/dev-lang/ghc/files/digest-ghc-6.2.2 +++ b/dev-lang/ghc/files/digest-ghc-6.2.2 @@ -1,3 +1,16 @@ +MD5 e81174308a2782ab83b23ef009ce44f2 ghc-6.2.2-libraries.tar.gz 524182 +RMD160 f4ce0df2040f91a5a56cc618e68f1aa2e4bf0185 ghc-6.2.2-libraries.tar.gz 524182 +SHA256 ebcf8c1fd31c9a33ff64ca888f01e9911464469f59e5432c626b8c686c2d9142 ghc-6.2.2-libraries.tar.gz 524182 MD5 42088bff4de30e7c3a277cfa55d5589e ghc-6.2.2-src.tar.bz2 5406427 RMD160 7afa370c148f2b9c3d53d662da996f5d7c05282d ghc-6.2.2-src.tar.bz2 5406427 SHA256 a0fe7eb8d447f25fbc616cdbce2bb4e03961a884c2c37969d1e23588b588a852 ghc-6.2.2-src.tar.bz2 5406427 +MD5 5475d32b4e26c5d67850808ff3032558 ghc-6.2.2-users_guide.tar.gz 197576 +RMD160 d17c2c89d03d911dfa0b449b47814d2e19dc6030 ghc-6.2.2-users_guide.tar.gz 197576 +SHA256 846df4bedf44f00a438a276c849289ce1b2d79f3fa53fb16d576517b2da1e509 ghc-6.2.2-users_guide.tar.gz 197576 +RMD160 4dda12e11ce31d395d1085e441171580832003f7 ghc-bin-6.2.2-r1-ppc.tbz2 21018465 +SHA256 453babea6a9c3d3382b9987f5e40d184dd3e591a7b1d1f6bd6d41984d94f4dd4 ghc-bin-6.2.2-r1-ppc.tbz2 21018465 +RMD160 0ba8ff87c91abcd43988c21df8537eec0932c6a3 ghc-bin-6.2.2-r1-sparc.tbz2 16189582 +SHA256 5d225e05e73cb85500b4a1860a4dd82adbb9edc4791d087341b4458e70022cc3 ghc-bin-6.2.2-r1-sparc.tbz2 16189582 +MD5 707ec1a9e6d298c2d357a1be031ead83 ghc-bin-6.2.2-r1-x86.tbz2 14561932 +RMD160 b8e6a08b269257689efdc95d698a9e2b86c6d3e3 ghc-bin-6.2.2-r1-x86.tbz2 14561932 +SHA256 24a4ea7fe9b8ba58f84e0d68012158e70972a1caacd482d6c84905bda4502f63 ghc-bin-6.2.2-r1-x86.tbz2 14561932 diff --git a/dev-lang/ghc/files/digest-ghc-6.4.2 b/dev-lang/ghc/files/digest-ghc-6.4.2 index 535bdc990220..005707551351 100644 --- a/dev-lang/ghc/files/digest-ghc-6.4.2 +++ b/dev-lang/ghc/files/digest-ghc-6.4.2 @@ -1,9 +1,34 @@ MD5 2719f349e10f883963ffe4b1537106b6 ghc-6.4.2-alut.patch.gz 6670 RMD160 e6ab2a114f44f6f176a98c9cd6ab1e336662a958 ghc-6.4.2-alut.patch.gz 6670 SHA256 e116b385df3bb5a5feb92ce92a92bdb0f24115361aedb1bddc9a7e6ce682d8b9 ghc-6.4.2-alut.patch.gz 6670 +MD5 da0c29eec955c2218a2434eaeda9dccd ghc-6.4.2-libraries.tar.gz 975364 +RMD160 e1f19920ba7cfbc92e52fb1e3a770cd6437482c1 ghc-6.4.2-libraries.tar.gz 975364 +SHA256 b1d492f1cb8b036f56e7df187730492a6dd993b5d9ce52e4bd42dbebc9044b51 ghc-6.4.2-libraries.tar.gz 975364 MD5 a394bf14e94c3bca5507d568fcc03375 ghc-6.4.2-src.tar.bz2 6954958 RMD160 19943eb2673e663973e64739cdf23720b6f36d38 ghc-6.4.2-src.tar.bz2 6954958 SHA256 d517e52e0204a077c54cda11b67bf9b6ac3daa47ac7bccf1561afc7c572e6be0 ghc-6.4.2-src.tar.bz2 6954958 +MD5 bf0aaab4470184d0587bde1428e2e984 ghc-6.4.2-users_guide.tar.gz 233341 +RMD160 0c0d7325b1535c6e248a25accd068085b8ff8880 ghc-6.4.2-users_guide.tar.gz 233341 +SHA256 8949148e37b6ec7fbbc82f7151ac26c3cadcfec1783e17f672fa527f7366ccdd ghc-6.4.2-users_guide.tar.gz 233341 +RMD160 f53968b2b9329dd4ffb15dfb64c3e7748e7fcfc2 ghc-bin-6.4.2-alpha.tbz2 30930863 +SHA256 8668d6b4d28a6567fb17665d41784c61576cabf6d80cf47c8b66d1f3f4178a3b ghc-bin-6.4.2-alpha.tbz2 30930863 +MD5 43a086bf746c332f30f379001d8a1ddf ghc-bin-6.4.2-amd64.tbz2 18554509 +RMD160 f4b9ee0041d2a005a1d2d98290dc89eb120c5939 ghc-bin-6.4.2-amd64.tbz2 18554509 +SHA256 8466a5f017a09d5bee2bd4f28cb0fa690cd2bf0f6c9fedd892624c7f1096d214 ghc-bin-6.4.2-amd64.tbz2 18554509 +RMD160 c20d9a783abcfdda1a69b63e941c9f5c1fd587a0 ghc-bin-6.4.2-hppa.tbz2 33914952 +SHA256 6c036e313b4d67ab4940e62a3719589c5e94591ac8fe96ed595796876dd4bd88 ghc-bin-6.4.2-hppa.tbz2 33914952 +RMD160 85f9a3f09e9f319cea0c8a253fdb03885ff7f13e ghc-bin-6.4.2-ia64.tbz2 28944776 +SHA256 7ac02b0277bbbc92aea4de150404ebf5b12445db197b08573446cad901638f12 ghc-bin-6.4.2-ia64.tbz2 28944776 +RMD160 3ee3b26a1b98ceb085a2ca12e9e9e791c245ba86 ghc-bin-6.4.2-ppc.tbz2 22994932 +SHA256 1239845ddaafe0bbfe8e24a13a6a7a7ba4462f313227e28d47beb644e876979c ghc-bin-6.4.2-ppc.tbz2 22994932 +RMD160 98f4e0800233d0b75c519be26b77fd2455fa167d ghc-bin-6.4.2-ppc64.tbz2 28817831 +SHA256 788a4c4e5730afd921bfe2c84c894b4190422a5d9e6d18d135de92976446d40a ghc-bin-6.4.2-ppc64.tbz2 28817831 +RMD160 fa8fa8d85a167db895ea74b9ce40590ceae503ab ghc-bin-6.4.2-sparc.tbz2 22175545 +SHA256 c95edaff53778edcfd275e41f70cadc2fd7e83c058b5d09e2a44081ae1c29d30 ghc-bin-6.4.2-sparc.tbz2 22175545 +RMD160 6071878b02b87066f8937b671d6414330a41a841 ghc-bin-6.4.2-x86-fbsd.tbz2 19091807 +SHA256 f2a397d233a491ab65ab43223e7657f7fc47311413e168bcd6a735e705c1acf3 ghc-bin-6.4.2-x86-fbsd.tbz2 19091807 +RMD160 5d3ad1b92c3785db1090799ee6da6182a4771248 ghc-bin-6.4.2-x86.tbz2 19367589 +SHA256 9628c3d3ca3c095c5c423cffb0d0daf801e518f6d6ace17c032c6ca6d5e3e24c ghc-bin-6.4.2-x86.tbz2 19367589 MD5 6d97897b1f5cef7bf4bdc7fa6745d853 ghc-testsuite-6.4.2.tar.gz 1181389 RMD160 1eea6a19a9fca6b3d56a6f29b69289cb88af8173 ghc-testsuite-6.4.2.tar.gz 1181389 SHA256 1a864243e922c233049585fa3bf4a86a0ca3e7b3ffebf26245eb037f15dd4d12 ghc-testsuite-6.4.2.tar.gz 1181389 diff --git a/dev-lang/ghc/ghc-6.2.2.ebuild b/dev-lang/ghc/ghc-6.2.2.ebuild index fa8bedac8ada..786ebf57ae59 100644 --- a/dev-lang/ghc/ghc-6.2.2.ebuild +++ b/dev-lang/ghc/ghc-6.2.2.ebuild @@ -1,18 +1,20 @@ # Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ghc-6.2.2.ebuild,v 1.24 2007/11/05 02:18:21 dcoutts Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ghc-6.2.2.ebuild,v 1.25 2007/11/05 10:27:49 dcoutts Exp $ # Brief explanation of the bootstrap logic: # -# ghc requires ghc-bin to bootstrap. -# Therefore, -# (1) both ghc-bin and ghc provide virtual/ghc -# (2) virtual/ghc *must* default to ghc-bin -# (3) ghc depends on virtual/ghc +# Previous ghc ebuilds have been split into two: ghc and ghc-bin, +# where ghc-bin was primarily used for bootstrapping purposes. +# From now on, these two ebuilds have been combined, with the +# binary USE flag used to determine whether or not the pre-built +# binary package should be emerged or whether ghc should be compiled +# from source. If the latter, then the relevant ghc-bin for the +# arch in question will be used in the working directory to compile +# ghc from source. # -# This solution has the advantage that the binary distribution -# can be removed once an forall after the first succesful install -# of ghc. +# This solution has the advantage of allowing us to retain the one +# ebuild for both packages, and thus phase out virtual/ghc. # Note to users of hardened gcc-3.x: # @@ -31,42 +33,35 @@ inherit base eutils flag-o-matic toolchain-funcs ghc-package DESCRIPTION="The Glasgow Haskell Compiler" HOMEPAGE="http://www.haskell.org/ghc/" -SRC_URI="http://www.haskell.org/ghc/dist/${PV}/ghc-${PV}-src.tar.bz2" +SRC_URI="!binary? ( http://haskell.org/ghc/dist/${PV}/${P}-src.tar.bz2 ) + doc? ( mirror://gentoo/${P}-libraries.tar.gz + mirror://gentoo/${P}-users_guide.tar.gz ) + ppc? ( mirror://gentoo/ghc-bin-${PV}-r1-ppc.tbz2 ) + sparc? ( mirror://gentoo/ghc-bin-${PV}-r1-sparc.tbz2 ) + x86? ( mirror://gentoo/ghc-bin-${PV}-r1-x86.tbz2 )" -LICENSE="as-is" +LICENSE="BSD" SLOT="0" KEYWORDS="-* ppc sparc x86" -IUSE="doc opengl" +IUSE="binary doc ghcbootstrap opengl" + +LOC="/opt/ghc" # location for installation of binary version PROVIDE="virtual/ghc" RDEPEND=" + !dev-lang/ghc-bin >=sys-devel/gcc-2.95.3 >=sys-devel/binutils-2.17 >=dev-lang/perl-5.6.1 >=dev-libs/gmp-4.1 - >=sys-libs/readline-4.2 + =sys-libs/readline-5* opengl? ( virtual/opengl virtual/glu virtual/glut )" -# ghc cannot usually be bootstrapped using later versions ... -DEPEND="${RDEPEND} - =virtual/ghc-6.4 - doc? ( ~app-text/docbook-sgml-dtd-3.1 - >=app-text/docbook-dsssl-stylesheets-1.64 - >=app-text/openjade-1.3.1 - >=app-text/sgml-common-0.6.3 - >=dev-haskell/haddock-0.6-r2 )" - -pkg_setup() { - if test $(gcc-major-version) -gt 3; then - eerror "ghc-6.2.2 does not work with gcc-4.x, only 3.x or older" - eerror "You can either use gcc-config to switch to gcc-3.x" - eerror "or you emerge '>=dev-lang/ghc-6.4' or later." - die "ghc-6.2.2 does not work with gcc-4.x, only 3.x or older" - fi -} +DEPEND="${RDEPEND}" +# In the ghcbootstrap case we rely on the developer having +# >=ghc-5.04.3 on their $PATH already append-ghc-cflags() { local flag compile assemble link @@ -118,113 +113,208 @@ ghc_setup_cflags() { gcc-specs-ssp && append-ghc-cflags compile -fno-stack-protector } -ghc_setup_wrapper() { - echo '#!/bin/sh' - echo "GHCBIN=\"$(ghc-libdir)/ghc-$1\";" - echo "TOPDIROPT=\"-B$(ghc-libdir)\";" - echo "GHC_CFLAGS=\"${GHC_CFLAGS}\";" - echo '# Mini-driver for GHC' - echo 'exec $GHCBIN $TOPDIROPT $GHC_CFLAGS ${1+"$@"}' +pkg_setup() { + if test $(gcc-major-version) -gt 3; then + eerror "ghc-6.2.2 does not work with gcc-4.x, only 3.x or older" + eerror "You can either use gcc-config to switch to gcc-3.x" + eerror "or you emerge '>=dev-lang/ghc-6.4' or later." + die "ghc-6.2.2 does not work with gcc-4.x, only 3.x or older" + fi + + if use ghcbootstrap; then + ewarn "You requested ghc bootstrapping, this is usually only used" + ewarn "by Gentoo developers to make binary .tbz2 packages for" + ewarn "use with the ghc ebuild's USE=\"binary\" feature." + use binary && \ + die "USE=\"ghcbootstrap binary\" is not a valid combination." + use doc && \ + die "USE=\"ghcbootstrap doc\" is not a valid combination" + [[ -z $(type -P ghc) ]] && \ + die "Could not find a ghc to bootstrap with." + fi + + if use binary; then + if use opengl || use doc; then + ewarn "The binary build does not include the docs or OpenGL bindings" + ewarn "If you want those features, emerge with USE=\"-binary\"" + fi + fi + + set_config +} + +set_config() { + # make this a separate function and call it several times as portage doesn't + # remember the variables properly between the fuctions. + use binary && GHC_PREFIX="/opt/ghc" || GHC_PREFIX="/usr" } src_unpack() { + # Create the ${S} dir if we're using the binary version + use binary && mkdir "${S}" + base_src_unpack ghc_setup_cflags - # Modify the ghc driver script to use GHC_CFLAGS - echo "SCRIPT_SUBST_VARS += GHC_CFLAGS" >> "${S}/ghc/driver/ghc/Makefile" - echo "GHC_CFLAGS = ${GHC_CFLAGS}" >> "${S}/ghc/driver/ghc/Makefile" - sed -i -e 's|$TOPDIROPT|$TOPDIROPT $GHC_CFLAGS|' "${S}/ghc/driver/ghc/ghc.sh" + if use binary; then + + # Move unpacked files to the expected place + mv "${WORKDIR}/usr" "${S}" - # Patch to fix a mis-compilation in the rts due to strict aliasing, - # should be fixed upstream for 6.4.3 and 6.6. Fixes bug #135651. - echo 'GC_HC_OPTS += -optc-fno-strict-aliasing' >> "${S}/ghc/rts/Makefile" + # Relocate from /usr to /opt/ghc + sed -i -e "s|/usr|${LOC}|g" \ + "${S}/usr/bin/ghc-${PV}" \ + "${S}/usr/bin/ghci-${PV}" \ + "${S}/usr/bin/ghc-pkg-${PV}" \ + "${S}/usr/bin/hsc2hs" \ + "${S}/usr/$(get_libdir)/${P}/package.conf" \ + || die "Relocating ghc from /usr to /opt/ghc failed" - # Don't strip binaries on install. See QA warnings in bug #140369. - sed -i -e 's/SRC_INSTALL_BIN_OPTS += -s//' "${S}/mk/config.mk.in" + sed -i -e "s|/usr/$(get_libdir)|${LOC}/$(get_libdir)|" \ + "${S}/usr/bin/ghcprof" + + else + # Modify the ghc driver script to use GHC_CFLAGS + echo "SCRIPT_SUBST_VARS += GHC_CFLAGS" >> "${S}/ghc/driver/ghc/Makefile" + echo "GHC_CFLAGS = ${GHC_CFLAGS}" >> "${S}/ghc/driver/ghc/Makefile" + sed -i -e 's|$TOPDIROPT|$TOPDIROPT $GHC_CFLAGS|' "${S}/ghc/driver/ghc/ghc.sh" + + if ! use ghcbootstrap; then + # Relocate from /usr to ${WORKDIR}/usr + sed -i -e "s|/usr|${WORKDIR}/usr|g" \ + "${WORKDIR}/usr/bin/ghc-${PV}" \ + "${WORKDIR}/usr/bin/ghci-${PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${PV}" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/$(get_libdir)/${P}/package.conf" \ + || die "Relocating ghc from /usr to workdir failed" + fi + + # Patch to fix a mis-compilation in the rts due to strict aliasing, + # should be fixed upstream for 6.4.3 and 6.6. Fixes bug #135651. + echo 'GC_HC_OPTS += -optc-fno-strict-aliasing' >> "${S}/ghc/rts/Makefile" + + # Don't strip binaries on install. See QA warnings in bug #140369. + sed -i -e 's/SRC_INSTALL_BIN_OPTS += -s//' "${S}/mk/config.mk.in" + fi } src_compile() { - # initialize build.mk - echo '# Gentoo changes' > mk/build.mk + if ! use binary; then - # We also need to use the GHC_CFLAGS flags when building ghc itself - echo "SRC_HC_OPTS+=${GHC_CFLAGS}" >> mk/build.mk - echo "SRC_CC_OPTS+=${CFLAGS} -Wa,--noexecstack" >> mk/build.mk + # initialize build.mk + echo '# Gentoo changes' > mk/build.mk - # determine what to do with documentation - if use doc; then - echo SGMLDocWays="html" >> mk/build.mk - else + # We also need to use the GHC_CFLAGS flags when building ghc itself + echo "SRC_HC_OPTS+=${GHC_CFLAGS}" >> mk/build.mk + echo "SRC_CC_OPTS+=${CFLAGS} -Wa,--noexecstack" >> mk/build.mk + + # We can't depend on haddock so we never build docs + # and we rely on pre-built ones instead echo SGMLDocWays="" >> mk/build.mk # needed to prevent haddock from being called echo NO_HADDOCK_DOCS=YES >> mk/build.mk - fi - # circumvent a very strange bug that seems related with ghc producing too much - # output while being filtered through tee (e.g. due to portage logging) - # reported as bug #111183 - echo "SRC_HC_OPTS+=-fno-warn-deprecations" >> mk/build.mk + # circumvent a very strange bug that seems related with ghc producing too much + # output while being filtered through tee (e.g. due to portage logging) + # reported as bug #111183 + echo "SRC_HC_OPTS+=-fno-warn-deprecations" >> mk/build.mk - # Required for some architectures, because they don't support ghc fully ... - use ppc || use sparc && echo "SplitObjs=NO" >> mk/build.mk - use sparc && echo "GhcWithInterpreter=NO" >> mk/build.mk + # Required for some architectures, because they don't support ghc fully ... + use ppc || use sparc && echo "SplitObjs=NO" >> mk/build.mk + use sparc && echo "GhcWithInterpreter=NO" >> mk/build.mk - GHC_CFLAGS="" ghc_setup_wrapper $(ghc-version) > "${T}/ghc.sh" - chmod +x "${T}/ghc.sh" + # Get ghc from the unpacked binary .tbz2 + # except when bootstrapping we just pick ghc up off the path + use ghcbootstrap || \ + export PATH="${WORKDIR}/usr/bin:${PATH}" - # unset SGML_CATALOG_FILES because documentation installation - # breaks otherwise ... - SGML_CATALOG_FILES="" econf \ - --with-ghc="${T}/ghc.sh" \ - $(use_enable opengl hopengl) \ - || die "econf failed" + # Note that --disable-hopengl actually enables it. We have to ommit + # the flag to disable opengl. + econf \ + $(use opengl && echo "--enable-hopengl") \ + || die "econf failed" - # ghc-6.2.x build system does not support parallel make - emake -j1 datadir="/usr/share/doc/${PF}" || die "make failed" - # the explicit datadir is required to make the haddock entries - # in the package.conf file point to the right place ... + # ghc-6.2.x build system does not support parallel make + emake -j1 datadir="/usr/share/doc/${P}" || die "make failed" + # the explicit datadir is required to make the haddock entries + # in the package.conf file point to the right place ... + fi # ! use binary } -src_install () { - local insttarget - - insttarget="install" - use doc && insttarget="${insttarget} install-docs" - - # the libdir0 setting is needed for amd64, and does not - # harm for other arches - emake -j1 ${insttarget} \ - prefix="${D}/usr" \ - datadir="${D}/usr/share/doc/${PF}" \ - infodir="${D}/usr/share/info" \ - mandir="${D}/usr/share/man" \ - libdir0="${D}/usr/$(get_libdir)" \ - || die "make ${insttarget} failed" - - #need to remove ${D} from ghcprof script - # TODO: does this actually work? - cd "${D}/usr/bin" - mv ghcprof ghcprof-orig - sed -e 's:$FPTOOLS_TOP_ABS:#$FPTOOLS_TOP_ABS:' ghcprof-orig > ghcprof - chmod a+x ghcprof - rm -f ghcprof-orig - - cd "${S}/ghc" - dodoc README ANNOUNCE LICENSE VERSION - - dosbin "${FILESDIR}/ghc-updater" +src_install() { + if use binary; then + mkdir "${D}/opt" + mv "${S}/usr" "${D}/opt/ghc" + + cp -p "${D}/${GHC_PREFIX}/$(get_libdir)/${P}/package.conf"{,.shipped} \ + || die "failed to copy package.conf" + + doenvd "${FILESDIR}/10ghc" + else + # the libdir0 setting is needed for amd64, and does not + # harm for other arches + #TODO: are any of these overrides still required? isn't econf enough? + emake -j1 install \ + prefix="${D}/usr" \ + datadir="${D}/usr/share/doc/${PF}" \ + infodir="${D}/usr/share/info" \ + mandir="${D}/usr/share/man" \ + libdir0="${D}/usr/$(get_libdir)" \ + || die "make install failed" + + cd "${S}/ghc" + dodoc README ANNOUNCE LICENSE VERSION + + dosbin "${FILESDIR}/ghc-updater" + + cp -p "${D}/${GHC_PREFIX}/$(get_libdir)/${P}/package.conf"{,.shipped} \ + || die "failed to copy package.conf" + fi + + if use doc; then + docinto "html/libraries" + dohtml -A haddock -r "${WORKDIR}/libraries/"* \ + || die "installing library docs failed" + docinto "html/users_guide" + dohtml -r "${WORKDIR}/users_guide/"* \ + || die "installing user guide failed" + docinto "" + fi } pkg_postinst () { ghc-reregister - elog "If you have dev-lang/ghc-bin installed, you might" - elog "want to unmerge it. It is no longer needed." - elog + + if use binary; then + elog "The envirenment has been set to use the binary distribution of" + elog "GHC. In order to activate it please run:" + elog " env-update && source /etc/profile" + elog "Otherwise this setting will become active the next time you login" + fi + ewarn "IMPORTANT:" ewarn "If you have upgraded from another version of ghc or" - ewarn "if you have switched from ghc-bin to ghc, please run:" - ewarn " /usr/sbin/ghc-updater" + ewarn "if you have switched between binary and source versions" + ewarn "of ghc, please run:" + if use binary; then + ewarn " /opt/ghc/sbin/ghc-updater" + else + ewarn " /usr/sbin/ghc-updater" + fi ewarn "to re-merge all ghc-based Haskell libraries." } + +pkg_prerm() { + # Overwrite the (potentially) modified package.conf with a copy of the + # original one, so that it will be removed during uninstall. + + set_config # load GHC_PREFIX + + PKG="${ROOT}/${GHC_PREFIX}/$(get_libdir)/${P}/package.conf" + + cp -p "${PKG}"{.shipped,} + + [[ -f ${PKG}.old ]] && rm "${PKG}.old" +} diff --git a/dev-lang/ghc/ghc-6.4.2.ebuild b/dev-lang/ghc/ghc-6.4.2.ebuild index 8b29141f47f9..d881731e4ea8 100644 --- a/dev-lang/ghc/ghc-6.4.2.ebuild +++ b/dev-lang/ghc/ghc-6.4.2.ebuild @@ -1,18 +1,20 @@ # Copyright 1999-2007 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ghc-6.4.2.ebuild,v 1.22 2007/11/05 02:18:21 dcoutts Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ghc-6.4.2.ebuild,v 1.23 2007/11/05 10:27:49 dcoutts Exp $ # Brief explanation of the bootstrap logic: # -# ghc requires ghc-bin to bootstrap. -# Therefore, -# (1) both ghc-bin and ghc provide virtual/ghc -# (2) virtual/ghc *must* default to ghc-bin -# (3) ghc depends on virtual/ghc +# Previous ghc ebuilds have been split into two: ghc and ghc-bin, +# where ghc-bin was primarily used for bootstrapping purposes. +# From now on, these two ebuilds have been combined, with the +# binary USE flag used to determine whether or not the pre-built +# binary package should be emerged or whether ghc should be compiled +# from source. If the latter, then the relevant ghc-bin for the +# arch in question will be used in the working directory to compile +# ghc from source. # -# This solution has the advantage that the binary distribution -# can be removed once an forall after the first succesful install -# of ghc. +# This solution has the advantage of allowing us to retain the one +# ebuild for both packages, and thus phase out virtual/ghc. # Note to users of hardened gcc-3.x: # @@ -26,7 +28,7 @@ # re-emerge ghc (or ghc-bin). People using vanilla gcc can switch between # gcc-3.x and 4.x with no problems. -inherit base eutils flag-o-matic toolchain-funcs autotools ghc-package check-reqs +inherit base eutils flag-o-matic toolchain-funcs autotools ghc-package DESCRIPTION="The Glasgow Haskell Compiler" HOMEPAGE="http://www.haskell.org/ghc/" @@ -38,60 +40,49 @@ MY_P="${PN}-${MY_PV}" EXTRA_SRC_URI="${MY_PV}" [[ -z "${IS_SNAPSHOT}" ]] && EXTRA_SRC_URI="stable/dist" -SRC_URI="http://www.haskell.org/ghc/dist/${EXTRA_SRC_URI}/${MY_P}-src.tar.bz2 - test? ( http://haskell.org/ghc/dist/ghc-testsuite-${MY_PV}.tar.gz ) - mirror://gentoo/${P}-alut.patch.gz" - -LICENSE="as-is" +SRC_URI="!binary? ( http://haskell.org/ghc/dist/${EXTRA_SRC_URI}/${MY_P}-src.tar.bz2 ) + doc? ( mirror://gentoo/${P}-libraries.tar.gz + mirror://gentoo/${P}-users_guide.tar.gz ) + alpha? ( mirror://gentoo/ghc-bin-${PV}-alpha.tbz2 ) + amd64? ( mirror://gentoo/ghc-bin-${PV}-amd64.tbz2 ) + hppa? ( mirror://gentoo/ghc-bin-${PV}-hppa.tbz2 ) + ia64? ( mirror://gentoo/ghc-bin-${PV}-ia64.tbz2 ) + ppc? ( mirror://gentoo/ghc-bin-${PV}-ppc.tbz2 ) + ppc64? ( mirror://gentoo/ghc-bin-${PV}-ppc64.tbz2 ) + sparc? ( mirror://gentoo/ghc-bin-${PV}-sparc.tbz2 ) + x86? ( mirror://gentoo/ghc-bin-${PV}-x86.tbz2 ) + x86-fbsd? ( mirror://gentoo/ghc-bin-${PV}-x86-fbsd.tbz2 ) + test? ( http://haskell.org/ghc/dist/ghc-testsuite-${MY_PV}.tar.gz ) + mirror://gentoo/${P}-alut.patch.gz" + +LICENSE="BSD" SLOT="0" KEYWORDS="~alpha amd64 hppa ~ia64 ppc ppc64 sparc x86 ~x86-fbsd" -IUSE="test doc X opengl openal" +IUSE="binary doc ghcbootstrap test X opengl openal" +LOC="/opt/ghc" # location for installation of binary version S="${WORKDIR}/${MY_P}" PROVIDE="virtual/ghc" RDEPEND=" + !dev-lang/ghc-bin >=sys-devel/gcc-2.95.3 >=sys-devel/binutils-2.17 >=dev-lang/perl-5.6.1 >=dev-libs/gmp-4.1 - >=sys-libs/readline-4.2 - X? ( x11-libs/libX11 ) + =sys-libs/readline-5* + X? ( || ( x11-libs/libX11 virtual/x11 ) ) opengl? ( virtual/opengl virtual/glu virtual/glut openal? ( media-libs/openal media-libs/freealut ) )" -# ghc cannot usually be bootstrapped using later versions ... -DEPEND="${RDEPEND} - =virtual/ghc-6.6 - doc? ( ~app-text/docbook-xml-dtd-4.2 - app-text/docbook-xsl-stylesheets - >=dev-libs/libxslt-1.1.2 - >=dev-haskell/haddock-0.6-r2 )" +DEPEND="${RDEPEND}" +# In the ghcbootstrap case we rely on the developer having +# >=ghc-5.04.3 on their $PATH already PDEPEND=">=dev-haskell/cabal-1.1.4" -pkg_setup() { - if use openal && ! use opengl; then - ewarn "The OpenAL bindings require the OpenGL bindings, however" - ewarn "USE=\"-opengl\" so the OpenAL bindings will not be built." - ewarn "To build the OpenAL bindings emerge with USE=\"openal opengl\"" - fi - - # Portage's resolution of virtuals fails on virtual/ghc in some Portage - # releases, the following function causes the build to fail with an - # informative error message in such a case. - #if ! has_version virtual/ghc; then - # eerror "This ebuild needs a version of GHC to bootstrap from." - # eerror "Please emerge dev-lang/ghc-bin to get a binary version." - # eerror "You can either use the binary version directly or emerge" - # eerror "dev-lang/ghc afterwards." - # die "virtual/ghc version required to build" - #fi -} - append-ghc-cflags() { local flag compile assemble link for flag in $*; do @@ -146,130 +137,220 @@ ghc_setup_cflags() { append-ghc-cflags assemble "-Wa,--noexecstack" } -ghc_setup_wrapper() { - echo '#!/bin/sh' - echo "GHCBIN=\"$(ghc-libdir)/ghc-$1\";" - echo "TOPDIROPT=\"-B$(ghc-libdir)\";" - echo "GHC_CFLAGS=\"${GHC_CFLAGS}\";" - echo '# Mini-driver for GHC' - echo 'exec $GHCBIN $TOPDIROPT $GHC_CFLAGS ${1+"$@"}' +pkg_setup() { + if use ghcbootstrap; then + ewarn "You requested ghc bootstrapping, this is usually only used" + ewarn "by Gentoo developers to make binary .tbz2 packages for" + ewarn "use with the ghc ebuild's USE=\"binary\" feature." + use binary && \ + die "USE=\"ghcbootstrap binary\" is not a valid combination." + use doc && \ + die "USE=\"ghcbootstrap doc\" is not a valid combination" + [[ -z $(type -P ghc) ]] && \ + die "Could not find a ghc to bootstrap with." + fi + + if use openal && ! use opengl; then + ewarn "The OpenAL bindings require the OpenGL bindings, however" + ewarn "USE=\"-opengl\" so the OpenAL bindings will not be built." + ewarn "To build the OpenAL bindings emerge with USE=\"openal opengl\"" + fi + + if use binary; then + if use opengl || use openal || use X || use test; then + ewarn "The binary build does not include the X, OpenGL" + ewarn "or OpenAL bindings and does not support the testsuite." + ewarn "If you want those features, emerge with USE=\"-binary\"" + fi + fi + + set_config +} + +set_config() { + # make this a separate function and call it several times as portage doesn't + # remember the variables properly between the fuctions. + use binary && GHC_PREFIX="/opt/ghc" || GHC_PREFIX="/usr" } src_unpack() { + # Create the ${S} dir if we're using the binary version + use binary && mkdir "${S}" + base_src_unpack ghc_setup_cflags - cd "${S}" - epatch "${WORKDIR}/${P}-alut.patch" - epatch "${FILESDIR}/${P}-sparc32plus.patch" - epatch "${FILESDIR}/${P}-sparcmangler.patch" + if use binary; then - # Modify the ghc driver script to use GHC_CFLAGS - echo "SCRIPT_SUBST_VARS += GHC_CFLAGS" >> "${S}/ghc/driver/ghc/Makefile" - echo "GHC_CFLAGS = ${GHC_CFLAGS}" >> "${S}/ghc/driver/ghc/Makefile" - sed -i -e 's|$TOPDIROPT|$TOPDIROPT $GHC_CFLAGS|' "${S}/ghc/driver/ghc/ghc.sh" + # Move unpacked files to the expected place + mv "${WORKDIR}/usr" "${S}" - # If we're using the testsuite then move it to into the build tree - use test && mv "${WORKDIR}/testsuite" "${S}/" + # Relocate from /usr to /opt/ghc + sed -i -e "s|/usr|${LOC}|g" \ + "${S}/usr/bin/ghc-${PV}" \ + "${S}/usr/bin/ghci-${PV}" \ + "${S}/usr/bin/ghc-pkg-${PV}" \ + "${S}/usr/bin/hsc2hs" \ + "${S}/usr/$(get_libdir)/${P}/package.conf" \ + || die "Relocating ghc from /usr to /opt/ghc failed" - # Patch to fix a mis-compilation in the rts due to strict aliasing, - # should be fixed upstream for 6.4.3 and 6.6. Fixes bug #135651. - echo 'GC_HC_OPTS += -optc-fno-strict-aliasing' >> "${S}/ghc/rts/Makefile" - # Don't strip binaries on install. See QA warnings in bug #140369. - sed -i -e 's/SRC_INSTALL_BIN_OPTS += -s//' "${S}/mk/config.mk.in" -} + # fix docs + if use doc; then + # correct the documentation and .haddock files path + sed -i -e \ + "s|/opt/ghc/share/doc/${P}/html/libraries|/usr/share/doc/${P}/html/libraries|g" \ + "${S}/usr/$(get_libdir)/${P}/package.conf" + else + # remove all doc stuff from package.conf + sed -i \ + -e 's|haddockInterfaces = \[[^]]*\]|haddockInterfaces = \[\]|g' \ + -e "s|haddockHTMLs = \[[^]]*\]|haddockHTMLs = \[\]|g" \ + "${S}/usr/$(get_libdir)/${P}/package.conf" + fi + + sed -i -e "s|/usr/$(get_libdir)|${LOC}/$(get_libdir)|" \ + "${S}/usr/bin/ghcprof" -src_compile() { - # initialize build.mk - echo '# Gentoo changes' > mk/build.mk - - # We also need to use the GHC_CFLAGS flags when building ghc itself - echo "SRC_HC_OPTS+=${GHC_CFLAGS}" >> mk/build.mk - echo "SRC_CC_OPTS+=${CFLAGS} -Wa,--noexecstack" >> mk/build.mk - - # If you need to do a quick build then enable this bit and add debug to IUSE - #if use debug; then - # echo "SRC_HC_OPTS = -H32m -O0" >> mk/build.mk - # echo "GhcStage1HcOpts =" >> mk/build.mk - # echo "GhcLibHcOpts =" >> mk/build.mk - # echo "GhcLibWays =" >> mk/build.mk - # echo "SplitObjs = NO" >> mk/build.mk - #fi - - # determine what to do with documentation - if use doc; then - echo XMLDocWays="html" >> mk/build.mk else - echo XMLDocWays="" >> mk/build.mk - # needed to prevent haddock from being called - echo NO_HADDOCK_DOCS=YES >> mk/build.mk - fi - # circumvent a very strange bug that seems related with ghc producing too much - # output while being filtered through tee (e.g. due to portage logging) - # reported as bug #111183 - echo "SRC_HC_OPTS+=-fno-warn-deprecations" >> mk/build.mk + cd "${S}" + epatch "${WORKDIR}/${P}-alut.patch" + epatch "${FILESDIR}/${P}-sparc32plus.patch" + epatch "${FILESDIR}/${P}-sparcmangler.patch" + + # Modify the ghc driver script to use GHC_CFLAGS + echo "SCRIPT_SUBST_VARS += GHC_CFLAGS" >> "${S}/ghc/driver/ghc/Makefile" + echo "GHC_CFLAGS = ${GHC_CFLAGS}" >> "${S}/ghc/driver/ghc/Makefile" + sed -i -e 's|$TOPDIROPT|$TOPDIROPT $GHC_CFLAGS|' "${S}/ghc/driver/ghc/ghc.sh" + + if ! use ghcbootstrap; then + # Relocate from /usr to ${WORKDIR}/usr + sed -i -e "s|/usr|${WORKDIR}/usr|g" \ + "${WORKDIR}/usr/bin/ghc-${PV}" \ + "${WORKDIR}/usr/bin/ghci-${PV}" \ + "${WORKDIR}/usr/bin/ghc-pkg-${PV}" \ + "${WORKDIR}/usr/bin/hsc2hs" \ + "${WORKDIR}/usr/$(get_libdir)/${P}/package.conf" \ + || die "Relocating ghc from /usr to workdir failed" + fi - # And some arches used to work ok, but bork with recent gcc versions - # See bug #145466 for ppc64. - if use ia64 || use ppc64; then - echo "GhcUnregisterised=YES" >> mk/build.mk - echo "GhcRTSWays := debug" >> mk/build.mk - fi + # If we're using the testsuite then move it to into the build tree + use test && mv "${WORKDIR}/testsuite" "${S}/" - GHC_CFLAGS="" ghc_setup_wrapper $(ghc-version) > "${T}/ghc.sh" - chmod +x "${T}/ghc.sh" + # Patch to fix a mis-compilation in the rts due to strict aliasing, + # should be fixed upstream for 6.4.3 and 6.6. Fixes bug #135651. + echo 'GC_HC_OPTS += -optc-fno-strict-aliasing' >> "${S}/ghc/rts/Makefile" - # We've patched some configure.ac files to fix the OpenAL/ALUT bindings. - # So we need to autoreconf. - eautoreconf + # Don't strip binaries on install. See QA warnings in bug #140369. + sed -i -e 's/SRC_INSTALL_BIN_OPTS += -s//' "${S}/mk/config.mk.in" + fi +} - econf \ - --with-ghc="${T}/ghc.sh" \ - $(use_enable opengl opengl) \ - $(use_enable opengl glut) \ - $(use openal && use opengl \ - && echo --enable-openal --enable-alut \ - || echo --disable-openal --disable-alut) \ - $(use_enable X x11) \ - $(use_enable X hgl) \ - || die "econf failed" +src_compile() { + if ! use binary; then + + # initialize build.mk + echo '# Gentoo changes' > mk/build.mk + + # We also need to use the GHC_CFLAGS flags when building ghc itself + echo "SRC_HC_OPTS+=${GHC_CFLAGS}" >> mk/build.mk + echo "SRC_CC_OPTS+=${CFLAGS} -Wa,--noexecstack" >> mk/build.mk + + # If you need to do a quick build then enable this bit and add debug to IUSE + #if use debug; then + # echo "SRC_HC_OPTS = -H32m -O -fasm" >> mk/build.mk + # echo "GhcLibHcOpts =" >> mk/build.mk + # echo "GhcLibWays =" >> mk/build.mk + # echo "SplitObjs = NO" >> mk/build.mk + #fi + + # We can't depend on haddock so we never build docs + # and we rely on pre-built ones instead + echo SGMLDocWays="" >> mk/build.mk + # needed to prevent haddock from being called + echo NO_HADDOCK_DOCS=YES >> mk/build.mk - emake all datadir="/usr/share/doc/${PF}" || die "make failed" - # the explicit datadir is required to make the haddock entries - # in the package.conf file point to the right place ... + # circumvent a very strange bug that seems related with ghc producing too much + # output while being filtered through tee (e.g. due to portage logging) + # reported as bug #111183 + echo "SRC_HC_OPTS+=-fno-warn-deprecations" >> mk/build.mk + + # And some arches used to work ok, but bork with recent gcc versions + # See bug #145466 for ppc64. + if use ia64 || use ppc64; then + echo "GhcUnregisterised=YES" >> mk/build.mk + echo "GhcWithNativeCodeGen=NO" >> mk/build.mk + echo "GhcWithInterpreter=NO" >> mk/build.mk + echo "SplitObjs=NO" >> mk/build.mk + echo "GhcRTSWays := debug" >> mk/build.mk + fi + # We've patched some configure.ac files to fix the OpenAL/ALUT bindings. + # So we need to autoreconf. + eautoreconf + + # Get ghc from the unpacked binary .tbz2 + # except when bootstrapping we just pick ghc up off the path + use ghcbootstrap || \ + export PATH="${WORKDIR}/usr/bin:${PATH}" + + econf \ + $(use_enable opengl opengl) \ + $(use_enable opengl glut) \ + $(use openal && use opengl \ + && echo --enable-openal --enable-alut \ + || echo --disable-openal --disable-alut) \ + $(use_enable X x11) \ + $(use_enable X hgl) \ + || die "econf failed" + + emake all datadir="/usr/share/doc/${P}" || die "make failed" + # the explicit datadir is required to make the haddock entries + # in the package.conf file point to the right place ... + + fi # ! use binary } -src_install () { - local insttarget - - insttarget="install" - use doc && insttarget="${insttarget} install-docs" - - # the libdir0 setting is needed for amd64, and does not - # harm for other arches - emake -j1 ${insttarget} \ - prefix="${D}/usr" \ - datadir="${D}/usr/share/doc/${PF}" \ - infodir="${D}/usr/share/info" \ - mandir="${D}/usr/share/man" \ - libdir0="${D}/usr/$(get_libdir)" \ - || die "make ${insttarget} failed" - - #need to remove ${D} from ghcprof script - # TODO: does this actually work? - cd "${D}/usr/bin" - mv ghcprof ghcprof-orig - sed -e 's:$FPTOOLS_TOP_ABS:#$FPTOOLS_TOP_ABS:' ghcprof-orig > ghcprof - chmod a+x ghcprof - rm -f ghcprof-orig - - cd "${S}/ghc" - dodoc README ANNOUNCE LICENSE VERSION - - dosbin "${FILESDIR}/ghc-updater" +src_install() { + if use binary; then + mkdir "${D}/opt" + mv "${S}/usr" "${D}/opt/ghc" + + cp -p "${D}/${GHC_PREFIX}/$(get_libdir)/${P}/package.conf"{,.shipped} \ + || die "failed to copy package.conf" + + doenvd "${FILESDIR}/10ghc" + else + # the libdir0 setting is needed for amd64, and does not + # harm for other arches + #TODO: are any of these overrides still required? isn't econf enough? + emake -j1 install \ + prefix="${D}/usr" \ + datadir="${D}/usr/share/doc/${PF}" \ + infodir="${D}/usr/share/info" \ + mandir="${D}/usr/share/man" \ + libdir0="${D}/usr/$(get_libdir)" \ + || die "make install failed" + + cd "${S}/ghc" + dodoc README ANNOUNCE LICENSE VERSION + + dosbin "${FILESDIR}/ghc-updater" + + cp -p "${D}/${GHC_PREFIX}/$(get_libdir)/${P}/package.conf"{,.shipped} \ + || die "failed to copy package.conf" + fi + + if use doc; then + docinto "html/libraries" + dohtml -A haddock -r "${WORKDIR}/libraries/"* \ + || die "installing library docs failed" + docinto "html/users_guide" + dohtml -r "${WORKDIR}/users_guide/"* \ + || die "installing user guide failed" + docinto "" + fi } pkg_postinst () { @@ -277,16 +358,39 @@ pkg_postinst () { $(ghc-getghcpkg) unregister Cabal > /dev/null eend $? ghc-reregister - elog "If you have dev-lang/ghc-bin installed, you might" - elog "want to unmerge it. It is no longer needed." - elog + + if use binary; then + elog "The envirenment has been set to use the binary distribution of" + elog "GHC. In order to activate it please run:" + elog " env-update && source /etc/profile" + elog "Otherwise this setting will become active the next time you login" + fi + ewarn "IMPORTANT:" ewarn "If you have upgraded from another version of ghc or" - ewarn "if you have switched from ghc-bin to ghc, please run:" - ewarn " /usr/sbin/ghc-updater" + ewarn "if you have switched between binary and source versions" + ewarn "of ghc, please run:" + if use binary; then + ewarn " /opt/ghc/sbin/ghc-updater" + else + ewarn " /usr/sbin/ghc-updater" + fi ewarn "to re-merge all ghc-based Haskell libraries." } +pkg_prerm() { + # Overwrite the (potentially) modified package.conf with a copy of the + # original one, so that it will be removed during uninstall. + + set_config # load GHC_PREFIX + + PKG="${ROOT}/${GHC_PREFIX}/$(get_libdir)/${P}/package.conf" + + cp -p "${PKG}"{.shipped,} + + [[ -f ${PKG}.old ]] && rm "${PKG}.old" +} + src_test() { if use test; then local summary -- cgit v1.2.3-65-gdbad