1################################################################################ 2# 3# binutils 4# 5################################################################################ 6 7# Version is set when using buildroot toolchain. 8# If not, we do like other packages 9BINUTILS_VERSION = $(call qstrip,$(BR2_BINUTILS_VERSION)) 10ifeq ($(BINUTILS_VERSION),) 11ifeq ($(BR2_arc),y) 12BINUTILS_VERSION = arc-2020.09-release 13else 14BINUTILS_VERSION = 2.38 15endif 16endif # BINUTILS_VERSION 17 18ifeq ($(BINUTILS_VERSION),arc-2020.09-release) 19BINUTILS_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,binutils-gdb,$(BINUTILS_VERSION)) 20BINUTILS_SOURCE = binutils-gdb-$(BINUTILS_VERSION).tar.gz 21BINUTILS_FROM_GIT = y 22endif 23 24BINUTILS_SITE ?= $(BR2_GNU_MIRROR)/binutils 25BINUTILS_SOURCE ?= binutils-$(BINUTILS_VERSION).tar.xz 26BINUTILS_EXTRA_CONFIG_OPTIONS = $(call qstrip,$(BR2_BINUTILS_EXTRA_CONFIG_OPTIONS)) 27BINUTILS_INSTALL_STAGING = YES 28BINUTILS_DEPENDENCIES = zlib $(TARGET_NLS_DEPENDENCIES) 29BINUTILS_MAKE_OPTS = LIBS=$(TARGET_NLS_LIBS) 30BINUTILS_LICENSE = GPL-3.0+, libiberty LGPL-2.1+ 31BINUTILS_LICENSE_FILES = COPYING3 COPYING.LIB 32BINUTILS_CPE_ID_VENDOR = gnu 33 34ifeq ($(BINUTILS_FROM_GIT),y) 35BINUTILS_DEPENDENCIES += host-flex host-bison 36HOST_BINUTILS_DEPENDENCIES += host-flex host-bison 37endif 38 39# When binutils sources are fetched from the binutils-gdb repository, 40# they also contain the gdb sources, but gdb shouldn't be built, so we 41# disable it. 42BINUTILS_DISABLE_GDB_CONF_OPTS = \ 43 --disable-sim \ 44 --disable-gdb 45 46# We need to specify host & target to avoid breaking ARM EABI 47BINUTILS_CONF_OPTS = \ 48 --disable-multilib \ 49 --disable-werror \ 50 --host=$(GNU_TARGET_NAME) \ 51 --target=$(GNU_TARGET_NAME) \ 52 --enable-install-libiberty \ 53 --enable-build-warnings=no \ 54 --with-system-zlib \ 55 --disable-gprofng \ 56 $(BINUTILS_DISABLE_GDB_CONF_OPTS) \ 57 $(BINUTILS_EXTRA_CONFIG_OPTIONS) 58 59ifeq ($(BR2_PACKAGE_BINUTILS_ENABLE_GOLD),y) 60BINUTILS_CONF_OPTS += --enable-gold 61endif 62 63ifeq ($(BR2_STATIC_LIBS),y) 64BINUTILS_CONF_OPTS += --disable-plugins 65endif 66 67# Don't build documentation. It takes up extra space / build time, 68# and sometimes needs specific makeinfo versions to work 69BINUTILS_CONF_ENV += MAKEINFO=true 70BINUTILS_MAKE_OPTS += MAKEINFO=true 71BINUTILS_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) MAKEINFO=true install 72HOST_BINUTILS_CONF_ENV += MAKEINFO=true 73HOST_BINUTILS_MAKE_OPTS += MAKEINFO=true 74HOST_BINUTILS_INSTALL_OPTS += MAKEINFO=true install 75 76# Workaround a build issue with -Os for ARM Cortex-M cpus. 77# (Binutils 2.25.1 and 2.26.1) 78# https://sourceware.org/bugzilla/show_bug.cgi?id=20552 79ifeq ($(BR2_ARM_CPU_ARMV7M)$(BR2_OPTIMIZE_S),yy) 80BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2" 81endif 82 83# "host" binutils should actually be "cross" 84# We just keep the convention of "host utility" for now 85HOST_BINUTILS_CONF_OPTS = \ 86 --disable-multilib \ 87 --disable-werror \ 88 --target=$(GNU_TARGET_NAME) \ 89 --disable-shared \ 90 --enable-static \ 91 --with-sysroot=$(STAGING_DIR) \ 92 --enable-poison-system-directories \ 93 --without-debuginfod \ 94 --enable-plugins \ 95 --enable-lto \ 96 $(BINUTILS_DISABLE_GDB_CONF_OPTS) \ 97 $(BINUTILS_EXTRA_CONFIG_OPTIONS) 98 99ifeq ($(BR2_BINUTILS_GPROFNG),y) 100HOST_BINUTILS_DEPENDENCIES += host-bison 101HOST_BINUTILS_CONF_OPTS += --enable-gprofng 102else 103HOST_BINUTILS_CONF_OPTS += --disable-gprofng 104endif 105 106ifeq ($(BR2_PACKAGE_BINUTILS_ENABLE_GOLD),y) 107HOST_BINUTILS_CONF_OPTS += --enable-gold 108endif 109 110# binutils run configure script of subdirs at make time, so ensure 111# our TARGET_CONFIGURE_ARGS are taken into consideration for those 112BINUTILS_MAKE_ENV = $(TARGET_CONFIGURE_ARGS) 113 114# We just want libbfd, libiberty and libopcodes, 115# not the full-blown binutils in staging 116define BINUTILS_INSTALL_STAGING_CMDS 117 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(STAGING_DIR) install 118 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/opcodes DESTDIR=$(STAGING_DIR) install 119 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libiberty DESTDIR=$(STAGING_DIR) install 120endef 121 122# If we don't want full binutils on target 123ifneq ($(BR2_PACKAGE_BINUTILS_TARGET),y) 124# libiberty is static-only, so it is only installed to staging, above. 125define BINUTILS_INSTALL_TARGET_CMDS 126 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(TARGET_DIR) install 127 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/opcodes DESTDIR=$(TARGET_DIR) install 128endef 129endif 130 131ifneq ($(ARCH_XTENSA_OVERLAY_FILE),) 132define BINUTILS_XTENSA_OVERLAY_EXTRACT 133 $(call arch-xtensa-overlay-extract,$(@D),binutils) 134endef 135BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT 136BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL) 137HOST_BINUTILS_POST_EXTRACT_HOOKS += BINUTILS_XTENSA_OVERLAY_EXTRACT 138HOST_BINUTILS_EXTRA_DOWNLOADS += $(ARCH_XTENSA_OVERLAY_URL) 139endif 140 141# Hardlinks between binaries in different directories cause a problem 142# with rpath fixup, so we de-hardlink those binaries, and replace them 143# with copies instead. 144BINUTILS_TOOLS = ar as ld ld.bfd nm objcopy objdump ranlib readelf strip 145define HOST_BINUTILS_FIXUP_HARDLINKS 146 $(foreach tool,$(BINUTILS_TOOLS),\ 147 rm -f $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool) && \ 148 cp -a $(HOST_DIR)/bin/$(GNU_TARGET_NAME)-$(tool) \ 149 $(HOST_DIR)/$(GNU_TARGET_NAME)/bin/$(tool) 150 ) 151endef 152HOST_BINUTILS_POST_INSTALL_HOOKS += HOST_BINUTILS_FIXUP_HARDLINKS 153 154$(eval $(autotools-package)) 155$(eval $(host-autotools-package)) 156