1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007-2011 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 ###############################################################################
33 DL_FILE = $(THISAPP).tar.bz2
34 DL_FROM = $(URL_IPFIRE)
35 DIR_APP = $(DIR_SRC)/$(THISAPP)
37 CFLAGS := $(patsubst -march=%,,$(CFLAGS))
38 CFLAGS := $(patsubst -mtune=%,,$(CFLAGS))
39 CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS))
41 # https://bugzilla.redhat.com/show_bug.cgi?id=476370
42 CFLAGS += -fgnu89-inline
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) \
68 --disable-decimal-float \
70 --disable-libmudflap \
73 --disable-libquadmath \
82 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
84 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
85 AR="$(CROSSTARGET)-ar" \
86 RANLIB="$(CROSSTARGET)-ranlib"
88 --host=$(BUILDTARGET) \
89 --build=$(BUILDTARGET) \
90 --target=$(BUILDTARGET) \
92 --with-local-prefix=/tools \
93 --enable-clocale=gnu \
95 --enable-threads=posix \
96 --enable-__cxa_atexit \
97 --enable-languages=c,c++ \
98 --disable-libstdcxx-pch \
104 # Disable stack protection in toolchain.
105 CFLAGS += -fno-stack-protector
108 ifeq "$(MACHINE_TYPE)" "arm"
111 --disable-sjlj-exceptions
114 ifeq "$(MACHINE)" "i586"
120 ifeq "$(MACHINE)" "x86_64"
126 --with-bugurl=http://bugtracker.ipfire.org \
127 --disable-libunwind-exceptions \
128 --enable-gnu-unique-object
130 export XCFLAGS = $(CFLAGS)
131 export TCFLAGS = $(CFLAGS)
133 ###############################################################################
135 ###############################################################################
137 objects = $(DL_FILE) \
138 gmp-$(GMP_VER).tar.bz2 \
139 mpfr-$(MPFR_VER).tar.bz2
141 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
142 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
143 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
145 $(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281
146 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
147 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
151 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
153 download :$(patsubst %,$(DIR_DL)/%,$(objects))
155 md5 : $(subst %,%_MD5,$(objects))
157 ###############################################################################
158 # Downloading, checking, md5sum
159 ###############################################################################
161 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
164 $(patsubst %,$(DIR_DL)/%,$(objects)) :
167 $(subst %,%_MD5,$(objects)) :
170 ###############################################################################
171 # Installation Details
172 ###############################################################################
174 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
176 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
177 @mkdir $(DIR_SRC)/gcc-build
180 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-build-id.patch
181 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-c++-builtin-redecl.patch
182 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-i386-libgomp.patch
183 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-libtool-no-rpath.patch
184 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-no-add-needed.patch
185 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-pr33763.patch
186 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh330771.patch
187 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh533181.patch
188 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh610785.patch
189 cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-unwind-debug-hook.patch
191 # texinfo 5 syntax-fixes
192 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-4.4.7-texinfo-5.patch
195 # Build gmp and mpfr internally in toolchain.
196 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
197 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
198 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
199 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
202 # GCC does not detect stack protection correctly, which causes problems
203 # for the build of libresolv_pic.a.
204 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
208 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch
210 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
211 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
212 echo "Processing $${file}..."; \
214 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
215 -e 's@/usr@/tools@g'; \
216 echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \
217 echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \
218 echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \
219 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
224 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
225 cd $(DIR_APP) && sed -i gcc/Makefile.in \
226 -e 's@\./fixinc\.sh@-c true@' \
227 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
230 cd $(DIR_SRC)/gcc-build && \
232 $(DIR_APP)/configure \
234 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
235 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
238 ln -svf ../usr/bin/cpp /lib
239 ln -svf gcc /usr/bin/cc
242 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
244 ln -svf gcc /tools/bin/cc
247 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build