]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - lfs/gcc
Merge remote-tracking branch 'origin/master' into next
[people/pmueller/ipfire-2.x.git] / lfs / gcc
1 ###############################################################################
2 # #
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2016 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.9.3
28
29 GMP_VER = 5.0.5
30 MPFR_VER = 2.4.2
31 MPC_VER = 1.0.3
32
33 THISAPP = gcc-$(VER)
34 DL_FILE = $(THISAPP).tar.gz
35 DL_FROM = $(URL_IPFIRE)
36 DIR_APP = $(DIR_SRC)/$(THISAPP)
37
38 CFLAGS := $(patsubst -march=%,,$(CFLAGS))
39 CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
40 CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
41 CFLAGS := $(filter-out -fexceptions,$(CFLAGS))
42 CXXFLAGS := $(CFLAGS)
43
44 # Normal build or /tools build.
45 #
46 ifeq "$(ROOT)" ""
47 TARGET = $(DIR_INFO)/$(THISAPP)
48 EXTRA_CONFIG = \
49 --prefix=/usr \
50 --libexecdir=/usr/lib \
51 --enable-shared \
52 --enable-threads=posix \
53 --enable-__cxa_atexit \
54 --enable-clocale=gnu \
55 --enable-languages=c,c++ \
56 --disable-bootstrap \
57 --disable-nls
58 EXTRA_MAKE =
59 EXTRA_INSTALL =
60 else
61 ifeq "$(PASS)" "1"
62 CFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CFLAGS))
63 CXXFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CXXFLAGS))
64 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
65 EXTRA_CONFIG = \
66 --target=$(CROSSTARGET) \
67 --prefix=/tools \
68 --with-sysroot=$(ROOT) \
69 --disable-nls \
70 --disable-shared \
71 --disable-decimal-float \
72 --disable-threads \
73 --disable-libatomic \
74 --disable-libmudflap \
75 --disable-libssp \
76 --disable-libgomp \
77 --disable-libquadmath \
78 --disable-libstdc++-v3 \
79 --disable-libvtv \
80 --disable-libcilkrts \
81 --disable-libitm \
82 --disable-libsanitizer \
83 --with-newlib \
84 --without-headers \
85 --without-ppl \
86 --without-cloog \
87 --enable-languages=c,c++
88 EXTRA_MAKE =
89 EXTRA_INSTALL =
90 else
91 ifeq "$(PASS)" "2"
92 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
93 EXTRA_ENV = \
94 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
95 CXX="$(CROSSTARGET)-g++" \
96 AR="$(CROSSTARGET)-ar" \
97 RANLIB="$(CROSSTARGET)-ranlib"
98 EXTRA_CONFIG = \
99 --host=$(BUILDTARGET) \
100 --build=$(BUILDTARGET) \
101 --target=$(BUILDTARGET) \
102 --prefix=/tools \
103 --with-local-prefix=/tools \
104 --with-native-system-header-dir=/tools/include \
105 --enable-clocale=gnu \
106 --enable-shared \
107 --enable-threads=posix \
108 --enable-__cxa_atexit \
109 --enable-languages=c,c++ \
110 --disable-libstdcxx-pch \
111 --enable-bootstrap
112 EXTRA_MAKE =
113 EXTRA_INSTALL =
114 else
115 # PASS=L # libstdc++-v3
116 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
117 EXTRA_ENV = \
118 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
119 AR="$(CROSSTARGET)-ar" \
120 RANLIB="$(CROSSTARGET)-ranlib"
121 EXTRA_CONFIG = \
122 --host=$(CROSSTARGET) \
123 --prefix=/tools \
124 --with-sysroot=$(ROOT) \
125 --disable-shared \
126 --disable-nls \
127 --disable-libstdcxx-threads \
128 --disable-libstdcxx-pch \
129 --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER)
130 EXTRA_MAKE =
131 EXTRA_INSTALL =
132 endif
133 endif
134
135 # Disable stack protection in toolchain.
136 CFLAGS += -fno-stack-protector
137 endif
138
139 ifeq "$(MACHINE_TYPE)" "arm"
140 EXTRA_CONFIG += \
141 --with-float=soft \
142 --disable-sjlj-exceptions
143 endif
144
145 ifeq "$(MACHINE)" "i586"
146 EXTRA_CONFIG += \
147 --with-arch=i586 \
148 --with-tune=generic
149 endif
150
151 ifeq "$(MACHINE)" "x86_64"
152 EXTRA_CONFIG += \
153 --disable-multilib
154 endif
155
156 EXTRA_CONFIG += \
157 --with-bugurl=http://bugtracker.ipfire.org \
158 --disable-libunwind-exceptions \
159 --enable-gnu-unique-object
160
161 export XCFLAGS = $(CFLAGS)
162 export TCFLAGS = $(CFLAGS)
163
164 ###############################################################################
165 # Top-level Rules
166 ###############################################################################
167
168 objects = $(DL_FILE) \
169 gmp-$(GMP_VER).tar.bz2 \
170 mpfr-$(MPFR_VER).tar.bz2 \
171 mpc-$(MPC_VER).tar.gz
172
173 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
174 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
175 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
176 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
177
178 $(DL_FILE)_MD5 = 648bfba342bb41a4b5350fb685f85bc5
179 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
180 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
181 mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
182
183 install : $(TARGET)
184
185 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
186
187 download :$(patsubst %,$(DIR_DL)/%,$(objects))
188
189 md5 : $(subst %,%_MD5,$(objects))
190
191 ###############################################################################
192 # Downloading, checking, md5sum
193 ###############################################################################
194
195 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
196 @$(CHECK)
197
198 $(patsubst %,$(DIR_DL)/%,$(objects)) :
199 @$(LOAD)
200
201 $(subst %,%_MD5,$(objects)) :
202 @$(MD5)
203
204 ###############################################################################
205 # Installation Details
206 ###############################################################################
207
208 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
209 @$(PREBUILD)
210 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
211 @mkdir $(DIR_SRC)/gcc-build
212
213 # Apply patches.
214 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-i386-libgomp.patch
215 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-libtool-no-rpath.patch
216 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-no-add-needed.patch
217 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr38757.patch
218 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr64336.patch
219 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc/gcc-fix-inlining-issues.patch
220
221 ifneq "$(ROOT)" ""
222 # Build gmp and mpfr internally in toolchain.
223 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
224 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
225 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
226 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
227 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
228 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
229
230 ifeq "$(PASS)" "1"
231 # GCC does not detect stack protection correctly, which causes problems
232 # for the build of libresolv_pic.a.
233 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
234
235 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
236 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
237 echo "Processing $${file}..."; \
238 sed -i $${file} \
239 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
240 -e 's@/usr@/tools@g'; \
241 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
242 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
243 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
244 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
245 done
246 endif
247
248 ifeq "$(PASS)" "2"
249 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
250 `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
251 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
252 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
253 echo "Processing $${file}..."; \
254 sed -i $${file} \
255 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
256 -e 's@/usr@/tools@g'; \
257 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
258 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
259 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
260 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
261 done
262 endif
263 endif
264
265 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
266 cd $(DIR_APP) && sed -i gcc/Makefile.in \
267 -e 's@\./fixinc\.sh@-c true@' \
268 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
269
270 ifeq "$(PASS)" "L"
271 # libstdc++ pass
272 cd $(DIR_SRC)/gcc-build && \
273 $(EXTRA_ENV) \
274 $(DIR_APP)/libstdc++-v3/configure \
275 $(EXTRA_CONFIG)
276 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
277 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
278 else
279 # The actual build.
280 cd $(DIR_SRC)/gcc-build && \
281 $(EXTRA_ENV) \
282 $(DIR_APP)/configure \
283 $(EXTRA_CONFIG)
284 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
285 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
286 endif
287
288 ifeq "$(ROOT)" ""
289 ln -svf ../usr/bin/cpp /lib
290 ln -svf gcc /usr/bin/cc
291 # remove gdb python files from libdir
292 rm -rf /usr/lib/*-gdb.py
293 else
294 ifeq "$(PASS)" "1"
295 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
296 else
297 ln -svf gcc /tools/bin/cc
298 # remove gdb python files from libdir
299 rm -rf /tools/lib/*-gdb.py
300 endif
301 endif
302 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
303 @$(POSTBUILD)