]> Pileus Git - ~andy/sunrise/blob - dev-lang/dmd/dmd-2.060.ebuild
app-dicts/words-bin: Adding ~amd64 keyword
[~andy/sunrise] / dev-lang / dmd / dmd-2.060.ebuild
1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="4"
6
7 inherit eutils multilib bash-completion-r1
8
9 DESCRIPTION="Reference compiler for the D programming language"
10 HOMEPAGE="http://dlang.org/"
11 SRC_URI="mirror://github/D-Programming-Language/dmd/${PN}.${PV}.zip"
12
13 # DMD supports amd64/x86 exclusively
14 KEYWORDS="-* ~amd64 ~x86"
15 SLOT="2"
16 IUSE="multilib doc examples tools"
17
18 # License doesn't allow redistribution
19 LICENSE="DMD"
20 RESTRICT="mirror"
21
22 DEPEND="sys-apps/findutils
23         app-arch/unzip"
24 RDEPEND="!dev-lang/dmd-bin"
25
26 S="${WORKDIR}/${PN}2/src"
27
28 rdos2unix() {
29         edos2unix $(find . -name '*'.$1 -type f) || die "Failed to convert line-endings of all .$1 files"
30 }
31
32 src_prepare() {
33         cd .. || die
34
35         rm -r README.TXT windows freebsd osx linux/{lib32,lib64} \
36         linux/{bin32,bin64}/{README.TXT,dmd,dmd.conf} \
37         || die "Failed to remove included binaries"
38
39         # convert line-endings of file-types that start as cr-lf and are
40         # patched or installed later on
41         rdos2unix c
42         rdos2unix d
43         rdos2unix txt
44         rdos2unix css
45
46         # misc patches for the build process
47         epatch "${FILESDIR}/${P}-makefile.patch"
48 }
49
50 src_compile() {
51         # DMD
52         ln -s . "dmd/mars" || die "Failed to add recursive symbolic link to DMD sources."
53         if use x86; then
54                 einfo 'Building DMD for x86 ...'
55                 emake -C dmd -f posix.mak MODEL=32
56         elif use amd64; then
57                 einfo 'Building DMD for amd64 ...'
58                 emake -C dmd -f posix.mak MODEL=64
59         fi
60
61         # druntime & Phobos
62         if use x86 || (use amd64 && use multilib); then
63                 einfo 'Building druntime for x86 ...'
64                 emake -C druntime -f posix.mak MODEL=32 "DMD=../dmd/dmd"
65                 einfo 'Building Phobos for x86 ...'
66                 emake -C phobos -f posix.mak MODEL=32 "DMD=../dmd/dmd"
67         fi
68         if use amd64; then
69                 einfo 'Building druntime for amd64 ...'
70                 emake -C druntime -f posix.mak MODEL=64 "DMD=../dmd/dmd"
71                 einfo 'Building Phobos for amd64 ...'
72                 emake -C phobos -f posix.mak MODEL=64 "DMD=../dmd/dmd"
73         fi
74 }
75
76 src_test() {
77         local DFLAGS="-Iphobos -Idruntime/import -L-lrt"
78         local DMD="dmd/dmd"
79         if use x86 || (use amd64 && use multilib); then
80                 ${DMD} -m32 ${DFLAGS} -Lphobos/generated/linux/release32/libphobos2.a ../samples/d/hello.d || die "Failed to build hello.d (32bit)"
81                 ./hello 32bit || die "Failed to run test sample (32bit)"
82         fi
83         if use amd64; then
84                 ${DMD} -m64 ${DFLAGS} -Lphobos/generated/linux/release64/libphobos2.a ../samples/d/hello.d || die "Failed to build hello.d (64bit)"
85                 ./hello 64bit || die "Failed to run test sample (64bit)"
86         fi
87         rm hello.o hello
88 }
89
90 src_install() {
91         # prepeare and install config
92         cd "dmd" || die
93         cat > dmd.conf << EOF
94 [Environment]
95 DFLAGS=-I/usr/include/phobos2 -I/usr/include/druntime -L--no-warn-search-mismatch -L--export-dynamic -L-lrt
96 EOF
97         insinto /etc
98         doins dmd.conf
99         dobashcomp "${FILESDIR}/${PN}.bashcomp"
100
101         # Compiler
102         dobin "dmd"
103
104         # Man pages, docs and samples
105         cd ".." || die
106         doman ../man/man1/dmd.1
107         doman ../man/man1/dmd.conf.5
108
109         use doc && dohtml -r ../html/*
110
111         if use tools; then
112                 doman ../man/man1/dumpobj.1
113                 doman ../man/man1/obj2asm.1
114                 doman ../man/man1/rdmd.1
115
116                 # Bundled pre-compiled tools
117                 if use amd64; then
118                         dobin ../linux/bin64/{dumpobj,obj2asm,rdmd}
119                 fi
120                 if use x86; then
121                         dobin ../linux/bin32/{dumpobj,obj2asm,rdmd}
122                 fi
123         fi
124
125         docompress -x /usr/share/doc/${PF}/samples/
126         insinto /usr/share/doc/${PF}/samples/
127         if use examples; then
128                 doins -r ../samples/d/*
129         fi
130
131         # druntime & Phobos
132         if use amd64; then
133                 newlib.a "druntime/lib/libdruntime-linux64.a" "libdruntime.a"
134                 dolib.a "phobos/generated/linux/release/64/libphobos2.a"
135         fi
136         if use x86 || (use amd64 && use multilib); then
137                 use amd64 && multilib_toolchain_setup x86
138                 newlib.a "druntime/lib/libdruntime-linux32.a" "libdruntime.a"
139                 dolib.a "phobos/generated/linux/release/32/libphobos2.a"
140                 # TODO: restore target architecture
141         fi
142
143         # cleanup builds
144         rm -r "druntime/obj" "druntime/lib" || die
145         rm -r "phobos/generated" || die
146
147         # remove files that are not required
148         rm "phobos/posix.mak" || die
149         rm "phobos/win32.mak" || die
150         rm "phobos/std.ddoc" || die
151         rm "phobos/index.d" || die
152         rm -r "phobos/etc/c/zlib" || die
153
154         # imports
155         insinto /usr/include/druntime/
156         doins -r druntime/import/*
157
158         insinto /usr/include/phobos2
159         doins -r phobos/*
160 }
161
162 pkg_postinst() {
163         if use doc || use examples; then
164                 elog "The bundled docs and/or samples may be found in"
165                 elog "/usr/share/doc/${PF}"
166         fi
167 }