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 -mbranch-protection=%,,$(CFLAGS))
47 CFLAGS := $(patsubst -mfunction-return=%,,$(CFLAGS))
48 CFLAGS := $(patsubst -fstack-clash-protection,,$(CFLAGS))
49 CFLAGS := $(patsubst -fcf-protection,,$(CFLAGS))
54 # Normal build or $(TOOLS_DIR) build.
57 TARGET = $(DIR_INFO)/$(THISAPP)
60 --libexecdir=/usr/lib \
62 --enable-threads=posix \
63 --enable-__cxa_atexit \
64 --enable-clocale=gnu \
65 --enable-languages=c,c++ \
71 TARGET = $(DIR_INFO)/$(THISAPP)-libatomic
72 ROOTFILE_APPEND = "-libatomic"
76 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
78 --target=$(CROSSTARGET) \
79 --prefix=$(TOOLS_DIR) \
80 --with-sysroot=$(ROOT) \
81 --with-local-prefix=$(TOOLS_DIR) \
82 --with-native-system-header-dir=$(TOOLS_DIR)/include \
83 --with-glibc-version=2.11 \
87 --disable-decimal-float \
90 --disable-libmudflap \
94 --disable-libquadmath \
95 --disable-libstdc++-v3 \
97 --disable-libcilkrts \
99 --disable-libsanitizer \
104 --enable-languages=c,c++
109 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
111 CC="$(CROSSTARGET)-gcc" \
112 CXX="$(CROSSTARGET)-g++" \
113 AR="$(CROSSTARGET)-ar" \
114 RANLIB="$(CROSSTARGET)-ranlib"
116 --build=$(BUILDTARGET) \
117 --host=$(BUILDTARGET) \
118 --prefix=$(TOOLS_DIR) \
119 --with-local-prefix=$(TOOLS_DIR) \
120 --with-native-system-header-dir=$(TOOLS_DIR)/include \
121 --disable-bootstrap \
122 --enable-languages=c,c++ \
123 --disable-libstdcxx-pch \
129 # PASS=L # libstdc++-v3
130 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
132 CC="$(CROSSTARGET)-gcc" \
133 AR="$(CROSSTARGET)-ar" \
134 RANLIB="$(CROSSTARGET)-ranlib"
136 --host=$(CROSSTARGET) \
137 --prefix=$(TOOLS_DIR) \
138 --with-sysroot=$(ROOT) \
141 --disable-libstdcxx-threads \
142 --disable-libstdcxx-pch \
143 --with-gxx-include-dir=$(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)
150 ifeq "$(BUILD_ARCH)" "aarch64"
152 --enable-standard-branch-protection
155 ifeq "$(BUILD_ARCH)" "riscv64"
163 --with-bugurl=https://bugzilla.ipfire.org \
164 --disable-libunwind-exceptions \
165 --enable-gnu-unique-object
167 export XCFLAGS = $(CFLAGS)
168 export TCFLAGS = $(CFLAGS)
170 ###############################################################################
172 ###############################################################################
174 objects = $(DL_FILE) \
175 gmp-$(GMP_VER).tar.xz \
176 mpfr-$(MPFR_VER).tar.xz \
177 mpc-$(MPC_VER).tar.gz
179 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
180 gmp-$(GMP_VER).tar.xz = $(DL_FROM)/gmp-$(GMP_VER).tar.xz
181 mpfr-$(MPFR_VER).tar.xz = $(DL_FROM)/mpfr-$(MPFR_VER).tar.xz
182 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
184 $(DL_FILE)_BLAKE2 = a902ce99db4e93615879e435bcd0b96d5a16ea0af42598ca0e6d12913b2ce3651a98574c3264b2717b848e6b5a823b403ccca0adde463938d5b41aa3f1da0d34
185 gmp-$(GMP_VER).tar.xz_BLAKE2 = a865129e2b3f634ec5bad7f97ed89532e43f5662ac47a7d8ab7f0df8c9f8d0886bd984651422e2573c2163bca69c0547c248147ec90880accbd53db97dc0ddee
186 mpfr-$(MPFR_VER).tar.xz_BLAKE2 = 6bbf5658e70fbb673a3b65246a6bac708d1571aa6943c6742efd92f468ac71e6f0fe351b757f7133440ea312d9a5fc3549acd89d54f4d975c58bdc204d7b21ec
187 mpc-$(MPC_VER).tar.gz_BLAKE2 = 76434e6f8830af3571836d51576bfebbc9701e9bbb5c4686f134081cd96cd90ae02f7ff42bf9e3957c7a7ba92b6b2d9cdabe18f0269271147521cd7f6a2d551c
191 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
193 download :$(patsubst %,$(DIR_DL)/%,$(objects))
195 b2 : $(subst %,%_BLAKE2,$(objects))
197 ###############################################################################
198 # Downloading, checking, b2sum
199 ###############################################################################
201 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
204 $(patsubst %,$(DIR_DL)/%,$(objects)) :
207 $(subst %,%_BLAKE2,$(objects)) :
210 ###############################################################################
211 # Installation Details
212 ###############################################################################
214 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
216 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
217 @mkdir $(DIR_SRC)/gcc-build
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/'
224 ifeq "$(TOOLCHAIN)" "1"
225 # Build gmp and mpfr internally in toolchain.
226 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.xz
227 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
228 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.xz
229 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
230 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
231 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
233 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
234 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
235 echo "Processing $${file}..."; \
237 -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \
238 -e 's@/usr@$(TOOLS_DIR)@g'; \
239 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
240 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
241 echo '#define STANDARD_STARTFILE_PREFIX_1 "$(TOOLS_DIR)/lib/"' >> $${file}; \
242 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
248 cd $(DIR_SRC)/gcc-build && \
250 $(DIR_APP)/libstdc++-v3/configure \
252 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) $(MAKETUNING)
253 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
257 cd $(DIR_SRC)/gcc-build && \
259 $(DIR_APP)/libatomic/configure \
261 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
262 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
265 cd $(DIR_SRC)/gcc-build && \
267 $(DIR_APP)/configure \
269 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) $(MAKETUNING)
270 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
274 ifeq "$(TOOLCHAIN)" "1"
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
280 ln -svf libgcc.a $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
284 ln -svf gcc $(TOOLS_DIR)/bin/cc
285 # remove gdb python files from libdir
286 rm -rf $(TOOLS_DIR)/lib/*-gdb.py
290 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
291 sed -e "s/^#include_next/#include/" -i $(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
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
301 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build