File libgcj41.spec of Package gcc41

#
# spec file for package libgcj41 (Version 4.1.2_20070115)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild
# icecream 0

%define building_libjava 1
%define run_tests 1
#
# spec file for package gcc (Version 4.1.x)
#
# 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://www.suse.de/feedback/
#
# PREFIX_FOR_OPT is the definition for _prefix
# LIBDIR_FOR_OPT is the definition for _libdir
# Run the testsuite if there's a file named RUN_TESTS in the source
%if 0%{!?run_tests:1}
%define run_tests %(test -f %_sourcedir/RUN_TESTS && echo 1 || echo 0)
%endif
# Ada currently fails to build on a few platforms, enable it only
# on those that work
# Note that AdaCore only supports %ix86, x86_64 and ia64
%ifarch %ix86 x86_64 ia64 hppa ppc s390
%define build_ada 1
%else
# alpha ppc64 s390x
%define build_ada 0
%endif
# We don't want to build java on arm
%ifarch mips %arm
%define build_java 0
%define build_libjava 0
%else
%define build_java 1
%define build_libjava 0%{?building_libjava:1}
%endif
%define build_fortran 1
%define build_objcp 0%{!?building_libjava:1}
%if 0%{?build_for_base:1}
%define build_ada 0 
%define build_java 0
%define build_libjava 0
%define build_fortran 0
%define build_objcp 0
%define run_tests 0
%endif

Name:           libgcj41
BuildRequires:  bison flex gettext-devel glibc-devel-32bit perl texinfo zlib-devel
%if %{build_ada}
%if %{suse_version} > 1010
%define hostsuffix -4.1
BuildRequires:  gcc41-ada
%else
%define hostsuffix %{nil}
BuildRequires:  gcc-ada
%endif
%endif
%if %{build_libjava}
BuildRequires:  gtk2-devel libart_lgpl-devel unzip
%endif
%if %{build_fortran}
BuildRequires:  mpfr-devel
%endif
%ifarch ia64
BuildRequires:  libunwind-devel
%endif
%if %{run_tests}
BuildRequires:  dejagnu expect
%endif
# Define this as 1 to get gcc packages for business products
%define gcc_for_opt 0
# Disable the use of icecream for this package.  It would generate
# too much parallelism when building state2 and stage3 and the runtime libs
# Just touch RUN_TESTS in the source dir to run the testsuite.
%if %{gcc_for_opt}
%define run_tests 0
%endif
# Define version number of libgcc_s
%ifarch hppa
%define libgcc_s 4
%else
%define libgcc_s 1
%endif
%ifarch ppc
# We support building the nof libraries, but don't want this in the
# regular rpms
%define build_nof 0
%else
%define build_nof 0
%endif
%define separate_bi32 0
%define separate_bi64 0
%ifarch ppc
# Beware, this does _not_ separate libgcj, as for that one multilibing
# is inactive for the time being
%define separate_bi64 1
%endif
%ifarch x86_64 s390x
%define separate_bi32 1
%endif
# Define two macros to trigger -32bit or -64bit package variants
%define separate_biarch 0
%if %{separate_bi32}
%define separate_biarch 1
%define separate_biarch_suffix -32bit
%endif
%if %{separate_bi64}
%define separate_biarch 1
%define separate_biarch_suffix -64bit
%endif
%ifarch x86_64 ia64 s390x alpha ppc64
# 64-bit is primary build target
%define build_primary_64bit 1
%else
%define build_primary_64bit 0
%endif
%define biarch_libjava 0
# COMMON-BEGIN
%define biarch_targets x86_64 s390x powerpc64 powerpc
Url:            http://gcc.gnu.org/
License:        GPL
Version:        4.1.2_20070115
Release:        12
%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
# COMMON-END
%if 0%{?!building_libjava:1}
Requires:       binutils glibc-devel
Requires:       cpp41 = %{version}-%{release}
Requires:       libgcc >= %{version}-%{release}
Obsoletes:      gcc41-mudflap
Requires:       libmudflap >= %{version}-%{release}
%endif
# COMMON-BEGIN
Group:          System/Libraries
AutoReqProv:    on
Summary:        Java Runtime Library for gcc
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Source:         gcc-%{gcc_version}%{snapshot_date}.tar.bz2
Source1:        change_spec
Source2:        gcc41-rpmlintrc	
Patch1:         bug-reporting.patch
Patch2:         gcc-noalias-warn.diff
Patch5:         boehm-gc-strict-aliasing.patch
Patch7:         acats-timeout.patch
Patch8:         gcc41-makeinfo.patch
Patch9:         gcc41-binutils-version.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
Patch102:       ia64-bad-prologue-generation.patch
Patch103:       pr34130.patch
Patch104:       nov480052.diff
Patch105:       pr34641.patch
Patch107:       fix-ada-build.diff
Patch108:       pr20218.patch
Patch109:       pr29558.patch
Patch110:       pr29512.patch
Patch111:       nov495844.diff
Patch123:       gcc41-no-unwind-tables.diff
Patch124:       pr28460.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
Patch52:        note-gnu-stack.diff
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:        fpreserve-function-arguments4.patch
Patch74:        warn-enum.diff
Patch75:        nov277135.diff
Patch76:        nov376357.diff
Patch77:        nov394409.diff
Patch78:        nov354405.diff
Patch79:        nov494022.diff
Patch80:        nov415378.diff
Patch81:        nov465381.diff
Patch90:        parentheses-mathematical-5.diff
Patch91:        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
Patch213:       gcc-amdfam10-alignloop.diff
Patch214:       barcelona.patch
Patch215:       sse5-suse.patch01
# POWER6 support
Patch300:       gcc-4.1.0-power6.diff
Patch301:       nov341254-pic.diff
Patch302:       nov341254-altivec.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
Summary:        Java Runtime Library for gcc
Group:          System/Libraries
Provides:       libgcj = %{version}-%{release}
Obsoletes:      libgcj
# make SLE10 ppc -> SLE11 ppc64 update happy
%ifarch ppc64
Obsoletes:      libgcj-64bit
%endif
AutoReqProv:    on

