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