Root/gcc-mips/Makefile

1#
2# Copyright (C) 2008 OpenWrt.org
3#
4# This is free software, licensed under the GNU General Public License v2.
5# See /LICENSE for more information.
6#
7include $(TOPDIR)/rules.mk
8PKG_NAME:=gcc
9#PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
10PKG_VERSION:=4.6.2
11PKG_RELEASE:=1
12PATCH_DIR=$(TOPDIR)/toolchain/gcc/patches/$(PKG_VERSION)
13PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
14    http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
15        ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
16
17PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
18PKG_MD5SUM:=028115c4fbfb6cfd75d6369f4a90d87e
19PKG_INSTALL:=1
20PKG_FIXUP:=libtool
21
22include $(INCLUDE_DIR)/package.mk
23
24SEP:=,
25TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
26EXTRA_TARGET=$(if $(CONFIG_EXTRA_TARGET_ARCH),--enable-biarch --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-uclibc)
27
28STRIP:=$(STAGING_DIR_HOST)/bin/sstrip
29RSTRIP:= \
30    NM="$(TARGET_CROSS)nm" \
31    STRIP="$(STRIP) --strip-debug" \
32    STRIP_KMOD="$(TARGET_CROSS)strip --strip-debug" \
33    $(SCRIPT_DIR)/rstrip.sh
34
35define Package/gcc-mips
36  SECTION:=devel
37  CATEGORY:=Development
38  TITLE:=gcc-mips
39  DEPENDS:=+mpfr +binutils +libmpc
40endef
41
42define Package/gcc-mips/description
43    build a native toolchain for compiling on target
44endef
45
46define Build/Prepare
47    $(call Build/Prepare/Default)
48    ($(CP) ./patches $(PKG_BUILD_DIR); cd $(PKG_BUILD_DIR); patch -Np1 < ./patches/001-cache-amnesia.patch;);
49    (cd $(PKG_BUILD_DIR)/libstdc++-v3; \
50    $(SED) 's/m4_rename(/m4_rename_force(/' acinclude.m4;);
51endef
52
53define Build/Configure
54    $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(PKG_BUILD_DIR)/libstdc++-v3/configure
55    $(SED) 's/\"CFLAGS=/\"CFLAGS=$(FPIC) /' $(PKG_BUILD_DIR)/libstdc++-v3/Makefile.am
56    (cd $(PKG_BUILD_DIR); rm -f config.cache; \
57        SHELL="$(BASH)" \
58        $(TARGET_CONFIGURE_OPTS) \
59        $(PKG_BUILD_DIR)/configure \
60            $(TARGET_CONFIGURE_ARGS) \
61            --build=$(GNU_HOST_NAME) \
62            --host=$(REAL_GNU_TARGET_NAME) \
63            --target=$(REAL_GNU_TARGET_NAME) \
64            --enable-languages=$(TARGET_LANGUAGES) \
65            --enable-shared \
66            --disable-__cxa_atexit \
67            --enable-target-optspace \
68            --with-gnu-ld \
69            --disable-nls \
70            --disable-libmudflap \
71            --disable-multilib \
72            --with-gmp=$(STAGING_DIR)/usr \
73            --with-mpc=$(STAGING_DIR)/usr \
74            --with-mpfr=$(STAGING_DIR)/usr \
75            --disable-libstdcxx-pch \
76            --prefix=/usr \
77            $(EXTRA_TARGET) \
78            $(SOFT_FLOAT_CONFIG_OPTION) \
79            $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
80    );
81endef
82
83define Build/Compile
84    export SHELL="$(BASH)"; $(MAKE_VARS) $(MAKE) -C $(PKG_BUILD_DIR) \
85            DESTDIR="$(PKG_INSTALL_DIR)" $(MAKE_ARGS) all install
86endef
87
88define Package/gcc-mips/install
89    $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
90    cp -ar $(PKG_INSTALL_DIR)/usr/{include,libexec} $(1)/usr
91    cp -a $(PKG_INSTALL_DIR)/usr/bin/{$(REAL_GNU_TARGET_NAME)-{g++,gcc},cpp,gcov} $(1)/usr/bin
92    ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/c++
93    ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/g++
94    ln -s $(REAL_GNU_TARGET_NAME)-g++ $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-c++
95    ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/gcc
96    ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc-$(PKG_VERSION)
97    cp -a $(PKG_INSTALL_DIR)/usr/lib/*.a $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
98    cp -ar $(PKG_INSTALL_DIR)/usr/lib/gcc $(1)/usr/lib
99    cp -ar $(TOOLCHAIN_DIR)/include $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
100    cp -a $(TOOLCHAIN_DIR)/lib/*.{a,o,so*} $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
101endef
102
103define Package/gcc-mips/postinst
104#!/bin/sh
105#we use some files from host's openwrt toolchain for gcc-mips package,
106#and the host's gcc version (linaro) is now 4.6.3.
107#workaround for now
108for i in $$(find $${IPKG_INSTROOT}/usr/lib/gcc/mipsel-openwrt-linux-uclibc/4.6.3 -type f); do
109    ln -s ../4.6.3/$${i##*/} $${i/4.6.3/4.6.2}
110done
111endef
112
113$(eval $(call BuildPackage,gcc-mips))
114

Archive Download this file



interactive