blob: 37813dd864fcf3574d58ecb6e173045c60ebb9ee [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
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050016#
17# we need chrpath > 0.14 and some distros like centos 7 still have older chrpath
18#
19DEPENDS_append_class-target = " chrpath-replacement-native"
20EXTRANATIVEPATH_append_class-target = " chrpath-native"
21
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022inherit autotools gettext multilib_header texinfo
23
24FILES_${PN} = " \
25 ${bindir}/${TARGET_PREFIX}* \
26 ${libdir}/lib*-*.so \
27 ${prefix}/${TARGET_SYS}/bin/* \
28 ${bindir}/embedspu"
29
30RPROVIDES_${PN} += "${PN}-symlinks"
31
32FILES_${PN}-dev = " \
33 ${includedir} \
34 ${libdir}/*.la \
35 ${libdir}/libbfd.so \
36 ${libdir}/libopcodes.so"
37
38# Rather than duplicating multiple entries for these, make one
39# list and reuse it.
40
41USE_ALTERNATIVES_FOR = " \
42 addr2line \
43 ar \
44 as \
45 c++filt \
46 elfedit \
47 gprof \
48 ld \
49 ld.bfd \
50 ld.gold dwp \
51 nm \
52 objcopy \
53 objdump \
54 ranlib \
55 readelf \
56 size \
57 strings \
58 strip \
59"
60
61python do_package_prepend() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062 make_alts = d.getVar("USE_ALTERNATIVES_FOR") or ""
63 prefix = d.getVar("TARGET_PREFIX")
64 bindir = d.getVar("bindir")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065 for alt in make_alts.split():
66 d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt)
67 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt)
68}
69
Patrick Williamsc124f4f2015-09-15 14:41:29 -050070B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
71
72EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
73 --disable-werror \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060074 --enable-deterministic-archives \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075 --enable-plugins \
76 ${LDGOLD} \
77 ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
78
79LDGOLD_class-native = ""
80LDGOLD_class-crosssdk = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050081LDGOLD ?= "${@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 -050082
83# This is necessary due to a bug in the binutils Makefiles
84# EXTRA_OEMAKE = "configure-build-libiberty all"
85
86export AR = "${HOST_PREFIX}ar"
87export AS = "${HOST_PREFIX}as"
88export LD = "${HOST_PREFIX}ld"
89export NM = "${HOST_PREFIX}nm"
90export RANLIB = "${HOST_PREFIX}ranlib"
91export OBJCOPY = "${HOST_PREFIX}objcopy"
92export OBJDUMP = "${HOST_PREFIX}objdump"
93
94export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
95export AS_FOR_TARGET = "${TARGET_PREFIX}as"
96export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
97export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
98export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
99
100export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
101export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
102
103# autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need
104# to unset LD_LIBRARY_PATH.
105export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}"
106
107MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}"
108do_configure[vardeps] += "MULTIARCH"
109do_configure () {
110 (cd ${S}; gnu-configize) || die "Failed to run gnu-configize"
111 oe_runconf
112#
113# must prime config.cache to ensure the build of libiberty
114#
115 mkdir -p ${B}/build-${BUILD_SYS}
116 for i in ${CONFIG_SITE}; do
117 cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true
118 done
119}
120
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500121do_compile_append_class-target() {
122 chrpath -d ${B}/binutils/elfedit
123 chrpath -d ${B}/binutils/readelf
124}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125do_install () {
126 autotools_do_install
127
128 # We don't really need these, so we'll remove them...
129 rm -rf ${D}${libdir}/ldscripts
130
131 # Fix the /usr/${TARGET_SYS}/bin/* links
132 for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do
133 rm -f $l
134 ln -sf `echo ${prefix}/${TARGET_SYS}/bin \
135 | tr -s / \
136 | sed -e 's,^/,,' -e 's,[^/]*,..,g'`${bindir}/${TARGET_PREFIX}`basename $l` $l
137 done
138
139 # Install the libiberty header
140 install -d ${D}${includedir}
141 install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
142 install -m 644 ${S}/include/libiberty.h ${D}${includedir}
143
144 cd ${D}${bindir}
145
146 # Symlinks for ease of running these on the native target
147 for p in ${TARGET_PREFIX}* ; do
148 ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,`
149 done
150
151 for alt in ${USE_ALTERNATIVES_FOR}; do
152 rm -f ${D}${bindir}/$alt
153 done
154
155 oe_multilib_header bfd.h
156}
157
158inherit update-alternatives
159
160ALTERNATIVE_PRIORITY = "100"
161
162ALTERNATIVE_${PN}_class-target = "${USE_ALTERNATIVES_FOR}"