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