]> git.ipfire.org Git - ipfire-2.x.git/blame - lfs/gcc
Allow building the toolchain for x86_64
[ipfire-2.x.git] / lfs / gcc
CommitLineData
cd1a2927 1###############################################################################
cd1a2927 2# #
70df8302 3# IPFire.org - A linux based firewall #
3f8c9dc5 4# Copyright (C) 2007-2011 IPFire Team <info@ipfire.org> #
70df8302
MT
5# #
6# This program is free software: you can redistribute it and/or modify #
cd1a2927 7# it under the terms of the GNU General Public License as published by #
70df8302 8# the Free Software Foundation, either version 3 of the License, or #
cd1a2927
MT
9# (at your option) any later version. #
10# #
70df8302 11# This program is distributed in the hope that it will be useful, #
cd1a2927
MT
12# but WITHOUT ANY WARRANTY; without even the implied warranty of #
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14# GNU General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
70df8302 17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
cd1a2927 18# #
cd1a2927
MT
19###############################################################################
20
21###############################################################################
22# Definitions
23###############################################################################
24
25include Config
26
82b312a9
MT
27VER = 4.4.7
28
29GMP_VER = 5.0.5
30MPFR_VER = 2.4.2
cd1a2927
MT
31
32THISAPP = gcc-$(VER)
dd714b8a
MT
33DL_FILE = $(THISAPP).tar.bz2
34DL_FROM = $(URL_IPFIRE)
cd1a2927 35DIR_APP = $(DIR_SRC)/$(THISAPP)
cd1a2927 36
ed635824
MT
37CFLAGS := $(patsubst -march=%,,$(CFLAGS))
38CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
62a430f9 39CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
ed635824 40
cd1a2927
MT
41# Normal build or /tools build.
42#
43ifeq "$(ROOT)" ""
44 TARGET = $(DIR_INFO)/$(THISAPP)
afbd9856
MT
45 EXTRA_CONFIG = \
46 --prefix=/usr \
47 --libexecdir=/usr/lib \
48 --enable-shared \
49 --enable-threads=posix \
50 --enable-__cxa_atexit \
51 --enable-clocale=gnu \
52 --enable-languages=c,c++ \
53 --disable-bootstrap \
54 --disable-nls
857d9bf2
MT
55 EXTRA_MAKE =
56 EXTRA_INSTALL =
cd1a2927 57else
15679d9f 58ifeq "$(PASS)" "1"
cd1a2927 59 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
82b312a9
MT
60 EXTRA_CONFIG = \
61 --target=$(CROSSTARGET) \
62 --prefix=/tools \
63 --disable-nls \
64 --disable-shared \
65 --disable-decimal-float \
66 --disable-threads \
67 --disable-libmudflap \
68 --disable-libssp \
69 --disable-libgomp \
70 --disable-libquadmath \
71 --with-newlib \
72 --without-headers \
73 --without-ppl \
74 --without-cloog \
b469c8c2 75 --enable-languages=c
575ea031 76 EXTRA_MAKE =
cd1a2927
MT
77 EXTRA_INSTALL =
78else
79 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
82b312a9
MT
80 EXTRA_ENV = \
81 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
82 AR="$(CROSSTARGET)-ar" \
83 RANLIB="$(CROSSTARGET)-ranlib"
84 EXTRA_CONFIG = \
85 --host=$(BUILDTARGET) \
86 --build=$(BUILDTARGET) \
87 --target=$(BUILDTARGET) \
88 --prefix=/tools \
89 --with-local-prefix=/tools \
90 --enable-clocale=gnu \
91 --enable-shared \
92 --enable-threads=posix \
93 --enable-__cxa_atexit \
94 --enable-languages=c,c++ \
95 --disable-libstdcxx-pch \
96 --disable-bootstrap
cd1a2927
MT
97 EXTRA_MAKE =
98 EXTRA_INSTALL =
99endif
3a317084
AF
100
101 # Disable stack protection in toolchain.
102 CFLAGS += -fno-stack-protector
cd1a2927
MT
103endif
104
cc72d5cb 105ifeq "$(MACHINE_TYPE)" "arm"
51f9e7ac 106 EXTRA_CONFIG += \
afbd9856
MT
107 --with-float=soft \
108 --disable-sjlj-exceptions
51f9e7ac
MT
109endif
110
ed635824
MT
111ifeq "$(MACHINE)" "i586"
112 EXTRA_CONFIG += \
113 --with-arch=i586 \
114 --with-tune=generic
115endif
116
81aa9714
MT
117ifeq "$(MACHINE)" "x86_64"
118 EXTRA_CONFIG += \
119 --disable-multilib
120endif
121
ed635824
MT
122EXTRA_CONFIG += \
123 --with-bugurl=http://bugtracker.ipfire.org \
124 --disable-libunwind-exceptions \
125 --enable-gnu-unique-object
126
51f9e7ac
MT
127export XCFLAGS = $(CFLAGS)
128export TCFLAGS = $(CFLAGS)
129
cd1a2927
MT
130###############################################################################
131# Top-level Rules
132###############################################################################
82b312a9
MT
133
134objects = $(DL_FILE) \
135 gmp-$(GMP_VER).tar.bz2 \
136 mpfr-$(MPFR_VER).tar.bz2
cd1a2927 137
41921bd9 138$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
82b312a9
MT
139gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
140mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
cd1a2927 141
82b312a9
MT
142$(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281
143gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
144mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
cd1a2927
MT
145
146install : $(TARGET)
147
148check : $(patsubst %,$(DIR_CHK)/%,$(objects))
149
150download :$(patsubst %,$(DIR_DL)/%,$(objects))
151
152md5 : $(subst %,%_MD5,$(objects))
153
154###############################################################################
155# Downloading, checking, md5sum
156###############################################################################
157
158$(patsubst %,$(DIR_CHK)/%,$(objects)) :
159 @$(CHECK)
160
161$(patsubst %,$(DIR_DL)/%,$(objects)) :
162 @$(LOAD)
163
164$(subst %,%_MD5,$(objects)) :
165 @$(MD5)
166
167###############################################################################
168# Installation Details
169###############################################################################
170
171$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
172 @$(PREBUILD)
173 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
dd714b8a 174 @mkdir $(DIR_SRC)/gcc-build
51f9e7ac 175
ed635824
MT
176 # Apply patches.
177 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-build-id.patch
178 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-c++-builtin-redecl.patch
179 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-i386-libgomp.patch
180 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-libtool-no-rpath.patch
181 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-no-add-needed.patch
182 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-pr33763.patch
183 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh330771.patch
184 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh533181.patch
185 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh610785.patch
186 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-unwind-debug-hook.patch
187
defd8d00
AF
188 # texinfo 5 syntax-fixes
189 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-4.4.7-texinfo-5.patch
190
82b312a9
MT
191ifneq "$(ROOT)" ""
192 # Build gmp and mpfr internally in toolchain.
193 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
194 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
195 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
196 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
197
198ifeq "$(PASS)" "1"
199 # GCC does not detect stack protection correctly, which causes problems
200 # for the build of libresolv_pic.a.
201 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
202endif
51f9e7ac 203
82b312a9
MT
204ifeq "$(PASS)" "2"
205 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch
206
82b312a9
MT
207 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
208 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
209 echo "Processing $${file}..."; \
210 sed -i $${file} \
211 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
212 -e 's@/usr@/tools@g'; \
213 echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \
214 echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \
215 echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \
216 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
217 done
218endif
219endif
dd714b8a 220
afbd9856
MT
221 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
222 cd $(DIR_APP) && sed -i gcc/Makefile.in \
223 -e 's@\./fixinc\.sh@-c true@' \
224 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
225
82b312a9
MT
226 # The actual build.
227 cd $(DIR_SRC)/gcc-build && \
228 $(EXTRA_ENV) \
229 $(DIR_APP)/configure \
230 $(EXTRA_CONFIG)
f97be0a6
MT
231 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
232 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
82b312a9 233
afbd9856
MT
234ifeq "$(ROOT)" ""
235 ln -svf ../usr/bin/cpp /lib
6753fbe0 236 ln -svf gcc /usr/bin/cc
afbd9856 237else
82b312a9
MT
238ifeq "$(PASS)" "1"
239 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
cd1a2927 240else
82b312a9 241 ln -svf gcc /tools/bin/cc
cd1a2927 242endif
cd1a2927
MT
243endif
244 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
245 @$(POSTBUILD)