2005-07-20 17:58:27 +03:00
|
|
|
# Makefile for to build a gcc/uClibc toolchain
|
|
|
|
#
|
|
|
|
# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
|
|
|
|
# Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
|
2006-06-21 09:19:43 +03:00
|
|
|
# Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
|
2005-07-20 17:58:27 +03:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
2005-03-06 05:34:52 +02:00
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
2006-06-21 09:19:43 +03:00
|
|
|
PKG_NAME:=gcc
|
2008-07-15 02:24:58 +03:00
|
|
|
PKG_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
|
2005-07-20 17:58:27 +03:00
|
|
|
|
2008-11-08 23:18:33 +02:00
|
|
|
PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
|
|
|
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
|
|
|
|
|
|
|
ifeq ($(PKG_VERSION),3.4.6)
|
|
|
|
PKG_MD5SUM:=4a21ac777d4b5617283ce488b808da7b
|
|
|
|
endif
|
|
|
|
ifeq ($(PKG_VERSION),4.1.2)
|
|
|
|
PKG_MD5SUM:=a4a3eb15c96030906d8494959eeda23c
|
|
|
|
endif
|
|
|
|
ifeq ($(PKG_VERSION),4.2.0)
|
|
|
|
PKG_MD5SUM:=4798c23548dc791ea12a139e18940684
|
|
|
|
endif
|
|
|
|
ifeq ($(PKG_VERSION),4.2.1)
|
|
|
|
PKG_MD5SUM:=cba410e6ff70f7d7f4be7a0267707fd0
|
|
|
|
endif
|
|
|
|
ifeq ($(PKG_VERSION),4.2.2)
|
|
|
|
PKG_MD5SUM:=7ae33781417a35a2eb03ee098a9f4490
|
|
|
|
endif
|
|
|
|
ifeq ($(PKG_VERSION),4.2.3)
|
|
|
|
PKG_MD5SUM:=ef2a4d9991b3644115456ea05b2b8163
|
|
|
|
endif
|
|
|
|
ifeq ($(PKG_VERSION),4.2.4)
|
|
|
|
PKG_MD5SUM:=d79f553e7916ea21c556329eacfeaa16
|
|
|
|
endif
|
|
|
|
|
2006-11-23 06:08:52 +02:00
|
|
|
PATCH_DIR=./patches/$(PKG_VERSION)
|
2008-11-08 23:18:33 +02:00
|
|
|
|
2007-08-07 03:04:25 +03:00
|
|
|
STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
|
|
|
|
BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
|
2008-09-02 13:57:35 +03:00
|
|
|
override CONFIG_AUTOREBUILD=
|
2005-07-20 17:58:27 +03:00
|
|
|
|
2006-06-21 09:19:43 +03:00
|
|
|
include $(INCLUDE_DIR)/host-build.mk
|
|
|
|
|
2007-11-20 21:58:49 +02:00
|
|
|
STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
|
2007-08-07 03:04:25 +03:00
|
|
|
BUILD_DIR1:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-initial
|
|
|
|
BUILD_DIR2:=$(BUILD_DIR_HOST)/gcc-$(PKG_VERSION)-final
|
|
|
|
|
|
|
|
SEP:=,
|
|
|
|
TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
|
2006-06-21 09:19:43 +03:00
|
|
|
|
2008-07-30 15:54:28 +03:00
|
|
|
ifeq ($(CONFIG_SSP_SUPPORT),y)
|
|
|
|
SSP:=--enable-ssp
|
|
|
|
else
|
|
|
|
SSP:=--disable-ssp
|
|
|
|
endif
|
|
|
|
|
2008-04-13 02:14:42 +03:00
|
|
|
EXTRA_TARGET=$(if $(CONFIG_EXTRA_TARGET_ARCH),--enable-biarch --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-uclibc)
|
|
|
|
|
2006-06-21 09:19:43 +03:00
|
|
|
define Stage1/Configure
|
2007-08-07 03:04:25 +03:00
|
|
|
$(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
|
|
|
|
$(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
|
2006-06-21 09:19:43 +03:00
|
|
|
mkdir -p $(BUILD_DIR1)
|
2006-08-04 14:59:52 +03:00
|
|
|
(cd $(BUILD_DIR1); rm -f config.cache; \
|
2006-11-12 04:45:13 +02:00
|
|
|
SHELL="$(BASH)" \
|
2006-06-21 09:19:43 +03:00
|
|
|
$(PKG_BUILD_DIR)/configure \
|
2007-08-07 03:04:25 +03:00
|
|
|
--prefix=$(TOOLCHAIN_DIR) \
|
2005-07-20 17:58:27 +03:00
|
|
|
--build=$(GNU_HOST_NAME) \
|
|
|
|
--host=$(GNU_HOST_NAME) \
|
|
|
|
--target=$(REAL_GNU_TARGET_NAME) \
|
|
|
|
--enable-languages=c \
|
|
|
|
--disable-shared \
|
2007-08-07 03:04:25 +03:00
|
|
|
--with-sysroot=$(BUILD_DIR_HOST)/uClibc_dev/ \
|
2005-07-20 17:58:27 +03:00
|
|
|
--disable-__cxa_atexit \
|
|
|
|
--enable-target-optspace \
|
|
|
|
--with-gnu-ld \
|
2006-06-21 09:19:43 +03:00
|
|
|
--disable-nls \
|
2007-06-08 13:35:23 +03:00
|
|
|
--disable-libmudflap \
|
2007-08-23 19:08:09 +03:00
|
|
|
--disable-multilib \
|
2008-07-30 15:54:28 +03:00
|
|
|
$(SSP) \
|
2008-04-13 02:14:42 +03:00
|
|
|
$(EXTRA_TARGET) \
|
2007-12-28 20:06:47 +02:00
|
|
|
$(SOFT_FLOAT_CONFIG_OPTION) \
|
2007-10-23 09:23:17 +03:00
|
|
|
$(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
|
2006-05-30 19:53:36 +03:00
|
|
|
);
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
define Stage1/Compile
|
2006-11-12 05:42:05 +02:00
|
|
|
export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
define Stage1/Install
|
2006-11-12 05:42:05 +02:00
|
|
|
export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Stage2/Configure
|
2008-04-22 23:30:55 +03:00
|
|
|
mkdir -p $(BUILD_DIR2) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
|
2005-07-20 17:58:27 +03:00
|
|
|
# Important! Required for limits.h to be fixed.
|
2007-08-07 03:04:25 +03:00
|
|
|
rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
|
|
|
|
ln -sf ../include $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
|
|
|
|
rm -rf $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
|
|
|
|
ln -sf ../lib $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)/lib
|
2006-08-04 14:59:52 +03:00
|
|
|
(cd $(BUILD_DIR2); rm -f config.cache; \
|
2006-11-12 04:45:13 +02:00
|
|
|
SHELL="$(BASH)" \
|
2006-06-21 09:19:43 +03:00
|
|
|
$(PKG_BUILD_DIR)/configure \
|
2007-08-07 03:04:25 +03:00
|
|
|
--prefix=$(TOOLCHAIN_DIR) \
|
2005-07-20 17:58:27 +03:00
|
|
|
--build=$(GNU_HOST_NAME) \
|
|
|
|
--host=$(GNU_HOST_NAME) \
|
|
|
|
--target=$(REAL_GNU_TARGET_NAME) \
|
|
|
|
--enable-languages=$(TARGET_LANGUAGES) \
|
|
|
|
--enable-shared \
|
|
|
|
--disable-__cxa_atexit \
|
|
|
|
--enable-target-optspace \
|
|
|
|
--with-gnu-ld \
|
2006-06-21 09:19:43 +03:00
|
|
|
--disable-nls \
|
2007-06-08 13:35:23 +03:00
|
|
|
--disable-libmudflap \
|
2007-08-26 16:00:27 +03:00
|
|
|
--disable-multilib \
|
2008-07-30 15:54:28 +03:00
|
|
|
$(SSP) \
|
2008-04-13 02:14:42 +03:00
|
|
|
$(EXTRA_TARGET) \
|
2007-12-28 20:06:47 +02:00
|
|
|
$(SOFT_FLOAT_CONFIG_OPTION) \
|
2007-10-23 09:23:17 +03:00
|
|
|
$(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
|
2006-05-30 19:53:36 +03:00
|
|
|
);
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
2007-08-07 03:04:25 +03:00
|
|
|
|
2006-06-21 09:19:43 +03:00
|
|
|
define Stage2/Compile
|
2007-08-13 19:26:58 +03:00
|
|
|
export SHELL="\$(BASH)"; \$(MAKE) -C \$(BUILD_DIR2) all
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
2007-08-07 03:04:25 +03:00
|
|
|
|
2008-04-13 02:14:42 +03:00
|
|
|
define SetupExtraArch
|
|
|
|
for app in $(TOOLCHAIN_DIR)/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
|
|
|
|
[ -e $$$$app ] || continue; \
|
|
|
|
old_base=$$$$(basename $$$$app); \
|
|
|
|
new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
|
|
|
|
sed -e "s/@CC_BASE@/$$$$old_base/" \
|
|
|
|
-e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
|
|
|
|
./files/alternate-arch-cc.in > \
|
|
|
|
$(TOOLCHAIN_DIR)/bin/$$$$new_base; \
|
|
|
|
chmod a+x $(TOOLCHAIN_DIR)/bin/$$$$new_base; \
|
|
|
|
done
|
|
|
|
endef
|
|
|
|
|
2006-06-21 09:19:43 +03:00
|
|
|
define Stage2/Install
|
2007-08-07 03:04:25 +03:00
|
|
|
$(MAKE) -C $(BUILD_DIR2) \
|
|
|
|
SHELL="$(BASH)" \
|
|
|
|
install
|
2005-07-20 17:58:27 +03:00
|
|
|
# Set up the symlinks to enable lying about target name.
|
|
|
|
set -e; \
|
2007-08-07 03:04:25 +03:00
|
|
|
(cd $(TOOLCHAIN_DIR); \
|
2005-07-20 17:58:27 +03:00
|
|
|
ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
|
|
|
|
cd bin; \
|
|
|
|
for app in $(REAL_GNU_TARGET_NAME)-* ; do \
|
2006-08-29 22:30:05 +03:00
|
|
|
ln -sf $$$${app} \
|
|
|
|
$(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
|
2005-07-20 17:58:27 +03:00
|
|
|
done; \
|
|
|
|
);
|
2008-04-13 02:14:42 +03:00
|
|
|
$(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Prepare
|
|
|
|
$(call Build/Prepare/Default)
|
|
|
|
$(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
|
|
|
|
$(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
|
2006-11-21 14:13:04 +02:00
|
|
|
(cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
|
2007-06-28 22:52:09 +03:00
|
|
|
$(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(PKG_BUILD_DIR)/libstdc++-v3/configure
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Configure
|
|
|
|
$(call Stage1/Configure)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Compile
|
|
|
|
$(call Stage1/Compile)
|
2007-08-07 03:04:25 +03:00
|
|
|
$(if $(wildcard $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gcc),,$(call Stage1/Install))
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Install
|
|
|
|
$(call Stage2/Configure)
|
|
|
|
$(call Stage2/Compile)
|
|
|
|
$(call Stage2/Install)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Clean
|
2007-08-07 03:04:25 +03:00
|
|
|
rm -rf \
|
|
|
|
$(PKG_BUILD_DIR) \
|
|
|
|
$(BUILD_DIR1) \
|
|
|
|
$(BUILD_DIR2) \
|
|
|
|
$(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME) \
|
|
|
|
$(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc* \
|
|
|
|
$(TOOLCHAIN_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call HostBuild))
|