Sophie

Sophie

distrib > Mandriva > 2006.0 > i586 > by-pkgid > 64890195d69497be61023af7fb8f5ff8 > files > 5

gcc-4.0.1-5mdk.src.rpm

%define name			%{cross_prefix}gcc%{package_suffix}
%define branch			4.0
%define branch_tag		%(perl -e 'printf "%%02d%%02d", split(/\\./,shift)' %{branch})
%define version			4.0.1
#define snapshot_version	%{version}
%define snapshot_version	4.0.2
%define release			5mdk
%define nof_arches		ppc
%define biarches		x86_64 ppc64
%define biarch_java		0
%ifarch x86_64
%define multilib_32_arch	i586
%endif
%ifarch ppc64
%define multilib_32_arch	ppc
%endif
%ifarch sparc64
%define multilib_32_arch	sparc
%endif

# TODO: Provide gccint info pages?
%define _unpackaged_files_terminate_build 0

# Define libraries major versions
%define libgcc_major		1
%define libstdcxx_major		6
%define libstdcxx_minor		5
%define libgfortran_major	0
%define libgcj_major		6
%define libobjc_major		1
%define libgnat_major		1
%define libffi_major		4
%define libmudflap_major	0

# Package holding Java tools (gij, jv-convert, etc.)
%define GCJ_TOOLS		%{cross_prefix}gcj%{package_suffix}-tools

#-- JDK version
# "gcj" implements the JDK 1.4 language, "libgcj" is largely compatible with JDK 1.4
%define jdk_version	1.4.2
%define jdk_base	java-%{jdk_version}-gcj
%define jdk_package	%{jdk_base}-compat
%define jdk_home	%{_prefix}/lib/jvm/%{jdk_base}-%{jdk_version}.0/jre

#-- Alternatives for Java tools
#       Sun JDK         40
#       Kaffe           30
#       Gcj 3.2         20
%define gcj_alternative_priority 20
%define gcj_alternative_programs fastjar grepjar grmic grmiregistry

# Define if building a cross compiler
# FIXME: assume user does not define both cross and cross_bootstrap variables
%define build_cross		0
%define build_cross_bootstrap	0
%{expand: %{?cross:		%%global build_cross 1}}
%{expand: %{?cross_bootstrap:	%%global build_cross_bootstrap 1}}

# System compiler in MDV 2006
%if %{mdkversion} >= 200600
%define system_compiler		1
%else
%define system_compiler		0
%endif
%define target_cpu		%{_target_cpu}
%if %{build_cross}
%define system_compiler		0
%define target_cpu		%{cross}
%endif
%if %{build_cross_bootstrap}
%define build_cross		1
%define system_compiler		0
%define target_cpu		%{cross_bootstrap}
%endif
%if %{system_compiler}
%define alternative_priority	30%{branch_tag}
%define cross_prefix		%{nil}
%define cross_program_prefix	%{nil}
%define package_suffix		%{nil}
%define program_prefix		%{nil}
%define program_suffix		%{nil}
%else
%if %{build_cross}
%define alternative_priority	10%{branch_tag}
%define cross_prefix		cross-%{target_cpu}-
%define cross_program_prefix	%{target_cpu}-linux-
%define package_suffix		%{nil}
%define program_prefix		%{cross_program_prefix}
%define program_suffix		%{nil}
%else
%define alternative_priority	20%{branch_tag}
%define cross_prefix		%{nil}
%define cross_program_prefix	%{nil}
%define package_suffix		%{branch}
%define program_prefix		%{nil}
%define program_suffix		-%{version}
%endif
%endif
%define _alternativesdir	/etc/alternatives
%if "%{package_suffix}" == "%{nil}"
%define _package_suffix		%{nil}
%else
%define _package_suffix		-%{package_suffix}
%endif

%define RELEASE			0
%if %{RELEASE}
%define source_package		gcc-%{version}
%define source_dir		gcc-%{version}
%else
%define snapshot		20050826
%define source_package		gcc-%{snapshot_version}-%{snapshot}
%define source_dir		gcc-%{snapshot_version}
%endif

# Define GCC target platform, and arch we built for
%if %{build_cross}
%define arch			%{target_cpu}
%define gcc_target_platform	%{target_cpu}-linux
%define target_prefix		%{_prefix}/%{gcc_target_platform}
%define target_libdir		%{target_prefix}/lib
%define target_slibdir		%{target_prefix}/lib
%else
%define arch			%(echo %{_target_cpu}|sed -e "s/i.86/i386/" -e "s/athlon/i386/" -e "s/amd64/x86_64/")
%define gcc_target_platform	%{_target_platform}
%define target_prefix		%{_prefix}
%define target_libdir		%{_libdir}
%define target_slibdir		/%{_lib}
%endif
%define gcc_libdir		%{_prefix}/lib/gcc
%ifarch %{biarches}
%define gcc32_target_platform	%{multilib_32_arch}-%{_real_vendor}-%{_target_os}%{?_gnu}
%endif

# Location of Java headers, don't let them in compiler specific
# directory as they are grabbed first
%define libjava_includedir	%{target_prefix}/include/libgcj-%{version}

# We now have versioned libstdcxx_includedir, that is c++/<VERSION>/
%define libstdcxx_includedir	%{target_prefix}/include/c++/%{version}

%define color_gcc_version	1.3.2
%define build_minimal		0
%define build_doc		1
%define build_pdf_doc		1
%define build_check		1
%define build_ada		0
%define gpc_snapshot		20040516
%define build_pascal		0
%ifarch noarch
%define build_pascal		1
%endif
%ifarch %{ix86} x86_64 ia64
%define build_ada		1
%endif
%define build_cxx		1
%define build_libstdcxx		%{build_cxx}
%define build_fortran		1
%define build_objc		1
%ifarch sparc sparcv9 sparc64
%define build_libffi		0
%define build_java		0
%else
%define build_libffi		1
%define build_java		1
%endif
%define build_colorgcc		1
%define build_debug		0
%if !%{system_compiler}
%define build_libstdcxx		0
%define build_objc		0
%define build_pascal		0
%define build_ada		0
%define build_colorgcc		0
%define build_libffi		0
%endif

# Allow --with[out] <feature> at rpm command line build
%{expand: %{?_without_PDF:	%%global build_pdf_doc 0}}
%{expand: %{?_without_DEBUG:	%%global build_debug 0}}
%{expand: %{?_without_CHECK:	%%global build_check 0}}
%{expand: %{?_without_MINIMAL:	%%global build_minimal 0}}
%{expand: %{?_with_PDF:		%%global build_pdf_doc 1}}
%{expand: %{?_with_DEBUG:	%%global build_debug 1}}
%{expand: %{?_with_CHECK:	%%global build_check 1}}
%{expand: %{?_with_MINIMAL:	%%global build_minimal 1}}

# Allow --without <front-end> at rpm command line build
%{expand: %{?_with_CXX:		%%global build_cxx 1}}
%{expand: %{?_with_ADA:		%%global build_ada 1}}
%{expand: %{?_with_FORTRAN:	%%global build_fortran 1}}
%{expand: %{?_with_JAVA:	%%global build_java 1}}
%{expand: %{?_with_OBJC:	%%global build_objc 1}}
%{expand: %{?_with_PASCAL:	%%global build_pascal 1}}

# Allow --with <front-end> at rpm command line build
%{expand: %{?_without_CXX:	%%global build_cxx 0}}
%{expand: %{?_without_ADA:	%%global build_ada 0}}
%{expand: %{?_without_FORTRAN:	%%global build_fortran 0}}
%{expand: %{?_without_JAVA:	%%global build_java 0}}
%{expand: %{?_without_OBJC:	%%global build_objc 0}}
%{expand: %{?_without_PASCAL:	%%global build_pascal 0}}

# A minimal build overrides all other options
%if %{build_cross_bootstrap}
%define build_minimal		1
%endif
%if %{build_minimal}
%define build_doc		0
%define build_pdf_doc		0
%define build_check		0
%define build_ada		0
%define build_cxx		0
%define build_fortran		0
%define build_objc		0
%define build_java		0
%define build_colorgcc		0
%define build_debug		0
%endif
%if %{build_cross}
%define build_doc		0
%define build_pdf_doc		0
# Unsupported front-ends when cross-compiling for now
%define build_check		0
%define build_colorgcc		0
%define build_java		0
%define build_ada		0
%endif

# Define library packages names
%define libgcc_name_orig	%{cross_prefix}libgcc
%define libgcc_name		%{libgcc_name_orig}%{libgcc_major}
%define libstdcxx_name_orig	%{cross_prefix}libstdc++
%define libstdcxx_name		%{libstdcxx_name_orig}%{libstdcxx_major}
%define libgfortran_name_orig	%{cross_prefix}libgfortran
%define libgfortran_name	%{libgfortran_name_orig}%{libgfortran_major}
%define libgcj_name_orig	%{cross_prefix}libgcj
%define libgcj_name		%{cross_prefix}%{mklibname gcj %{libgcj_major}}
%define libgcj_name_base	%{libgcj_name_orig}%{libgcj_major}
%define libobjc_name_orig	%{cross_prefix}libobjc
%define libobjc_name		%{libobjc_name_orig}%{libobjc_major}
%define libgnat_name_orig	%{cross_prefix}libgnat
%define libgnat_name		%{libgnat_name_orig}%{libgnat_major}
%define libffi_name_orig	%{cross_prefix}libffi
%define libffi_name		%{libffi_name_orig}%{libffi_major}
%define libmudflap_name_orig	%{cross_prefix}libmudflap
%define libmudflap_name		%{libmudflap_name_orig}%{libmudflap_major}

# Extract Mandriva Linux name and version
%if %{mdkversion} >= 1010
%define mdk_distro_version_file	/etc/release
%else
%define mdk_distro_version_file	/etc/mandrake-release
%endif
%define mdk_distro_version	%(perl -ne '/^([.\\w\\s]+) \\(.+\\).+/ and print $1' < %{mdk_distro_version_file})

Summary:	GNU Compiler Collection
Name:		%{name}
Version:	%{version}
Release:	%{release}
License:	GPL
Group:		Development/C

# Main source:	(CVS)
URL:		http://gcc.gnu.org/
Source0:	%{source_package}.tar.bz2
# OBSOLETE: pkg-config files are now shipped
Source3:	gcc35-jdk-config.bz2
# ColorGCC:	http://home.i1.net/~jamoyers/software/colorgcc/
Source4:	colorgcc-%{color_gcc_version}.tar.bz2
Source5:	gcc35-gpc-%{gpc_snapshot}.tar.bz2
# FIXME: unless we get proper help2man package
Source6:	gcc35-help2man.pl.bz2
Source7:	gcc35-gnatmake-bash-completion.bz2
Source8:	build_cross_gcc4.sh

# CVS patches
Patch1: gcc33-pr11536-testcase.patch.bz2
Patch2: gcc33-pr9929-testcase.patch.bz2
Patch3: gcc4-pr15248.patch.bz2

# Mandriva patches
Patch100: colorgcc-1.3.2-mdkconf.patch.bz2
Patch101: gcc33-pass-slibdir.patch.bz2
Patch102: gcc32-pr7434-testcase.patch.bz2
Patch103: gcc33-pr8213-testcase.patch.bz2
Patch104: gcc40-cross-build-fixes.patch.bz2
Patch105: gcc35-ada-link.patch.bz2
Patch106: gcc40-ada-makefile.patch.bz2
Patch107: gcc33-multi-do-libdir.patch.bz2
Patch108: gcc40-visibility1.patch.bz2
Patch109: gcc40-visibility2.patch.bz2
Patch110: gcc34-c++-classfn-member-template.patch.bz2
Patch111: gcc34-gpc-fixes.patch.bz2
Patch112: gcc33-gpc-serialize-build.patch.bz2
Patch113: gcc33-pr11631.patch.bz2
Patch114: gcc35-pch-mdkflags.patch.bz2
Patch115: gcc40-linux32.patch.bz2
Patch116: gcc40-linux32-build-env.patch.bz2
Patch117: gcc40-ada-64bit-hack.patch.bz2
Patch118: gcc4-pr23326.patch.bz2
Patch119: gcc4-cairo1.patch.bz2
Patch120: gcc4-gjavah-jint32.patch.bz2

# Red Hat patches
Patch200: gcc34-debug-pr7241.patch.bz2
Patch201: gcc4-libjava-no-multilib.patch.bz2
Patch202: gcc4-ppc64-m32-m64-multilib-only.patch.bz2
Patch203: gcc40-rh-fortify.patch.bz2
Patch204: gcc4-dv.patch.bz2
Patch205: gcc4-g++-struct-layout.patch.bz2
Patch206: gcc4-pr16104-test.patch.bz2
Patch207: gcc4-struct-layout.patch.bz2
Patch208: gcc4-vsb-stack.patch.bz2
Patch209: gcc4-java-rh163099.patch.bz2
Patch210: gcc4-pr22052.patch.bz2
Patch211: gcc4-pr17828-test.patch.bz2
Patch212: gcc4-pr23484.patch.bz2
Patch213: gcc4-libjava-rhl-branch.patch.bz2
Patch214: gcc4-libltdl-multilib.patch.bz2