%description 
This library is needed if you want to use the GNU Java compiler, gcj.
Source code for this package is in gcc.

%post 
/sbin/ldconfig

%postun 
/sbin/ldconfig

%package -n libgcj41-devel
License:        GPL
Summary:        Include Files and Libraries mandatory for Development.
Group:          Development/Libraries/Java
AutoReqProv:    on
Requires:       libstdc++41-devel = %{version}
Requires:       libgcj >= %{version}-%{release}
Requires:       gtk2-devel
Requires:       libart_lgpl-devel
Requires:       glibc-devel
Requires:       zlib-devel
%ifarch ia64
Requires:       libunwind-devel
%endif

%description -n libgcj41-devel
This package contains all necessary include files and libraries needed
to develop applications that require these.


%package -n gcc41-gij
License:        GPL
Summary:        Java Bytecode Interpreter for gcc
Group:          Development/Libraries/Java
Requires:       libgcj >= %{version}-%{release}
AutoReqProv:    on

%description -n gcc41-gij
This package contains the java bytecode interpreter gij and related tools.


%package -n libffi41
License:        GPL
Summary:        Foreign Function Interface library
Group:          Development/Languages/C and C++
AutoReqProv:    on
Provides:       g-wrap:/usr/lib/libffi.so.4

%description -n libffi41
A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language.

%post -n libffi41
/sbin/ldconfig

%postun -n libffi41
/sbin/ldconfig
# PACKAGE-END
# PACKAGE-BEGIN
# PACKAGE-BEGIN

%package -n libffi41-32bit
License:        GPL
Summary:        Foreign Function Interface library
Group:          Development/Languages/C and C++
AutoReqProv:    on
Provides:       g-wrap:/usr/lib/libffi.so.4

%description -n libffi41-32bit
This is a re-packaged binary rpm. For the package source, please look
for the source of the package without the "32bit" ending

A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language.

%post -n libffi41-32bit
/sbin/ldconfig

%postun -n libffi41-32bit
/sbin/ldconfig
# PACKAGE-END
# PACKAGE-BEGIN
# PACKAGE-BEGIN

%package -n libffi41-64bit
License:        GPL
Summary:        Foreign Function Interface library
Group:          Development/Languages/C and C++
AutoReqProv:    on
Provides:       g-wrap:/usr/lib/libffi.so.4

%description -n libffi41-64bit
This is a re-packaged binary rpm. For the package source, please look
for the source of the package without the "64bit" ending

A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language.

%post -n libffi41-64bit
/sbin/ldconfig

