File cross-sh4-gcc.spec of Package cross-sh4-gcc

#
# spec file for package gcc41 (Version 4.1.3_20070413)
#
# Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild

%define HOST %(echo %{_target_cpu}|sed -e "s/parisc/hppa/" -e "s/i.86/i586/" -e "s/ppc/powerpc/")-suse-linux
%define TARGET %(echo %{name}|sed -e "s/cross-\\(.*\\)-gcc/\\1/;s/-/_/g;s/parisc/hppa/;s/i.86/i586/;s/ppc/powerpc/")

%define gcc_target_arch %{TARGET}-linux
%define _prefix /opt/cross

Name:           cross-sh4-gcc
BuildRequires:  cross-sh4-binutils cross-sh4-kernel-headers cross-sh4-glibc-bootstrap
BuildRequires:  gcc-c++ libstdc++-devel
BuildRequires:  bison flex gettext-devel glibc-devel texinfo zlib-devel
BuildRequires:  dejagnu expect
Requires:       cross-sh4-binutils
%define build_ada 0
%define build_java 0
%define build_libjava 0
%define build_fortran 0
%define build_objcp 1
%define build_objc 1
%define build_nof 0
%define gcc_for_opt 0
# COMMON-BEGIN
%define biarch_targets x86_64 s390x powerpc64 powerpc
URL:            http://gcc.gnu.org/
License:        GNU General Public License (GPL)
Version:        4.1.3_20070430
Release:        1
%define gcc_version %(echo %version | sed 's/_.*//')
%define snapshot_date %(echo %version | sed 's/[34]\.[0-4]\.[0-6]//' | sed 's/_/-/')
%define binsuffix -4.1
%if %{gcc_for_opt}
%define versionspecificlibs 1
%else
%define versionspecificlibs 0
%endif
Autoprov:       no
Provides:       cross-sh4-gcc
Group:          Development/Languages/C and C++
Autoreqprov:    off
Summary:        The GNU C Compiler and Support Files
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source:         gcc-%{gcc_version}%{snapshot_date}.tar.bz2
Source1:        change_spec
Patch1:         bug-reporting.patch
Patch2:         gcc-noalias-warn.diff
Patch5:         boehm-gc-strict-aliasing.patch
Patch7:         acats-timeout.patch
Patch10:        program-transform-name.diff
Patch12:        gcc4-ppc64-m32-m64-multilib-only.patch
Patch23:        libjava-no-multilib.diff
Patch24:        tls-no-direct.diff
Patch37:        pr20425.patch
Patch38:        large-gcc.diff
Patch43:        generic-cpu-model-1.patch
Patch44:        generic-cpu-model-2.patch
Patch45:        generic-cpu-model-3.patch
Patch47:        partial-flag-regstall.patch
Patch39:        tree_expr_nonzero.patch
Patch40:        vrp.patch
Patch46:        force_fit_type.patch
Patch48:        pr24879.patch
Patch82:        pr13212.patch
Patch93:        nvl161673.patch
Patch95:        pr26399.patch
Patch96:        nov189571.diff
Patch97:        nov189571-2.diff
Patch98:        nvl199137.patch
Patch100:       pr28755.patch
Patch101:       pr30113.patch
Patch105:       pr29166.diff
Patch106:       fix-ada-build.diff
Patch107:       pr20218.patch
Patch108:       pr29558.patch
Patch110:       pr29512.patch
# A set of patches from the RH srpm
Patch51:        gcc41-ia64-stack-protector.patch
Patch55:        gcc41-java-slow_pthread_self.patch
Patch57:        gcc41-ppc32-retaddr.patch
Patch54:        gcc41-ldbl-default.patch
Patch50:        gcc41-ldbl-default-libstdc++.patch
Patch53:        gcc41-strncat-chk.patch
# general improvement patches
Patch60:        pr25626.patch
Patch61:        fortran-matmul.patch
Patch62:        gcc41-fortran-where-opt.patch
Patch63:        emmintr.patch
Patch64:        libstdcxx-bitset.patch
Patch65:        stack-protect-kernel.patch
Patch66:        pr26208.patch
Patch67:        dwarf3-constants.patch
Patch68:        dwarf3-unwind.patch
Patch69:        gcc41-ssse3.patch
Patch70:        pr27880.diff
Patch72:        Wprofile-mismatch.patch
Patch73:        parentheses-mathematical-5.diff
Patch74:        Wuninitialized.patch
# Greyhound (aka AMD Family 10h) support
Patch200:       gcc-amdfam10-suse-1.patch
Patch201:       gcc-amdfam10-suse-2.patch
Patch202:       gcc-amdfam10-suse-3.patch
Patch203:       gcc-amdfam10-suse-4.patch
Patch204:       gcc-amdfam10-suse-5.patch
Patch205:       gcc-amdfam10-suse-6.patch
Patch206:       gcc-amdfam10-suse-7.patch
Patch207:       gcc-amdfam10-suse-8.patch
Patch208:       gcc-amdfam10-suse-9.patch
Patch209:       gcc-amdfam10-suse-10.patch
Patch210:       gcc-amdfam10-suse-11.patch
Patch211:       gcc-amdfam10-suse-12.patch
Patch212:       gcc-amdfam10-suse-20.patch
# POWER6 support
Patch300:       gcc-4.1.0-power6.diff
%if "%{gcc_target_arch}" == "avr"
# Joerg Wunsch places his cross-avr-gcc-patches there:
# http://www.freebsd.org/cgi/cvsweb.cgi/ports/devel/avr-gcc/files
# grab what has not yet made it into upstream
Patch1000:      cross-avr-patch-0b-constants.patch
Patch1001:      cross-avr-patch-attribute_alias.patch
Patch1002:      cross-avr-patch-bug25672.patch
Patch1003:      cross-avr-patch-dwarf.patch
Patch1004:      cross-avr-patch-newdevices.patch
Patch1005:      cross-avr-patch-zz-atmega256x.patch
%endif
# LIBJAVA-DELETE-BEGIN

