Update rootfiles.
[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
MT
36
37# Normal build or /tools build.
38#
39ifeq "$(ROOT)" ""
40 TARGET = $(DIR_INFO)/$(THISAPP)
afbd9856
MT
41 EXTRA_CONFIG = \
42 --prefix=/usr \
43 --libexecdir=/usr/lib \
44 --enable-shared \
45 --enable-threads=posix \
46 --enable-__cxa_atexit \
47 --enable-clocale=gnu \
48 --enable-languages=c,c++ \
49 --disable-bootstrap \
50 --disable-nls
857d9bf2
MT
51 EXTRA_MAKE =
52 EXTRA_INSTALL =
cd1a2927 53else
15679d9f 54ifeq "$(PASS)" "1"
222362c3 55 CFLAGS := $(patsubst -march=%,,$(CFLAGS))
cd1a2927 56 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
82b312a9
MT
57 EXTRA_CONFIG = \
58 --target=$(CROSSTARGET) \
59 --prefix=/tools \
60 --disable-nls \
61 --disable-shared \
62 --disable-decimal-float \
63 --disable-threads \
64 --disable-libmudflap \
65 --disable-libssp \
66 --disable-libgomp \
67 --disable-libquadmath \
68 --with-newlib \
69 --without-headers \
70 --without-ppl \
71 --without-cloog \
b469c8c2 72 --enable-languages=c
575ea031 73 EXTRA_MAKE =
cd1a2927
MT
74 EXTRA_INSTALL =
75else
76 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
82b312a9
MT
77 EXTRA_ENV = \
78 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
79 AR="$(CROSSTARGET)-ar" \
80 RANLIB="$(CROSSTARGET)-ranlib"
81 EXTRA_CONFIG = \
82 --host=$(BUILDTARGET) \
83 --build=$(BUILDTARGET) \
84 --target=$(BUILDTARGET) \
85 --prefix=/tools \
86 --with-local-prefix=/tools \
87 --enable-clocale=gnu \
88 --enable-shared \
89 --enable-threads=posix \
90 --enable-__cxa_atexit \
91 --enable-languages=c,c++ \
92 --disable-libstdcxx-pch \
93 --disable-bootstrap
cd1a2927
MT
94 EXTRA_MAKE =
95 EXTRA_INSTALL =
96endif
97endif
98
cc72d5cb 99ifeq "$(MACHINE_TYPE)" "arm"
51f9e7ac 100 EXTRA_CONFIG += \
afbd9856
MT
101 --with-float=soft \
102 --disable-sjlj-exceptions
51f9e7ac
MT
103endif
104
105export XCFLAGS = $(CFLAGS)
106export TCFLAGS = $(CFLAGS)
107
6c9d6fcc
AF
108ifeq "$(PASS)" "1"
109 CFLAGS =
110endif
111
cd1a2927
MT
112###############################################################################
113# Top-level Rules
114###############################################################################
82b312a9
MT
115
116objects = $(DL_FILE) \
117 gmp-$(GMP_VER).tar.bz2 \
118 mpfr-$(MPFR_VER).tar.bz2
cd1a2927 119
41921bd9 120$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
82b312a9
MT
121gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
122mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
cd1a2927 123
82b312a9
MT
124$(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281
125gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
126mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
cd1a2927
MT
127
128install : $(TARGET)
129
130check : $(patsubst %,$(DIR_CHK)/%,$(objects))
131
132download :$(patsubst %,$(DIR_DL)/%,$(objects))
133
134md5 : $(subst %,%_MD5,$(objects))
135
136###############################################################################
137# Downloading, checking, md5sum
138###############################################################################
139
140$(patsubst %,$(DIR_CHK)/%,$(objects)) :
141 @$(CHECK)
142
143$(patsubst %,$(DIR_DL)/%,$(objects)) :
144 @$(LOAD)
145
146$(subst %,%_MD5,$(objects)) :
147 @$(MD5)
148
149###############################################################################
150# Installation Details
151###############################################################################
152
153$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
154 @$(PREBUILD)
155 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
dd714b8a 156 @mkdir $(DIR_SRC)/gcc-build
51f9e7ac 157
82b312a9
MT
158ifneq "$(ROOT)" ""
159 # Build gmp and mpfr internally in toolchain.
160 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
161 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
162 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
163 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
164
165ifeq "$(PASS)" "1"
166 # GCC does not detect stack protection correctly, which causes problems
167 # for the build of libresolv_pic.a.
168 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
169endif
51f9e7ac 170
82b312a9
MT
171ifeq "$(PASS)" "2"
172 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch
173
82b312a9
MT
174 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
175 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
176 echo "Processing $${file}..."; \
177 sed -i $${file} \
178 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
179 -e 's@/usr@/tools@g'; \
180 echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \
181 echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \
182 echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \
183 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
184 done
185endif
186endif
dd714b8a 187
afbd9856
MT
188 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
189 cd $(DIR_APP) && sed -i gcc/Makefile.in \
190 -e 's@\./fixinc\.sh@-c true@' \
191 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
192
82b312a9
MT
193 # The actual build.
194 cd $(DIR_SRC)/gcc-build && \
195 $(EXTRA_ENV) \
196 $(DIR_APP)/configure \
197 $(EXTRA_CONFIG)
f97be0a6
MT
198 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
199 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
82b312a9 200
afbd9856
MT
201ifeq "$(ROOT)" ""
202 ln -svf ../usr/bin/cpp /lib
6753fbe0 203 ln -svf gcc /usr/bin/cc
afbd9856 204else
82b312a9
MT
205ifeq "$(PASS)" "1"
206 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
cd1a2927 207else
82b312a9 208 ln -svf gcc /tools/bin/cc
cd1a2927 209endif
cd1a2927
MT
210endif
211 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
212 @$(POSTBUILD)