%postun -n libffi41-64bit
/sbin/ldconfig
# PACKAGE-END
# PACKAGE-BEGIN
# PACKAGE-BEGIN

%package -n libffi41-devel
License:        GPL
Summary:        Foreign Function Interface library development files
Group:          Development/Languages/C and C++
AutoReqProv:    on
Requires:       libffi41 >= %{version}-%{release}

%description -n libffi41-devel
A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language.
%package -n libffi41-devel-32bit
License:        GPL
Summary:        Foreign Function Interface library development files
Group:          Development/Languages/C and C++
AutoReqProv:    on
Requires:       libffi41-32bit >= %{version}-%{release}

%description -n libffi41-devel-32bit
This is a re-packaged binary rpm. For the package source, please look
for the source of the package without the "32bit" ending

A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language.
%package -n libffi41-devel-64bit
License:        GPL
Summary:        Foreign Function Interface library development files
Group:          Development/Languages/C and C++
AutoReqProv:    on
Requires:       libffi41-64bit >= %{version}-%{release}

%description -n libffi41-devel-64bit
This is a re-packaged binary rpm. For the package source, please look
for the source of the package without the "64bit" ending

A foreign function interface is the popular name for the interface that allows code written in one language to call code written in another language.

%package -n gcc41-testresults
License:        GPL
Summary:        Testsuite results
Group:          Development/Languages/C and C++

%description -n gcc41-testresults
Results from running the gcc and target library testsuites.



%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}
# COMMON-END
# Versionspecific directories
%define versmainlibdir %{libsubdir}
%define versmainlibdirbi32 %{libsubdir}/32
%define versmainlibdirbi64 %{libsubdir}/64
%ifarch ppc
%define versnoflibdir %{libsubdir}/nof
%define versmainlibdirbi32 %{libsubdir}
%define versmainlibdirbi64 %{libsubdir}/64
%endif
%ifarch ppc64
%define versnoflibdir %{libsubdir}/32/nof
%endif
# If we use versionspecific libs, they end in libsubdir
%if %{versionspecificlibs}
%define mainlibdir %{libsubdir}
%define mainlibdirbi32 %{libsubdir}/32
%define mainlibdirbi64 %{libsubdir}/64
%ifarch ppc
%define noflibdir %{libsubdir}/nof
%define mainlibdirbi32 %{libsubdir}
%define mainlibdirbi64 %{libsubdir}/64
%endif
%ifarch ppc64
%define noflibdir %{libsubdir}/32/nof
%endif
%else
%define mainlibdir %{_libdir}
%define mainlibdirbi32 %{_prefix}/lib
%define mainlibdirbi64 %{_prefix}/lib64
%define noflibdir %{_prefix}/lib/nof
%endif
# Now define a few macros that make it easy to package libs and
# related files just to the right package, without caring for the
# exact path the files are in.
#   %mainlib  package X from all dirs that belong to the main package
#   %biarchlib   package X from all dirs that belong to the -32/64bit package
# by default, nof libs go where the 32bit libs go.
%if %{build_nof}
%define mainlib() %{mainlibdir}/%1\
%{noflibdir}/%1\
%{nil}
%else
%define mainlib() %{mainlibdir}/%1\
%{nil}
%endif
%define biarchlib() %{nil}
%if %{biarch}
%if %{build_primary_64bit}
%if !%{separate_bi32}
%if %{build_nof}
%define mainlib() %{mainlibdir}/%1\
%{mainlibdirbi32}/%1\
%{noflibdir}/%1\
%{nil}
%else
%define mainlib() %{mainlibdir}/%1\
%{mainlibdirbi32}/%1\
%{nil}
%endif
%else
%if %{build_nof}
%define biarchlib() %{mainlibdirbi32}/%1\
%{noflibdir}/%1\
%{nil}
%define mainlib() %{mainlibdir}/%1\
%{nil}
%else
%define biarchlib() %{mainlibdirbi32}/%1\
%{nil}
%endif
%endif
%else
%if !%{separate_bi64}
%if %{build_nof}
%define mainlib() %{mainlibdir}/%1\
%{mainlibdirbi64}/%1\
%{noflibdir}/%1\
%{nil}
%else
%define mainlib() %{mainlibdir}/%1\
%{mainlibdirbi64}/%1\
%{nil}
%endif
%else
%define biarchlib() %{mainlibdirbi64}/%1\
%{nil}
%endif
%endif
%endif
%if %{build_nof}
%define versmainlib() %{versmainlibdir}/%1\
%{versnoflibdir}/%1\
%{nil}
%else
%define versmainlib() %{versmainlibdir}/%1\
%{nil}
%endif
%define versbiarchlib() %{nil}
%if %{biarch}
%if %{build_primary_64bit}
%if !%{separate_bi32}
%if %{build_nof}
%define versmainlib() %{versmainlibdir}/%1\
%{versmainlibdirbi32}/%1\
%{versnoflibdir}/%1\
%{nil}
%else
%define versmainlib() %{versmainlibdir}/%1\
%{versmainlibdirbi32}/%1\
%{nil}
%endif
%else
%if %{build_nof}
%define versbiarchlib() %{versmainlibdirbi32}/%1\
%{versnoflibdir}/%1\
%{nil}
%define versmainlib() %{versmainlibdir}/%1\
%{nil}
%else
%define versbiarchlib() %{versmainlibdirbi32}/%1\
%{nil}
%endif
%endif
%else
%if !%{separate_bi64}
%if %{build_nof}
%define versmainlib() %{versmainlibdir}/%1\
%{versmainlibdirbi64}/%1\
%{versnoflibdir}/%1\
%{nil}
%else
%define versmainlib() %{versmainlibdir}/%1\
%{versmainlibdirbi64}/%1\
%{nil}
%endif
%else
%define versbiarchlib() %{versmainlibdirbi64}/%1\
%{nil}
%endif
%endif
%endif
# COMMON-BEGIN

