Debian Bug report logs - #231707
More general build of binutils for cross-targets

version graph

Package: binutils; Maintainer for binutils is Matthias Klose <doko@debian.org>; Source for binutils is src:binutils.

Reported by: Raphael Bossek <raphael.bossek@gmx.de>

Date: Sun, 8 Feb 2004 14:18:01 UTC

Severity: wishlist

Tags: patch

Found in version 2.14.90.0.7-5

Fixed in version 2.16.1cvs20060413-1

Done: Josh Triplett <josh@freedesktop.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Raphael Bossek <raphael.bossek@gmx.de>:
New Bug report received and forwarded. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox):

From: Raphael Bossek <raphael.bossek@gmx.de>
To: james@nocrew.org
Cc: submit@bugs.debian.org
Subject: More general build of binutils for cross-targets
Date: Sun, 8 Feb 2004 14:58:19 +0100
[Message part 1 (text/plain, inline)]
Package: binutils
Version: 2.14.90.0.7-5
Severity: wishlist

Hi James,

I've created a patch agains latest binutils (unstable) package to create
different target binutils packages, e.g. for cross-compiling. This patch
supports also the -hppa64 target and any other too. It is alternative
more general implementation what you have done. I needed this for your
powerpc cross-development environment. Are you interested in apply this
patch in future releases?
None, I'm using debhelper for this extension. (I don't know why you don't but it was easier for me to do so.)

-- 
 .''`.   __   _                                           Raphael Bossek
: :' :  / /  (_)__  __ ____  _                  bossekrNOSPAM@debian.org
`. `'  / /__/ / _ \/ // /\ \/ /  (2.4.24-1-k8+bluez)   http://www.s4l.de
  `-  /____/_/_//_/\_ _/ /_/\_\  Debian GNU/Linux 3.0      ICQ #40047651

      UNIX is user friendly, it's just picky about who its friends are


[binutils.patch (application/octet-stream, attachment)]
[Message part 3 (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #10 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: 231707@bugs.debian.org, 231707-submitter@bugs.debian.org
Subject: Alternative patch to binutils source package to create cross-binutils packages
Date: Thu, 12 Feb 2004 01:56:03 +0300
[Message part 1 (text/plain, inline)]
Hello.

Yesterday I've created a patch for binutils source thatmakes it possible to 
build cross-binutils packages for cross-compiling.

Before submitting my patch, I looked through binutils bug reports and found 
this one...

I've looked quickly through your patch. Here are some comments:

- I don't see any rationale for binutils-dev-cross.

- I believe it is a bad idea to remove cross-binutils binaries hardlinks 
from /usr/TARGET/bin. These hardlinks don't occupy any additional space, 
and it may be useful to have them there. E.g. current gcc-3.3 source 
package adds /usr/TARGET/bin to PATH to make dh_strip to work with 
non-native binaries without requiring binutils-multiarch to be installed.

- binutils.postinst only runs "ldconfig", and binutils-cross package seems 
not to provide any .so libraries in standard paths. So what for making it 
binutils-cross's postinst?

- what for to remove man pages from binutils-cross?

Anyway, I am posting my patch - just for case. It's much simpler, seems to 
work (I was able to create cross-binutils for all archs supported by 
debian; and it should be possible to create packages even for non-linux 
targets), contains a small usage instruction, and does not use debhelper 
(just to look more like the original debian/rules).
[binutils-cross.patch (text/x-diff, attachment)]

Message sent on to Raphael Bossek <raphael.bossek@gmx.de>:
Bug#231707. Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to James Troup <james@nocrew.org>:
Extra info received and forwarded to list. Full text and rfc822 format available.

Message #18 received at 231707@bugs.debian.org (full text, mbox):

From: James Troup <james@nocrew.org>
To: "Nikita V. Youshchenko" <yoush@cs.msu.su>
Cc: 231707@bugs.debian.org
Subject: Re: Bug#231707: Alternative patch to binutils source package to create cross-binutils packages
Date: Wed, 11 Feb 2004 23:17:46 +0000
"Nikita V. Youshchenko" <yoush@cs.msu.su> writes:

> Anyway, I am posting my patch - just for case. It's much simpler, seems to

and doesn't user debhelper.  Yay, you.

P.S. please don't anyone apply the other patch, on initial inspection
it seems quite broken.  I haven't had a chance to properly look at
Nikita's yet.

-- 
James



Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Raphael Bossek <raphael.bossek@gmx.de>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #23 received at 231707@bugs.debian.org (full text, mbox):

From: Raphael Bossek <raphael.bossek@gmx.de>
To: "Nikita V. Youshchenko" <yoush@cs.msu.su>, james@ruari-quinn.demon.co.uk
Cc: 231707@bugs.debian.org
Subject: Re: Bug#231707: Alternative patch to binutils source package to create cross-binutils packages
Date: Sat, 14 Feb 2004 20:35:35 +0100
[Message part 1 (text/plain, inline)]
James, it whould be nice to hear a more detailed comment why this
patch is broken.

Nikita,

> - I don't see any rationale for binutils-dev-cross.
Hmm, you intent to leave the header files within binutils-cross?
The existence of binutils-dev-cross is the same as binutils-dev is,
nothing more or less.

> - I believe it is a bad idea to remove cross-binutils binaries
> hardlinks from /usr/TARGET/bin.
Who is removing them? I can remember doing it explicit.

> These hardlinks don't occupy any additional space, and it may be
> useful to have them there.
Using hardlink may be usefull for the size of the Debian package to
speed-up downloads over the I-Net. A possible improvement on this patch
if someone requests it.

> E.g. current gcc-3.3 source 
> package adds /usr/TARGET/bin to PATH to make dh_strip to work with 
> non-native binaries without requiring binutils-multiarch to be
> installed.
This functionality won't be broken with or without hardlinks. If all
required files are wihtin /usr/TARGET/bin everything will work as
expected.

> - binutils.postinst only runs "ldconfig", and binutils-cross package
> seems not to provide any .so libraries in standard paths. So what for
> making it binutils-cross's postinst?
No additional maintainance required if something change upstream. Also
make the maintainance as easy as possible between native and cross.

> - what for to remove man pages from binutils-cross?
Adding man pages for cross applications should not be a big task.

> contains a small usage instruction, and does not use debhelper
1) Why is there any usage instruction required?
Here is a big difference between the patches. For yours you have to
specify the desired target and built the package again. If you look
at my patch you will see that binutils for all cross targets are
created out-of-the-box without the requirement to rebuild the package
again. This save a lot of time for all the people linke me who like
to use a package not to built it themself again and again if an bugfix
release is announced.

2) Never heard that it is important to avoid debhelper? It works fine
for me and saved me a lot of time while packaging...

--
Raphael
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #28 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: Raphael Bossek <raphael.bossek@gmx.de>
Cc: 231707@bugs.debian.org
Subject: Re: Bug#231707: Alternative patch to binutils source package to create cross-binutils packages
Date: Thu, 19 Feb 2004 00:49:59 +0300
Hello

> Nikita,
>
> > - I don't see any rationale for binutils-dev-cross.
> Hmm, you intent to leave the header files within binutils-cross?
> The existence of binutils-dev-cross is the same as binutils-dev is,
> nothing more or less.

Definitly you don't need these headers for cross-compile environment.
In general, I can hardly imagine a situation when you need to link anything 
against cross-libbfd.

> > - I believe it is a bad idea to remove cross-binutils binaries
> > hardlinks from /usr/TARGET/bin.
> Who is removing them? I can remember doing it explicit.

You patch manually removes them:
+       rm -rf $(d_bin_cross)/usr/$(DEB_HOST_GNU_TYPE)

> > These hardlinks don't occupy any additional space, and it may be
> > useful to have them there.
> Using hardlink may be usefull for the size of the Debian package to
> speed-up downloads over the I-Net. A possible improvement on this patch
> if someone requests it.

Hard links are there by default after make install; just dont remove 
them :).

> > - binutils.postinst only runs "ldconfig", and binutils-cross package
> > seems not to provide any .so libraries in standard paths. So what for
> > making it binutils-cross's postinst?
> No additional maintainance required if something change upstream. Also
> make the maintainance as easy as possible between native and cross.

You can't guarantee that code added to binutils.postinst will be 
appropriate for binutils-cross postinst. E.g. any playing with 
update-alternatives won't work.

> > - what for to remove man pages from binutils-cross?
> Adding man pages for cross applications should not be a big task.

Your patch removes them manually:
+       rm -rf $(d_bin_cross)/usr/share

> > contains a small usage instruction, and does not use debhelper
> 1) Why is there any usage instruction required?
> Here is a big difference between the patches. For yours you have to
> specify the desired target and built the package again. If you look
> at my patch you will see that binutils for all cross targets are
> created out-of-the-box without the requirement to rebuild the package
> again. This save a lot of time for all the people linke me who like
> to use a package not to built it themself again and again if an bugfix
> release is announced.

I don't think it is a good idea to pollute debian archive with all 
host-target cross-binutils combinations. I hardly believe anybody will 
need cross-binutils for non-x86 host :).  And there are lots of possible 
targets other than linux on debian-supported archs.
On the other hand, it should not be hard for anyone experienced enough to 
do cross-development to run 2 commands to create cross-binutils for exact 
host-target combination.
And rebuild is actually required only if you face a bug - not each time 
package updates.

I can remember that I've read somewhere that Debian decided not to provide 
cross-development tools for all host-target combinations because of it is 
very resource-costy and not much useful for wide community. Since some 
debian users and developers still need cross-development tools, and 
non-deb install is definitly a bad idea, I thought that making source 
package to build cross-deb if explicitly asked to is a good trade-off.

Some time ago I did that with gcc-3.3 package (there already was some code, 
but it didn't work for me) - yes, gcc-3.3 source package currently in sid 
can build cross-compilers now if it is explicitly asked to.
Then I tried to do it with binutils - the resulting patch is what I posted.

Another proposed solution for creating debs for cross-toolchain was 
toolchain-source package, but it's fundamental problem is that unless it 
is not updated on the regular basis it becomes obsolete, and this is 
exactly what happened.

> 2) Never heard that it is important to avoid debhelper? It works fine
> for me and saved me a lot of time while packaging...

The only reason to avoid debhelper was that it was not used in the original 
debian/rules, and I didn't want to change the style that James has chosen 
for debian/rules.

Nikita




Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #33 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: 231707@bugs.debian.org, debian-embedded@lists.debian.org
Subject: Updated cross-binutils patch
Date: Thu, 24 Jun 2004 00:22:14 +0400
[Message part 1 (text/plain, inline)]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.

Attached to this message is my updated patch to binutils debian source 
package that enables cross-binutils builds.

The only difference from the previous version is that now it sets same 
additional --enable-targets for cross targets as are set for native 
targets.

As previously, the patch only adds additional targets to debian/rules. 
Native build is not affected anyhow.


