Re: Fedora and Cross Compiling

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

 



On Tue, Jun 12, 2007 at 04:31:51PM +0100, David Woodhouse wrote:

> > As gcc matures, it's likely that the libgcc problem will go away by it 
> > being split out.  At that time, the chicken/egg problem will be solved 
> > without having to resort to clever hacks.
> 
> I think we need to accelerate that rather than waiting for it.
> 
> Binutils at least should be relatively easy. Here's a patch against
> binutils/F-7 which lets me:
>   make DIST_DEFINES='--define "binutils_target i686-linux-gnu"' ppc

Works fine for me on arm.  (One packaging issue with 'as'/'nm', see
below.)

Attached is a very hacky patch to the gcc spec file to make it cross
build (Fedora -> Fedora.)  It requires that you already have glibc and
kernel headers installed in your sysroot (/usr/%{_target_platform}).
(If you're doing Fedora -> Fedora, presumably you already have glibc
packages for the target, which will suffice for bootstrapping.)

There's a couple of issues:
- Whereas your binutils patch is pretty clean, I can't really seem
  to find a way to make the cross changes to the gcc spec file not
  very intrusive.

  I'm starting to wonder whether the gcc cross stuff should just be
  in a separate spec file.  We _do_ want to use exactly the same
  sources to build the cross-compiler, so maybe the regular gcc
  package can provide gcc-source, which can then be pulled in by
  the gcc-cross variant?

- binutils puts as/nm binaries into the sysroot, even though they are
  host binaries.  Your binutils spec patch doesn't package those, which
  makes sense (I don't fully understand why binutils puts them there to
  begin with), but gcc insists on being able to invoke the target 'as'
  as 'as'.  I've hacked around that by making
  /usr/libexec/gcc/$target/$version/as a symlink to $target-as (and the
  same thing with 'nm'), which seems to work.

- There's also two issues with building libstdc++ -- it doesn't pick
  up the sysroot info correctly (and subsequently tries to link against
  the host's /lib/libc.so.6 after reading the target libc.so script in
  the sysroot), and its install target installs various target files
  not in the sysroot but in the host's directory space.



Index: SPECS/gcc41.spec
===================================================================
--- SPECS.orig/gcc41.spec
+++ SPECS/gcc41.spec
@@ -1,32 +1,32 @@
+%if "%{?gcc_target}" == ""
+%define gcc_target %{_target_platform}
+%define isnative 1
+%else
+%define isnative 0
+%define cross %{gcc_target}-
+%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
+%else
 %ifarch %{ix86} x86_64 ia64 ppc alpha
 %define build_ada 1
 %else
 %define build_ada 0
 %endif
+%endif
 %define build_fortran 0
 %define build_java 0
 %define build_objc 0
 %define run_tests 0
-%ifarch s390x
-%define multilib_32_arch s390
-%endif
-%ifarch sparc64
-%define multilib_32_arch sparc
-%endif
-%ifarch ppc64
-%define multilib_32_arch ppc
-%endif
-%ifarch x86_64
-%define multilib_32_arch i386
-%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 +44,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 +52,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 +69,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,37 +80,39 @@ 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: %{?cross}libgcc >= %{version}-%{release}
+%if %{isnative}
+Requires: %{?cross}libgomp = %{version}-%{release}
 %endif
-Requires: libgcc >= %{version}-%{release}
-Requires: libgomp = %{version}-%{release}
-Obsoletes: gcc3
-Obsoletes: egcs
+Obsoletes: %{?cross}gcc3
+Obsoletes: %{?cross}egcs
 %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
+Obsoletes: %{?cross}gcc-chill
 %if !%{build_ada}
-Obsoletes: gcc-gnat < %{version}-%{release}
-Obsoletes: libgnat < %{version}-%{release}
+Obsoletes: %{?cross}gcc-gnat < %{version}-%{release}
+Obsoletes: %{?cross}libgnat < %{version}-%{release}
 %endif
 %ifarch sparc sparc64
-Obsoletes: egcs64
+Obsoletes: %{?cross}egcs64
 %endif
-Obsoletes: gcc34
-Obsoletes: gcc35
-Obsoletes: gcc4
+Obsoletes: %{?cross}gcc34
+Obsoletes: %{?cross}gcc35
+Obsoletes: %{?cross}gcc4
 Prereq: /sbin/install-info
 AutoReq: true
 
@@ -160,6 +162,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,17 +172,20 @@ 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.
 
@@ -200,18 +206,18 @@ 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
 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