%prep
%setup -q -n gcc-%{gcc_version}%{snapshot_date}
%patch1
%patch2
%patch5
%patch7
%patch8
%patch9
%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
%patch102 -p1
%patch103
%patch104
%patch105
%patch107
%patch108
%patch109
%patch110
%patch111
%patch123
%patch124
%patch51
%patch55
%patch57
%patch54
%patch50
%patch52
%patch53
cd libstdc++-v3
%patch60
%patch64
cd ..
%patch61
%patch62 -p1
%patch63
%patch65
%patch66
%patch67
%patch68
%patch69
%patch70
%patch72
%patch73
%patch74
%patch75
%patch76
%patch77
%patch78
%patch79
%patch80
%patch81
%patch90
%patch91
%patch200
%patch201
%patch202
%patch203
%patch204
%patch205
%patch206
%patch207
%patch208
%patch209
%patch210
%patch211
%patch212
%patch213 -p1
%patch214
%patch215
%patch300
%patch301 -p1
%patch302 -p1
%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'`
languages=c,c++,objc
%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
# override for cross targets until we have build_objc
%if 0%{?gcc_target_arch:1}
languages=c,c++
%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
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=/
%if %{build_ada}
# Using the host gnatmake like
#   CC="gcc%{hostsuffix}" GNATBIND="gnatbind%{hostsuffix}"
#   GNATMAKE="gnatmake%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
mkdir -p host-tools/bin
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" GCJFLAGS="$RPM_OPT_FLAGS" \
../configure \
%if 0%{?gcc_target_arch:1} && 0%{!?gcc_icecream:1}
%else
	--enable-threads=posix \
%endif
	--prefix=%{_prefix} --with-local-prefix=/usr/local \
	--infodir=%{_infodir} --mandir=%{_mandir} \
	--libdir=%{_libdir} --libexecdir=%{_libdir} \
	--enable-languages=$languages $ENABLE_CHECKING \
	--with-gxx-include-dir=/usr/include/c++/%{gcc_version} \
	--enable-ssp --disable-libssp \
%if !%{build_libjava}
        --disable-libgcj \
%else
        --enable-java-awt=gtk --enable-gtk-cairo \
%if !%{biarch_libjava}
        --disable-libjava-multilib \
%endif
%endif
	--with-slibdir=/%{_lib} --with-system-zlib \
	--enable-shared --enable-__cxa_atexit \
	--enable-libstdcxx-allocator=new \
%if 0%{?gcc_target_arch:1}
%if 0%{?gcc_icecream:1}
	--with-as=/opt/cross/%{TARGET_ARCH}-linux/bin/as \
	--with-ld=/opt/cross/%{TARGET_ARCH}-linux/bin/ld \
	--with-sysroot=/ \
