]>
Commit | Line | Data |
---|---|---|
cd1a2927 | 1 | ############################################################################### |
cd1a2927 | 2 | # # |
70df8302 | 3 | # IPFire.org - A linux based firewall # |
4e6fcc73 | 4 | # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> # |
70df8302 MT |
5 | # # |
6 | # This program is free software: you can redistribute it and/or modify # | |
cd1a2927 | 7 | # it under the terms of the GNU General Public License as published by # |
70df8302 | 8 | # the Free Software Foundation, either version 3 of the License, or # |
cd1a2927 MT |
9 | # (at your option) any later version. # |
10 | # # | |
70df8302 | 11 | # This program is distributed in the hope that it will be useful, # |
cd1a2927 MT |
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 # | |
70df8302 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # |
cd1a2927 | 18 | # # |
cd1a2927 MT |
19 | ############################################################################### |
20 | ||
21 | ############################################################################### | |
22 | # Definitions | |
23 | ############################################################################### | |
24 | ||
25 | include Config | |
26 | ||
e8bdca4d | 27 | VER = 13.2.0 |
82b312a9 | 28 | |
570590a2 | 29 | GMP_VER = 6.2.1 |
32bbae10 | 30 | MPFR_VER = 4.2.0 |
df1a3f56 | 31 | MPC_VER = 1.3.1 |
cd1a2927 MT |
32 | |
33 | THISAPP = gcc-$(VER) | |
11b5e5cb | 34 | DL_FILE = $(THISAPP).tar.xz |
dd714b8a | 35 | DL_FROM = $(URL_IPFIRE) |
cd1a2927 | 36 | DIR_APP = $(DIR_SRC)/$(THISAPP) |
cd1a2927 | 37 | |
05c54e82 | 38 | ifeq "$(PASS)" "1" |
ed635824 | 39 | CFLAGS := $(patsubst -march=%,,$(CFLAGS)) |
f3c01b39 | 40 | CFLAGS := $(patsubst -mfpu=%,,$(CFLAGS)) |
ed635824 | 41 | CFLAGS := $(patsubst -mtune=%,,$(CFLAGS)) |
62a430f9 | 42 | CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS)) |
8675b78a | 43 | CFLAGS := $(filter-out -fexceptions,$(CFLAGS)) |
11b5e5cb | 44 | |
11b5e5cb | 45 | CFLAGS := $(patsubst -mindirect-branch=%,,$(CFLAGS)) |
51211195 | 46 | CFLAGS := $(patsubst -mbranch-protection=%,,$(CFLAGS)) |
11b5e5cb | 47 | CFLAGS := $(patsubst -mfunction-return=%,,$(CFLAGS)) |
d83422d1 AF |
48 | CFLAGS := $(patsubst -fstack-clash-protection,,$(CFLAGS)) |
49 | CFLAGS := $(patsubst -fcf-protection,,$(CFLAGS)) | |
11b5e5cb AF |
50 | endif |
51 | ||
8675b78a | 52 | CXXFLAGS := $(CFLAGS) |
ff1d5f3a | 53 | |
6c4cc7ea | 54 | # Normal build or $(TOOLS_DIR) build. |
cd1a2927 MT |
55 | # |
56 | ifeq "$(ROOT)" "" | |
57 | TARGET = $(DIR_INFO)/$(THISAPP) | |
afbd9856 MT |
58 | EXTRA_CONFIG = \ |
59 | --prefix=/usr \ | |
60 | --libexecdir=/usr/lib \ | |
61 | --enable-shared \ | |
62 | --enable-threads=posix \ | |
63 | --enable-__cxa_atexit \ | |
64 | --enable-clocale=gnu \ | |
eed179ac | 65 | --enable-languages=c,c++ \ |
afbd9856 MT |
66 | --disable-bootstrap \ |
67 | --disable-nls | |
857d9bf2 MT |
68 | EXTRA_MAKE = |
69 | EXTRA_INSTALL = | |
b2af45b2 AF |
70 | ifeq "$(PASS)" "A" |
71 | TARGET = $(DIR_INFO)/$(THISAPP)-libatomic | |
72 | endif | |
cd1a2927 | 73 | else |
15679d9f | 74 | ifeq "$(PASS)" "1" |
cd1a2927 | 75 | TARGET = $(DIR_INFO)/$(THISAPP)-tools1 |
82b312a9 MT |
76 | EXTRA_CONFIG = \ |
77 | --target=$(CROSSTARGET) \ | |
6c4cc7ea | 78 | --prefix=$(TOOLS_DIR) \ |
764a3f1f | 79 | --with-sysroot=$(ROOT) \ |
6c4cc7ea MT |
80 | --with-local-prefix=$(TOOLS_DIR) \ |
81 | --with-native-system-header-dir=$(TOOLS_DIR)/include \ | |
e111b836 | 82 | --with-glibc-version=2.11 \ |
82b312a9 MT |
83 | --disable-nls \ |
84 | --disable-shared \ | |
e111b836 | 85 | --disable-multilib \ |
82b312a9 MT |
86 | --disable-decimal-float \ |
87 | --disable-threads \ | |
764a3f1f | 88 | --disable-libatomic \ |
82b312a9 MT |
89 | --disable-libmudflap \ |
90 | --disable-libssp \ | |
8bc5ded2 | 91 | --disable-libmpx \ |
82b312a9 MT |
92 | --disable-libgomp \ |
93 | --disable-libquadmath \ | |
764a3f1f AF |
94 | --disable-libstdc++-v3 \ |
95 | --disable-libvtv \ | |
96 | --disable-libcilkrts \ | |
97 | --disable-libitm \ | |
98 | --disable-libsanitizer \ | |
82b312a9 MT |
99 | --with-newlib \ |
100 | --without-headers \ | |
101 | --without-ppl \ | |
102 | --without-cloog \ | |
764a3f1f | 103 | --enable-languages=c,c++ |
66c36198 PM |
104 | EXTRA_MAKE = |
105 | EXTRA_INSTALL = | |
cd1a2927 | 106 | else |
764a3f1f | 107 | ifeq "$(PASS)" "2" |
cd1a2927 | 108 | TARGET = $(DIR_INFO)/$(THISAPP)-tools2 |
82b312a9 | 109 | EXTRA_ENV = \ |
6f8f4522 | 110 | CC="$(CROSSTARGET)-gcc" \ |
764a3f1f | 111 | CXX="$(CROSSTARGET)-g++" \ |
82b312a9 MT |
112 | AR="$(CROSSTARGET)-ar" \ |
113 | RANLIB="$(CROSSTARGET)-ranlib" | |
114 | EXTRA_CONFIG = \ | |
c16a83df MT |
115 | --build=$(BUILDTARGET) \ |
116 | --host=$(BUILDTARGET) \ | |
6c4cc7ea MT |
117 | --prefix=$(TOOLS_DIR) \ |
118 | --with-local-prefix=$(TOOLS_DIR) \ | |
119 | --with-native-system-header-dir=$(TOOLS_DIR)/include \ | |
39f94ee8 | 120 | --disable-bootstrap \ |
82b312a9 MT |
121 | --enable-languages=c,c++ \ |
122 | --disable-libstdcxx-pch \ | |
e111b836 | 123 | --disable-multilib \ |
b45e371f | 124 | --disable-libgomp |
66c36198 PM |
125 | EXTRA_MAKE = |
126 | EXTRA_INSTALL = | |
764a3f1f AF |
127 | else |
128 | # PASS=L # libstdc++-v3 | |
129 | TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++ | |
130 | EXTRA_ENV = \ | |
6f8f4522 | 131 | CC="$(CROSSTARGET)-gcc" \ |
764a3f1f AF |
132 | AR="$(CROSSTARGET)-ar" \ |
133 | RANLIB="$(CROSSTARGET)-ranlib" | |
134 | EXTRA_CONFIG = \ | |
135 | --host=$(CROSSTARGET) \ | |
6c4cc7ea | 136 | --prefix=$(TOOLS_DIR) \ |
764a3f1f AF |
137 | --with-sysroot=$(ROOT) \ |
138 | --disable-shared \ | |
139 | --disable-nls \ | |
140 | --disable-libstdcxx-threads \ | |
141 | --disable-libstdcxx-pch \ | |
6c4cc7ea | 142 | --with-gxx-include-dir=$(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER) |
66c36198 PM |
143 | EXTRA_MAKE = |
144 | EXTRA_INSTALL = | |
764a3f1f | 145 | endif |
cd1a2927 MT |
146 | endif |
147 | endif | |
148 | ||
0c30619a MT |
149 | ifeq "$(BUILD_ARCH)" "aarch64" |
150 | EXTRA_CONFIG += \ | |
151 | --enable-standard-branch-protection | |
152 | endif | |
153 | ||
e3a093f5 MT |
154 | ifeq "$(BUILD_ARCH)" "riscv64" |
155 | EXTRA_CONFIG += \ | |
156 | --with-arch=rv64gc \ | |
157 | --with-abi=lp64d | |
158 | endif | |
159 | ||
ed635824 | 160 | EXTRA_CONFIG += \ |
51777e5d | 161 | --disable-multilib \ |
4e6fcc73 | 162 | --with-bugurl=https://bugzilla.ipfire.org \ |
ed635824 | 163 | --disable-libunwind-exceptions \ |
8fa66ce7 | 164 | --enable-gnu-unique-object |
ed635824 | 165 | |
51f9e7ac MT |
166 | export XCFLAGS = $(CFLAGS) |
167 | export TCFLAGS = $(CFLAGS) | |
168 | ||
cd1a2927 MT |
169 | ############################################################################### |
170 | # Top-level Rules | |
171 | ############################################################################### | |
82b312a9 MT |
172 | |
173 | objects = $(DL_FILE) \ | |
11b5e5cb AF |
174 | gmp-$(GMP_VER).tar.xz \ |
175 | mpfr-$(MPFR_VER).tar.xz \ | |
8675b78a | 176 | mpc-$(MPC_VER).tar.gz |
cd1a2927 | 177 | |
41921bd9 | 178 | $(DL_FILE) = $(DL_FROM)/$(DL_FILE) |
176b1cc6 | 179 | gmp-$(GMP_VER).tar.xz = $(DL_FROM)/gmp-$(GMP_VER).tar.xz |
11b5e5cb | 180 | mpfr-$(MPFR_VER).tar.xz = $(DL_FROM)/mpfr-$(MPFR_VER).tar.xz |
8675b78a | 181 | mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz |
cd1a2927 | 182 | |
e8bdca4d | 183 | $(DL_FILE)_BLAKE2 = 0034b29d3d6cc05821f0c4253ce077805943aff7b370729dd203bda57d89c107edd657eeddc2fb1e69ea15c7b0323b961f46516c7f4af89a3ccf7fea84701be2 |
9a7e4d85 | 184 | gmp-$(GMP_VER).tar.xz_BLAKE2 = c0d85f175392a50cfa01bc6b0a312b235946ad8b4f6f84f6dabd33d7a6f2cc75c9b0e1e33057be07750bfa0145b7c4cf3b6188a5be6ca9d7271ec2276c84ebcb |
32bbae10 | 185 | mpfr-$(MPFR_VER).tar.xz_BLAKE2 = dd88ae3a6a910ad8faeb791b49c3b1085de5d0d4c49c637c124bf4d9bc79fb621d0d1d69e07d0642b9b678f6d355a5830d083dfd189e1e91d0e04c970c10bd64 |
df1a3f56 | 186 | mpc-$(MPC_VER).tar.gz_BLAKE2 = 76434e6f8830af3571836d51576bfebbc9701e9bbb5c4686f134081cd96cd90ae02f7ff42bf9e3957c7a7ba92b6b2d9cdabe18f0269271147521cd7f6a2d551c |
cd1a2927 MT |
187 | |
188 | install : $(TARGET) | |
189 | ||
190 | check : $(patsubst %,$(DIR_CHK)/%,$(objects)) | |
191 | ||
192 | download :$(patsubst %,$(DIR_DL)/%,$(objects)) | |
193 | ||
9a7e4d85 | 194 | b2 : $(subst %,%_BLAKE2,$(objects)) |
cd1a2927 MT |
195 | |
196 | ############################################################################### | |
9a7e4d85 | 197 | # Downloading, checking, b2sum |
cd1a2927 MT |
198 | ############################################################################### |
199 | ||
200 | $(patsubst %,$(DIR_CHK)/%,$(objects)) : | |
201 | @$(CHECK) | |
202 | ||
203 | $(patsubst %,$(DIR_DL)/%,$(objects)) : | |
204 | @$(LOAD) | |
205 | ||
9a7e4d85 PM |
206 | $(subst %,%_BLAKE2,$(objects)) : |
207 | @$(B2SUM) | |
cd1a2927 MT |
208 | |
209 | ############################################################################### | |
210 | # Installation Details | |
211 | ############################################################################### | |
212 | ||
213 | $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) | |
214 | @$(PREBUILD) | |
8675b78a | 215 | @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) |
a04ae8c4 AF |
216 | cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc/gcc-13.1.0-riscv_use_log2_from_cheader_without_namespace.patch |
217 | ||
dd714b8a | 218 | @mkdir $(DIR_SRC)/gcc-build |
51f9e7ac | 219 | |
991d11d7 MT |
220 | cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in |
221 | cd $(DIR_APP) && sed -i gcc/Makefile.in \ | |
222 | -e 's@\./fixinc\.sh@-c true@' \ | |
223 | -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/' | |
224 | ||
225 | ifeq "$(TOOLCHAIN)" "1" | |
82b312a9 | 226 | # Build gmp and mpfr internally in toolchain. |
11b5e5cb | 227 | cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.xz |
82b312a9 | 228 | cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp |
11b5e5cb | 229 | cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.xz |
82b312a9 | 230 | cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr |
8675b78a MT |
231 | cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz |
232 | cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc | |
82b312a9 | 233 | |
991d11d7 | 234 | ifeq "$(PASS)" "2" |
764a3f1f | 235 | cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ |
6c4cc7ea | 236 | `dirname $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h |
991d11d7 MT |
237 | endif |
238 | ||
82b312a9 | 239 | for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \ |
cfd39a32 | 240 | -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \ |
82b312a9 MT |
241 | echo "Processing $${file}..."; \ |
242 | sed -i $${file} \ | |
6c4cc7ea MT |
243 | -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \ |
244 | -e 's@/usr@$(TOOLS_DIR)@g'; \ | |
764a3f1f AF |
245 | echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \ |
246 | echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \ | |
6c4cc7ea | 247 | echo '#define STANDARD_STARTFILE_PREFIX_1 "$(TOOLS_DIR)/lib/"' >> $${file}; \ |
82b312a9 MT |
248 | echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \ |
249 | done | |
82b312a9 | 250 | endif |
dd714b8a | 251 | |
991d11d7 | 252 | ifeq "$(PASS)" "L" |
764a3f1f AF |
253 | # libstdc++ pass |
254 | cd $(DIR_SRC)/gcc-build && \ | |
255 | $(EXTRA_ENV) \ | |
256 | $(DIR_APP)/libstdc++-v3/configure \ | |
257 | $(EXTRA_CONFIG) | |
79ccd55d | 258 | cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) |
764a3f1f | 259 | cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install |
b2af45b2 AF |
260 | else |
261 | ifeq "$(PASS)" "A" | |
262 | # libatomic pass | |
263 | cd $(DIR_SRC)/gcc-build && \ | |
264 | $(EXTRA_ENV) \ | |
265 | $(DIR_APP)/libatomic/configure \ | |
266 | $(EXTRA_CONFIG) | |
267 | cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) | |
268 | cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install | |
764a3f1f | 269 | else |
82b312a9 MT |
270 | # The actual build. |
271 | cd $(DIR_SRC)/gcc-build && \ | |
272 | $(EXTRA_ENV) \ | |
273 | $(DIR_APP)/configure \ | |
274 | $(EXTRA_CONFIG) | |
3c2b8c6c | 275 | cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) $(MAKETUNING) |
f97be0a6 | 276 | cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install |
764a3f1f | 277 | endif |
b2af45b2 | 278 | endif |
82b312a9 | 279 | |
991d11d7 MT |
280 | ifeq "$(TOOLCHAIN)" "1" |
281 | ifeq "$(PASS)" "1" | |
6c4cc7ea | 282 | ln -svf libgcc.a $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/') |
991d11d7 MT |
283 | endif |
284 | ||
285 | ifeq "$(PASS)" "2" | |
6c4cc7ea | 286 | ln -svf gcc $(TOOLS_DIR)/bin/cc |
8f2ac12a | 287 | # remove gdb python files from libdir |
6c4cc7ea | 288 | rm -rf $(TOOLS_DIR)/lib/*-gdb.py |
991d11d7 MT |
289 | endif |
290 | ||
291 | ifeq "$(PASS)" "L" | |
292 | # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936 | |
6c4cc7ea | 293 | sed -e "s/^#include_next/#include/" -i $(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)/cstdlib |
991d11d7 MT |
294 | endif |
295 | ||
296 | else # NON-TOOLCHAIN | |
297 | ln -svf ../usr/bin/cpp /lib | |
298 | ln -svf gcc /usr/bin/cc | |
299 | # remove gdb python files from libdir | |
300 | rm -rf /usr/lib/*-gdb.py | |
cd1a2927 | 301 | endif |
991d11d7 | 302 | |
cd1a2927 MT |
303 | @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build |
304 | @$(POSTBUILD) |