]> git.ipfire.org Git - ipfire-2.x.git/blame_incremental - lfs/gcc
sed: Update to 4.2.1.
[ipfire-2.x.git] / lfs / gcc
... / ...
CommitLineData
1###############################################################################
2# #
3# IPFire.org - A linux based firewall #
4# Copyright (C) 2007-2011 IPFire Team <info@ipfire.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 3 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 #
14# GNU 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, see <http://www.gnu.org/licenses/>. #
18# #
19###############################################################################
20
21###############################################################################
22# Definitions
23###############################################################################
24
25include Config
26
27VER = 4.4.7
28
29GMP_VER = 5.0.5
30MPFR_VER = 2.4.2
31
32THISAPP = gcc-$(VER)
33DL_FILE = $(THISAPP).tar.bz2
34DL_FROM = $(URL_IPFIRE)
35DIR_APP = $(DIR_SRC)/$(THISAPP)
36
37# Normal build or /tools build.
38#
39ifeq "$(ROOT)" ""
40 TARGET = $(DIR_INFO)/$(THISAPP)
41 EXTRA_CONFIG = --prefix=/usr \
42 --libexecdir=/usr/lib \
43 --enable-shared \
44 --enable-threads=posix \
45 --enable-__cxa_atexit \
46 --enable-clocale=gnu \
47 --enable-languages=c,c++ \
48 --disable-nls
49 EXTRA_MAKE =
50 EXTRA_INSTALL =
51else
52ifeq "$(PASS)" "1"
53 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
54 EXTRA_CONFIG = \
55 --target=$(CROSSTARGET) \
56 --prefix=/tools \
57 --disable-nls \
58 --disable-shared \
59 --disable-decimal-float \
60 --disable-threads \
61 --disable-libmudflap \
62 --disable-libssp \
63 --disable-libgomp \
64 --disable-libquadmath \
65 --with-newlib \
66 --without-headers \
67 --without-ppl \
68 --without-cloog \
69 --enable-languages=c
70 EXTRA_MAKE =
71 EXTRA_INSTALL =
72else
73 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
74 EXTRA_ENV = \
75 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
76 AR="$(CROSSTARGET)-ar" \
77 RANLIB="$(CROSSTARGET)-ranlib"
78 EXTRA_CONFIG = \
79 --host=$(BUILDTARGET) \
80 --build=$(BUILDTARGET) \
81 --target=$(BUILDTARGET) \
82 --prefix=/tools \
83 --with-local-prefix=/tools \
84 --enable-clocale=gnu \
85 --enable-shared \
86 --enable-threads=posix \
87 --enable-__cxa_atexit \
88 --enable-languages=c,c++ \
89 --disable-libstdcxx-pch \
90 --disable-bootstrap
91 EXTRA_MAKE =
92 EXTRA_INSTALL =
93endif
94endif
95
96ifeq "$(MACHINE_TYPE)" "arm"
97 EXTRA_CONFIG += \
98 --with-float=soft
99endif
100
101export XCFLAGS = $(CFLAGS)
102export TCFLAGS = $(CFLAGS)
103
104###############################################################################
105# Top-level Rules
106###############################################################################
107
108objects = $(DL_FILE) \
109 gmp-$(GMP_VER).tar.bz2 \
110 mpfr-$(MPFR_VER).tar.bz2
111
112$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
113gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
114mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
115
116$(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281
117gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
118mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
119
120install : $(TARGET)
121
122check : $(patsubst %,$(DIR_CHK)/%,$(objects))
123
124download :$(patsubst %,$(DIR_DL)/%,$(objects))
125
126md5 : $(subst %,%_MD5,$(objects))
127
128###############################################################################
129# Downloading, checking, md5sum
130###############################################################################
131
132$(patsubst %,$(DIR_CHK)/%,$(objects)) :
133 @$(CHECK)
134
135$(patsubst %,$(DIR_DL)/%,$(objects)) :
136 @$(LOAD)
137
138$(subst %,%_MD5,$(objects)) :
139 @$(MD5)
140
141###############################################################################
142# Installation Details
143###############################################################################
144
145$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
146 @$(PREBUILD)
147 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
148 @mkdir $(DIR_SRC)/gcc-build
149
150ifneq "$(ROOT)" ""
151 # Build gmp and mpfr internally in toolchain.
152 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
153 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
154 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
155 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
156
157ifeq "$(PASS)" "1"
158 # GCC does not detect stack protection correctly, which causes problems
159 # for the build of libresolv_pic.a.
160 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
161endif
162
163ifeq "$(PASS)" "2"
164 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch
165
166 cd $(DIR_APP) && sed -i gcc/Makefile.in \
167 -e 's@\./fixinc\.sh@-c true@' \
168 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
169
170 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
171 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
172 echo "Processing $${file}..."; \
173 sed -i $${file} \
174 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
175 -e 's@/usr@/tools@g'; \
176 echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \
177 echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \
178 echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \
179 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
180 done
181endif
182endif
183
184 # The actual build.
185 cd $(DIR_SRC)/gcc-build && \
186 $(EXTRA_ENV) \
187 $(DIR_APP)/configure \
188 $(EXTRA_CONFIG)
189 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
190 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
191
192ifneq "$(ROOT)" ""
193ifeq "$(PASS)" "1"
194 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
195else
196 ln -svf gcc /tools/bin/cc
197endif
198endif
199 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
200 @$(POSTBUILD)