%description
The system GNU C Compiler for cross targets on linux with glibc

Authors:
--------
    The GCC team.

%if 0%{?gcc_target_arch:1}
%define CONFIGURE_TARGET %{gcc_target_arch}
%define TARGET_ARCH %(echo %{gcc_target_arch} | cut -d - -f 1 | sed -e "s/i.86/i586/;s/ppc/powerpc/")
%if 0%{?gcc_icecream:1} && %{TARGET_ARCH} == "powerpc"
%define CONFIGURE_TARGET powerpc64-linux
%endif
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/")
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/")
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_version}
%prep
%setup -q -n gcc-%{gcc_version}%{snapshot_date}
%patch1
%patch2
%patch5
%patch7
%patch10
%if !%{build_nof}
%patch12
%endif
%patch23
%patch24
%patch37
%patch38
%patch43
%patch44
%patch45
%patch47
%patch39
%patch40
%patch46
%patch48
%patch82
%patch93
%patch95
%patch96
%patch97
%patch98 -p1
%patch100
%patch101
%patch105
%patch106
%patch107
%patch108
%patch110
%patch51
%patch55
%patch57
%patch54
%patch50
%patch53
cd libstdc++-v3
%patch60
%patch64
cd ..
%patch61
%patch62 -p1
%patch63
%patch65
%patch66
%patch67
%patch68
%patch69
%patch70
%patch72
%patch73
%patch74
%patch200
%patch201
%patch202
%patch203
%patch204
%patch205
%patch206
%patch207
%patch208
%patch209
%patch210
%patch211
%patch212
%patch300
%if "%{gcc_target_arch}" == "avr"
%patch1000
%patch1001
%patch1002
%patch1003
%patch1004
%patch1005
%endif

%build
# Avoid conflict with commercial libjawt.so
sed -i -e 's/libjawt/libgcjawt/g' libjava/Makefile.{am,in}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector//g' -e 's/-ffortify=.//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler.  -mcpu gives a warning that stops
# the build process, so remove it for now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/  / /g'`

# Select which basis languages to activate
languages=c,c++
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_java}
languages=$languages,java
%endif
%if %{build_ada}
languages=$languages,ada
%endif
J=%{?jobs:%jobs}
if test -z "$J"; then
  J=$(getconf _NPROCESSORS_CONF)
  JL=$(($J * 2))