BuildRoot:	%{_tmppath}/%{name}-%{version}-root
# Want updated alternatives priorities
%if %{build_cross}
Conflicts:	gcc-cpp < 3.2.2-4mdk
%endif
# We want -pie support
%define binutils_version 2.14.90.0.5-1mdk
%if %{mdkversion} >= 1010
%define binutils_version 2.15.90.0.3-1mdk
%endif
%if %{mdkversion} >= 1020
%define binutils_version 2.15.92.0.2-1mdk
%endif
%if %{mdkversion} >= 200600
%define binutils_version 2.16.91.0.2-2mdk
%endif
Requires:	%{cross_prefix}binutils >= %{binutils_version}
BuildRequires:	%{cross_prefix}binutils >= %{binutils_version}
# Make sure gdb will understand DW_FORM_strp
Conflicts:	gdb < 5.1.1
BuildRequires:	zlib-devel
%if !%{system_compiler}
# We need gcc3.4 + its libstdc++ headers
%define gcc34_version %(gcc3.4-version)
%define libstdcxx_includedir %{target_prefix}/include/c++/%{gcc34_version}
BuildRequires:	gcc3.4 >= %{gcc34_version}, gcc3.4-c++ >= %{gcc34_version}
%endif
%if %{build_ada}
# Ada requires Ada to build
BuildRequires:	%{name}-gnat >= 3.1, %{libgnat_name} >= 3.1
%endif
Requires:	%{name}-cpp = %{version}-%{release}
# FIXME: We need a libgcc with 3.4 symbols
Requires:	%{libgcc_name_orig} >= 3.3.2-5mdk
Requires(post,postun): /usr/sbin/update-alternatives
BuildRequires:	gettext, flex, bison
BuildRequires:	texinfo >= 4.1
# XXX: Needs a GNU awk recent enough to correctly generate options.h
BuildRequires:	gawk >= 3.1.4
# Make sure pthread.h doesn't contain __thread keyword
%if !%{build_cross_bootstrap}
Requires:	%{cross_prefix}glibc-devel >= 2.2.5-14mdk
BuildRequires:	%{cross_prefix}glibc-devel >= 2.2.5-14mdk
%endif
%if %{build_check}
%if %{mdkversion} >= 900
BuildRequires:	%{cross_prefix}glibc-static-devel >= 2.2.5-14mdk
%endif
%endif
%if %{system_compiler}
Obsoletes:	gcc%{branch}
Provides:	gcc%{branch} = %{version}-%{release}
%endif
%if %{build_pdf_doc}
BuildRequires:	tetex, tetex-dvips, tetex-latex
%endif
%if %{build_check}
BuildRequires:	dejagnu
%endif

%description
A compiler aimed at integrating all the optimizations and features
necessary for a high-performance and stable development environment.
This package is required for all other GCC compilers, namely C++,
Fortran 95, Objective C, Java and Ada 95.

If you have multiple versions of GCC installed on your system, it is
preferred to type "gcc-$(gcc%{branch}-version)" (without double quotes) in
order to use the GNU C compiler version %{version}.

%package -n %{libgcc_name}
Summary:	GNU C library
Group:		System/Libraries
Provides:	%{libgcc_name_orig} = %{version}-%{release}
Obsoletes:	%{libgcc_name_orig}%{branch}
Provides:	%{libgcc_name_orig}%{branch} = %{version}-%{release}
Obsoletes:	%{libgcc_name_orig}3.0
Provides:	%{libgcc_name_orig}3.0 = %{version}-%{release}
Provides:	%{libgcc_name_orig}3.2 = %{version}-%{release}

%description -n %{libgcc_name}
The %{libgcc_name} package contains GCC shared libraries for gcc %{branch}

####################################################################
# C++ Compiler

%package c++
Summary:	C++ support for gcc
Group:		Development/C++
%if %{system_compiler}
Obsoletes:	gcc%{branch}-c++
Provides:	gcc%{branch}-c++ = %{version}-%{release}
%endif
Requires:	%{name} = %{version}-%{release}
%if %{system_compiler}
Requires:	%{libstdcxx_name} = %{version}
Requires:	%{libstdcxx_name}-devel = %{version}
%else
Requires:	%{libstdcxx_name} >= %{gcc34_version}
Requires:	%{libstdcxx_name}-devel >= %{gcc34_version}
%endif
Requires(post,postun): /usr/sbin/update-alternatives

%description c++
This package adds C++ support to the GNU C compiler. It includes support
for most of the current C++ specification, including templates and
exception handling. It does include the static standard C++
library and C++ header files; the library for dynamically linking
programs is available separately.

If you have multiple versions of GCC installed on your system, it is
preferred to type "g++-$(gcc%{branch}-version)" (without double quotes) in
order to use the GNU C++ compiler version %{version}.

####################################################################
# C++ Libraries

%package -n %{libstdcxx_name}
Summary:	GNU C++ library
Group:		System/Libraries
Obsoletes:	%{libstdcxx_name_orig}%{branch}
Provides:	%{libstdcxx_name_orig}%{branch} = %{version}-%{release}
Provides:	%{libstdcxx_name_orig} = %{version}-%{release}
%if "%{branch}" == "3.3"
# By default, the libstdc++ from gcc3.3 is ABI compatible with the one
# from gcc3.2. Just tell other packages about it if they relied on that.
Provides:	%{libstdcxx_name_orig}3.2 = %{version}-%{release}
%endif

%description -n %{libstdcxx_name}
This package contains the GCC Standard C++ Library v3, an ongoing
project to implement the ISO/IEC 14882:1998 Standard C++ library.

%package -n %{libstdcxx_name}-devel
Summary:	Header files and libraries for C++ development
Group:		Development/C++
Requires:	%{libstdcxx_name} = %{version}-%{release}
Obsoletes:	%{libstdcxx_name_orig}%{branch}-devel
Provides:	%{libstdcxx_name_orig}%{branch}-devel = %{version}-%{release}
Provides:	%{libstdcxx_name_orig}-devel = %{version}-%{release}

%description -n %{libstdcxx_name}-devel
This is the GNU implementation of the standard C++ libraries.  This
package includes the header files and libraries needed for C++
development.

%package -n %{libstdcxx_name}-static-devel
Summary:	Static libraries for C++ development
Group:		Development/C++
Requires:	%{libstdcxx_name}-devel = %{version}-%{release}
Obsoletes:	%{libstdcxx_name_orig}%{branch}-static-devel
Provides:	%{libstdcxx_name_orig}%{branch}-static-devel = %{version}-%{release}
Provides:	%{libstdcxx_name_orig}-static-devel = %{version}-%{release}

%description -n %{libstdcxx_name}-static-devel
This is the GNU implementation of the standard C++ libraries.  This
package includes the static libraries needed for C++ development.

####################################################################
# Objective C Compiler

%package objc
Summary:	Objective C support for gcc
Group:		Development/Other
%if %{system_compiler}
Obsoletes:	gcc%{branch}-objc
Provides:	gcc%{branch}-objc = %{version}-%{release}
%endif
Requires:	%{name} = %{version}-%{release}

%description objc
This package adds Objective C support to the GNU C compiler. Objective
C is an object oriented derivative of the C language, mainly used on
systems running NeXTSTEP. This package does not include the standard
Objective C object library.

####################################################################
# Objective C Libraries

%package -n %{libobjc_name}
Summary:	Objective C runtime libraries
Group:		System/Libraries
Obsoletes:	%{libobjc_name_orig}3.0, %{libobjc_name_orig}3.1
Provides:	%{libobjc_name_orig} = %{version}-%{release}
Provides:	%{libobjc_name_orig}3.0 = %{version}-%{release}
Provides:	%{libobjc_name_orig}3.1 = %{version}-%{release}
%if !%{system_compiler}
Conflicts:	%{name}-objc < %{branch}
%endif

%description -n %{libobjc_name}
Runtime libraries for the GNU Objective C Compiler.

####################################################################
# Pascal Compiler

%package gpc
Summary:	Pascal support for gcc
Group:		Development/Other
%if %{system_compiler}
Obsoletes:	gcc%{branch}-gpc
Provides:	gcc%{branch}-gpc = %{version}-%{release}
%endif
Requires:	%{name} = %{version}-%{release}

%description gpc
The GNU Pascal Compiler (GPC) is, as the name says, the Pascal
compiler of the GNU family.  The compiler supports the following
language standards and quasi-standards:

  * ISO 7185 Pascal (see Resources),
  * most of ISO 10206 Extended Pascal,
  * Borland Pascal 7.0,
  * parts of Borland Delphi, Mac Pascal and Pascal-SC (PXSC). 

If you have multiple versions of GCC installed on your system, it is
preferred to type "gpc-$(gcc%{branch}-version)" (without double quotes) in
order to use the GNU Pascal compiler version %{version}.

####################################################################
# Fortran 95 Compiler

%package gfortran
Summary:	Fortran 95 support for gcc
Group:		Development/Other
%if %{system_compiler}
Obsoletes:	gcc%{branch}-gfortran
Provides:	gcc%{branch}-gfortran = %{version}-%{release}
%endif
Obsoletes:	gcc%{branch}-g77
Requires:	%{name} = %{version}-%{release}
Requires:	%{libgfortran_name_orig} = %{version}-%{release}
BuildRequires:	libgmp-devel

%description gfortran
This package adds support for compiling Fortran 95 programs with the GNU
compiler.

If you have multiple versions of GCC installed on your system, it is
preferred to type "gfortran-$(gcc%{branch}-version)" (without double quotes) in
order to use the GNU Fortran 95 compiler version %{version}.

####################################################################
# Fortran 95 Libraries

%package -n %{libgfortran_name}
Summary:	Fortran 95 runtime libraries
Group:		System/Libraries
Provides:	%{libgfortran_name_orig} = %{version}
Obsoletes:	%{libgfortran_name_orig}%{branch}
Provides:	%{libgfortran_name_orig}%{branch} = %{version}-%{release}

%description -n %{libgfortran_name}
This package contains Fortran 95 shared library which is needed to run
Fortran 95 dynamically linked programs.

####################################################################
# Ada 95 Compiler

%package gnat
Summary:	Ada 95 support for gcc
Group:		Development/Other
Requires:	%{libgnat_name} = %{version}-%{release}
%if %{system_compiler}
Obsoletes:	gcc%{branch}-gnat
Provides:	gcc%{branch}-gnat = %{version}-%{release}
%endif
Obsoletes:	%{cross_prefix}gnat
Provides:	%{cross_prefix}gnat = %{version}-%{release}
Requires:	%{name} = %{version}-%{release}

%description gnat
This package contains an Ada95 compiler and associated development
tools based on the GNU gcc technology. Ada95 is the object oriented
successor of the Ada83 language. To build this package from sources
you must have installed a binary version to bootstrap the compiler.

####################################################################
# Ada 95 Libraries

%package -n %{libgnat_name}
Summary:	Ada 95 runtime libraries
Group:		System/Libraries
Provides:	%{libgnat_name_orig} = %{version}-%{release}
Obsoletes:	%{cross_prefix}gnat-runtime
Provides:	%{cross_prefix}gnat-runtime = %{version}-%{release}

%description -n %{libgnat_name}
This package contains the shared libraries required to run programs
compiled with the GNU Ada compiler (GNAT) if they are compiled to use
shared libraries.  It also contains the shared libraries for the
Implementation of the Ada Semantic Interface Specification (ASIS), the
implementation of Distributed Systems Programming (GLADE) and the
Posix 1003.5 Binding (Florist).

####################################################################
# Java Compiler

%package java
Summary:	Java support for gcc
Group:		Development/Java
%if %{system_compiler}
Obsoletes:	gcc%{branch}-java
Provides:	gcc%{branch}-java = %{version}-%{release}
%endif
Requires:	%{name} = %{version}-%{release}
Requires:	%{GCJ_TOOLS} = %{version}-%{release}
Requires:	%{libgcj_name} >= %{version}
Requires:	%{libgcj_name}-devel >= %{version}
Requires(post,postun): /usr/sbin/update-alternatives

%description java
This package adds experimental support for compiling Java(tm) programs
and bytecode into native code. To use this you will also need the
libgcj package.

If you have multiple versions of GCC installed on your system, it is
preferred to type "gcj-$(gcc%{branch}-version)" (without double quotes) in
order to use the GNU Java compiler version %{version}.

####################################################################
# Java Runtime Tools

%package -n %{GCJ_TOOLS}
Summary:	Java related tools from gcc %{version}
Group:		Development/Java
%if %{system_compiler}
Obsoletes:	%{cross_prefix}gcj%{branch}-tools
Provides:	%{cross_prefix}gcj%{branch}-tools = %{version}-%{release}
%endif
Provides:	%{cross_prefix}gcj-tools = %{version}-%{release}
Requires:	%{libgcj_name} >= %{version}
Requires:	%{libgcj_name}-devel >= %{version}
Conflicts:	kaffe < 1.0.7-3mdk
Requires(post,postun): /usr/sbin/update-alternatives

%description -n %{GCJ_TOOLS}
This package includes Java related tools built from gcc %{version}:

   * gij: a Java ByteCode Interpreter
   * fastjar: a fast .jar archiver
   * gcjh: generate header files from class files
   * gjnih: generate JNI header files from class files
   * jv-scan: print information about source files
   * jcf-dump: print information about class files
   * gcj-dbtool: tool for manipulating class file databases
   * grmic: generate stubs for Remote Method Invocation
   * grmiregistry: the remote object registry

If you have multiple versions of GCC installed on your system, the
above-mentioned tools are called as follows: "<gcj_tool>-$(gcc%{branch}-version)"
(without double quotes).

####################################################################
# Java Libraries

