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