else
  test 1 -gt "$J" && J=1
  JL=$(($(getconf _NPROCESSORS_CONF)*2))
fi
if test "$J" == "0"; then
  J=1
fi
if test "$JL" == "0"; then
  JL=1
fi
PARALLEL="-j$J -l$JL"
# we don't want some miscompiles in the testsuite, or some fault in
# the compiler to kill the machine.  Hence we limit the amount of memory
# by the physical RAM plus half of swap
#MEM=$(free -m | awk '/^Mem:/ {print $2}')
#SWAP=$(free -m | awk '/^Swap:/ {print $2}')
#ulimit -v $(((MEM + SWAP/2)*1024))
# In general we want to ship release checking enabled compilers
# and run BETA with checking enabled.
ENABLE_CHECKING="--enable-checking=release"
%if "%{name}" != "gcc41"
export PATH=/opt/cross/bin:$PATH
%endif
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
# configure tries to parse include/features.h to detect
# if glibc supports SSP.  When cross compiling we would need
# to install a cross glibc, which we don't, or make the whole
# thing point to the native glibc, which is in /, hence the
# --with-sysroot=/
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \
%if %{build_ada}
CC="gcc%{binsuffix}" GNATBIND="gnatbind%{binsuffix}" \
%endif
../configure \
        --prefix=%{_prefix} \
        --build=%{_target_cpu}-suse-linux \
        --host=%{_target_cpu}-suse-linux \
        --target=%{gcc_target_arch} \
        --enable-languages=$languages \
        --enable-threads=posix \
        --infodir=%{_infodir} --mandir=%{_mandir} \
        --libdir=%{_libdir} --libexecdir=%{_libdir} \
        --with-sysroot=%{_prefix}/%{gcc_target_arch}/sys-root \
        --with-build-sysroot=%{_prefix}/%{gcc_target_arch}/sys-root \
        --with-gxx-include-dir=%{_prefix}/%{gcc_target_arch}/sys-root/usr/include/c++ \
        --without-system-libunwind --enable-ssp --disable-libssp --disable-libmudflap \
        --disable-checking --without-newlib --enable-fp --disable-nls \
        --enable-shared --disable-multilib --enable-__cxa_atexit \
        --enable-version-specific-runtime-libs \
        --enable-libstdcxx-allocator=new \
%if !%{build_libjava}
        --disable-libgcj \
%else
        --enable-java-awt=gtk --enable-gtk-cairo \
%if !%{biarch_libjava}
        --disable-libjava-multilib \
%endif
%endif
%ifarch ia64
	--with-system-libunwind \
%else
	--without-system-libunwind \
%endif
%if "%{TARGET_ARCH}" == "powerpc"
	--with-cpu=default32 \
	--enable-secureplt \
	--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64"
	--enable-secureplt \
	--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
	--with-cpu=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
	--with-cpu=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
        --with-tune=z9-109 --with-arch=z900 \
	--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "s390x"
        --with-tune=z9-109 --with-arch=z900 \
	--with-long-double-128 \
%endif
	--host=%{GCCDIST}
# COMMON-END
make %{?jobs:-j%jobs} 

%install
cd obj-%{GCCDIST}
make install DESTDIR=$RPM_BUILD_ROOT
rm -rf $RPM_BUILD_ROOT/%{_prefix}/share
rm $RPM_BUILD_ROOT/%{_libdir}/libiberty.a
rmdir $RPM_BUILD_ROOT/%{_prefix}/include

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%{_prefix}

%changelog
* Tue May  8 2007 - martin.mohring@5etech.eu
- upstream merge with gcc41 updates
* Thu Apr  5 2007 - martin.mohring@5etech.eu
- upstream merge with gcc41 updates
- added flex bison required by post openSUSE 10.2 releases
* Fri Feb 23 2007 - martin.mohring@5etech.eu
- copied specfile from openSUSE:Factory
- modified for <cross>-linux
- fix cross build problems with sysroot stuff
openSUSE Build Service is sponsored by