board/csky: fixup gdb instructions in readme.txt
[buildroot-gz.git] / package / binutils / binutils.mk
blob6d29f245e1784fd98c01353d1e0e9131f4651a2a
1 ################################################################################
3 # binutils
5 ################################################################################
7 # Version is set when using buildroot toolchain.
8 # If not, we do like other packages
9 BINUTILS_VERSION = $(call qstrip,$(BR2_BINUTILS_VERSION))
10 ifeq ($(BINUTILS_VERSION),)
11 ifeq ($(BR2_arc),y)
12 BINUTILS_VERSION = arc-2017.03-eng008
13 else
14 BINUTILS_VERSION = 2.25.1
15 endif
16 endif # BINUTILS_VERSION
18 ifeq ($(BR2_arc),y)
19 BINUTILS_SITE = $(call github,foss-for-synopsys-dwc-arc-processors,binutils-gdb,$(BINUTILS_VERSION))
20 BINUTILS_SOURCE = binutils-$(BINUTILS_VERSION).tar.gz
21 BINUTILS_FROM_GIT = y
22 endif
23 BINUTILS_SITE ?= $(BR2_GNU_MIRROR)/binutils
24 BINUTILS_SOURCE ?= binutils-$(BINUTILS_VERSION).tar.bz2
25 BINUTILS_EXTRA_CONFIG_OPTIONS = $(call qstrip,$(BR2_BINUTILS_EXTRA_CONFIG_OPTIONS))
26 BINUTILS_INSTALL_STAGING = YES
27 BINUTILS_DEPENDENCIES = $(if $(BR2_NEEDS_GETTEXT_IF_LOCALE),gettext)
28 BINUTILS_LICENSE = GPLv3+, libiberty LGPLv2.1+
29 BINUTILS_LICENSE_FILES = COPYING3 COPYING.LIB
31 ifeq ($(BINUTILS_FROM_GIT),y)
32 BINUTILS_DEPENDENCIES += host-flex host-bison
33 HOST_BINUTILS_DEPENDENCIES += host-flex host-bison
34 endif
36 # When binutils sources are fetched from the binutils-gdb repository,
37 # they also contain the gdb sources, but gdb shouldn't be built, so we
38 # disable it.
39 BINUTILS_DISABLE_GDB_CONF_OPTS = \
40 --disable-sim \
41 --disable-gdb
43 # We need to specify host & target to avoid breaking ARM EABI
44 BINUTILS_CONF_OPTS = \
45 --disable-multilib \
46 --disable-werror \
47 --host=$(GNU_TARGET_NAME) \
48 --target=$(GNU_TARGET_NAME) \
49 --enable-install-libiberty \
50 --enable-build-warnings=no \
51 $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
52 $(BINUTILS_EXTRA_CONFIG_OPTIONS)
54 ifeq ($(BR2_STATIC_LIBS),y)
55 BINUTILS_CONF_OPTS += --disable-plugins
56 endif
58 # Don't build documentation. It takes up extra space / build time,
59 # and sometimes needs specific makeinfo versions to work
60 BINUTILS_CONF_ENV += MAKEINFO=true
61 BINUTILS_MAKE_OPTS += MAKEINFO=true
62 BINUTILS_INSTALL_TARGET_OPTS = DESTDIR=$(TARGET_DIR) MAKEINFO=true install
63 HOST_BINUTILS_CONF_ENV += MAKEINFO=true
64 HOST_BINUTILS_MAKE_OPTS += MAKEINFO=true
65 HOST_BINUTILS_INSTALL_OPTS += MAKEINFO=true install
67 # gcc bug with Os/O2/O3, PR77311
68 # error: unable to find a register to spill in class 'CCREGS'
69 ifeq ($(BR2_bfin),y)
70 BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O1"
71 endif
73 # Workaround a build issue with -Os for ARM Cortex-M cpus.
74 # (Binutils 2.25.1 and 2.26.1)
75 # https://sourceware.org/bugzilla/show_bug.cgi?id=20552
76 ifeq ($(BR2_ARM_CPU_ARMV7M)$(BR2_OPTIMIZE_S),yy)
77 BINUTILS_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -O2"
78 endif
80 # Install binutils after busybox to prefer full-blown utilities
81 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
82 BINUTILS_DEPENDENCIES += busybox
83 endif
85 ifeq ($(BR2_PACKAGE_ZLIB),y)
86 BINUTILS_DEPENDENCIES += zlib
87 endif
89 # "host" binutils should actually be "cross"
90 # We just keep the convention of "host utility" for now
91 HOST_BINUTILS_CONF_OPTS = \
92 --disable-multilib \
93 --disable-werror \
94 --target=$(GNU_TARGET_NAME) \
95 --disable-shared \
96 --enable-static \
97 --with-sysroot=$(STAGING_DIR) \
98 --enable-poison-system-directories \
99 $(BINUTILS_DISABLE_GDB_CONF_OPTS) \
100 $(BINUTILS_EXTRA_CONFIG_OPTIONS)
102 # binutils run configure script of subdirs at make time, so ensure
103 # our TARGET_CONFIGURE_ARGS are taken into consideration for those
104 define BINUTILS_BUILD_CMDS
105 $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_ARGS) $(MAKE) $(BINUTILS_MAKE_OPTS) -C $(@D)
106 endef
108 # We just want libbfd, libiberty and libopcodes,
109 # not the full-blown binutils in staging
110 define BINUTILS_INSTALL_STAGING_CMDS
111 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(STAGING_DIR) install
112 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/opcodes DESTDIR=$(STAGING_DIR) install
113 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libiberty DESTDIR=$(STAGING_DIR) install
114 endef
116 # If we don't want full binutils on target
117 ifneq ($(BR2_PACKAGE_BINUTILS_TARGET),y)
118 define BINUTILS_INSTALL_TARGET_CMDS
119 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/bfd DESTDIR=$(TARGET_DIR) install
120 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/libiberty DESTDIR=$(STAGING_DIR) install
121 endef
122 endif
124 XTENSA_CORE_NAME = $(call qstrip, $(BR2_XTENSA_CORE_NAME))
125 ifneq ($(XTENSA_CORE_NAME),)
126 define BINUTILS_XTENSA_PRE_PATCH
127 tar xf $(BR2_XTENSA_OVERLAY_DIR)/xtensa_$(XTENSA_CORE_NAME).tar \
128 -C $(@D) --strip-components=1 binutils
129 endef
130 BINUTILS_PRE_PATCH_HOOKS += BINUTILS_XTENSA_PRE_PATCH
131 HOST_BINUTILS_PRE_PATCH_HOOKS += BINUTILS_XTENSA_PRE_PATCH
132 endif
134 ifeq ($(BR2_BINUTILS_ENABLE_LTO),y)
135 HOST_BINUTILS_CONF_OPTS += --enable-plugins --enable-lto
136 endif
138 $(eval $(autotools-package))
139 $(eval $(host-autotools-package))