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