#
# 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/usr/include        &&

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

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     \
            ${INSTALL_ROOT}/usr/include/gnu/stubs-32.h  \
            ${INSTALL_ROOT}/usr/include/gnu/stubs-64.h; do
  if  [  -f  $i  ];  then
    rm  -vf  $i
  fi
done  &&
#
# End syscall.h and stubs.h fix
#

#
# install
#
cd "${SOURCE_DIRECTORY}.bld/INSTALL_ROOT" &&
if test -d ${TRACK_ROOT}/lib64 || test -f ./lib/ld-linux-x86-64.so.2; then
  mkdir -p ./lib64 &&
  ln -sf $TRACK_ROOT/lib/ld-linux-x86-64.so.2 ./lib64/ld-linux-x86-64.so.2
fi &&
find . | cpio --pass-through --make-directories --unconditional --verbose \
              "${INSTALL_ROOT}/"

(  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  &&

if [[ $INIT_INSTALLED ]]; then
  install_config_file "$SPELL_DIRECTORY/init.d/nscd.conf" \
                      "$INSTALL_ROOT/etc/sysconfig/nscd"
fi &&

install_config_file  $SOURCE_DIRECTORY/nscd/nscd.conf  \
  $INSTALL_ROOT/etc/nscd.conf &&

ln -sfn /usr/include/locale.h "${INSTALL_ROOT}/usr/include/xlocale.h"
