sed: Update to 4.2.1.
[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)
41 EXTRA_CONFIG = --prefix=/usr \
a50d04ab
MT
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
857d9bf2
MT
49 EXTRA_MAKE =
50 EXTRA_INSTALL =
cd1a2927 51else
15679d9f 52ifeq "$(PASS)" "1"
cd1a2927 53 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
82b312a9
MT
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
575ea031 70 EXTRA_MAKE =
cd1a2927
MT
71 EXTRA_INSTALL =
72else
73 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
82b312a9
MT
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
cd1a2927
MT
91 EXTRA_MAKE =
92 EXTRA_INSTALL =
93endif
94endif
95
cc72d5cb 96ifeq "$(MACHINE_TYPE)" "arm"
51f9e7ac 97 EXTRA_CONFIG += \
82b312a9 98 --with-float=soft
51f9e7ac
MT
99endif
100
101export XCFLAGS = $(CFLAGS)
102export TCFLAGS = $(CFLAGS)
103
cd1a2927
MT
104###############################################################################
105# Top-level Rules
106###############################################################################
82b312a9
MT
107
108objects = $(DL_FILE) \
109 gmp-$(GMP_VER).tar.bz2 \
110 mpfr-$(MPFR_VER).tar.bz2
cd1a2927 111
41921bd9 112$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
82b312a9
MT
113gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
114mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
cd1a2927 115
82b312a9
MT
116$(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281
117gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
118mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
cd1a2927
MT
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)
dd714b8a 148 @mkdir $(DIR_SRC)/gcc-build
51f9e7ac 149
82b312a9
MT
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
51f9e7ac 162
82b312a9
MT
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
dd714b8a 183
82b312a9
MT
184 # The actual build.
185 cd $(DIR_SRC)/gcc-build && \
186 $(EXTRA_ENV) \
187 $(DIR_APP)/configure \
188 $(EXTRA_CONFIG)
f97be0a6
MT
189 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
190 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
82b312a9
MT
191
192ifneq "$(ROOT)" ""
193ifeq "$(PASS)" "1"
194 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
cd1a2927 195else
82b312a9 196 ln -svf gcc /tools/bin/cc
cd1a2927 197endif
cd1a2927
MT
198endif
199 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
200 @$(POSTBUILD)