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:

> 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

I've had to change two things to make cross-gcc happy with this:

1. Change the location of the sysroot.   /usr/%{target} is not the
   right place to put the sysroot, as binutils/gcc use it to store
   target-specific binaries, etc.  (binutils stores things like 'as'
   in /usr/%{target}/bin, which gcc expects to find there.)

   If you use the default sysroot path (i.e. --with-sysroot=yes), the
   sysroot gets put in /usr/%{target}/sys-root.  That seems like a
   sane default to me.

2. Do package /usr/%{target}, as the subsequently built gcc depends
   on (see #1) having 'as' in /usr/%{target}/bin and such.

Here's a new version (beware: against a locally modified tree)
with these changes.  Seems to work OK for me.


Index: SPECS/binutils.spec
===================================================================
--- SPECS.orig/binutils.spec
+++ SPECS/binutils.spec
@@ -1,5 +1,13 @@
+%if "%{?binutils_target}" == ""
+%define binutils_target %{_target_platform}
+%define isnative 1
+%else
+%define cross %{binutils_target}-
+%define isnative 0
+%endif
+
 Summary: A GNU collection of binary utilities.
-Name: binutils
+Name: %{?cross}binutils
 Version: 2.17.50.0.12
 Release: 4.fa1
 License: GPL
@@ -55,7 +63,7 @@ have a stable ABI.  Developers starting 
 to consider using libelf instead of BFD.
 
 %prep
-%setup -q
+%setup -q -n binutils-%{version}
 %patch1 -p0 -b .ltconfig-multilib~
 %patch2 -p0 -b .ppc64-pie~
 %patch3 -p0 -b .place-orphan~
@@ -70,7 +78,7 @@ to consider using libelf instead of BFD.
 %patch8 -p0 -b .osabi~
 %patch9 -p0 -b .rh235747~
 
-# On ppc64 we might use 64K pages
+# On ppc64 we might use 64KiB pages
 sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*ppc.c
 # LTP sucks
 perl -pi -e 's/i\[3-7\]86/i[34567]86/g' */conf*
@@ -82,24 +90,36 @@ sed -i -e 's/^libbfd_la_LDFLAGS = /&-Wl,
 sed -i -e 's/^libopcodes_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' opcodes/Makefile.{am,in}
 fi
 touch */configure
+sed -i -e 's/^ PACKAGE=/ PACKAGE=%{?cross}/' */configure
 
 %build
-mkdir build-%{_target_platform}
-cd build-%{_target_platform}
+mkdir build-%{binutils_target}
+cd build-%{binutils_target}
 CARGS=
-%ifarch sparc ppc s390
-CARGS=--enable-64-bit-bfd
-%endif
-%ifarch ia64
-CARGS=--enable-targets=i386-linux
+case %{binutils_target} in
+    sparc*|ppc*|s390*)
+	CARGS=--enable-64-bit-bfd
+	;;
+    ia64*)
+	CARGS=--enable-targets=i386-linux
+	;;
+esac
+%if %isnative
+   SHAREDARGS=--enable-shared
+   TARGET=%{binutils_target}
+   SYSROOT=
+%else
+   SHAREDARGS=--disable-shared
+   TARGET="--target %{binutils_target} --host %{_target_platform}"
+   SYSROOT="--with-sysroot=yes"
 %endif
 CC="gcc -L`pwd`/bfd/.libs/" CFLAGS="${CFLAGS:-%optflags}" ../configure \
-  %{_target_platform} --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} \
+  $TARGET --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} \
   --bindir=%{_bindir} --sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} \
   --datadir=%{_datadir} --includedir=%{_includedir} --libdir=%{_libdir} \
   --libexecdir=%{_libexecdir} --localstatedir=%{_localstatedir} \
   --sharedstatedir=%{_sharedstatedir} --mandir=%{_mandir} \
-  --infodir=%{_infodir} --enable-shared $CARGS --disable-werror
+  --infodir=%{_infodir} $SHAREDARGS $CARGS --disable-werror $SYSROOT
 make %{_smp_mflags} tooldir=%{_prefix} all
 make %{_smp_mflags} tooldir=%{_prefix} info
 make -k check < /dev/null > check.log 2>&1 || :
