fix the gcc stampfile for initial stage installation
[openwrt/staging/chunkeey.git] / toolchain / gcc / Makefile
1 # Makefile for to build a gcc/uClibc toolchain
2 #
3 # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
4 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
5 # Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21 include $(TOPDIR)/rules.mk
22
23 PKG_NAME:=gcc
24 PKG_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))#"))
25
26 PATCH_DIR=./patches/$(PKG_VERSION)
27 PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
28 http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
29 ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
30
31 PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
32 PKG_MD5SUM:=unknown
33 PKG_CAT:=bzcat
34
35 PKG_BUILD_DIR:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)
36
37 TARGET_LANGUAGES:=c
38 ifeq ($(CONFIG_INSTALL_LIBSTDCPP),y)
39 TARGET_LANGUAGES:=$(TARGET_LANGUAGES),c++
40 endif
41 ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
42 TARGET_LANGUAGES:=$(TARGET_LANGUAGES),java
43 endif
44
45 include $(INCLUDE_DIR)/host-build.mk
46
47 STAMP_BUILT:=$(STAGING_DIR)/stampfiles/.host_gcc-initial_installed
48 BUILD_DIR1:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-initial
49 BUILD_DIR2:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-final
50
51 define Stage1/Configure
52 mkdir -p $(BUILD_DIR1)
53 (cd $(BUILD_DIR1); rm -f config.cache; \
54 SHELL="$(BASH)" \
55 $(PKG_BUILD_DIR)/configure \
56 --prefix=$(STAGING_DIR) \
57 --build=$(GNU_HOST_NAME) \
58 --host=$(GNU_HOST_NAME) \
59 --target=$(REAL_GNU_TARGET_NAME) \
60 --enable-languages=c \
61 --disable-shared \
62 --with-sysroot=$(TOOLCHAIN_BUILD_DIR)/uClibc_dev/ \
63 --disable-__cxa_atexit \
64 --enable-target-optspace \
65 --with-gnu-ld \
66 --disable-nls \
67 --disable-libmudflap \
68 );
69 endef
70 define Stage1/Compile
71 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
72 endef
73 define Stage1/Install
74 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
75 endef
76
77 define Stage2/Configure
78 mkdir -p $(BUILD_DIR2)
79 # Important! Required for limits.h to be fixed.
80 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
81 ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
82 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
83 ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
84 (cd $(BUILD_DIR2); rm -f config.cache; \
85 SHELL="$(BASH)" \
86 $(PKG_BUILD_DIR)/configure \
87 --prefix=$(STAGING_DIR) \
88 --build=$(GNU_HOST_NAME) \
89 --host=$(GNU_HOST_NAME) \
90 --target=$(REAL_GNU_TARGET_NAME) \
91 --enable-languages=$(TARGET_LANGUAGES) \
92 --enable-shared \
93 --disable-__cxa_atexit \
94 --enable-target-optspace \
95 --with-gnu-ld \
96 --disable-nls \
97 --disable-libmudflap \
98 );
99 endef
100 define Stage2/Compile
101 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) all
102 endef
103 define Stage2/Install
104 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) install
105 echo $(PKG_VERSION) > $(STAGING_DIR)/gcc_version
106 # Set up the symlinks to enable lying about target name.
107 set -e; \
108 (cd $(STAGING_DIR); \
109 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
110 cd bin; \
111 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
112 ln -sf $$$${app} \
113 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
114 done; \
115 );
116 endef
117
118 define Build/Prepare
119 $(call Build/Prepare/Default)
120 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
121 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
122 (cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
123 $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(PKG_BUILD_DIR)/libstdc++-v3/configure
124 endef
125
126 define Build/Configure
127 $(call Stage1/Configure)
128 endef
129
130 define Build/Compile
131 $(call Stage1/Compile)
132 $(call Stage1/Install)
133 endef
134
135 define Build/Install
136 $(call Stage2/Configure)
137 $(call Stage2/Compile)
138 $(call Stage2/Install)
139 endef
140
141 define Build/Clean
142 rm -rf $(PKG_BUILD_DIR)
143 rm -rf $(BUILD_DIR1)
144 rm -rf $(BUILD_DIR2)
145 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
146 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
147 endef
148
149 $(eval $(call HostBuild))