@@ -219,7 +225,7 @@ Obsoletes: 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.
@@ -246,12 +252,12 @@ Autoreq: true
 %description objc++
 gcc-objc++ package provides Objective-C++ support for the GCC.
 
-%package -n libobjc
+%package -n %{?cross}libobjc
 Summary: Objective-C runtime
 Group: System Environment/Libraries
 Autoreq: true
 
-%description -n libobjc
+%description -n %{?cross}libobjc
 This package contains Objective-C shared library which is needed to run
 Objective-C dynamically linked programs.
 
@@ -271,39 +277,39 @@ Autoreq: true
 The gcc-gfortran package provides support for compiling Fortran 95
 programs with the GNU Compiler Collection.
 
-%package -n libgfortran
+%package -n %{?cross}libgfortran
 Summary: Fortran 95 runtime
 Group: System Environment/Libraries
 Obsoletes: libf2c
 Autoreq: true
 
-%description -n libgfortran
+%description -n %{?cross}libgfortran
 This package contains Fortran 95 shared library which is needed to run
 Fortran 95 dynamically linked programs.
 
-%package -n libgomp
+%package -n %{?cross}libgomp
 Summary: GCC OpenMP 2.5 shared support library
 Group: System Environment/Libraries
 
-%description -n libgomp
+%description -n %{?cross}libgomp
 This package contains GCC shared support library which is needed
 for OpenMP 2.5 support.
 
-%package -n libmudflap
+%package -n %{?cross}libmudflap
 Summary: GCC mudflap shared support library
 Group: System Environment/Libraries
 
-%description -n libmudflap
+%description -n %{?cross}libmudflap
 This package contains GCC shared support library which is needed
 for mudflap support.
 
-%package -n libmudflap-devel
+%package -n %{?cross}libmudflap-devel
 Summary: GCC mudflap support
 Group: Development/Libraries
 Requires: libmudflap = %{version}-%{release}
 Requires: gcc = %{version}-%{release}
 
-%description -n libmudflap-devel
+%description -n %{?cross}libmudflap-devel
 This package contains headers and static libraries for building
 mudflap-instrumented programs.
 
@@ -329,7 +335,7 @@ Autoreq: true
 This package adds support for compiling Java(tm) programs and
 bytecode into native code.
 
-%package -n libgcj
+%package -n %{?cross}libgcj
 Summary: Java runtime library for gcc
 Group: System Environment/Libraries
 Prereq: /sbin/install-info
@@ -352,11 +358,11 @@ Obsoletes: libgcj34
 Obsoletes: libgcj4
 Autoreq: true
 
-%description -n libgcj
+%description -n %{?cross}libgcj
 The Java(tm) runtime library. You will need this package to run your Java
 programs compiled using the Java compiler from GNU Compiler Collection (gcj).
 
-%package -n libgcj-devel
+%package -n %{?cross}libgcj-devel
 Summary: Libraries for Java development using GCC
 Group: Development/Languages
 Requires: libgcj = %{version}-%{release}, %{_prefix}/%{_lib}/libgcj.so.8rh
@@ -368,21 +374,21 @@ Obsoletes: libgcj4-devel
 Autoreq: false
 Autoprov: false
 
-%description -n libgcj-devel
+%description -n %{?cross}libgcj-devel
 The Java(tm) static libraries and C header files. You will need this
 package to compile your Java programs using the GCC Java compiler (gcj).
 
-%package -n libgcj-src
+%package -n %{?cross}libgcj-src
 Summary: Java library sources from GCC4 preview
 Group: System Environment/Libraries
 Requires: libgcj = %{version}-%{release}
 Obsoletes: libgcj4-src
 Autoreq: true
 
-%description -n libgcj-src
+%description -n %{?cross}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 +397,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
@@ -425,13 +431,13 @@ Autoreq: true
 GNAT is a GNU Ada 95 front-end to GCC. This package includes development tools,
 the documents and Ada 95 compiler.
 
-%package -n libgnat
+%package -n %{?cross}libgnat
 Summary: GNU Ada 95 runtime shared libraries
 Group: System Environment/Libraries
 Obsoletes: gnat libgnat3
 Autoreq: true
 
-%description -n libgnat
+%description -n %{?cross}libgnat
 GNAT is a GNU Ada 95 front-end to GCC. This package includes shared libraries,
 which are required to run programs compiled with the GNAT.
 
