]> Pileus Git - ~andy/sunrise/blob - dev-lang/dmd/dmd-2.057.ebuild
sunrise/ net-nntp/nzbperl/Manifest: Update copyright line to satisfy repoman
[~andy/sunrise] / dev-lang / dmd / dmd-2.057.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"
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 osx linux windows freebsd README.TXT || die "Failed to remove included binaries"
36
37         # convert line-endings of file-types that start as cr-lf and are
38         # patched or installed later on
39         rdos2unix c
40         rdos2unix d
41         rdos2unix txt
42         rdos2unix css
43
44         # misc patches for the build process
45         epatch "${FILESDIR}/${P}-makefile.patch"
46 }
47
48 src_compile() {
49         # DMD
50         ln -s . "dmd/mars" || die "Failed to add recursive symbolic link to DMD sources."
51         if use x86; then
52                 einfo 'Building DMD for x86 ...'
53                 emake -C dmd -f posix.mak MODEL=32
54         elif use amd64; then
55                 einfo 'Building DMD for amd64 ...'
56                 emake -C dmd -f posix.mak MODEL=64
57         fi
58
59         # druntime & Phobos
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"
65         fi
66         if use amd64; then
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"
71         fi
72 }
73
74 src_test() {
75         local DFLAGS="-Iphobos -Idruntime/import -L-lrt"
76         local DMD="dmd/dmd"
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)"
80         fi
81         if use amd64; then
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)"
84         fi
85         rm hello.o hello
86 }
87
88 src_install() {
89         # prepeare and install config
90         cd "dmd" || die
91         cat > dmd.conf << EOF
92 [Environment]
93 DFLAGS=-I/usr/include/phobos2 -I/usr/include/druntime -L-L--no-warn-search-mismatch -L--export-dynamic -L-lrt
94 EOF
95         insinto /etc
96         doins dmd.conf
97         dobashcomp "${FILESDIR}/${PN}.bashcomp"
98
99         # Compiler
100         dobin "dmd"
101
102         # Man pages, docs and samples
103         cd ".." || die
104         doman ../man/man1/dmd.1
105         doman ../man/man1/dmd.conf.5
106
107         use doc && dohtml -r ../html/*
108
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/*
113         fi
114
115         # druntime & Phobos
116         if use amd64; then
117                 dolib.a "druntime/lib64/libdruntime.a"
118                 dolib.a "phobos/generated/linux/release64/libphobos2.a"
119         fi
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
125         fi
126
127         # cleanup builds
128         rm -r "druntime/obj"* "druntime/lib"* || die
129         rm -r "phobos/generated" || die
130
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
137
138         # imports
139         insinto /usr/include/druntime/
140         doins -r druntime/import/*
141
142         insinto /usr/include/phobos2
143         doins -r phobos/*
144 }
145
146 pkg_postinst() {
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}"
150         fi
151 }