1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2018 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)
38 CFLAGS := $(patsubst -march=%,,$(CFLAGS))
39 CFLAGS := $(patsubst -mfpu=%,,$(CFLAGS))
40 CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
41 CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
42 CFLAGS := $(filter-out -fexceptions,$(CFLAGS))
45 CFLAGS := $(patsubst -mindirect-branch=%,,$(CFLAGS))
46 CFLAGS := $(patsubst -mfunction-return=%,,$(CFLAGS))
51 ifeq "$(BUILD_ARCH)" "armv7hl"
55 ifeq "$(BUILD_ARCH)" "armv5tel"
59 # Normal build or $(TOOLS_DIR) build.
62 TARGET = $(DIR_INFO)/$(THISAPP)
65 --libexecdir=/usr/lib \
67 --enable-threads=posix \
68 --enable-__cxa_atexit \
69 --enable-clocale=gnu \
70 --enable-languages=c,c++ \
77 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
79 --target=$(CROSSTARGET) \
80 --prefix=$(TOOLS_DIR) \
81 --with-sysroot=$(ROOT) \
82 --with-local-prefix=$(TOOLS_DIR) \
83 --with-native-system-header-dir=$(TOOLS_DIR)/include \
86 --disable-decimal-float \
89 --disable-libmudflap \
93 --disable-libquadmath \
94 --disable-libstdc++-v3 \
96 --disable-libcilkrts \
98 --disable-libsanitizer \
103 --enable-languages=c,c++
108 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
110 CC="$(CROSSTARGET)-gcc" \
111 CXX="$(CROSSTARGET)-g++" \
112 AR="$(CROSSTARGET)-ar" \
113 RANLIB="$(CROSSTARGET)-ranlib"
115 --build=$(BUILDTARGET) \
116 --prefix=$(TOOLS_DIR) \
117 --with-local-prefix=$(TOOLS_DIR) \
118 --with-native-system-header-dir=$(TOOLS_DIR)/include \
119 --enable-languages=c,c++ \
120 --disable-libstdcxx-pch \
125 ifeq "$(FULL_BOOTSTRAP)" "1"
126 EXTRA_CONFIG += --enable-bootstrap
128 EXTRA_CONFIG += --disable-bootstrap
131 # PASS=L # libstdc++-v3
132 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
134 CC="$(CROSSTARGET)-gcc" \
135 AR="$(CROSSTARGET)-ar" \
136 RANLIB="$(CROSSTARGET)-ranlib"
138 --host=$(CROSSTARGET) \
139 --prefix=$(TOOLS_DIR) \
140 --with-sysroot=$(ROOT) \
143 --disable-libstdcxx-threads \
144 --disable-libstdcxx-pch \
145 --with-gxx-include-dir=$(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)
152 ifeq "$(BUILD_ARCH)" "aarch64"
154 --enable-standard-branch-protection
157 ifeq "$(BUILD_ARCH)" "armv7hl"
162 ifeq "$(BUILD_ARCH)" "armv5tel"
165 --disable-sjlj-exceptions
168 ifeq "$(BUILD_ARCH)" "i586"
176 --with-bugurl=http://bugtracker.ipfire.org \
177 --disable-libunwind-exceptions \
178 --enable-gnu-unique-object
180 export XCFLAGS = $(CFLAGS)
181 export TCFLAGS = $(CFLAGS)
183 ###############################################################################
185 ###############################################################################
187 objects = $(DL_FILE) \
188 gmp-$(GMP_VER).tar.xz \
189 mpfr-$(MPFR_VER).tar.xz \
190 mpc-$(MPC_VER).tar.gz
192 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
193 gmp-$(GMP_VER).tar.xz = $(DL_FROM)/gmp-$(GMP_VER).tar.xz
194 mpfr-$(MPFR_VER).tar.xz = $(DL_FROM)/mpfr-$(MPFR_VER).tar.xz
195 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
197 $(DL_FILE)_MD5 = e9fd9b1789155ad09bcf3ae747596b50
198 gmp-$(GMP_VER).tar.xz_MD5 = a325e3f09e6d91e62101e59f9bda3ec1
199 mpfr-$(MPFR_VER).tar.xz_MD5 = bdd3d5efba9c17da8d83a35ec552baef
200 mpc-$(MPC_VER).tar.gz_MD5 = 4125404e41e482ec68282a2e687f6c73
204 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
206 download :$(patsubst %,$(DIR_DL)/%,$(objects))
208 md5 : $(subst %,%_MD5,$(objects))
210 ###############################################################################
211 # Downloading, checking, md5sum
212 ###############################################################################
214 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
217 $(patsubst %,$(DIR_DL)/%,$(objects)) :
220 $(subst %,%_MD5,$(objects)) :
223 ###############################################################################
224 # Installation Details
225 ###############################################################################
227 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
229 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
230 @mkdir $(DIR_SRC)/gcc-build
232 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
233 cd $(DIR_APP) && sed -i gcc/Makefile.in \
234 -e 's@\./fixinc\.sh@-c true@' \
235 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
237 ifeq "$(TOOLCHAIN)" "1"
238 # Build gmp and mpfr internally in toolchain.
239 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.xz
240 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
241 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.xz
242 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
243 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
244 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
247 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
248 `dirname $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
251 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
252 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
253 echo "Processing $${file}..."; \
255 -e 's@/lib\(64\)\?\(32\)\?/ld@$(TOOLS_DIR)&@g' \
256 -e 's@/usr@$(TOOLS_DIR)@g'; \
257 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
258 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
259 echo '#define STANDARD_STARTFILE_PREFIX_1 "$(TOOLS_DIR)/lib/"' >> $${file}; \
260 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
266 cd $(DIR_SRC)/gcc-build && \
268 $(DIR_APP)/libstdc++-v3/configure \
270 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
271 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
275 cd $(DIR_SRC)/gcc-build && \
277 $(DIR_APP)/configure \
279 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
280 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
283 ifeq "$(TOOLCHAIN)" "1"
285 ln -svf libgcc.a $$($(TOOLS_DIR)/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
289 ln -svf gcc $(TOOLS_DIR)/bin/cc
290 # remove gdb python files from libdir
291 rm -rf $(TOOLS_DIR)/lib/*-gdb.py
295 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
296 sed -e "s/^#include_next/#include/" -i $(TOOLS_DIR)/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
300 ln -svf ../usr/bin/cpp /lib
301 ln -svf gcc /usr/bin/cc
302 # remove gdb python files from libdir
303 rm -rf /usr/lib/*-gdb.py
306 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build