2005-07-20 22:58:27 +08: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 14:19:43 +08:00
|
|
|
# Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
|
2005-07-20 22:58:27 +08: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 11:34:52 +08:00
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
|
2006-06-21 14:19:43 +08:00
|
|
|
PKG_NAME:=gcc
|
|
|
|
PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
|
2005-07-20 22:58:27 +08:00
|
|
|
|
2006-11-23 12:08:52 +08:00
|
|
|
PATCH_DIR=./patches/$(PKG_VERSION)
|
2006-06-21 14:19:43 +08:00
|
|
|
PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
|
|
|
|
http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
|
|
|
|
ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
|
2006-11-23 12:08:52 +08:00
|
|
|
PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
|
2007-08-07 08:04:25 +08:00
|
|
|
STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
|
|
|
|
BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
|
2005-07-20 22:58:27 +08:00
|
|
|
|
2006-06-21 14:19:43 +08:00
|
|
|
include $(INCLUDE_DIR)/host-build.mk
|
|
|
|
|
2007-08-07 08:04:25 +08:00
|
|
|
STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
|
|
|
|
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 14:19:43 +08:00
|
|
|
|
|
|
|
define Stage1/Configure
|
2007-08-07 08:04:25 +08: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 14:19:43 +08:00
|
|
|
mkdir -p $(BUILD_DIR1)
|
2006-08-04 19:59:52 +08:00
|
|
|
(cd $(BUILD_DIR1); rm -f config.cache; \
|
2006-11-12 10:45:13 +08:00
|
|
|
SHELL="$(BASH)" \
|
2006-06-21 14:19:43 +08:00
|
|
|
$(PKG_BUILD_DIR)/configure \
|
2007-08-07 08:04:25 +08:00
|
|
|
--prefix=$(TOOLCHAIN_DIR) \
|
2005-07-20 22:58:27 +08:00
|
|
|
--build=$(GNU_HOST_NAME) \
|
|
|
|
--host=$(GNU_HOST_NAME) \
|
|
|
|
--target=$(REAL_GNU_TARGET_NAME) \
|
|
|
|
--enable-languages=c \
|
|
|
|
--disable-shared \
|
2007-08-07 08:04:25 +08:00
|
|
|
--with-sysroot=$(BUILD_DIR_HOST)/uClibc_dev/ \
|
2005-07-20 22:58:27 +08:00
|
|
|
--disable-__cxa_atexit \
|
|
|
|
--enable-target-optspace \
|
|
|
|
--with-gnu-ld \
|
2006-06-21 14:19:43 +08:00
|
|
|
--disable-nls \
|
2007-06-08 18:35:23 +08:00
|
|
|
--disable-libmudflap \
|
2006-05-31 00:53:36 +08:00
|
|
|
);
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
define Stage1/Compile
|
2006-11-12 11:42:05 +08:00
|
|
|
export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
define Stage1/Install
|
2006-11-12 11:42:05 +08:00
|
|
|
export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Stage2/Configure
|
|
|
|
mkdir -p $(BUILD_DIR2)
|
2005-07-20 22:58:27 +08:00
|
|
|
# Important! Required for limits.h to be fixed.
|
2007-08-07 08:04:25 +08: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 19:59:52 +08:00
|
|
|
(cd $(BUILD_DIR2); rm -f config.cache; \
|
2006-11-12 10:45:13 +08:00
|
|
|
SHELL="$(BASH)" \
|
2006-06-21 14:19:43 +08:00
|
|
|
$(PKG_BUILD_DIR)/configure \
|
2007-08-07 08:04:25 +08:00
|
|
|
--prefix=$(TOOLCHAIN_DIR) \
|
2005-07-20 22:58:27 +08: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 14:19:43 +08:00
|
|
|
--disable-nls \
|
2007-06-08 18:35:23 +08:00
|
|
|
--disable-libmudflap \
|
2006-05-31 00:53:36 +08:00
|
|
|
);
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
2007-08-07 08:04:25 +08:00
|
|
|
|
2006-06-21 14:19:43 +08:00
|
|
|
define Stage2/Compile
|
2007-08-07 08:04:25 +08:00
|
|
|
$(MAKE) -C $(BUILD_DIR2) \
|
|
|
|
SHELL="$(BASH)" \
|
|
|
|
all
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
2007-08-07 08:04:25 +08:00
|
|
|
|
2006-06-21 14:19:43 +08:00
|
|
|
define Stage2/Install
|
2007-08-07 08:04:25 +08:00
|
|
|
$(MAKE) -C $(BUILD_DIR2) \
|
|
|
|
SHELL="$(BASH)" \
|
|
|
|
install
|
2005-07-20 22:58:27 +08:00
|
|
|
# Set up the symlinks to enable lying about target name.
|
|
|
|
set -e; \
|
2007-08-07 08:04:25 +08:00
|
|
|
(cd $(TOOLCHAIN_DIR); \
|
2005-07-20 22:58:27 +08:00
|
|
|
ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
|
|
|
|
cd bin; \
|
|
|
|
for app in $(REAL_GNU_TARGET_NAME)-* ; do \
|
2006-08-30 03:30:05 +08:00
|
|
|
ln -sf $$$${app} \
|
|
|
|
$(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
|
2005-07-20 22:58:27 +08:00
|
|
|
done; \
|
|
|
|
);
|
2006-06-21 14:19:43 +08: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 20:13:04 +08:00
|
|
|
(cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
|
2007-06-29 03:52:09 +08:00
|
|
|
$(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(PKG_BUILD_DIR)/libstdc++-v3/configure
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Configure
|
|
|
|
$(call Stage1/Configure)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Compile
|
|
|
|
$(call Stage1/Compile)
|
2007-08-07 08:04:25 +08:00
|
|
|
$(if $(wildcard $(TOOLCHAIN_DIR)/bin/$(GNU_TARGET_NAME)-gcc),,$(call Stage1/Install))
|
2006-06-21 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Install
|
|
|
|
$(call Stage2/Configure)
|
|
|
|
$(call Stage2/Compile)
|
|
|
|
$(call Stage2/Install)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Clean
|
2007-08-07 08:04:25 +08: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 14:19:43 +08:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call HostBuild))
|