#!/bin/bash
#binutils_toolchain.

#"Locking in" Glibc

#link everything against newly build glibc in prelfs
# this needs a "prepared" binutils-tree (from 003.sh)
#if you dont have that build anymore, its no major problem to
# leave out the followwung 2 lines:
cd $LFS/usr/src/_binutils
make -C ld install
#binutils sources can be deleted now

#let gcc use our static dynlinker
SPECFILE=`gcc -print-file-name=specs` &&
sed -i 's@ /lib/ld-linux.so.2@ /prelfs/lib/ld-linux.so.2@g' $SPECFILE &&
#the book says: inspect the specs to verify intended changes
#remove headers that may have come from host by gcc's fixincl
rm -f /prelfs/lib/gcc/*/*/include/{pthread.h,bits/sigthread.h}

#small test:
echo 'main(){}' > dummy.c
cc dummy.c
readelf -l a.out |grep ': /prelfs'
#[Requesting program interpreter: /prelfs/lib/ld-linux.so.2] is expected here!!!!!!!!!
rm -f dummy.c a.out
