hostapd: add support for socket filtering to get rid of some of the massive cpu overh...
[openwrt.git] / toolchain / gcc / Makefile
1 #
2 # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
3 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
4 # Copyright (C) 2005-2006 Felix Fietkau <nbd@openwrt.org>
5 # Copyright (C) 2006-2009 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:=$(call qstrip,$(CONFIG_GCC_VERSION))
25
26 PKG_SOURCE_URL:=@GNU/gcc/gcc-$(PKG_VERSION)
27 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
28
29 ifeq ($(PKG_VERSION),3.4.6)
30 PKG_MD5SUM:=4a21ac777d4b5617283ce488b808da7b
31 endif
32 ifeq ($(PKG_VERSION),4.1.2)
33 PKG_MD5SUM:=a4a3eb15c96030906d8494959eeda23c
34 endif
35 ifeq ($(PKG_VERSION),4.2.4)
36 PKG_MD5SUM:=d79f553e7916ea21c556329eacfeaa16
37 endif
38 ifeq ($(PKG_VERSION),4.3.1)
39 PKG_MD5SUM:=4afa0290cc3a41ac8822666f1110de98
40 endif
41 ifeq ($(PKG_VERSION),4.3.2)
42 PKG_MD5SUM:=5dfac5da961ecd5f227c3175859a486d
43 endif
44
45 PATCH_DIR=./patches/$(PKG_VERSION)
46
47 STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
48 BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
49
50 override CONFIG_AUTOREBUILD=
51
52 include $(INCLUDE_DIR)/host-build.mk
53
54 STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed
55
56 PKG_BUILD_DIR0:=$(PKG_BUILD_DIR)-minimal
57 PKG_BUILD_DIR1:=$(PKG_BUILD_DIR)-initial
58 PKG_BUILD_DIR2:=$(PKG_BUILD_DIR)-final
59
60 SEP:=,
61 TARGET_LANGUAGES:="c$(if $(CONFIG_INSTALL_LIBSTDCPP),$(SEP)c++)$(if $(CONFIG_INSTALL_LIBGCJ),$(SEP)java)"
62
63 GCC_CONFIGURE_COMMON:= \
64 SHELL="$(BASH)" \
65 $(PKG_BUILD_DIR)/configure \
66 --prefix=$(TOOLCHAIN_DIR)/usr \
67 --build=$(GNU_HOST_NAME) \
68 --host=$(GNU_HOST_NAME) \
69 --target=$(REAL_GNU_TARGET_NAME) \
70 --with-gnu-ld \
71 --enable-target-optspace \
72 --disable-libgomp \
73 --disable-libmudflap \
74 --disable-multilib \
75 --disable-nls \
76 $(SOFT_FLOAT_CONFIG_OPTION) \
77 $(call qstrip,$(CONFIG_EXTRA_GCC_CONFIG_OPTIONS)) \
78
79 ifneq ($(CONFIG_GCC_VERSION_4_3),)
80 GCC_BUILD_TARGET_LIBGCC:=y
81 GCC_CONFIGURE_COMMON+= \
82 --with-gmp=$(TOPDIR)/staging_dir/host \
83 --with-mpfr=$(TOPDIR)/staging_dir/host \
84 --disable-decimal-float
85 endif
86
87 ifneq ($(CONFIG_SSP_SUPPORT),)
88 GCC_CONFIGURE_COMMON+= \
89 --enable-libssp
90 else
91 GCC_CONFIGURE_COMMON+= \
92 --disable-libssp
93 endif
94
95 ifneq ($(CONFIG_EXTRA_TARGET_ARCH),)
96 GCC_CONFIGURE_COMMON+= \
97 --enable-biarch \
98 --enable-targets=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-linux-$(TARGET_SUFFIX)
99 endif
100
101 ifeq ($(LIBC),uClibc)
102 GCC_CONFIGURE_COMMON+= \
103 --disable-__cxa_atexit
104 else
105 GCC_CONFIGURE_COMMON+= \
106 --enable-__cxa_atexit
107 endif
108
109 GCC_CONFIGURE_STAGE0:= \
110 $(GCC_CONFIGURE_COMMON) \
111 --with-newlib \
112 --without-headers \
113 --enable-languages=c \
114 --disable-libssp \
115 --disable-shared \
116 --disable-threads \
117
118 GCC_CONFIGURE_STAGE1:= \
119 $(GCC_CONFIGURE_COMMON) \
120 --with-newlib \
121 --with-sysroot=$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev \
122 --enable-languages=c \
123 --disable-shared \
124 --disable-threads \
125
126 GCC_CONFIGURE_STAGE2:= \
127 $(GCC_CONFIGURE_COMMON) \
128 --enable-languages=$(TARGET_LANGUAGES) \
129 --enable-shared \
130 --enable-threads \
131 --with-slibdir=$(TOOLCHAIN_DIR)/lib \
132
133 GCC_MAKE:= \
134 export SHELL="$(BASH)"; \
135 $(MAKE) \
136
137
138 define Build/SetToolchainInfo
139 $(SED) 's,TARGET_CROSS=.*,TARGET_CROSS=$(REAL_GNU_TARGET_NAME)-,' $(TOOLCHAIN_DIR)/info.mk
140 $(SED) 's,GCC_VERSION=.*,GCC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
141 endef
142
143
144 define Stage0/Configure
145 mkdir -p $(PKG_BUILD_DIR0)
146 (cd $(PKG_BUILD_DIR0); rm -f config.cache; \
147 $(GCC_CONFIGURE_STAGE0) \
148 );
149 endef
150
151 define Stage0/Compile
152 $(GCC_MAKE) -C $(PKG_BUILD_DIR0) all-gcc
153 endef
154
155 define Stage0/Install
156 $(GCC_MAKE) -C $(PKG_BUILD_DIR0) install-gcc
157 endef
158
159
160 define Stage1/Configure
161 mkdir -p $(PKG_BUILD_DIR1)
162 (cd $(PKG_BUILD_DIR1); rm -f config.cache; \
163 $(GCC_CONFIGURE_STAGE1) \
164 );
165 endef
166
167 define Stage1/Compile
168 $(CP) $(BUILD_DIR_TOOLCHAIN)/linux-dev/* $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/
169 $(GCC_MAKE) -C $(PKG_BUILD_DIR1) \
170 all-build-libiberty \
171 all-gcc \
172 $(if $(GCC_BUILD_TARGET_LIBGCC),all-target-libgcc)
173 endef
174
175 define Stage1/Install
176 $(GCC_MAKE) -C $(PKG_BUILD_DIR1) \
177 install-gcc \
178 $(if $(GCC_BUILD_TARGET_LIBGCC),install-target-libgcc)
179
180 # XXX: glibc insists on linking against libgcc_eh
181 ( cd $(TOOLCHAIN_DIR)/usr/lib/gcc/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION) ; \
182 [ -e libgcc_eh.a ] || ln -sf libgcc.a libgcc_eh.a ; \
183 )
184 endef
185
186
187 define Stage2/Configure
188 mkdir -p $(PKG_BUILD_DIR2) $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)
189 # Important! Required for limits.h to be fixed.
190 rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
191 ln -sf ../include $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/sys-include
192 rm -rf $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
193 ln -sf ../lib $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME)/lib
194 (cd $(PKG_BUILD_DIR2); rm -f config.cache; \
195 $(GCC_CONFIGURE_STAGE2) \
196 );
197 endef
198
199 define Stage2/Compile
200 $(GCC_MAKE) -C $(PKG_BUILD_DIR2) all
201 endef
202
203 define SetupExtraArch
204 for app in $(TOOLCHAIN_DIR)/usr/bin/$(OPTIMIZE_FOR_CPU)*-{gcc,gcc-*,g++}; do \
205 [ -e $$$$app ] || continue; \
206 old_base=$$$$(basename $$$$app); \
207 new_base=$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_NAME))-$$$${old_base##$(OPTIMIZE_FOR_CPU)-}; \
208 sed -e "s/@CC_BASE@/$$$$old_base/" \
209 -e 's/@EXTRA_ARCH_OPTS@/$(call qstrip,$(CONFIG_EXTRA_TARGET_ARCH_OPTS))/' \
210 ./files/alternate-arch-cc.in > \
211 $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
212 chmod a+x $(TOOLCHAIN_DIR)/usr/bin/$$$$new_base; \
213 done
214 endef
215
216 define Stage2/Install
217 $(GCC_MAKE) -C $(PKG_BUILD_DIR2) install
218 # Set up the symlinks to enable lying about target name.
219 set -e; \
220 (cd $(TOOLCHAIN_DIR)/usr; \
221 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
222 cd bin; \
223 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
224 ln -sf $$$${app} \
225 $(GNU_TARGET_NAME)$$$${app##$(REAL_GNU_TARGET_NAME)}; \
226 done; \
227 );
228 $(if $(CONFIG_EXTRA_TARGET_ARCH),$(call SetupExtraArch))
229 endef
230
231
232 define Build/Prepare
233 $(call Build/SetToolchainInfo)
234 $(call Build/Prepare/Default)
235 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
236 $(CP) $(SCRIPT_DIR)/config.{guess,sub} $(PKG_BUILD_DIR)/
237 $(SED) 's,\(version_string.. = "[0-9\.]*\).*\(";\),\1 (OpenWrt-2.0)\2,' $(PKG_BUILD_DIR)/gcc/version.c
238 $(SED) 's,\(bug_report_url.. = "\).*\(";\),\1<URL:https://dev.openwrt.org/>\2,' $(PKG_BUILD_DIR)/gcc/version.c
239 (cd $(PKG_BUILD_DIR)/libstdc++-v3; autoconf;);
240 $(SED) 's,gcc_no_link=yes,gcc_no_link=no,' $(PKG_BUILD_DIR)/libstdc++-v3/configure
241 $(call Stage0/Configure)
242 $(call Stage0/Compile)
243 $(call Stage0/Install)
244 endef
245
246 define Build/Configure
247 endef
248
249 define Build/Compile
250 $(call Stage1/Configure)
251 $(call Stage1/Compile)
252 $(call Stage1/Install)
253 endef
254
255 define Build/Install
256 $(call Stage2/Configure)
257 $(call Stage2/Compile)
258 $(call Stage2/Install)
259 endef
260
261 define Build/Clean
262 rm -rf \
263 $(PKG_BUILD_DIR) \
264 $(PKG_BUILD_DIR0) \
265 $(PKG_BUILD_DIR1) \
266 $(PKG_BUILD_DIR2) \
267 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
268 $(TOOLCHAIN_DIR)/usr/$(REAL_GNU_TARGET_NAME) \
269 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-gc* \
270 $(TOOLCHAIN_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-c*
271 endef
272
273 $(eval $(call HostBuild))
This page took 0.067378 seconds and 5 git commands to generate.