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
|
|
|
|
PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
|
2005-07-20 17:58:27 +03:00
|
|
|
|
2006-06-21 09:19:43 +03:00
|
|
|
PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
|
|
|
|
PKG_MD5SUM:=unknown
|
|
|
|
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)
|
|
|
|
PKG_CAT:=bzcat
|
2005-07-20 17:58:27 +03:00
|
|
|
|
2006-09-27 17:06:46 +03:00
|
|
|
PKG_BUILD_DIR:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)
|
2005-07-20 17:58:27 +03:00
|
|
|
|
|
|
|
TARGET_LANGUAGES:=c
|
2006-06-21 09:19:43 +03:00
|
|
|
ifeq ($(CONFIG_INSTALL_LIBSTDCPP),y)
|
|
|
|
TARGET_LANGUAGES:=$(TARGET_LANGUAGES),c++
|
2005-07-20 17:58:27 +03:00
|
|
|
endif
|
2006-06-21 09:19:43 +03:00
|
|
|
ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
|
|
|
|
TARGET_LANGUAGES:=$(TARGET_LANGUAGES),java
|
2005-07-20 17:58:27 +03:00
|
|
|
endif
|
|
|
|
|
2006-06-21 09:19:43 +03:00
|
|
|
include $(INCLUDE_DIR)/host-build.mk
|
|
|
|
|
2006-09-27 17:06:46 +03:00
|
|
|
BUILD_DIR1:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-initial
|
|
|
|
BUILD_DIR2:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-final
|
2006-06-21 09:19:43 +03:00
|
|
|
|
|
|
|
define Stage1/Configure
|
|
|
|
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 \
|
2005-07-20 17:58:27 +03:00
|
|
|
--prefix=$(STAGING_DIR) \
|
|
|
|
--build=$(GNU_HOST_NAME) \
|
|
|
|
--host=$(GNU_HOST_NAME) \
|
|
|
|
--target=$(REAL_GNU_TARGET_NAME) \
|
|
|
|
--enable-languages=c \
|
|
|
|
--disable-shared \
|
2006-09-27 17:06:46 +03:00
|
|
|
--with-sysroot=$(TOOLCHAIN_BUILD_DIR)/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 \
|
2006-05-30 19:53:36 +03:00
|
|
|
);
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
define Stage1/Compile
|
2006-11-12 04:45:13 +02:00
|
|
|
$(MAKE) -C $(BUILD_DIR1) all-gcc SHELL="$(BASH)"
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
define Stage1/Install
|
2006-11-12 04:45:13 +02:00
|
|
|
$(MAKE) -C $(BUILD_DIR1) install-gcc SHELL="$(BASH)"
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Stage2/Configure
|
|
|
|
mkdir -p $(BUILD_DIR2)
|
2005-07-20 17:58:27 +03:00
|
|
|
# Important! Required for limits.h to be fixed.
|
|
|
|
rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
|
|
|
|
ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
|
|
|
|
rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
|
|
|
|
ln -sf ../lib $(STAGING_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 \
|
2005-07-20 17:58:27 +03:00
|
|
|
--prefix=$(STAGING_DIR) \
|
|
|
|
--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 \
|
2006-05-30 19:53:36 +03:00
|
|
|
);
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
define Stage2/Compile
|
2006-11-12 04:45:13 +02:00
|
|
|
$(MAKE) -C $(BUILD_DIR2) all SHELL="$(BASH)"
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
define Stage2/Install
|
2006-11-12 04:45:13 +02:00
|
|
|
$(MAKE) -C $(BUILD_DIR2) install SHELL="$(BASH)"
|
2006-06-21 09:19:43 +03:00
|
|
|
echo $(PKG_VERSION) > $(STAGING_DIR)/gcc_version
|
2005-07-20 17:58:27 +03:00
|
|
|
# Set up the symlinks to enable lying about target name.
|
|
|
|
set -e; \
|
|
|
|
(cd $(STAGING_DIR); \
|
|
|
|
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; \
|
|
|
|
);
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Prepare
|
|
|
|
$(call Build/Prepare/Default)
|
|
|
|
$(SCRIPT_DIR)/patch-kernel.sh $(PKG_BUILD_DIR) ./patches/$(PKG_VERSION) \*.patch
|
|
|
|
$(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
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Configure
|
|
|
|
$(call Stage1/Configure)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Compile
|
|
|
|
$(call Stage1/Compile)
|
|
|
|
$(call Stage1/Install)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Install
|
|
|
|
$(call Stage2/Configure)
|
|
|
|
$(call Stage2/Compile)
|
|
|
|
$(call Stage2/Install)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define Build/Clean
|
|
|
|
rm -rf $(PKG_BUILD_DIR)
|
|
|
|
rm -rf $(BUILD_DIR1)
|
|
|
|
rm -rf $(BUILD_DIR2)
|
2005-07-20 17:58:27 +03:00
|
|
|
rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
|
|
|
|
rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
|
2006-06-21 09:19:43 +03:00
|
|
|
endef
|
|
|
|
|
|
|
|
$(eval $(call HostBuild))
|