cd $SOURCE_DIRECTORY.bld  &&

#
# the following conditional is commented out because the
# make install install_root="${INSTALL_ROOT}"
# does what it does already.
#

#if  [  "$CROSS_INSTALL"  =  "on"  ];  then
#  echo "prefix = ${INSTALL_ROOT}/usr" > configparms                               &&
#  echo "slibdir = ${INSTALL_ROOT}/lib" >> configparms                             &&
#  echo "rootsbindir = ${INSTALL_ROOT}/sbin" >> configparms                        &&
#  echo "sysconfdir = ${INSTALL_ROOT}/etc" >> configparms                          &&
#  echo "infodir = ${INSTALL_ROOT}/usr/share/info" >> configparms                  &&
#  sedit "s/\$(slibdir)/\/lib/g" $SOURCE_DIRECTORY/Makerules                       &&
#  sedit "s/\$(libdir)/\/usr\/lib/g" $SOURCE_DIRECTORY/Makerules                   &&
#
#  if  [  "$GLIBC_NPTL"  =  "y"  ];  then
#    sedit  "s/\$(slibdir)/\/lib/g"      $SOURCE_DIRECTORY/nptl/Makefile  &&
#    sedit  "s/\$(libdir)/\/usr\/lib/g"  $SOURCE_DIRECTORY/nptl/Makefile
#  else
#    sedit  "s/\$(slibdir)/\/lib/g"      $SOURCE_DIRECTORY/linuxthreads/Makefile  &&
#    sedit  "s/\$(libdir)/\/usr\/lib/g"  $SOURCE_DIRECTORY/linuxthreads/Makefile
#  fi
#fi  &&

#
# 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 /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  )  &&

#
# Now install sanitised glibc-kernel-headers
#
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"  &&
# workaround the 0.9.3 iso installing broken glibc-kernel-headers
rm -rf ${INSTALL_ROOT}/usr/include/asm/mach-*  &&
#
#  asm is a symlink to asm-$GLIBC-ARCH
#
install  -d  ${INSTALL_ROOT}/usr/include/asm     &&
cp  -fa  asm/*  ${INSTALL_ROOT}/usr/include/asm  &&

#
# 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
