1 ###############################################################################
3 # IPFire.org - A linux based firewall #
4 # Copyright (C) 2007, 2008, 2009 Michael Tremer & Christian Schmidt #
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 ###############################################################################
25 include $(PKGROOT)/Include
31 PKG_MAINTAINER = Michael Tremer <michael.tremer@ipfire.org>
32 PKG_GROUPS = Development/Compilers
33 PKG_URL = http://gcc.gnu.org/
34 PKG_LICENSE = GPLv3+ and GPLv2+ with exceptions
35 PKG_SUMMARY = Various compilers (C, C++, Objective-C, Java, ...).
37 define PKG_DESCRIPTION
38 The gcc package contains the GNU Compiler Collection. \
39 You'll need this package in order to compile C code.
42 BINUTILS_VER = 2.21.51.0.8-1
44 PKG_BUILD_DEPS+= autogen binutils>=$(BINUTILS_VER) cloog-devel dejagnu \
45 elfutils-devel expect flex gmp-devel libffi-devel mpc-devel mpfr-devel \
46 ppl-devel=0.10.2-0.ip3 texinfo zlib-devel
47 PKG_DEPS-gcc += binutils>=$(BINUTILS_VER) libgcc-devel cloog>=0.15
49 # Make the GCC target platform
50 GCC_TARGET_PLATFORM = $(subst -gnu,,$(DISTRO_MACHINE))
52 ifeq "$(DISTRO_ARCH)" "x86_64"
53 CONFIGURE_ARGS = --disable-multilib
56 ifeq "$(DISTRO_ARCH)" "i686"
57 CONFIGURE_ARGS = --with-arch=$(DISTRO_ARCH) --with-tune=generic
61 # Remove -m32 and -m64
62 CFLAGS := $(subst -m32,,$(CFLAGS))
63 CFLAGS := $(subst -m64,,$(CFLAGS))
65 CFLAGS := $(subst -march=i686,,$(CFLAGS))
67 HARD_CFLAGS = -DEFAULT_PIE_SSP -DEFAULT_RELRO -DEFAULT_BIND_NOW
70 export CXXFLAGS = $(subst -Wall,,$(CFLAGS))
72 PKG_TARBALL += $(THISAPP).tar.gz
76 gcc46-c++-builtin-redecl.patch0 \
77 gcc46-pr33763.patch0 \
78 gcc46-libgomp-omp_h-multilib.patch0 \
79 gcc46-libtool-no-rpath.patch0 \
80 gcc46-cloog-dl.patch0 \
81 gcc46-pr38757.patch0 \
82 gcc46-no-add-needed.patch0 \
83 gcc46-unwind-debughook-sdt.patch0 \
84 gcc46-ppl-0.10.patch \
85 gcc46-Woverlength-string.patch0 \
86 gcc46-Woverlength-string-asm.patch0 \
87 gcc-4.6.0-piepatches-20110407.patch
90 PKG_PACKAGES += $(PKG_NAME)-c++
91 PKG_DEPS-$(PKG_NAME)-c++ = gcc libstdc++-devel
92 define PKG_FILES-$(PKG_NAME)-c++
94 /usr/lib/gcc/*/*/cc1plus
95 /usr/share/man/man*/*++*
99 PKG_PACKAGES += libgcc
100 define PKG_FILES-libgcc
104 PKG_PACKAGES += libgcc-devel
105 define PKG_FILES-libgcc-devel
110 PKG_PACKAGES += libstdc++
111 define PKG_FILES-libstdc++
112 /usr/lib/libstdc++*.so.*
115 PKG_PACKAGES += libstdc++-devel
116 define PKG_FILES-libstdc++-devel
118 /usr/lib/libstdc++*.so
122 PKG_PACKAGES += libgomp
123 define PKG_FILES-libgomp
124 /usr/lib/libgomp*.so.*
127 PKG_PACKAGES += libgomp-devel
128 define PKG_FILES-libgomp-devel
130 /usr/lib/libgomp.spec
134 PKG_PACKAGES += libmudflap
135 define PKG_FILES-libmudflap
136 /usr/lib/libmudflap*.so.*
139 PKG_PACKAGES += libmudflap-devel
140 define PKG_FILES-libmudflap-devel
141 /usr/lib/libmudflap*.so
145 PKG_PACKAGES += libquadmath
146 define PKG_FILES-libquadmath
147 /usr/lib/libquadmath*.so.*
150 PKG_PACKAGES += libquadmath-devel
151 define PKG_FILES-libquadmath-devel
152 /usr/lib/libquadmath*.so
155 define STAGE_PREPARE_CMDS
156 -mkdir -v $(DIR_SRC)/gcc-build
158 # Remove unneeded features that will save some compile time
159 rm -rf $(DIR_APP)/lib{gfortran,java,objc} \
160 $(DIR_APP)/gcc/{fortran,java,objc,objcp}
162 # Apply a sed substitution that will suppress the installation of
163 # libiberty.a. The version of libiberty.a provided by Binutils will be used
165 cd $(DIR_APP) && sed -i 's/install_to_$$(INSTALL_DEST) //' libiberty/Makefile.in
168 echo "$(DISTRO_NAME) $(PKG_VER)-$(PKG_RELEASE)" > $(DIR_APP)/gcc/DEV-PHASE
170 # Libgomp uses -Werror regardless of --disable-werror, and this will cause a
171 # build failure when -D_FORTIFY_SOURCE=2 causes build time warnings:
172 cd $(DIR_APP) && sed -e "s/-Werror//" -i libgomp/configure
174 # The fixincludes script is known to occasionally erroneously attempt to
175 # "fix" the system headers installed so far. As the headers up to this point
176 # are known to not require fixing, issue the following command to prevent
177 # the fixincludes script from running:
178 cd $(DIR_APP) && sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in
180 cd $(DIR_APP) && sed -i gcc/Makefile.in \
181 -e "s/-fno-exceptions/& -fno-asynchronous-unwind-tables/"
183 # we want to be able to control the pie patch logic via something other
185 cd $(DIR_APP) && sed -i gcc/Makefile.in \
186 -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
187 -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $$(HARD_CFLAGS) |'
189 # Enable the GCC hardening by default.
190 cd $(DIR_APP) && sed -i gcc/Makefile.in \
191 -e "s|^HARD_CFLAGS = |HARD_CFLAGS = $(HARD_CFLAGS) |"
193 # Compile the compile with -fPIC as well.
194 cd $(DIR_APP) && sed -i gcc/Makefile.in \
195 -e "s|^ESP_NOPIE_CFLAGS = .*|ESP_NOPIE_CFLAGS =|"
199 cd $(DIR_SRC)/gcc-build && \
201 CXXFLAGS="$(CXXFLAGS)" \
202 XCFLAGS="$(CFLAGS)" \
203 TCFLAGS="$(CFLAGS)" \
204 ../$(THISAPP)/configure \
205 --build=$(GCC_TARGET_PLATFORM) \
207 --libexecdir=/usr/lib \
208 --mandir=/usr/share/man \
211 --enable-threads=posix \
212 --enable-__cxa_atexit \
213 --enable-clocale=gnu \
214 --enable-languages=c,c++,lto \
216 --enable-checking=release \
221 --with-bugurl=http://bugtracker.ipfire.org \
224 --disable-libunwind-exceptions \
225 --enable-gnu-unique-object \
226 --enable-linker-build-id \
229 cd $(DIR_SRC)/gcc-build && make profiledbootstrap #$(PARALLELISMFLAGS)
233 # cd $(DIR_SRC)/gcc-build && make check
234 # cd $(DIR_APP) && ./contrib/test_summary
238 cd $(DIR_SRC)/gcc-build && make install DESTDIR=$(BUILDROOT)
240 -mkdir -pv $(BUILDROOT)/lib
241 ln -sfv ../usr/bin/cpp $(BUILDROOT)/lib/cpp
242 ln -sfv gcc $(BUILDROOT)/usr/bin/cc
244 # Move libgcc_s to /lib
245 mv -vf $(BUILDROOT)/usr/lib/libgcc_s.so.1 $(BUILDROOT)/lib/
246 ln -svf ../../lib/libgcc_s.so.1 $(BUILDROOT)/usr/lib/libgcc_s.so
248 # Remove some GNU debugger stuff.
249 rm -vf $(BUILDROOT)/usr/lib/lib*.py