@@ -111,8 +131,9 @@ cd ..
 %install
 rm -rf %{buildroot}
 mkdir -p %{buildroot}%{_prefix}
-cd build-%{_target_platform}
+cd build-%{binutils_target}
 %makeinstall
+%if %isnative
 make prefix=%{buildroot}%{_prefix} infodir=%{buildroot}%{_infodir} install-info
 gzip -q9f %{buildroot}%{_infodir}/*.info*
 
@@ -134,10 +155,6 @@ rm -f %{buildroot}%{_prefix}/%{_lib}/lib
 # Remove libtool files, which reference the .so libs
 rm -f %{buildroot}%{_prefix}/%{_lib}/lib{bfd,opcodes}.la
 
-# This one comes from gcc
-rm -f %{buildroot}%{_infodir}/dir
-rm -rf %{buildroot}%{_prefix}/%{_target_platform}
-
 %ifarch %{ix86} x86_64 ppc ppc64 s390 s390x sparc sparc64
 sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include <bits/wordsize.h>~;}' \
 %ifarch %{ix86} x86_64
@@ -155,22 +172,36 @@ sed -i -e '/^#include "ansidecl.h"/{p;s~
 %endif
 touch -r ../bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h
 
+%else # native
+# For cross-binutils we drop the documentation.
+rm -rf %{buildroot}%{_infodir}
+#rm -rf %{buildroot}%{_prefix}/share/locale
+#rm -rf %{buildroot}%{_mandir}
+rm -rf %{buildroot}%{_prefix}/%{_lib}/libiberty.a
+%endif # native
+
+# This one comes from gcc
+rm -f %{buildroot}%{_infodir}/dir
+#rm -rf %{buildroot}%{_prefix}/%{binutils_target}
+
+
 cd ..
-%find_lang binutils
-%find_lang opcodes
-%find_lang bfd
-%find_lang gas
-%find_lang ld
-%find_lang gprof
-cat opcodes.lang >> binutils.lang
-cat bfd.lang >> binutils.lang
-cat gas.lang >> binutils.lang
-cat ld.lang >> binutils.lang
-cat gprof.lang >> binutils.lang
+%find_lang %{?cross}binutils
+%find_lang %{?cross}opcodes
+%find_lang %{?cross}bfd
+%find_lang %{?cross}gas
+%find_lang %{?cross}ld
+%find_lang %{?cross}gprof
+cat %{?cross}opcodes.lang >> %{?cross}binutils.lang
+cat %{?cross}bfd.lang >> %{?cross}binutils.lang
+cat %{?cross}gas.lang >> %{?cross}binutils.lang
+cat %{?cross}ld.lang >> %{?cross}binutils.lang
+cat %{?cross}gprof.lang >> %{?cross}binutils.lang
 
 %clean
 rm -rf %{buildroot}
 
+%if %isnative
 %post
 /sbin/ldconfig
 /sbin/install-info --info-dir=%{_infodir} %{_infodir}/as.info.gz
@@ -201,12 +232,16 @@ exit 0
 if [ $1 = 0 ] ;then
   /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/bfd.info.gz || :
 fi
+%endif # native
 
-%files -f binutils.lang
+%files -f %{?cross}binutils.lang
 %defattr(-,root,root)
 %doc README
 %{_prefix}/bin/*
 %{_mandir}/man1/*
+%if !%isnative
+%{_prefix}/%{binutils_target}
+%else
 %{_prefix}/%{_lib}/lib*.so
 %{_infodir}/[^b]*info*
 %{_infodir}/binutils*info*
@@ -216,6 +251,7 @@ fi
 %{_prefix}/include/*
 %{_prefix}/%{_lib}/lib*.a
 %{_infodir}/bfd*info*
+%endif # native
 
 %changelog
 * Sat Apr 14 2007 Jakub Jelinek <jakub@xxxxxxxxxx> 2.17.50.0.12-4

-- 
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