%endif
	--disable-nls --disable-shared \
	--target=%{CONFIGURE_TARGET} \
%else
	--program-suffix=%{binsuffix} \
	--enable-version-specific-runtime-libs \
%ifarch ia64
	--with-system-libunwind \
%else
	--without-system-libunwind \
%endif
%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
# Only run profiled bootstrap on archs where it works
#%ifarch %ix86 x86_64 ppc ppc64 ia64
#make profiledbootstrap BOOT_CFLAGS="$RPM_OPT_FLAGS" $PARALLEL
#%else
make bootstrap-lean BOOT_CFLAGS="$RPM_OPT_FLAGS" $PARALLEL
#%endif
#make -C gcc proto
make info
%if %{run_tests}
echo "Run testsuite"
(make -C %{GCCDIST}/libstdc++-v3 check-abi || true)
mv %{GCCDIST}/libstdc++-v3/testsuite/libstdc++.log %{GCCDIST}/libstdc++-v3/testsuite/libstdc++-abi.log
mv %{GCCDIST}/libstdc++-v3/testsuite/libstdc++.sum %{GCCDIST}/libstdc++-v3/testsuite/libstdc++-abi.sum
make -k check $PARALLEL || true
mkdir ../testresults
../contrib/test_summary > ../testresults/test_summary.txt
%endif

%install
# get Check to pick up man/info pages under /opt
%if %{gcc_for_opt}
manpath=%{_mandir}:%{_infodir}
export manpath
%endif
cd obj-%{GCCDIST}
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
export LIBRARY_PATH=$RPM_BUILD_ROOT%{libsubdir}:$RPM_BUILD_ROOT%{mainlibdirbi32}:$RPM_BUILD_ROOT%{mainlibdirbi64}
%if 0%{?building_libjava:1}
make -C %{GCCDIST}/libjava install DESTDIR=$RPM_BUILD_ROOT
make -C %{GCCDIST}/libffi install DESTDIR=$RPM_BUILD_ROOT
make -C gcc java.install-man DESTDIR=$RPM_BUILD_ROOT
%else
make install DESTDIR=$RPM_BUILD_ROOT
%endif
mkdir -p $RPM_BUILD_ROOT%{_libdir}
# Remove some useless .la files
for lib in libobjc libgfortran libgfortranbegin libmudflap libmudflapth \
    libstdc++ libsupc++; do
  rm -f $RPM_BUILD_ROOT%{versmainlibdir}/$lib.la
%if %{biarch}
%if %{build_primary_64bit}
  rm -f $RPM_BUILD_ROOT%{versmainlibdirbi32}/$lib.la
%else
  rm -f $RPM_BUILD_ROOT%{versmainlibdirbi64}/$lib.la
%endif
%endif
done
rm -f $RPM_BUILD_ROOT%{_libdir}/libffi.la
%if %{biarch}
%if %{build_primary_64bit}
  rm -f $RPM_BUILD_ROOT%{_prefix}/lib/libffi.la
%else
  rm -f $RPM_BUILD_ROOT%{_prefix}/lib64/libffi.la
%endif
%endif
%if %{biarch}
%if %{build_primary_64bit}
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
%else
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib64
%endif
%endif
# Move shared libs around
%if %{versionspecificlibs}
%else
# libjava possibly breaks, ada is broken
for libname in \
%if %{build_libjava}
  libgcj libgij libgcjawt lib-gnu-java-awt-peer-gtk \
%endif
  ; do
  mv -f $RPM_BUILD_ROOT%{versmainlibdir}/$libname.* $RPM_BUILD_ROOT%{mainlibdir}/
%if %{biarch_libjava}
%if %{build_primary_64bit}
  mv -f $RPM_BUILD_ROOT%{versmainlibdirbi32}/$libname.* $RPM_BUILD_ROOT%{mainlibdirbi32}/
%else
  mv -f $RPM_BUILD_ROOT%{versmainlibdirbi64}/$libname.* $RPM_BUILD_ROOT%{mainlibdirbi64}/
