1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2016 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.gz
35 DL_FROM = $(URL_IPFIRE)
36 DIR_APP = $(DIR_SRC)/$(THISAPP)
38 CFLAGS := $(patsubst -march=%,,$(CFLAGS))
39 CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
40 CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
41 CFLAGS := $(filter-out -fexceptions,$(CFLAGS))
44 # Normal build or /tools build.
47 TARGET = $(DIR_INFO)/$(THISAPP)
50 --libexecdir=/usr/lib \
52 --enable-threads=posix \
53 --enable-__cxa_atexit \
54 --enable-clocale=gnu \
55 --enable-languages=c,c++ \
62 CFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CFLAGS))
63 CXXFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CXXFLAGS))
64 CXXFLAGS += -std=gnu++98
66 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
68 --target=$(CROSSTARGET) \
70 --with-sysroot=$(ROOT) \
71 --with-local-prefix=/tools \
72 --with-native-system-header-dir=/tools/include \
75 --disable-decimal-float \
78 --disable-libmudflap \
81 --disable-libquadmath \
82 --disable-libstdc++-v3 \
84 --disable-libcilkrts \
86 --disable-libsanitizer \
91 --enable-languages=c,c++
96 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
98 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
99 CXX="$(CROSSTARGET)-g++" \
100 AR="$(CROSSTARGET)-ar" \
101 RANLIB="$(CROSSTARGET)-ranlib"
103 --host=$(BUILDTARGET) \
104 --build=$(BUILDTARGET) \
105 --target=$(BUILDTARGET) \
107 --with-local-prefix=/tools \
108 --with-native-system-header-dir=/tools/include \
109 --enable-clocale=gnu \
111 --enable-threads=posix \
112 --enable-__cxa_atexit \
113 --enable-languages=c,c++ \
114 --disable-libstdcxx-pch \
119 # PASS=L # libstdc++-v3
120 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
122 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
123 AR="$(CROSSTARGET)-ar" \
124 RANLIB="$(CROSSTARGET)-ranlib"
126 --host=$(CROSSTARGET) \
128 --with-sysroot=$(ROOT) \
131 --disable-libstdcxx-threads \
132 --disable-libstdcxx-pch \
133 --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER)
139 # Disable stack protection in toolchain.
140 CFLAGS += -fno-stack-protector
143 ifeq "$(MACHINE)" "armv5tel"
146 --disable-sjlj-exceptions
149 ifeq "$(MACHINE)" "i586"
155 ifeq "$(MACHINE)" "x86_64"
161 --with-bugurl=http://bugtracker.ipfire.org \
162 --disable-libunwind-exceptions \
163 --enable-gnu-unique-object
165 export XCFLAGS = $(CFLAGS)
166 export TCFLAGS = $(CFLAGS)
168 ###############################################################################
170 ###############################################################################
172 objects = $(DL_FILE) \
173 gmp-$(GMP_VER).tar.bz2 \
174 mpfr-$(MPFR_VER).tar.bz2 \
175 mpc-$(MPC_VER).tar.gz
177 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
178 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
179 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
180 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
182 $(DL_FILE)_MD5 = 6e5ea04789678f1250c1b30c4d9ec417
183 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
184 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
185 mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
189 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
191 download :$(patsubst %,$(DIR_DL)/%,$(objects))
193 md5 : $(subst %,%_MD5,$(objects))
195 ###############################################################################
196 # Downloading, checking, md5sum
197 ###############################################################################
199 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
202 $(patsubst %,$(DIR_DL)/%,$(objects)) :
205 $(subst %,%_MD5,$(objects)) :
208 ###############################################################################
209 # Installation Details
210 ###############################################################################
212 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
214 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
215 @mkdir $(DIR_SRC)/gcc-build
218 # Build gmp and mpfr internally in toolchain.
219 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
220 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
221 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
222 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
223 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
224 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
227 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
228 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
229 echo "Processing $${file}..."; \
231 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
232 -e 's@/usr@/tools@g'; \
233 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
234 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
235 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
236 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
241 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
242 `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
243 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
244 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
245 echo "Processing $${file}..."; \
247 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
248 -e 's@/usr@/tools@g'; \
249 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
250 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
251 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
252 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
257 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
258 cd $(DIR_APP) && sed -i gcc/Makefile.in \
259 -e 's@\./fixinc\.sh@-c true@' \
260 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
264 cd $(DIR_SRC)/gcc-build && \
266 $(DIR_APP)/libstdc++-v3/configure \
268 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
269 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
271 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
272 sed -e "s/^#include_next/#include/" -i /tools/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
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
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 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
292 ln -svf gcc /tools/bin/cc
293 # remove gdb python files from libdir
294 rm -rf /tools/lib/*-gdb.py
297 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build