@@ -511,6 +517,7 @@ if [ -d libstdc++-v3/config/abi/sparc64-
   rm -rf libstdc++-v3/config/abi/sparc64-linux-gnu/32
 fi
 %endif
+find -name configure | xargs sed -i -e 's/^ PACKAGE=/ PACKAGE=%{?cross}/'
 
 %build
 
@@ -583,6 +590,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} \
@@ -632,7 +640,6 @@ CC="$CC" CFLAGS="$OPT_FLAGS" CXXFLAGS="$
 	--host=%{gcc_target_platform}
 %endif
 
-#GCJFLAGS="$OPT_FLAGS" make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" bootstrap
 GCJFLAGS="$OPT_FLAGS" make %{?_smp_mflags} BOOT_CFLAGS="$OPT_FLAGS" profiledbootstrap
 
 %if %{run_tests}
@@ -663,6 +670,19 @@ 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 --disable-libgcj --disable-libssp \
+	--disable-libgomp --disable-libmudflap \
+	--with-sysroot=/usr/%{gcc_target_platform} \
+	--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,10 +750,10 @@ fi
 export PATH=`pwd`/java_hacks${PATH:+:$PATH}
 %endif
 
-TARGET_PLATFORM=%{gcc_target_platform}
-
+%if %{isnative}
 # There are some MP bugs in libstdc++ Makefiles
 make -C %{gcc_target_platform}/libstdc++-v3
+%endif
 
 make prefix=$RPM_BUILD_ROOT%{_prefix} mandir=$RPM_BUILD_ROOT%{_mandir} \
   infodir=$RPM_BUILD_ROOT%{_infodir} install
@@ -748,16 +768,26 @@ 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
 
+%if !%{isnative}
+ln -s ../../../../bin/%{gcc_target}-as $FULLEPATH/as
+ln -s ../../../../bin/%{gcc_target}-nm $FULLEPATH/nm
+%endif
+
+%if %{isnative}
 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
@@ -783,6 +813,7 @@ EOF
     break
   fi
 done
+%endif
 
 %ifarch sparc sparc64
 ln -f $RPM_BUILD_ROOT%{_prefix}/bin/%{gcc_target_platform}-gcc \
@@ -818,11 +849,13 @@ 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
+%endif
 %ifarch sparc ppc
 ln -sf /lib64/libgcc_s.so.1 $FULLPATH/64/libgcc_s.so
 %endif
@@ -830,8 +863,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}/
@@ -856,16 +891,21 @@ fi
 
 pushd $FULLPATH
 if [ "%{_lib}" = "lib" ]; then
+true
 %if %{build_objc}
 ln -sf ../../../libobjc.so.1 libobjc.so
 %endif
+%if %{isnative}
 ln -sf ../../../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
@@ -883,7 +923,9 @@ else
 %if %{build_objc}
 ln -sf ../../../../%{_lib}/libobjc.so.1 libobjc.so
 %endif
+%if %{isnative}
 ln -sf ../../../../%{_lib}/libstdc++.so.6.* libstdc++.so
+%endif
 %if %{build_fortran}
 ln -sf ../../../../%{_lib}/libgfortran.so.1.* libgfortran.so
 %endif
@@ -907,8 +949,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,21 +960,27 @@ 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}
 ln -sf ../../../../../lib64/libobjc.so.1 64/libobjc.so
 %endif
+%if %{isnative}
 ln -sf ../`echo ../../../../lib/libstdc++.so.6.* | sed s~/lib/~/lib64/~` 64/libstdc++.so
+%endif
 %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
