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 # Normal build or /tools build.
40 TARGET = $(DIR_INFO)/$(THISAPP)
41 EXTRA_CONFIG = --prefix=/usr \
42 --libexecdir=/usr/lib \
44 --enable-threads=posix \
45 --enable-__cxa_atexit \
46 --enable-clocale=gnu \
47 --enable-languages=c,c++ \
53 TARGET = $(DIR_INFO)/$(THISAPP)-tools1
55 --target=$(CROSSTARGET) \
59 --disable-decimal-float \
61 --disable-libmudflap \
64 --disable-libquadmath \
73 TARGET = $(DIR_INFO)/$(THISAPP)-tools2
75 CC="$(CROSSTARGET)-gcc -B/tools/lib/" \
76 AR="$(CROSSTARGET)-ar" \
77 RANLIB="$(CROSSTARGET)-ranlib"
79 --host=$(BUILDTARGET) \
80 --build=$(BUILDTARGET) \
81 --target=$(BUILDTARGET) \
83 --with-local-prefix=/tools \
84 --enable-clocale=gnu \
86 --enable-threads=posix \
87 --enable-__cxa_atexit \
88 --enable-languages=c,c++ \
89 --disable-libstdcxx-pch \
96 ifeq "$(MACHINE_TYPE)" "arm"
101 export XCFLAGS = $(CFLAGS)
102 export TCFLAGS = $(CFLAGS)
104 ###############################################################################
106 ###############################################################################
108 objects = $(DL_FILE) \
109 gmp-$(GMP_VER).tar.bz2 \
110 mpfr-$(MPFR_VER).tar.bz2
112 $(DL_FILE) = $(DL_FROM)/$(DL_FILE)
113 gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2
114 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2
116 $(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281
117 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe
118 mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0
122 check : $(patsubst %,$(DIR_CHK)/%,$(objects))
124 download :$(patsubst %,$(DIR_DL)/%,$(objects))
126 md5 : $(subst %,%_MD5,$(objects))
128 ###############################################################################
129 # Downloading, checking, md5sum
130 ###############################################################################
132 $(patsubst %,$(DIR_CHK)/%,$(objects)) :
135 $(patsubst %,$(DIR_DL)/%,$(objects)) :
138 $(subst %,%_MD5,$(objects)) :
141 ###############################################################################
142 # Installation Details
143 ###############################################################################
145 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
147 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE)
148 @mkdir $(DIR_SRC)/gcc-build
151 # Build gmp and mpfr internally in toolchain.
152 cd $(DIR_APP) && tar xfa $(DIR_DL)/gmp-$(GMP_VER).tar.bz2
153 cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp
154 cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2
155 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr
158 # GCC does not detect stack protection correctly, which causes problems
159 # for the build of libresolv_pic.a.
160 cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
164 cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch
166 cd $(DIR_APP) && sed -i gcc/Makefile.in \
167 -e 's@\./fixinc\.sh@-c true@' \
168 -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
170 for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \
171 -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \
172 echo "Processing $${file}..."; \
174 -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
175 -e 's@/usr@/tools@g'; \
176 echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \
177 echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \
178 echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \
179 echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \
185 cd $(DIR_SRC)/gcc-build && \
187 $(DIR_APP)/configure \
189 cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE)
190 cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install
194 ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/')
196 ln -svf gcc /tools/bin/cc
199 @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build