[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Fedora and Cross Compiling



On Wed, Jun 27, 2007 at 03:59:55PM +0200, Ralf Corsepius wrote:

> > There's a couple of issues:
> > - There's also two issues with building libstdc++ -
> 
> >  ... it install target installs various target files
> >   not in the sysroot but in the host's directory space.
> 
> --enable-version-specific-runtime-libs

Thanks, that worked.

Here is a new version of the Fedora -> Fedora gcc cross patch.  It
results in a working C/C++ cross compiler (at least, it manages to
cross-compile several programs for ARM, and manages to cross-compile
a native ARM gcc from sources.)

There's a couple of issues left:
- The current cross-libgcc and cross-libstdc++ packages put their
  libraries in the sysroot (/usr/%{target}/sys-root), since they
  are target libraries, but this might collide with installed
  native versions of the same packages down the road.
- rpm's %ifarch handling doesn't go together with cross-compiling
  very well, neither does handling of macros such as %{__strip},
  %{__objdump}.  Find a proper solution for this.

Again, I don't know whether adding cross support to the main gcc
package is the best idea.  Maybe splitting the cross bits out into
a separate source package is a better option, I'm not sure.

Comments?  Ideas?


Index: SPECS/gcc41.spec
===================================================================
--- SPECS.orig/gcc41.spec
+++ SPECS/gcc41.spec
@@ -1,9 +1,25 @@
+%if "%{?gcc_target}" == ""
+%define gcc_target %{_target_platform}
+%define isnative 1
+%else
+%define isnative 0
+%define cross %{gcc_target}-
+%define __strip %{gcc_target}-strip
+%endif
+
 %define DATE 20070503
 %define gcc_version 4.1.2
 %define gcc_release 12
 %define _unpackaged_files_terminate_build 0
-%define multilib_64_archs sparc64 ppc64 s390x x86_64
 %define include_gappletviewer 1
+%if !%{isnative}
+%define build_ada 0
+%define build_fortran 0
+%define build_java 0
+%define build_objc 0
+%define run_tests 0
+%else
+%define multilib_64_archs sparc64 ppc64 s390x x86_64
 %ifarch %{ix86} x86_64 ia64 ppc alpha
 %define build_ada 1
 %else
@@ -25,8 +41,9 @@
 %ifarch x86_64
 %define multilib_32_arch i386
 %endif
+%endif
 Summary: Various compilers (C, C++, Objective-C, Java, ...)
-Name: gcc
+Name: %{?cross}gcc
 Version: %{gcc_version}
 Release: %{gcc_release}.fa1
 License: GPL
@@ -44,7 +61,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version
 # Need binutils which support --hash-style=gnu >= 2.17.50.0.2-7
 # Need binutils which support mffgpr and mftgpr >= 2.17.50.0.2-8
 # Need binutils which support 2-argument .movsp >= 2.17.50.0.5
-BuildRequires: binutils >= 2.17.50.0.5
+BuildRequires: %{?cross}binutils >= 2.17.50.0.5
 BuildRequires: zlib-devel, gettext, dejagnu, bison, flex, texinfo, sharutils
 %if %{build_java}
 BuildRequires: gcc-java, libgcj, /usr/share/java/eclipse-ecj.jar, zip, unzip
@@ -52,7 +69,7 @@ BuildRequires: gcc-java, libgcj, /usr/sh
 # Make sure pthread.h doesn't contain __thread tokens
 # Make sure glibc supports stack protector
 # Make sure glibc supports DT_GNU_HASH
-BuildRequires: glibc-devel >= 2.4.90-13
+BuildRequires: %{?cross}glibc-devel >= 2.4.90-13
 BuildRequires: elfutils-devel >= 0.72
 %ifarch ppc ppc64 s390 s390x sparc sparcv9 alpha
 # Make sure glibc supports TFmode long double
@@ -69,7 +86,7 @@ BuildRequires: gcc-gnat >= 3.1, libgnat 
 %ifarch ia64
 BuildRequires: libunwind >= 0.98
 %endif
-Requires: cpp = %{version}-%{release}
+Requires: %{?cross}cpp = %{version}-%{release}
 # Need .eh_frame ld optimizations
 # Need proper visibility support
 # Need -pie support
@@ -80,25 +97,29 @@ Requires: cpp = %{version}-%{release}
 # Need binutils that supports --hash-style=gnu
 # Need binutils that support mffgpr/mftgpr
 # Need binutils that support 2-argument .movsp >= 2.17.50.0.5
-Requires: binutils >= 2.17.50.0.5
+Requires: %{?cross}binutils >= 2.17.50.0.5
 # Make sure gdb will understand DW_FORM_strp
-Conflicts: gdb < 5.1-2
-Requires: glibc-devel >= 2.2.90-12
+Conflicts: %{?cross}gdb < 5.1-2
+Requires: %{?cross}glibc-devel >= 2.2.90-12
 %ifarch ppc ppc64 s390 s390x sparc sparcv9 alpha
 # Make sure glibc supports TFmode long double
-Requires: glibc >= 2.3.90-35
+Requires: %{?cross}glibc >= 2.3.90-35
 %endif
-Requires: libgcc >= %{version}-%{release}
+Requires: %{?cross}libgcc >= %{version}-%{release}
+%if %{isnative}
 Requires: libgomp = %{version}-%{release}
+%endif
+%if %{isnative}
 Obsoletes: gcc3
 Obsoletes: egcs
+%endif
 %ifarch sparc
-Obsoletes: gcc-sparc32
-Obsoletes: gcc-c++-sparc32
+Obsoletes: %{?cross}gcc-sparc32
+Obsoletes: %{?cross}gcc-c++-sparc32
 %endif
 %ifarch ppc
-Obsoletes: gcc-ppc32
-Obsoletes: gcc-c++-ppc32
+Obsoletes: %{?cross}gcc-ppc32
+Obsoletes: %{?cross}gcc-c++-ppc32
 %endif
 Obsoletes: gcc-chill
 %if !%{build_ada}
@@ -160,6 +181,7 @@ Patch40: gcc41-unbreak-armv4t.patch
 %ifnarch %{arm}
 %define _gnu %{nil}
 %endif
+%if "%{?gcc_target}" == ""
 %ifarch sparc
 %define gcc_target_platform sparc64-%{_vendor}-%{_target_os}
 %endif
@@ -169,30 +191,33 @@ Patch40: gcc41-unbreak-armv4t.patch
 %ifnarch sparc ppc
 %define gcc_target_platform %{_target_platform}
 %endif
+%else
+%define gcc_target_platform %{gcc_target}
+%endif
 
 %description
 The gcc package contains the GNU Compiler Collection version 4.1.
 You'll need this package in order to compile C code.
 
-%package -n libgcc
+%package -n %{?cross}libgcc
 Summary: GCC version 4.1 shared support library
 Group: System Environment/Libraries
 Autoreq: false
 
-%description -n libgcc
+%description -n %{?cross}libgcc
 This package contains GCC shared support library which is needed
 e.g. for exception handling support.
 
 %package c++
 Summary: C++ support for GCC
 Group: Development/Languages
-Requires: gcc = %{version}-%{release}
-Requires: libstdc++ = %{version}-%{release}
-Requires: libstdc++-devel = %{version}-%{release}
-Obsoletes: gcc3-c++
-Obsoletes: gcc34-c++
-Obsoletes: gcc35-c++
-Obsoletes: gcc4-c++
+Requires: %{?cross}gcc = %{version}-%{release}
+Requires: %{?cross}libstdc++ = %{version}-%{release}
+Requires: %{?cross}libstdc++-devel = %{version}-%{release}
+Obsoletes: %{?cross}gcc3-c++
+Obsoletes: %{?cross}gcc34-c++
+Obsoletes: %{?cross}gcc35-c++
+Obsoletes: %{?cross}gcc4-c++
 Autoreq: true
 
 %description c++
@@ -200,26 +225,26 @@ This package adds C++ support to the GNU
 It includes support for most of the current C++ specification,
 including templates and exception handling.
 
-%package -n libstdc++
+%package -n %{?cross}libstdc++
 Summary: GNU Standard C++ Library
 Group: System Environment/Libraries
-Obsoletes: libstdc++3
-Obsoletes: libstdc++34
+Obsoletes: %{?cross}libstdc++3
+Obsoletes: %{?cross}libstdc++34
 Autoreq: true
 
-%description -n libstdc++
+%description -n %{?cross}libstdc++
 The libstdc++ package contains a rewritten standard compliant GCC Standard
 C++ Library.
 
-%package -n libstdc++-devel
+%package -n %{?cross}libstdc++-devel
 Summary: Header files and libraries for C++ development
 Group: Development/Libraries
-Requires: libstdc++ = %{version}-%{release}, %{_prefix}/%{_lib}/libstdc++.so.6
-Obsoletes: libstdc++3-devel
+Requires: %{?cross}libstdc++ = %{version}-%{release}, %{_prefix}/%{_lib}/libstdc++.so.6
+Obsoletes: %{?cross}libstdc++3-devel
 Obsoletes: libstdc++34-devel
 Autoreq: true
 
-%description -n libstdc++-devel
+%description -n %{?cross}libstdc++-devel
 This is the GNU implementation of the standard C++ libraries.  This
 package includes the header files and libraries needed for C++
 development. This includes rewritten implementation of STL.
@@ -382,7 +407,7 @@ Autoreq: true
 %description -n libgcj-src
 The Java(tm) runtime library sources for use in Eclipse.
 
-%package -n cpp
+%package -n %{?cross}cpp
 Summary: The C Preprocessor.
 Group: Development/Languages
 Prereq: /sbin/install-info
@@ -391,7 +416,7 @@ Obsoletes: gnupro
 %endif
 Autoreq: true
 
-%description -n cpp
+%description -n %{?cross}cpp
 Cpp is the GNU C-Compatible Compiler Preprocessor.
 Cpp is a macro processor which is used automatically
 by the C compiler to transform your program before actual
@@ -583,6 +608,7 @@ case "$OPT_FLAGS" in
       ../gcc/Makefile.in
     ;;
 esac
+%if %{isnative}
 CC="$CC" CFLAGS="$OPT_FLAGS" CXXFLAGS="$OPT_FLAGS" XCFLAGS="$OPT_FLAGS" TCFLAGS="$OPT_FLAGS" \
 	GCJFLAGS="$OPT_FLAGS" \
 	../configure --prefix=%{_prefix} --mandir=%{_mandir} --infodir=%{_infodir} \
@@ -663,6 +689,20 @@ rm -rf testlogs-%{_target_platform}-%{ve
 
 # Make protoize
 make -C gcc CC="./xgcc -B ./ -O2" proto
+%else
+CC="$CC" CFLAGS="-O2 -g" CXXFLAGS="-O2 -g" XCFLAGS="-O2 -g" TCFLAGS="-O2 -g" \
+	GCJFLAGS="-O2 -g" \
+	../configure --prefix=%{_prefix} --mandir=%{_mandir} \
+	--infodir=%{_infodir} --enable-shared --enable-threads=posix \
+	--enable-checking=release --with-system-zlib --enable-__cxa_atexit \
+	--disable-libunwind-exceptions --enable-languages=c,c++ \
+	--disable-libgcj --disable-libssp --disable-libgomp \
+	--disable-libmudflap --with-sysroot=yes \
+	--enable-version-specific-runtime-libs \
+	--target=%{gcc_target_platform}
+
+GCJFLAGS="-O2 -g" make %{?_smp_mflags} BOOT_CFLAGS="-O2 -g"
+%endif
 
 # Make generated man pages even if Pod::Man is not new enough
 perl -pi -e 's/head3/head2/' ../contrib/texi2pod.pl
@@ -730,8 +770,6 @@ fi
 export PATH=`pwd`/java_hacks${PATH:+:$PATH}
 %endif
 
-TARGET_PLATFORM=%{gcc_target_platform}
-
 # There are some MP bugs in libstdc++ Makefiles
 make -C %{gcc_target_platform}/libstdc++-v3
 
@@ -748,15 +786,19 @@ FULLPATH=$RPM_BUILD_ROOT%{_prefix}/lib/g
 FULLEPATH=$RPM_BUILD_ROOT%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}
 
 # fix some things
+%if %{isnative}
 ln -sf gcc $RPM_BUILD_ROOT%{_prefix}/bin/cc
 mkdir -p $RPM_BUILD_ROOT/lib
 ln -sf ..%{_prefix}/bin/cpp $RPM_BUILD_ROOT/lib/cpp
+%endif
 %if %{build_fortran}
 ln -sf gfortran $RPM_BUILD_ROOT%{_prefix}/bin/f95
 %endif
 rm -f $RPM_BUILD_ROOT%{_infodir}/dir
 gzip -9 $RPM_BUILD_ROOT%{_infodir}/*.info*
+%if %{build_ada}
 ln -sf gcc $RPM_BUILD_ROOT%{_prefix}/bin/gnatgcc
+%endif
 
 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
@@ -818,11 +860,26 @@ sed -i -e 's/lib: /&%%{static:%%eJava pr
   $FULLPATH/libgcj.spec
 %endif
 
+%if %{isnative}
 mkdir -p $RPM_BUILD_ROOT/%{_lib}
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgcc_s.so.1 $RPM_BUILD_ROOT/%{_lib}/libgcc_s-%{gcc_version}-%{DATE}.so.1
 chmod 755 $RPM_BUILD_ROOT/%{_lib}/libgcc_s-%{gcc_version}-%{DATE}.so.1
 ln -sf libgcc_s-%{gcc_version}-%{DATE}.so.1 $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so.1
 ln -sf /%{_lib}/libgcc_s.so.1 $FULLPATH/libgcc_s.so
+%else
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/lib
+mv -f $FULLPATH/libgcc_s.so.1 $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/%{_lib}/libgcc_s-%{gcc_version}-%{DATE}.so.1
+chmod 755 $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/%{_lib}/libgcc_s-%{gcc_version}-%{DATE}.so.1
+ln -sf libgcc_s-%{gcc_version}-%{DATE}.so.1 $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/%{_lib}/libgcc_s.so.1
+ln -sf ../../../../%{gcc_target_platform}/sys-root/%{_lib}/libgcc_s.so.1 $FULLPATH/libgcc_s.so
+
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/include
+mv -f $FULLPATH/include/c++ $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/include/
+ln -sf ../../../../../%{gcc_target_platform}/sys-root/%{_prefix}/include/c++ $FULLPATH/include/c++
+
+mkdir -p $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/%{_lib}
+mv $FULLPATH/libstdc++.so.* $RPM_BUILD_ROOT%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/%{_lib}/
+%endif
 %ifarch sparc ppc
 ln -sf /lib64/libgcc_s.so.1 $FULLPATH/64/libgcc_s.so
 %endif
@@ -830,8 +887,10 @@ ln -sf /lib64/libgcc_s.so.1 $FULLPATH/64
 ln -sf /lib/libgcc_s.so.1 $FULLPATH/32/libgcc_s.so
 %endif
 
+%if %{isnative}
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgomp.spec $FULLPATH/
 mv -f $RPM_BUILD_ROOT%{_prefix}/include/omp.h $FULLPATH/include/
+%endif
 
 %if %{build_ada}
 mv -f $FULLPATH/adalib/libgnarl-*.so $RPM_BUILD_ROOT%{_prefix}/%{_lib}/
@@ -859,13 +918,19 @@ if [ "%{_lib}" = "lib" ]; then
 %if %{build_objc}
 ln -sf ../../../libobjc.so.1 libobjc.so
 %endif
+%if %{isnative}
 ln -sf ../../../libstdc++.so.6.* libstdc++.so
+%else
+ln -sf ../../../../%{gcc_target}/sys-root/%{_prefix}/%{_lib}/libstdc++.so.6.* libstdc++.so
+%endif
 %if %{build_fortran}
 ln -sf ../../../libgfortran.so.1.* libgfortran.so
 %endif
+%if %{isnative}
 ln -sf ../../../libgomp.so.1.* libgomp.so
 ln -sf ../../../libmudflap.so.0.* libmudflap.so
 ln -sf ../../../libmudflapth.so.0.* libmudflapth.so
+%endif
 %if %{build_java}
 ln -sf ../../../libgcj.so.8rh.* libgcj.so
 ln -sf ../../../libgcj-tools.so.8rh.* libgcj-tools.so
@@ -907,8 +972,10 @@ fi
 %if %{build_java}
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgcj_bc.so $FULLLPATH/
 %endif
+%if %{isnative}
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libstdc++.*a $FULLLPATH/
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libsupc++.*a .
+%endif
 %if %{build_fortran}
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgfortran.*a .
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgfortranbegin.*a .
@@ -916,9 +983,11 @@ mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/
 %if %{build_objc}
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libobjc.*a .
 %endif
+%if %{isnative}
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgomp.*a .
 mv -f $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libmudflap{,th}.*a .
 mv -f $RPM_BUILD_ROOT%{_prefix}/include/mf-runtime.h include/
+%endif
 
 %ifarch sparc ppc
 %if %{build_objc}
@@ -928,9 +997,11 @@ ln -sf ../`echo ../../../../lib/libstdc+
 %if %{build_fortran}
 ln -sf ../`echo ../../../../lib/libgfortran.so.1.* | sed s~/lib/~/lib64/~` 64/libgfortran.so
 %endif
+%if %{isnative}
 ln -sf ../`echo ../../../../lib/libgomp.so.1.* | sed s~/lib/~/lib64/~` 64/libgomp.so
 ln -sf ../`echo ../../../../lib/libmudflap.so.0.* | sed s~/lib/~/lib64/~` 64/libmudflap.so
 ln -sf ../`echo ../../../../lib/libmudflapth.so.0.* | sed s~/lib/~/lib64/~` 64/libmudflapth.so
+%endif
 %if %{build_java}
 ln -sf ../`echo ../../../../lib/libgcj.so.8rh.* | sed s~/lib/~/lib64/~` 64/libgcj.so
 ln -sf ../`echo ../../../../lib/libgcj-tools.so.8rh.* | sed s~/lib/~/lib64/~` 64/libgcj-tools.so
@@ -946,8 +1017,10 @@ mv -f $RPM_BUILD_ROOT%{_prefix}/lib64/li
 %if %{build_objc}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib64/libobjc.*a 64/
 %endif
+%if %{isnative}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib64/libgomp.*a 64/
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib64/libmudflap{,th}.*a 64/
+%endif
 ln -sf lib32/libstdc++.a libstdc++.a
 ln -sf ../lib64/libstdc++.a 64/libstdc++.a
 %endif
@@ -960,9 +1033,11 @@ ln -sf ../`echo ../../../../lib64/libstd
 %if %{build_fortran}
 ln -sf ../`echo ../../../../lib64/libgfortran.so.1.* | sed s~/../lib64/~/~` 32/libgfortran.so
 %endif
+%if %{isnative}
 ln -sf ../`echo ../../../../lib64/libgomp.so.1.* | sed s~/../lib64/~/~` 32/libgomp.so
 ln -sf ../`echo ../../../../lib64/libmudflap.so.0.* | sed s~/../lib64/~/~` 32/libmudflap.so
 ln -sf ../`echo ../../../../lib64/libmudflapth.so.0.* | sed s~/../lib64/~/~` 32/libmudflapth.so
+%endif
 %if %{build_java}
 ln -sf ../`echo ../../../../lib64/libgcj.so.8rh.* | sed s~/../lib64/~/~` 32/libgcj.so
 ln -sf ../`echo ../../../../lib64/libgcj-tools.so.8rh.* | sed s~/../lib64/~/~` 32/libgcj-tools.so
@@ -976,9 +1051,11 @@ mv -f $RPM_BUILD_ROOT%{_prefix}/lib/libg
 %if %{build_objc}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib/libobjc.*a 32/
 %endif
+%if %{isnative}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib/libgomp.*a 32/
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib/libmudflap{,th}.*a 32/
 %endif
+%endif
 %ifarch sparc64 ppc64
 ln -sf ../lib32/libstdc++.a 32/libstdc++.a
 ln -sf lib64/libstdc++.a libstdc++.a
@@ -996,15 +1073,17 @@ ln -sf ../../../%{multilib_32_arch}-%{_v
 %endif
 
 # Strip debug info from Fortran/ObjC/Java static libraries
-strip -g `find . \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \
+%{__strip} -g `find . \( -name libgfortran.a -o -name libobjc.a -o -name libgomp.a \
 		    -o -name libmudflap.a -o -name libmudflapth.a \
 		    -o -name libgcc.a -o -name libgcov.a \) -a -type f`
 popd
 %if %{build_fortran}
 chmod 755 $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgfortran.so.1.*
 %endif
+%if %{isnative}
 chmod 755 $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libgomp.so.1.*
 chmod 755 $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libmudflap{,th}.so.0.*
+%endif
 %if %{build_objc}
 chmod 755 $RPM_BUILD_ROOT%{_prefix}/%{_lib}/libobjc.so.1.*
 %endif
@@ -1022,7 +1101,11 @@ for h in `find $FULLPATH/include -name \
   fi
 done
 
+%if %{isnative}
 cat > $RPM_BUILD_ROOT%{_prefix}/bin/c89 <<"EOF"
+%else
+cat > $RPM_BUILD_ROOT%{_prefix}/bin/%{gcc_target_platform}-c89 <<"EOF"
+%endif
 #!/bin/sh
 fl="-std=c89"
 for opt; do
@@ -1034,7 +1117,11 @@ for opt; do
 done
 exec gcc $fl ${1+"$@"}
 EOF
+%if %{isnative}
 cat > $RPM_BUILD_ROOT%{_prefix}/bin/c99 <<"EOF"
+%else
+cat > $RPM_BUILD_ROOT%{_prefix}/bin/%{gcc_target_platform}-c99 <<"EOF"
+%endif
 #!/bin/sh
 fl="-std=c99"
 for opt; do
@@ -1046,17 +1133,25 @@ for opt; do
 done
 exec gcc $fl ${1+"$@"}
 EOF
+%if %{isnative}
 chmod 755 $RPM_BUILD_ROOT%{_prefix}/bin/c?9
+%else
+chmod 755 $RPM_BUILD_ROOT%{_prefix}/bin/%{gcc_target_platform}-c?9
+%endif
 
+%if %{isnative}
 %ifnarch %{arm}
 mkdir -p $RPM_BUILD_ROOT%{_prefix}/sbin
 gcc -static -Os %{SOURCE1} -o $RPM_BUILD_ROOT%{_prefix}/sbin/libgcc_post_upgrade
-strip $RPM_BUILD_ROOT%{_prefix}/sbin/libgcc_post_upgrade
+%{__strip} $RPM_BUILD_ROOT%{_prefix}/sbin/libgcc_post_upgrade
+%endif
 %endif
 
 cd ..
-%find_lang %{name}
-%find_lang cpplib
+%if %{isnative}
+%find_lang %{?cross}%{name}
+%find_lang %{?cross}cpplib
+%endif
 
 # Remove binaries we will not be including, so that they don't end up in
 # gcc-debuginfo
@@ -1102,11 +1197,11 @@ if [ $1 = 0 ]; then
     --info-dir=%{_infodir} %{_infodir}/gcc.info.gz || :
 fi
 
-%post -n cpp
+%post -n %{?cross}cpp
 /sbin/install-info \
   --info-dir=%{_infodir} %{_infodir}/cpp.info.gz || :
 
-%preun -n cpp
+%preun -n %{?cross}cpp
 if [ $1 = 0 ]; then
   /sbin/install-info --delete \
     --info-dir=%{_infodir} %{_infodir}/cpp.info.gz || :
@@ -1150,16 +1245,18 @@ if [ $1 = 0 ]; then
     --info-dir=%{_infodir} %{_infodir}/gnat-style.info.gz || :
 fi
 
+%if %{isnative}
 %ifnarch %{arm}
 # Because glibc Prereq's libgcc and /sbin/ldconfig
 # comes from glibc, it might not exist yet when
 # libgcc is installed
-%post -n libgcc -p %{_prefix}/sbin/libgcc_post_upgrade
+%post -n %{?cross}libgcc -p %{_prefix}/sbin/libgcc_post_upgrade
 %endif
 
-%post -n libstdc++ -p /sbin/ldconfig
+%post -n %{?cross}libstdc++ -p /sbin/ldconfig
 
-%postun -n libstdc++ -p /sbin/ldconfig
+%postun -n %{?cross}libstdc++ -p /sbin/ldconfig
+%endif
 
 %post -n libobjc -p /sbin/ldconfig
 
@@ -1194,8 +1291,13 @@ fi
 
 %postun -n libmudflap -p /sbin/ldconfig
 
+%if %{isnative}
 %files -f %{name}.lang
+%else
+%files
+%endif
 %defattr(-,root,root)
+%if %{isnative}
 %{_prefix}/bin/cc
 %{_prefix}/bin/c89
 %{_prefix}/bin/c99
@@ -1203,6 +1305,11 @@ fi
 %{_prefix}/bin/gcov
 %{_prefix}/bin/protoize
 %{_prefix}/bin/unprotoize
+%else
+%{_prefix}/bin/%{gcc_target_platform}-c89
+%{_prefix}/bin/%{gcc_target_platform}-c99
+%{_prefix}/bin/%{gcc_target_platform}-gcov
+%endif
 %ifarch sparc ppc
 %{_prefix}/bin/%{_target_platform}-gcc
 %endif
@@ -1213,11 +1320,16 @@ fi
 %{_prefix}/bin/ppc-%{_vendor}-%{_target_os}-gcc
 %endif
 %{_prefix}/bin/%{gcc_target_platform}-gcc
+%if %{isnative}
 %{_mandir}/man1/gcc.1*
 %{_mandir}/man1/gcov.1*
 %{_mandir}/man1/protoize.1*
 %{_mandir}/man1/unprotoize.1*
 %{_infodir}/gcc*
+%else
+%{_mandir}/man1/%{gcc_target_platform}-gcc.1*
+%{_mandir}/man1/%{gcc_target_platform}-gcov.1*
+%endif
 %dir %{_prefix}/lib/gcc
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}
@@ -1225,7 +1337,9 @@ fi
 %dir %{_prefix}/libexec/gcc/%{gcc_target_platform}
 %dir %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include
+%if %{isnative}
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/SYSCALLS.c.X
+%endif
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/stddef.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/stdarg.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/varargs.h
@@ -1235,6 +1349,7 @@ fi
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/iso646.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/syslimits.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/unwind.h
+%if %{isnative}
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/omp.h
 %ifarch %{ix86} x86_64
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/mmintrin.h
@@ -1254,6 +1369,7 @@ fi
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/altivec.h
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/spe.h
 %endif
+%endif
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/README
 %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}/collect2
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/crt*.o
@@ -1261,6 +1377,7 @@ fi
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgcov.a
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgcc_eh.a
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgcc_s.so
+%if %{isnative}
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgomp.spec
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgomp.a
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgomp.so
@@ -1284,36 +1401,54 @@ fi
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/32/libgomp.a
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/32/libgomp.so
 %endif
+%endif
 %dir %{_prefix}/libexec/getconf
 %{_prefix}/libexec/getconf/default
 %doc gcc/README* rpm.doc/changelogs/gcc/ChangeLog* gcc/COPYING*
 
+%if %{isnative}
 %files -n cpp -f cpplib.lang
+%else
+%files -n %{?cross}cpp
+%endif
 %defattr(-,root,root)
+%if %{isnative}
 /lib/cpp
 %{_prefix}/bin/cpp
 %{_mandir}/man1/cpp.1*
 %{_infodir}/cpp*
+%else
+%{_prefix}/bin/%{gcc_target_platform}-cpp
+%{_mandir}/man1/%{gcc_target_platform}-cpp.1*
+%endif
 %dir %{_prefix}/libexec/gcc
 %dir %{_prefix}/libexec/gcc/%{gcc_target_platform}
 %dir %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}
 %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}/cc1
 
-%files -n libgcc
+%files -n %{?cross}libgcc
 %defattr(-,root,root)
+%if %{isnative}
 /%{_lib}/libgcc_s-%{gcc_version}-%{DATE}.so.1
 /%{_lib}/libgcc_s.so.1
 %ifnarch %{arm}
 %{_prefix}/sbin/libgcc_post_upgrade
 %endif
-%doc gcc/COPYING.LIB
+%else
+/%{_prefix}/%{gcc_target_platform}/sys-root/%{_lib}/libgcc_s-%{gcc_version}-%{DATE}.so.1
+/%{_prefix}/%{gcc_target_platform}/sys-root/%{_lib}/libgcc_s.so.1
+%endif
 
 %files c++
 %defattr(-,root,root)
 %{_prefix}/bin/%{gcc_target_platform}-*++
+%if %{isnative}
 %{_prefix}/bin/g++
 %{_prefix}/bin/c++
 %{_mandir}/man1/g++.1*
+%else
+%{_mandir}/man1/%{gcc_target_platform}-g++.1*
+%endif
 %dir %{_prefix}/lib/gcc
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}
@@ -1342,20 +1477,32 @@ fi
 %endif
 %doc rpm.doc/changelogs/gcc/cp/ChangeLog*
 
-%files -n libstdc++
+%files -n %{?cross}libstdc++
 %defattr(-,root,root)
+%if %{isnative}
 %{_prefix}/%{_lib}/libstdc++.so.6*
+%else
+%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/%{_lib}/libstdc++.so.6*
+%endif
 
-%files -n libstdc++-devel
+%files -n %{?cross}libstdc++-devel
 %defattr(-,root,root)
+%if %{isnative}
 %dir %{_prefix}/include/c++
 %dir %{_prefix}/include/c++/%{gcc_version}
 %{_prefix}/include/c++/%{gcc_version}/[^gjos]*
 %{_prefix}/include/c++/%{gcc_version}/os*
 %{_prefix}/include/c++/%{gcc_version}/s[^u]*
+%endif
 %dir %{_prefix}/lib/gcc
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}
+%if !%{isnative}
+%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/include/c++/[^gjos]*
+%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/include/c++/os*
+%{_prefix}/%{gcc_target_platform}/sys-root/%{_prefix}/include/c++/s[^u]*
+%{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/include/c++
+%endif
 %ifarch sparc ppc
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/lib32
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/lib32/libstdc++.a
@@ -1619,6 +1766,7 @@ fi
 %{_prefix}/%{_lib}/libgnarl-*.so
 %endif
 
+%if %{isnative}
 %files -n libgomp
 %defattr(-,root,root)
 %{_prefix}/%{_lib}/libgomp.so.1*
@@ -1655,6 +1803,7 @@ fi
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/32/libmudflapth.so
 %endif
 %doc rpm.doc/changelogs/libmudflap/ChangeLog*
+%endif
 
 %changelog
 * Thu May  3 2007 Jakub Jelinek <jakub redhat com> 4.1.2-12


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]