1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2021 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 ifeq "$(BUILD_ARCH)" "armv7hl"
57 ifeq "$(BUILD_ARCH)" "armv6l"
61 # Normal build or $(TOOLS_DIR) build.
64 TARGET = $(DIR_INFO)/$(THISAPP)
67 --libexecdir=/usr/lib \
69 --enable-threads=posix \
70 --enable-__cxa_atexit \
71 --enable-clocale=gnu \
72 --enable-languages=c,c++ \
79 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
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 \
88 --disable-decimal-float \
91 --disable-libmudflap \
95 --disable-libquadmath \
96 --disable-libstdc++-v3 \
98 --disable-libcilkrts \
100 --disable-libsanitizer \
105 --enable-languages=c,c++
110 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
112 CC="$(CROSSTARGET)-gcc" \
113 CXX="$(CROSSTARGET)-g++" \
114 AR="$(CROSSTARGET)-ar" \
115 RANLIB="$(CROSSTARGET)-ranlib"
117 --build=$(BUILDTARGET) \
118 --prefix=$(TOOLS_DIR) \
119 --with-sysroot=$(ROOT) \
120 --with-local-prefix=$(TOOLS_DIR) \
121 --with-native-system-header-dir=$(TOOLS_DIR)/include \
122 --enable-languages=c,c++ \
123 --disable-libstdcxx-pch \
128 ifeq "$(FULL_BOOTSTRAP)" "1"
129 EXTRA_CONFIG += --enable-bootstrap
131 EXTRA_CONFIG += --disable-bootstrap
134 # PASS=L # libstdc++-v3
135 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
137 CC="$(CROSSTARGET)-gcc" \
138 AR="$(CROSSTARGET)-ar" \
139 RANLIB="$(CROSSTARGET)-ranlib"
141 --host=$(CROSSTARGET) \
142 --prefix=$(TOOLS_DIR) \
143 --with-sysroot=$(ROOT) \
146 --disable-libstdcxx-threads \
147 --disable-libstdcxx-pch \
148 --with-gxx-include-dir=$(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)
155 ifeq "$(BUILD_ARCH)" "aarch64"
157 --enable-standard-branch-protection
160 ifeq "$(BUILD_ARCH)" "armv7hl"
165 ifeq "$(BUILD_ARCH)" "armv6l"
167 --with-arch=armv6zk+fp \
169 # --disable-sjlj-exceptions
172 ifeq "$(BUILD_ARCH)" "riscv64"
180 --with-bugurl=http://bugtracker.ipfire.org \
181 --disable-libunwind-exceptions \
182 --enable-gnu-unique-object
184 export XCFLAGS = $(CFLAGS)
185 export TCFLAGS = $(CFLAGS)
187 ###############################################################################
189 ###############################################################################
191 objects = $(DL_FILE) \
192 gmp-$(GMP_VER).tar.xz \
193 mpfr-$(MPFR_VER).tar.xz \
194 mpc-$(MPC_VER).tar.gz
196 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
197 gmp-$(GMP_VER).tar.xz = $(DL_FROM)/gmp-$(GMP_VER).tar.xz
198 mpfr-$(MPFR_VER).tar.xz = $(DL_FROM)/mpfr-$(MPFR_VER).tar.xz
199 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
201 $(DL_FILE)_MD5 = 77f6252be0861ab918042acf42bc10ff
202 gmp-$(GMP_VER).tar.xz_MD5 = 0b82665c4a92fd2ade7440c13fcaa42b
203 mpfr-$(MPFR_VER).tar.xz_MD5 = bdd3d5efba9c17da8d83a35ec552baef
204 mpc-$(MPC_VER).tar.gz_MD5 = 9f16c976c25bb0f76b50be749cd7a3a8
208 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
210 download :$(patsubst %,$(DIR_DL)/%,$(objects))
212 md5 : $(subst %,%_MD5,$(objects))
214 ###############################################################################
215 # Downloading, checking, md5sum
216 ###############################################################################
218 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
221 $(patsubst %,$(DIR_DL)/%,$(objects)) :
224 $(subst %,%_MD5,$(objects)) :
227 ###############################################################################
228 # Installation Details
229 ###############################################################################
231 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
233 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
235 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc/gcc.git-745dae5-remove_cyclades.patch
238 @mkdir $(DIR_SRC)/gcc-build
240 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
241 cd $(DIR_APP) && sed -i gcc/Makefile.in \
242 -e 's@\./fixinc\.sh@-c true@' \
243 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
245 ifeq "$(TOOLCHAIN)" "1"
246 # Build gmp and mpfr internally in toolchain.
247 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.xz
248 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
249 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.xz
250 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
251 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
252 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
255 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
256 `dirname $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
259 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
260 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
261 echo "Processing $${file}..."; \
263 -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \
264 -e 's@/usr@$(TOOLS_DIR)@g'; \
265 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
266 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
267 echo '#define STANDARD_STARTFILE_PREFIX_1 "$(TOOLS_DIR)/lib/"' >> $${file}; \
268 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
274 cd $(DIR_SRC)/gcc-build && \
276 $(DIR_APP)/libstdc++-v3/configure \
278 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
279 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
283 cd $(DIR_SRC)/gcc-build && \
285 $(DIR_APP)/configure \
287 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE) $(MAKETUNING)
288 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
291 ifeq "$(TOOLCHAIN)" "1"
293 ln -svf libgcc.a $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
297 ln -svf gcc $(TOOLS_DIR)/bin/cc
298 # remove gdb python files from libdir
299 rm -rf $(TOOLS_DIR)/lib/*-gdb.py
303 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
304 sed -e "s/^#include_next/#include/" -i $(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
308 ln -svf ../usr/bin/cpp /lib
309 ln -svf gcc /usr/bin/cc
310 # remove gdb python files from libdir
311 rm -rf /usr/lib/*-gdb.py
314 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build