add a swap-utils subpackage,
[openwrt.git] / obsolete-buildroot / make / gcc-uclibc-3.3.mk
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 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20 ifneq ($(GCC_2_95_TOOLCHAIN),true)
21
22 # Shiny new stuff...
23 GCC_VERSION:=3.3.3
24 GCC_SITE:=ftp://ftp.gnu.org/gnu/gcc/releases/gcc-$(GCC_VERSION)
25 #GCC_SITE:=http://www.binarycode.org/gcc/releases/gcc-$(GCC_VERSION)
26 #GCC_SITE:=http://gcc.get-software.com/releases/gcc-$(GCC_VERSION)
27
28 #
29 # snapshots....
30 #GCC_VERSION:=3.3-20031013
31 #GCC_SITE:=http://gcc.get-software.com/snapshots/$(GCC_VERSION)
32 #
33 GCC_SOURCE:=gcc-$(GCC_VERSION).tar.bz2
34 GCC_DIR:=$(TOOL_BUILD_DIR)/gcc-$(GCC_VERSION)
35 GCC_CAT:=bzcat
36 GCC_STRIP_HOST_BINARIES:=true
37
38 #############################################################
39 #
40 # Setup some initial stuff
41 #
42 #############################################################
43
44 ifeq ($(INSTALL_LIBGCJ),true)
45 TARGET_LANGUAGES:=c,c++,java
46 else
47 ifeq ($(INSTALL_LIBSTDCPP),true)
48 TARGET_LANGUAGES:=c,c++
49 else
50 TARGET_LANGUAGES:=c
51 endif
52 endif
53
54 #############################################################
55 #
56 # build the first pass gcc compiler
57 #
58 #############################################################
59 GCC_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) gcc3.3-mega.patch.bz2
71 $(SOURCE_DIR)/patch-kernel.sh $(GCC_DIR) $(SOURCE_DIR) gcc-uclibc-3.3*.patch
72 ifeq ($(SOFT_FLOAT),true)
73 ifeq ("$(strip $(ARCH))","i386")
74 $(SOURCE_DIR)/patch-kernel.sh $(GCC_DIR) $(SOURCE_DIR) i386-gcc-soft-float.patch
75 endif
76 endif
77 touch $(GCC_DIR)/.patched
78
79 # The --without-headers option stopped working with gcc 3.0 and has never been
80 # # fixed, so we need to actually have working C library header files prior to
81 # # the step or libgcc will not build...
82 $(GCC_BUILD_DIR1)/.configured: $(GCC_DIR)/.patched
83 mkdir -p $(GCC_BUILD_DIR1)
84 -mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/include
85 (cd $(GCC_BUILD_DIR1); PATH=$(TARGET_PATH) \
86 $(GCC_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=c \
92 --disable-shared \
93 --includedir=$(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/include \
94 --with-sysroot=$(TOOL_BUILD_DIR)/uClibc_dev/ \
95 --disable-__cxa_atexit \
96 --enable-target-optspace \
97 --with-gnu-ld \
98 $(DISABLE_NLS) \
99 $(MULTILIB) \
100 $(SOFT_FLOAT_CONFIG_OPTION) \
101 $(EXTRA_GCC_CONFIG_OPTIONS));
102 touch $(GCC_BUILD_DIR1)/.configured
103
104 $(GCC_BUILD_DIR1)/.compiled: $(GCC_BUILD_DIR1)/.configured
105 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) -C $(GCC_BUILD_DIR1) all-gcc
106 touch $(GCC_BUILD_DIR1)/.compiled
107
108 $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc: $(GCC_BUILD_DIR1)/.compiled
109 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) -C $(GCC_BUILD_DIR1) install-gcc
110 #rm -f $(STAGING_DIR)/bin/gccbug $(STAGING_DIR)/bin/gcov
111 #rm -rf $(STAGING_DIR)/info $(STAGING_DIR)/man $(STAGING_DIR)/share/doc $(STAGING_DIR)/share/locale
112
113 gcc3_3_initial: uclibc-configured binutils $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)-gcc
114
115 gcc3_3_initial-clean:
116 rm -rf $(GCC_BUILD_DIR1)
117 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
118
119 gcc3_3_initial-dirclean:
120 rm -rf $(GCC_BUILD_DIR1)
121
122 #############################################################
123 #
124 # second pass compiler build. Build the compiler targeting
125 # the newly built shared uClibc library.
126 #
127 #############################################################
128 GCC_BUILD_DIR2:=$(TOOL_BUILD_DIR)/gcc-3.3-final
129 $(GCC_BUILD_DIR2)/.configured: $(GCC_DIR)/.patched $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib/libc.a
130 mkdir -p $(GCC_BUILD_DIR2)
131 # Important! Required for limits.h to be fixed.
132 ln -sf include $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/sys-include
133 (cd $(GCC_BUILD_DIR2); PATH=$(TARGET_PATH) \
134 $(GCC_DIR)/configure \
135 --prefix=$(STAGING_DIR) \
136 --build=$(GNU_HOST_NAME) \
137 --host=$(GNU_HOST_NAME) \
138 --target=$(REAL_GNU_TARGET_NAME) \
139 --enable-languages=$(TARGET_LANGUAGES) \
140 --enable-shared \
141 --with-gxx-include-dir=$(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/include/c++ \
142 --disable-__cxa_atexit \
143 --enable-target-optspace \
144 --with-gnu-ld \
145 $(DISABLE_NLS) \
146 $(MULTILIB) \
147 $(SOFT_FLOAT_CONFIG_OPTION) \
148 $(GCC_USE_SJLJ_EXCEPTIONS) \
149 $(EXTRA_GCC_CONFIG_OPTIONS));
150 touch $(GCC_BUILD_DIR2)/.configured
151
152 $(GCC_BUILD_DIR2)/.compiled: $(GCC_BUILD_DIR2)/.configured
153 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) -C $(GCC_BUILD_DIR2) all
154 touch $(GCC_BUILD_DIR2)/.compiled
155
156 $(GCC_BUILD_DIR2)/.installed: $(GCC_BUILD_DIR2)/.compiled
157 PATH=$(TARGET_PATH) $(MAKE) $(JLEVEL) -C $(GCC_BUILD_DIR2) install
158 # Strip the host binaries
159 ifeq ($(GCC_STRIP_HOST_BINARIES),true)
160 -strip --strip-all -R .note -R .comment $(STAGING_DIR)/bin/*
161 endif
162 # Set up the symlinks to enable lying about target name.
163 set -e; \
164 (cd $(STAGING_DIR); \
165 ln -sf $(REAL_GNU_TARGET_NAME) $(GNU_TARGET_NAME); \
166 cd bin; \
167 for app in $(REAL_GNU_TARGET_NAME)-* ; do \
168 ln -sf $${app} \
169 $(GNU_TARGET_NAME)$${app##$(REAL_GNU_TARGET_NAME)}; \
170 done; \
171 );
172 ifeq ($(SOFT_FLOAT),true)
173 # Replace specs file with one that defaults to soft float mode.
174 if [ ! -f $(STAGING_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ] ; then \
175 echo staging dir specs file is missing ; \
176 /bin/false ; \
177 fi;
178 cp $(SOURCE_DIR)/specs-$(ARCH)-soft-float $(STAGING_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
179 endif
180 touch $(GCC_BUILD_DIR2)/.installed
181
182 gcc3_3: uclibc-configured binutils gcc3_3_initial $(LIBFLOAT_TARGET) uclibc \
183 $(GCC_BUILD_DIR2)/.installed $(GCC_TARGETS)
184
185 gcc3_3-source: $(DL_DIR)/$(GCC_SOURCE)
186
187 gcc3_3-clean:
188 rm -rf $(GCC_BUILD_DIR2)
189 rm -f $(STAGING_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
190
191 gcc3_3-dirclean:
192 rm -rf $(GCC_BUILD_DIR2)
193
194 #############################################################
195 #
196 # Next build target gcc compiler
197 #
198 #############################################################
199 GCC_BUILD_DIR3:=$(BUILD_DIR)/gcc-3.3-target
200
201 $(GCC_BUILD_DIR3)/.configured: $(GCC_BUILD_DIR2)/.installed
202 mkdir -p $(GCC_BUILD_DIR3)
203 (cd $(GCC_BUILD_DIR3); PATH=$(TARGET_PATH) \
204 $(GCC_DIR)/configure \
205 --prefix=/usr \
206 --build=$(GNU_HOST_NAME) \
207 --host=$(REAL_GNU_TARGET_NAME) \
208 --target=$(REAL_GNU_TARGET_NAME) \
209 --enable-languages=$(TARGET_LANGUAGES) \
210 --enable-shared \
211 --with-gxx-include-dir=/usr/include/c++ \
212 --disable-__cxa_atexit \
213 --enable-target-optspace \
214 --with-gnu-ld \
215 $(DISABLE_NLS) \
216 $(MULTILIB) \
217 $(SOFT_FLOAT_CONFIG_OPTION) \
218 $(GCC_USE_SJLJ_EXCEPTIONS) \
219 $(EXTRA_GCC_CONFIG_OPTIONS));
220 touch $(GCC_BUILD_DIR3)/.configured
221
222 $(GCC_BUILD_DIR3)/.compiled: $(GCC_BUILD_DIR3)/.configured
223 PATH=$(TARGET_PATH) \
224 $(MAKE) $(JLEVEL) $(TARGET_GCC_ARGS) -C $(GCC_BUILD_DIR3) all
225 touch $(GCC_BUILD_DIR3)/.compiled
226
227 $(TARGET_DIR)/usr/bin/gcc: $(GCC_BUILD_DIR3)/.compiled
228 PATH=$(TARGET_PATH) \
229 $(MAKE) $(JLEVEL) DESTDIR=$(TARGET_DIR) -C $(GCC_BUILD_DIR3) install
230 ifeq ($(SOFT_FLOAT),true)
231 # Replace specs file with one that defaults to soft float mode.
232 if [ ! -f $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs ] ; then \
233 echo target dir specs file is missing ; \
234 /bin/false ; \
235 fi;
236 cp $(SOURCE_DIR)/specs-$(ARCH)-soft-float $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
237 # Make sure gcc does not think we are cross compiling
238 $(SED) "s/^1/0/;" $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
239 else
240 # Remove broken specs file (cross compile flag is set).
241 rm -f $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/specs
242 endif
243 -(cd $(TARGET_DIR)/bin; find -type f | xargs $(STRIP) > /dev/null 2>&1)
244 -(cd $(TARGET_DIR)/usr/bin; find -type f | xargs $(STRIP) > /dev/null 2>&1)
245 -(cd $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION); $(STRIP) cc1 cc1plus collect2 > /dev/null 2>&1)
246 -(cd $(TARGET_DIR)/usr/lib; $(STRIP) libstdc++.so.*.*.* > /dev/null 2>&1)
247 -(cd $(TARGET_DIR)/lib; $(STRIP) libgcc_s.so.*.*.* > /dev/null 2>&1)
248 #
249 rm -f $(TARGET_DIR)/usr/lib/*.la*
250 #rm -rf $(TARGET_DIR)/share/locale $(TARGET_DIR)/usr/info \
251 # $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/doc
252 # Work around problem of missing syslimits.h
253 cp -f $(STAGING_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/include/syslimits.h $(TARGET_DIR)/usr/lib/gcc-lib/$(REAL_GNU_TARGET_NAME)/$(GCC_VERSION)/include/
254 # These are in /lib, so...
255 #rm -rf $(TARGET_DIR)/usr/lib/libgcc_s.so*
256 #touch -c $(TARGET_DIR)/usr/bin/gcc
257
258 gcc3_3_target: uclibc_target binutils_target $(TARGET_DIR)/usr/bin/gcc
259
260 gcc3_3_target-clean:
261 rm -rf $(GCC_BUILD_DIR3)
262 rm -f $(TARGET_DIR)/bin/$(REAL_GNU_TARGET_NAME)*
263
264 gcc3_3_target-dirclean:
265 rm -rf $(GCC_BUILD_DIR3)
266
267 endif
This page took 0.052716 seconds and 5 git commands to generate.