@@ -938,7 +988,9 @@ ln -sf ../`echo ../../../../lib/libgij.s
 ln -sf lib32/libgcj_bc.so libgcj_bc.so
 ln -sf ../lib64/libgcj_bc.so 64/libgcj_bc.so
 %endif
+%if %{isnative}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib64/libsupc++.*a 64/
+%endif
 %if %{build_fortran}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib64/libgfortran.*a 64/
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib64/libgfortranbegin.*a 64/
@@ -946,29 +998,37 @@ 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/
 ln -sf lib32/libstdc++.a libstdc++.a
 ln -sf ../lib64/libstdc++.a 64/libstdc++.a
 %endif
+%endif
 %ifarch %{multilib_64_archs}
 mkdir -p 32
 %if %{build_objc}
 ln -sf ../../../../libobjc.so.1 32/libobjc.so
 %endif
+%if %{isnative}
 ln -sf ../`echo ../../../../lib64/libstdc++.so.6.* | sed s~/../lib64/~/~` 32/libstdc++.so
+%endif
 %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
 ln -sf ../`echo ../../../../lib64/libgij.so.8rh.* | sed s~/../lib64/~/~` 32/libgij.so
 %endif
+%if %{isnative}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib/libsupc++.*a 32/
+%endif
 %if %{build_fortran}
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib/libgfortran.*a 32/
 mv -f $RPM_BUILD_ROOT%{_prefix}/lib/libgfortranbegin.*a 32/
@@ -976,21 +1036,41 @@ 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
+%if %{isnative}
 ln -sf ../lib32/libstdc++.a 32/libstdc++.a
 ln -sf lib64/libstdc++.a libstdc++.a
+%endif
 %if %{build_java}
 ln -sf ../lib32/libgcj_bc.so 32/libgcj_bc.so
 ln -sf lib64/libgcj_bc.so libgcj_bc.so
 %endif
 %else
+case %{gcc_target} in
+    s390x*)
+	MULTILIB_32_ARCH=s390
+	;;
+    sparc64*)
+	MULTILIB_32_ARCH=sparc
+	;;
+    ppc64*)
+	MULTILIB_32_ARCH=ppc
+	;;
+    x86_64*)
+	MULTILIB_32_ARCH=i386
+	;;
+esac
 %ifarch %{multilib_64_archs}
-ln -sf ../../../%{multilib_32_arch}-%{_vendor}-%{_target_os}/%{gcc_version}/libstdc++.a 32/libstdc++.a
+%if %{isnative}
+ln -sf ../../../${MULTILIB_32_ARCH}-%{_vendor}-%{_target_os}/%{gcc_version}/libstdc++.a 32/libstdc++.a
+%endif
 %if %{build_java}
-ln -sf ../../../%{multilib_32_arch}-%{_vendor}-%{_target_os}/%{gcc_version}/libgcj_bc.so 32/libgcj_bc.so
+ln -sf ../../../${MULTILIB_32_ARCH}-%{_vendor}-%{_target_os}/%{gcc_version}/libgcj_bc.so 32/libgcj_bc.so
 %endif
 %endif
 %endif
@@ -1003,8 +1083,10 @@ 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 +1104,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 +1120,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 +1136,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
 %endif
+%endif
 
 cd ..
+%if %{isnative}
 %find_lang %{name}
 %find_lang cpplib
+%endif
 
 # Remove binaries we will not be including, so that they don't end up in
 # gcc-debuginfo
@@ -1102,11 +1200,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 || :
@@ -1154,48 +1252,53 @@ fi
 # 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
 
-%post -n libobjc -p /sbin/ldconfig
+%post -n %{?cross}libobjc -p /sbin/ldconfig
 
-%postun -n libobjc -p /sbin/ldconfig
+%postun -n %{?cross}libobjc -p /sbin/ldconfig
 
-%post -n libgcj
+%post -n %{?cross}libgcj
 /sbin/ldconfig
 /sbin/install-info \
   --info-dir=%{_infodir} %{_infodir}/fastjar.info.gz || :
 
-%preun -n libgcj
+%preun -n %{?cross}libgcj
 if [ $1 = 0 ]; then
   /sbin/install-info --delete \
     --info-dir=%{_infodir} %{_infodir}/fastjar.info.gz || :
 fi
 
-%postun -n libgcj -p /sbin/ldconfig
+%postun -n %{?cross}libgcj -p /sbin/ldconfig
 
-%post -n libgfortran -p /sbin/ldconfig
+%post -n %{?cross}libgfortran -p /sbin/ldconfig
 
-%postun -n libgfortran -p /sbin/ldconfig
+%postun -n %{?cross}libgfortran -p /sbin/ldconfig
 
-%post -n libgnat -p /sbin/ldconfig
+%post -n %{?cross}libgnat -p /sbin/ldconfig
 
-%postun -n libgnat -p /sbin/ldconfig
+%postun -n %{?cross}libgnat -p /sbin/ldconfig
 
-%post -n libgomp -p /sbin/ldconfig
+%post -n %{?cross}libgomp -p /sbin/ldconfig
 
-%postun -n libgomp -p /sbin/ldconfig
+%postun -n %{?cross}libgomp -p /sbin/ldconfig
 
-%post -n libmudflap -p /sbin/ldconfig
+%post -n %{?cross}libmudflap -p /sbin/ldconfig
 
-%postun -n libmudflap -p /sbin/ldconfig
+%postun -n %{?cross}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 +1306,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 +1321,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 +1338,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 +1350,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,12 +1370,14 @@ 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
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgcc.a
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgcov.a
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgcc_eh.a
+%if %{isnative}
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgcc_s.so
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgomp.spec
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libgomp.a
@@ -1284,30 +1402,50 @@ 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
+%if !%{isnative}
+%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}/as
+%{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}/nm
+%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
+%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
+%else
+/%{_prefix}/%{gcc_target_platform}/%{_lib}/libgcc_s.so.1
+%endif
+%if %{isnative)
 %ifnarch %{arm}
 %{_prefix}/sbin/libgcc_post_upgrade
 %endif
+%endif
 %doc gcc/COPYING.LIB
 
+%if %{isnative}
 %files c++
 %defattr(-,root,root)
 %{_prefix}/bin/%{gcc_target_platform}-*++
@@ -1342,11 +1480,11 @@ fi
 %endif
 %doc rpm.doc/changelogs/gcc/cp/ChangeLog*
 
-%files -n libstdc++
+%files -n %{?cross}libstdc++
 %defattr(-,root,root)
 %{_prefix}/%{_lib}/libstdc++.so.6*
 
-%files -n libstdc++-devel
+%files -n %{?cross}libstdc++-devel
 %defattr(-,root,root)
 %dir %{_prefix}/include/c++
 %dir %{_prefix}/include/c++/%{gcc_version}
@@ -1372,6 +1510,7 @@ fi
 %{_prefix}/lib/gcc/%{gcc_target_platform}/%{gcc_version}/libsupc++.a
 %endif
 %doc rpm.doc/changelogs/libstdc++-v3/ChangeLog* libstdc++-v3/README* libstdc++-v3/docs/html/
+%endif
 
 %if %{build_objc}
 %files objc
@@ -1407,7 +1546,7 @@ fi
 %dir %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}
 %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}/cc1objplus
 
-%files -n libobjc
+%files -n %{?cross}libobjc
 %defattr(-,root,root)
 %{_prefix}/%{_lib}/libobjc.so.1*
 %endif
@@ -1448,7 +1587,7 @@ fi
 %endif
 %doc rpm.doc/gfortran/*
 
-%files -n libgfortran
+%files -n %{?cross}libgfortran
 %defattr(-,root,root)
 %{_prefix}/%{_lib}/libgfortran.so.1*
 %endif
@@ -1496,7 +1635,7 @@ fi
 %endif
 %doc rpm.doc/changelogs/gcc/java/ChangeLog*
 
-%files -n libgcj
+%files -n %{?cross}libgcj
 %defattr(-,root,root)
 %{_prefix}/bin/jv-convert
 %{_prefix}/bin/gij
@@ -1555,7 +1694,7 @@ fi
 %doc rpm.doc/README.libgcjwebplugin.so
 %endif
 
-%files -n libgcj-devel
+%files -n %{?cross}libgcj-devel
 %defattr(-,root,root)
 %{_prefix}/bin/addr2name.awk
 %dir %{_prefix}/lib/gcc
@@ -1589,7 +1728,7 @@ fi
 %doc rpm.doc/boehm-gc/* rpm.doc/fastjar/* rpm.doc/libffi/*
 %doc rpm.doc/libjava/*
 
-%files -n libgcj-src
+%files -n %{?cross}libgcj-src
 %defattr(-,root,root)
 %dir %{_prefix}/share/java
 %{_prefix}/share/java/src*.zip
@@ -1613,23 +1752,24 @@ fi
 %{_prefix}/libexec/gcc/%{gcc_target_platform}/%{gcc_version}/gnat1
 %doc rpm.doc/changelogs/gcc/ada/ChangeLog*
 
-%files -n libgnat
+%files -n %{?cross}libgnat
 %defattr(-,root,root)
 %{_prefix}/%{_lib}/libgnat-*.so
 %{_prefix}/%{_lib}/libgnarl-*.so
 %endif
 
-%files -n libgomp
+%if %{isnative}
+%files -n %{?cross}libgomp
 %defattr(-,root,root)
 %{_prefix}/%{_lib}/libgomp.so.1*
 %doc rpm.doc/changelogs/libgomp/ChangeLog*
 
-%files -n libmudflap
+%files -n %{?cross}libmudflap
 %defattr(-,root,root)
 %{_prefix}/%{_lib}/libmudflap.so.0*
 %{_prefix}/%{_lib}/libmudflapth.so.0*
 
-%files -n libmudflap-devel
+%files -n %{?cross}libmudflap-devel
 %defattr(-,root,root)
 %dir %{_prefix}/lib/gcc
 %dir %{_prefix}/lib/gcc/%{gcc_target_platform}
@@ -1655,6 +1795,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@xxxxxxxxxx> 4.1.2-12

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux