summaryrefslogtreecommitdiff
blob: a00860e6b2a9345e328bbc6deb25a59679187227 (plain)
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
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI="6"

inherit eutils prefix

DESCRIPTION="Utility to change the binutils version being used"
HOMEPAGE="https://www.gentoo.org/"
GIT_REV="edc0d44f70c27daebcc080ac5d08e8e191bccd95"
WRAPPER_REV="${PV}.3.4"
SRC_URI="https://gitweb.gentoo.org/repo/proj/prefix.git/plain/sys-devel/binutils-config/files/ldwrapper.c?id=${GIT_REV} -> ${PN}-ldwrapper-${WRAPPER_REV}.c"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
IUSE=""

# We also RDEPEND on sys-apps/findutils which is in base @system
RDEPEND="sys-apps/gentoo-functions
	!<app-admin/eselect-1.4.5"

S=${WORKDIR}

# NOTE: the ld wrapper is only enabled on rpath versions of prefix.
src_prepare() {
	cp "${FILESDIR}"/${PN}-${PV} ./${PN} || die
	if use prefix-guest; then
		epatch "${FILESDIR}/${PN}-5-ldwrapper.patch"
	fi
	eprefixify ${PN}
	eapply_user
}

src_configure() {
	:
}

src_compile() {
	use prefix-guest || return
	local args=(
		$(tc-getCC)
		${CPPFLAGS}
		${CFLAGS}
		-o ldwrapper "${DISTDIR}"/${PN}-ldwrapper-${WRAPPER_REV}.c
		-DEPREFIX=\"${EPREFIX}\"
		-DCHOST=\"${CHOST}\"
		${LDFLAGS}
	)
	echo ${args[*]}
	"${args[@]}" || die
}

src_install() {
	dobin ${PN}
	use prefix && eprefixify "${ED}"/usr/bin/${PN}
	sed -i "s:@PV@:${PVR}:g" "${ED}"/usr/bin/${PN} || die
	doman "${FILESDIR}"/${PN}.8

	dodir /usr/$(get_libdir)/misc/binutils-config
	mv "${S}"/ldwrapper "${ED}"/usr/$(get_libdir)/misc/binutils-config/

	insinto /usr/share/eselect/modules
	doins "${FILESDIR}"/binutils.eselect
}

pkg_preinst() {
	# Force a refresh when upgrading from an older version that symlinked
	# in all the libs & includes that binutils-libs handles. #528088
	if has_version "<${CATEGORY}/${PN}-5" ; then
		local bc current
		bc="${ED}/usr/bin/binutils-config"
		if current=$("${bc}" -c) ; then
			"${bc}" "${current}"
		fi
	fi
}