1 # Makefile for to build a gcc/uClibc toolchain
3 # Copyright (C) 2002-2003 Erik Andersen <andersen@uclibc.org>
4 # Copyright (C) 2004 Manuel Novoa III <mjn3@uclibc.org>
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.
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.
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
20 ifneq ($(GCC_2_95_TOOLCHAIN
),true
)
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)
30 #GCC_VERSION:=3.3-20031013
31 #GCC_SITE:=http://gcc.get-software.com/snapshots/$(GCC_VERSION)
33 GCC_SOURCE
:=gcc-
$(GCC_VERSION
).
tar.bz2
34 GCC_DIR
:=$(TOOL_BUILD_DIR
)/gcc-
$(GCC_VERSION
)
36 GCC_STRIP_HOST_BINARIES
:=true
38 #############################################################
40 # Setup some initial stuff
42 #############################################################
44 ifeq ($(INSTALL_LIBGCJ
),true
)
45 TARGET_LANGUAGES
:=c
,c
++,java
47 ifeq ($(INSTALL_LIBSTDCPP
),true
)
48 TARGET_LANGUAGES
:=c
,c
++
54 #############################################################
56 # build the first pass gcc compiler
58 #############################################################
59 GCC_BUILD_DIR1
:=$(TOOL_BUILD_DIR
)/gcc-3.3
-initial
61 $(DL_DIR
)/$(GCC_SOURCE
):
62 $(WGET
) -P
$(DL_DIR
) $(GCC_SITE
)/$(GCC_SOURCE
)
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
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
77 touch
$(GCC_DIR
)/.patched
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 \
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 \
100 $(SOFT_FLOAT_CONFIG_OPTION
) \
101 $(EXTRA_GCC_CONFIG_OPTIONS
));
102 touch
$(GCC_BUILD_DIR1
)/.configured
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
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
113 gcc3_3_initial
: uclibc-configured binutils
$(STAGING_DIR
)/bin
/$(REAL_GNU_TARGET_NAME
)-gcc
115 gcc3_3_initial-clean
:
116 rm -rf
$(GCC_BUILD_DIR1
)
117 rm -f
$(STAGING_DIR
)/bin
/$(REAL_GNU_TARGET_NAME
)*
119 gcc3_3_initial-dirclean
:
120 rm -rf
$(GCC_BUILD_DIR1
)
122 #############################################################
124 # second pass compiler build. Build the compiler targeting
125 # the newly built shared uClibc library.
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
) \
141 --with-gxx-include-dir
=$(STAGING_DIR
)/$(REAL_GNU_TARGET_NAME
)/include/c
++ \
142 --disable-__cxa_atexit \
143 --enable-target-optspace \
147 $(SOFT_FLOAT_CONFIG_OPTION
) \
148 $(GCC_USE_SJLJ_EXCEPTIONS
) \
149 $(EXTRA_GCC_CONFIG_OPTIONS
));
150 touch
$(GCC_BUILD_DIR2
)/.configured
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
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
/*
162 # Set up the symlinks to enable lying about target name.
164 (cd
$(STAGING_DIR
); \
165 ln
-sf
$(REAL_GNU_TARGET_NAME
) $(GNU_TARGET_NAME
); \
167 for app in
$(REAL_GNU_TARGET_NAME
)-* ; do \
169 $(GNU_TARGET_NAME
)$${app
##$(REAL_GNU_TARGET_NAME)}; \
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
; \
178 cp
$(SOURCE_DIR
)/specs-
$(ARCH
)-soft-float
$(STAGING_DIR
)/usr
/lib
/gcc-lib
/$(REAL_GNU_TARGET_NAME
)/$(GCC_VERSION
)/specs
180 touch
$(GCC_BUILD_DIR2
)/.installed
182 gcc3_3
: uclibc-configured binutils gcc3_3_initial
$(LIBFLOAT_TARGET
) uclibc \
183 $(GCC_BUILD_DIR2
)/.installed
$(GCC_TARGETS
)
185 gcc3_3-source
: $(DL_DIR
)/$(GCC_SOURCE
)
188 rm -rf
$(GCC_BUILD_DIR2
)
189 rm -f
$(STAGING_DIR
)/bin
/$(REAL_GNU_TARGET_NAME
)*
192 rm -rf
$(GCC_BUILD_DIR2
)
194 #############################################################
196 # Next build target gcc compiler
198 #############################################################
199 GCC_BUILD_DIR3
:=$(BUILD_DIR
)/gcc-3.3
-target
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 \
206 --build
=$(GNU_HOST_NAME
) \
207 --host
=$(REAL_GNU_TARGET_NAME
) \
208 --target
=$(REAL_GNU_TARGET_NAME
) \
209 --enable-languages
=$(TARGET_LANGUAGES
) \
211 --with-gxx-include-dir
=/usr
/include/c
++ \
212 --disable-__cxa_atexit \
213 --enable-target-optspace \
217 $(SOFT_FLOAT_CONFIG_OPTION
) \
218 $(GCC_USE_SJLJ_EXCEPTIONS
) \
219 $(EXTRA_GCC_CONFIG_OPTIONS
));
220 touch
$(GCC_BUILD_DIR3
)/.configured
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
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
; \
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
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
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)
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
258 gcc3_3_target
: uclibc_target binutils_target
$(TARGET_DIR
)/usr
/bin
/gcc
261 rm -rf
$(GCC_BUILD_DIR3
)
262 rm -f
$(TARGET_DIR
)/bin
/$(REAL_GNU_TARGET_NAME
)*
264 gcc3_3_target-dirclean
:
265 rm -rf
$(GCC_BUILD_DIR3
)