%package -n %{libgcj_name}
Summary:	GNU Java runtime libraries
Group:		System/Libraries
Requires:	zip >= 2.1
Obsoletes:	%{cross_prefix}gcc-libgcj
Provides:	%{cross_prefix}gcc-libgcj = %{version}-%{release}
Obsoletes:	%{libgcj_name_orig}%{branch}
Provides:	%{libgcj_name_orig}%{branch} = %{version}-%{release}
%if %{mdkversion} >= 200600
# needed for cairo support (Graphics2D)
Requires:	gtk+2.0 >= 2.8.0
BuildRequires:	libgtk+2.0-devel >= 2.8.0
%else
Requires:	gtk+2.0 >= 2.4.0
BuildRequires:	libgtk+2.0-devel >= 2.4.0
%endif
Requires:	libglib2.0 >= 2.4.0
BuildRequires:	libglib2.0-devel >= 2.4.0
BuildRequires:	libart_lgpl-devel >= 2.1.0
%if %{biarch_java}
# build biarch peers
# XXX: probably start splitting more those 32-/64-bit libraries?
# XXX: or even drop 32-bit counterparts as I hardly expect this to be
# loaded from 32-bit libgcj. This looks like the best alternative...
BuildRequires:	linux32
BuildRequires:	devel(libglib-2.0(64bit)), devel(libglib-2.0)
BuildRequires:	devel(libgtk-x11-2.0(64bit)), devel(libgtk-x11-2.0)
BuildRequires:	devel(libart_lgpl_2(64bit)), devel(libart_lgpl_2)
%endif
Obsoletes:	libgcj3, libgcj4
%if %{system_compiler}
Obsoletes:	libgcj5
%endif
Requires:	%{libgcj_name_base}-base = %{version}

%description -n %{libgcj_name}
Runtime libraries for the GNU Java Compiler. The libgcj includes parts
of the Java Class Libraries, plus glue to connect the libraries to the
compiler and the underlying OS.

%package -n %{libgcj_name}-devel
Summary:	Header files and libraries for Java development
Group:		Development/Java
Requires:	zip >= 2.1
Requires:	zlib-devel
Requires:	%{libgcj_name} = %{version}-%{release}
Obsoletes:	%{libgcj_name_orig}%{branch}-devel
Provides:	%{libgcj_name_orig}%{branch}-devel = %{version}-%{release}
Provides:	%{libgcj_name_orig}-devel = %{version}-%{release}
Obsoletes:	libgcj3-devel, libgcj4-devel
%if %{system_compiler}
Obsoletes:	libgcj5-devel
%endif

%description -n %{libgcj_name}-devel
Development headers and libraries for the GNU Java Compiler. The
libgcj includes parts of the Java Class Libraries, plus glue to
connect the libraries to the compiler and the underlying OS.

%package -n %{libgcj_name}-static-devel
Summary:	Static libraries for Java development
Group:		Development/Java
Requires:	%{libgcj_name}-devel = %{version}-%{release}
Obsoletes:	%{libgcj_name_orig}%{branch}-static-devel
Provides:	%{libgcj_name_orig}%{branch}-static-devel = %{version}-%{release}
Provides:	%{libgcj_name_orig}-static-devel = %{version}-%{release}
Obsoletes:	libgcj3-static-devel, libgcj4-static-devel
%if %{system_compiler}
Obsoletes:	libgcj5-static-devel
%endif

%description -n %{libgcj_name}-static-devel
Static libraries for the GNU Java Compiler.

%package -n %{libgcj_name_base}-base
Summary: Java library base classes
Group: Development/Java

%description -n %{libgcj_name_base}-base
The Java(tm) runtime library classes.

%package -n %{libgcj_name_base}-src
Summary: Java library sources
Group: Development/Java
Requires: %{libgcj_name} = %{version}-%{release}

%description -n %{libgcj_name_base}-src
The Java(tm) runtime library sources.

####################################################################
# FFI headers and libraries

%package -n %{libffi_name}-devel
Summary:	Development headers and static library for FFI
Group:		Development/C
Obsoletes:	%{libffi_name_orig}%{branch}-devel
Provides:	%{libffi_name_orig}%{branch}-devel = %{version}-%{release}
Obsoletes:	%{libffi_name_orig}-devel
Provides:	%{libffi_name_orig}-devel = %{version}-%{release}
Provides:	ffi-devel = %{version}-%{release}

%description -n %{libffi_name}-devel
This package contains the development headers and the static library
for libffi. The libffi library provides a portable, high level
programming interface to various calling conventions. This allows a
programmer to call any function specified by a call interface
description at run time.

####################################################################
# mudflap headers and libraries

%package -n %{libmudflap_name}
Summary:	GCC mudflap shared support library
Group:		System/Libraries

%description -n %{libmudflap_name}
This package contains GCC shared support library which is needed
for mudflap support.

For front-ends that support it (C and C++), instrument all risky
pointer/array dereferencing operations, some standard library
string/heap functions, and some other associated constructs with
range/validity tests.  Modules so instrumented should be immune to
buffer overflows, invalid heap use, and some other classes of C/C++
programming errors.

Refer to the documentation for -fmudflap and -fmudflapth.

%package -n %{libmudflap_name}-devel
Summary:	GCC mudflap support
Group:		Development/C
Requires:	%{name} = %{version}-%{release}
Requires:	%{libmudflap_name} = %{version}-%{release}
Obsoletes:	%{libmudflap_name_orig}-devel
Provides:	%{libmudflap_name_orig}-devel = %{version}-%{release}

%description -n %{libmudflap_name}-devel
This package contains headers and static libraries for building
mudflap-instrumented programs.

To instrument a non-threaded program, add `-fmudflap' option to GCC
and when linking add `-lmudflap'. For threaded programs also add
`-fmudflapth' and `-lmudflapth'.

####################################################################
# Preprocessor

%package cpp
Summary:	The C Preprocessor
Group:		Development/C
%if %{system_compiler}
Obsoletes:	gcc%{branch}-cpp
Provides:	gcc%{branch}-cpp = %{version}-%{release}
%endif
Requires(post,postun): /usr/sbin/update-alternatives

%description cpp
The C preprocessor is a 'macro processor' which is used automatically
by the C compiler to transform your program before actual
compilation. It is called a macro processor because it allows
you to define 'macros,' which are abbreviations for longer
constructs.

The C preprocessor provides four separate facilities that you can use as
you see fit:

* Inclusion of header files. These are files of declarations that can be
  substituted into your program.
* Macro expansion. You can define 'macros,' which are abbreviations for 
  arbitrary fragments of C code, and then the C preprocessor will replace
  the macros with their definitions throughout the program.
* Conditional compilation. Using special preprocessing directives,
  you can include or exclude parts of the program according to various
  conditions.
* Line control. If you use a program to combine or rearrange source files
  into an intermediate file which is then compiled, you can use line
  control to inform the compiler about where each source line originated.

You should install this package if you are a programmer who is searching for
such a macro processor.

If you have multiple versions of GCC installed on your system, you
will have to type "cpp -V%{version}" or "cpp-%{version}" (without double quotes)
in order to use the GNU C Preprocessor version %{version}.

####################################################################
# ColorGCC

%package colorgcc
Summary:	GCC output colorizer
Group:		Development/Other
Obsoletes:	gcc2.96-colorgcc
%if %{system_compiler}
Obsoletes:	gcc%{branch}-colorgcc
Provides:	gcc%{branch}-colorgcc = %{version}-%{release}
%endif
Requires:	%{name} = %{version}
Requires(post,postun): /usr/sbin/update-alternatives
Requires:	perl

%description colorgcc
ColorGCC is a Perl wrapper to colorize the output of compilers with
warning and error messages matching the GCC output format.

This package is configured to run with the associated system compiler,
that is GCC version %{version}. If you want to use it for another
compiler (e.g. gcc 2.96), you may have to define gccVersion: 2.96 and
uncomment the respective compiler paths in %{_sysconfdir}/colorgccrc
for a system-wide effect, or in ~/.colorgccrc for your user only.

####################################################################
# Documentation

%package doc
Summary:	GCC documentation
Group:		Development/Other
%if %{system_compiler}
Obsoletes:	gcc%{branch}-doc
Provides:	gcc%{branch}-doc = %{version}-%{release}
%endif
Requires(post,preun): /sbin/install-info

%description doc
GCC is a compiler suite aimed at integrating all the optimizations and
features necessary for a high-performance and stable development
environment. This package contains the compiler documentation in INFO
pages.

%package doc-pdf
Summary:	GCC documentation
Group:		Development/Other
%if %{system_compiler}
Obsoletes:	gcc%{branch}-doc-pdf
Provides:	gcc%{branch}-doc-pdf = %{version}-%{release}
%endif

%description doc-pdf
GCC is a compiler suite aimed at integrating all the optimizations and
features necessary for a high-performance and stable development
environment. This package contains the compiler printable
documentation in PDF.

%prep
%setup -q -n %{source_dir} -a 4 -a 5
%patch1 -p1 -b .pr11536-testcase
%patch2 -p1 -b .pr9929-testcase
%patch3 -p1 -b .pr15248

# Mandriva patches
%patch101 -p1 -b .pass-slibdir
%patch102 -p1 -b .pr7434-testcase
%patch103 -p1 -b .pr8213-testcase
%patch104 -p1 -b .cross-build-fixes
%patch105 -p1 -b .ada-link
%patch106 -p1 -b .ada-makefile
%patch107 -p1 -b .multi-do-libdir
%patch108 -p1 -b .visibility1
%patch109 -p1 -b .visibility2
%patch110 -p1 -b .c++-classfn-member-template
%patch113 -p1 -b .pr11631-testcase
%patch114 -p1 -b .pch-mdkflags
%patch115 -p1 -b .linux32
%patch116 -p1 -b .linux32-build-env
%patch117 -p1 -b .ada-64bit-hack
%patch118 -p1 -b .pr23326
%patch119 -p1 -b .libjava-cairo-0.5-api
%patch120 -p1 -b .gjavah-jint32
# FIXME: use a configure flag
optflags=`echo $RPM_OPT_FLAGS | sed -e 's/-mcpu=/-mtune=/'`
perl -pi -e "s/\@MDK_OPT_FLAGS\@/$optflags/" \
	libstdc++-v3/include/Makefile.am \
	libstdc++-v3/include/Makefile.in

# Red Hat patches
%patch200 -p0 -b .debug-pr7241
%if ! %{biarch_java}
%patch201 -p1 -b .libjava-no-multilib
%endif
%patch202 -p0 -b .ppc64-m32-m64-multilib-only
%patch203 -p1 -b .fortify
%patch204 -p0 -b .dv
%patch205 -p0 -b .g++-struct-layout
%patch206 -p0 -b .pr16104
%patch207 -p0 -b .struct-layout
%patch208 -p0 -b .vsb-stack
%patch209 -p0 -b .java-rh163099
%patch210 -p0 -b .pr22052
%patch211 -p0 -b .pr17828-test
%patch212 -p0 -b .pr23484
%patch213 -p1 -b .libjava-rhl-branch
%patch214 -p0 -b .libltdl-multilib

# Integrate GNU Pascal compiler
%if %{build_pascal}
mv gpc-%{gpc_snapshot}/p gcc/p
rmdir gpc-%{gpc_snapshot}
patch -p1 < gcc/p/diffs/gcc-3.5.0.diff
%patch111 -p1 -b .gpc-fixes
%patch112 -p1 -b .gpc-serialize-build
%endif

# Patch version for Mandriva and bug reports
perl -pi -e 's/%{snapshot_version}/%{version}/' gcc/version.c
perl -pi -e "/bug_report_url/ and s/\"[^\"]+\"/\"<URL:https:\/\/qa.mandriva.com\/>\"/;" \
         -e '/version_string/ and s/([0-9]*(\.[0-9]*){1,3}).*(\";)$/\1 \(%{version}-%{release} for %{mdk_distro_version}\)\3/;' \
         gcc/version.c

# Ship with libgcjawt instead of jawt commonly used in non-free JVMs
perl -pi -e 's/libjawt/libgcjawt/g' libjava/Makefile.{am,in}

# Fix java-ext path
sed -i -e 's,\$(jardir)/ext,$(jardir)-ext,g' libjava/Makefile.{am,in}

# ColorGCC patch
cd colorgcc-%{color_gcc_version};
%patch100 -p1 -b .mdkconf
perl -pi -e 's|GCC_VERSION|%{version}|' colorgcc*
cd ..

bzcat %{SOURCE7} > gnatmake.bash-completion

%build
# Force a seperate object dir
rm -fr obj-%{gcc_target_platform}
mkdir obj-%{gcc_target_platform}
cd obj-%{gcc_target_platform}

# FIXME: extra tools needed
mkdir -p bin
bzcat %{SOURCE6} >bin/help2man
export PATH=$PATH:$PWD/bin

# Make bootstrap-lean
OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-mcpu=pentiumpro//g'`
%if %{build_debug}
OPT_FLAGS=`echo "$OPT_FLAGS -g" | sed -e "s/-fomit-frame-pointer//g"`
%endif
%if %{build_cross}
OPT_FLAGS="-O2 -pipe"
%endif
OPT_FLAGS=`echo $OPT_FLAGS|sed -e 's/-fomit-frame-pointer//g'`

