# Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/dev-lang/dmd-bin/dmd-bin-2.008-r1.ebuild,v 1.5 2009/08/23 01:57:40 williamh Exp $ EAPI="3" inherit eutils MY_P=${P/-bin/} MY_P=${MY_P/-/.} DESCRIPTION="Digital Mars D Compiler" HOMEPAGE="http://www.digitalmars.com/d/" SRC_URI="http://ftp.digitalmars.com/${MY_P}.zip" IUSE="multilib build" # TODO: under amd64 build is required for getting 64bit dmd LICENSE="DMD" RESTRICT="mirror strip" SLOT="0" KEYWORDS="~amd64 ~x86" LOC="/opt/dmd" S="${WORKDIR}" DEPEND="sys-apps/findutils app-arch/unzip amd64? ( sys-devel/gcc[multilib] )" RDEPEND=" amd64? ( sys-devel/gcc[multilib] )" # TODO: +amd64 and (-build or +multilib) means that we need gcc[multilib] # TODO: currently it targeted only at linux src_unpack() { unpack ${A} # Cleanup line endings cd "${S}/dmd2" edos2unix `find . -name '*.c' -type f` edos2unix `find . -name '*.d' -type f` edos2unix `find . -name '*.ddoc' -type f` edos2unix `find . -name '*.h' -type f` edos2unix `find . -name '*.mak' -type f` edos2unix `find . -name '*.txt' -type f` edos2unix `find samples -name '*.html' -type f` edos2unix src/dmd/linux.mak src/phobos/linux.mak src/phobos/etc/c/zlib/linux.mak # Fix permissions and clean up fperms guo=r,u+w `find . -type f` fperms guo=rx,u+w `find . -type d` fperms guo=rx,u+w linux/bin/dmd linux/bin/dumpobj linux/bin/obj2asm linux/bin/rdmd epatch "${FILESDIR}/${P}.patch" } src_compile() { if use build; then # rebuild compiler # TODO: check that nothing is broken cd "${S}/dmd2/src/dmd" if use x86; then make -f linux.mak MODEL=32 || die "Failed to build dmd 32bit" elif use amd64; then make -f linux.mak MODEL=64 || die "Failed to build dmd 64bit" else die "x86 or amd64 should be in USE?" fi cp -f dmd "${S}/dmd2/linux/bin/" make -f linux.mak clean # XXX: dumpobj, obj2asm and rdmd will stay as 32bit binaries # fix druntime to use boundled/built cd "${S}/dmd2/src/druntime" # rebuild phobos2 (druntime will be rebuilt as dependency) cd "${S}/dmd2/src/phobos" if use x86 || use amd64 && use multilib; then make -f posix.mak MODEL=32 "DMD=${S}/dmd2/linux/bin/dmd" || die "Failed to build phobos2 32bit" cp generated/linux/release32/libphobos2.a "${S}/dmd2/linux/lib32/" || die fi if use amd64; then make -f posix.mak MODEL=64 "DMD=${S}/dmd2/linux/bin/dmd" || die "Failed to build phobos2 64bit" cp generated/linux/release64/libphobos2.a "${S}/dmd2/linux/lib64/" || die fi # Clean up make -f posix.mak clean MODEL=32 make -f posix.mak clean MODEL=64 cd "${S}/dmd2/src/druntime" #make -f posix.mak clean MODEL=32 #make -f posix.mak clean MODEL=64 rm -rf lib* obj* doc # check that we didn't screwed-up (TODO: make it in a right way, with USE) cd "${S}/dmd2/samples/d" || die "No samples?" DFLAGS="-I${S}/dmd2/src/phobos -I${S}/dmd2/src/druntime/import -L-L${S}/dmd2/linux/lib32 -L-L${S}/dmd2/linux/lib64" DMD="${S}/dmd2/linux/bin/dmd" pwd if use x86 || use amd64 && use multilib; then ${DMD} -m32 ${DFLAGS} hello.d || die "Failed to build hello.d (32bit)" rm hello.o hello fi if use amd64; then ${DMD} -m64 ${DFLAGS} hello.d || die "Failed to build hello.d (64bit)" rm hello.o hello fi #die "XXX" fi } src_install() { cd "${S}/dmd2" sed -i -e 's|%@P%/../../src/|/opt/dmd/src/|g;s|%@P%/../lib|/opt/dmd/lib|g' "linux/bin/dmd.conf" if use amd64; then # add -m64 as default sed -i -e 's/^\(\s*DFLAGS=\)/\1-m64 /' "linux/bin/dmd.conf" fi insinto /etc doins linux/bin/dmd.conf # Man pages doman man/man1/dmd.1 doman man/man1/dmd.conf.5 doman man/man1/dumpobj.1 doman man/man1/obj2asm.1 doman man/man1/rdmd.1 # Documentation dohtml -r html/d/* # Install exeinto /opt/dmd/bin doexe linux/bin/dmd doexe linux/bin/dumpobj doexe linux/bin/obj2asm doexe linux/bin/rdmd if use x86 || use amd64 && use multilib; then insinto /opt/dmd/lib32 doins linux/lib32/libphobos2.a fi if use amd64; then insinto /opt/dmd/lib64 doins linux/lib64/libphobos2.a fi insinto /opt/dmd/samples doins samples/d/* # Phobos and DMD source mv src "${D}/opt/dmd/" # Set PATH doenvd "${FILESDIR}/25dmd" } pkg_postinst () { ewarn "You may need to run: " ewarn "env-update && source /etc/profile " ewarn "to be able to use the compiler immediately. " einfo " " einfo "The bundled samples and sources may be found in " einfo "/opt/dmd/samples and /opt/dmd/src respectively. " einfo " " }