]> Pileus Git - ~andy/sunrise/blob - dev-lang/dmd/dmd-2.059.ebuild
www-servers/webcit: Version bump for bug #123139
[~andy/sunrise] / dev-lang / dmd / dmd-2.059.ebuild
1 # Copyright 1999-2012 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://www.digitalmars.com/d/"
11 SRC_URI="http://ftp.digitalmars.com/${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         epatch "${FILESDIR}/${PV}-issue-7907.patch"
49         epatch "${FILESDIR}/${PV}-issue-7911.patch"
50         epatch "${FILESDIR}/${PV}-issue-7922.patch"
51         epatch "${FILESDIR}/${PV}-std-path-sep-deprecation.patch"
52         epatch "${FILESDIR}/${PV}-outOfMemoryError-undeprecation.patch"
53 }
54
55 src_compile() {
56         # DMD
57         ln -s . "dmd/mars" || die "Failed to add recursive symbolic link to DMD sources."
58         if use x86; then
59                 einfo 'Building DMD for x86 ...'
60                 emake -C dmd -f posix.mak MODEL=32
61         elif use amd64; then
62                 einfo 'Building DMD for amd64 ...'
63                 emake -C dmd -f posix.mak MODEL=64
64         fi
65
66         # druntime & Phobos
67         if use x86 || (use amd64 && use multilib); then
68                 einfo 'Building druntime for x86 ...'
69                 emake -C druntime -f posix.mak MODEL=32 "DMD=../dmd/dmd"
70                 einfo 'Building Phobos for x86 ...'
71                 emake -C phobos -f posix.mak MODEL=32 "DMD=../dmd/dmd"
72         fi
73         if use amd64; then
74                 einfo 'Building druntime for amd64 ...'
75                 emake -C druntime -f posix.mak MODEL=64 "DMD=../dmd/dmd"
76                 einfo 'Building Phobos for amd64 ...'
77                 emake -C phobos -f posix.mak MODEL=64 "DMD=../dmd/dmd"
78         fi
79 }
80
81 src_test() {
82         local DFLAGS="-Iphobos -Idruntime/import -L-lrt"
83         local DMD="dmd/dmd"
84         if use x86 || (use amd64 && use multilib); then
85                 ${DMD} -m32 ${DFLAGS} -Lphobos/generated/linux/release32/libphobos2.a ../samples/d/hello.d || die "Failed to build hello.d (32bit)"
86                 ./hello 32bit || die "Failed to run test sample (32bit)"
87         fi
88         if use amd64; then
89                 ${DMD} -m64 ${DFLAGS} -Lphobos/generated/linux/release64/libphobos2.a ../samples/d/hello.d || die "Failed to build hello.d (64bit)"
90                 ./hello 64bit || die "Failed to run test sample (64bit)"
91         fi
92         rm hello.o hello
93 }
94
95 src_install() {
96         # prepeare and install config
97         cd "dmd" || die
98         cat > dmd.conf << EOF
99 [Environment]
100 DFLAGS=-I/usr/include/phobos2 -I/usr/include/druntime -L--no-warn-search-mismatch -L--export-dynamic -L-lrt
101 EOF
102         insinto /etc
103         doins dmd.conf
104         dobashcomp "${FILESDIR}/${PN}.bashcomp"
105
106         # Compiler
107         dobin "dmd"
108
109         # Man pages, docs and samples
110         cd ".." || die
111         doman ../man/man1/dmd.1
112         doman ../man/man1/dmd.conf.5
113
114         use doc && dohtml -r ../html/*
115
116         if use tools; then
117                 doman ../man/man1/dumpobj.1
118                 doman ../man/man1/obj2asm.1
119                 doman ../man/man1/rdmd.1
120
121                 # Bundled pre-compiled tools
122                 if use amd64; then
123                         dobin ../linux/bin64/{dumpobj,obj2asm,rdmd}
124                 fi
125                 if use x86; then
126                         dobin ../linux/bin32/{dumpobj,obj2asm,rdmd}
127                 fi
128         fi
129
130         docompress -x /usr/share/doc/${PF}/samples/
131         insinto /usr/share/doc/${PF}/samples/
132         if use examples; then
133                 doins -r ../samples/d/*
134         fi
135
136         # druntime & Phobos
137         if use amd64; then
138                 newlib.a "druntime/lib/libdruntime-linux64.a" "libdruntime.a"
139                 dolib.a "phobos/generated/linux/release/64/libphobos2.a"
140         fi
141         if use x86 || (use amd64 && use multilib); then
142                 use amd64 && multilib_toolchain_setup x86
143                 newlib.a "druntime/lib/libdruntime-linux32.a" "libdruntime.a"
144                 dolib.a "phobos/generated/linux/release/32/libphobos2.a"
145                 # TODO: restore target architecture
146         fi
147
148         # cleanup builds
149         rm -r "druntime/obj" "druntime/lib" || die
150         rm -r "phobos/generated" || die
151
152         # remove files that are not required
153         rm "phobos/posix.mak" || die
154         rm "phobos/win32.mak" || die
155         rm "phobos/std.ddoc" || die
156         rm "phobos/index.d" || die
157         rm -r "phobos/etc/c/zlib" || die
158
159         # imports
160         insinto /usr/include/druntime/
161         doins -r druntime/import/*
162
163         insinto /usr/include/phobos2
164         doins -r phobos/*
165 }
166
167 pkg_postinst() {
168         if use doc || use examples; then
169                 elog "The bundled docs and/or samples may be found in"
170                 elog "/usr/share/doc/${PF}"
171         fi
172 }