git-svn-id: http://svn.ipfire.org/svn/ipfire/IPFire/source@16 ea5c0bd1-69bd-2848...
[ipfire-2.x.git] / src / uClibc / make / gcc-3.3.mk
CommitLineData
cd1a2927
MT
1# Makefile for to build a gcc/uClibc toolchain
2#
3# Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19ifneq ($(GCC_2_95_TOOLCHAIN),true)
20
21# Older stuff...
22#GCC_SITE:=ftp://ftp.gnu.org/gnu/gcc/
23#GCC_SOURCE:=gcc-3.3.tar.gz
24#GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-3.3
25#GCC_CAT:=zcat
26
27# Shiny new stuff...
28GCC_VERSION:=3.3.1
29#GCC_SITE:=ftp://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)
30#GCC_SITE:=http://www.binarycode.org/gcc/releases/gcc-$(GCC_VERSION)
31GCC_SITE:=http://gcc.get-software.com/releases/gcc-$(GCC_VERSION)
32
33#
34# snapshots....
35#GCC_VERSION:=3.3-20031013
36#GCC_SITE:=http://gcc.get-software.com/snapshots/$(GCC_VERSION)
37#
38GCC_SOURCE:=gcc-$(GCC_VERSION).tar.gz
39GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)
40GCC_CAT:=gzip -dc
41
42#############################################################
43#
44# Setup some initial stuff
45#
46#############################################################
47
48ifeq ($(INSTALL_LIBSTDCPP),true)
49TARGET_LANGUAGES:=c,c++
50else
51TARGET_LANGUAGES:=c
52endif
53
54#############################################################
55#
56# build the first pass gcc compiler
57#
58#############################################################
59GCC_BUILD_DIR1:=$(TOOL_BUILD_DIR)/gcc-3.3-initial
60
61$(DL_DIR)/$(GCC_SOURCE):
62# $(WGET) -P $(DL_DIR) $(GCC_SITE)/$(GCC_SOURCE)
63
64$(GCC_DIR)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)
65 $(GCC_CAT) $(DL_DIR)/$(GCC_SOURCE) | tar -C $(TOOL_BUILD_DIR) -xvf -
66 touch $(GCC_DIR)/.unpacked
67
68$(GCC_DIR)/.patched: $(GCC_DIR)/.unpacked
69 # Apply any files named gcc-*.patch from the source directory to gcc
70 $(SOURCE_DIR)/patch-kernel.sh $(GCC_DIR) $(SOURCE_DIR) gcc-*.patch
71ifeq ($(SOFT_FLOAT),true)
72ifeq ("$(strip $(ARCH))","i386")
73 $(SOURCE_DIR)/patch-kernel.sh $(GCC_DIR) $(SOURCE_DIR) i386-gcc-soft-float.patch
74endif
75endif
76 touch $(GCC_DIR)/.patched
77
78$(GCC_DIR)/.gcc3_3_build_hacks: $(GCC_DIR)/.patched
79 #
80 # Hack things to use the correct shared lib loader
81 #
82 (cd $(GCC_DIR); set -e; export LIST=`grep -lr -- "-dynamic-linker.*\.so[\.0-9]*" *`;\
83 if [ -n "$$LIST" ] ; then \
84 $(SED) "s,-dynamic-linker.*\.so[\.0-9]*},\
85 -dynamic-linker /lib/ld-uClibc.so.0},;" $$LIST; fi);
86 #
87 # Prevent gcc from using the unwind-dw2-fde-glibc code used for
88 # unwinding stack frames for C++ exception handling. The
89 # unwind-dw2-fde-glibc code depends on glibc's ldso, we want to
90 # use the generic version instead.
91 #
92 $(SED) "s,^#ifndef inhibit_libc,#define inhibit_libc\n\
93 #ifndef inhibit_libc,g;" $(GCC_DIR)/gcc/unwind-dw2-fde-glibc.c;
94 #
95 # Prevent system glibc start files from leaking in uninvited...
96 #
97 $(SED) "s,standard_startfile_prefix_1 = \".*,standard_startfile_prefix_1 =\
98 \"$(STAGING_DIR)/lib/\";,;" $(GCC_DIR)/gcc/gcc.c;
99 $(SED) "s,standard_startfile_prefix_2 = \".*,standard_startfile_prefix_2 =\
100 \"$(STAGING_DIR)/usr/lib/\";,;" $(GCC_DIR)/gcc/gcc.c;
101 #
102 # Prevent system glibc include files from leaking in uninvited...
103 #
104 $(SED) "s,^NATIVE_SYSTEM_HEADER_DIR.*,NATIVE_SYSTEM_HEADER_DIR=\
105 $(STAGING_DIR)/include,;" $(GCC_DIR)/gcc/Makefile.in;
106 $(SED) "s,^CROSS_SYSTEM_HEADER_DIR.*,CROSS_SYSTEM_HEADER_DIR=\
107 $(STAGING_DIR)/include,;" $(GCC_DIR)/gcc/Makefile.in;
108 $(SED) "s,^#define.*STANDARD_INCLUDE_DIR.*,#define STANDARD_INCLUDE_DIR \
109 \"$(STAGING_DIR)/include\",;" $(GCC_DIR)/gcc/cppdefault.h;
110 #
111 # Prevent system glibc libraries from being found by collect2
112 # when it calls locatelib() and rummages about the system looking
113 # for libraries with the correct name...
114 #
115 $(SED) "s,\"/lib,\"$(STAGING_DIR)/lib,g;" $(GCC_DIR)/gcc/collect2.c
116 $(SED) "s,\"/usr/,\"$(STAGING_DIR)/usr/,g;" $(GCC_DIR)/gcc/collect2.c
117 touch $(GCC_DIR)/.gcc3_3_build_hacks
118
119# The --without-headers option stopped working with gcc 3.0 and has never been
120# # fixed, so we need to actually have working C library header files prior to
121# # the step or libgcc will not build...
122$(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.gcc3_3_build_hacks
123 mkdir -p $(GCC_BUILD_DIR1)
124 echo -e "#!/bin/sh\nexec $(GCC_BUILD_DIR1)/gcc/xgcc -B$(GCC_BUILD_DIR1)/gcc/ -B$(STAGING_DIR)/$(ARCH)-linux/bin/ -B$(STAGING_DIR)/$(ARCH)-linux/lib/ -isystem $(STAGING_DIR)/$(ARCH)-linux/include $(TARGET_SOFT_FLOAT) \$$@" > $(GCC_BUILD_DIR1)/target_gcc
125 chmod a+x $(GCC_BUILD_DIR1)/target_gcc
126 (cd $(GCC_BUILD_DIR1); PATH=$(TARGET_PATH) AR=$(TARGET_CROSS)ar \
127 RANLIB=$(TARGET_CROSS)ranlib \
128 CC="$(HOSTCC)" \
129 LDFLAGS="$(HOSTLDFLAGS)" \
130 gcc_cv_as_hidden=no \
131 $(GCC_DIR)/configure \
132 --target=$(GNU_TARGET_NAME) \
133 --host=$(GNU_HOST_NAME) \
134 --build=$(GNU_HOST_NAME) \
135 --prefix=$(STAGING_DIR) \
136 --exec-prefix=$(STAGING_DIR) \
137 --bindir=$(STAGING_DIR)/bin \
138 --sbindir=$(STAGING_DIR)/sbin \
139 --sysconfdir=$(STAGING_DIR)/etc \
140 --datadir=$(STAGING_DIR)/share \
141 --includedir=$(STAGING_DIR)/include \
142 --libdir=$(STAGING_DIR)/lib \
143 --localstatedir=$(STAGING_DIR)/var \
144 --mandir=$(STAGING_DIR)/man \
145 --infodir=$(STAGING_DIR)/info \
146 --with-local-prefix=$(STAGING_DIR)/usr/local \
147 --oldincludedir=$(STAGING_DIR)/include $(MULTILIB) \
148 --enable-target-optspace $(DISABLE_NLS) --with-gnu-ld \
149 --disable-shared --enable-languages=c --disable-__cxa_atexit \
150 $(SOFT_FLOAT_CONFIG_OPTION) \
151 $(EXTRA_GCC_CONFIG_OPTIONS) --program-prefix=$(ARCH)-linux-);
152 touch $(GCC_BUILD_DIR1)/.configured
153
154$(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
155 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) -C $(GCC_BUILD_DIR1) \
156 CC="$(HOSTCC)" \
157 LDFLAGS="$(HOSTLDFLAGS)" \
158 AR_FOR_TARGET=$(STAGING_DIR)/bin/$(ARCH)-linux-ar \
159 RANLIB_FOR_TARGET=$(STAGING_DIR)/bin/$(ARCH)-linux-ranlib \
160 CC_FOR_TARGET=$(GCC_BUILD_DIR1)/target_gcc \
161 GCC_FOR_TARGET=$(GCC_BUILD_DIR1)/target_gcc
162 touch $(GCC_BUILD_DIR1)/.compiled
163
164$(STAGING_DIR)/bin/$(ARCH)-linux-gcc: $(GCC_BUILD_DIR1)/.compiled
165 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) \
166 CC="$(HOSTCC)" \
167 LDFLAGS="$(HOSTLDFLAGS)" \
168 -C $(GCC_BUILD_DIR1) install;
169 #Cleanup then mess when --program-prefix mysteriously fails
170 -mv $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-cpp $(STAGING_DIR)/bin/$(ARCH)-linux-cpp
171 -mv $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-gcc $(STAGING_DIR)/bin/$(ARCH)-linux-gcc
172 if [ -n "$(strip $(TARGET_SOFT_FLOAT))" ] ; then \
173 for app in gcc c++ g++ ; do \
174 if [ -x $(STAGING_DIR)/bin/$(ARCH)-linux-$${app} ] ; then \
175 (cd $(STAGING_DIR)/bin; \
176 rm -f $(ARCH)-linux-$${app}$(TARGET_SOFT_FLOAT); \
177 echo -e "#!/bin/sh\nexec $(STAGING_DIR)/bin/$(ARCH)-linux-$${app} -msoft-float \$$@" > $(ARCH)-linux-$${app}$(TARGET_SOFT_FLOAT); \
178 chmod a+x $(ARCH)-linux-$${app}$(TARGET_SOFT_FLOAT); \
179 ); \
180 fi; \
181 done; \
182 fi; \
183 rm -f $(STAGING_DIR)/bin/gccbug $(STAGING_DIR)/bin/gcov
184 rm -rf $(STAGING_DIR)/info $(STAGING_DIR)/man $(STAGING_DIR)/share/doc \
185 $(STAGING_DIR)/share/locale
186
187gcc3_3_initial: binutils uclibc-configured $(STAGING_DIR)/bin/$(ARCH)-linux-gcc
188
189gcc3_3_initial-clean:
190 rm -rf $(GCC_BUILD_DIR1)
191 rm -f $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)*
192
193gcc3_3_initial-dirclean:
194 rm -rf $(GCC_BUILD_DIR1)
195
196#############################################################
197#
198# second pass compiler build. Build the compiler targeting
199# the newly built shared uClibc library.
200#
201#############################################################
202GCC_BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-3.3-final
203$(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched
204 mkdir -p $(GCC_BUILD_DIR2)
205 echo -e "#!/bin/sh\nexec $(GCC_BUILD_DIR2)/gcc/xgcc -B$(GCC_BUILD_DIR2)/gcc/ -B$(STAGING_DIR)/$(ARCH)-linux/bin/ -B$(STAGING_DIR)/$(ARCH)-linux/lib/ -isystem $(STAGING_DIR)/$(ARCH)-linux/include $(TARGET_SOFT_FLOAT) \$$@" > $(GCC_BUILD_DIR2)/target_g++
206 chmod a+x $(GCC_BUILD_DIR2)/target_g++
207 echo -e "#!/bin/sh\nexec $(GCC_BUILD_DIR2)/gcc/xgcc -B$(GCC_BUILD_DIR2)/gcc/ -B$(STAGING_DIR)/$(ARCH)-linux/bin/ -B$(STAGING_DIR)/$(ARCH)-linux/lib/ -isystem $(STAGING_DIR)/$(ARCH)-linux/include $(TARGET_SOFT_FLOAT) \$$@" > $(GCC_BUILD_DIR2)/target_gcc
208 chmod a+x $(GCC_BUILD_DIR2)/target_gcc
209 (cd $(GCC_BUILD_DIR2); PATH=$(TARGET_PATH) AR=$(TARGET_CROSS)ar \
210 RANLIB=$(TARGET_CROSS)ranlib LD=$(TARGET_CROSS)ld \
211 NM=$(TARGET_CROSS)nm \
212 CC="$(HOSTCC)" \
213 LDFLAGS="$(HOSTLDFLAGS)" \
214 gcc_cv_as_hidden=no \
215 $(GCC_DIR)/configure \
216 --target=$(GNU_TARGET_NAME) \
217 --host=$(GNU_HOST_NAME) \
218 --build=$(GNU_HOST_NAME) \
219 --prefix=$(STAGING_DIR) \
220 --exec-prefix=$(STAGING_DIR) \
221 --bindir=$(STAGING_DIR)/bin \
222 --sbindir=$(STAGING_DIR)/sbin \
223 --sysconfdir=$(STAGING_DIR)/etc \
224 --datadir=$(STAGING_DIR)/share \
225 --localstatedir=$(STAGING_DIR)/var \
226 --mandir=$(STAGING_DIR)/man \
227 --infodir=$(STAGING_DIR)/info \
228 --with-local-prefix=$(STAGING_DIR)/usr/local \
229 --libdir=$(STAGING_DIR)/lib \
230 --includedir=$(STAGING_DIR)/include \
231 --with-gxx-include-dir=$(STAGING_DIR)/include/c++ \
232 --oldincludedir=$(STAGING_DIR)/include \
233 --enable-shared $(MULTILIB) \
234 --enable-target-optspace $(DISABLE_NLS) \
235 --with-gnu-ld --disable-__cxa_atexit \
236 --enable-languages=$(TARGET_LANGUAGES) \
237 $(EXTRA_GCC_CONFIG_OPTIONS) \
238 --program-prefix=$(ARCH)-linux- \
239 );
240 touch $(GCC_BUILD_DIR2)/.configured
241
242$(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
243 $(SED) 's/\-lc//' $(GCC_BUILD_DIR2)/gcc/Makefile
244 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) \
245 CC="$(HOSTCC)" \
246 LDFLAGS="$(HOSTLDFLAGS)" \
247 AR_FOR_TARGET=$(TARGET_CROSS)ar RANLIB_FOR_TARGET=$(TARGET_CROSS)ranlib \
248 LD_FOR_TARGET=$(TARGET_CROSS)ld NM_FOR_TARGET=$(TARGET_CROSS)nm \
249 CC_FOR_TARGET=$(GCC_BUILD_DIR2)/target_gcc \
250 GCC_FOR_TARGET=$(GCC_BUILD_DIR2)/target_gcc \
251 CXX_FOR_TARGET=$(GCC_BUILD_DIR2)/target_g++ \
252 -C $(GCC_BUILD_DIR2)
253 touch $(GCC_BUILD_DIR2)/.compiled
254
255$(GCC_BUILD_DIR2)/.installed: $(GCC_BUILD_DIR2)/.compiled $(STAGING_DIR)/lib/libc.a
256 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) \
257 CC="$(HOSTCC)" \
258 LDFLAGS="$(HOSTLDFLAGS)" \
259 -C $(GCC_BUILD_DIR2) install;
260 -mv $(STAGING_DIR)/bin/gcc $(STAGING_DIR)/usr/bin;
261 -mv $(STAGING_DIR)/bin/protoize $(STAGING_DIR)/usr/bin;
262 -mv $(STAGING_DIR)/bin/unprotoize $(STAGING_DIR)/usr/bin;
263 -mv $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-cpp $(STAGING_DIR)/bin/$(ARCH)-linux-cpp
264 -mv $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-gcc $(STAGING_DIR)/bin/$(ARCH)-linux-gcc
265 -mv $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-c++ $(STAGING_DIR)/bin/$(ARCH)-linux-c++
266 -mv $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-g++ $(STAGING_DIR)/bin/$(ARCH)-linux-g++
267 -mv $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-c++filt $(STAGING_DIR)/bin/$(ARCH)-linux-c++filt
268 rm -f $(STAGING_DIR)/bin/cpp $(STAGING_DIR)/bin/gcov $(STAGING_DIR)/bin/*gccbug
269 rm -f $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)-$(ARCH)-linux-*
270 rm -rf $(STAGING_DIR)/info $(STAGING_DIR)/man $(STAGING_DIR)/share/doc \
271 $(STAGING_DIR)/share/locale
272 # Strip the host binaries
273 -strip --strip-all -R .note -R .comment $(STAGING_DIR)/bin/*
274 if [ -n "$(strip $(TARGET_SOFT_FLOAT))" ] ; then \
275 for app in gcc c++ g++ ; do \
276 if [ -x $(STAGING_DIR)/bin/$(ARCH)-linux-$${app} ] ; then \
277 (cd $(STAGING_DIR)/bin; \
278 rm -f $(ARCH)-linux-$${app}$(TARGET_SOFT_FLOAT); \
279 echo -e "#!/bin/sh\nexec $(STAGING_DIR)/bin/$(ARCH)-linux-$${app} -msoft-float \$$@" > $(ARCH)-linux-$${app}$(TARGET_SOFT_FLOAT); \
280 chmod a+x $(ARCH)-linux-$${app}$(TARGET_SOFT_FLOAT); \
281 ); \
282 fi; \
283 done; \
284 fi; \
285 set -e; \
286 for app in cc gcc c89 cpp c++ g++ ; do \
287 if [ -x $(STAGING_DIR)/bin/$(ARCH)-linux-$${app} ] ; then \
288 (cd $(STAGING_DIR)/usr/bin; \
289 ln -fs ../../bin/$(ARCH)-linux-$${app} $${app}; \
290 ); \
291 fi; \
292 done;
293 (cd $(STAGING_DIR)/usr/bin; \
294 ln -fs gcc cc; \
295 )
296 touch $(GCC_BUILD_DIR2)/.installed
297
298ifneq ($(TARGET_DIR),)
299$(TARGET_DIR)/lib/libstdc++.so.5.0.5: $(GCC_BUILD_DIR2)/.installed
300 cp -a $(STAGING_DIR)/lib/libstdc++.so* $(TARGET_DIR)/lib/
301
302$(GCC_BUILD_DIR2)/.shared_libgcc: $(GCC_BUILD_DIR2)/.installed
303 # Make sure a copy of libgcc_s is in the target's /lib.
304 if [ -f $(STAGING_DIR)/lib/libgcc_s.so.0.9.9 ] ; then \
305 cp -a $(STAGING_DIR)/lib/libgcc_s.so* $(TARGET_DIR)/lib/ ; \
306 fi
307 touch $(GCC_BUILD_DIR2)/.shared_libgcc
308
309GCC_TARGETS:=$(GCC_BUILD_DIR2)/.shared_libgcc
310ifeq ($(INSTALL_LIBSTDCPP),true)
311GCC_TARGETS+=$(TARGET_DIR)/lib/libstdc++.so.5.0.5
312endif
313
314endif
315
316gcc3_3: binutils uclibc-configured gcc3_3_initial $(LIBFLOAT_TARGET) uclibc \
317 $(GCC_BUILD_DIR2)/.installed $(GCC_TARGETS)
318
319gcc3_3-source: $(DL_DIR)/$(GCC_SOURCE)
320
321gcc3_3-clean:
322 rm -rf $(GCC_BUILD_DIR2)
323 rm -f $(STAGING_DIR)/bin/$(GNU_TARGET_NAME)*
324
325gcc3_3-dirclean:
326 rm -rf $(GCC_BUILD_DIR2)
327
328#############################################################
329#
330# Next build target gcc compiler
331#
332#############################################################
333GCC_BUILD_DIR3:=$(BUILD_DIR)/gcc-3.3-target
334
335TARGET_GCC_ARGS= $(TARGET_CONFIGURE_OPTS) \
336 AR_FOR_BUILD=ar \
337 AS_FOR_BUILD=as \
338 LD_FOR_BUILD=ld \
339 NM_FOR_BUILD=nm \
340 RANLIB_FOR_BUILD=ranlib \
341 CC="$(HOSTCC)" \
342 LDFLAGS="$(HOSTLDFLAGS)" \
343 CC_FOR_BUILD="$(HOSTCC)" \
344 GCC_FOR_BUILD="$(HOSTCC)" \
345 CXX_FOR_BUILD="$(HOSTCC)" \
346 AR_FOR_TARGET=$(TARGET_CROSS)ar \
347 AS_FOR_TARGET=$(TARGET_CROSS)as \
348 LD_FOR_TARGET=$(TARGET_CROSS)ld \
349 NM_FOR_TARGET=$(TARGET_CROSS)nm \
350 CC="$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) -isystem $(STAGING_DIR)/include" \
351 GCC="$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) -isystem $(STAGING_DIR)/include" \
352 CXX="$(TARGET_CROSS)g++$(TARGET_SOFT_FLOAT) -isystem $(STAGING_DIR)/include" \
353 CC_FOR_TARGET="$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) -isystem $(STAGING_DIR)/include" \
354 GCC_FOR_TARGET="$(TARGET_CROSS)gcc$(TARGET_SOFT_FLOAT) -isystem $(STAGING_DIR)/include" \
355 CXX_FOR_TARGET="$(TARGET_CROSS)g++$(TARGET_SOFT_FLOAT) -isystem $(STAGING_DIR)/include" \
356 RANLIB_FOR_TARGET=$(TARGET_CROSS)ranlib
357
358# We need to unpack a pristine source tree to avoid some of
359# the previously applied hacks, which do not apply here...
360$(GCC_BUILD_DIR3)/.unpacked: $(DL_DIR)/$(GCC_SOURCE)
361 $(GCC_CAT) $(DL_DIR)/$(GCC_SOURCE) | tar -C $(BUILD_DIR) -xvf -
362 mv $(BUILD_DIR)/gcc-$(GCC_VERSION) $(GCC_BUILD_DIR3)
363 touch $(GCC_BUILD_DIR3)/.unpacked
364
365$(GCC_BUILD_DIR3)/.patched: $(GCC_BUILD_DIR3)/.unpacked
366 # Apply any files named gcc-*.patch from the source directory to gcc
367 $(SOURCE_DIR)/patch-kernel.sh $(GCC_BUILD_DIR3) $(SOURCE_DIR) gcc-*.patch
368ifeq ("$(strip $(ARCH))","i386")
369 $(SOURCE_DIR)/patch-kernel.sh $(GCC_BUILD_DIR3) $(SOURCE_DIR) i386-gcc-*.patch
370endif
371 touch $(GCC_BUILD_DIR3)/.patched
372
373$(GCC_BUILD_DIR3)/.gcc3_3_build_hacks: $(GCC_BUILD_DIR3)/.patched
374 #
375 # Hack things to use the correct shared lib loader
376 #
377 (cd $(GCC_BUILD_DIR3); set -e; export LIST=`grep -lr -- "-dynamic-linker.*\.so[\.0-9]*" *`;\
378 if [ -n "$$LIST" ] ; then \
379 $(SED) "s,-dynamic-linker.*\.so[\.0-9]*},\
380 -dynamic-linker /lib/ld-uClibc.so.0},;" $$LIST; fi);
381 #
382 # Prevent gcc from using the unwind-dw2-fde-glibc code used for
383 # unwinding stack frames for C++ exception handling. The
384 # unwind-dw2-fde-glibc code depends on glibc's ldso, we want to
385 # use the generic version instead.
386 #
387 $(SED) "s,^#ifndef inhibit_libc,#define inhibit_libc\n\
388 #ifndef inhibit_libc,g;" $(GCC_BUILD_DIR3)/gcc/unwind-dw2-fde-glibc.c;
389 touch $(GCC_BUILD_DIR3)/.gcc3_3_build_hacks
390
391$(GCC_BUILD_DIR3)/.configured: $(GCC_BUILD_DIR3)/.gcc3_3_build_hacks
392 mkdir -p $(GCC_BUILD_DIR3)
393 #(cd $(GCC_BUILD_DIR3); ln -fs $(ARCH)-linux build-$(GNU_TARGET_NAME))
394 (cd $(GCC_BUILD_DIR3); \
395 $(TARGET_GCC_ARGS) \
396 gcc_cv_as_hidden=no \
397 ./configure \
398 --verbose \
399 --target=$(GNU_TARGET_NAME) \
400 --host=$(GNU_TARGET_NAME) \
401 --build=`./config.guess` \
402 --prefix=/usr \
403 --mandir=/usr/man \
404 --infodir=/usr/info \
405 --with-gxx-include-dir=/usr/include/c++/3.3 \
406 --enable-target-optspace \
407 --enable-shared \
408 $(MULTILIB) \
409 $(DISABLE_NLS) \
410 --with-gnu-ld --disable-__cxa_atexit \
411 --enable-languages=$(TARGET_LANGUAGES) \
412 $(EXTRA_GCC_CONFIG_OPTIONS) \
413 );
414 touch $(GCC_BUILD_DIR3)/.configured
415
416$(GCC_BUILD_DIR3)/.compiled: $(GCC_BUILD_DIR3)/.configured
417 $(MAKE) $(JLEVEL) $(TARGET_GCC_ARGS) -C $(GCC_BUILD_DIR3)
418 touch $(GCC_BUILD_DIR3)/.compiled
419
420$(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
421 $(MAKE) $(JLEVEL) $(TARGET_GCC_ARGS) DESTDIR=$(TARGET_DIR) \
422 -C $(GCC_BUILD_DIR3) install
423 (cd $(TARGET_DIR)/usr/bin; ln -fs gcc cc)
424 (cd $(TARGET_DIR)/lib; ln -fs /usr/bin/cpp)
425 rm -rf $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/include
426 rm -rf $(TARGET_DIR)/usr/$(GNU_TARGET_NAME)/sys-include
427 rm -rf $(TARGET_DIR)/usr/include/include $(TARGET_DIR)/usr/usr
428 -mv $(TARGET_DIR)/lib/*.a $(TARGET_DIR)/usr/lib/
429 -mv $(TARGET_DIR)/lib/*.la $(TARGET_DIR)/usr/lib/
430 rm -f $(TARGET_DIR)/lib/libstdc++.so*
431 # Make sure gcc does not think we are cross compiling
432 $(SED) "s/^1/0/;" $(TARGET_DIR)/usr/lib/gcc-lib/$(ARCH)-linux/$(GCC_VERSION)/specs
433 -(cd $(TARGET_DIR)/bin; find -type f | xargs $(STRIP) > /dev/null 2>&1)
434 -(cd $(TARGET_DIR)/usr/bin; find -type f | xargs $(STRIP) > /dev/null 2>&1)
435 -(cd $(TARGET_DIR)/usr/lib/gcc-lib/$(ARCH)-linux/$(GCC_VERSION); $(STRIP) cc1 cc1plus collect2 > /dev/null 2>&1)
436 -(cd $(TARGET_DIR)/usr/lib; $(STRIP) libstdc++.so.*.*.* > /dev/null 2>&1)
437 -(cd $(TARGET_DIR)/lib; $(STRIP) libgcc_s.so.*.*.* > /dev/null 2>&1)
438 #
439 rm -f $(TARGET_DIR)/usr/lib/*.la*
440 rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
441 $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
442 # Work around problem of missing syslimits.h
443 cp -f $(STAGING_DIR)/usr/lib/gcc-lib/$(ARCH)-linux/$(GCC_VERSION)/include/syslimits.h $(TARGET_DIR)/usr/lib/gcc-lib/$(ARCH)-linux/$(GCC_VERSION)/include/
444 # These are in /lib, so...
445 rm -rf $(TARGET_DIR)/usr/lib/libgcc_s.so*
446 touch -c $(TARGET_DIR)/usr/bin/gcc
447
448gcc3_3_target: uclibc_target binutils_target $(TARGET_DIR)/usr/bin/gcc
449
450gcc3_3_target-clean:
451 rm -rf $(GCC_BUILD_DIR3)
452 rm -f $(TARGET_DIR)/bin/$(GNU_TARGET_NAME)*
453
454gcc3_3_target-dirclean:
455 rm -rf $(GCC_BUILD_DIR3)
456
457endif