%endif
%endif
done
%endif
rm -f $RPM_BUILD_ROOT%{_prefix}/bin/c++%{binsuffix}
%if %{biarch}
%if %{build_primary_64bit}
# move around some libs that end in wrong paths
pushd .
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
mkdir -p $RPM_BUILD_ROOT%{_libdir}/32
(cd $RPM_BUILD_ROOT%{_libdir}/32; tar cf - .) | (cd $RPM_BUILD_ROOT%{_prefix}/lib ; tar xf -)
rm -rf $RPM_BUILD_ROOT%{_libdir}/32
%if 0%{?!building_libjava:1}
ln -s %{_prefix}/lib $RPM_BUILD_ROOT%{_libdir}/32
rm -rf $RPM_BUILD_ROOT/%{_lib}/32
ln -s /lib $RPM_BUILD_ROOT/%{_lib}/32
%endif
popd
%else
# 32-bit biarch systems
# move around some libs that end in wrong paths
pushd .
mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib64
mkdir -p $RPM_BUILD_ROOT%{_libdir}/64
(cd $RPM_BUILD_ROOT%{_libdir}/64; tar cf - .) | (cd $RPM_BUILD_ROOT%{_prefix}/lib64 ; tar xf -)
rm -rf $RPM_BUILD_ROOT%{_libdir}/64
%if 0%{?!building_libjava:1}
ln -s %{_prefix}/lib $RPM_BUILD_ROOT%{_libdir}/64
%endif
popd
%endif
%endif
# Remove some crap from the .la files:
for l in `find $RPM_BUILD_ROOT -name '*.la'`; do
  echo "changing $l"
  sed -e '/^dependency_libs/s| -L/usr/src/packages/BUILD/[^ ]*||g' \
      -e '/^dependency_libs/s| -L/usr/%{GCCDIST}/bin||g' \
      -e '/^dependency_libs/s|-lm \(-lm \)*|-lm |' \
      -e '/^dependency_libs/s|-L[^ ]* ||g' \
      -e '/^dependency_libs/s|%{libsubdir}/\([^.]*\)\.la |%{_libdir}/\1\.la |g' \
%if %{biarch}
%if %{build_primary_64bit}
      -e '/^libdir/s|%{_libdir}/32|%{_prefix}/lib|' \
      -e '/^libdir/s|lib64/\.\./||' \
%else
      -e '/^libdir/s|%{_libdir}/64|%{_prefix}/lib64|' \
%endif
%endif
      < $l  > $l.new
  mv $l.new $l
done
%if %{gcc_for_opt}
%ifarch x86_64
perl  -pi -e "s|^(.*elf_i386.*)|\1 %{m32:-rpath=/opt/gcc33/lib} %{\!m32:-rpath=/opt/gcc33/lib64}|;"  $RPM_BUILD_ROOT%{_prefix}/lib64/gcc/x86_64-suse-linux/3.3/specs
%endif
%endif
%if %{run_tests} 
cp `find . -name "*.sum"` ../testresults/
cp `find . -name "*.log"  \! -name "config.log" |grep -v 'acats/tests' ` ../testresults/
chmod 644 ../testresults/*
%endif
# Delete precompiled headers
find $RPM_BUILD_ROOT%{_prefix}/include/c++ \
  -type d -name "*.gch" | xargs rm -rf
# Find C++ and Java headers
find $RPM_BUILD_ROOT%{_prefix}/include/c++ \
  -regex ".*/\(org\|gcj\|gnu\|java\|javax\)" -prune \
  -o \( -type d -printf "%%%%dir " , \
        -printf "%{_prefix}/include/c++/%%P\n" \) > ../c++-headers
# Remove files that we do not need to clean up filelist
rm -f $RPM_BUILD_ROOT%{_prefix}/bin/%{GCCDIST}-*
rm -rf $RPM_BUILD_ROOT%{libsubdir}/install-tools
rm -rf $RPM_BUILD_ROOT%{libsubdir}/install-tools
rm -rf $RPM_BUILD_ROOT%{_libdir}/pkgconfig/libgcj.pc
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/root
rm -f $RPM_BUILD_ROOT%{libsubdir}/include/curses.h
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/asm-*
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/linux
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/sound
rm -f $RPM_BUILD_ROOT%{libsubdir}/include/ncurses.h
rm -f $RPM_BUILD_ROOT%{libsubdir}/include/stdio.h
rm -f $RPM_BUILD_ROOT%{libsubdir}/include/zutil.h
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/X11
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/bits
rm -f $RPM_BUILD_ROOT%{libsubdir}/include/obstack.h
rm -f $RPM_BUILD_ROOT%{libsubdir}/include/spe.h
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/bits
rm -rf $RPM_BUILD_ROOT%{libsubdir}/include/sys
rm -f  $RPM_BUILD_ROOT%{_infodir}/dir
rm -f $RPM_BUILD_ROOT%{_prefix}/bin/gccbug%{binsuffix}
%if %{build_libjava}
# gcj -static doesn't work properly anyway, unless using --whole-archive
# let's save the space instead.
find $RPM_BUILD_ROOT -name libgcj.a -o -name lib-gnu-java-awt-peer-gtk.a \
                     -o -name libgjsmalsa.a \
                     -o -name libgij.a -o -name libgcjawt.a | xargs rm -f
