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) \
67 --with-local-prefix=/tools \
68 --with-native-system-header-dir=/tools/include \
71 --disable-decimal-float \
74 --disable-libmudflap \
77 --disable-libquadmath \
78 --disable-libstdc++-v3 \
80 --disable-libcilkrts \
82 --disable-libsanitizer \
87 --enable-languages=c,c++
92 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
94 CC="$(CROSSTARGET)-gcc" \
95 CXX="$(CROSSTARGET)-g++" \
96 AR="$(CROSSTARGET)-ar" \
97 RANLIB="$(CROSSTARGET)-ranlib"
99 --host=$(BUILDTARGET) \
100 --build=$(BUILDTARGET) \
101 --target=$(BUILDTARGET) \
103 --with-local-prefix=/tools \
104 --with-native-system-header-dir=/tools/include \
105 --enable-clocale=gnu \
107 --enable-threads=posix \
108 --enable-__cxa_atexit \
109 --enable-languages=c,c++ \
110 --disable-libstdcxx-pch \
115 # PASS=L # libstdc++-v3
116 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
118 CC="$(CROSSTARGET)-gcc" \
119 AR="$(CROSSTARGET)-ar" \
120 RANLIB="$(CROSSTARGET)-ranlib"
122 --host=$(CROSSTARGET) \
124 --with-sysroot=$(ROOT) \
127 --disable-libstdcxx-threads \
128 --disable-libstdcxx-pch \
129 --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER)
136 ifeq "$(MACHINE)" "armv5tel"
139 --disable-sjlj-exceptions
142 ifeq "$(MACHINE)" "i586"
148 ifeq "$(MACHINE)" "x86_64"
154 --with-bugurl=http://bugtracker.ipfire.org \
155 --disable-libunwind-exceptions \
156 --enable-gnu-unique-object
158 export XCFLAGS = $(CFLAGS)
159 export TCFLAGS = $(CFLAGS)
161 ###############################################################################
163 ###############################################################################
165 objects = $(DL_FILE) \
166 gmp-$(GMP_VER).tar.bz2 \
167 mpfr-$(MPFR_VER).tar.bz2 \
168 mpc-$(MPC_VER).tar.gz
170 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
171 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
172 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
173 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
175 $(DL_FILE)_MD5 = 6e5ea04789678f1250c1b30c4d9ec417
176 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
177 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
178 mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
182 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
184 download :$(patsubst %,$(DIR_DL)/%,$(objects))
186 md5 : $(subst %,%_MD5,$(objects))
188 ###############################################################################
189 # Downloading, checking, md5sum
190 ###############################################################################
192 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
195 $(patsubst %,$(DIR_DL)/%,$(objects)) :
198 $(subst %,%_MD5,$(objects)) :
201 ###############################################################################
202 # Installation Details
203 ###############################################################################
205 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
207 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
208 @mkdir $(DIR_SRC)/gcc-build
211 # Build gmp and mpfr internally in toolchain.
212 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
213 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
214 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
215 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
216 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
217 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
220 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
221 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
222 echo "Processing $${file}..."; \
224 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
225 -e 's@/usr@/tools@g'; \
226 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
227 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
228 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
229 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
234 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
235 `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
236 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
237 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
238 echo "Processing $${file}..."; \
240 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
241 -e 's@/usr@/tools@g'; \
242 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
243 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
244 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
245 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
250 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
251 cd $(DIR_APP) && sed -i gcc/Makefile.in \
252 -e 's@\./fixinc\.sh@-c true@' \
253 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
257 cd $(DIR_SRC)/gcc-build && \
259 $(DIR_APP)/libstdc++-v3/configure \
261 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
262 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
264 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
265 sed -e "s/^#include_next/#include/" -i /tools/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
268 cd $(DIR_SRC)/gcc-build && \
270 $(DIR_APP)/configure \
272 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
273 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
277 ln -svf ../usr/bin/cpp /lib
278 ln -svf gcc /usr/bin/cc
279 # remove gdb python files from libdir
280 rm -rf /usr/lib/*-gdb.py
283 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
285 ln -svf gcc /tools/bin/cc
286 # remove gdb python files from libdir
287 rm -rf /tools/lib/*-gdb.py
290 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build