#
# install kernel headers first so that gcc doesn't fail to find them if
# glibc decides to compile stuff during 'make install', which it does in 2.4
#
install  -d  ${INSTALL_ROOT}/usr/include  &&
cd  $GLIBC_HEADERS_DIR/include            &&

if [  !  "$GLIBC_NPTL"  =  "y"  ];  then
  echo  "installing asm-generic headers"                &&
  install  -d  ${INSTALL_ROOT}/usr/include/asm-generic  &&
  cp  -fa  asm-generic/*  ${INSTALL_ROOT}/usr/include/asm-generic
fi  &&

echo  "installing glibc linux headers"               &&
install  -d  ${INSTALL_ROOT}/usr/include/linux       &&
cp  -fa  linux/*  ${INSTALL_ROOT}/usr/include/linux  &&

echo  "installing asm-$GLIBC_ARCH headers to /usr/include/asm"  &&
#
#  asm is a symlink to asm-$GLIBC-ARCH
#
install  -d  ${INSTALL_ROOT}/usr/include/asm     &&
cp  -fa  asm/*  ${INSTALL_ROOT}/usr/include/asm  &&

cd $SOURCE_DIRECTORY.bld  &&

#
# glibc only installs these if the file differs
#
for  i  in  ${INSTALL_ROOT}/usr/include/bits/syscall.h  \
            ${INSTALL_ROOT}/usr/include/gnu/stubs.h;    do
  if  [  -f  $i  ];  then
    rm  -vf  $i
  fi
done  &&
#
# End syscall.h and stubs.h fix
#

#
# install
#
make  install install_root="${INSTALL_ROOT}" &&
if [[ ${SMGL_COMPAT_ARCHS[1]} == x86_64 ]]; then
  [ -d /lib64 -a ! -f /lib64/ld-linux-x86-64.so.2 -a -f /lib/ld-linux-x86-64.so.2 ] &&
    ln -s $TRACK_ROOT/lib/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
  true  # see bug 8626 for info about this conditional
fi &&
(  ldconfig  ||  true  )  &&

#
# In case this is a "new" system, setup INSTALL_ROOT/etc/ld.so.conf
#
if  !  grep  -q  "/usr/lib"  $INSTALL_ROOT/etc/ld.so.conf;  then
  echo  "/usr/lib"  >>  $INSTALL_ROOT/etc/ld.so.conf
fi