find $RPM_BUILD_ROOT -name libgcj.spec | xargs \
  sed -i -e 's/lib: /&%%{static:%%eJava programs cannot be linked statically}/'
mv $RPM_BUILD_ROOT%{libsubdir}/include/libffi/ffitarget.h $RPM_BUILD_ROOT%{_prefix}/include/
rm -r $RPM_BUILD_ROOT%{libsubdir}/include/libffi
%endif
%if %{build_java}
%if !%{build_libjava}
rm $RPM_BUILD_ROOT%{_mandir}/man1/gcj-dbtool%{binsuffix}.1
rm $RPM_BUILD_ROOT%{_mandir}/man1/gij%{binsuffix}.1
rm $RPM_BUILD_ROOT%{_mandir}/man1/grmic%{binsuffix}.1
rm $RPM_BUILD_ROOT%{_mandir}/man1/grmiregistry%{binsuffix}.1
%endif
# fastjar is separate now
rm -f $RPM_BUILD_ROOT%{_prefix}/bin/fastjar%{binsuffix}
rm -f $RPM_BUILD_ROOT%{_prefix}/bin/grepjar%{binsuffix}
rm -f $RPM_BUILD_ROOT%{_infodir}/fastjar.info*
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/fastjar%{binsuffix}.1
rm -f $RPM_BUILD_ROOT%{_mandir}/man1/grepjar%{binsuffix}.1
%endif
rm -f $RPM_BUILD_ROOT%{_mandir}/man7/fsf-funding.7
rm -f $RPM_BUILD_ROOT%{_mandir}/man7/gfdl.7
rm -f $RPM_BUILD_ROOT%{_mandir}/man7/gpl.7
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
%if %{build_nof}
rm -f $RPM_BUILD_ROOT%{_prefix}/lib/nof/libiberty.a
%endif
%if %{biarch}
%if %{build_primary_64bit}
rm -f $RPM_BUILD_ROOT%{_prefix}/lib/libiberty.a
%else
rm -f $RPM_BUILD_ROOT%{_prefix}/lib64/libiberty.a
%endif
%endif
# Move mudflap header
%if 0%{!?building_libjava:1}
mv $RPM_BUILD_ROOT/usr/include/mf-runtime.h $RPM_BUILD_ROOT%{libsubdir}/include/
rm $RPM_BUILD_ROOT%{_mandir}/man1/jv-convert%{binsuffix}.1
%endif
# For building libjava only we need to delete other manpages
%if 0%{?building_libjava:1}
rm $RPM_BUILD_ROOT%{_prefix}/bin/addr2name.awk%{binsuffix}
rm $RPM_BUILD_ROOT%{_mandir}/man1/gcj%{binsuffix}.1
rm $RPM_BUILD_ROOT%{_mandir}/man1/gcjh%{binsuffix}.1
rm $RPM_BUILD_ROOT%{_mandir}/man1/gjnih%{binsuffix}.1
rm $RPM_BUILD_ROOT%{_mandir}/man1/jcf-dump%{binsuffix}.1
rm $RPM_BUILD_ROOT%{_mandir}/man1/jv-scan%{binsuffix}.1
%endif
# Delete some files...
%if %{versionspecificlibs}
%if %{build_libjava}
rm $RPM_BUILD_ROOT%{_libdir}/logging.properties
rm $RPM_BUILD_ROOT%{_libdir}/security/classpath.security
rm $RPM_BUILD_ROOT%{_libdir}/security/libgcj.security
%endif
rm $RPM_BUILD_ROOT%{_infodir}/*.info*
rm $RPM_BUILD_ROOT%{_prefix}/share/locale/*/LC_MESSAGES/*.mo
%endif
%if %{build_java}
%if %{build_libjava}

%files 
%defattr(-,root,root)
%dir %{_libdir}/gcj-%{gcc_version}
%{_prefix}/share/java/libgcj-%{gcc_version}.jar
%{_libdir}/gcj-%{gcc_version}/classmap.db
%if !%{versionspecificlibs}
%dir %{_libdir}/security
%{_libdir}/security/classpath.security
%{_libdir}/security/libgcj.security
%endif
# We usually do not multilib libjava
%if %{biarch_libjava}
%mainlib libgcj.so.*

%mainlib libgij.so.*

%mainlib libgcjawt.so.*

%mainlib lib-gnu-java-awt-peer-gtk.so.*

# these libs may get dlopened by their .la/.so name
%mainlib libgcjawt.la

%mainlib libgcjawt.so

%mainlib lib-gnu-java-awt-peer-gtk.la

%mainlib lib-gnu-java-awt-peer-gtk.so

%else
%{mainlibdir}/libgcj.so.*
%{mainlibdir}/libgij.so.*
%{mainlibdir}/libgcjawt.so.*
%{mainlibdir}/lib-gnu-java-awt-peer-gtk.so.*
# these libs may get dlopened by their .la/.so name
%{mainlibdir}/libgcjawt.la
%{mainlibdir}/libgcjawt.so
%{mainlibdir}/lib-gnu-java-awt-peer-gtk.la
%{mainlibdir}/lib-gnu-java-awt-peer-gtk.so
%endif
%if !%{versionspecificlibs}
%{_libdir}/logging.properties
%endif

%files -n libgcj41-devel
%defattr(-,root,root)
%dir %{_prefix}/include/c++
%dir %{libsubdir}
%dir %{libsubdir}/include
%dir %{gxxinclude}
%{libsubdir}/include/jawt.h
%{libsubdir}/include/jawt_md.h
%{libsubdir}/include/jni.h
%{libsubdir}/include/jni_md.h
%{libsubdir}/include/jvmpi.h
%{gxxinclude}/gnu
%{gxxinclude}/gcj
%{gxxinclude}/java
%{gxxinclude}/javax
%{gxxinclude}/org
%{libsubdir}/include/gcj
%if %{biarch_libjava}
%mainlib libgcj.la

%mainlib libgcj.so

%mainlib libgcj.spec

%mainlib libgij.la

%mainlib libgij.so

%else
%{mainlibdir}/libgcj.la
%{mainlibdir}/libgcj.so
%{mainlibdir}/libgcj.spec
%{mainlibdir}/libgij.la
%{mainlibdir}/libgij.so
%endif

%files -n gcc41-gij
%defattr(-,root,root)
%{_prefix}/bin/grmic%{binsuffix}
%{_prefix}/bin/grmiregistry%{binsuffix}
%{_prefix}/bin/jv-convert%{binsuffix}
%{_prefix}/bin/gcj-dbtool%{binsuffix}
%{_prefix}/bin/gij%{binsuffix}
%doc %{_mandir}/man1/gij%{binsuffix}.1.gz
%doc %{_mandir}/man1/gcj-dbtool%{binsuffix}.1.gz
%doc %{_mandir}/man1/grmic%{binsuffix}.1.gz
%doc %{_mandir}/man1/grmiregistry%{binsuffix}.1.gz
%doc %{_mandir}/man1/jv-convert%{binsuffix}.1.gz

%files -n libffi41
%defattr(-,root,root)
%mainlib libffi.so.*

%if %{separate_biarch}

%files -n libffi41%{separate_biarch_suffix}
%defattr(-,root,root)
%biarchlib libffi.so.*

%endif

%files -n libffi41-devel
%defattr(-,root,root)
%{_prefix}/include/ffi.h
%{_prefix}/include/ffitarget.h
%mainlib libffi.so

%mainlib libffi.a

%if %{separate_biarch}

%files -n libffi41-devel%{separate_biarch_suffix}
%defattr(-,root,root)
%biarchlib libffi.so

%biarchlib libffi.a

%endif
%endif
%endif
%if %{run_tests}

%files -n gcc41-testresults
%defattr(-,root,root)
%doc testresults/test_summary.txt
%doc testresults/*.sum
%doc testresults/*.log
%endif

%changelog
openSUSE Build Service is sponsored by