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