blob: 30f1682483eb81b8dd09c6a9e077f20ab5b4d2dd (
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
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
|
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI="8"
DESCRIPTION="Host OS native assembler as and static linker ld"
HOMEPAGE="https://prefix.gentoo.org/"
LICENSE="GPL-2" # actually, we don't know, the wrapper is
SLOT="0"
KEYWORDS="~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
DEPEND="sys-devel/binutils-config"
RDEPEND="${DEPEND}"
src_unpack() {
mkdir -p "${S}"
}
src_install() {
LIBPATH=/usr/$(get_libdir)/binutils/${CHOST}/native-${PV}
BINPATH=/usr/${CHOST}/binutils-bin/native-${PV}
keepdir ${LIBPATH} || die
dodir ${BINPATH}
# allow for future hosts with different paths
nativepath=""
wrappers=()
case ${CHOST} in
*-solaris*)
nativepath=/usr/sfw/bin
;;
*-apple-darwin*)
nativepath=/usr/bin
;;
*)
die "Don't know where the native linker for your platform is"
;;
esac
what="addr2line as ar c++filt gprof ld nm objcopy objdump \
ranlib readelf elfdump size strings strip"
# Darwin things
what="${what} install_name_tool ld64 libtool lipo nmedit \
otool otool64 pagestuff redo_prebinding segedit"
# copy from the host os
cd "${ED}${BINPATH}"
for b in ${what} ; do
if [[ ${CHOST} == *-darwin* && ${b} == libtool ]] ; then
echo "linking darwin libtool ${nativepath}/${b}"
ln -s "${nativepath}/${b}" "${b}"
elif [[ -x ${nativepath}/g${b} ]] ; then
einfo "linking ${nativepath}/g${b}"
ln -s "${nativepath}/g${b}" "${b}"
elif [[ -x ${nativepath}/${b} ]] ; then
einfo "linking ${nativepath}/${b}"
ln -s "${nativepath}/${b}" "${b}"
else
ewarn "skipping ${b} (not in ${nativepath})"
fi
done
# post fix for Darwin's ranlib (doesn't like it when its called other than
# that, as libtool and ranlib are one tool)
# on macOS Big Sur, all tools except ld require to be called plainly as well
if [[ ${CHOST} == *-darwin* ]] ; then
[[ ${CHOST##*-darwin} -lt 20 ]] && what="ranlib"
for b in ${what} ; do
[[ ${what} == ld ]] && continue
rm -f ${b}
cat <<-EOF > ${b}
#!/usr/bin/env bash
exec ${nativepath}/${b} "\$@"
EOF
chmod 755 ${b}
done
fi
exeinto ${BINPATH}
local wrapper source target
for wrapper in "${wrappers[@]}" ; do
source=${wrapper#*=}
target=${wrapper%%=*}
rm -f "${target}"
newexe "${source}" "${target}" || die
done
# Generate an env.d entry for this binutils
insinto /etc/env.d/binutils
cat <<-EOF > "${T}"/env.d
TARGET="${CHOST}"
VER="native-${PV}"
LIBPATH="${EPREFIX}/${LIBPATH}"
FAKE_TARGETS="${CHOST}"
EOF
newins "${T}"/env.d ${CHOST}-native-${PV}
}
pkg_postinst() {
binutils-config ${CHOST}-native-${PV}
}
|