LANGUAGES="c"
%if %{build_cxx}
LANGUAGES="$LANGUAGES,c++"
%endif
%if %{build_ada}
LANGUAGES="$LANGUAGES,ada"
%endif
%if %{build_fortran}
LANGUAGES="$LANGUAGES,f95"
%endif
%if %{build_objc}
LANGUAGES="$LANGUAGES,objc"
%endif
%if %{build_java}
LANGUAGES="$LANGUAGES,java"
%endif
%if %{build_pascal}
LANGUAGES="$LANGUAGES,pascal"
%endif
PROGRAM_SUFFIX=""
%if !%{system_compiler}
PROGRAM_SUFFIX="--program-suffix=%{program_suffix}"
%endif
%if %{build_cxx}
LIBSTDCXX_FLAGS="--enable-long-long --enable-__cxa_atexit --enable-clocale=gnu --disable-libunwind-exceptions"
%endif
%if %{build_java}
LIBJAVA_FLAGS="--enable-java-awt=gtk --with-java-home=%{jdk_home}"
%if %{mdkversion} >= 200600
LIBJAVA_FLAGS="$LIBJAVA_FLAGS --enable-gtk-cairo"
%endif
%else
LIBJAVA_FLAGS="--disable-libgcj"
%endif
%if ! %{biarch_java}
LIBJAVA_FLAGS="$LIBJAVA_FLAGS --disable-libjava-multilib"
%endif
%if %{build_cross}
CROSS_FLAGS="--with-sysroot=%{_prefix}/%{target_cpu}-linux --disable-multilib --disable-nls"
%endif
%if %{build_cross_bootstrap}
CROSS_FLAGS="--disable-multilib --disable-shared --disable-threads --disable-libmudflap"
%endif
%if !%{system_compiler}
LIBSTDCXX_FLAGS="$LIBSTDCXX_FLAGS --with-gxx-include-dir=%{libstdcxx_includedir}"
%endif
[[ -n "$CROSS_FLAGS" ]] && CROSS_FLAGS="$CROSS_FLAGS --target=%{gcc_target_platform}"
# update config.{sub,guess} scripts
%{?__cputoolize: %{__cputoolize} -c ..}
%{?__cputoolize: %{__cputoolize} -c ../boehm-gc}
CC="%{__cc}" CFLAGS="$OPT_FLAGS" CXXFLAGS="$OPT_FLAGS" XCFLAGS="$OPT_FLAGS" TCFLAGS="$OPT_FLAGS" \
	../configure --prefix=%{_prefix} --libexecdir=%{_prefix}/lib --with-slibdir=%{target_slibdir} \
	--mandir=%{_mandir} --infodir=%{_infodir} \
	--enable-shared --enable-threads=posix --disable-checking \
	--enable-languages="$LANGUAGES" $PROGRAM_SUFFIX \
	--host=%{_target_platform} $CROSS_FLAGS \
	--with-system-zlib $LIBSTDCXX_FLAGS $LIBJAVA_FLAGS
touch ../gcc/c-gperf.h
%if %{build_cross}
%make
%else
%ifarch %{ix86} x86_64
%make profiledbootstrap BOOT_CFLAGS="$OPT_FLAGS"
%else
%make bootstrap-lean BOOT_CFLAGS="$OPT_FLAGS"
%endif
%endif

%if !%{build_cross}
# Make protoize
make -C gcc CC="./xgcc -B ./ -O2" proto
%endif
cd ..

# Copy various doc files here and there
mkdir -p rpm.doc/gfortran
mkdir -p rpm.doc/objc
mkdir -p rpm.doc/libjava
mkdir -p rpm.doc/libobjc
mkdir -p rpm.doc/boehm-gc
mkdir -p rpm.doc/fastjar
mkdir -p rpm.doc/gpc

%if %{build_pascal}
(cd gcc/p; for i in ChangeLog* README NEWS FAQ; do
	cp -p $i ../../rpm.doc/gpc/$i
done)
%endif
%if %{build_fortran}
(cd gcc/fortran; for i in ChangeLog*; do
	cp -p $i ../../rpm.doc/gfortran/$i
done)
(cd libgfortran; for i in ChangeLog*; do
	cp -p $i ../rpm.doc/gfortran/$i.libgfortran
done)
%endif
%if %{build_objc}
(cd gcc/objc; for i in README*; do
	cp -p $i ../../rpm.doc/objc/$i.objc
done)
(cd libobjc; for i in README*; do
	cp -p $i ../rpm.doc/libobjc/$i.libobjc
done)
%endif
%if %{build_java}
(cd boehm-gc; for i in ChangeLog*; do
        cp -p $i ../rpm.doc/boehm-gc/$i.gc
done)
(cd fastjar; for i in ChangeLog* README*; do
        cp -p $i ../rpm.doc/fastjar/$i.fastjar
done)
(cd libjava; for i in README THANKS COPYING ChangeLog; do
	cp -p $i ../rpm.doc/libjava/$i.libjava
done)
(cd libjava; cp -p LIBGCJ_LICENSE ../rpm.doc/libjava/LICENSE.libjava)
%endif

# [ghibo] - build printable documentation
%if %{build_pdf_doc}
unset TEXINPUTS
(cd gcc/doc; for file in gcc.texi cpp.texi cppinternals.texi; do
  texi2dvi -p -t @afourpaper -t @finalout -I ./include $file
done)
(cd gcc/fortran;
  texi2dvi -p -t @afourpaper -t @finalout -I ../doc/include gfortran.texi)
(cd gcc/ada;
  texi2dvi -p -t @afourpaper -t @finalout -I ../doc/include gnat_rm.texi)
(cd obj-%{gcc_target_platform}/gcc/doc;
  texi2dvi -p -t @afourpaper -t @finalout -I ../../../gcc/doc/include gnat_ugn_unw.texi
  mv gnat_ugn_unw.pdf ../../../gcc/ada/gnat_ug.pdf)
%endif

# Run tests
%ifarch %{biarches}
RUNTESTFLAGS="--target_board 'unix{-m32,}'"
%endif
echo ====================TESTING=========================
%if %{build_check}
cd obj-%{gcc_target_platform}
%make -k RUNTESTFLAGS="$RUNTESTFLAGS" check || true
logfile="$PWD/../%{name}-%{version}-%{release}.log"
../contrib/test_summary > $logfile
cd ..
%endif
echo ====================TESTING END=====================
 
%install
rm -rf $RPM_BUILD_ROOT

# Fix HTML docs for libstdc++-v3
perl -pi -e \
  's~href="l(ibstdc|atest)~href="http://gcc.gnu.org/onlinedocs/libstdc++/l\1~' \
  libstdc++-v3/docs/html/documentation.html
ln -sf documentation.html libstdc++-v3/docs/html/index.html
find libstdc++-v3/docs/html -name CVS | xargs rm -rf

# Create some directories, just to make sure (e.g. ColorGCC)
mkdir -p $RPM_BUILD_ROOT%{_bindir}
mkdir -p $RPM_BUILD_ROOT%{_mandir}
mkdir -p $RPM_BUILD_ROOT%{_infodir}
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}

# ColorGCC stuff
%if %{build_colorgcc}
pushd colorgcc-%{color_gcc_version};
  install -m 755 colorgcc $RPM_BUILD_ROOT%{_bindir}/colorgcc-%{version}
  ln -s colorgcc-%{version} $RPM_BUILD_ROOT%{_bindir}/colorgcc
  install -m 644 colorgccrc $RPM_BUILD_ROOT%{_sysconfdir}/
  for i in COPYING CREDITS ChangeLog; do
    [ ! -f ../$i.colorgcc ] && mv -f $i ../$i.colorgcc
  done
popd
%endif

pushd obj-%{gcc_target_platform};
  %makeinstall_std
  %if %{build_java}
  %makeinstall_std -C %{gcc_target_platform}/libjava install-src.zip
  %endif
  %if %{build_ada}
  for f in $RPM_BUILD_ROOT%{_infodir}/gnat_ugn_unw.info*; do
    sed -e "s/gnat_ugn_unw/gnat_ug/g" $f > ${f/gnat_ugn_unw/gnat_ug}
  done
  chmod 644 $RPM_BUILD_ROOT%{_infodir}/gnat*
  %endif
popd

FULLVER=`$RPM_BUILD_ROOT%{_bindir}/%{gcc_target_platform}-gcc%{program_suffix} --version | head -n 1 | cut -d' ' -f3`
FULLPATH=$(dirname $RPM_BUILD_ROOT%{gcc_libdir}/%{gcc_target_platform}/%{version}/cc1)

#if [ "%{gcc_target_platform}" != "%{_target_platform}" ]; then
#   mv -f $RPM_BUILD_ROOT%{_bindir}/%{gcc_target_platform}-gcc $RPM_BUILD_ROOT%{_bindir}/%{_target_platform}-gcc
#fi

