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