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