1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
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. #
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. #
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/>. #
19 ###############################################################################
21 ###############################################################################
23 ###############################################################################
34 DL_FILE = $(THISAPP).tar.xz
35 DL_FROM = $(URL_IPFIRE)
36 DIR_APP = $(DIR_SRC)/$(THISAPP)
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))
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))
53 # Normal build or $(TOOLS_DIR) build.
56 TARGET = $(DIR_INFO)/$(THISAPP)
59 --libexecdir=/usr/lib \
61 --enable-threads=posix \
62 --enable-__cxa_atexit \
63 --enable-clocale=gnu \
64 --enable-languages=c,c++ \
71 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
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 --with-glibc-version=2.11 \
82 --disable-decimal-float \
85 --disable-libmudflap \
89 --disable-libquadmath \
90 --disable-libstdc++-v3 \
92 --disable-libcilkrts \
94 --disable-libsanitizer \
99 --enable-languages=c,c++
104 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
106 CC="$(CROSSTARGET)-gcc" \
107 CXX="$(CROSSTARGET)-g++" \
108 AR="$(CROSSTARGET)-ar" \
109 RANLIB="$(CROSSTARGET)-ranlib"
111 --build=$(BUILDTARGET) \
112 --host=$(BUILDTARGET) \
113 --prefix=$(TOOLS_DIR) \
114 --with-local-prefix=$(TOOLS_DIR) \
115 --with-native-system-header-dir=$(TOOLS_DIR)/include \
116 --disable-bootstrap \
117 --enable-languages=c,c++ \
118 --disable-libstdcxx-pch \
124 # PASS=L # libstdc++-v3
125 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
127 CC="$(CROSSTARGET)-gcc" \
128 AR="$(CROSSTARGET)-ar" \
129 RANLIB="$(CROSSTARGET)-ranlib"
131 --host=$(CROSSTARGET) \
132 --prefix=$(TOOLS_DIR) \
133 --with-sysroot=$(ROOT) \
136 --disable-libstdcxx-threads \
137 --disable-libstdcxx-pch \
138 --with-gxx-include-dir=$(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)
145 ifeq "$(BUILD_ARCH)" "aarch64"
147 --enable-standard-branch-protection
150 ifeq "$(BUILD_ARCH)" "riscv64"
158 --with-bugurl=https://bugzilla.ipfire.org \
159 --disable-libunwind-exceptions \
160 --enable-gnu-unique-object
162 export XCFLAGS = $(CFLAGS)
163 export TCFLAGS = $(CFLAGS)
165 ###############################################################################
167 ###############################################################################
169 objects = $(DL_FILE) \
170 gmp-$(GMP_VER).tar.xz \
171 mpfr-$(MPFR_VER).tar.xz \
172 mpc-$(MPC_VER).tar.gz
174 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
175 gmp-$(GMP_VER).tar.xz = $(DL_FROM)/gmp-$(GMP_VER).tar.xz
176 mpfr-$(MPFR_VER).tar.xz = $(DL_FROM)/mpfr-$(MPFR_VER).tar.xz
177 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
179 $(DL_FILE)_BLAKE2 = 7e562d25446ca4ab9fe8cdb714866f66aba3744d78bf84f31bfb097c1a981e4c7f990cb1e6bcfec5ae6671836a4984e2b70eb8fed81dcef5e244f88da8623469
180 gmp-$(GMP_VER).tar.xz_BLAKE2 = c0d85f175392a50cfa01bc6b0a312b235946ad8b4f6f84f6dabd33d7a6f2cc75c9b0e1e33057be07750bfa0145b7c4cf3b6188a5be6ca9d7271ec2276c84ebcb
181 mpfr-$(MPFR_VER).tar.xz_BLAKE2 = 41d1be0c4b557760f12a4525ad3a84b6e2cd6f0927c935fcfba577ac0490e582d1ae4b581dce58e21e705cf9d7c88373054d7fb7a94bb32c69b339f99a25dc68
182 mpc-$(MPC_VER).tar.gz_BLAKE2 = 9cd03c6a71839e4cdb3c1f18d718cc4d3097c3f8ec307a5c756bd5df27c68aa013755156b3b156efee1acabfee2269602c6a3a358092ef0d522271c9c56c133d
186 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
188 download :$(patsubst %,$(DIR_DL)/%,$(objects))
190 b2 : $(subst %,%_BLAKE2,$(objects))
192 ###############################################################################
193 # Downloading, checking, b2sum
194 ###############################################################################
196 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
199 $(patsubst %,$(DIR_DL)/%,$(objects)) :
202 $(subst %,%_BLAKE2,$(objects)) :
205 ###############################################################################
206 # Installation Details
207 ###############################################################################
209 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
211 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
212 @mkdir $(DIR_SRC)/gcc-build
214 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc/gcc-11.3.0-glibc-2.36-headers-fix.patch
216 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
217 cd $(DIR_APP) && sed -i gcc/Makefile.in \
218 -e 's@\./fixinc\.sh@-c true@' \
219 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
221 ifeq "$(TOOLCHAIN)" "1"
222 # Build gmp and mpfr internally in toolchain.
223 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.xz
224 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
225 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.xz
226 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
227 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
228 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
231 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
232 `dirname $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
235 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
236 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
237 echo "Processing $${file}..."; \
239 -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \
240 -e 's@/usr@$(TOOLS_DIR)@g'; \
241 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
242 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
243 echo '#define STANDARD_STARTFILE_PREFIX_1 "$(TOOLS_DIR)/lib/"' >> $${file}; \
244 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
250 cd $(DIR_SRC)/gcc-build && \
252 $(DIR_APP)/libstdc++-v3/configure \
254 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
255 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
259 cd $(DIR_SRC)/gcc-build && \
261 $(DIR_APP)/configure \
263 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) $(MAKETUNING)
264 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
267 ifeq "$(TOOLCHAIN)" "1"
269 ln -svf libgcc.a $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
273 ln -svf gcc $(TOOLS_DIR)/bin/cc
274 # remove gdb python files from libdir
275 rm -rf $(TOOLS_DIR)/lib/*-gdb.py
279 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
280 sed -e "s/^#include_next/#include/" -i $(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
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
290 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build