madwifi: add some extra delay between bringing the interface up and configuring it...
[openwrt/openwrt.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 ifeq ($(PKG_VERSION),4.2)
27 PKG_VERSION:=20060709
28 PKG_SOURCE_URL:=http://downloads.openwrt.org/sources
29 PATCH_DIR=./patches/4.2
30 else
31 PATCH_DIR=./patches/$(PKG_VERSION)
32 PKG_SOURCE_URL:=ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-$(PKG_VERSION) \
33 http://mirrors.rcn.net/pub/sourceware/gcc/releases/gcc-$(PKG_VERSION) \
34 ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(PKG_VERSION)
35 endif
36
37 PKG_SOURCE:=gcc-$(PKG_VERSION).tar.bz2
38 PKG_MD5SUM:=unknown
39 PKG_CAT:=bzcat
40
41 PKG_BUILD_DIR:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)
42
43 TARGET_LANGUAGES:=c
44 ifeq ($(CONFIG_INSTALL_LIBSTDCPP),y)
45 TARGET_LANGUAGES:=$(TARGET_LANGUAGES),c++
46 endif
47 ifeq ($(CONFIG_INSTALL_LIBGCJ),y)
48 TARGET_LANGUAGES:=$(TARGET_LANGUAGES),java
49 endif
50
51 include $(INCLUDE_DIR)/host-build.mk
52
53 BUILD_DIR1:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-initial
54 BUILD_DIR2:=$(TOOLCHAIN_BUILD_DIR)/gcc-$(PKG_VERSION)-final
55
56 define Stage1/Configure
57 mkdir -p $(BUILD_DIR1)
58 (cd $(BUILD_DIR1); rm -f config.cache; \
59 SHELL="$(BASH)" \
60 $(PKG_BUILD_DIR)/configure \
61 --prefix=$(STAGING_DIR) \
62 --build=$(GNU_HOST_NAME) \
63 --host=$(GNU_HOST_NAME) \
64 --target=$(REAL_GNU_TARGET_NAME) \
65 --enable-languages=c \
66 --disable-shared \
67 --with-sysroot=$(TOOLCHAIN_BUILD_DIR)/uClibc_dev/ \
68 --disable-__cxa_atexit \
69 --enable-target-optspace \
70 --with-gnu-ld \
71 --disable-nls \
72 --disable-libmudflap \
73 );
74 endef
75 define Stage1/Compile
76 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) all-gcc
77 endef
78 define Stage1/Install
79 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR1) install-gcc
80 endef
81
82 define Stage2/Configure
83 mkdir -p $(BUILD_DIR2)
84 # Important! Required for limits.h to be fixed.
85 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
86 ln -sf ../include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
87 rm -rf $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
88 ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
89 (cd $(BUILD_DIR2); rm -f config.cache; \
90 SHELL="$(BASH)" \
91 $(PKG_BUILD_DIR)/configure \
92 --prefix=$(STAGING_DIR) \
93 --build=$(GNU_HOST_NAME) \
94 --host=$(GNU_HOST_NAME) \
95 --target=$(REAL_GNU_TARGET_NAME) \
96 --enable-languages=$(TARGET_LANGUAGES) \
97 --enable-shared \
98 --disable-__cxa_atexit \
99 --enable-target-optspace \
100 --with-gnu-ld \
101 --disable-nls \
102 --disable-libmudflap \
103 );
104 endef
105 define Stage2/Compile
106 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) all
107 endef
108 define Stage2/Install
109 export SHELL="$(BASH)"; $(MAKE) -C $(BUILD_DIR2) install
110 echo $(PKG_VERSION) > $(STAGING_DIR)/gcc_version
111 # Set up the symlinks to enable lying about target name.
112 set -e; \
113 (cd $(STAGING_DIR); \
114 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
115 cd bin; \
116 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
117 ln -sf $$$${app} \
118 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
119 done; \
120 );
121 endef
122
123 define Build/Prepare
124 $(call Build/Prepare/Default)
125 $(SCRIPT_DIR)/patch-kernel.sh $(PKG_BUILD_DIR) $(PATCH_DIR) \*.patch
126 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
127 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
128 (cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
129 endef
130
131 define Build/Configure
132 $(call Stage1/Configure)
133 endef
134
135 define Build/Compile
136 $(call Stage1/Compile)
137 $(call Stage1/Install)
138 endef
139
140 define Build/Install
141 $(call Stage2/Configure)
142 $(call Stage2/Compile)
143 $(call Stage2/Install)
144 endef
145
146 define Build/Clean
147 rm -rf $(PKG_BUILD_DIR)
148 rm -rf $(BUILD_DIR1)
149 rm -rf $(BUILD_DIR2)
150 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gc*
151 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-c*
152 endef
153
154 $(eval $(call HostBuild))