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