blob: e93cd50b20694a3bf78e847a0ffc5088f14e2751 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "GNU binary utilities"
2DESCRIPTION = "The GNU Binutils are a collection of binary tools. \
3The main ones are ld (GNU Linker), and as (GNU Assembler). This \
4package also includes addition tools such as addr2line (Converts \
5addresses into filenames and line numbers), ar (utility for creating, \
6modifying and extracting archives), nm (list symbols in object \
7files), objcopy (copy and translate object files), objdump (Display \
8object information), and other tools and related libraries."
9HOMEPAGE = "http://www.gnu.org/software/binutils/"
10BUGTRACKER = "http://sourceware.org/bugzilla/"
11SECTION = "devel"
12LICENSE = "GPLv3"
13
14DEPENDS = "flex-native bison-native zlib-native gnu-config-native autoconf-native"
15
16inherit autotools gettext multilib_header texinfo
17
18FILES_${PN} = " \
19 ${bindir}/${TARGET_PREFIX}* \
Andrew Geissler82c905d2020-04-13 13:39:40 -050020 ${libdir}/lib*.so.* \
21 ${libdir}/lib*-${PV}*.so \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 ${prefix}/${TARGET_SYS}/bin/* \
23 ${bindir}/embedspu"
24
25RPROVIDES_${PN} += "${PN}-symlinks"
26
27FILES_${PN}-dev = " \
28 ${includedir} \
29 ${libdir}/*.la \
30 ${libdir}/libbfd.so \
Andrew Geissler82c905d2020-04-13 13:39:40 -050031 ${libdir}/libctf.so \
32 ${libdir}/libctf-nobfd.so \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 ${libdir}/libopcodes.so"
34
35# Rather than duplicating multiple entries for these, make one
36# list and reuse it.
37
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038LDGOLD_ALTS ?= "ld.gold dwp"
39LDGOLD_ALTS_riscv64 = ""
Andrew Geissler82c905d2020-04-13 13:39:40 -050040LDGOLD_ALTS_riscv32 = ""
41LDGOLD_ALTS_libc-glibc_mipsarch = ""
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043USE_ALTERNATIVES_FOR = " \
44 addr2line \
45 ar \
46 as \
47 c++filt \
48 elfedit \
49 gprof \
50 ld \
51 ld.bfd \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080052 ${LDGOLD_ALTS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050053 nm \
54 objcopy \
55 objdump \
56 ranlib \
57 readelf \
58 size \
59 strings \
60 strip \
61"
62
63python do_package_prepend() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064 make_alts = d.getVar("USE_ALTERNATIVES_FOR") or ""
65 prefix = d.getVar("TARGET_PREFIX")
66 bindir = d.getVar("bindir")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 for alt in make_alts.split():
68 d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt)
69 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt)
70}
71
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
73
74EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
75 --disable-werror \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060076 --enable-deterministic-archives \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077 --enable-plugins \
Andrew Geissler82c905d2020-04-13 13:39:40 -050078 --disable-gdb \
79 --disable-gdbserver \
80 --disable-libdecnumber \
81 --disable-readline \
82 --disable-sim \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 ${LDGOLD} \
Andrew Geissler82c905d2020-04-13 13:39:40 -050084 ${EXTRA_TARGETS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
86
Andrew Geissler82c905d2020-04-13 13:39:40 -050087EXTRA_TARGETS = ""
88EXTRA_TARGETS_x86-64 = " --enable-targets=x86_64-pe,x86_64-pep "
89EXTRA_TARGETS_class-native = ""
90
Patrick Williamsc124f4f2015-09-15 14:41:29 -050091LDGOLD_class-native = ""
92LDGOLD_class-crosssdk = ""
Andrew Geissler82c905d2020-04-13 13:39:40 -050093LDGOLD_libc-glibc_mipsarch = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050094LDGOLD ?= "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', '--enable-gold=default --enable-threads', '--enable-gold --enable-ld=default --enable-threads', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095
Andrew Geissler82c905d2020-04-13 13:39:40 -050096
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097# This is necessary due to a bug in the binutils Makefiles
98# EXTRA_OEMAKE = "configure-build-libiberty all"
99
100export AR = "${HOST_PREFIX}ar"
101export AS = "${HOST_PREFIX}as"
102export LD = "${HOST_PREFIX}ld"
103export NM = "${HOST_PREFIX}nm"
104export RANLIB = "${HOST_PREFIX}ranlib"
105export OBJCOPY = "${HOST_PREFIX}objcopy"
106export OBJDUMP = "${HOST_PREFIX}objdump"
107
108export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
109export AS_FOR_TARGET = "${TARGET_PREFIX}as"
110export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
111export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
112export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
113
114export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
115export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
116
117# autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need
118# to unset LD_LIBRARY_PATH.
119export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}"
120
121MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}"
122do_configure[vardeps] += "MULTIARCH"
123do_configure () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500124 (cd ${S} && gnu-configize)
125
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126 oe_runconf
127#
128# must prime config.cache to ensure the build of libiberty
129#
130 mkdir -p ${B}/build-${BUILD_SYS}
131 for i in ${CONFIG_SITE}; do
132 cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true
133 done
134}
135
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136do_install () {
137 autotools_do_install
138
139 # We don't really need these, so we'll remove them...
140 rm -rf ${D}${libdir}/ldscripts
141
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800142 bindir_rel=${@os.path.relpath('${bindir}', '${prefix}/${TARGET_SYS}/bin')}
143
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500144 # Fix the /usr/${TARGET_SYS}/bin/* links
145 for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do
146 rm -f $l
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800147 ln -sf $bindir_rel/${TARGET_PREFIX}`basename $l` $l
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148 done
149
150 # Install the libiberty header
151 install -d ${D}${includedir}
152 install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
153 install -m 644 ${S}/include/libiberty.h ${D}${includedir}
154
Andrew Geissler82c905d2020-04-13 13:39:40 -0500155 # insall pic version of libiberty if available
156 if [ -e ${B}/libiberty/pic/libiberty.a ]; then
157 install -Dm 0644 ${B}/libiberty/pic/libiberty.a ${D}${libdir}/libiberty.a
158 fi
159
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160 cd ${D}${bindir}
161
162 # Symlinks for ease of running these on the native target
163 for p in ${TARGET_PREFIX}* ; do
164 ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,`
165 done
166
167 for alt in ${USE_ALTERNATIVES_FOR}; do
168 rm -f ${D}${bindir}/$alt
169 done
170
171 oe_multilib_header bfd.h
Andrew Geissler82c905d2020-04-13 13:39:40 -0500172 # bfd_stdint.h encodes the compiler name in the header
173 sed -i ${D}${includedir}/bfd_stdint.h -e "s,${TARGET_PREFIX},,"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174}
175
176inherit update-alternatives
177
178ALTERNATIVE_PRIORITY = "100"
179
180ALTERNATIVE_${PN}_class-target = "${USE_ALTERNATIVES_FOR}"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500181
182python () {
183 if bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', True, False, d) and bb.utils.contains_any('TARGET_ARCH', 'riscv32 riscv64', True, False, d):
184 bb.fatal("Gold linker does not _yet_ support RISC-V architecture please remove ld-is-gold from DISTRO_FEATURES")
185}