1 # Copyright 1999-2012 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils multilib bash-completion-r1
9 DESCRIPTION="Reference compiler for the D programming language"
10 HOMEPAGE="http://www.digitalmars.com/d/"
11 SRC_URI="http://ftp.digitalmars.com/${PN}.${PV}.zip"
13 # DMD supports amd64/x86 exclusively
14 KEYWORDS="-* ~amd64 ~x86"
16 IUSE="multilib doc examples"
18 # License doesn't allow redistribution
22 DEPEND="sys-apps/findutils
24 RDEPEND="!dev-lang/dmd-bin"
26 S="${WORKDIR}/${PN}2/src"
29 edos2unix $(find . -name '*'.$1 -type f) || die "Failed to convert line-endings of all .$1 files"
35 rm -r osx linux windows freebsd README.TXT || die "Failed to remove included binaries"
37 # convert line-endings of file-types that start as cr-lf and are
38 # patched or installed later on
44 # misc patches for the build process
45 epatch "${FILESDIR}/${P}-makefile.patch"
50 ln -s . "dmd/mars" || die "Failed to add recursive symbolic link to DMD sources."
52 einfo 'Building DMD for x86 ...'
53 emake -C dmd -f posix.mak MODEL=32
55 einfo 'Building DMD for amd64 ...'
56 emake -C dmd -f posix.mak MODEL=64
60 if use x86 || (use amd64 && use multilib); then
61 einfo 'Building druntime for x86 ...'
62 emake -C druntime -f posix.mak MODEL=32 "DMD=../dmd/dmd"
63 einfo 'Building Phobos for x86 ...'
64 emake -C phobos -f posix.mak MODEL=32 "DMD=../dmd/dmd"
67 einfo 'Building druntime for amd64 ...'
68 emake -C druntime -f posix.mak MODEL=64 "DMD=../dmd/dmd"
69 einfo 'Building Phobos for amd64 ...'
70 emake -C phobos -f posix.mak MODEL=64 "DMD=../dmd/dmd"
75 local DFLAGS="-Iphobos -Idruntime/import -L-lrt"
77 if use x86 || (use amd64 && use multilib); then
78 ${DMD} -m32 ${DFLAGS} -Lphobos/generated/linux/release32/libphobos2.a ../samples/d/hello.d || die "Failed to build hello.d (32bit)"
79 ./hello 32bit || die "Failed to run test sample (32bit)"
82 ${DMD} -m64 ${DFLAGS} -Lphobos/generated/linux/release64/libphobos2.a ../samples/d/hello.d || die "Failed to build hello.d (64bit)"
83 ./hello 64bit || die "Failed to run test sample (64bit)"
89 # prepeare and install config
93 DFLAGS=-I/usr/include/phobos2 -I/usr/include/druntime -L-L--no-warn-search-mismatch -L--export-dynamic -L-lrt
97 dobashcomp "${FILESDIR}/${PN}.bashcomp"
102 # Man pages, docs and samples
104 doman ../man/man1/dmd.1
105 doman ../man/man1/dmd.conf.5
107 use doc && dohtml -r ../html/*
109 docompress -x /usr/share/doc/${PF}/samples/
110 insinto /usr/share/doc/${PF}/samples/
111 if use examples; then
112 doins -r ../samples/d/*
117 dolib.a "druntime/lib64/libdruntime.a"
118 dolib.a "phobos/generated/linux/release64/libphobos2.a"
120 if use x86 || (use amd64 && use multilib); then
121 use amd64 && multilib_toolchain_setup x86
122 dolib.a "druntime/lib32/libdruntime.a"
123 dolib.a "phobos/generated/linux/release32/libphobos2.a"
124 # TODO: restore target architecture
128 rm -r "druntime/obj"* "druntime/lib"* || die
129 rm -r "phobos/generated" || die
131 # remove files that are not required
132 rm "phobos/posix.mak" || die
133 rm "phobos/win32.mak" || die
134 rm "phobos/std.ddoc" || die
135 rm "phobos/index.d" || die
136 rm -r "phobos/etc/c/zlib" || die
139 insinto /usr/include/druntime/
140 doins -r druntime/import/*
142 insinto /usr/include/phobos2
147 if use doc || use examples; then
148 elog "The bundled docs and/or samples may be found in"
149 elog "/usr/share/doc/${PF}"