#!/bin/bash
#binutils_toolchain

#this needs a "prepared" binutils build (from 009.sh):
#If you dont have it, skip the rest of this script. Will work without.
cd /usr/src/_binutils ||exit
#INSTALL=: correct assumption about existence of /usr/bin/install
make -C ld INSTALL=/prelfs/bin/install install

#let gcc use the new dynamic linker:
SPECFILE=$(gcc --print-file specs) &&
perl -pi -e 's@ /prelfs/lib/ld-linux.so.2@ /lib/ld-linux.so.2@g;' -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/@g;' $SPECFILE
perl -pi -e 's@/usr/lib//usr/lib/@/usr/lib/@g;' $SPECFILE

#a small test:
echo 'main(){}' > dummy.c
cc dummy.c
#this should give "Requesting program interpreter: /lib/ld-linux.so.2" !!!!!!!!!:
readelf -l a.out |grep ': /lib'
rm dummy.c a.out

#now you can remove binutils sources
