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 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
64 --target=$(CROSSTARGET) \
66 --with-sysroot=$(ROOT) \
69 --disable-decimal-float \
72 --disable-libmudflap \
75 --disable-libquadmath \
76 --disable-libstdc++-v3 \
78 --disable-libcilkrts \
80 --disable-libsanitizer \
85 --enable-languages=c,c++
90 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
92 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
93 CXX="$(CROSSTARGET)-g++" \
94 AR="$(CROSSTARGET)-ar" \
95 RANLIB="$(CROSSTARGET)-ranlib"
97 --host=$(BUILDTARGET) \
98 --build=$(BUILDTARGET) \
99 --target=$(BUILDTARGET) \
101 --with-local-prefix=/tools \
102 --with-native-system-header-dir=/tools/include \
103 --enable-clocale=gnu \
105 --enable-threads=posix \
106 --enable-__cxa_atexit \
107 --enable-languages=c,c++ \
108 --disable-libstdcxx-pch \
113 # PASS=L # libstdc++-v3
114 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
116 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
117 AR="$(CROSSTARGET)-ar" \
118 RANLIB="$(CROSSTARGET)-ranlib"
120 --host=$(CROSSTARGET) \
122 --with-sysroot=$(ROOT) \
125 --disable-libstdcxx-threads \
126 --disable-libstdcxx-pch \
127 --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER)
133 # Disable stack protection in toolchain.
134 CFLAGS += -fno-stack-protector
137 ifeq "$(MACHINE_TYPE)" "arm"
140 --disable-sjlj-exceptions
143 ifeq "$(MACHINE)" "i586"
149 ifeq "$(MACHINE)" "x86_64"
155 --with-bugurl=http://bugtracker.ipfire.org \
156 --disable-libunwind-exceptions \
157 --enable-gnu-unique-object
159 export XCFLAGS = $(CFLAGS)
160 export TCFLAGS = $(CFLAGS)
162 ###############################################################################
164 ###############################################################################
166 objects = $(DL_FILE) \
167 gmp-$(GMP_VER).tar.bz2 \
168 mpfr-$(MPFR_VER).tar.bz2 \
169 mpc-$(MPC_VER).tar.gz
171 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
172 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
173 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
174 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
176 $(DL_FILE)_MD5 = 648bfba342bb41a4b5350fb685f85bc5
177 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
178 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
179 mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
183 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
185 download :$(patsubst %,$(DIR_DL)/%,$(objects))
187 md5 : $(subst %,%_MD5,$(objects))
189 ###############################################################################
190 # Downloading, checking, md5sum
191 ###############################################################################
193 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
196 $(patsubst %,$(DIR_DL)/%,$(objects)) :
199 $(subst %,%_MD5,$(objects)) :
202 ###############################################################################
203 # Installation Details
204 ###############################################################################
206 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
208 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
209 @mkdir $(DIR_SRC)/gcc-build
212 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-i386-libgomp.patch
213 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-libtool-no-rpath.patch
214 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-no-add-needed.patch
215 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr38757.patch
216 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr64336.patch
217 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc/gcc-fix-inlining-issues.patch
220 # Build gmp and mpfr internally in toolchain.
221 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
222 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
223 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
224 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
225 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
226 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
229 # GCC does not detect stack protection correctly, which causes problems
230 # for the build of libresolv_pic.a.
231 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
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); do \
235 echo "Processing $${file}..."; \
237 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
238 -e 's@/usr@/tools@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/lib/"' >> $${file}; \
242 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
247 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
248 `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
249 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
250 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
251 echo "Processing $${file}..."; \
253 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
254 -e 's@/usr@/tools@g'; \
255 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
256 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
257 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
258 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
263 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
264 cd $(DIR_APP) && sed -i gcc/Makefile.in \
265 -e 's@\./fixinc\.sh@-c true@' \
266 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
270 cd $(DIR_SRC)/gcc-build && \
272 $(DIR_APP)/libstdc++-v3/configure \
274 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
275 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
278 cd $(DIR_SRC)/gcc-build && \
280 $(DIR_APP)/configure \
282 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
283 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
287 ln -svf ../usr/bin/cpp /lib
288 ln -svf gcc /usr/bin/cc
289 # remove gdb python files from libdir
290 rm -rf /usr/lib/*-gdb.py
293 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
295 ln -svf gcc /tools/bin/cc
296 # remove gdb python files from libdir
297 rm -rf /tools/lib/*-gdb.py
300 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build