# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or later # $Header: $ inherit eutils flag-o-matic toolchain-funcs IUSE="nls" #need to check what gcc version we are running GCC_PV=`gcc-version` GCC_PVS=`gcc-major-version`.`gcc-minor-version`.`gcc-micro-version` GCC_PVF=`gcc-fullversion` GCC_LIBS="`gcc-config --get-lib-path`" # GCC_LIBS must be saved before we inherit toolchain # toolchain makes gcc-config not work # toolchain is used to patch the version inherit toolchain DESCRIPTION="D GCC Frontend" SRC_URI="http://home.earthlink.net/~dvdfrdmn/d/gdc-${PV}.tar.bz2 ftp://gcc.gnu.org/pub/gcc/releases/gcc-${GCC_PVS}/gcc-${GCC_PVS}.tar.bz2" HOMEPAGE="http://home.earthlink.net/~dvdfrdmn/d/" SLOT="0" KEYWORDS="~x86" LICENSE="GPL-2" S="${WORKDIR}/gcc-${GCC_PVS}" DEPEND="virtual/glibc >=sys-devel/gcc-3.3.2" RDEPEND="virtual/glibc >=sys-devel/gcc-3.3.2 !dev-lang/dmd" src_unpack() { unpack "gcc-${GCC_PVS}.tar.bz2" cd "${S}/gcc" gcc_version_patch "${GCC_PVF}" unpack "gdc-${PV}.tar.bz2" if [ "${GCC_PV}" = "3.4" ] then patch -p1 < d/patch-gcc-3.4.x || die "GCC 3.4.x patch failed" elif [ "${GCC_PV}" = "3.3" ] then patch -p1 < d/patch-gcc-3.3.x || die "GCC 3.3.x patch failed" else die "GCC ${GCC_PV} not supported by GDC" fi } src_compile() { einfo "Configuring GCC for GDC inclusion..." strip-flags # In general gcc does not like optimization, and add -O2 where # it is safe. This is especially true for gcc 3.3 + 3.4 replace-flags -O? -O2 # -mcpu is deprecated on these archs, and possibly others if use amd64 || use x86 ; then setting="`get-flag mcpu`" [ ! -z "${setting}" ] && \ replace-flags -mcpu="${setting}" -mtune="${setting}" && \ ewarn "-mcpu is deprecated on your arch\a\a\a" && \ epause 5 fi strip-unsupported-flags mkdir -p ${WORKDIR}/gdc-build cd ${WORKDIR}/gdc-build ${S}/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-languages=d einfo "Building GDC..." gmake # install temporary GDC, for building Phobos mkdir -p ${WORKDIR}/gdc-temp gmake -s DESTDIR="${WORKDIR}/gdc-temp" install OLDPATH="$PATH" export PATH="${WORKDIR}/gdc-temp/usr/bin:$PATH" einfo "Configuring Phobos runtime library... (release)" unset CC unset CXX unset CFLAGS unset CXXFLAGS unset DMD unset DFLAGS mkdir -p ${WORKDIR}/phobos-build cd ${WORKDIR}/phobos-build ${S}/gcc/d/phobos/configure --prefix=/usr einfo "Building Phobos... (release)" gmake } src_test() { einfo "Configuring Phobos runtime library... (unittest)" unset CC unset CXX unset CFLAGS unset CXXFLAGS unset DMD unset DFLAGS mkdir -p ${WORKDIR}/phobos-test cd ${WORKDIR}/phobos-test ${S}/gcc/d/phobos/configure --prefix=/usr einfo "Building Phobos... (unittest)" gmake DFLAGS="-funittest -nostdinc" libphobos.a unittest ./unittest || die "Unit test failed" } src_install() { cd ${WORKDIR} dobin gdc-build/gcc/gdc # rename to dmd but move to ${WORKDIR} since there already is a directory named "dmd" in old location mv gcc-${GCC_PVS}/gcc/d/dmd-script ${WORKDIR}/dmd dobin ${WORKDIR}/dmd mv ${WORKDIR}/dmd gcc-${GCC_PVS}/gcc/d/dmd-script dodir "${GCC_LIBS}" cp gdc-build/gcc/cc1d ${D}"${GCC_LIBS}" dolib.a phobos-build/libphobos.a dodir /usr/include/d cp phobos-build/phobos-ver-syms ${D}/usr/include/d/ cp phobos-build/libphobos.spec ${D}"${GCC_LIBS}" cd ${S}/gcc/d/phobos (find -name '*.d' | grep -v internal | xargs tar c) | (cd ${D}/usr/include/d; tar xo) }