1 |
commit: a21b012fa6c110975dd84f0b31cc9bdac216a1cc |
2 |
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Oct 15 13:41:54 2017 +0000 |
4 |
Commit: Andreas Hüttel <dilfridge <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Oct 15 13:44:03 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a21b012f |
7 |
|
8 |
sys-devel/binutils: Port away from toolchain-binutils.eclass, update EAPI, simplify |
9 |
|
10 |
Package-Manager: Portage-2.3.11, Repoman-2.3.3 |
11 |
|
12 |
sys-devel/binutils/binutils-9999.ebuild | 387 +++++++++++++++++++++++++++++++- |
13 |
1 file changed, 385 insertions(+), 2 deletions(-) |
14 |
|
15 |
diff --git a/sys-devel/binutils/binutils-9999.ebuild b/sys-devel/binutils/binutils-9999.ebuild |
16 |
index cf90a61b1d4..3c7b8b3b06a 100644 |
17 |
--- a/sys-devel/binutils/binutils-9999.ebuild |
18 |
+++ b/sys-devel/binutils/binutils-9999.ebuild |
19 |
@@ -1,6 +1,389 @@ |
20 |
# Copyright 1999-2017 Gentoo Foundation |
21 |
# Distributed under the terms of the GNU General Public License v2 |
22 |
|
23 |
-EAPI="5" |
24 |
+EAPI=6 |
25 |
|
26 |
-inherit toolchain-binutils |
27 |
+inherit eutils libtool flag-o-matic gnuconfig multilib versionator |
28 |
+ |
29 |
+DESCRIPTION="Tools necessary to build programs" |
30 |
+HOMEPAGE="https://sourceware.org/binutils/" |
31 |
+LICENSE="|| ( GPL-3 LGPL-3 )" |
32 |
+IUSE="cxx multitarget nls static-libs test" |
33 |
+ |
34 |
+# Variables that can be set here: |
35 |
+# PATCH_VER - the patchset version |
36 |
+# Default: empty, no patching |
37 |
+# PATCH_BINUTILS_VER - the binutils version in the patchset name |
38 |
+# - Default: PV |
39 |
+# PATCH_DEV - Use download URI https://dev.gentoo.org/~{PATCH_DEV}/distfiles/... |
40 |
+# for the patchsets |
41 |
+# Default: dilfridge :) |
42 |
+ |
43 |
+case ${PV} in |
44 |
+ 9999) |
45 |
+ BVER="git" |
46 |
+ EGIT_REPO_URI="https://sourceware.org/git/binutils-gdb.git" |
47 |
+ inherit git-r3 |
48 |
+ S=${WORKDIR}/binutils |
49 |
+ EGIT_CHECKOUT_DIR=${S} |
50 |
+ ;; |
51 |
+ *) |
52 |
+ BVER=${PV} |
53 |
+ SRC_URI="mirror://gnu/binutils/binutils-${BVER}.tar.xz" |
54 |
+ ;; |
55 |
+esac |
56 |
+SLOT="${BVER}" |
57 |
+ |
58 |
+# |
59 |
+# The Gentoo patchset |
60 |
+# |
61 |
+PATCH_BINUTILS_VER=${PATCH_BINUTILS_VER:-${BVER}} |
62 |
+PATCH_DEV=${PATCH_DEV:-dilfridge} |
63 |
+ |
64 |
+[[ -z ${PATCH_VER} ]] || SRC_URI="${SRC_URI} |
65 |
+ https://dev.gentoo.org/~${PATCH_DEV}/distfiles/binutils-${PATCH_BINUTILS_VER}-patches-${PATCH_VER}.tar.xz" |
66 |
+ |
67 |
+# |
68 |
+# The cross-compile logic |
69 |
+# |
70 |
+export CTARGET=${CTARGET:-${CHOST}} |
71 |
+if [[ ${CTARGET} == ${CHOST} ]] ; then |
72 |
+ if [[ ${CATEGORY} == cross-* ]] ; then |
73 |
+ export CTARGET=${CATEGORY#cross-} |
74 |
+ fi |
75 |
+fi |
76 |
+is_cross() { [[ ${CHOST} != ${CTARGET} ]] ; } |
77 |
+ |
78 |
+# |
79 |
+# The dependencies |
80 |
+# |
81 |
+RDEPEND=" |
82 |
+ >=sys-devel/binutils-config-3 |
83 |
+ sys-libs/zlib |
84 |
+" |
85 |
+DEPEND="${RDEPEND} |
86 |
+ test? ( dev-util/dejagnu ) |
87 |
+ nls? ( sys-devel/gettext ) |
88 |
+ sys-devel/flex |
89 |
+ virtual/yacc |
90 |
+" |
91 |
+if is_cross ; then |
92 |
+ # The build assumes the host has libiberty and such when cross-compiling |
93 |
+ # its build tools. We should probably make binutils itself build a local |
94 |
+ # copy to use, but until then, be lazy. |
95 |
+ DEPEND+=" >=sys-libs/binutils-libs-${PV}" |
96 |
+fi |
97 |
+ |
98 |
+MY_BUILDDIR=${WORKDIR}/build |
99 |
+ |
100 |
+src_unpack() { |
101 |
+ case ${PV} in |
102 |
+ 9999) |
103 |
+ git-r3_src_unpack; |
104 |
+ ;; |
105 |
+ *) |
106 |
+ default |
107 |
+ ;; |
108 |
+ esac |
109 |
+ mkdir -p "${MY_BUILDDIR}" |
110 |
+ [[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip |
111 |
+} |
112 |
+ |
113 |
+src_prepare() { |
114 |
+ if [[ ! -z ${PATCH_VER} ]] ; then |
115 |
+ elog "Applying binutils-${PATCH_BINUTILS_VER} patchset ${PATCH_VER}" |
116 |
+ eapply "${WORKDIR}/patch"/*.patch |
117 |
+ fi |
118 |
+ |
119 |
+ # This check should probably go somewhere else, like pkg_pretend. |
120 |
+ if [[ ${CTARGET} == *-uclibc* ]] ; then |
121 |
+ if grep -qs 'linux-gnu' "${S}"/ltconfig ; then |
122 |
+ die "sorry, but this binutils doesn't yet support uClibc :(" |
123 |
+ fi |
124 |
+ fi |
125 |
+ |
126 |
+ # Make sure our explicit libdir paths don't get clobbered. #562460 |
127 |
+ sed -i \ |
128 |
+ -e 's:@bfdlibdir@:@libdir@:g' \ |
129 |
+ -e 's:@bfdincludedir@:@includedir@:g' \ |
130 |
+ {bfd,opcodes}/Makefile.in || die |
131 |
+ |
132 |
+ # Fix locale issues if possible #122216 |
133 |
+ if [[ -e ${FILESDIR}/binutils-configure-LANG.patch ]] ; then |
134 |
+ einfo "Fixing misc issues in configure files" |
135 |
+ for f in $(find "${S}" -name configure -exec grep -l 'autoconf version 2.13' {} +) ; do |
136 |
+ ebegin " Updating ${f/${S}\/}" |
137 |
+ patch "${f}" "${FILESDIR}"/binutils-configure-LANG.patch >& "${T}"/configure-patch.log \ |
138 |
+ || eerror "Please file a bug about this" |
139 |
+ eend $? |
140 |
+ done |
141 |
+ fi |
142 |
+ |
143 |
+ # Fix conflicts with newer glibc #272594 |
144 |
+ if [[ -e libiberty/testsuite/test-demangle.c ]] ; then |
145 |
+ sed -i 's:\<getline\>:get_line:g' libiberty/testsuite/test-demangle.c |
146 |
+ fi |
147 |
+ |
148 |
+ # Fix po Makefile generators |
149 |
+ sed -i \ |
150 |
+ -e '/^datadir = /s:$(prefix)/@DATADIRNAME@:@datadir@:' \ |
151 |
+ -e '/^gnulocaledir = /s:$(prefix)/share:$(datadir):' \ |
152 |
+ */po/Make-in || die "sed po's failed" |
153 |
+ |
154 |
+ # Apply things from PATCHES and user dirs |
155 |
+ default |
156 |
+ |
157 |
+ # Run misc portage update scripts |
158 |
+ gnuconfig_update |
159 |
+ elibtoolize --portage --no-uclibc |
160 |
+} |
161 |
+ |
162 |
+# Intended for ebuilds to override to set their own versioning information. |
163 |
+toolchain-binutils_bugurl() { |
164 |
+ printf "https://bugs.gentoo.org/" |
165 |
+} |
166 |
+toolchain-binutils_pkgversion() { |
167 |
+ printf "Gentoo ${BVER}" |
168 |
+ [[ -n ${PATCH_VER} ]] && printf " p${PATCH_VER}" |
169 |
+} |
170 |
+ |
171 |
+src_configure() { |
172 |
+ # Setup some paths |
173 |
+ LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER} |
174 |
+ INCPATH=${LIBPATH}/include |
175 |
+ DATAPATH=/usr/share/binutils-data/${CTARGET}/${BVER} |
176 |
+ if is_cross ; then |
177 |
+ BINPATH=/usr/${CHOST}/${CTARGET}/binutils-bin/${BVER} |
178 |
+ else |
179 |
+ BINPATH=/usr/${CTARGET}/binutils-bin/${BVER} |
180 |
+ fi |
181 |
+ |
182 |
+ # Make sure we filter $LINGUAS so that only ones that |
183 |
+ # actually work make it through #42033 |
184 |
+ strip-linguas -u */po |
185 |
+ |
186 |
+ # Keep things sane |
187 |
+ strip-flags |
188 |
+ |
189 |
+ local x |
190 |
+ echo |
191 |
+ for x in CATEGORY CBUILD CHOST CTARGET CFLAGS LDFLAGS ; do |
192 |
+ einfo "$(printf '%10s' ${x}:) ${!x}" |
193 |
+ done |
194 |
+ echo |
195 |
+ |
196 |
+ cd "${MY_BUILDDIR}" |
197 |
+ local myconf=() |
198 |
+ |
199 |
+ # enable gold (installed as ld.gold) and ld's plugin architecture |
200 |
+ if use cxx ; then |
201 |
+ myconf+=( --enable-gold ) |
202 |
+ myconf+=( --enable-plugins ) |
203 |
+ fi |
204 |
+ |
205 |
+ if use nls ; then |
206 |
+ myconf+=( --without-included-gettext ) |
207 |
+ else |
208 |
+ myconf+=( --disable-nls ) |
209 |
+ fi |
210 |
+ |
211 |
+ myconf+=( --with-system-zlib ) |
212 |
+ |
213 |
+ # For bi-arch systems, enable a 64bit bfd. This matches |
214 |
+ # the bi-arch logic in toolchain.eclass. #446946 |
215 |
+ # We used to do it for everyone, but it's slow on 32bit arches. #438522 |
216 |
+ case $(tc-arch) in |
217 |
+ ppc|sparc|x86) myconf+=( --enable-64-bit-bfd ) ;; |
218 |
+ esac |
219 |
+ |
220 |
+ use multitarget && myconf+=( --enable-targets=all --enable-64-bit-bfd ) |
221 |
+ |
222 |
+ [[ -n ${CBUILD} ]] && myconf+=( --build=${CBUILD} ) |
223 |
+ |
224 |
+ is_cross && myconf+=( |
225 |
+ --with-sysroot="${EPREFIX}"/usr/${CTARGET} |
226 |
+ --enable-poison-system-directories |
227 |
+ ) |
228 |
+ |
229 |
+ # glibc-2.3.6 lacks support for this ... so rather than force glibc-2.5+ |
230 |
+ # on everyone in alpha (for now), we'll just enable it when possible |
231 |
+ has_version ">=${CATEGORY}/glibc-2.5" && myconf+=( --enable-secureplt ) |
232 |
+ has_version ">=sys-libs/glibc-2.5" && myconf+=( --enable-secureplt ) |
233 |
+ |
234 |
+ myconf+=( |
235 |
+ --prefix="${EPREFIX}"/usr |
236 |
+ --host=${CHOST} |
237 |
+ --target=${CTARGET} |
238 |
+ --datadir="${EPREFIX}"${DATAPATH} |
239 |
+ --infodir="${EPREFIX}"${DATAPATH}/info |
240 |
+ --mandir="${EPREFIX}"${DATAPATH}/man |
241 |
+ --bindir="${EPREFIX}"${BINPATH} |
242 |
+ --libdir="${EPREFIX}"${LIBPATH} |
243 |
+ --libexecdir="${EPREFIX}"${LIBPATH} |
244 |
+ --includedir="${EPREFIX}"${INCPATH} |
245 |
+ --enable-obsolete |
246 |
+ --enable-shared |
247 |
+ --enable-threads |
248 |
+ # Newer versions (>=2.27) offer a configure flag now. |
249 |
+ --enable-relro |
250 |
+ # Newer versions (>=2.24) make this an explicit option. #497268 |
251 |
+ --enable-install-libiberty |
252 |
+ --disable-werror |
253 |
+ --with-bugurl="$(toolchain-binutils_bugurl)" |
254 |
+ --with-pkgversion="$(toolchain-binutils_pkgversion)" |
255 |
+ $(use_enable static-libs static) |
256 |
+ ${EXTRA_ECONF} |
257 |
+ # Disable modules that are in a combined binutils/gdb tree. #490566 |
258 |
+ --disable-{gdb,libdecnumber,readline,sim} |
259 |
+ # Strip out broken static link flags. |
260 |
+ # https://gcc.gnu.org/PR56750 |
261 |
+ --without-stage1-ldflags |
262 |
+ ) |
263 |
+ echo ./configure "${myconf[@]}" |
264 |
+ "${S}"/configure "${myconf[@]}" || die |
265 |
+ |
266 |
+ # Prevent makeinfo from running in releases. It may not always be |
267 |
+ # installed, and older binutils may fail with newer texinfo. |
268 |
+ # Besides, we never patch the doc files anyways, so regenerating |
269 |
+ # in the first place is useless. #193364 |
270 |
+ # For older versions, it means we don't get any info pages at all. |
271 |
+ # Oh well, tough luck. #294617 |
272 |
+ if [[ -e ${S}/gas/doc/as.info ]] || ! version_is_at_least 2.24 ; then |
273 |
+ sed -i \ |
274 |
+ -e '/^MAKEINFO/s:=.*:= true:' \ |
275 |
+ Makefile || die |
276 |
+ fi |
277 |
+} |
278 |
+ |
279 |
+src_compile() { |
280 |
+ cd "${MY_BUILDDIR}" |
281 |
+ emake all |
282 |
+ |
283 |
+ # only build info pages if we user wants them, and if |
284 |
+ # we have makeinfo (may not exist when we bootstrap) |
285 |
+ if type -p makeinfo > /dev/null ; then |
286 |
+ emake info |
287 |
+ fi |
288 |
+ |
289 |
+ # we nuke the manpages when we're left with junk |
290 |
+ # (like when we bootstrap, no perl -> no manpages) |
291 |
+ find . -name '*.1' -a -size 0 -delete |
292 |
+} |
293 |
+ |
294 |
+src_test() { |
295 |
+ cd "${MY_BUILDDIR}" |
296 |
+ emake -k check |
297 |
+} |
298 |
+ |
299 |
+src_install() { |
300 |
+ local x d |
301 |
+ |
302 |
+ cd "${MY_BUILDDIR}" |
303 |
+ emake DESTDIR="${D}" tooldir="${EPREFIX}${LIBPATH}" install |
304 |
+ rm -rf "${ED}"/${LIBPATH}/bin |
305 |
+ use static-libs || find "${ED}" -name '*.la' -delete |
306 |
+ |
307 |
+ # Newer versions of binutils get fancy with ${LIBPATH} #171905 |
308 |
+ cd "${ED}"/${LIBPATH} |
309 |
+ for d in ../* ; do |
310 |
+ [[ ${d} == ../${BVER} ]] && continue |
311 |
+ mv ${d}/* . || die |
312 |
+ rmdir ${d} || die |
313 |
+ done |
314 |
+ |
315 |
+ # Now we collect everything intp the proper SLOT-ed dirs |
316 |
+ # When something is built to cross-compile, it installs into |
317 |
+ # /usr/$CHOST/ by default ... we have to 'fix' that :) |
318 |
+ if is_cross ; then |
319 |
+ cd "${ED}"/${BINPATH} |
320 |
+ for x in * ; do |
321 |
+ mv ${x} ${x/${CTARGET}-} |
322 |
+ done |
323 |
+ |
324 |
+ if [[ -d ${ED}/usr/${CHOST}/${CTARGET} ]] ; then |
325 |
+ mv "${ED}"/usr/${CHOST}/${CTARGET}/include "${ED}"/${INCPATH} |
326 |
+ mv "${ED}"/usr/${CHOST}/${CTARGET}/lib/* "${ED}"/${LIBPATH}/ |
327 |
+ rm -r "${ED}"/usr/${CHOST}/{include,lib} |
328 |
+ fi |
329 |
+ fi |
330 |
+ insinto ${INCPATH} |
331 |
+ local libiberty_headers=( |
332 |
+ # Not all the libiberty headers. See libiberty/Makefile.in:install_to_libdir. |
333 |
+ demangle.h |
334 |
+ dyn-string.h |
335 |
+ fibheap.h |
336 |
+ hashtab.h |
337 |
+ libiberty.h |
338 |
+ objalloc.h |
339 |
+ splay-tree.h |
340 |
+ ) |
341 |
+ doins "${libiberty_headers[@]/#/${S}/include/}" || die |
342 |
+ if [[ -d ${ED}/${LIBPATH}/lib ]] ; then |
343 |
+ mv "${ED}"/${LIBPATH}/lib/* "${ED}"/${LIBPATH}/ |
344 |
+ rm -r "${ED}"/${LIBPATH}/lib |
345 |
+ fi |
346 |
+ |
347 |
+ # Generate an env.d entry for this binutils |
348 |
+ insinto /etc/env.d/binutils |
349 |
+ cat <<-EOF > "${T}"/env.d |
350 |
+ TARGET="${CTARGET}" |
351 |
+ VER="${BVER}" |
352 |
+ LIBPATH="${EPREFIX}${LIBPATH}" |
353 |
+ EOF |
354 |
+ newins "${T}"/env.d ${CTARGET}-${BVER} |
355 |
+ |
356 |
+ # Handle documentation |
357 |
+ if ! is_cross ; then |
358 |
+ cd "${S}" |
359 |
+ dodoc README |
360 |
+ docinto bfd |
361 |
+ dodoc bfd/ChangeLog* bfd/README bfd/PORTING bfd/TODO |
362 |
+ docinto binutils |
363 |
+ dodoc binutils/ChangeLog binutils/NEWS binutils/README |
364 |
+ docinto gas |
365 |
+ dodoc gas/ChangeLog* gas/CONTRIBUTORS gas/NEWS gas/README* |
366 |
+ docinto gprof |
367 |
+ dodoc gprof/ChangeLog* gprof/TEST gprof/TODO gprof/bbconv.pl |
368 |
+ docinto ld |
369 |
+ dodoc ld/ChangeLog* ld/README ld/NEWS ld/TODO |
370 |
+ docinto libiberty |
371 |
+ dodoc libiberty/ChangeLog* libiberty/README |
372 |
+ docinto opcodes |
373 |
+ dodoc opcodes/ChangeLog* |
374 |
+ fi |
375 |
+ |
376 |
+ # Remove shared info pages |
377 |
+ rm -f "${ED}"/${DATAPATH}/info/{dir,configure.info,standards.info} |
378 |
+ |
379 |
+ # Trim all empty dirs |
380 |
+ find "${ED}" -depth -type d -exec rmdir {} + 2>/dev/null |
381 |
+} |
382 |
+ |
383 |
+pkg_postinst() { |
384 |
+ # Make sure this ${CTARGET} has a binutils version selected |
385 |
+ [[ -e ${EROOT}/etc/env.d/binutils/config-${CTARGET} ]] && return 0 |
386 |
+ binutils-config ${CTARGET}-${BVER} |
387 |
+} |
388 |
+ |
389 |
+pkg_postrm() { |
390 |
+ local current_profile=$(binutils-config -c ${CTARGET}) |
391 |
+ |
392 |
+ # If no other versions exist, then uninstall for this |
393 |
+ # target ... otherwise, switch to the newest version |
394 |
+ # Note: only do this if this version is unmerged. We |
395 |
+ # rerun binutils-config if this is a remerge, as |
396 |
+ # we want the mtimes on the symlinks updated (if |
397 |
+ # it is the same as the current selected profile) |
398 |
+ if [[ ! -e ${EPREFIX}${BINPATH}/ld ]] && [[ ${current_profile} == ${CTARGET}-${BVER} ]] ; then |
399 |
+ local choice=$(binutils-config -l | grep ${CTARGET} | awk '{print $2}') |
400 |
+ choice=${choice//$'\n'/ } |
401 |
+ choice=${choice/* } |
402 |
+ if [[ -z ${choice} ]] ; then |
403 |
+ env -i ROOT="${ROOT}" binutils-config -u ${CTARGET} |
404 |
+ else |
405 |
+ binutils-config ${choice} |
406 |
+ fi |
407 |
+ elif [[ $(CHOST=${CTARGET} binutils-config -c) == ${CTARGET}-${BVER} ]] ; then |
408 |
+ binutils-config ${CTARGET}-${BVER} |
409 |
+ fi |
410 |
+} |