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