]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - lfs/gcc
initrd: don't remove binary moduldeps.
[people/teissler/ipfire-2.x.git] / lfs / gcc
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
25 include Config
26
27 VER = 4.4.7
28
29 GMP_VER = 5.0.5
30 MPFR_VER = 2.4.2
31
32 THISAPP = gcc-$(VER)
33 DL_FILE = $(THISAPP).tar.bz2
34 DL_FROM = $(URL_IPFIRE)
35 DIR_APP = $(DIR_SRC)/$(THISAPP)
36
37 CFLAGS := $(patsubst -march=%,,$(CFLAGS))
38 CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
39 CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
40
41 # Normal build or /tools build.
42 #
43 ifeq "$(ROOT)" ""
44 TARGET = $(DIR_INFO)/$(THISAPP)
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
55 EXTRA_MAKE =
56 EXTRA_INSTALL =
57 else
58 ifeq "$(PASS)" "1"
59 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
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 \
75 --enable-languages=c
76 EXTRA_MAKE =
77 EXTRA_INSTALL =
78 else
79 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
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
97 EXTRA_MAKE =
98 EXTRA_INSTALL =
99 endif
100
101 # Disable stack protection in toolchain.
102 CFLAGS += -fno-stack-protector
103 endif
104
105 ifeq "$(MACHINE_TYPE)" "arm"
106 EXTRA_CONFIG += \
107 --with-float=soft \
108 --disable-sjlj-exceptions
109 endif
110
111 ifeq "$(MACHINE)" "i586"
112 EXTRA_CONFIG += \
113 --with-arch=i586 \
114 --with-tune=generic
115 endif
116
117 EXTRA_CONFIG += \
118 --with-bugurl=http://bugtracker.ipfire.org \
119 --disable-libunwind-exceptions \
120 --enable-gnu-unique-object
121
122 export XCFLAGS = $(CFLAGS)
123 export TCFLAGS = $(CFLAGS)
124
125 ###############################################################################
126 # Top-level Rules
127 ###############################################################################
128
129 objects = $(DL_FILE) \
130 gmp-$(GMP_VER).tar.bz2 \
131 mpfr-$(MPFR_VER).tar.bz2
132
133 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
134 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
135 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
136
137 $(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281
138 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
139 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
140
141 install : $(TARGET)
142
143 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
144
145 download :$(patsubst %,$(DIR_DL)/%,$(objects))
146
147 md5 : $(subst %,%_MD5,$(objects))
148
149 ###############################################################################
150 # Downloading, checking, md5sum
151 ###############################################################################
152
153 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
154 @$(CHECK)
155
156 $(patsubst %,$(DIR_DL)/%,$(objects)) :
157 @$(LOAD)
158
159 $(subst %,%_MD5,$(objects)) :
160 @$(MD5)
161
162 ###############################################################################
163 # Installation Details
164 ###############################################################################
165
166 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
167 @$(PREBUILD)
168 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
169 @mkdir $(DIR_SRC)/gcc-build
170
171 # Apply patches.
172 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-build-id.patch
173 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-c++-builtin-redecl.patch
174 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-i386-libgomp.patch
175 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-libtool-no-rpath.patch
176 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-no-add-needed.patch
177 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-pr33763.patch
178 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh330771.patch
179 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh533181.patch
180 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh610785.patch
181 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-unwind-debug-hook.patch
182
183 # texinfo 5 syntax-fixes
184 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-4.4.7-texinfo-5.patch
185
186 ifneq "$(ROOT)" ""
187 # Build gmp and mpfr internally in toolchain.
188 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
189 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
190 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
191 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
192
193 ifeq "$(PASS)" "1"
194 # GCC does not detect stack protection correctly, which causes problems
195 # for the build of libresolv_pic.a.
196 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
197 endif
198
199 ifeq "$(PASS)" "2"
200 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch
201
202 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
203 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
204 echo "Processing $${file}..."; \
205 sed -i $${file} \
206 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
207 -e 's@/usr@/tools@g'; \
208 echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \
209 echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \
210 echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \
211 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
212 done
213 endif
214 endif
215
216 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
217 cd $(DIR_APP) && sed -i gcc/Makefile.in \
218 -e 's@\./fixinc\.sh@-c true@' \
219 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
220
221 # The actual build.
222 cd $(DIR_SRC)/gcc-build && \
223 $(EXTRA_ENV) \
224 $(DIR_APP)/configure \
225 $(EXTRA_CONFIG)
226 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
227 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
228
229 ifeq "$(ROOT)" ""
230 ln -svf ../usr/bin/cpp /lib
231 ln -svf gcc /usr/bin/cc
232 else
233 ifeq "$(PASS)" "1"
234 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
235 else
236 ln -svf gcc /tools/bin/cc
237 endif
238 endif
239 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
240 @$(POSTBUILD)