820b5f8efaec6408af7ecdef2de2ed6206c0bf49
[openwrt/openwrt.git] / toolchain / binutils / Makefile
1 #
2 # Copyright (C) 2006-2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8
9 PKG_NAME:=binutils
10 PKG_VERSION:=$(call qstrip,$(CONFIG_BINUTILS_VERSION))
11 BIN_VERSION:=$(PKG_VERSION)
12
13 ifeq ($(findstring linaro, $(CONFIG_BINUTILS_VERSION)),linaro)
14 PKG_SOURCE_URL:=https://releases.linaro.org/14.09/components/toolchain/binutils-linaro/
15 PKG_REV:=2.24.0-2014.09
16 PKG_SOURCE:=$(PKG_NAME)-linaro-$(PKG_REV).tar.xz
17 PKG_MD5SUM:=8f9b2b2e049d59b1b86ce9657802a353
18 BINUTILS_DIR:=$(PKG_NAME)-linaro-$(PKG_REV)
19 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(BINUTILS_DIR)
20 else
21 PKG_SOURCE_URL:=@GNU/binutils/
22 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
23
24 ifeq ($(PKG_VERSION),2.20.1)
25 PKG_MD5SUM:=9cdfb9d6ec0578c166d3beae5e15c4e5
26 endif
27 endif
28
29 HOST_BUILD_PARALLEL:=1
30
31 PATCH_DIR:=./patches/$(PKG_VERSION)
32
33 REAL_STAGING_DIR_HOST:=$(STAGING_DIR_HOST)
34
35 include $(INCLUDE_DIR)/toolchain-build.mk
36
37 BINUTILS_CONFIGURE:= \
38 ./configure \
39 --prefix=$(TOOLCHAIN_DIR) \
40 --build=$(GNU_HOST_NAME) \
41 --host=$(GNU_HOST_NAME) \
42 --target=$(REAL_GNU_TARGET_NAME) \
43 --with-sysroot=$(TOOLCHAIN_DIR) \
44 --disable-multilib \
45 --disable-werror \
46 --disable-nls \
47 $(GRAPHITE_CONFIGURE) \
48 $(SOFT_FLOAT_CONFIG_OPTION) \
49 $(call qstrip,$(CONFIG_EXTRA_BINUTILS_CONFIG_OPTIONS))
50
51 ifneq ($(CONFIG_SSP_SUPPORT),)
52 BINUTILS_CONFIGURE+= \
53 --enable-libssp
54 else
55 BINUTILS_CONFIGURE+= \
56 --disable-libssp
57 endif
58
59 ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
60 BINUTILS_CONFIGURE+= \
61 --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
62 endif
63
64 define Host/Prepare
65 $(call Host/Prepare/Default)
66 ln -snf $(notdir $(HOST_BUILD_DIR)) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
67 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(HOST_BUILD_DIR)/
68 $(SED) 's, " Linaro.*,,' $(HOST_BUILD_DIR)/bfd/version.h
69 endef
70
71 define Host/Configure
72 (cd $(HOST_BUILD_DIR); \
73 $(BINUTILS_CONFIGURE) \
74 );
75 endef
76
77 define Host/Compile
78 +$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR) all
79 endef
80
81 define Host/Install
82 mkdir -p $(TOOLCHAIN_DIR)/initial
83 $(MAKE) -C $(HOST_BUILD_DIR) \
84 prefix=$(TOOLCHAIN_DIR)/initial \
85 install
86 $(call FixupLibdir,$(TOOLCHAIN_DIR)/initial)
87 $(RM) $(TOOLCHAIN_DIR)/initial/lib/libiberty.a
88 $(CP) $(TOOLCHAIN_DIR)/initial/. $(TOOLCHAIN_DIR)/
89 $(CP) $(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-readelf $(REAL_STAGING_DIR_HOST)/bin/readelf
90 endef
91
92 define Host/Clean
93 rm -rf \
94 $(HOST_BUILD_DIR) \
95 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
96 endef
97
98 $(eval $(call HostBuild))