blob: 0fb6cae407b5abe116304b60560e7c59ca07fbeb [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
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080041LDGOLD_ALTS ?= "ld.gold dwp"
42LDGOLD_ALTS_riscv64 = ""
43
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044USE_ALTERNATIVES_FOR = " \
45 addr2line \
46 ar \
47 as \
48 c++filt \
49 elfedit \
50 gprof \
51 ld \
52 ld.bfd \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080053 ${LDGOLD_ALTS} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054 nm \
55 objcopy \
56 objdump \
57 ranlib \
58 readelf \
59 size \
60 strings \
61 strip \
62"
63
64python do_package_prepend() {
Brad Bishop6e60e8b2018-02-01 10:27:11 -050065 make_alts = d.getVar("USE_ALTERNATIVES_FOR") or ""
66 prefix = d.getVar("TARGET_PREFIX")
67 bindir = d.getVar("bindir")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050068 for alt in make_alts.split():
69 d.setVarFlag('ALTERNATIVE_TARGET', alt, bindir + "/" + prefix + alt)
70 d.setVarFlag('ALTERNATIVE_LINK_NAME', alt, bindir + "/" + alt)
71}
72
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073B = "${S}/build.${HOST_SYS}.${TARGET_SYS}"
74
75EXTRA_OECONF = "--program-prefix=${TARGET_PREFIX} \
76 --disable-werror \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060077 --enable-deterministic-archives \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078 --enable-plugins \
79 ${LDGOLD} \
80 ${@bb.utils.contains('DISTRO_FEATURES', 'multiarch', '--enable-64-bit-bfd', '', d)}"
81
82LDGOLD_class-native = ""
83LDGOLD_class-crosssdk = ""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050084LDGOLD ?= "${@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 -050085
86# This is necessary due to a bug in the binutils Makefiles
87# EXTRA_OEMAKE = "configure-build-libiberty all"
88
89export AR = "${HOST_PREFIX}ar"
90export AS = "${HOST_PREFIX}as"
91export LD = "${HOST_PREFIX}ld"
92export NM = "${HOST_PREFIX}nm"
93export RANLIB = "${HOST_PREFIX}ranlib"
94export OBJCOPY = "${HOST_PREFIX}objcopy"
95export OBJDUMP = "${HOST_PREFIX}objdump"
96
97export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
98export AS_FOR_TARGET = "${TARGET_PREFIX}as"
99export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
100export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
101export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
102
103export CC_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
104export CXX_FOR_HOST = "${CCACHE}${HOST_PREFIX}gcc ${HOST_CC_ARCH}"
105
106# autotools.bbclass sets the _FOR_BUILD variables, but for some reason we need
107# to unset LD_LIBRARY_PATH.
108export CC_FOR_BUILD = "LD_LIBRARY_PATH= ${BUILD_CC}"
109
110MULTIARCH := "${@bb.utils.contains("DISTRO_FEATURES", "multiarch", "yes", "no", d)}"
111do_configure[vardeps] += "MULTIARCH"
112do_configure () {
113 (cd ${S}; gnu-configize) || die "Failed to run gnu-configize"
114 oe_runconf
115#
116# must prime config.cache to ensure the build of libiberty
117#
118 mkdir -p ${B}/build-${BUILD_SYS}
119 for i in ${CONFIG_SITE}; do
120 cat $i >> ${B}/build-${BUILD_SYS}/config.cache || true
121 done
122}
123
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500124do_compile_append_class-target() {
125 chrpath -d ${B}/binutils/elfedit
126 chrpath -d ${B}/binutils/readelf
127}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128do_install () {
129 autotools_do_install
130
131 # We don't really need these, so we'll remove them...
132 rm -rf ${D}${libdir}/ldscripts
133
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800134 bindir_rel=${@os.path.relpath('${bindir}', '${prefix}/${TARGET_SYS}/bin')}
135
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136 # Fix the /usr/${TARGET_SYS}/bin/* links
137 for l in ${D}${prefix}/${TARGET_SYS}/bin/*; do
138 rm -f $l
Brad Bishop1a4b7ee2018-12-16 17:11:34 -0800139 ln -sf $bindir_rel/${TARGET_PREFIX}`basename $l` $l
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500140 done
141
142 # Install the libiberty header
143 install -d ${D}${includedir}
144 install -m 644 ${S}/include/ansidecl.h ${D}${includedir}
145 install -m 644 ${S}/include/libiberty.h ${D}${includedir}
146
147 cd ${D}${bindir}
148
149 # Symlinks for ease of running these on the native target
150 for p in ${TARGET_PREFIX}* ; do
151 ln -sf $p `echo $p | sed -e s,${TARGET_PREFIX},,`
152 done
153
154 for alt in ${USE_ALTERNATIVES_FOR}; do
155 rm -f ${D}${bindir}/$alt
156 done
157
158 oe_multilib_header bfd.h
159}
160
161inherit update-alternatives
162
163ALTERNATIVE_PRIORITY = "100"
164
165ALTERNATIVE_${PN}_class-target = "${USE_ALTERNATIVES_FOR}"