]> git.ipfire.org Git - ipfire-2.x.git/blame_incremental - lfs/gcc
gcc: Do not build libmpx on x86 in first pass in toolchain
[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 = 6.3.0
28
29GMP_VER = 5.0.5
30MPFR_VER = 2.4.2
31MPC_VER = 1.0.3
32
33THISAPP = gcc-$(VER)
34DL_FILE = $(THISAPP).tar.gz
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 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
63 EXTRA_CONFIG = \
64 --target=$(CROSSTARGET) \
65 --prefix=/tools \
66 --with-sysroot=$(ROOT) \
67 --with-local-prefix=/tools \
68 --with-native-system-header-dir=/tools/include \
69 --disable-nls \
70 --disable-shared \
71 --disable-decimal-float \
72 --disable-threads \
73 --disable-libatomic \
74 --disable-libmudflap \
75 --disable-libssp \
76 --disable-libmpx \
77 --disable-libgomp \
78 --disable-libquadmath \
79 --disable-libstdc++-v3 \
80 --disable-libvtv \
81 --disable-libcilkrts \
82 --disable-libitm \
83 --disable-libsanitizer \
84 --with-newlib \
85 --without-headers \
86 --without-ppl \
87 --without-cloog \
88 --enable-languages=c,c++
89 EXTRA_MAKE =
90 EXTRA_INSTALL =
91else
92ifeq "$(PASS)" "2"
93 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
94 EXTRA_ENV = \
95 CC="$(CROSSTARGET)-gcc" \
96 CXX="$(CROSSTARGET)-g++" \
97 AR="$(CROSSTARGET)-ar" \
98 RANLIB="$(CROSSTARGET)-ranlib"
99 EXTRA_CONFIG = \
100 --host=$(BUILDTARGET) \
101 --build=$(BUILDTARGET) \
102 --target=$(BUILDTARGET) \
103 --prefix=/tools \
104 --with-local-prefix=/tools \
105 --with-native-system-header-dir=/tools/include \
106 --enable-clocale=gnu \
107 --enable-shared \
108 --enable-threads=posix \
109 --enable-__cxa_atexit \
110 --enable-languages=c,c++ \
111 --disable-libstdcxx-pch \
112 --disable-bootstrap
113 EXTRA_MAKE =
114 EXTRA_INSTALL =
115else
116 # PASS=L # libstdc++-v3
117 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
118 EXTRA_ENV = \
119 CC="$(CROSSTARGET)-gcc" \
120 AR="$(CROSSTARGET)-ar" \
121 RANLIB="$(CROSSTARGET)-ranlib"
122 EXTRA_CONFIG = \
123 --host=$(CROSSTARGET) \
124 --prefix=/tools \
125 --with-sysroot=$(ROOT) \
126 --disable-shared \
127 --disable-nls \
128 --disable-libstdcxx-threads \
129 --disable-libstdcxx-pch \
130 --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER)
131 EXTRA_MAKE =
132 EXTRA_INSTALL =
133endif
134endif
135endif
136
137ifeq "$(BUILD_ARCH)" "armv7hl"
138 EXTRA_CONFIG += \
139 --with-float=hard
140endif
141
142ifeq "$(BUILD_ARCH)" "armv5tel"
143 EXTRA_CONFIG += \
144 --with-float=soft \
145 --disable-sjlj-exceptions
146endif
147
148ifeq "$(BUILD_ARCH)" "i586"
149 EXTRA_CONFIG += \
150 --with-arch=i586 \
151 --with-tune=generic
152endif
153
154EXTRA_CONFIG += \
155 --disable-multilib \
156 --with-bugurl=http://bugtracker.ipfire.org \
157 --disable-libunwind-exceptions \
158 --enable-gnu-unique-object
159
160export XCFLAGS = $(CFLAGS)
161export TCFLAGS = $(CFLAGS)
162
163###############################################################################
164# Top-level Rules
165###############################################################################
166
167objects = $(DL_FILE) \
168 gmp-$(GMP_VER).tar.bz2 \
169 mpfr-$(MPFR_VER).tar.bz2 \
170 mpc-$(MPC_VER).tar.gz
171
172$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
173gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
174mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
175mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
176
177$(DL_FILE)_MD5 = 6e5ea04789678f1250c1b30c4d9ec417
178gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
179mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
180mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
181
182install : $(TARGET)
183
184check : $(patsubst %,$(DIR_CHK)/%,$(objects))
185
186download :$(patsubst %,$(DIR_DL)/%,$(objects))
187
188md5 : $(subst %,%_MD5,$(objects))
189
190###############################################################################
191# Downloading, checking, md5sum
192###############################################################################
193
194$(patsubst %,$(DIR_CHK)/%,$(objects)) :
195 @$(CHECK)
196
197$(patsubst %,$(DIR_DL)/%,$(objects)) :
198 @$(LOAD)
199
200$(subst %,%_MD5,$(objects)) :
201 @$(MD5)
202
203###############################################################################
204# Installation Details
205###############################################################################
206
207$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
208 @$(PREBUILD)
209 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
210 @mkdir $(DIR_SRC)/gcc-build
211
212 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
213 cd $(DIR_APP) && sed -i gcc/Makefile.in \
214 -e 's@\./fixinc\.sh@-c true@' \
215 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
216
217ifeq "$(TOOLCHAIN)" "1"
218 # Build gmp and mpfr internally in toolchain.
219 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
220 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
221 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
222 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
223 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
224 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
225
226ifeq "$(PASS)" "2"
227 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
228 `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
229endif
230
231 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
232 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
233 echo "Processing $${file}..."; \
234 sed -i $${file} \
235 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
236 -e 's@/usr@/tools@g'; \
237 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
238 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
239 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
240 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
241 done
242endif
243
244ifeq "$(PASS)" "L"
245 # libstdc++ pass
246 cd $(DIR_SRC)/gcc-build && \
247 $(EXTRA_ENV) \
248 $(DIR_APP)/libstdc++-v3/configure \
249 $(EXTRA_CONFIG)
250 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
251 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
252
253else
254 # The actual build.
255 cd $(DIR_SRC)/gcc-build && \
256 $(EXTRA_ENV) \
257 $(DIR_APP)/configure \
258 $(EXTRA_CONFIG)
259 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
260 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
261endif
262
263ifeq "$(TOOLCHAIN)" "1"
264 ifeq "$(PASS)" "1"
265 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
266 endif
267
268 ifeq "$(PASS)" "2"
269 ln -svf gcc /tools/bin/cc
270 # remove gdb python files from libdir
271 rm -rf /tools/lib/*-gdb.py
272 endif
273
274 ifeq "$(PASS)" "L"
275 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
276 sed -e "s/^#include_next/#include/" -i /tools/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
277 endif
278
279else # NON-TOOLCHAIN
280 ln -svf ../usr/bin/cpp /lib
281 ln -svf gcc /usr/bin/cc
282 # remove gdb python files from libdir
283 rm -rf /usr/lib/*-gdb.py
284endif
285
286 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build
287 @$(POSTBUILD)