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