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