2005-07-20 14:58:27 +00: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 06:19:43 +00:00
|
|
|
# Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
|
2005-07-20 14:58:27 +00: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 03:34:52 +00:00
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
2006-06-21 06:19:43 +00:00
|
|
|
PKG_NAME:=gcc
|
2008-07-14 23:24:58 +00:00
|
|
|
PKG_VERSION:=$(call qstrip,$(CONFIG_GCC_VERSION))
|
2005-07-20 14:58:27 +00:00
|
|
|
|
2008-11-08 21:18:33 +00: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.4)
|
|
|
|
PKG_MD5SUM:=d79f553e7916ea21c556329eacfeaa16
|
|
|
|
endif
|
|
|
|
|
2006-11-23 04:08:52 +00:00
|
|
|
PATCH_DIR=./patches/$(PKG_VERSION)
|
2008-11-08 21:18:33 +00:00
|
|
|
|
2007-08-07 00:04:25 +00:00
|
|
|
STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
|
|
|
|
BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
|
2008-09-02 10:57:35 +00:00
|
|
|
override CONFIG_AUTOREBUILD=
|
2005-07-20 14:58:27 +00:00
|
|
|
|
2006-06-21 06:19:43 +00:00
|
|
|
include $(INCLUDE_DIR)/host-build.mk
|
|
|
|
|
2007-11-20 19:58:49 +00:00
|
|
|
STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
|
2007-08-07 00:04:25 +00: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 06:19:43 +00:00
|
|
|
|
2008-07-30 12:54:28 +00:00
|
|
|
ifeq ($(CONFIG_SSP_SUPPORT),y)
|
|
|
|
SSP:=--enable-ssp
|
|
|
|
else
|
|
|
|
SSP:=--disable-ssp
|
|
|
|
endif
|
|
|
|
|
2008-04-12 23:14:42 +00:00
|
|
|
EXTRA_TARGET=$(if $(CONFIG_EXTRA_TARGET_ARCH),--enable-biarch --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-uclibc)
|
|
|
|
|
2006-06-21 06:19:43 +00:00
|
|
|
define Stage1/Configure
|
2007-08-07 00:04:25 +00: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 06:19:43 +00:00
|
|
|
mkdir -p $(BUILD_DIR1)
|
2006-08-04 11:59:52 +00:00
|
|
|
(cd $(BUILD_DIR1); rm -f config.cache; \
|
2006-11-12 02:45:13 +00:00
|
|
|
SHELL="$(BASH)" \
|
2006-06-21 06:19:43 +00:00
|
|
|
$(PKG_BUILD_DIR)/configure \
|
2007-08-07 00:04:25 +00:00
|
|
|
--prefix=$(TOOLCHAIN_DIR) \
|
2005-07-20 14:58:27 +00:00
|
|
|
--build=$(GNU_HOST_NAME) \
|
|
|
|
--host=$(GNU_HOST_NAME) \
|
|
|
|
--target=$(REAL_GNU_TARGET_NAME) \
|
|
|
|
--enable-languages=c \
|
|
|
|
--disable-shared \
|
2007-08-07 00:04:25 +00:00
|
|
|
--with-sysroot=$(BUILD_DIR_HOST)/uClibc_dev/ \
|
2005-07-20 14:58:27 +00:00
|
|
|
--disable-__cxa_atexit \
|
|
|
|
--enable-target-optspace \
|
|
|
|
--with-gnu-ld \
|
2006-06-21 06:19:43 +00:00
|
|
|
--disable-nls \
|
2007-06-08 10:35:23 +00:00
|
|
|
--disable-libmudflap \
|
2007-08-23 16:08:09 +00:00
|
|
|
--disable-multilib \
|
2008-07-30 12:54:28 +00:00
|
|
|
$(SSP) \
|
2008-04-12 23:14:42 +00:00
|
|
|
$(EXTRA_TARGET) \
|
2007-12-28 18:06:47 +00:00
|
|
|
$(SOFT_FLOAT_CONFIG_OPTION) \
|
2007-10-23 06:23:17 +00:00
|
|
|
$(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
|
2006-05-30 16:53:36 +00:00
|
|
|
);
|
2006-06-21 06:19:43 +00:00
|
|
|
endef
|
|
|
|
define Stage1/Compile
|
2006-11-12 03:42:05 +00:00
|
|
|
export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
|
2006-06-21 06:19:43 +00:00
|
|
|
endef
|
|
|
|
define Stage1/Install
|
2006-11-12 03:42:05 +00:00
|
|
|
export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
|
2006-06-21 06:19:43 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Stage2/Configure
|
2008-04-22 20:30:55 +00:00
|
|
|
mkdir -p $(BUILD_DIR2) $(TOOLCHAIN_DIR)/$(REAL_GNU_TARGET_NAME)
|
2005-07-20 14:58:27 +00:00
|
|
|
# Important! Required for limits.h to be fixed.
|
2007-08-07 00:04:25 +00: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 11:59:52 +00:00
|
|
|
(cd $(BUILD_DIR2); rm -f config.cache; \
|
2006-11-12 02:45:13 +00:00
|
|
|
SHELL="$(BASH)" \
|
2006-06-21 06:19:43 +00:00
|
|
|
$(PKG_BUILD_DIR)/configure \
|
2007-08-07 00:04:25 +00:00
|
|
|
--prefix=$(TOOLCHAIN_DIR) \
|
2005-07-20 14:58:27 +00: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 06:19:43 +00:00
|
|
|
--disable-nls \
|
2007-06-08 10:35:23 +00:00
|
|
|
--disable-libmudflap \
|
2007-08-26 13:00:27 +00:00
|
|
|
--disable-multilib \
|
2008-07-30 12:54:28 +00:00
|
|
|
$(SSP) \
|
2008-04-12 23:14:42 +00:00
|
|
|
$(EXTRA_TARGET) \
|
2007-12-28 18:06:47 +00:00
|
|
|
$(SOFT_FLOAT_CONFIG_OPTION) \
|
2007-10-23 06:23:17 +00:00
|
|
|
$(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
|
2006-05-30 16:53:36 +00:00
|
|
|
);
|
2006-06-21 06:19:43 +00:00
|
|
|
endef
|
2007-08-07 00:04:25 +00:00
|
|
|
|
2006-06-21 06:19:43 +00:00
|
|
|
define Stage2/Compile
|
2007-08-13 16:26:58 +00:00
|
|
|
export SHELL="\$(BASH)"; \$(MAKE) -C \$(BUILD_DIR2) all
|
2006-06-21 06:19:43 +00:00
|
|
|
endef
|
2007-08-07 00:04:25 +00:00
|
|
|
|
2008-04-12 23:14:42 +00: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 06:19:43 +00:00
|
|
|
define Stage2/Install
|
2007-08-07 00:04:25 +00:00
|
|
|
$(MAKE) -C $(BUILD_DIR2) \
|
|
|
|
SHELL="$(BASH)" \
|
|
|
|
install
|
2005-07-20 14:58:27 +00:00
|
|
|
# Set up the symlinks to enable lying about target name.
|
|
|
|
set -e; \
|
2007-08-07 00:04:25 +00:00
|
|
|
(cd $(TOOLCHAIN_DIR); \
|
2005-07-20 14:58:27 +00:00
|
|
|
ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
|
|
|
|
cd bin; \
|
|
|
|
for app in $(REAL_GNU_TARGET_NAME)-* ; do \
|
2006-08-29 19:30:05 +00:00
|
|
|
ln -sf $$$${app} \
|
|
|
|
$(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
|
2005-07-20 14:58:27 +00:00
|
|
|
done; \
|
|
|
|
);
|
2008-04-12 23:14:42 +00:00
|
|
|
$(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
|
2006-06-21 06:19:43 +00: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 12:13:04 +00:00
|
|
|
(cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
|
2007-06-28 19:52:09 +00:00
|
|
|
$(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(PKG_BUILD_DIR)/libstdc++-v3/configure
|
2006-06-21 06:19:43 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Configure
|
|
|
|
$(call Stage1/Configure)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Compile
|
|
|
|
$(call Stage1/Compile)
|
2007-08-07 00:04:25 +00:00
|
|
|
$(if $(wildcard $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gcc),,$(call Stage1/Install))
|
2006-06-21 06:19:43 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Install
|
|
|
|
$(call Stage2/Configure)
|
|
|
|
$(call Stage2/Compile)
|
|
|
|
$(call Stage2/Install)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Clean
|
2007-08-07 00:04:25 +00: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 06:19:43 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call HostBuild))
|