#!/bin/sh
# Build binutils for Slackware by volkerdi@slackware.com
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-binutils

mkdir -p $PKG/usr
cd $TMP
tar xzvf $CWD/binutils-2.9.5.0.42.tar.gz
cd binutils-2.9.5.0.42

# Now install the default ELF target.  We'll use this target for libc6, but will enable all the
# supported targets to make sure the various binutils utilities that are symlinked to in /bin are
# cross platform.
./configure --prefix=/usr \
  --enable-shared \
  --enable-targets=i386-slackware-linux,i386-slackware-linux-gnulibc1,i386-slackware-linux-gnuaout \
  i386-slackware-linux
make CFLAGS=-O2 LDFLAGS=-s
make CFLAGS=-O2 LDFLAGS=-s install prefix=$PKG/usr

mkdir -p $PKG/usr/doc/binutils-2.9.5.0.42
cp -a COPYING* Chang* README $PKG/usr/doc/binutils-2.9.5.0.42
chown -R root.root $PKG/usr/doc/binutils-2.9.5.0.42
( cd $PKG/usr/bin ; mv strings strings-GNU )
( cd $PKG/usr/man/man1 ; mv strings.1 strings-GNU.1 )
rm $PKG/usr/bin/c++filt
rm $PKG/usr/man/man1/c++filt.1

# Now, make symlinks for the binaries in /usr/i386*/bin to the utils
# in /usr/bin.  EXCEPT:  Don't like 'as' and 'ld' in non-default
# targets (libc4 and libc5).

# Move ldscripts to /usr/lib/ldscripts.
# Link /usr/i386-slackware-linux/lib/ldscripts/ to /usr/lib/ldscripts.
# Link /usr/i386-slackware-linux-gnuaout/lib/ldscripts/ to /usr/lib/ldscripts.
# Don't link the libc5 stuff.  It'll have to be changed in /usr/lib/ldscripts.
# (these files:  i386linux.x i386linux.xbn i386linux.xn)

# Make sure the ldscripts search the full library path for libc6, and only
# the /usr/i386-*/lib/ path for non-default targets.

# Whew! :)