Do I understand correctly that debian binutils source package + 
binutils.cross patch is the 'official' way of building emdebian 
cross-binutils? If so, maybe we should ask James Troup once more to 
include this (definitly harmless) patch to the official package?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA2eZ7sTbPknTfAB4RAiNtAJsGqKv4AbErFDYZ+VUpBpq/Eoi7KwCfQeJz
x4jrR9Cdlz92kB8tZdwJo/Y=
=MOZc
-----END PGP SIGNATURE-----
[binutils-cross.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Wookey <wookey@aleph1.co.uk>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #38 received at 231707@bugs.debian.org (full text, mbox):

From: Wookey <wookey@aleph1.co.uk>
To: "Nikita V. Youshchenko" <yoush@cs.msu.su>
Cc: 231707@bugs.debian.org, debian-embedded@lists.debian.org
Subject: Re: Updated cross-binutils patch
Date: Wed, 30 Jun 2004 11:57:56 +0100
+++ Nikita V. Youshchenko [04-06-24 00:22 +0400]:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hello.
> 
> Attached to this message is my updated patch to binutils debian source 
> package that enables cross-binutils builds.
> 
> The only difference from the previous version is that now it sets same 
> additional --enable-targets for cross targets as are set for native 
> targets.
> 
> As previously, the patch only adds additional targets to debian/rules. 
> Native build is not affected anyhow.
> 
> 
> Do I understand correctly that debian binutils source package + 
> binutils.cross patch is the 'official' way of building emdebian 
> cross-binutils? 

Yes - or at least that's the way I'd like to see it done, and what we'll det
up on the buildd machine when someone gets round to it.

> If so, maybe we should ask James Troup once more to 
> include this (definitly harmless) patch to the official package?

That would be great. Please do.



Wookey
-- 
Aleph One Ltd, Bottisham, CAMBRIDGE, CB5 9BA, UK  Tel +44 (0) 1223 811679
work: http://www.aleph1.co.uk/     play: http://www.chaos.org.uk/~wookey/



Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #43 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: Wookey <wookey@aleph1.co.uk>
Cc: 231707@bugs.debian.org, debian-embedded@lists.debian.org
Subject: Re: Updated cross-binutils patch
Date: Wed, 7 Jul 2004 23:37:52 +0400
[Message part 1 (text/plain, inline)]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Yes - or at least that's the way I'd like to see it done, and what we'll
> det up on the buildd machine when someone gets round to it.

Until that's done, maybe the site should point to my repository that 
contains cross-toolchain debs?

> > If so, maybe we should ask James Troup once more to
> > include this (definitly harmless) patch to the official package?
>
> That would be great. Please do.

I'm afraid I'm the wrong person to do such "semi-official" request. I'm not 
even a DD yet.

Attached to this message is a slightly updated version of 
binutils-cross.patch that makes binutils-arm-linux package to conflict 
with binutils-arm, and binutils-powerpc-linux to conflict with 
binutils-powerpc. This will avoid "file overlap" errors when installing on 
system with old emdebian packages already installed.

Nikita
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA7FEUsTbPknTfAB4RAp7jAJ9nhMVCOtdqLwUHadYcX+lOVOZuSACfb1c0
iv0gC6hu+kA+18awgueel5M=
=UH5b
-----END PGP SIGNATURE-----
[binutils-cross.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #48 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: Wookey <wookey@aleph1.co.uk>
Cc: 231707@bugs.debian.org, debian-embedded@lists.debian.org
Subject: Re: Updated cross-binutils patch
Date: Thu, 8 Jul 2004 00:52:28 +0400
[Message part 1 (text/plain, inline)]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Attached to this message is a slightly updated version of
> binutils-cross.patch that makes binutils-arm-linux package to conflict
> with binutils-arm, and binutils-powerpc-linux to conflict with
> binutils-powerpc. This will avoid "file overlap" errors when installing
> on system with old emdebian packages already installed.

One more update to fix failure of mipsel-linux target build: 
- --enable-targets should be mips64el-linux, not mipsel64-linux.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA7GKQsTbPknTfAB4RAtFMAJ9aT/ulE8eoK8F8zGETwk0GnbDR6wCgkzAc
hLj/cFryAh6NTw/HpmQumqo=
=Vqxw
-----END PGP SIGNATURE-----
[binutils-cross.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Philippe De Swert <philippe.deswert@student.denayer.wenk.be>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #53 received at 231707@bugs.debian.org (full text, mbox):

From: Philippe De Swert <philippe.deswert@student.denayer.wenk.be>
To: "Nikita V. Youshchenko" <yoush@cs.msu.su>
Cc: Wookey <wookey@aleph1.co.uk>, 231707@bugs.debian.org, debian-embedded@lists.debian.org
Subject: Re: Updated cross-binutils patch
Date: Thu, 8 Jul 2004 10:20:05 +0200
Hi people, 
 
Quoting "Nikita V. Youshchenko" <yoush@cs.msu.su>: 
 
> -----BEGIN PGP SIGNED MESSAGE----- 
> Hash: SHA1 
>  
> > Yes - or at least that's the way I'd like to see it done, and what we'll 
> > det up on the buildd machine when someone gets round to it. 
>  
> Until that's done, maybe the site should point to my repository that  
> contains cross-toolchain debs? 
 
This is a  really good idea, so we can point people to a place to get those 
toolchains. It will solve a lot of cross_toolchain searching. 
 
greets, 
 
Philippe 
 
| Philippe De Swert -GNU/linux - uClinux freak-      
|      
| Stag developer http://stag.mind.be/  
| Emdebian developer: http://www.emdebian.org  
|   
| Please do not send me documents in a closed format. (*.doc,*.xls,*.ppt)    
| Use the open alternatives. (*.pdf,*.ps,*.html,*.txt)    
| Why? http://pallieter.is-a-geek.org:7832/~johan/word/english/    

--------------------------------------------------------------------------
Gestuurd via het webmailsysteem van het De Nayer Instituut: www.denayer.be




Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #58 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: 231707@bugs.debian.org
Cc: debian-embedded@lists.debian.org
Subject: Updated binutils-cross.patch, with lib64 support
Date: Thu, 15 Jul 2004 11:46:47 +0400
[Message part 1 (text/plain, inline)]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.

Attached to this message there is my latest version of binutils-cross.patch
Compared to previous version, it has proper support for lib64 on cross 
targets. This is implemented as a small additional patch in debian/patches 
that ensures that ${exec_prefix}/$target-alias}/lib64 is added to default 
library search path for 64bit targets. This patch probably should be 
submitted upstream, since it looks to be the correct solution for 
multilib'ed cross-target support.

Please consider applying binutils-cross.patch to the next debian binutils 
upload. The patch doesn't affect native targets build in any way, and is 
really useful for cross-development. E.g. it's currently the official 
method used by debian-embedded, and is needed to build cross-compilers 
from gcc-* source packages.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFA9jZqsTbPknTfAB4RAqCEAJ0UaagNN7Gxi9xlS2VpMsMDVFT84gCfehdS
9MUHR3VOEhmrGJyHBhys2sc=
=dqqv
-----END PGP SIGNATURE-----
[binutils-cross.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #63 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: 231707@bugs.debian.org
Cc: debian-embedded@lists.debian.org
Subject: Binutils-cross.patch updated for binutils 2.15
Date: Tue, 24 Aug 2004 16:43:10 +0400
[Message part 1 (text/plain, inline)]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.

Here is binutils-cross.patch updated to apply cleanly to binutils 2.15-1 
source package.
Pre-built cross binutils debs ar at usual place, and seem to work ok while 
building cross-compilers for all debian archs.

Nikita
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBKzfisTbPknTfAB4RAjZMAKCVhsN4Z4Zi20Mp0uoScVxyR5gd8gCfcXlH
llu7KpKft1gnT165K4A/RFA=
=N8FQ
-----END PGP SIGNATURE-----
[binutils-cross-2.15-1.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #68 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: 231707@bugs.debian.org
Subject: cross-binutils patch for 2.15-4
Date: Fri, 1 Oct 2004 00:11:05 +0400
[Message part 1 (text/plain, inline)]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello.
This is a version of cross-binutils patch that applies cleanly to binutils 
2.15-4 source debian package.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBXGhjv3x5OskTLdsRAvBMAJ99/eNKfLmJAKdSSm4bLfoWT2OK/gCdGNDb
DAC57l+4RENSuupsIj0izdo=
=oyy6
-----END PGP SIGNATURE-----
[binutils-cross-2.15-4.patch (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #73 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: 231707@bugs.debian.org
Subject: cross-binutils patch for 2.15-5
Date: Tue, 30 Nov 2004 18:16:37 +0300
[Message part 1 (text/plain, inline)]
Here is cross-binutils patch for 2.15-5.
Additional change is support for x86_64-linux target (and any other target 
that has '_' in it's name); in the package name '_' is replaced with '-'.
[binutils-cross-2.15-5.patch.20041130 (text/x-diff, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Raphael Bossek <raphael.bossek@gmx.de>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #78 received at 231707@bugs.debian.org (full text, mbox):

From: Raphael Bossek <raphael.bossek@gmx.de>
To: 231707@bugs.debian.org
Cc: "Nikita V. Youshchenko" <yoush@cs.msu.su>
Subject: Update the binutils-cross patch against 2.15-6
Date: Wed, 01 Jun 2005 11:38:47 +0200
[Message part 1 (text/plain, inline)]
This patch is an update against 2.15-6 sources with an additional
fix for default search path of shared libararies.
[binutils-cross-2.15-6.patch.20050601 (text/plain, inline)]
diff -Nru binutils-2.15/debian/README.cross binutils-2.15.cross/debian/README.cross
--- binutils-2.15/debian/README.cross	Thu Jan  1 01:00:00 1970
+++ binutils-2.15.cross/debian/README.cross	Wed Jun  1 11:29:26 2005
@@ -0,0 +1,12 @@
+Cross-binutils debian packages can be built directly from binutils
+source package.
+
+To build cross-binutils package, download and unpack binutils
+source package, and run
+
+TARGET=your-target fakeroot debian/rules binary-cross
+
+(substitute your target name, e.g. "arm-linux", instead of "your-target")
+
+---
+Nikita Youshchenko <yoush@cs.msu.su>
diff -Nru binutils-2.15/debian/control.cross.in binutils-2.15.cross/debian/control.cross.in
--- binutils-2.15/debian/control.cross.in	Thu Jan  1 01:00:00 1970
+++ binutils-2.15.cross/debian/control.cross.in	Wed Jun  1 11:29:26 2005
@@ -0,0 +1,12 @@
+Package: PACKAGE
+Architecture: any
+Depends: binutils, ${shlibs:Depends}
+Suggests: binutils-doc (= ${Source-Version})
+Priority: extra
+OLD_EMDEBIAN_CONFLICT
+Description: The GNU binary utilities, for TARGET target
+ This package provides GNU assembler, linker and binary utilities
+ for TARGET target, for use in cross-compilation environment.
+ .
+ You don't need this package unless you plan to cross-compile programs
+ for TARGET.
diff -Nru binutils-2.15/debian/patches/00list binutils-2.15.cross/debian/patches/00list
--- binutils-2.15/debian/patches/00list	Wed Jun  1 11:30:45 2005
+++ binutils-2.15.cross/debian/patches/00list	Wed Jun  1 11:30:03 2005
@@ -16,3 +16,4 @@
 121_ia64_unwind_fixes
 122_m68k_undefweak_symbols
 123_bfd_overflow_fix
+999_lib64_for_cross
diff -Nru binutils-2.15/debian/patches/999_lib64_for_cross.dpatch binutils-2.15.cross/debian/patches/999_lib64_for_cross.dpatch
--- binutils-2.15/debian/patches/999_lib64_for_cross.dpatch	Thu Jan  1 01:00:00 1970
+++ binutils-2.15.cross/debian/patches/999_lib64_for_cross.dpatch	Wed Jun  1 11:29:26 2005
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+## 999_lib64_for_cross.dpatch by Nikita Youshchenko <yoush@cs.msu.su>
+##
+## DP: Add /usr/${target-alias}/lib${LIBPATH_SUFFIX} to ld's default
+## DP: library search path for cross targets. Needed for cross targets that
+## DP: try to support both 32bit and 64bit emulations.
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+        exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh binutils-2.14.90.0.7.cross/ld/genscripts.sh
+--- /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh	2003-10-29 20:37:48.000000000 +0300
++++ binutils-2.14.90.0.7.cross/ld/genscripts.sh	2004-07-15 00:29:19.000000000 +0400
+@@ -176,6 +176,26 @@
+   ::) LIB_PATH=${tool_lib} ;;
+   *) LIB_PATH=${tool_lib}:${LIB_PATH} ;;
+   esac
++  # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
++  # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} to default search path, because
++  # 64bit libraries may be in both places, depending on cross-development
++  # setup method (e.g.: /usr/s390x-linux/lib64 vs /usr/s390-linux/lib64)
++  case "${LIBPATH_SUFFIX}:${tool_lib}" in
++    :*) ;;
++    *:*${LIBPATH_SUFFIX}) ;;
++    *)
++      paths="${exec_prefix}/${target_alias}/lib${LIBPATH_SUFFIX}"
++      if [ "${TOOL_LIB}" != x ]; then
++        paths="${paths} ${exec_prefix}/${TOOL_LIB}/lib${LIBPATH_SUFFIX}"
++      fi
++      for path in $paths; do
++        case :${LIB_PATH}: in
++          ::: | *:${path}:*) ;;
++          *) LIB_PATH=${path}:${LIB_PATH} ;;
++        esac
++      done
++    ;;
++  esac
+ fi
+ 
+ LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
diff -Nru binutils-2.15/debian/rules binutils-2.15.cross/debian/rules
--- binutils-2.15/debian/rules	Wed Jun  1 11:30:45 2005
+++ binutils-2.15.cross/debian/rules	Wed Jun  1 11:29:26 2005
@@ -377,7 +377,8 @@
 endif
 
 	$(install_file) $(pwd)/test-summary binutils/NEWS  \
-	                debian/README.Debian $(d_bin)/usr/share/doc/$(p_bin)/
+	                debian/README.Debian debian/README.cross \
+			$(d_bin)/usr/share/doc/$(p_bin)/
 
 	$(install_file) binutils/ChangeLog $(d_bin)/usr/share/doc/$(p_bin)/changelog
 
@@ -433,6 +434,99 @@
 	chmod -R go=rX  $(d_hppa64)
 	dpkg --build $(d_hppa64) ..
 endif
+
+################################################################################
+
+#################
+# cross targets #
+#################
+
+p_cross = $(subst _,-,binutils-$(TARGET))
+d_cross = debian/$(p_cross)
+
+ifneq ($(filter sparc-linux powerpc-linux mips-linux, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux=%64-linux)
+endif
+ifneq ($(filter i386-linux i486-linux i586-linux x86-linux, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=x86_64-linux
+endif
+ifeq ($(TARGET), x86_64-linux)
+ADDITIONAL_TARGETS = --enable-targets=i386-linux
+endif
+ifeq ($(TARGET), mipsel-linux)
+ADDITIONAL_TARGETS = --enable-targets=mips64el-linux
+endif
+ifeq ($(TARGET), sparc64-linux)
+ADDITIONAL_TARGETS = --enable-targets=sparc-linux
+endif
+ifeq ($(TARGET), s390-linux)
+ADDITIONAL_TARGETS = --enable-targets=s390x-linux
+endif
+
+configure-$(TARGET)-stamp: patch-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf configure-$(TARGET)-stamp builddir-$(TARGET)
+	mkdir builddir-$(TARGET)
+	cd builddir-$(TARGET) \
+	    && env CC="$(CC)" ../configure --host=$(DEB_HOST_GNU_TYPE) \
+	        --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/usr \
+	        --libdir=/usr/$(TARGET)/lib $(ADDITIONAL_TARGETS)
+	touch $@
+
+build-$(TARGET)-stamp: configure-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	$(MAKE) -C builddir-$(TARGET) CFLAGS="$(CFLAGS)"
+	touch $@
+
+install-$(TARGET)-stamp: build-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross)
+	$(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/usr \
+		libdir=$(pwd)/$(d_cross)/usr/$(TARGET)/lib \
+		mandir=$(pwd)/$(d_cross)/usr/share/man install
+	rm -rf $(d_cross)/usr/lib $(d_cross)/usr/info $(d_cross)/usr/share/locale
+	$(STRIP) $(d_cross)/usr/bin/*
+	gzip -9 $(d_cross)/usr/share/man/man1/*
+	touch $@
+
+binary-cross: checkroot install-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	
+	sed '/^$$/ q' < debian/control > debian/control.$(TARGET)
+	case "$(TARGET)" in \
+	  arm-linux|powerpc-linux) \
+	    sed "s/TARGET/$(TARGET)/g; s/PACKAGE/$(p_cross)/; s/OLD_EMDEBIAN_CONFLICT/Conflicts: binutils-`echo $(TARGET) | sed s/-linux//`/" < debian/control.cross.in >> debian/control.$(TARGET) ;; \
+	  *) \
+	    grep -v OLD_EMDEBIAN_CONFLICT debian/control.cross.in | sed "s/TARGET/$(TARGET)/g; s/PACKAGE/$(p_cross)/" >> debian/control.$(TARGET) ;; \
+	esac
+	
+	$(install_dir) $(d_cross)/DEBIAN
+	
+	$(install_dir) $(d_cross)/usr/share/doc/$(p_cross)/
+	$(install_file)	debian/changelog $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	$(install_file)	debian/copyright debian/README.cross $(d_cross)/usr/share/doc/$(p_cross)/
+	gzip -f -9 $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	
+	for pkg in bfd gas gprof ld; do \
+	  ln -sf ../binutils/$$pkg $(d_cross)/usr/share/doc/$(p_cross)/$$pkg; \
+	done
+
+	rm -f debian/substvars
+	dpkg-shlibdeps $(d_cross)/usr/bin/*
+	dpkg-gencontrol -cdebian/control.$(TARGET) -P$(d_cross) -p$(p_cross)
+	dpkg --build $(d_cross) ..
+
+clean-cross: unpatch
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross) debian/control.$(TARGET) debian/files debian/substvars \
+		builddir-$(TARGET) {configure,build,install}-$(TARGET)-stamp
+
+.PHONY: binary-cross clean-cross
 
 ################################################################################
 

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #83 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: Raphael Bossek <raphael.bossek@gmx.de>
Cc: debian-embedded@lists.debian.org, 231707@bugs.debian.org
Subject: Re: binutils 2.15 without default search path /usr/arch-linux/lib (+patch)
Date: Thu, 7 Jul 2005 01:12:32 +0400
[Message part 1 (text/plain, inline)]
Hello Raphael and all.

> I'm now sure it's a binutils problem with the search path for
> libraries. Here my analysis of the problem and a patch against
> binutils-cross-2.15-5.patch.20041130 (see Debian bug #231707).

At last I've got some time to review this thing.

It turned that Raphael's fix is not a fix, but just a working workaround.

> The ld/ldmain.c:670 function set_scripts_dir() try to identify
> the location of libraryies. The directory name will be determined
> using the make_relative_prefix() function which create a relative
> path using three informations:
>   1. The path of the arch-linux-ld application (searching PATH)
>   2. The BINDIR (configure option --prefix=/usr + /bin by default)
>   3. The SCRIPTDIR (configure option --libdir by default {prefix}/lib)
>
> Today folowing values are set:
>   1. = /usr/bin/arch-linux-ld
>   2. = /usr/bin
>   3. = /usr/lib
>
> The make_relative_prefix() function create now a relative path
> between (2) and (3). This is "../lib" and applies this to the
> dir's part of (1): "/usr/../lib" This directory will be now used
> to determine the location of *cross* libraries.

Not exactly.
Actually, set_scripts_dir() tries several directories (built by some 
strange games with make_relative_prefix()), and looks for ldscripts/ 
subdir in each one. When ldscripts/ directory is found, it's parent is 
appended to the library search path, and search stops.

In normal case, the first try should be the hit. It is a try for the 
directory passed in SCRIPTSDIR variable from the Makefile.

In normal case, this should be /usr/$(target-alias)/lib. With upstream 
source, this is the case, so cross-ld searches the correct dir.

But in Debian source package it happenes to be /usr/lib
This is caused by debian/patches/001_ld_makefile_patch.dpatch, which 
explicitly changed SCRIPTSDIR to /usr/lib. We can only guess what for it 
does that; probably to get ldscripts installed to /usr/lib/ldscripts on 
Debian.

Anyway, I fixed 001_ld_makefile_patch.dpatch not to change SCRIPTSDIR when 
building cross-binutils.

As for Raphael's solution to use --libdir, it's a workaround with 
side-effects, such as installation of *native* libs build with binutils 
into /usr/$(target-alias)/lib/, and probably some others, at code level. I 
think it's somewhat dangerous.

I've updated the patch to fix the cause of the problem. It is attached.

It is still against sarge's version, 2.15-6.
I've updated binary packages in my repository to use this version with this 
patch.

Later versions will hopely follow soon.

Nikita
[binutils-cross-2.15-6.patch.20050707 (text/x-diff, attachment)]
[Message part 3 (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to "Nikita V. Youshchenko" <yoush@cs.msu.su>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #88 received at 231707@bugs.debian.org (full text, mbox):

From: "Nikita V. Youshchenko" <yoush@cs.msu.su>
To: Matthias Klose <doko@cs.tu-berlin.de>
Cc: debian-embedded@lists.debian.org, 231707@bugs.debian.org
Subject: Updated cross-binutils patch for binutils 2.16.1-2
Date: Wed, 13 Jul 2005 01:05:19 +0400
[Message part 1 (text/plain, inline)]
Hello.

Attached to this mail, there is updated cross-binutils patch for binutils 
2.16.1-2 source package.

Compared to previouse versions, it has the following change.

*) Tool names follow recent change in dpkg-architecture, and now are 
'arm-linux-gnu-ld' and similar.
For old names, symlinks are provided
 (e.g. arm-linux-ld -> arm-linux-gnu-ld).
Package is named 'binutils-arm-linux-gnu' and Conflicts/Replaces/Provides 
binutils-arm-linux.

*) TARGET now may contain both debian architecture name and GNU target 
name; both will be processed correctly.

Build instructions are the same as usual, see debian/README.cross.

Updated cross-binutils sid binary packages for i386 host and all debian 
targets are available in my repository at 
http://zigzag.lvk.cs.msu.su/~nikita/debian/sid/.
(Sarge version is still at 
http://zigzag.lvk.cs.msu.su/~nikita/debian/sarge/, and will be available 
there while sarge remains the current Debian release).
[binutils-cross-2.16.1-2.patch.20050712 (text/x-diff, attachment)]
[Message part 3 (application/pgp-signature, inline)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Josh Triplett <josh@psas.pdx.edu>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #93 received at 231707@bugs.debian.org (full text, mbox):

From: Josh Triplett <josh@psas.pdx.edu>
To: 231707@bugs.debian.org
Subject: Updated binutils-cross patch for 2.16.1cvs20050902-1
Date: Fri, 14 Oct 2005 01:18:41 -0700
[Message part 1 (text/plain, inline)]
package binutils
tags 231707 + patch
thanks

The attached patch is an update of Nikita's most recent patch to apply
cleanly to binutils 2.16.1cvs20050902-1.  With this patch, I can
successfully build an i386-hosted binutils targetting powerpc-linux-gnu.

I'm also adding the patch tag, since it doesn't seem to already be set
on this bug.

- Josh Triplett

[binutils-cross-2.16.1cvs20050902-1.patch (text/x-patch, inline)]
diff -Naur binutils-2.16.1cvs20050902.old/debian/README.cross binutils-2.16.1cvs20050902/debian/README.cross
--- binutils-2.16.1cvs20050902.old/debian/README.cross	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/README.cross	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,13 @@
+Cross-binutils debian packages can be built directly from binutils
+source package.
+
+To build cross-binutils package, download and unpack binutils
+source package, and run
+
+TARGET=your-target fakeroot debian/rules binary-cross
+
+Target name may be set both as debian arch name (such as 'arm', 'powerpc', ...)
+ans ad GNU system type (arm-linux-gnu, powerpc-linux-gnu, etc).
+
+---
+Nikita Youshchenko <yoush@cs.msu.su>
diff -Naur binutils-2.16.1cvs20050902.old/debian/generate-cross-control binutils-2.16.1cvs20050902/debian/generate-cross-control
--- binutils-2.16.1cvs20050902.old/debian/generate-cross-control	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/generate-cross-control	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+target=`echo -n $1 | sed 's/_/-/g'`
+
+sed '/^$/ q' < debian/control
+
+echo "Package: binutils-$target"
+echo 'Architecture: any'
+echo 'Depends: binutils, ${shlibs:Depends}'
+echo 'Suggests: binutils-doc (= ${Source-Version})'
+
+# Add conflicts/replaces/provides for older names of same binutils
+oldtarget=`echo -n $target | sed 's/-linux-gnu$/-linux/'`
+if [ "$target" != "$oldtarget" ]; then
+  # Add conflicts with old EmDebian toolchain which was available for
+  # arm and powerpc
+  if [ "$oldtarget" = "arm-linux" ] || [ "$oldtarget" = "powerpc-linux" ]; then
+    veryoldtarget=`echo -n $target | sed 's/-linux$//'`
+    echo "Conflicts: binutils-$oldtarget, binutils-$veryoldtarget"
+  else
+    echo "Conflicts: binutils-$oldtarget"
+  fi
+  echo "Replaces: binutils-$oldtarget"
+  echo "Provides: binutils-$oldtarget"
+fi
+echo "Description: The GNU binary utilities, for $target target"
+echo " This package provides GNU assembler, linker and binary utilities"
+echo " for $target target, for use in cross-compilation environment."
+echo " ."
+echo " You don't need this package unless you plan to cross-compile programs"
+echo " for $target."
diff -Naur binutils-2.16.1cvs20050902.old/debian/patch-stamp binutils-2.16.1cvs20050902/debian/patch-stamp
--- binutils-2.16.1cvs20050902.old/debian/patch-stamp	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/patch-stamp	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,2 @@
+Patches applied in the Debian version of :
+
diff -Naur binutils-2.16.1cvs20050902.old/debian/patches/001_ld_makefile_patch.dpatch binutils-2.16.1cvs20050902/debian/patches/001_ld_makefile_patch.dpatch
--- binutils-2.16.1cvs20050902.old/debian/patches/001_ld_makefile_patch.dpatch	2005-10-13 23:58:15.000000000 -0700
+++ binutils-2.16.1cvs20050902/debian/patches/001_ld_makefile_patch.dpatch	2005-10-13 23:57:48.000000000 -0700
@@ -6,6 +6,10 @@
 ## DP: Author: Chris Chimelis <chris@debian.org>
 ## DP: Upstream status: N/A
 ## DP: Date: ??
+## DP: Fixed by Nikita Youshchenko <yoush@cs.msu.su> to be correct for
+## DP: cross-binutils - in that case change of $(scriptdir) to /usr/lib causes
+## DP: cross-ld to look for libraries in /usr/lib instead of
+## DP: /usr/$(target-alias)/lib
 
 if [ $# -ne 1 ]; then
     echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
@@ -29,24 +33,50 @@
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.am /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am
 --- ./ld/Makefile.am	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am	2005-09-02 21:42:18.000000000 +0000
-@@ -20,7 +20,7 @@
+@@ -20,7 +20,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  
  EMUL = @EMUL@
  EMULATION_OFILES = @EMULATION_OFILES@
+@@ -431,7 +435,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.in /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in
 --- ./ld/Makefile.in	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in	2005-09-02 21:43:37.259127535 +0000
-@@ -268,7 +268,7 @@
+@@ -268,7 +268,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  BASEDIR = $(srcdir)/..
  BFDDIR = $(BASEDIR)/bfd
  INCDIR = $(BASEDIR)/include
+@@ -1173,7 +1177,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
diff -Naur binutils-2.16.1cvs20050902.old/debian/patches/00list binutils-2.16.1cvs20050902/debian/patches/00list
--- binutils-2.16.1cvs20050902.old/debian/patches/00list	2005-10-13 23:58:15.000000000 -0700
+++ binutils-2.16.1cvs20050902/debian/patches/00list	2005-10-13 23:49:51.000000000 -0700
@@ -7,3 +7,4 @@
 117_mips_symbolic_link
 118_arm_pass_all
 120_mips_xgot_multigot_workaround
+999_lib64_for_cross
diff -Naur binutils-2.16.1cvs20050902.old/debian/patches/999_lib64_for_cross.dpatch binutils-2.16.1cvs20050902/debian/patches/999_lib64_for_cross.dpatch
--- binutils-2.16.1cvs20050902.old/debian/patches/999_lib64_for_cross.dpatch	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/patches/999_lib64_for_cross.dpatch	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+## 999_lib64_for_cross.dpatch by Nikita Youshchenko <yoush@cs.msu.su>
+##
+## DP: Add /usr/${target-alias}/lib${LIBPATH_SUFFIX} to ld's default
+## DP: library search path for cross targets. Needed for cross targets that
+## DP: try to support both 32bit and 64bit emulations.
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+        exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh binutils-2.14.90.0.7.cross/ld/genscripts.sh
+--- /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh	2003-10-29 20:37:48.000000000 +0300
++++ binutils-2.14.90.0.7.cross/ld/genscripts.sh	2004-07-15 00:29:19.000000000 +0400
+@@ -176,6 +176,26 @@
+   ::) LIB_PATH=${tool_lib} ;;
+   *) LIB_PATH=${tool_lib}:${LIB_PATH} ;;
+   esac
++  # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
++  # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} to default search path, because
++  # 64bit libraries may be in both places, depending on cross-development
++  # setup method (e.g.: /usr/s390x-linux/lib64 vs /usr/s390-linux/lib64)
++  case "${LIBPATH_SUFFIX}:${tool_lib}" in
++    :*) ;;
++    *:*${LIBPATH_SUFFIX}) ;;
++    *)
++      paths="${exec_prefix}/${target_alias}/lib${LIBPATH_SUFFIX}"
++      if [ "${TOOL_LIB}" != x ]; then
++        paths="${paths} ${exec_prefix}/${TOOL_LIB}/lib${LIBPATH_SUFFIX}"
++      fi
++      for path in $paths; do
++        case :${LIB_PATH}: in
++          ::: | *:${path}:*) ;;
++          *) LIB_PATH=${path}:${LIB_PATH} ;;
++        esac
++      done
++    ;;
++  esac
+ fi
+ 
+ LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
diff -Naur binutils-2.16.1cvs20050902.old/debian/rules binutils-2.16.1cvs20050902/debian/rules
--- binutils-2.16.1cvs20050902.old/debian/rules	2005-10-13 23:58:15.000000000 -0700
+++ binutils-2.16.1cvs20050902/debian/rules	2005-10-13 23:49:51.000000000 -0700
@@ -378,7 +378,8 @@
 endif
 
 	$(install_file) $(pwd)/test-summary binutils/NEWS  \
-	                debian/README.Debian $(d_bin)/usr/share/doc/$(p_bin)/
+	                debian/README.Debian debian/README.cross \
+			$(d_bin)/usr/share/doc/$(p_bin)/
 
 	$(install_file) binutils/ChangeLog $(d_bin)/usr/share/doc/$(p_bin)/changelog
 
@@ -438,6 +439,133 @@
 
 ################################################################################
 
+
+#################
+# cross targets #
+#################
+
+# If $(TARGET) is not set, try reading debian/target
+ifeq ($(TARGET),)
+TARGET := $(cat debian/target 2>/dev/null)
+endif
+
+# Process the following only if $(TARGET) is set
+ifneq ($(TARGET),)
+
+# Support TARGET both as Debian architecture specification (e.g. arm),
+# and as the target name (e.g. arm-linux-gnu).
+try_convert := $(shell dpkg-architecture -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null)
+ifneq ($(try_convert),)
+override TARGET := $(try_convert)
+endif
+
+# Many people expect cross-binutils to be named like 'arm-linux-ld', not
+# like 'arm-linux-gnu-ld'. Package will provide symlinks. In future, this may
+# be replaced with alternatives.
+tmp_cpu := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_CPU 2>/dev/null)
+tmp_os := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_OS 2>/dev/null)
+ifeq ($(TARGET),$(tmp_cpu)-$(tmp_os)-gnu)
+do_symlinks := yes
+else
+do_symlinks := no
+endif
+
+p_cross = $(subst _,-,binutils-$(TARGET))
+d_cross = debian/$(p_cross)
+
+ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu)
+endif
+ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu x86-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
+endif
+ifeq ($(TARGET), x86_64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu
+endif
+ifeq ($(TARGET), mipsel-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu
+endif
+ifeq ($(TARGET), sparc64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=sparc-linux-gnu
+endif
+ifeq ($(TARGET), s390-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390x-linux-gnu
+endif
+ifeq ($(TARGET), s390x-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390-linux-gnu
+endif
+
+configure-$(TARGET)-stamp: patch-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf configure-$(TARGET)-stamp builddir-$(TARGET)
+	mkdir builddir-$(TARGET)
+	cd builddir-$(TARGET) \
+	    && env CC="$(CC)" ../configure --host=$(DEB_HOST_GNU_TYPE) \
+	        --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/usr \
+		$(ADDITIONAL_TARGETS)
+	touch $@
+
+build-$(TARGET)-stamp: configure-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	$(MAKE) -C builddir-$(TARGET) CFLAGS="$(CFLAGS)"
+	touch $@
+
+install-$(TARGET)-stamp: build-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross)
+	$(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/usr \
+		mandir=$(pwd)/$(d_cross)/usr/share/man install
+	rm -rf $(d_cross)/usr/lib $(d_cross)/usr/info $(d_cross)/usr/share/locale
+	$(STRIP) $(d_cross)/usr/bin/*
+	gzip -9 $(d_cross)/usr/share/man/man1/*
+ifeq ($(do_symlinks),yes)
+	cd $(d_cross)/usr/bin && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+	cd $(d_cross)/usr/share/man/man1 && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+endif
+	touch $@
+
+binary-cross: checkroot install-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	
+	chmod 755 debian/generate-cross-control
+	debian/generate-cross-control $(TARGET) > debian/control.$(TARGET)
+	
+	$(install_dir) $(d_cross)/DEBIAN
+	
+	$(install_dir) $(d_cross)/usr/share/doc/$(p_cross)/
+	$(install_file)	debian/changelog $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	$(install_file)	debian/copyright debian/README.cross $(d_cross)/usr/share/doc/$(p_cross)/
+	gzip -f -9 $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	
+	for pkg in bfd gas gprof ld; do \
+	  ln -sf ../binutils/$$pkg $(d_cross)/usr/share/doc/$(p_cross)/$$pkg; \
+	done
+
+	rm -f debian/substvars
+	dpkg-shlibdeps $(d_cross)/usr/bin/*
+	dpkg-gencontrol -cdebian/control.$(TARGET) -P$(d_cross) -p$(p_cross)
+	dpkg --build $(d_cross) ..
+
+clean-cross: unpatch
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross) debian/control.$(TARGET) debian/files debian/substvars \
+		builddir-$(TARGET) {configure,build,install}-$(TARGET)-stamp
+
+.PHONY: binary-cross clean-cross
+
+endif
+
+################################################################################
+
 define checkdir
         test -f bfd/elf32.c -a -f debian/rules
 endef
diff -Naur binutils-2.16.1cvs20050902.old/debian/rules.orig binutils-2.16.1cvs20050902/debian/rules.orig
--- binutils-2.16.1cvs20050902.old/debian/rules.orig	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/rules.orig	2005-10-13 12:36:36.000000000 -0700
@@ -0,0 +1,453 @@
+#!/usr/bin/make -f
+# debian/rules file - for binutils (2.16.1cvs20050902)
+# Based on sample debian/rules file - for GNU Hello (1.3).
+# Copyright 1994,1995 by Ian Jackson.
+# Copyright 1998-2005 James Troup
+# I hereby give you perpetual unlimited permission to copy,
+# modify and relicense this file, provided that you do not remove
+# my name from the file itself.  (I assert my moral right of
+# paternity under the Copyright, Designs and Patents Act 1988.)
+# This file may have to be extensively modified
+
+################################################################################
+
+include /usr/share/dpatch/dpatch.make
+
+################################################################################
+
+p_bin = binutils
+p_dev = $(p_bin)-dev
+p_mul = $(p_bin)-multiarch
+p_doc = $(p_bin)-doc
+p_hppa64 = $(p_bin)-hppa64
+
+pwd   := $(shell pwd)
+d     = debian/tmp
+d_bin = $(d)
+d_dev = debian/$(p_dev)
+d_mul = debian/$(p_mul)
+d_doc = debian/$(p_doc)
+d_hppa64 = debian/$(p_hppa64)
+
+install_dir    = install -d -m 755
+install_file   = install -m 644
+install_script = install -m 755
+install_binary = install -m 755 -s
+
+DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+DEB_HOST_ARCH 	   := $(shell dpkg-architecture -qDEB_HOST_ARCH)
+DEB_HOST_GNU_TYPE  := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+
+CC     = gcc
+CFLAGS = -g -O2
+STRIP  = strip --remove-section=.comment --remove-section=.note
+
+VERSION       = $(shell sed -n 's/^ *VERSION=\(.*\)/\1/p' bfd/configure)
+MULTI_VERSION = $(VERSION)-multiarch
+MULTI_ARGS    = MAKEOVERRIDES="VERSION=$(MULTI_VERSION)"
+
+HPPA64_VERSION= $(VERSION)-hppa64
+HPPA64_ARGS   = MAKEOVERRIDES="VERSION=$(HPPA64_VERSION)"
+
+########################################
+
+CONFARGS = --enable-shared --prefix=/usr --build=$(DEB_BUILD_GNU_TYPE) \
+	   --host=$(DEB_HOST_GNU_TYPE)
+CONFLICTS = -VmainConflicts="gas, elf-binutils, modutils (<< 2.4.19-1)"
+
+ifeq ($(DEB_HOST_ARCH),sparc)
+	CONFARGS += --enable-targets=sparc64-linux-gnu
+	CONFLICTS = -VmainConflicts="gas, elf-binutils, modutils (<< 2.4.19-1), libc6-dev-sparc64 (<< 2.2.5-7)"
+endif
+ifeq ($(DEB_HOST_ARCH),sparc64)
+	CONFARGS += --enable-targets=sparc-linux-gnu
+	CONFLICTS = -VmainConflicts="gas, elf-binutils, libc6-dev-sparc64 (<< 2.2.5-7)"
+endif
+ifeq ($(DEB_HOST_ARCH),powerpc)
+	CONFARGS += --enable-targets=powerpc64-linux-gnu
+endif
+ifeq ($(DEB_HOST_ARCH),s390)
+	CONFARGS += --enable-targets=s390x-linux-gnu
+endif
+ifeq ($(DEB_HOST_ARCH),i386)
+	CONFARGS += --enable-targets=x86_64-linux-gnu
+endif
+ifeq ($(DEB_HOST_ARCH),mips)
+       CONFARGS += --enable-targets=mips64-linux-gnu
+endif
+ifeq ($(DEB_HOST_ARCH),mipsel)
+       CONFARGS += --enable-targets=mips64el-linux-gnu
+endif
+
+################################################################################
+
+################
+# clean target #
+################
+
+clean: unpatch
+	$(checkdir)
+	-rm -fr builddir-multi builddir-single builddir-hppa64
+	-find . -name \*.gmo -o -name \*~ -o -name \*.info | xargs rm -f
+	-rm -f $(pwd)/test-summary
+	-rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc) $(d_hppa64)
+	-rm -rf debian/patched debian/tmp debian/files debian/substvars
+
+################################################################################
+
+#######################
+# single-arch targets #
+#######################
+
+configure-single-stamp: patch-stamp
+	$(checkdir)
+	rm -rf configure-single-stamp \
+		builddir-single
+	mkdir builddir-single
+	cd builddir-single && env CC="$(CC)" \
+		../configure $(CONFARGS)
+	$(MAKE) -C builddir-single configure-host
+	touch configure-single-stamp
+
+build-single-stamp: configure-single-stamp
+	$(checkdir)
+	$(MAKE) -C builddir-single/bfd headers
+	$(MAKE) -C builddir-single \
+		CFLAGS="$(CFLAGS)"
+	-$(MAKE) -C builddir-single -k \
+		CFLAGS="$(CFLAGS)" check
+	cat builddir-single/binutils/binutils.sum \
+	    builddir-single/gas/testsuite/gas.sum \
+	    builddir-single/ld/ld.sum >> $(pwd)/test-summary
+	touch build-single-stamp
+
+################################################################################
+
+#####################
+# multiarch targets #
+#####################
+
+configure-multi-stamp: patch-stamp
+	$(checkdir)
+	rm -rf configure-multi-stamp \
+		builddir-multi
+	mkdir builddir-multi
+	cd builddir-multi \
+	    && env CC="$(CC)" ../configure $(CONFARGS) \
+		--enable-targets=alpha-linux-gnu,arm-linux-gnu,hppa-linux-gnu,i486-gnu,i486-linux-gnu,ia64-linux-gnu,m68k-linux-gnu,m68k-rtems,mips-linux-gnu,mipsel-linux-gnu,mips64-linux-gnu,mips64el-linux-gnu,powerpc-linux-gnu,powerpc64-linux-gnu,s390-linux-gnu,s390x-linux-gnu,sh-linux-gnu,sparc-linux-gnu,sparc64-linux-gnu,x86_64-linux-gnu
+	$(MAKE) -C builddir-multi configure-host
+	touch configure-multi-stamp
+
+build-multi-stamp: configure-multi-stamp
+	$(checkdir)
+	$(MAKE) -C builddir-multi/bfd headers
+	$(MAKE) -C builddir-multi \
+		CFLAGS="$(CFLAGS)" $(MULTI_ARGS)
+	touch build-multi-stamp
+
+################################################################################
+
+#################
+# hppa64 target #
+#################
+
+configure-hppa64-stamp: patch-stamp
+	$(checkdir)
+	rm -rf configure-hppa64-stamp \
+		builddir-hppa64
+	mkdir builddir-hppa64
+	cd builddir-hppa64 \
+	    && env CC="$(CC)" ../configure \
+		--enable-shared \
+		--prefix=/usr \
+		--build=$(DEB_BUILD_GNU_TYPE) \
+		--host=$(DEB_BUILD_GNU_TYPE) \
+		--target=hppa64-linux-gnu
+	$(MAKE) -C builddir-hppa64 configure-host
+	touch configure-hppa64-stamp
+
+build-hppa64-stamp: configure-hppa64-stamp
+	$(checkdir)
+	$(MAKE) -C builddir-hppa64/bfd headers
+	$(MAKE) -C builddir-hppa64 \
+		CFLAGS="$(CFLAGS)" $(HPPA64_ARGS)
+	touch build-hppa64-stamp
+
+build_stamps = build-single-stamp build-multi-stamp
+ifeq ($(DEB_HOST_ARCH),hppa)
+       build_stamps += build-hppa64-stamp
+endif
+build: build-stamp
+build-stamp: $(build_stamps)
+	touch build-stamp
+
+
+################################################################################
+
+##################
+# install target #
+##################
+
+install_stamps = install-stamp
+ifeq ($(DEB_HOST_ARCH),hppa)
+       install_stamps += install-hppa64-stamp
+endif
+install: $(install_stamps)
+install-stamp: checkroot build-stamp
+	$(checkdir)
+
+	rm -fr $(d_bin) $(d_dev) $(d_mul) $(d_doc)
+	$(install_dir) $(d_bin) $(d_dev) $(d_mul) $(d_doc)
+
+	: # install binutils and -dev stuff
+	$(MAKE) -C builddir-single \
+		CFLAGS="$(CFLAGS)" prefix=$(pwd)/$(d_bin)/usr \
+		mandir=$(pwd)/$(d_bin)/usr/share/man \
+		infodir=$(pwd)/$(d_doc)/usr/share/info install
+
+	: # now install binutils-multiarch stuff
+	$(MAKE) -C builddir-multi \
+		CFLAGS="$(CFLAGS)" $(MULTI_ARGS) \
+		prefix=$(pwd)/$(d_mul)/usr \
+		mandir=$(pwd)/$(d_mul)/usr/share/man \
+		infodir=$(pwd)/$(d_doc)/usr/share/info install
+
+	: # copy libiberty.h ... not too keen on this, but it was requested
+	cp -f include/libiberty.h $(d_bin)/usr/include
+
+	: # We don't need to distribute everything in binutils and -dev
+	rm -rf $(d_bin)/usr/include/obstack.h
+	rm -f $(d_bin)/usr/man/man1/configure.1
+	rm -f $(d_doc)/usr/share/info/configure.* $(d_doc)/usr/share/info/standards.*
+	: # *sigh*, bugs.debian.org/213524
+	rm -f $(d_doc)/usr/share/info/dir*
+
+	: # Now get rid of just about everything in binutils-multiarch
+	rm -rf $(d_mul)/usr/man $(d_mul)/usr/info $(d_mul)/usr/include
+	rm -rf $(d_mul)/usr/share/man $(d_mul)/usr/share/info $(d_mul)/usr/share/locale
+
+	: # Get rid of ld for the time being since it's suddenly unhappy when
+	: # linking kernels.  Also get rid of the ldscripts for good measure.
+	rm -f $(d_mul)/usr/bin/as $(d_mul)/usr/bin/gasp $(d_mul)/usr/bin/c++filt \
+	       $(d_mul)/usr/bin/ld
+	rm -rf $(d_mul)/usr/lib/ldscripts
+
+	$(install_dir) $(d_dev)/usr/include/ $(d_dev)/usr/lib/
+	mv $(d_bin)/usr/include/* $(d_dev)/usr/include/
+	mv $(d_bin)/usr/lib/*.a $(d_bin)/usr/lib/libbfd.so $(d_bin)/usr/lib/libopcodes.so \
+	   $(d_dev)/usr/lib/
+
+	rm -f $(d_mul)/usr/lib/libbfd.so $(d_mul)/usr/lib/libopcodes.so
+	rm -f $(d_mul)/usr/lib/*.la
+	rm -f $(d_mul)/usr/lib/libiberty*
+
+	: # Get rid of .la files since libtool obviously has no idea about transient paths
+	rm -f $(d_bin)/usr/lib/*.la
+
+	: # Strip shared libraries
+	$(STRIP) --strip-unneeded $(d_bin)/usr/lib/libbfd-*so
+	$(STRIP) --strip-unneeded $(d_bin)/usr/lib/libopcodes-*so
+	$(STRIP) --strip-unneeded $(d_mul)/usr/lib/libbfd-*so
+	$(STRIP) --strip-unneeded $(d_mul)/usr/lib/libopcodes-*so
+
+	chmod ugo-x $(d_bin)/usr/lib/*.so $(d_mul)/usr/lib/*.so
+	$(STRIP) $(d_bin)/usr/bin/* $(d_mul)/usr/bin/*
+
+	: # Don't want /usr/<arch>-linux to exist in any package
+	rm -rf $(d_bin)/usr/$(DEB_HOST_GNU_TYPE)
+	rm -rf $(d_mul)/usr/$(DEB_HOST_GNU_TYPE)
+
+	: # Remove windres manpages
+	rm -f $(d_bin)/usr/share/man/man1/windres.1
+	rm -f $(d_mul)/usr/share/man/man1/windres.1
+
+	: # Remove empty directory
+	rmdir $(d_bin)/usr/include/
+
+	touch install-stamp
+
+install-hppa64-stamp: checkroot build-hppa64-stamp
+	$(checkdir)
+
+	rm -fr $(d_hppa64)
+	$(install_dir) $(d_hppa64)
+	$(install_dir) $(d_hppa64)/usr/lib
+
+	: # install binutils-hppa64 stuff
+	$(MAKE) -C builddir-hppa64 \
+		CFLAGS="$(CFLAGS)" $(HPPA64_ARGS) \
+		prefix=$(pwd)/$(d_hppa64)/usr/ \
+		mandir=$(pwd)/$(d_hppa64)/usr/share/man \
+		infodir=$(pwd)/$(d_hppa64)/usr/share/info install
+
+	: # move shared libs to the standard path
+	mv $(d_hppa64)/usr/hppa-linux-gnu/hppa64-linux-gnu/lib/lib*-*.so \
+		$(d_hppa64)/usr/lib/.
+
+	: # Now get rid of just about everything in binutils-hppa64
+	rm -rf $(d_hppa64)/usr/man
+	rm -rf $(d_hppa64)/usr/info
+	rm -rf $(d_hppa64)/usr/include
+	rm -rf $(d_hppa64)/usr/share
+	rm -rf $(d_hppa64)/usr/hppa-linux-gnu
+	rm -rf $(d_hppa64)/usr/lib/libiberty.a
+
+	: # Strip shared libraries
+	$(STRIP) --strip-unneeded $(d_hppa64)/usr/lib/libbfd-*so
+	$(STRIP) --strip-unneeded $(d_hppa64)/usr/lib/libopcodes-*so
+
+	chmod ugo-x $(d_hppa64)/usr/lib/*.so
+	$(STRIP) $(d_hppa64)/usr/bin/*
+
+	: # Don't want /usr/<arch>-linux to exist in any package
+	rm -rf $(d_hppa64)/usr/hppa64-linux-gnu
+
+	touch install-hppa64-stamp
+
+################################################################################
+
+#######################
+# binary-indep target #
+#######################
+
+binary-indep: checkroot build install
+	$(checkdir)
+
+	rm -f debian/files debian/substvars
+
+	$(install_dir) $(d_doc)/DEBIAN
+	$(install_script) debian/binutils-doc.postinst $(d_doc)/DEBIAN/postinst
+	$(install_script) debian/binutils-doc.prerm $(d_doc)/DEBIAN/prerm
+
+	$(install_dir) $(d_doc)/usr/share/doc/$(p_doc)/
+	$(install_file)	debian/changelog $(d_doc)/usr/share/doc/$(p_doc)/changelog.Debian
+	$(install_file)	debian/copyright $(d_doc)/usr/share/doc/$(p_doc)/
+	for i in bfd gas gprof ld; do \
+	  ln -sf ../$(p_bin)/$$i $(d_doc)/usr/share/doc/$(p_doc)/$$i; \
+	done
+	find $(d_doc)/usr/share/doc/$(p_doc) -type f -maxdepth 1 ! -name copyright | xargs gzip -9
+	gzip -9 $(d_doc)/usr/share/info/*
+
+	dpkg-gencontrol -isp -P$(d_doc) -p$(p_doc)
+	chown -R root:root $(d_doc)
+	chmod -R go=rX  $(d_doc)
+	[ -x /usr/bin/pkgstriptranslations ] && /usr/bin/pkgstriptranslations || true
+	dpkg --build $(d_doc) ..
+
+################################################################################
+
+#######################
+# binary-arch target  #
+#######################
+
+binary-arch: checkroot build install
+	$(checkdir)
+
+	: # install maintainer scrtips
+	$(install_dir) $(d_bin)/DEBIAN
+	$(install_script) debian/binutils.postinst $(d_bin)/DEBIAN/postinst
+	$(install_script) debian/binutils.postrm $(d_bin)/DEBIAN/postrm
+	$(install_file) debian/binutils.shlibs $(d_bin)/DEBIAN/shlibs
+
+	$(install_dir) $(d_dev)/DEBIAN
+
+	$(install_dir) $(d_mul)/DEBIAN
+	$(install_script) debian/binutils-multiarch.postinst $(d_mul)/DEBIAN/postinst
+	$(install_script) debian/binutils-multiarch.postrm $(d_mul)/DEBIAN/postrm
+	$(install_script) debian/binutils-multiarch.preinst $(d_mul)/DEBIAN/preinst
+	$(install_file) debian/binutils-multiarch.shlibs $(d_mul)/DEBIAN/shlibs
+
+ifeq ($(DEB_HOST_ARCH),hppa)
+	$(install_dir) $(d_hppa64)/DEBIAN
+	$(install_script) debian/binutils-hppa64.postinst $(d_hppa64)/DEBIAN/postinst
+	$(install_script) debian/binutils-hppa64.postrm $(d_hppa64)/DEBIAN/postrm
+	$(install_file) debian/binutils-hppa64.shlibs $(d_hppa64)/DEBIAN/shlibs
+endif
+
+	: # install docs
+	$(install_dir) $(d_bin)/usr/share/doc/$(p_bin)/
+	$(install_file)	debian/changelog $(d_bin)/usr/share/doc/$(p_bin)/changelog.Debian
+	$(install_file)	debian/copyright $(d_bin)/usr/share/doc/$(p_bin)/
+
+	$(install_dir) $(d_dev)/usr/share/doc/ $(d_mul)/usr/share/doc/
+	ln -sf $(p_bin) $(d_dev)/usr/share/doc/$(p_dev)
+	ln -sf $(p_bin) $(d_mul)/usr/share/doc/$(p_mul)
+ifeq ($(DEB_HOST_ARCH),hppa)
+	$(install_dir) $(d_hppa64)/usr/share/doc/
+	ln -sf $(p_bin) $(d_hppa64)/usr/share/doc/$(p_hppa64)
+endif
+
+	$(install_file) $(pwd)/test-summary binutils/NEWS  \
+	                debian/README.Debian $(d_bin)/usr/share/doc/$(p_bin)/
+
+	$(install_file) binutils/ChangeLog $(d_bin)/usr/share/doc/$(p_bin)/changelog
+
+	for pkg in bfd gas gprof ld; do \
+	  $(install_dir) $(d_bin)/usr/share/doc/$(p_bin)/$$pkg; \
+	done
+	$(install_file) bfd/ChangeLog bfd/PORTING bfd/TODO \
+			$(d_bin)/usr/share/doc/$(p_bin)/bfd/
+	$(install_file) gas/ChangeLog gas/NEWS $(d_bin)/usr/share/doc/$(p_bin)/gas/
+	$(install_file) gprof/ChangeLog gprof/TODO gprof/TEST \
+			$(d_bin)/usr/share/doc/$(p_bin)/gprof/
+	$(install_file) ld/ChangeLog ld/TODO ld/NEWS \
+			$(d_bin)/usr/share/doc/$(p_bin)/ld/
+
+	: # These only exist in H. J. Lu releases not GNU ones.
+	for dir in binutils bfd gas gprof ld; do \
+	  if [ -f $$dir/ChangeLog.linux ]; then \
+	    $(install_file) $(d_bin)/usr/share/doc/$(p_bin)/$$dir/; \
+	  fi; \
+	done
+
+	: # Copy bbconv.pl to the doc dir for use by interested people
+	$(install_file) gprof/bbconv.pl $(d_bin)/usr/share/doc/$(p_bin)/gprof/.
+
+	: # Compress stuff that needs it
+	gzip -9 $(d_bin)/usr/share/man/man1/*
+	find $(d_bin)/usr/share/doc/$(p_bin)/ -type f ! -name copyright -a ! -name bbconv.pl | xargs gzip -9
+
+	: # Finish it all up
+	find $(d_bin) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
+	dpkg-gencontrol -isp -P$(d_bin) -p$(p_bin) $(CONFLICTS)
+
+	rm -f debian/substvars
+	dpkg-gencontrol -isp -P$(d_dev) -p$(p_dev)
+
+	rm -f debian/substvars
+	find $(d_mul) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
+	dpkg-gencontrol -isp -P$(d_mul) -p$(p_mul)
+
+ifeq ($(DEB_HOST_ARCH),hppa)
+	rm -f debian/substvars
+	find $(d_hppa64) -type f | xargs file | grep ELF | cut -d: -f 1 | xargs dpkg-shlibdeps
+	dpkg-gencontrol -isp -P$(d_hppa64) -p$(p_hppa64)
+endif
+
+	chown -R root:root $(d_bin) $(d_dev) $(d_mul)
+	chmod -R go=rX  $(d_bin) $(d_dev) $(d_mul)
+	[ -x /usr/bin/pkgstriptranslations ] && /usr/bin/pkgstriptranslations || true
+	dpkg --build $(d_bin) ..
+	dpkg --build $(d_dev) ..
+	dpkg --build $(d_mul) ..
+ifeq ($(DEB_HOST_ARCH),hppa)
+	chown -R root:root $(d_hppa64)
+	chmod -R go=rX  $(d_hppa64)
+	dpkg --build $(d_hppa64) ..
+endif
+
+################################################################################
+
+define checkdir
+        test -f bfd/elf32.c -a -f debian/rules
+endef
+
+# Below here is fairly generic really
+
+binary:         binary-indep binary-arch
+
+checkroot:
+	$(checkdir)
+        test root = "`whoami`"
+
+.PHONY: binary binary-arch binary-indep clean checkroot

[signature.asc (application/pgp-signature, attachment)]

Tags added: patch Request was from Josh Triplett <josh@psas.pdx.edu> to control@bugs.debian.org. Full text and rfc822 format available.

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Josh Triplett <josh@psas.pdx.edu>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #100 received at 231707@bugs.debian.org (full text, mbox):

From: Josh Triplett <josh@psas.pdx.edu>
To: 231707@bugs.debian.org
Subject: Updated patch
Date: Fri, 14 Oct 2005 02:13:02 -0700
[Message part 1 (text/plain, inline)]
This version fixes the unintentional inclusion of a debian/rules.orig
file in the patch.

- Josh Triplett
[binutils-cross-2.16.1cvs20050902-1.patch (text/x-patch, inline)]
diff -Naur binutils-2.16.1cvs20050902.old/debian/README.cross binutils-2.16.1cvs20050902/debian/README.cross
--- binutils-2.16.1cvs20050902.old/debian/README.cross	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/README.cross	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,13 @@
+Cross-binutils debian packages can be built directly from binutils
+source package.
+
+To build cross-binutils package, download and unpack binutils
+source package, and run
+
+TARGET=your-target fakeroot debian/rules binary-cross
+
+Target name may be set both as debian arch name (such as 'arm', 'powerpc', ...)
+ans ad GNU system type (arm-linux-gnu, powerpc-linux-gnu, etc).
+
+---
+Nikita Youshchenko <yoush@cs.msu.su>
diff -Naur binutils-2.16.1cvs20050902.old/debian/generate-cross-control binutils-2.16.1cvs20050902/debian/generate-cross-control
--- binutils-2.16.1cvs20050902.old/debian/generate-cross-control	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/generate-cross-control	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+target=`echo -n $1 | sed 's/_/-/g'`
+
+sed '/^$/ q' < debian/control
+
+echo "Package: binutils-$target"
+echo 'Architecture: any'
+echo 'Depends: binutils, ${shlibs:Depends}'
+echo 'Suggests: binutils-doc (= ${Source-Version})'
+
+# Add conflicts/replaces/provides for older names of same binutils
+oldtarget=`echo -n $target | sed 's/-linux-gnu$/-linux/'`
+if [ "$target" != "$oldtarget" ]; then
+  # Add conflicts with old EmDebian toolchain which was available for
+  # arm and powerpc
+  if [ "$oldtarget" = "arm-linux" ] || [ "$oldtarget" = "powerpc-linux" ]; then
+    veryoldtarget=`echo -n $target | sed 's/-linux$//'`
+    echo "Conflicts: binutils-$oldtarget, binutils-$veryoldtarget"
+  else
+    echo "Conflicts: binutils-$oldtarget"
+  fi
+  echo "Replaces: binutils-$oldtarget"
+  echo "Provides: binutils-$oldtarget"
+fi
+echo "Description: The GNU binary utilities, for $target target"
+echo " This package provides GNU assembler, linker and binary utilities"
+echo " for $target target, for use in cross-compilation environment."
+echo " ."
+echo " You don't need this package unless you plan to cross-compile programs"
+echo " for $target."
diff -Naur binutils-2.16.1cvs20050902.old/debian/patch-stamp binutils-2.16.1cvs20050902/debian/patch-stamp
--- binutils-2.16.1cvs20050902.old/debian/patch-stamp	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/patch-stamp	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,2 @@
+Patches applied in the Debian version of :
+
diff -Naur binutils-2.16.1cvs20050902.old/debian/patches/001_ld_makefile_patch.dpatch binutils-2.16.1cvs20050902/debian/patches/001_ld_makefile_patch.dpatch
--- binutils-2.16.1cvs20050902.old/debian/patches/001_ld_makefile_patch.dpatch	2005-10-13 23:58:15.000000000 -0700
+++ binutils-2.16.1cvs20050902/debian/patches/001_ld_makefile_patch.dpatch	2005-10-13 23:57:48.000000000 -0700
@@ -6,6 +6,10 @@
 ## DP: Author: Chris Chimelis <chris@debian.org>
 ## DP: Upstream status: N/A
 ## DP: Date: ??
+## DP: Fixed by Nikita Youshchenko <yoush@cs.msu.su> to be correct for
+## DP: cross-binutils - in that case change of $(scriptdir) to /usr/lib causes
+## DP: cross-ld to look for libraries in /usr/lib instead of
+## DP: /usr/$(target-alias)/lib
 
 if [ $# -ne 1 ]; then
     echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
@@ -29,24 +33,50 @@
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.am /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am
 --- ./ld/Makefile.am	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am	2005-09-02 21:42:18.000000000 +0000
-@@ -20,7 +20,7 @@
+@@ -20,7 +20,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  
  EMUL = @EMUL@
  EMULATION_OFILES = @EMULATION_OFILES@
+@@ -431,7 +435,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.in /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in
 --- ./ld/Makefile.in	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in	2005-09-02 21:43:37.259127535 +0000
-@@ -268,7 +268,7 @@
+@@ -268,7 +268,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  BASEDIR = $(srcdir)/..
  BFDDIR = $(BASEDIR)/bfd
  INCDIR = $(BASEDIR)/include
+@@ -1173,7 +1177,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
diff -Naur binutils-2.16.1cvs20050902.old/debian/patches/00list binutils-2.16.1cvs20050902/debian/patches/00list
--- binutils-2.16.1cvs20050902.old/debian/patches/00list	2005-10-13 23:58:15.000000000 -0700
+++ binutils-2.16.1cvs20050902/debian/patches/00list	2005-10-13 23:49:51.000000000 -0700
@@ -7,3 +7,4 @@
 117_mips_symbolic_link
 118_arm_pass_all
 120_mips_xgot_multigot_workaround
+999_lib64_for_cross
diff -Naur binutils-2.16.1cvs20050902.old/debian/patches/999_lib64_for_cross.dpatch binutils-2.16.1cvs20050902/debian/patches/999_lib64_for_cross.dpatch
--- binutils-2.16.1cvs20050902.old/debian/patches/999_lib64_for_cross.dpatch	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20050902/debian/patches/999_lib64_for_cross.dpatch	2005-10-13 23:49:51.000000000 -0700
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+## 999_lib64_for_cross.dpatch by Nikita Youshchenko <yoush@cs.msu.su>
+##
+## DP: Add /usr/${target-alias}/lib${LIBPATH_SUFFIX} to ld's default
+## DP: library search path for cross targets. Needed for cross targets that
+## DP: try to support both 32bit and 64bit emulations.
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+        exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh binutils-2.14.90.0.7.cross/ld/genscripts.sh
+--- /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh	2003-10-29 20:37:48.000000000 +0300
++++ binutils-2.14.90.0.7.cross/ld/genscripts.sh	2004-07-15 00:29:19.000000000 +0400
+@@ -176,6 +176,26 @@
+   ::) LIB_PATH=${tool_lib} ;;
+   *) LIB_PATH=${tool_lib}:${LIB_PATH} ;;
+   esac
++  # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
++  # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} to default search path, because
++  # 64bit libraries may be in both places, depending on cross-development
++  # setup method (e.g.: /usr/s390x-linux/lib64 vs /usr/s390-linux/lib64)
++  case "${LIBPATH_SUFFIX}:${tool_lib}" in
++    :*) ;;
++    *:*${LIBPATH_SUFFIX}) ;;
++    *)
++      paths="${exec_prefix}/${target_alias}/lib${LIBPATH_SUFFIX}"
++      if [ "${TOOL_LIB}" != x ]; then
++        paths="${paths} ${exec_prefix}/${TOOL_LIB}/lib${LIBPATH_SUFFIX}"
++      fi
++      for path in $paths; do
++        case :${LIB_PATH}: in
++          ::: | *:${path}:*) ;;
++          *) LIB_PATH=${path}:${LIB_PATH} ;;
++        esac
++      done
++    ;;
++  esac
+ fi
+ 
+ LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
diff -Naur binutils-2.16.1cvs20050902.old/debian/rules binutils-2.16.1cvs20050902/debian/rules
--- binutils-2.16.1cvs20050902.old/debian/rules	2005-10-13 23:58:15.000000000 -0700
+++ binutils-2.16.1cvs20050902/debian/rules	2005-10-13 23:49:51.000000000 -0700
@@ -378,7 +378,8 @@
 endif
 
 	$(install_file) $(pwd)/test-summary binutils/NEWS  \
-	                debian/README.Debian $(d_bin)/usr/share/doc/$(p_bin)/
+	                debian/README.Debian debian/README.cross \
+			$(d_bin)/usr/share/doc/$(p_bin)/
 
 	$(install_file) binutils/ChangeLog $(d_bin)/usr/share/doc/$(p_bin)/changelog
 
@@ -438,6 +439,133 @@
 
 ################################################################################
 
+
+#################
+# cross targets #
+#################
+
+# If $(TARGET) is not set, try reading debian/target
+ifeq ($(TARGET),)
+TARGET := $(cat debian/target 2>/dev/null)
+endif
+
+# Process the following only if $(TARGET) is set
+ifneq ($(TARGET),)
+
+# Support TARGET both as Debian architecture specification (e.g. arm),
+# and as the target name (e.g. arm-linux-gnu).
+try_convert := $(shell dpkg-architecture -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null)
+ifneq ($(try_convert),)
+override TARGET := $(try_convert)
+endif
+
+# Many people expect cross-binutils to be named like 'arm-linux-ld', not
+# like 'arm-linux-gnu-ld'. Package will provide symlinks. In future, this may
+# be replaced with alternatives.
+tmp_cpu := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_CPU 2>/dev/null)
+tmp_os := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_OS 2>/dev/null)
+ifeq ($(TARGET),$(tmp_cpu)-$(tmp_os)-gnu)
+do_symlinks := yes
+else
+do_symlinks := no
+endif
+
+p_cross = $(subst _,-,binutils-$(TARGET))
+d_cross = debian/$(p_cross)
+
+ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu)
+endif
+ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu x86-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
+endif
+ifeq ($(TARGET), x86_64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu
+endif
+ifeq ($(TARGET), mipsel-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu
+endif
+ifeq ($(TARGET), sparc64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=sparc-linux-gnu
+endif
+ifeq ($(TARGET), s390-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390x-linux-gnu
+endif
+ifeq ($(TARGET), s390x-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390-linux-gnu
+endif
+
+configure-$(TARGET)-stamp: patch-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf configure-$(TARGET)-stamp builddir-$(TARGET)
+	mkdir builddir-$(TARGET)
+	cd builddir-$(TARGET) \
+	    && env CC="$(CC)" ../configure --host=$(DEB_HOST_GNU_TYPE) \
+	        --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/usr \
+		$(ADDITIONAL_TARGETS)
+	touch $@
+
+build-$(TARGET)-stamp: configure-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	$(MAKE) -C builddir-$(TARGET) CFLAGS="$(CFLAGS)"
+	touch $@
+
+install-$(TARGET)-stamp: build-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross)
+	$(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/usr \
+		mandir=$(pwd)/$(d_cross)/usr/share/man install
+	rm -rf $(d_cross)/usr/lib $(d_cross)/usr/info $(d_cross)/usr/share/locale
+	$(STRIP) $(d_cross)/usr/bin/*
+	gzip -9 $(d_cross)/usr/share/man/man1/*
+ifeq ($(do_symlinks),yes)
+	cd $(d_cross)/usr/bin && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+	cd $(d_cross)/usr/share/man/man1 && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+endif
+	touch $@
+
+binary-cross: checkroot install-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	
+	chmod 755 debian/generate-cross-control
+	debian/generate-cross-control $(TARGET) > debian/control.$(TARGET)
+	
+	$(install_dir) $(d_cross)/DEBIAN
+	
+	$(install_dir) $(d_cross)/usr/share/doc/$(p_cross)/
+	$(install_file)	debian/changelog $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	$(install_file)	debian/copyright debian/README.cross $(d_cross)/usr/share/doc/$(p_cross)/
+	gzip -f -9 $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	
+	for pkg in bfd gas gprof ld; do \
+	  ln -sf ../binutils/$$pkg $(d_cross)/usr/share/doc/$(p_cross)/$$pkg; \
+	done
+
+	rm -f debian/substvars
+	dpkg-shlibdeps $(d_cross)/usr/bin/*
+	dpkg-gencontrol -cdebian/control.$(TARGET) -P$(d_cross) -p$(p_cross)
+	dpkg --build $(d_cross) ..
+
+clean-cross: unpatch
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross) debian/control.$(TARGET) debian/files debian/substvars \
+		builddir-$(TARGET) {configure,build,install}-$(TARGET)-stamp
+
+.PHONY: binary-cross clean-cross
+
+endif
+
+################################################################################
+
 define checkdir
         test -f bfd/elf32.c -a -f debian/rules
 endef
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Josh Triplett <josh@freedesktop.org>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #105 received at 231707@bugs.debian.org (full text, mbox):

From: Josh Triplett <josh@freedesktop.org>
To: 231707@bugs.debian.org
Subject: Updated patch: 2.16.1cvs20051214-1
Date: Thu, 05 Jan 2006 19:38:43 -0800
[Message part 1 (text/plain, inline)]
Here's an updated patch for 2.16.1cvs20051214-1.

Is there any problem with these patches preventing them from being
applied?  If not, are there any plans to apply one of them?

- Josh Triplett
[binutils-cross-2.16.1cvs20051214-1.patch (text/x-patch, inline)]
diff -Naur binutils-2.16.1cvs20051214.orig/debian/README.cross binutils-2.16.1cvs20051214/debian/README.cross
--- binutils-2.16.1cvs20051214.orig/debian/README.cross	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20051214/debian/README.cross	2006-01-05 19:15:10.000000000 -0800
@@ -0,0 +1,13 @@
+Cross-binutils debian packages can be built directly from binutils
+source package.
+
+To build cross-binutils package, download and unpack binutils
+source package, and run
+
+TARGET=your-target fakeroot debian/rules binary-cross
+
+Target name may be set both as debian arch name (such as 'arm', 'powerpc', ...)
+ans ad GNU system type (arm-linux-gnu, powerpc-linux-gnu, etc).
+
+---
+Nikita Youshchenko <yoush@cs.msu.su>
diff -Naur binutils-2.16.1cvs20051214.orig/debian/generate-cross-control binutils-2.16.1cvs20051214/debian/generate-cross-control
--- binutils-2.16.1cvs20051214.orig/debian/generate-cross-control	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20051214/debian/generate-cross-control	2006-01-05 19:15:10.000000000 -0800
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+target=`echo -n $1 | sed 's/_/-/g'`
+
+sed '/^$/ q' < debian/control
+
+echo "Package: binutils-$target"
+echo 'Architecture: any'
+echo 'Depends: binutils, ${shlibs:Depends}'
+echo 'Suggests: binutils-doc (= ${Source-Version})'
+
+# Add conflicts/replaces/provides for older names of same binutils
+oldtarget=`echo -n $target | sed 's/-linux-gnu$/-linux/'`
+if [ "$target" != "$oldtarget" ]; then
+  # Add conflicts with old EmDebian toolchain which was available for
+  # arm and powerpc
+  if [ "$oldtarget" = "arm-linux" ] || [ "$oldtarget" = "powerpc-linux" ]; then
+    veryoldtarget=`echo -n $target | sed 's/-linux$//'`
+    echo "Conflicts: binutils-$oldtarget, binutils-$veryoldtarget"
+  else
+    echo "Conflicts: binutils-$oldtarget"
+  fi
+  echo "Replaces: binutils-$oldtarget"
+  echo "Provides: binutils-$oldtarget"
+fi
+echo "Description: The GNU binary utilities, for $target target"
+echo " This package provides GNU assembler, linker and binary utilities"
+echo " for $target target, for use in cross-compilation environment."
+echo " ."
+echo " You don't need this package unless you plan to cross-compile programs"
+echo " for $target."
diff -Naur binutils-2.16.1cvs20051214.orig/debian/patch-stamp binutils-2.16.1cvs20051214/debian/patch-stamp
--- binutils-2.16.1cvs20051214.orig/debian/patch-stamp	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20051214/debian/patch-stamp	2006-01-05 19:15:10.000000000 -0800
@@ -0,0 +1,2 @@
+Patches applied in the Debian version of :
+
diff -Naur binutils-2.16.1cvs20051214.orig/debian/patches/001_ld_makefile_patch.dpatch binutils-2.16.1cvs20051214/debian/patches/001_ld_makefile_patch.dpatch
--- binutils-2.16.1cvs20051214.orig/debian/patches/001_ld_makefile_patch.dpatch	2006-01-05 19:18:44.000000000 -0800
+++ binutils-2.16.1cvs20051214/debian/patches/001_ld_makefile_patch.dpatch	2006-01-05 19:15:10.000000000 -0800
@@ -6,6 +6,10 @@
 ## DP: Author: Chris Chimelis <chris@debian.org>
 ## DP: Upstream status: N/A
 ## DP: Date: ??
+## DP: Fixed by Nikita Youshchenko <yoush@cs.msu.su> to be correct for
+## DP: cross-binutils - in that case change of $(scriptdir) to /usr/lib causes
+## DP: cross-ld to look for libraries in /usr/lib instead of
+## DP: /usr/$(target-alias)/lib
 
 if [ $# -ne 1 ]; then
     echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
@@ -29,24 +33,50 @@
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.am /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am
 --- ./ld/Makefile.am	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am	2005-09-02 21:42:18.000000000 +0000
-@@ -20,7 +20,7 @@
+@@ -20,7 +20,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  
  EMUL = @EMUL@
  EMULATION_OFILES = @EMULATION_OFILES@
+@@ -431,7 +435,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.in /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in
 --- ./ld/Makefile.in	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in	2005-09-02 21:43:37.259127535 +0000
-@@ -268,7 +268,7 @@
+@@ -268,7 +268,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  BASEDIR = $(srcdir)/..
  BFDDIR = $(BASEDIR)/bfd
  INCDIR = $(BASEDIR)/include
+@@ -1173,7 +1177,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
diff -Naur binutils-2.16.1cvs20051214.orig/debian/patches/00list binutils-2.16.1cvs20051214/debian/patches/00list
--- binutils-2.16.1cvs20051214.orig/debian/patches/00list	2006-01-05 19:18:44.000000000 -0800
+++ binutils-2.16.1cvs20051214/debian/patches/00list	2006-01-05 19:16:33.000000000 -0800
@@ -8,3 +8,4 @@
 120_mips_xgot_multigot_workaround
 121_i386_x86_64_biarch
 125_fix_tc_arm_cast
+999_lib64_for_cross
diff -Naur binutils-2.16.1cvs20051214.orig/debian/patches/999_lib64_for_cross.dpatch binutils-2.16.1cvs20051214/debian/patches/999_lib64_for_cross.dpatch
--- binutils-2.16.1cvs20051214.orig/debian/patches/999_lib64_for_cross.dpatch	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20051214/debian/patches/999_lib64_for_cross.dpatch	2006-01-05 19:15:10.000000000 -0800
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+## 999_lib64_for_cross.dpatch by Nikita Youshchenko <yoush@cs.msu.su>
+##
+## DP: Add /usr/${target-alias}/lib${LIBPATH_SUFFIX} to ld's default
+## DP: library search path for cross targets. Needed for cross targets that
+## DP: try to support both 32bit and 64bit emulations.
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+        exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh binutils-2.14.90.0.7.cross/ld/genscripts.sh
+--- /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh	2003-10-29 20:37:48.000000000 +0300
++++ binutils-2.14.90.0.7.cross/ld/genscripts.sh	2004-07-15 00:29:19.000000000 +0400
+@@ -176,6 +176,26 @@
+   ::) LIB_PATH=${tool_lib} ;;
+   *) LIB_PATH=${tool_lib}:${LIB_PATH} ;;
+   esac
++  # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
++  # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} to default search path, because
++  # 64bit libraries may be in both places, depending on cross-development
++  # setup method (e.g.: /usr/s390x-linux/lib64 vs /usr/s390-linux/lib64)
++  case "${LIBPATH_SUFFIX}:${tool_lib}" in
++    :*) ;;
++    *:*${LIBPATH_SUFFIX}) ;;
++    *)
++      paths="${exec_prefix}/${target_alias}/lib${LIBPATH_SUFFIX}"
++      if [ "${TOOL_LIB}" != x ]; then
++        paths="${paths} ${exec_prefix}/${TOOL_LIB}/lib${LIBPATH_SUFFIX}"
++      fi
++      for path in $paths; do
++        case :${LIB_PATH}: in
++          ::: | *:${path}:*) ;;
++          *) LIB_PATH=${path}:${LIB_PATH} ;;
++        esac
++      done
++    ;;
++  esac
+ fi
+ 
+ LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
diff -Naur binutils-2.16.1cvs20051214.orig/debian/rules binutils-2.16.1cvs20051214/debian/rules
--- binutils-2.16.1cvs20051214.orig/debian/rules	2006-01-05 19:18:44.000000000 -0800
+++ binutils-2.16.1cvs20051214/debian/rules	2006-01-05 19:15:10.000000000 -0800
@@ -381,7 +381,8 @@
 endif
 
 	$(install_file) $(pwd)/test-summary binutils/NEWS  \
-	                debian/README.Debian $(d_bin)/usr/share/doc/$(p_bin)/
+	                debian/README.Debian debian/README.cross \
+			$(d_bin)/usr/share/doc/$(p_bin)/
 
 	$(install_file) binutils/ChangeLog $(d_bin)/usr/share/doc/$(p_bin)/changelog
 
@@ -440,6 +441,133 @@
 
 ################################################################################
 
+
+#################
+# cross targets #
+#################
+
+# If $(TARGET) is not set, try reading debian/target
+ifeq ($(TARGET),)
+TARGET := $(cat debian/target 2>/dev/null)
+endif
+
+# Process the following only if $(TARGET) is set
+ifneq ($(TARGET),)
+
+# Support TARGET both as Debian architecture specification (e.g. arm),
+# and as the target name (e.g. arm-linux-gnu).
+try_convert := $(shell dpkg-architecture -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null)
+ifneq ($(try_convert),)
+override TARGET := $(try_convert)
+endif
+
+# Many people expect cross-binutils to be named like 'arm-linux-ld', not
+# like 'arm-linux-gnu-ld'. Package will provide symlinks. In future, this may
+# be replaced with alternatives.
+tmp_cpu := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_CPU 2>/dev/null)
+tmp_os := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_OS 2>/dev/null)
+ifeq ($(TARGET),$(tmp_cpu)-$(tmp_os)-gnu)
+do_symlinks := yes
+else
+do_symlinks := no
+endif
+
+p_cross = $(subst _,-,binutils-$(TARGET))
+d_cross = debian/$(p_cross)
+
+ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu)
+endif
+ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu x86-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
+endif
+ifeq ($(TARGET), x86_64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu
+endif
+ifeq ($(TARGET), mipsel-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu
+endif
+ifeq ($(TARGET), sparc64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=sparc-linux-gnu
+endif
+ifeq ($(TARGET), s390-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390x-linux-gnu
+endif
+ifeq ($(TARGET), s390x-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390-linux-gnu
+endif
+
+configure-$(TARGET)-stamp: patch-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf configure-$(TARGET)-stamp builddir-$(TARGET)
+	mkdir builddir-$(TARGET)
+	cd builddir-$(TARGET) \
+	    && env CC="$(CC)" ../configure --host=$(DEB_HOST_GNU_TYPE) \
+	        --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/usr \
+		$(ADDITIONAL_TARGETS)
+	touch $@
+
+build-$(TARGET)-stamp: configure-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	$(MAKE) -C builddir-$(TARGET) CFLAGS="$(CFLAGS)"
+	touch $@
+
+install-$(TARGET)-stamp: build-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross)
+	$(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/usr \
+		mandir=$(pwd)/$(d_cross)/usr/share/man install
+	rm -rf $(d_cross)/usr/lib $(d_cross)/usr/info $(d_cross)/usr/share/locale
+	$(STRIP) $(d_cross)/usr/bin/*
+	gzip -9 $(d_cross)/usr/share/man/man1/*
+ifeq ($(do_symlinks),yes)
+	cd $(d_cross)/usr/bin && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+	cd $(d_cross)/usr/share/man/man1 && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+endif
+	touch $@
+
+binary-cross: checkroot install-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	
+	chmod 755 debian/generate-cross-control
+	debian/generate-cross-control $(TARGET) > debian/control.$(TARGET)
+	
+	$(install_dir) $(d_cross)/DEBIAN
+	
+	$(install_dir) $(d_cross)/usr/share/doc/$(p_cross)/
+	$(install_file)	debian/changelog $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	$(install_file)	debian/copyright debian/README.cross $(d_cross)/usr/share/doc/$(p_cross)/
+	gzip -f -9 $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	
+	for pkg in bfd gas gprof ld; do \
+	  ln -sf ../binutils/$$pkg $(d_cross)/usr/share/doc/$(p_cross)/$$pkg; \
+	done
+
+	rm -f debian/substvars
+	dpkg-shlibdeps $(d_cross)/usr/bin/*
+	dpkg-gencontrol -cdebian/control.$(TARGET) -P$(d_cross) -p$(p_cross)
+	dpkg --build $(d_cross) ..
+
+clean-cross: unpatch
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross) debian/control.$(TARGET) debian/files debian/substvars \
+		builddir-$(TARGET) {configure,build,install}-$(TARGET)-stamp
+
+.PHONY: binary-cross clean-cross
+
+endif
+
+################################################################################
+
 define checkdir
         test -f bfd/elf32.c -a -f debian/rules
 endef
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Josh Triplett <josh@freedesktop.org>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #110 received at 231707@bugs.debian.org (full text, mbox):

From: Josh Triplett <josh@freedesktop.org>
To: 231707@bugs.debian.org
Subject: Updated binutils-cross patch for version 2.16.1cvs20060117
Date: Wed, 22 Feb 2006 19:41:03 -0800
[Message part 1 (text/plain, inline)]
Here is an updated binutils-cross patch for version 2.16.1cvs20060117.

- Josh Triplett
[binutils-cross-2.16.1cvs20060117.patch (text/x-patch, inline)]
diff -Naur binutils-2.16.1cvs20060117.orig/debian/README.cross binutils-2.16.1cvs20060117/debian/README.cross
--- binutils-2.16.1cvs20060117.orig/debian/README.cross	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20060117/debian/README.cross	2006-02-22 19:35:43.000000000 -0800
@@ -0,0 +1,13 @@
+Cross-binutils debian packages can be built directly from binutils
+source package.
+
+To build cross-binutils package, download and unpack binutils
+source package, and run
+
+TARGET=your-target fakeroot debian/rules binary-cross
+
+Target name may be set both as debian arch name (such as 'arm', 'powerpc', ...)
+ans ad GNU system type (arm-linux-gnu, powerpc-linux-gnu, etc).
+
+---
+Nikita Youshchenko <yoush@cs.msu.su>
diff -Naur binutils-2.16.1cvs20060117.orig/debian/generate-cross-control binutils-2.16.1cvs20060117/debian/generate-cross-control
--- binutils-2.16.1cvs20060117.orig/debian/generate-cross-control	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20060117/debian/generate-cross-control	2006-02-22 19:35:43.000000000 -0800
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+target=`echo -n $1 | sed 's/_/-/g'`
+
+sed '/^$/ q' < debian/control
+
+echo "Package: binutils-$target"
+echo 'Architecture: any'
+echo 'Depends: binutils, ${shlibs:Depends}'
+echo 'Suggests: binutils-doc (= ${Source-Version})'
+
+# Add conflicts/replaces/provides for older names of same binutils
+oldtarget=`echo -n $target | sed 's/-linux-gnu$/-linux/'`
+if [ "$target" != "$oldtarget" ]; then
+  # Add conflicts with old EmDebian toolchain which was available for
+  # arm and powerpc
+  if [ "$oldtarget" = "arm-linux" ] || [ "$oldtarget" = "powerpc-linux" ]; then
+    veryoldtarget=`echo -n $target | sed 's/-linux$//'`
+    echo "Conflicts: binutils-$oldtarget, binutils-$veryoldtarget"
+  else
+    echo "Conflicts: binutils-$oldtarget"
+  fi
+  echo "Replaces: binutils-$oldtarget"
+  echo "Provides: binutils-$oldtarget"
+fi
+echo "Description: The GNU binary utilities, for $target target"
+echo " This package provides GNU assembler, linker and binary utilities"
+echo " for $target target, for use in cross-compilation environment."
+echo " ."
+echo " You don't need this package unless you plan to cross-compile programs"
+echo " for $target."
diff -Naur binutils-2.16.1cvs20060117.orig/debian/patch-stamp binutils-2.16.1cvs20060117/debian/patch-stamp
--- binutils-2.16.1cvs20060117.orig/debian/patch-stamp	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20060117/debian/patch-stamp	2006-02-22 19:35:43.000000000 -0800
@@ -0,0 +1,2 @@
+Patches applied in the Debian version of :
+
diff -Naur binutils-2.16.1cvs20060117.orig/debian/patches/001_ld_makefile_patch.dpatch binutils-2.16.1cvs20060117/debian/patches/001_ld_makefile_patch.dpatch
--- binutils-2.16.1cvs20060117.orig/debian/patches/001_ld_makefile_patch.dpatch	2006-02-22 19:37:29.000000000 -0800
+++ binutils-2.16.1cvs20060117/debian/patches/001_ld_makefile_patch.dpatch	2006-02-22 19:35:43.000000000 -0800
@@ -6,6 +6,10 @@
 ## DP: Author: Chris Chimelis <chris@debian.org>
 ## DP: Upstream status: N/A
 ## DP: Date: ??
+## DP: Fixed by Nikita Youshchenko <yoush@cs.msu.su> to be correct for
+## DP: cross-binutils - in that case change of $(scriptdir) to /usr/lib causes
+## DP: cross-ld to look for libraries in /usr/lib instead of
+## DP: /usr/$(target-alias)/lib
 
 if [ $# -ne 1 ]; then
     echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
@@ -29,24 +33,50 @@
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.am /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am
 --- ./ld/Makefile.am	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.am	2005-09-02 21:42:18.000000000 +0000
-@@ -20,7 +20,7 @@
+@@ -20,7 +20,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  
  EMUL = @EMUL@
  EMULATION_OFILES = @EMULATION_OFILES@
+@@ -431,7 +435,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
 diff -urNad --exclude=CVS --exclude=.svn ./ld/Makefile.in /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in
 --- ./ld/Makefile.in	2005-08-31 03:27:36.000000000 +0000
 +++ /tmp/dpep-work.eKU2vW/binutils-2.16.1cvs20050902/ld/Makefile.in	2005-09-02 21:43:37.259127535 +0000
-@@ -268,7 +268,7 @@
+@@ -268,7 +268,11 @@
  # We put the scripts in the directory $(scriptdir)/ldscripts.
  # We can't put the scripts in $(datadir) because the SEARCH_DIR
  # directives need to be different for native and cross linkers.
 -scriptdir = $(tooldir)/lib
-+scriptdir = $(libdir)
++scriptdir = `if [ "@host@" = "@target@" ] ; then \
++               echo '$(libdir)'; \
++	     else \
++	       echo '$(tooldir)/lib'; \
++	     fi`
  BASEDIR = $(srcdir)/..
  BFDDIR = $(BASEDIR)/bfd
  INCDIR = $(BASEDIR)/include
+@@ -1173,7 +1177,7 @@
+ 
+ ldmain.o: ldmain.c config.status
+ 	$(COMPILE) -c -DDEFAULT_EMULATION='"$(EMUL)"' \
+-	  -DSCRIPTDIR='"$(scriptdir)"' -DBINDIR='"$(bindir)"' \
++	  -DSCRIPTDIR='"'$(scriptdir)'"' -DBINDIR='"$(bindir)"' \
+ 	  -DTOOLBINDIR='"$(tooldir)/bin"' \
+ 	  -DTARGET='"@target@"' @TARGET_SYSTEM_ROOT_DEFINE@ \
+ 	  $(srcdir)/ldmain.c
diff -Naur binutils-2.16.1cvs20060117.orig/debian/patches/00list binutils-2.16.1cvs20060117/debian/patches/00list
--- binutils-2.16.1cvs20060117.orig/debian/patches/00list	2006-02-22 19:37:29.000000000 -0800
+++ binutils-2.16.1cvs20060117/debian/patches/00list	2006-02-22 19:37:05.000000000 -0800
@@ -6,3 +6,4 @@
 012_check_ldrunpath_length
 120_mips_xgot_multigot_workaround
 121_i386_x86_64_biarch
+999_lib64_for_cross
diff -Naur binutils-2.16.1cvs20060117.orig/debian/patches/999_lib64_for_cross.dpatch binutils-2.16.1cvs20060117/debian/patches/999_lib64_for_cross.dpatch
--- binutils-2.16.1cvs20060117.orig/debian/patches/999_lib64_for_cross.dpatch	1969-12-31 16:00:00.000000000 -0800
+++ binutils-2.16.1cvs20060117/debian/patches/999_lib64_for_cross.dpatch	2006-02-22 19:35:43.000000000 -0800
@@ -0,0 +1,56 @@
+#! /bin/sh -e
+## 999_lib64_for_cross.dpatch by Nikita Youshchenko <yoush@cs.msu.su>
+##
+## DP: Add /usr/${target-alias}/lib${LIBPATH_SUFFIX} to ld's default
+## DP: library search path for cross targets. Needed for cross targets that
+## DP: try to support both 32bit and 64bit emulations.
+
+if [ $# -lt 1 ]; then
+    echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+    exit 1
+fi
+
+[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
+patch_opts="${patch_opts:--f --no-backup-if-mismatch} ${2:+-d $2}"
+
+case "$1" in
+    -patch) patch -p1 ${patch_opts} < $0;;
+    -unpatch) patch -R -p1 ${patch_opts} < $0;;
+    *)
+        echo "`basename $0`: script expects -patch|-unpatch as argument" >&2
+        exit 1;;
+esac
+
+exit 0
+
+@DPATCH@
+diff -urNad /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh binutils-2.14.90.0.7.cross/ld/genscripts.sh
+--- /home/nikita/debian/binutils/binutils-2.14.90.0.7.cross/ld/genscripts.sh	2003-10-29 20:37:48.000000000 +0300
++++ binutils-2.14.90.0.7.cross/ld/genscripts.sh	2004-07-15 00:29:19.000000000 +0400
+@@ -176,6 +176,26 @@
+   ::) LIB_PATH=${tool_lib} ;;
+   *) LIB_PATH=${tool_lib}:${LIB_PATH} ;;
+   esac
++  # For multilib'ed targets, ensure both ${target_alias}/lib${LIBPATH_SUFFIX}
++  # and ${TOOL_LIB}/lib${LIBPATH_SUFFIX} to default search path, because
++  # 64bit libraries may be in both places, depending on cross-development
++  # setup method (e.g.: /usr/s390x-linux/lib64 vs /usr/s390-linux/lib64)
++  case "${LIBPATH_SUFFIX}:${tool_lib}" in
++    :*) ;;
++    *:*${LIBPATH_SUFFIX}) ;;
++    *)
++      paths="${exec_prefix}/${target_alias}/lib${LIBPATH_SUFFIX}"
++      if [ "${TOOL_LIB}" != x ]; then
++        paths="${paths} ${exec_prefix}/${TOOL_LIB}/lib${LIBPATH_SUFFIX}"
++      fi
++      for path in $paths; do
++        case :${LIB_PATH}: in
++          ::: | *:${path}:*) ;;
++          *) LIB_PATH=${path}:${LIB_PATH} ;;
++        esac
++      done
++    ;;
++  esac
+ fi
+ 
+ LIB_SEARCH_DIRS=`echo ${LIB_PATH} | sed -e 's/:/ /g' -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'`
diff -Naur binutils-2.16.1cvs20060117.orig/debian/rules binutils-2.16.1cvs20060117/debian/rules
--- binutils-2.16.1cvs20060117.orig/debian/rules	2006-02-22 19:37:29.000000000 -0800
+++ binutils-2.16.1cvs20060117/debian/rules	2006-02-22 19:35:43.000000000 -0800
@@ -381,7 +381,8 @@
 endif
 
 	$(install_file) $(pwd)/test-summary binutils/NEWS  \
-	                debian/README.Debian $(d_bin)/usr/share/doc/$(p_bin)/
+	                debian/README.Debian debian/README.cross \
+			$(d_bin)/usr/share/doc/$(p_bin)/
 
 	$(install_file) binutils/ChangeLog $(d_bin)/usr/share/doc/$(p_bin)/changelog
 
@@ -440,6 +441,133 @@
 
 ################################################################################
 
+
+#################
+# cross targets #
+#################
+
+# If $(TARGET) is not set, try reading debian/target
+ifeq ($(TARGET),)
+TARGET := $(cat debian/target 2>/dev/null)
+endif
+
+# Process the following only if $(TARGET) is set
+ifneq ($(TARGET),)
+
+# Support TARGET both as Debian architecture specification (e.g. arm),
+# and as the target name (e.g. arm-linux-gnu).
+try_convert := $(shell dpkg-architecture -a$(TARGET) -qDEB_HOST_GNU_TYPE 2>/dev/null)
+ifneq ($(try_convert),)
+override TARGET := $(try_convert)
+endif
+
+# Many people expect cross-binutils to be named like 'arm-linux-ld', not
+# like 'arm-linux-gnu-ld'. Package will provide symlinks. In future, this may
+# be replaced with alternatives.
+tmp_cpu := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_CPU 2>/dev/null)
+tmp_os := $(shell dpkg-architecture -t$(TARGET) -qDEB_HOST_ARCH_OS 2>/dev/null)
+ifeq ($(TARGET),$(tmp_cpu)-$(tmp_os)-gnu)
+do_symlinks := yes
+else
+do_symlinks := no
+endif
+
+p_cross = $(subst _,-,binutils-$(TARGET))
+d_cross = debian/$(p_cross)
+
+ifneq ($(filter sparc-linux-gnu powerpc-linux-gnu mips-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=$(TARGET:%-linux-gnu=%64-linux-gnu)
+endif
+ifneq ($(filter i386-linux-gnu i486-linux-gnu i586-linux-gnu x86-linux-gnu, $(TARGET)),)
+ADDITIONAL_TARGETS = --enable-targets=x86_64-linux-gnu
+endif
+ifeq ($(TARGET), x86_64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=i486-linux-gnu
+endif
+ifeq ($(TARGET), mipsel-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=mips64el-linux-gnu
+endif
+ifeq ($(TARGET), sparc64-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=sparc-linux-gnu
+endif
+ifeq ($(TARGET), s390-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390x-linux-gnu
+endif
+ifeq ($(TARGET), s390x-linux-gnu)
+ADDITIONAL_TARGETS = --enable-targets=s390-linux-gnu
+endif
+
+configure-$(TARGET)-stamp: patch-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf configure-$(TARGET)-stamp builddir-$(TARGET)
+	mkdir builddir-$(TARGET)
+	cd builddir-$(TARGET) \
+	    && env CC="$(CC)" ../configure --host=$(DEB_HOST_GNU_TYPE) \
+	        --build=$(DEB_BUILD_GNU_TYPE) --target=$(TARGET) --prefix=/usr \
+		$(ADDITIONAL_TARGETS)
+	touch $@
+
+build-$(TARGET)-stamp: configure-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	$(MAKE) -C builddir-$(TARGET) CFLAGS="$(CFLAGS)"
+	touch $@
+
+install-$(TARGET)-stamp: build-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross)
+	$(MAKE) -C builddir-$(TARGET) prefix=$(pwd)/$(d_cross)/usr \
+		mandir=$(pwd)/$(d_cross)/usr/share/man install
+	rm -rf $(d_cross)/usr/lib $(d_cross)/usr/info $(d_cross)/usr/share/locale
+	$(STRIP) $(d_cross)/usr/bin/*
+	gzip -9 $(d_cross)/usr/share/man/man1/*
+ifeq ($(do_symlinks),yes)
+	cd $(d_cross)/usr/bin && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+	cd $(d_cross)/usr/share/man/man1 && for f in *; do \
+	  ln -s $$f `echo $$f | sed 's/-gnu//'`; \
+	done
+endif
+	touch $@
+
+binary-cross: checkroot install-$(TARGET)-stamp
+	$(checkdir)
+	test "" != "$(TARGET)"
+	
+	chmod 755 debian/generate-cross-control
+	debian/generate-cross-control $(TARGET) > debian/control.$(TARGET)
+	
+	$(install_dir) $(d_cross)/DEBIAN
+	
+	$(install_dir) $(d_cross)/usr/share/doc/$(p_cross)/
+	$(install_file)	debian/changelog $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	$(install_file)	debian/copyright debian/README.cross $(d_cross)/usr/share/doc/$(p_cross)/
+	gzip -f -9 $(d_cross)/usr/share/doc/$(p_cross)/changelog.Debian
+	
+	for pkg in bfd gas gprof ld; do \
+	  ln -sf ../binutils/$$pkg $(d_cross)/usr/share/doc/$(p_cross)/$$pkg; \
+	done
+
+	rm -f debian/substvars
+	dpkg-shlibdeps $(d_cross)/usr/bin/*
+	dpkg-gencontrol -cdebian/control.$(TARGET) -P$(d_cross) -p$(p_cross)
+	dpkg --build $(d_cross) ..
+
+clean-cross: unpatch
+	$(checkdir)
+	test "" != "$(TARGET)"
+	rm -rf $(d_cross) debian/control.$(TARGET) debian/files debian/substvars \
+		builddir-$(TARGET) {configure,build,install}-$(TARGET)-stamp
+
+.PHONY: binary-cross clean-cross
+
+endif
+
+################################################################################
+
 define checkdir
         test -f bfd/elf32.c -a -f debian/rules
 endef
[signature.asc (application/pgp-signature, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org, James Troup <james@nocrew.org>:
Bug#231707; Package binutils. Full text and rfc822 format available.

Acknowledgement sent to Wookey <wookey@aleph1.co.uk>:
Extra info received and forwarded to list. Copy sent to James Troup <james@nocrew.org>. Full text and rfc822 format available.

Message #115 received at 231707@bugs.debian.org (full text, mbox):

From: Wookey <wookey@aleph1.co.uk>
To: james@nocrew.org, doko@debian.org
Cc: Josh Triplett <josh@freedesktop.org>, 231707@bugs.debian.org, "Nikita V. Youshchenko" <yoush@debian.org>
Subject: binutils cross-build patches
Date: Thu, 13 Apr 2006 23:33:19 +0100
We're working on debian/emdebian cross-build infrastructure at the Embedded
Debian Worksession in Extremadura.

We just checked that Josh's updated version of Nikita's patch in bug 231707
works OK, and builds working cross-binutils for current testing (arm tested
right now). (thanx Josh for the updates)

(The resulting packages are available at
http://build.emdebian.org/emdebian-tools/testing )

This patch has been pending since Feb2004/stable since July2005 and is now
well-tested and represents the standard way of building Debian cross-tools.
It does not affect people who are not cross-building the tools.
Is there anything from your maintainers' point of view preventing them from
going into the standard debian package? It would be good to stop carrying
this patch forward sometime.

thanx

Wookey
-- 
Aleph One Ltd, Bottisham, CAMBRIDGE, CB5 9BA, UK  Tel +44 (0) 1223 811679
work: http://www.aleph1.co.uk/     play: http://www.chaos.org.uk/~wookey/



Reply sent to Josh Triplett <josh@freedesktop.org>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Raphael Bossek <raphael.bossek@gmx.de>:
Bug acknowledged by developer. Full text and rfc822 format available.

Message #120 received at 231707-done@bugs.debian.org (full text, mbox):

From: Josh Triplett <josh@freedesktop.org>
To: 231707-done@bugs.debian.org
Subject: Fixed in binutils 2.16.1cvs20060413-1
Date: Mon, 24 Apr 2006 10:40:18 -0700
[Message part 1 (text/plain, inline)]
Version: 2.16.1cvs20060413-1

In the binutils changelog for version 2.16.1cvs20060413-1:
  * Integrate most of a patch to build arbitrary binutils-$TARGET
    cross-packages from #231707.  Thanks to Nikita V. Youshchenko
    <yoush@cs.msu.su> and Josh Triplett <josh@freedesktop.org>.

I just tested building cross-binutils for powerpc-linux-gnu from the
2.16.1cvs20060413-1 source package, using the procedure documented at
<http://psas.pdx.edu/DebianCrossCompilerHowto>, and it worked fine.
Closing this bug.

- Josh Triplett


[signature.asc (application/pgp-signature, attachment)]

Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Sun, 24 Jun 2007 11:53:03 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sat Apr 19 07:13:34 2014; Machine Name: buxtehude.debian.org

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.