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 ifeq "$(BUILD_ARCH)" "armv7hl"
48 ifeq "$(BUILD_ARCH)" "armv5tel"
52 # Normal build or /tools build.
55 TARGET = $(DIR_INFO)/$(THISAPP)
58 --libexecdir=/usr/lib \
60 --enable-threads=posix \
61 --enable-__cxa_atexit \
62 --enable-clocale=gnu \
63 --enable-languages=c,c++ \
70 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
72 --target=$(CROSSTARGET) \
74 --with-sysroot=$(ROOT) \
75 --with-local-prefix=/tools \
76 --with-native-system-header-dir=/tools/include \
79 --disable-decimal-float \
82 --disable-libmudflap \
86 --disable-libquadmath \
87 --disable-libstdc++-v3 \
89 --disable-libcilkrts \
91 --disable-libsanitizer \
96 --enable-languages=c,c++
101 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
103 CC="$(CROSSTARGET)-gcc" \
104 CXX="$(CROSSTARGET)-g++" \
105 AR="$(CROSSTARGET)-ar" \
106 RANLIB="$(CROSSTARGET)-ranlib"
108 --build=$(BUILDTARGET) \
110 --with-local-prefix=/tools \
111 --with-native-system-header-dir=/tools/include \
112 --enable-languages=c,c++ \
113 --disable-libstdcxx-pch \
118 ifeq "$(FULL_BOOTSTRAP)" "1"
119 EXTRA_CONFIG += --enable-bootstrap
121 EXTRA_CONFIG += --disable-bootstrap
124 # PASS=L # libstdc++-v3
125 TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++
127 CC="$(CROSSTARGET)-gcc" \
128 AR="$(CROSSTARGET)-ar" \
129 RANLIB="$(CROSSTARGET)-ranlib"
131 --host=$(CROSSTARGET) \
133 --with-sysroot=$(ROOT) \
136 --disable-libstdcxx-threads \
137 --disable-libstdcxx-pch \
138 --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER)
145 ifeq "$(BUILD_ARCH)" "armv7hl"
150 ifeq "$(BUILD_ARCH)" "armv5tel"
153 --disable-sjlj-exceptions
156 ifeq "$(BUILD_ARCH)" "i586"
164 --with-bugurl=http://bugtracker.ipfire.org \
165 --disable-libunwind-exceptions \
166 --enable-gnu-unique-object
168 export XCFLAGS = $(CFLAGS)
169 export TCFLAGS = $(CFLAGS)
171 ###############################################################################
173 ###############################################################################
175 objects = $(DL_FILE) \
176 gmp-$(GMP_VER).tar.bz2 \
177 mpfr-$(MPFR_VER).tar.bz2 \
178 mpc-$(MPC_VER).tar.gz
180 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
181 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
182 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
183 mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
185 $(DL_FILE)_MD5 = 6e5ea04789678f1250c1b30c4d9ec417
186 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
187 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
188 mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
192 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
194 download :$(patsubst %,$(DIR_DL)/%,$(objects))
196 md5 : $(subst %,%_MD5,$(objects))
198 ###############################################################################
199 # Downloading, checking, md5sum
200 ###############################################################################
202 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
205 $(patsubst %,$(DIR_DL)/%,$(objects)) :
208 $(subst %,%_MD5,$(objects)) :
211 ###############################################################################
212 # Installation Details
213 ###############################################################################
215 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
217 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
218 @mkdir $(DIR_SRC)/gcc-build
220 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
221 cd $(DIR_APP) && sed -i gcc/Makefile.in \
222 -e 's@\./fixinc\.sh@-c true@' \
223 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
225 ifeq "$(TOOLCHAIN)" "1"
226 # Build gmp and mpfr internally in toolchain.
227 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
228 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
229 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
230 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
231 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz
232 cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
235 cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
236 `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h
239 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
240 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h -o -name aarch64-linux.h); do \
241 echo "Processing $${file}..."; \
243 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
244 -e 's@/usr@/tools@g'; \
245 echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \
246 echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \
247 echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \
248 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
254 cd $(DIR_SRC)/gcc-build && \
256 $(DIR_APP)/libstdc++-v3/configure \
258 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
259 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
263 cd $(DIR_SRC)/gcc-build && \
265 $(DIR_APP)/configure \
267 cd $(DIR_SRC)/gcc-build && make $(EXTRA_MAKE)
268 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
271 ifeq "$(TOOLCHAIN)" "1"
273 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
277 ln -svf gcc /tools/bin/cc
278 # remove gdb python files from libdir
279 rm -rf /tools/lib/*-gdb.py
283 # Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70936
284 sed -e "s/^#include_next/#include/" -i /tools/$(CROSSTARGET)/include/c++/$(VER)/cstdlib
288 ln -svf ../usr/bin/cpp /lib
289 ln -svf gcc /usr/bin/cc
290 # remove gdb python files from libdir
291 rm -rf /usr/lib/*-gdb.py
294 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build