file $RPM_BUILD_ROOT/%{_bindir}/* | grep ELF | cut -d':' -f1 | xargs strip || :
strip $FULLPATH/cc1
%if %{build_cxx}
strip $FULLPATH/cc1plus
%endif
%if %{build_pascal}
strip $FULLPATH/gpc1
%endif
%if %{build_fortran}
strip $FULLPATH/f951
%endif
%if %{build_java}
strip $FULLPATH/{jc1,jvgenmain}
%endif

# Create /usr/bin/%{program_prefix}gcc%{branch}-version that contains the full version of gcc
cat >$RPM_BUILD_ROOT%{_bindir}/%{program_prefix}gcc%{branch}-version <<EOF
#!/bin/sh
echo "$FULLVER"
EOF
chmod 0755 $RPM_BUILD_ROOT%{_bindir}/%{program_prefix}gcc%{branch}-version

# Fix program names
# (gb) For each primary program in every package, I want it to be
# named <program>-<version>
(cd $RPM_BUILD_ROOT%{_bindir}; for file in cpp gcc c++ g++ gcj gij gfortran gpc gpidump; do
  file_version="${file}-%{version}"
  if [ -x "$file" -a "(" ! -x "$file_version" -o -L "$file_version" ")" ]; then
    cp -f $file $file_version
    rm -f $file
    ln -s $file_version $file
  fi
  file="%{program_prefix}$file" file_version="%{program_prefix}$file_version"
  if [ -x "$file" -a ! -x "$file_version" ]; then
    cp -f $file $file_version
    rm -f $file
    ln -s $file_version $file
  fi
done)

# Fix some links
ln -sf gcc $RPM_BUILD_ROOT%{_bindir}/cc
rm -f $RPM_BUILD_ROOT%{_infodir}/dir

# Dispatch Ada 95 libraries (special case)
%if %{build_ada}
pushd $FULLPATH/adalib
  rm -f libgnarl.so* libgnat.so*
  mv -f libgnarl-*.so.* $RPM_BUILD_ROOT%{_libdir}/
  ln -s ../../../../../%{_lib}/libgnarl-*.so.* libgnarl-%{branch}.so
  ln -s libgnarl-%{branch}.so libgnarl.so
  mv -f libgnat-*.so.* $RPM_BUILD_ROOT%{_libdir}/
  ln -s ../../../../../%{_lib}/libgnat-*.so.* libgnat-%{branch}.so
  ln -s libgnat-%{branch}.so libgnat.so
popd
%endif

# Strip debug info from libraries
STRIP_DEBUG=
%if !%{build_debug}
STRIP_DEBUG="strip -g"
if [[ "%{_target_cpu}" != "%{target_cpu}" ]]; then
  STRIP_DEBUG="%{target_cpu}-linux-$STRIP_DEBUG"

fi
%endif

# Dispatch libraries to the right directories
DispatchLibs() {
	libname=$1 libversion=$2
	rm -f $libname.so $libname.a
	$STRIP_DEBUG ../../../../%{_lib}/$crosslibdir/$libname.so.$libversion
	$STRIP_DEBUG ../../../../%{_lib}/$crosslibdir/$libname.a
	ln -s ../../../../%{_lib}/$crosslibdir/$libname.so.$libversion $libname.so
	rm -f ../../../../%{_lib}/$crosslibdir/$libname.so
	cp -f ../../../../%{_lib}/$crosslibdir/$libname.a $libname.a
	rm -f ../../../../%{_lib}/$crosslibdir/$libname.a
	%ifarch %{biarches}
	[ -d 32 ] || mkdir 32
	cd 32
	mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib
	skip32=
	[[ -z "$skip32" ]] && {
	$STRIP_DEBUG ../../../../$libname.so.$libversion
	$STRIP_DEBUG ../../../../$libname.a
	ln -s ../../../../$libname.so.$libversion $libname.so
	rm -f ../../../../$libname.so
	[ -r "../../../../$libname.a" ] && {
	cp -f ../../../../$libname.a $libname.a
	rm -f ../../../../$libname.a
	}
	}
	cd ..
	%endif
	%ifarch %{nof_arches}
	[ -d nof ] || mkdir nof
	pushd nof
	$STRIP_DEBUG ../../../../nof/$libname.so.$libversion
	$STRIP_DEBUG ../../../../nof/$libname.a
	ln -s ../../../../nof/$libname.so.$libversion $libname.so
	rm -f ../../../../nof/$libname.so
	[ -r "../../../../nof/$libname.a" ] && {
	cp -f ../../../../nof/$libname.a $libname.a
	rm -f ../../../../nof/$libname.a
	}
	popd
	%endif
}
pushd $FULLPATH
	if [[ "%{_target_cpu}" != "%{target_cpu}" ]]; then
	crosslibdir="../%{gcc_target_platform}/lib"
	fi
	DispatchLibs libmudflap		%{libmudflap_major}.0.0
	DispatchLibs libmudflapth	%{libmudflap_major}.0.0
	%if %{build_cxx}
	DispatchLibs libstdc++	%{libstdcxx_major}.0.%{libstdcxx_minor}
	mv ../../../../%{_lib}/$crosslibdir/libsupc++.a libsupc++.a
	%ifarch %{biarches}
	mv -f ../../../libsupc++.a 32/libsupc++.a
	%endif
	%ifarch ppc
	mv -f ../../../nof/libsupc++.a nof/libsupc++.a
	%endif
	%endif
	# Make it less hard dependent on libstdc++ 3.4 minor changes
	%if ! %{system_compiler}
	[[ -f  ../../../../%{_lib}/$crosslibdir/libstdc++.so.%{libstdcxx_major} ]] &&
	ln -sf ../../../../%{_lib}/$crosslibdir/libstdc++.so.%{libstdcxx_major} libstdc++.so
	%ifarch %{biarches}
	[[ -f  ../../../$crosslibdir/libstdc++.so.%{libstdcxx_major} ]] &&
	ln -sf ../../../../$crosslibdir/libstdc++.so.%{libstdcxx_major} 32/libstdc++.so
	%endif
	%endif
	%if %{build_java}
	DispatchLibs libgcj	%{libgcj_major}.0.0
	DispatchLibs libgij	%{libgcj_major}.0.0
	DispatchLibs libgcjawt	%{libgcj_major}.0.0
	DispatchLibs lib-gnu-java-awt-peer-gtk	%{libgcj_major}.0.0
	%endif
	%if %{build_objc}
	DispatchLibs libobjc	%{libobjc_major}.0.0
	%endif
	%if %{build_fortran}
	DispatchLibs libgfortran	%{libgfortran_major}.0.0
	mv -f ../../../../%{_lib}/$crosslibdir/libgfortranbegin.a libgfortranbegin.a
	[ -r "../../../libgfortranbegin.a" ] &&
	mv -f ../../../libgfortranbegin.a 32/libgfortranbegin.a
	%ifarch %{nof_arches}
	[ -r "../../../nof/libgfortranbegin.a" ] &&
	mv -f ../../../nof/libgfortranbegin.a nof/libgfortranbegin.a
	%endif
	%endif
popd

# Move Java headers to /usr/include/libgcj-<version>
%if %{build_java}
if [ "%{libjava_includedir}" != "%{_includedir}" ]; then
  mkdir -p $RPM_BUILD_ROOT%{libjava_includedir}
  for dir in gcj gnu java javax org; do
    mkdir -p $RPM_BUILD_ROOT%{libjava_includedir}/$dir
    mv $RPM_BUILD_ROOT%{libstdcxx_includedir}/$dir/* $RPM_BUILD_ROOT%{libjava_includedir}/$dir/
    rmdir $RPM_BUILD_ROOT%{libstdcxx_includedir}/$dir
  done

  # include <libgcj/XXX.h> should lead to <libgcj-VERSION/XXX.h>
  ln -s %{libjava_includedir} $RPM_BUILD_ROOT%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/libgcj
  ln -s %{libjava_includedir} $RPM_BUILD_ROOT%{_includedir}/libgcj

  # fix pkgconfig files
  perl -pi -e 's,^(includedir=).+,\1%{libjava_includedir},' $RPM_BUILD_ROOT%{_prefix}/lib/pkgconfig/libgcj.pc
%ifarch %{biarches}
  mkdir -p $RPM_BUILD_ROOT%{_libdir}/pkgconfig
  perl -pe '/^libdir=/ and s,/lib,/%{_lib},' $RPM_BUILD_ROOT%{_prefix}/lib/pkgconfig/libgcj.pc > $RPM_BUILD_ROOT%{_libdir}/pkgconfig/libgcj.pc
%endif
fi
%endif

# Move libgcj.spec to compiler-specific directories
%if %{build_java}
mv $RPM_BUILD_ROOT%{_prefix}/lib/libgcj.spec $FULLPATH/libgcj.spec
%endif

# Rename jar because it could clash with Kaffe's if this gcc
# is primary compiler (aka don't have the -<version> extension)
%if %{build_java}
pushd $RPM_BUILD_ROOT%{_bindir}
  for app in %{gcj_alternative_programs}; do
    [[ -f $app ]] && mv -f $app $app-%{version}
    [[ -f $app-%{version} ]] || { echo "Missing $app"; exit 1; }
  done
popd
%endif

# Add jdk-config helper
%if %{build_java}
pushd $RPM_BUILD_ROOT%{_bindir}/
  SED_PATTERN="s|@GCJ_VERSION@|%{version}|;s|@JDK_VERSION@|%{jdk_version}|;s|@JDK_INCLUDES@|-I%{libjava_includedir}|;"
  bzcat %{SOURCE3} | sed -e "$SED_PATTERN" > gcj-jdk-config-%{version}
  chmod 0755 gcj-jdk-config-%{version}
popd
%endif

# Move <cxxabi.h> to compiler-specific directories
%if %{build_cxx}
mkdir -p $FULLPATH/include/bits/
mv $RPM_BUILD_ROOT%{libstdcxx_includedir}/cxxabi.h $FULLPATH/include/
mv $RPM_BUILD_ROOT%{libstdcxx_includedir}/%{gcc_target_platform}/bits/cxxabi_tweaks.h $FULLPATH/include/bits/
%endif

# Ship with biarch c++config.h headers
%if %{build_cxx}
pushd obj-%{gcc_target_platform}
cxxconfig="`find %{gcc_target_platform}/libstdc++-v3/include -name c++config.h`"
for i in `find %{gcc_target_platform}/[36]*/libstdc++-v3/include -name c++config.h 2>/dev/null`; do
  if ! diff -up $cxxconfig $i; then
    file_32=x file_64=x
    case $i in
      %{gcc_target_platform}/32/*) file_32=$i; file_64=$cxxconfig ;;
      %{gcc_target_platform}/64/*) file_32=$cxxconfig; file_64=$i ;;
    esac
    { [[ -f "$file_32" ]] && [[ -f "$file_64" ]]; } ||
      { echo "c++config.h dispatch error"; exit 1; }

    cat > $RPM_BUILD_ROOT%{libstdcxx_includedir}/%{gcc_target_platform}/bits/c++config.h <<EOF
#ifndef _CPP_CPPCONFIG_WRAPPER
#define _CPP_CPPCONFIG_WRAPPER 1
#include <bits/wordsize.h>
#if __WORDSIZE == 32
`cat $file_32`
#else
`cat $file_64`
#endif
#endif
EOF
    break
  fi
done
popd
%endif

# Move <mf-runtime.h> to compiler-specfic directory
mv $RPM_BUILD_ROOT%{_includedir}/mf-runtime.h $FULLPATH/include/

# Fix links to binaries
pushd $RPM_BUILD_ROOT%{_bindir};
	progs="cpp gcc"
	%if %{build_cxx}
	progs="$progs g++ c++"
	%endif
	for file in $progs; do
		[[ -L $file ]] && rm -f $file
		[[ -x $file ]] && mv $file "$file"-%{version}
		[[ -n "%{program_prefix}" ]] && {
			[[ -x "$file"-%{version} ]] && mv "$file"-%{version} "%{program_prefix}$file"-%{version}
			[[ -L "%{program_prefix}$file" ]] || ln -s "%{program_prefix}$file"-%{version} "%{program_prefix}$file"
		}
		[[ -x "%{program_prefix}$file"-%{version} ]] || { echo "ERROR: no versioned binary for $file"; exit 1; }
	done
	%if %{build_java}
	for file in gcjh gjnih jcf-dump jv-scan grmic grmiregistry gcj-dbtool; do [ -x $file -a -n "%{program_suffix}" ] && mv $file "$file"-%{version}; done
	%endif
popd

# Link gnatgcc to gcc
ln -sf gcc $RPM_BUILD_ROOT%{_bindir}/gnatgcc

# Create an empty file with perms 0755
FakeAlternatives() {
  for file in ${1+"$@"}; do
    rm -f $file
    touch $file
    chmod 0755 $file
  done
}

# Alternatives provide /lib/cpp and %{_bindir}/cpp
(cd $RPM_BUILD_ROOT%{_bindir}; FakeAlternatives cpp)
(mkdir -p $RPM_BUILD_ROOT/lib; cd $RPM_BUILD_ROOT/lib; ln -sf %{_bindir}/cpp cpp)

# Alternatives provide /usr/bin/{gfortran,f95}
(cd $RPM_BUILD_ROOT%{_bindir}; FakeAlternatives gfortran f95)

# Alternatives provide /usr/bin/c++
(cd $RPM_BUILD_ROOT%{_bindir}; FakeAlternatives c++)

# Alternatives provide java programs
(cd $RPM_BUILD_ROOT%{_bindir}; FakeAlternatives gij %{gcj_alternative_programs})

# Alternatives provide jdk-config script
(cd $RPM_BUILD_ROOT%{_bindir}; FakeAlternatives jdk-config)

if [[ -z "%{?cross_bootstrap:1}" ]]; then
# Move libgcc_s.so* to /%{_lib}
pushd $RPM_BUILD_ROOT%{_libdir}
  chmod 0755 libgcc_s.so.%{libgcc_major}
  mkdir -p $RPM_BUILD_ROOT%{target_slibdir}
  mv -f  libgcc_s.so.%{libgcc_major} $RPM_BUILD_ROOT%{target_slibdir}/libgcc_s-%{version}.so.%{libgcc_major}
  ln -sf libgcc_s-%{version}.so.%{libgcc_major} $RPM_BUILD_ROOT%{target_slibdir}/libgcc_s.so.%{libgcc_major}
  ln -sf ../..%{target_slibdir}/libgcc_s.so.%{libgcc_major} $RPM_BUILD_ROOT%{target_libdir}/libgcc_s.so
%ifarch %{nof_arches}
  chmod 0755 nof/libgcc_s.so.%{libgcc_major}
  mkdir -p $RPM_BUILD_ROOT%{target_slibdir}/nof
  mv -f  nof/libgcc_s.so.%{libgcc_major} $RPM_BUILD_ROOT%{target_slibdir}/nof/libgcc_s-%{version}.so.%{libgcc_major}
  ln -sf libgcc_s-%{version}.so.%{libgcc_major} $RPM_BUILD_ROOT%{target_slibdir}/nof/libgcc_s.so.%{libgcc_major}
  ln -sf ../..%{target_slibdir}/nof/libgcc_s.so.%{libgcc_major} $RPM_BUILD_ROOT%{target_libdir}/nof/libgcc_s.so
%endif
popd
%ifarch %{biarches}
pushd $RPM_BUILD_ROOT%{_prefix}/lib
  chmod 0755 libgcc_s.so.%{libgcc_major}
  mkdir -p $RPM_BUILD_ROOT/lib
  mv -f  libgcc_s.so.%{libgcc_major} $RPM_BUILD_ROOT/lib/libgcc_s-%{version}.so.%{libgcc_major}
  ln -sf libgcc_s-%{version}.so.%{libgcc_major} $RPM_BUILD_ROOT/lib/libgcc_s.so.%{libgcc_major}
  ln -sf ../../lib/libgcc_s.so.%{libgcc_major} $RPM_BUILD_ROOT%{_prefix}/lib/libgcc_s.so
  ln -sf ../../lib/libgcc_s.so.%{libgcc_major} $RPM_BUILD_ROOT%{_prefix}/lib/libgcc_s_32.so
popd
if [[ "%{build_java}:%{biarch_java}" = "1:0" ]]; then
  for lib in lib-gnu-java-awt-peer-gtk libgcj libgij libgcjawt; do
    ln -sf ../../../%{gcc32_target_platform}/%{version}/$lib.a  $FULLPATH/32/$lib.a
    ln -sf ../../../%{gcc32_target_platform}/%{version}/$lib.so $FULLPATH/32/$lib.so
  done
fi
%endif
fi

# Create c89 and c99 wrappers
%if %{system_compiler}
cat > $RPM_BUILD_ROOT%{_prefix}/bin/c89 <<"EOF"
#!/bin/sh
fl="-std=c89"
for opt; do
  case "$opt" in
    -ansi|-std=c89|-std=iso9899:1990) fl="";;
    -std=*) echo "`basename $0` called with non ANSI/ISO C option $opt" >&2
	    exit 1;;
  esac
done
exec %{_bindir}/gcc-%{version} $fl ${1+"$@"}
EOF
cat > $RPM_BUILD_ROOT%{_prefix}/bin/c99 <<"EOF"
#!/bin/sh
fl="-std=c99"
for opt; do
  case "$opt" in
    -std=c99|-std=iso9899:1999) fl="";;
    -std=*) echo "`basename $0` called with non ISO C99 option $opt" >&2
	    exit 1;;
  esac
done
exec %{_bindir}/gcc-%{version} $fl ${1+"$@"}
EOF
chmod 755 $RPM_BUILD_ROOT%{_prefix}/bin/c?9
%endif

# FIXME: cpp, gcov manpages names
pushd $RPM_BUILD_ROOT%{_mandir}/man1;
  if [[ -n "%{program_prefix}%{program_suffix}" ]]; then
    for f in gcov cpp gcc g++ gfortran gpc; do
      [[ -f "$f.1" ]] && mv $f.1 %{program_prefix}$f%{program_suffix}.1
    done
  fi
popd

# Fix info pages
if [[ "%{name}" = "gcc%{branch}" ]]; then
  cd $RPM_BUILD_ROOT%{_infodir}/
  for f in cpp cppinternals gcc gpc gpcs gfortran gnat-style gnat_rm gnat_ug gcj; do
    if [[ -f "$f.info" ]]; then
      perl -pe "/^START-INFO-DIR-ENTRY/ .. /^END-INFO-DIR-ENTRY/ and s/($f)/\${1}-%{branch}/ig" $f.info > ${f}-%{branch}.info
      rm -f $f.info
    fi
  done
  cd ..
fi

# Remove unpackaged files
rm -rf $RPM_BUILD_ROOT%{_prefix}/doc

# In case we are cross-compiling, don't bother to remake symlinks and
# don't let spec-helper when stripping files either
%if "%{name}" != "gcc"
export DONT_SYMLINK_LIBS=1
export DONT_STRIP=1
%endif

%if %{build_debug}
# Don't strip in debug mode
export DONT_STRIP=1
%endif

%if %{build_ada}
# gnatmake bash completion
install -d -m 755 $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
install -m 644 gnatmake.bash-completion $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/gnatmake
%endif

%if %{build_java}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/java/gcj-endorsed \
         $RPM_BUILD_ROOT%{_libdir}/gcj-%{version}/classmap.db.d
chmod 755 $RPM_BUILD_ROOT%{_datadir}/java/gcj-endorsed \
          $RPM_BUILD_ROOT%{_libdir}/gcj-%{version} \
          $RPM_BUILD_ROOT%{_libdir}/gcj-%{version}/classmap.db.d
touch $RPM_BUILD_ROOT%{_libdir}/gcj-%{version}/classmap.db

# check if gcj-dbtool hasn't been incorrectly relinked.  rh#165781
classmap_db=`LD_LIBRARY_PATH=$RPM_BUILD_ROOT%{_libdir}:$RPM_BUILD_ROOT/%{_lib} \
             $RPM_BUILD_ROOT%{_bindir}/gcj-dbtool%{program_suffix} -p`
case "$classmap_db" in
  # Which one of these 2 is right?
  %{_prefix}/lib/gcj-%{version}/classmap.db) ;;
  %{_libdir}/gcj-%{version}/classmap.db) ;;
  *) echo Unexpected gcj-dbtool%{program_suffix} -p output; exit 1 ;;
esac
%endif

%clean
#rm -rf $RPM_BUILD_ROOT

%post
/usr/sbin/update-alternatives --install %{_bindir}/%{cross_program_prefix}gcc %{cross_program_prefix}gcc %{_bindir}/%{program_prefix}gcc-%{version} %{alternative_priority}
[ -e %{_bindir}/%{cross_program_prefix}gcc ] || /usr/sbin/update-alternatives --auto %{cross_program_prefix}gcc

%postun
if [ ! -f %{_bindir}/%{cross_program_prefix}gcc-%{version} ]; then
  /usr/sbin/update-alternatives --remove %{cross_program_prefix}gcc %{_bindir}/%{program_prefix}gcc-%{version}
fi

%post colorgcc
/usr/sbin/update-alternatives --install %{_bindir}/gcc gcc %{_bindir}/%{program_prefix}colorgcc %(expr %{alternative_priority} + 50000)

%postun colorgcc
if [ ! -f %{_bindir}/colorgcc-%{version} ]; then
  /usr/sbin/update-alternatives --remove gcc %{_bindir}/colorgcc
  # /usr/sbin/update-alternatives silently ignores paths that don't exist
  /usr/sbin/update-alternatives --remove g++ %{_bindir}/colorgcc
  /usr/sbin/update-alternatives --remove gfortran %{_bindir}/colorgcc
  /usr/sbin/update-alternatives --remove gcj %{_bindir}/colorgcc
fi

%triggerin colorgcc -- %{name}-c++
/usr/sbin/update-alternatives --install %{_bindir}/g++ g++ %{_bindir}/colorgcc %(expr %{alternative_priority} + 50000) --slave %{_bindir}/c++ c++ %{_bindir}/colorgcc

%triggerpostun colorgcc -- %{name}-c++
if [ ! -f %{_bindir}/g++-%{version} ]; then
  /usr/sbin/update-alternatives --remove g++ %{_bindir}/colorgcc
fi

%triggerin colorgcc -- %{name}-gfortran
/usr/sbin/update-alternatives --install %{_bindir}/gfortran gfortran %{_bindir}/colorgcc %(expr %{alternative_priority} + 50000) --slave %{_bindir}/f95 f95 %{_bindir}/colorgcc

%triggerpostun colorgcc -- %{name}-gfortran
if [ ! -f %{_bindir}/gfortran-%{version} ]; then
  /usr/sbin/update-alternatives --remove gfortran %{_bindir}/colorgcc
fi

%triggerin colorgcc -- %{name}-java
/usr/sbin/update-alternatives --install %{_bindir}/gcj gcj %{_bindir}/colorgcc %(expr %{alternative_priority} + 50000)

%triggerpostun colorgcc -- %{name}-java
if [ ! -f %{_bindir}/gcj-%{version} ]; then
  /usr/sbin/update-alternatives --remove gcj %{_bindir}/colorgcc
fi

%if %{build_cxx}
%post c++
/usr/sbin/update-alternatives --install %{_bindir}/%{cross_program_prefix}g++ %{cross_program_prefix}g++ %{_bindir}/%{program_prefix}g++-%{version} %{alternative_priority} --slave %{_bindir}/%{cross_program_prefix}c++ %{cross_program_prefix}c++ %{_bindir}/%{program_prefix}g++-%{version}
[ -e %{_bindir}/%{cross_program_prefix}g++ ] || /usr/sbin/update-alternatives --auto %{cross_program_prefix}g++

%postun c++
if [ ! -f %{_bindir}/%{cross_program_prefix}g++-%{version} ]; then
  /usr/sbin/update-alternatives --remove %{cross_program_prefix}g++ %{_bindir}/%{program_prefix}g++-%{version}
fi
%endif

%if %{build_libstdcxx}
%post -n %{libstdcxx_name} -p /sbin/ldconfig
%postun -n %{libstdcxx_name} -p /sbin/ldconfig
%endif

%post -n %{libgcc_name} -p /sbin/ldconfig
%postun -n %{libgcc_name} -p /sbin/ldconfig

%post -n %{libmudflap_name} -p /sbin/ldconfig
%postun -n %{libmudflap_name} -p /sbin/ldconfig

%post cpp
/usr/sbin/update-alternatives --install %{_bindir}/%{cross_program_prefix}cpp %{cross_program_prefix}cpp %{_bindir}/%{program_prefix}cpp-%{version} %{alternative_priority} --slave /lib/%{cross_program_prefix}cpp %{cross_program_prefix}lib_cpp %{_bindir}/%{program_prefix}cpp-%{version}
[ -e %{_bindir}/%{cross_program_prefix}cpp ] || /usr/sbin/update-alternatives --auto %{cross_program_prefix}cpp

%postun cpp
if [ ! -f %{_bindir}/%{cross_program_prefix}cpp-%{version} ]; then
  /usr/sbin/update-alternatives --remove %{cross_program_prefix}cpp %{_bindir}/%{program_prefix}cpp-%{version}
fi

%if %{build_pascal}
%post gpc
/usr/sbin/update-alternatives --install %{_bindir}/gpc gpc %{_bindir}/%{program_prefix}gpc-%{version} %{alternative_priority} --slave %{_bindir}/gpidump gpidump %{_bindir}/%{program_prefix}gpidump-%{version}
[ -e %{_bindir}/gpc ] || /usr/sbin/update-alternatives --auto gpc

%postun gpc
if [ ! -f %{_bindir}/gpc-%{version} ]; then
  /usr/sbin/update-alternatives --remove gpc %{_bindir}/%{program_prefix}gpc-%{version}
fi
%endif

%if %{build_fortran}
%post gfortran
/usr/sbin/update-alternatives --install %{_bindir}/%{cross_program_prefix}gfortran %{cross_program_prefix}gfortran %{_bindir}/%{program_prefix}gfortran-%{version} %{alternative_priority} --slave %{_bindir}/f95 f95 %{_bindir}/%{program_prefix}gfortran-%{version}
[ -e %{_bindir}/%{cross_program_prefix}gfortran ] || /usr/sbin/update-alternatives --auto %{cross_program_prefix}gfortran

%postun gfortran
if [ ! -f %{_bindir}/%{cross_program_prefix}gfortran-%{version} ]; then
  /usr/sbin/update-alternatives --remove %{cross_program_prefix}gfortran %{_bindir}/%{program_prefix}gfortran-%{version}
fi
%endif

%if %{build_java}
%post java
/usr/sbin/update-alternatives --install %{_bindir}/gcj gcj %{_bindir}/gcj-%{version} %{alternative_priority}
[ -e %{_bindir}/gcj ] || /usr/sbin/update-alternatives --auto gcj
/usr/sbin/update-alternatives --install %{_bindir}/jdk-config jdk-config %{_bindir}/gcj-jdk-config-%{version} %{gcj_alternative_priority}

%postun java
if [ ! -f %{_bindir}/gcj-%{version} ]; then
  /usr/sbin/update-alternatives --remove gcj %{_bindir}/gcj-%{version}
fi
if [ ! -f %{_bindir}/gcj-jdk-config-%{version} ]; then
  /usr/sbin/update-alternatives --remove jdk-config %{_bindir}/gcj-jdk-config-%{version}
fi
%endif

%if %{build_java}
%post -n %{GCJ_TOOLS}
for app in %{gcj_alternative_programs}; do
  # Remove binaries if not alternativeszificated yet
  [ ! -L %{_bindir}/$app ] && /bin/rm -f %{_bindir}/$app
  # Build slaves list
  slaves="$slaves --slave %{_bindir}/$app $app %{_bindir}/$app-%{version}"
done
/usr/sbin/update-alternatives --install %{_bindir}/gij gij %{_bindir}/gij-%{version} %{gcj_alternative_priority} $slaves
%endif

%if %{build_java}
%postun -n %{GCJ_TOOLS}
if [ ! -f "%{_bindir}/gij-%{version}" ]; then
  /usr/sbin/update-alternatives --remove gij %{_bindir}/gij-%{version}
fi
%endif

%if %{build_java}
%post -n %{libgcj_name}-devel
/usr/sbin/update-alternatives --install %{_includedir}/libgcj libgcj %{_includedir}/libgcj-%{version} %{gcj_alternative_priority}
%endif

%if %{build_java}
%postun -n %{libgcj_name}-devel
if [ ! -d %{_includedir}/libgcj-%{version} ]; then
  /usr/sbin/update-alternatives --remove libgcj %{_includedir}/libgcj-%{version}
fi
%endif

%if %{build_java}
%post -n %{libgcj_name} -p /sbin/ldconfig
%postun -n %{libgcj_name} -p /sbin/ldconfig
%endif

%if %{build_objc}
%post -n %{libobjc_name} -p /sbin/ldconfig
%postun -n %{libobjc_name} -p /sbin/ldconfig
%endif

%if %{build_fortran}
%post -n %{libgfortran_name} -p /sbin/ldconfig
%postun -n %{libgfortran_name} -p /sbin/ldconfig
%endif

%if %{build_ada}
%post -n %{libgnat_name} -p /sbin/ldconfig
%postun -n %{libgnat_name} -p /sbin/ldconfig
%endif

%post doc
%_install_info gcc%{_package_suffix}.info
%_install_info cpp%{_package_suffix}.info
%if %{build_pascal}
%_install_info gpc%{_package_suffix}.info
%_install_info gpcs%{_package_suffix}.info
%endif
%if %{build_fortran}
%_install_info gfortran%{_package_suffix}.info
%endif
%if %{build_ada}
%_install_info gnat-style%{_package_suffix}.info
%_install_info gnat_rm%{_package_suffix}.info
%_install_info gnat_ug%{_package_suffix}.info
%endif
%if %{build_java}
%_install_info gcj%{_package_suffix}_ug.info
%endif

%preun doc
if [ "$1" = "0" ];then /sbin/install-info %{_infodir}/gcc%{_package_suffix}.info.bz2 --dir=%{_infodir}/dir --remove;fi;
%_remove_install_info cpp%{_package_suffix}.info
%if %{build_pascal}
%_remove_install_info gpc%{_package_suffix}.info
%_remove_install_info gpcs%{_package_suffix}.info
%endif
%if %{build_fortran}
%_remove_install_info gfortran%{_package_suffix}.info
%endif
%if %{build_ada}
%_remove_install_info gnat-style%{_package_suffix}.info
%_remove_install_info gnat_rm%{_package_suffix}.info
%_remove_install_info gnat_ug%{_package_suffix}.info
%endif
%if %{build_java}
%_remove_install_info gcj%{_package_suffix}.info
%endif

%files
%defattr(-,root,root)
#
%doc gcc/README* gcc/*ChangeLog*
%{_mandir}/man1/%{program_prefix}gcc%{program_suffix}.1*
%if "%{name}" == "gcc%{package_suffix}"
%{_mandir}/man1/gcov%{program_suffix}.1*
%endif
#
%{_bindir}/%{program_prefix}gcc%{branch}-version
%{_bindir}/%{program_prefix}gcc-%{version}
%{_bindir}/%{gcc_target_platform}-gcc%{program_suffix}
%if "%{name}" == "gcc%{package_suffix}"
%{_bindir}/protoize%{program_suffix}
%{_bindir}/unprotoize%{program_suffix}
%{_bindir}/gcov%{program_suffix}
%endif
%if %{system_compiler}
%{_bindir}/cc
%{_bindir}/c89
%{_bindir}/c99
%endif
#
%if !%{build_cross_bootstrap}
%{target_libdir}/libgcc_s.so
%endif
%if "%{name}" == "gcc%{package_suffix}"
%ifarch %{nof_arches}
%{_libdir}/nof/libgcc_s.so
%endif
%ifarch %{biarches}
%{_prefix}/lib/libgcc_s.so
%{_prefix}/lib/libgcc_s_32.so
%endif
%endif
#
%dir %{gcc_libdir}/%{gcc_target_platform}
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/collect2
%{gcc_libdir}/%{gcc_target_platform}/%{version}/crt*.o
%if "%{arch}" == "ppc"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/ecrt*.o
%{gcc_libdir}/%{gcc_target_platform}/%{version}/ncrt*.o
%endif
%if "%{arch}" == "ppc64"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/ecrt*.o
%{gcc_libdir}/%{gcc_target_platform}/%{version}/ncrt*.o
%endif
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcc.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcov.a
%if !%{build_cross_bootstrap}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcc_eh.a
%endif
%if "%{name}" == "gcc%{package_suffix}"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/SYSCALLS.c.X
%ifarch %{biarches}
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}/32
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/crt*.o
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgcc.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgcc_eh.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgcov.a
%endif
%ifarch %{nof_arches}
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}/nof
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/crt*.o
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/ecrt*.o
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgcc.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgcc_eh.a
%endif
%endif
#
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}/include
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/float.h
%if "%{arch}" == "i386"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/mm3dnow.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/mm_malloc.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/mmintrin.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/xmmintrin.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/pmmintrin.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/emmintrin.h
%endif
%if "%{arch}" == "x86_64"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/mm3dnow.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/mm_malloc.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/mmintrin.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/xmmintrin.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/pmmintrin.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/emmintrin.h
%endif
%if "%{arch}" == "ppc"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/spe.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/altivec.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/ppc-asm.h
%endif
%if "%{arch}" == "ppc64"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/spe.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/altivec.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/ppc-asm.h
%endif
%if "%{arch}" == "ia64"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/ia64intrin.h
%endif
%if "%{arch}" == "m68k"
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/math-68881.h
%endif
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/iso646.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/limits.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/stdarg.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/stdbool.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/stddef.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/syslimits.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/unwind.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/varargs.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/README

%if "%{name}" == "%{cross_prefix}gcc"
%files -n %{libgcc_name}
%defattr(-,root,root)
%if "%{name}" == "gcc%{package_suffix}"
/%{_lib}/libgcc_s-%{version}.so.%{libgcc_major}
/%{_lib}/libgcc_s.so.%{libgcc_major}
%ifarch %{biarches}
/lib/libgcc_s-%{version}.so.%{libgcc_major}
/lib/libgcc_s.so.%{libgcc_major}
%endif
%ifarch %{nof_arches}
/%{_lib}/nof/libgcc_s-%{version}.so.%{libgcc_major}
/%{_lib}/nof/libgcc_s.so.%{libgcc_major}
%endif
%endif
%if %{?build_cross:0}%{!?build_cross:1}
%{target_libdir}/libgcc_s-%{version}.so.%{libgcc_major}
%{target_libdir}/libgcc_s.so.%{libgcc_major}
%endif
%endif

%files -n %{libmudflap_name}
%defattr(-,root,root)
#
%{target_libdir}/libmudflap.so.%{libmudflap_major}
%{target_libdir}/libmudflap.so.%{libmudflap_major}.0.0
%{target_libdir}/libmudflapth.so.%{libmudflap_major}
%{target_libdir}/libmudflapth.so.%{libmudflap_major}.0.0
%ifarch %{biarches}
%{_prefix}/lib/libmudflap.so.%{libmudflap_major}
%{_prefix}/lib/libmudflap.so.%{libmudflap_major}.0.0
%{_prefix}/lib/libmudflapth.so.%{libmudflap_major}
%{_prefix}/lib/libmudflapth.so.%{libmudflap_major}.0.0
%endif

%files -n %{libmudflap_name}-devel
%defattr(-,root,root)
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/mf-runtime.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libmudflap.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libmudflap.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libmudflapth.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libmudflapth.so
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libmudflap.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libmudflap.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libmudflapth.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libmudflapth.so
%endif

%files cpp
%defattr(-,root,root)
#
%{_mandir}/man1/%{program_prefix}cpp%{program_suffix}.1*
#
/lib/cpp
%ghost %{_bindir}/%{cross_program_prefix}cpp
%{_bindir}/%{program_prefix}cpp-%{version}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/cc1

%if %{build_cxx}
%files c++
%defattr(-,root,root)
#
%doc gcc/cp/ChangeLog*
%{_mandir}/man1/%{program_prefix}g++%{program_suffix}.1*
#
%ghost %{_bindir}/%{cross_program_prefix}c++
%{_bindir}/%{program_prefix}g++-%{version}
%{_bindir}/%{program_prefix}c++-%{version}
%{_bindir}/%{gcc_target_platform}-g++%{program_suffix}
%{_bindir}/%{gcc_target_platform}-c++%{program_suffix}
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/cc1plus
# symlinks to gcc3.4 stuff
%if !%{system_compiler}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/cxxabi.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/bits/cxxabi_tweaks.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libstdc++.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libsupc++.a
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libstdc++.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libsupc++.a
%endif
%endif
%endif

%if %{build_libstdcxx}
%files -n %{libstdcxx_name}
%defattr(-,root,root)
%{target_libdir}/libstdc++.so.%{libstdcxx_major}
%{target_libdir}/libstdc++.so.%{libstdcxx_major}.0.%{libstdcxx_minor}
%ifarch %{biarches}
%{_prefix}/lib/libstdc++.so.%{libstdcxx_major}
%{_prefix}/lib/libstdc++.so.%{libstdcxx_major}.0.%{libstdcxx_minor}
%endif
%ifarch %{nof_arches}
%dir %{_libdir}/nof
%{_libdir}/nof/libstdc++.so.%{libstdcxx_major}
%{_libdir}/nof/libstdc++.so.%{libstdcxx_major}.0.%{libstdcxx_minor}
%endif
%endif

%if %{build_libstdcxx}
%files -n %{libstdcxx_name}-devel
%defattr(-,root,root)
#
%doc libstdc++-v3/ChangeLog* libstdc++-v3/README* libstdc++-v3/docs/html/
#
%dir %{libstdcxx_includedir}
%{libstdcxx_includedir}/*
%if %{system_compiler}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/cxxabi.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/bits/cxxabi_tweaks.h
%endif
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libstdc++.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libsupc++.a
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libstdc++.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libsupc++.a
%endif
%ifarch %{nof_arches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libstdc++.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libsupc++.a
%endif
%endif

%if %{build_libstdcxx}
%files -n %{libstdcxx_name}-static-devel
%defattr(-,root,root)
%doc libstdc++-v3/README
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libstdc++.a
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libstdc++.a
%endif
%ifarch %{nof_arches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libstdc++.a
%endif
%endif

%if %{build_objc}
%files objc
%defattr(-,root,root)
#
%doc rpm.doc/objc/*
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/cc1obj
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libobjc.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libobjc.so
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libobjc.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libobjc.so
%endif
%ifarch %{nof_arches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libobjc.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libobjc.so
%endif
#
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}/include/objc
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/objc/*.h
%endif

%if %{build_objc}
%files -n %{libobjc_name}
%defattr(-,root,root)
#
%doc rpm.doc/libobjc/*
%doc libobjc/THREADS* libobjc/ChangeLog
#
%{target_libdir}/libobjc.so.%{libobjc_major}
%{target_libdir}/libobjc.so.%{libobjc_major}.0.0
%ifarch %{biarches}
%{_prefix}/lib/libobjc.so.%{libobjc_major}
%{_prefix}/lib/libobjc.so.%{libobjc_major}.0.0
%endif
%endif

%if %{build_pascal}
%files gpc
%defattr(-,root,root)
#
%doc rpm.doc/gpc/*
%{_mandir}/man1/%{program_prefix}gpc%{program_suffix}.1*
%{_mandir}/man1/%{program_prefix}/gpc-run%{program_suffix}.1*
#
%{_bindir}/gpc-run
%{_bindir}/binobj
%ghost %{_bindir}/gpc
%ghost %{_bindir}/gpidump
%{_bindir}/%{program_prefix}gpc-%{version}
%{_bindir}/%{program_prefix}gpidump-%{version}
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/gpc1
%{gcc_libdir}/%{gcc_target_platform}/%{version}/gpcpp
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgpc.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/gpc-in-c.h
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}/units
%{gcc_libdir}/%{gcc_target_platform}/%{version}/units/*.c
%{gcc_libdir}/%{gcc_target_platform}/%{version}/units/*.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/units/*.s
%{gcc_libdir}/%{gcc_target_platform}/%{version}/units/*.inc
%{gcc_libdir}/%{gcc_target_platform}/%{version}/units/*.pas
%endif

%if %{build_fortran}
%files gfortran
%defattr(-,root,root)
#
%doc rpm.doc/gfortran/*
%{_mandir}/man1/%{program_prefix}gfortran%{program_suffix}.1*
#
%ghost %{_bindir}/gfortran
%ghost %{_bindir}/f95
%{_bindir}/%{program_prefix}gfortran-%{version}
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/f951
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgfortranbegin.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgfortran.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgfortran.so
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgfortranbegin.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgfortran.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgfortran.so
%endif
%ifarch %{nof_arches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgfortran.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgfortran.so
%endif
%endif

%if %{build_fortran}
%files -n %{libgfortran_name}
%defattr(-,root,root)
#
%{target_libdir}/libgfortran.so.%{libgfortran_major}
%{target_libdir}/libgfortran.so.%{libgfortran_major}.0.0
%ifarch %{biarches}
%{_prefix}/lib/libgfortran.so.%{libgfortran_major}
%{_prefix}/lib/libgfortran.so.%{libgfortran_major}.0.0
%endif
%endif

%if %{build_java}
%files java
%defattr(-,root,root)
%doc gcc/java/ChangeLog*
%{_bindir}/gcj-%{version}
%{_bindir}/gcj-jdk-config-%{version}
%ghost %{_bindir}/jdk-config
%{gcc_libdir}/%{gcc_target_platform}/%{version}/jc1
%{gcc_libdir}/%{gcc_target_platform}/%{version}/jvgenmain
%{_mandir}/man1/%{program_prefix}gcj%{program_suffix}.1*
%endif

%if %{build_java}
%files -n %{GCJ_TOOLS}
%defattr(-,root,root)
%doc rpm.doc/fastjar/*
%{_bindir}/gij-%{version}
%{_bindir}/fastjar-%{version}
%{_bindir}/grepjar-%{version}
%{_bindir}/grmic-%{version}
%{_bindir}/grmiregistry-%{version}
%ghost %{_bindir}/gij
%ghost %{_bindir}/fastjar
%ghost %{_bindir}/grepjar
%ghost %{_bindir}/grmic
%ghost %{_bindir}/grmiregistry
%{_bindir}/gcj-dbtool%{program_suffix}
%{_bindir}/gcjh%{program_suffix}
%{_bindir}/gjnih%{program_suffix}
%{_bindir}/jcf-dump%{program_suffix}
%{_bindir}/jv-scan%{program_suffix}
#
%{_mandir}/man1/fastjar*.1*
%{_mandir}/man1/grepjar*.1*
%{_mandir}/man1/gij*.1*
%{_mandir}/man1/gcjh*.1*
%{_mandir}/man1/gjnih*.1*
%{_mandir}/man1/grmic*.1*
%{_mandir}/man1/grmiregistry*.1*
%{_mandir}/man1/gcj-dbtool*.1*
%{_mandir}/man1/jv-scan*.1*
%{_mandir}/man1/jcf-dump*.1*
#
%dir %{_libdir}/gcj-%{version}
%dir %{_libdir}/gcj-%{version}/classmap.db.d
%attr(0644,root,root) %verify(not md5 size mtime) %ghost %config(missingok,noreplace) %{_libdir}/gcj-%{version}/classmap.db
%endif

%if %{build_java}
%files -n %{libgcj_name}
%defattr(-,root,root)
%{target_libdir}/libgcj.so.%{libgcj_major}
%{target_libdir}/libgcj.so.%{libgcj_major}.0.0
%{target_libdir}/libgij.so.%{libgcj_major}
%{target_libdir}/libgij.so.%{libgcj_major}.0.0
%{target_libdir}/libgcjawt.so.%{libgcj_major}
%{target_libdir}/libgcjawt.so.%{libgcj_major}.0.0
%{target_libdir}/lib-gnu-java-awt-peer-gtk.so.%{libgcj_major}
%{target_libdir}/lib-gnu-java-awt-peer-gtk.so.%{libgcj_major}.0.0
# XXX: temporary, until they lays in their own place (or patch to look into $FULLPATH/)
%{target_libdir}/lib-gnu-java-awt-peer-gtk.la
%ifarch %{biarches}
%if %{biarch_java}
%{_prefix}/lib/libgcj.so.%{libgcj_major}
%{_prefix}/lib/libgcj.so.%{libgcj_major}.0.0
%{_prefix}/lib/libgij.so.%{libgcj_major}
%{_prefix}/lib/libgij.so.%{libgcj_major}.0.0
%{_prefix}/lib/libgcjawt.so.%{libgcj_major}
%{_prefix}/lib/libgcjawt.so.%{libgcj_major}.0.0
%{_prefix}/lib/lib-gnu-java-awt-peer-gtk.so.%{libgcj_major}
%{_prefix}/lib/lib-gnu-java-awt-peer-gtk.so.%{libgcj_major}.0.0
%endif
%endif
%endif

%if %{build_java}
%files -n %{libgcj_name_base}-base
%defattr(-,root,root)
%dir %{_datadir}/java
%{_datadir}/java/[^s]*
%{_datadir}/java/libgcj-%{version}.jar
%dir %{_prefix}/lib/security
%config(noreplace) %{_prefix}/lib/security/*.security
%dir %{_prefix}/lib/gcj-%{version}
%{_prefix}/lib/gcj-%{version}/*.db
%{_prefix}/lib/logging.properties
%endif

%if %{build_java}
%files -n %{libgcj_name}-devel
%defattr(-,root,root)
#
%doc rpm.doc/boehm-gc/*
%doc rpm.doc/libjava/*
#
%{_bindir}/jv-convert%{program_suffix}
#
%{_libdir}/pkgconfig/libgcj.pc
%ifarch %{biarches}
%{_prefix}/lib/pkgconfig/libgcj.pc
%endif
#
%ghost %{_includedir}/libgcj
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/gcj
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/libgcj
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/jni.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/jvmpi.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/jawt.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/jawt_md.h
#
%dir %{libjava_includedir}
%dir %{libjava_includedir}/gcj
%{libjava_includedir}/gcj/*.h
%dir %{libjava_includedir}/gnu
%{libjava_includedir}/gnu/*
%dir %{libjava_includedir}/java
%{libjava_includedir}/java/*
%dir %{libjava_includedir}/javax
%{libjava_includedir}/javax/*
%dir %{libjava_includedir}/org
%{libjava_includedir}/org/*
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcj.spec
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcj.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgij.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcjawt.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/lib-gnu-java-awt-peer-gtk.so
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgcj.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgij.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgcjawt.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/lib-gnu-java-awt-peer-gtk.so
%endif
%ifarch %{nof_arches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgcj.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgij.so
%endif
%endif

%if %{build_java}
%files -n %{libgcj_name}-static-devel
%defattr(-,root,root)
%doc libjava/README libjava/LIBGCJ_LICENSE
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcj.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgij.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/libgcjawt.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/lib-gnu-java-awt-peer-gtk.a
%ifarch %{biarches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgcj.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgij.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/libgcjawt.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/32/lib-gnu-java-awt-peer-gtk.a
%endif
%ifarch %{nof_arches}
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgcj.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/nof/libgij.a
%endif
%endif

%if %{build_java}
%files -n %{libgcj_name_base}-src
%defattr(-,root,root)
%dir %{_datadir}/java
%{_datadir}/java/src*.zip
%endif

%if %{build_ada}
%files gnat
%defattr(-,root,root)
#
%{_bindir}/gprmake
%{_bindir}/gnat*
%config(noreplace) %{_sysconfdir}/bash_completion.d/gnatmake
#
%{gcc_libdir}/%{gcc_target_platform}/%{version}/gnat1
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}/adainclude
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adainclude/*.adb
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adainclude/*.ads
%dir %{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/*.ali
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/g-trasym.o
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgccprefix.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgmem.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgnat.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgnat.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgnat-%{branch}.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgnarl.a
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgnarl.so
%{gcc_libdir}/%{gcc_target_platform}/%{version}/adalib/libgnarl-%{branch}.so
%endif

%if %{build_libffi}
%files -n %{libffi_name}-devel
%defattr(-,root,root)
%doc libffi/README libffi/LICENSE libffi/ChangeLog*
%{_includedir}/ffi*.h
%{gcc_libdir}/%{gcc_target_platform}/%{version}/include/libffi/ffitarget.h
%{_libdir}/libffi.a
%ifarch %{biarches}
%{_prefix}/lib/libffi.a
%endif
%endif

%if %{build_ada}
%files -n %{libgnat_name}
%defattr(-,root,root)
#
%{target_libdir}/libgnat-*.so.*
%{target_libdir}/libgnarl-*.so.*
%ifarch %{biarches}
# FIXME: no biarch ada yet
#%{_prefix}/lib/libgnat-*.so.*
#%{_prefix}/lib/libgnarl-*.so.*
%endif
%endif

%if %{build_colorgcc}
%files colorgcc
%defattr (-,root,root)
%doc COPYING.colorgcc CREDITS.colorgcc ChangeLog.colorgcc
%config(noreplace) %{_sysconfdir}/colorgccrc
%{_bindir}/colorgcc
%{_bindir}/colorgcc-%{version}
%endif

%if %{build_doc}
%files doc
%defattr(-,root,root)
%{_infodir}/cppinternals%{_package_suffix}.info*
%{_infodir}/cpp%{_package_suffix}.info*
%{_infodir}/gcc%{_package_suffix}.info*
%if %{build_ada}
%{_infodir}/gnat-style%{_package_suffix}.info*
%{_infodir}/gnat_rm%{_package_suffix}.info*
%{_infodir}/gnat_ug%{_package_suffix}.info*
%endif
%if %{build_java}
%{_infodir}/gcj%{_package_suffix}.info*
%endif
%if %{build_pascal}
%{_infodir}/gpc%{_package_suffix}.info*
%{_infodir}/gpcs%{_package_suffix}.info*
%endif
%if %{build_fortran}
%{_infodir}/gfortran%{_package_suffix}.info*
%endif
%endif

%if %{build_pdf_doc}
%files doc-pdf
%defattr(-,root,root)
%doc gcc/doc/cppinternals.pdf
%doc gcc/doc/gcc.pdf
%doc gcc/doc/cpp.pdf
%if %{build_ada}
%doc gcc/ada/gnat_rm.pdf
%doc gcc/ada/gnat_ug.pdf
%endif
%if %{build_fortran}
%doc gcc/fortran/gfortran.pdf
%endif
%endif

%changelog
* Thu Sep  1 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.1-5mdk
- merge libjava from 4.0-rhl-branch
- make gcjh generate arch-independent code for 0x80000000
- add fastjar and grepjar man pages
- don't move <gcj/libgcj-config.h> around
- stick to /usr/share/java-ext dir for jpackage existing practise
- remove duplicated files, create a libgcjX-base package for classes
- fix possible reloads into read-only memory (4.0-branch, PR rtl-opt/15248)

* Mon Aug 29 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.1-4mdk
- build the cairo Graphics2D implementation on GTK (backport from 4.1)
- ship with biarch c++config.h headers
- mklibnamize java libs package, aka don't depend on huge 32-bit runtime
- fix kopete miscompilation on x86_64 (Richard Guenther, PR tree-opt/23326)
- merge from RH 4.0.1-10:
  * more testcases
  * support more than 16 nested GCC visibility pragmas (H.J.Lu)
  * fix linker command line ordering when compiling multiple java
    source files (Tom Tromey, #163099)
  * diagnose invalid uses of inline (Eric Christopher, PRs c/22052, c/21975)
  * fix __builtin_*_chk miscompilation (PR middle-end/23484)
- merge some java related changes from David Walluck:
  * add missing java files
  * don't add gcj- prefix to tools
  * java-1.4.2-gcj-compat now handles java and javac wrappers
  * fix libgcj alternative removal
  * ship with Java runtime library sources for use in Eclipse
  * ship with libgcjawt instead of jawt commonly used in non-free JVMs

* Sun Aug 26 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.1-3mdk
- updates from 4.0-branch (2005/08/26):
  * fix -dv option handling
  * fix documentation for -ftree-dominator-opts
  * fix PRs rtl-opt/23560, tree-optimization/23546, middle-end/23517,
    target/21571, target/23070, c/18175, middle-end/20624, c/21562,
    rtl-opt/21254, c++/23337, tree-optimization/21105, rtl-opt/23299,
    middle-end/23369, middle-end/23312, middle-end/22439,
    rtl-opt/23241, middle-end/21894, middle-end/21728,
    middle-end/21529, middle-end/21291, c++/20817, c++/22454,
    c++/23044, tree-optimization/23426, c++/22233, c++/23089,
    c++/21799, c++/8271, c++/23266, c++/23219, c++/20646, c++/22508,
    c++/23191, fortran/20363, fortran/23065, fortran/21432,
    libfortran/20006, libfortran/22143, fortran/18833, fortran/20850,
    fortran/22010, java/17845, java/21436, java/23230,
    libfortran/23154, libfortran/23428, libgcj/21020, libgcj/21074,
    libgcj/23353, libstdc++/23465, libstdc++/23550

* Thu Aug  4 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.1-2mdk
- add Red Hat Fortify extensions
- updates from 4.0-branch (2005/08/04):
  * aliasing bug fixes (tree-opt/23192, tree-opt/22591)
  * fix PRs tree-opt/19899, c/22311, rtl-opt/22619, middle-end/21362,
    debug/20161, c++/22545, fortran/22503, libfortran/23178,
    fortran/22570 et al.

* Tue Jul 26 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.1-1mdk
- 4.0.1 + updates from 4.0-branch (CVS 2005/07/26)
  * Fix PRs debug/21828, target/21149, target/22576,
    rtl-optimization/22167, tree-opt/22278, target/21721,
    middle-end/22057, c/22421, middle-end/20593, tree-opt/22105,
    middle-end/22028, debug/21946, debug/21946, middle-end/17961,
    target/22083, c/21911, c/22308, c/22013, c/22098, c++/22263,
    c++/22139, c++/22204, c++/22132, c++/20637, c++/20678, c++/21903,
    c++/20789, c++/21929, c++/20746, c++/10611, c++/20563

* Mon Jun  6 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.1-0.2mdk
- 4.0.1 (CVS 2005/06/06)
- description tweaks
- buildrequires gawk >= 3.1.4
- build ada on ia64
- fix build on ppc with nof libs (Christiaan)
- fix build on ppc64 and make it a biarch compiler too (3.3-branch)
- remove obsolete RH compatibility code with "2.96"

* Thu Jun  2 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.1-0.1mdk
- 4.0.1 (CVS 2005/06/01)
- obsoletes gcc-g77, improve post scriptlets
- fix internal build of ada for the testsuite
- fix build on x86_64 without biarch awt peers
- add missing MMX & 3D Now! intrinsics headers

* Wed May  4 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.0-3mdk
- rebuild as system compiler
- don't build 32-bit awt/gtk peer on lib64 platforms
- make /usr/lib/security/*.security %%config(noreplace)

* Mon May  2 2005 Gwenole Beauchesne <gbeauchesne@mandriva.com> 4.0.0-2mdk
- ship with mudflap libs
- buildrequires: libgmp-devel for gfortran
- enable java with some changes:
  * add missing security and database files
  * add current directory in classpath if empty
  * handle java -jar JARFILE in the wrapper script
- updates from 4.0-branch as of 2005/05/02:
  * really inline memcpy with -minline-all-stringops (fix etherboot build)
  * fix kernel miscompilation (PR tree-optimization/21173)
  * more tweaks to <tr1/type_traits> (issue 3.20)
  * fix PRs ada/18847, c++/19542, rtl-optimization/21144,
    target/21098, java/21022, c/21159, c/21213, c/20740,
    rtl-optimization/21163, middle-end/20991, target/21101, c++/21087,
    middle-end/20991, fortran/13082, fortran/18824, fortran/16861,
    fortran/20865, fortran/21177, fortran/20879, fortran/20059,
    java/21115, java/20768, libgfortran/20950, libgcj/21136,
    libgcj/21233, libstdc++/21286, libstdc++/21244, libstdc++/21035,
    libstdc++/20914

* Tue Apr 26 2005 Gwenole Beauchesne <gbeauchesne@mandrva.com> 4.0.0-1mdk
- add missing <bits/cxxabi_tweaks.h>
- don't obsolete g77 packages as they may still be there for now
- further visibility fixes for KDE 3.4 on x86-64
- 4.0 release + updates from 4.0-branch as of 2005/04/24:
  * fix PRs rtl-opt/21102, target/21100, target/21099, c++/20805,
    middle-end/20973, c/12913, fortran/14569
- merge with gcc3.4 package:
  * fix javac wrapper script for automake1.9 testsuite (Christiaan)
  * fix libgcj pkgconfig files to look for gcj includes at the right place
  * avoid installing gcc into /usr/lib64 so that existing ways to generate
    libtool scripts can cope with 32-bit development on 64-bit platforms
  * unset TEXINPUTS when building PDF docs (G. Rousse)
  * disable 64-bit code generation if running under a 32-bit personality
  * temporarily disable libffi/java on sparc, sparc64 (Per Oyvind Karlsen)

* Thu Apr 14 2005 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com> 4.0.0-0.4mdk
- add fortran 95 front-end, they are now called gfortran and f95

* Thu Apr 14 2005 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com> 4.0.0-0.3mdk
- update from CVS (2005/04/14)

* Wed Dec 29 2004 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com> 4.0.0-0.2mdk
- update from CVS (2004/12/28)
- make libstdc++.so symlink less sensitive to future changes from 3.4

* Fri Sep 10 2004 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com> 4.0.0-0.1mdk
- Renamed to 4.0.0 (2004/09/10)

* Tue Jul  6 2004 Gwenole Beauchesne <gbeauchesne@mandrakesoft.com> 3.5.0-0.1mdk
- First Preview Release for Mandrakelinux

# Local Variables:
# tab-width: 8
# End: