# Maintainer: Natanael Copa pkgname=gcc pkgver=4.5.1 _piepatchver=0.4.5 _specs_ver=0.2.0 _specs_gcc_ver=4.4.3 _uclibc_abiver=0.9.32 pkgrel=9 pkgdesc="The GNU Compiler Collection" url="http://gcc.gnu.org" license="GPL LGPL" depends="binutils libgcc libgomp libobjc" makedepends="bison flex gmp-dev mpfr-dev texinfo libmpc-dev gawk zlib-dev zip" subpackages="$pkgname-doc libstdc++:libcxx g++:gpp libgcc libgomp" if [ "$LANG_OBJC" != "off" ]; then subpackages="$subpackages libobjc" fi if [ "$LANG_JAVA" = "on" ]; then subpackages="$subpackages $pkgname-java libgcj" fi source="ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-core-$pkgver.tar.bz2 ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-g++-$pkgver.tar.bz2 ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-objc-$pkgver.tar.bz2 ftp://gcc.gnu.org/pub/gcc/releases/gcc-$pkgver/gcc-java-$pkgver.tar.bz2 http://distfiles.gentoo.org/distfiles/gcc-$pkgver-piepatches-v${_piepatchver}.tar.bz2 http://distfiles.gentoo.org/distfiles/gcc-$_specs_gcc_ver-specs-$_specs_ver.tar.bz2 ftp://sourceware.org/pub/java/ecj-latest.jar 09_all_gcc-4.5-Wtrampolines.patch 15_all_gcc-libgomp-no-werror.patch 51_all_gcc-3.4-libiberty-pic.patch gcc-spec-env.patch pt_gnu_eh_frame.patch uclibc-getipinfo.patch gcc-4.5-dynamic-linker.patch PR32219.patch boehem-gc-uclibc.patch gcc-pure64.patch " # we build out-of-tree _gccdir="$srcdir"/gcc-$pkgver _builddir="$srcdir/build" prepare() { cd "$_gccdir" # verify we have set CHOST if [ -z "$CHOST" ]; then error "CHOST not set" return 1 fi # PIE patches from gentoo # thanks to Zorry for hard work on those patches for i in "$srcdir"/piepatch/*.patch; do msg "Applying $i" patch -p0 -i $i || return 1 done # Gentoo and uclibc patches for i in $source; do case "$i" in *.patch) msg "Applying $i" patch -p1 -i "$srcdir"/$i || return 1 ;; esac done #PR33200 sed -i 's/use_fixproto=yes/:/' gcc/config.gcc || return 1 # enable hardened cflags by default # building gcc wih PIE seem to hit some strange bug. we probably run # out of some resource. so we disable PIE for gcc while enabling it # by default for everything else. local _hard_cflags="-DEFAULT_PIE_SSP -DEFAULT_RELRO -DEFAULT_BIND_NOW" sed -e "/^ALL_CFLAGS/iHARD_CFLAGS = ${_hard_cflags}" \ -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) -fno-PIE |' \ -i gcc/Makefile.in || return 1 sed -e "/stage1_cflags=/s/-fno-stack-protector/-fno-stack-protector -fno-PIE/" \ -i configure # see http://gcc.gnu.org/ml/java/2008-04/msg00027.html mv "$srcdir"/ecj-latest.jar ecj.jar echo ${pkgver} > gcc/BASE-VER } build() { local _languages= _dynamic_linker= _arch=${CHOST%%-*} cd "$_gccdir" export CFLAGS="-fno-stack-protector" [ -z "$CBUILD" ] && CBUILD="$CHOST" [ -z "$CTARGET" ] && CTARGET="$CHOST" case "$CHOST" in x86_64-*-uclibc) _dynamic_linker="--with-dynamic-linker=ld64-uClibc.so.$_uclibc_abiver" ;; *-uclibc) _dynamic_linker="--with-dynamic-linker=ld-uClibc.so.$_uclibc_abiver" ;; *) _dynamic_linker= ;; esac _languages=c,c++ # we can disable OBJC with LANG_OBJC=off if [ "$LANG_OBJC" != "off" ]; then _languages=$_languages,objc fi # and enable java with LANG_JAVA=on if [ "$LANG_JAVA" = "on" ]; then _languages="$_languages,java" fi msg "Building the following:" echo "" echo " CBUILD=$CBUILD" echo " CHOST=$CHOST" echo " CTARGET=$CTARGET" echo " languages=$_languages" echo " dynamic_linker=$_dynamic_linker" echo "" mkdir -p "$_builddir" cd "$_builddir" "$_gccdir"/configure --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --build=${CBUILD} \ --host=${CHOST} \ --target=${CTARGET} \ --disable-altivec \ --disable-checking \ --disable-fixed-point \ --disable-libssp \ --disable-libstdcxx-pch \ --disable-multilib \ --disable-nls \ --disable-werror \ --enable-__cxa_atexit \ --enable-cld \ --enable-esp \ --enable-languages=$_languages \ --enable-shared \ --enable-target-optspace \ --enable-tls \ --enable-threads \ --with-arch=$_arch \ $_dynamic_linker \ --with-dynamic-linker-prefix=/lib \ --with-system-zlib \ --without-system-libunwind make || return 1 } package() { cd "$_builddir" make -j1 DESTDIR="${pkgdir}" install || return 1 ln -s gcc "$pkgdir"/usr/bin/cc # binutils provides libiberty.a rm -f "$pkgdir"/usr/lib/libiberty.a # install the specs cd "$srcdir"/specs install -d "$pkgdir"/usr/share/gcc for i in *.specs; do install -m644 $i "$pkgdir"/usr/share/gcc/$i || return 1 done # we dont support gcj -static # and saving 35MB is not bad. find "$pkgdir" -name libgcj.a -o -name libgtkpeer.a \ -o -name libgjsmalsa.a -o -name libgcj-tools.a \ -o -name libjvm.a -o -name libgij.a -o -name libgcj_bc.a \ -o -name libjavamath.a \ | xargs rm -f \ || return 1 [ "$LANG_JAVA" = "on" ] && \ sed -i -e 's/lib: /&%{static:%eJava programs cannot be linked statically}/' \ "$pkdir"/usr/lib/libgcj.spec # remove ffi rm "$pkgdir"/usr/lib/libffi* find "$pkgdir" -name 'ffi*.h' | xargs rm -f } libcxx() { pkgdesc="GNU C++ standard runtime library" depends= mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libstdc++.so.* "$subpkgdir"/usr/lib/ } gpp() { pkgdesc="GNU C++ standard library and compiler" depends="libstdc++" local libexec=usr/libexec/gcc/${CHOST:-$_chost}/$pkgver mkdir -p "$subpkgdir/$libexec" \ "$subpkgdir"/usr/bin \ "$subpkgdir"/usr/include \ "$subpkgdir"/usr/lib \ mv "$pkgdir/$libexec/cc1plus" "$subpkgdir/$libexec/" mv "$pkgdir"/usr/lib/*++* "$subpkgdir"/usr/lib/ mv "$pkgdir"/usr/include/c++ "$subpkgdir"/usr/include/ mv "$pkgdir"/usr/bin/*++ "$subpkgdir"/usr/bin/ } libobjc() { pkgdesc="GNU ObjectiveC library" replaces="objc" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/*objc* "$subpkgdir"/usr/lib/ } libgcc() { pkgdesc="GNU C compiler runtime libraries" depends= mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libgcc_s.so.* "$subpkgdir"/usr/lib/ } libgomp() { pkgdesc="GCC shared-memory parallel programming API library" depends= replaces="gcc" mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/libgomp.so.* "$subpkgdir"/usr/lib/ } java() { pkgdesc="Java support for GCC" mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib cd "$pkgdir"/usr/bin mv gcj gcj-dbtool gjavah gcjh jcf-dump "$subpkgdir"/usr/bin/ cd "$pkgdir" for i in $(find usr/ -name ecj1 -o -name jc1 -o -name jvgenmain); do mkdir -p "$subpkgdir"/${i%/*} mv "$pkgdir"/$i "$subpkgdir"/$i || return 1 done mv \ "$pkgdir"/usr/lib/libgcj*.so \ "$pkgdir"/usr/lib/libgcj*.la \ "$pkgdir"/usr/lib/libgij.so \ "$pkgdir"/usr/lib/libgij.la \ "$pkgdir"/usr/lib/libgcj.spec \ "$subpkgdir"/usr/lib/ } libgcj() { pkgdesc="Java runtime library for gcc" mkdir -p "$subpkgdir"/usr/bin cd "$pkgdir"/usr/bin mv aot-compile gappletviewer gc-analyze gij gjar gjarsigner gkeytool\ gnative2ascii gorbd grmic grmid grmiregistry gserialver \ gtnameserv i486-alpine-linux-uclibc-gcj jv-convert \ rebuild-gcj-db \ "$subpkgdir"/usr/bin/ cd "$pkgdir" for i in $(find usr/lib -name jc1 -o -name jvgenmain); do mkdir -p "$subpkgdir"/${i%/*} mv "$pkgdir"/$i "$subpkgdir"/$i || return 1 done mkdir -p "$subpkgdir"/usr/lib mv "$pkgdir"/usr/lib/gcj-* \ "$pkgdir"/usr/lib/libgcj*.so.* \ "$pkgdir"/usr/lib/libgij.so.* \ "$pkgdir"/usr/lib/logging.properties \ "$pkgdir"/usr/lib/security \ "$subpkgdir"/usr/lib/ mkdir -p "$subpkgdir"/usr/share/ mv "$pkgdir"/usr/share/java "$subpkgdir"/usr/share/ } md5sums="dc8959e31b01a65ce10d269614815054 gcc-core-4.5.1.tar.bz2 b294953ff0bb2f20c7acb2bf005d832a gcc-g++-4.5.1.tar.bz2 3c11b7037896e967eddf8178af2ddd98 gcc-objc-4.5.1.tar.bz2 0f8692921c918ae6491857e5b00acc53 gcc-java-4.5.1.tar.bz2 1f86fe5dc7d506b7fc04fcd8b7d2693c gcc-4.5.1-piepatches-v0.4.5.tar.bz2 441c76504e1d97170117c294e65c7a72 gcc-4.4.3-specs-0.2.0.tar.bz2 d7cd6a27c8801e66cbaa964a039ecfdb ecj-latest.jar ab090760506eb70aa4436a349c6bd788 09_all_gcc-4.5-Wtrampolines.patch 1c00bd9d12891a3e2311b32b98deb6fa 15_all_gcc-libgomp-no-werror.patch 45951dd3bbc979c9e043c7203745cf31 51_all_gcc-3.4-libiberty-pic.patch c4045bfa85d8be780affd465be9d8ca8 gcc-spec-env.patch 2db1e3482c5dd59dab70f701afa2ca80 pt_gnu_eh_frame.patch 6cc2385c5bbd6d0da6eaedd53c8bf547 uclibc-getipinfo.patch 7f35da0f88f4d9c3d3839498bbda0eb3 gcc-4.5-dynamic-linker.patch 6c866c7fb8d56deb8f6d652bee64e228 PR32219.patch 2c6cb49bb9bfd8b6e690222e66ccc901 boehem-gc-uclibc.patch d1d3ad2b0c185b5548125a1b81bee154 gcc-pure64.patch"