#!/bin/sh

. config/options $1

mkdir -p $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/elf/ld*.so.* $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/libc.so.6 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/dlfcn/libdl.so.2 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/nptl/libpthread.so.0 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/math/libm.so.6 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/login/libutil.so.1 $INSTALL/lib # e.g. for utmp support, needed by PAM_filter
  cp $PKG_BUILD/objdir-$1/rt/librt.so.1 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/resolv/libnss_dns.so.2 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/nis/libnsl.so.1 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/nis/libnss_compat.so.2 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/nss/libnss_files.so.2 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/crypt/libcrypt.so.1 $INSTALL/lib
  cp $PKG_BUILD/objdir-$1/resolv/libresolv.so.2 $INSTALL/lib

  [ "$DEVTOOLS" = yes ] && cp $PKG_BUILD/objdir-$1/nptl_db/libthread_db.so.1 $INSTALL/lib # for GDB

mkdir -p $INSTALL/bin
  cp $PKG_BUILD/objdir-$1/elf/ldd $INSTALL/bin
  sed -i 's%bash%sh%g' $INSTALL/bin/ldd

  cp $PKG_BUILD/objdir-$1/locale/locale $INSTALL/bin

  mkdir -p $INSTALL/usr/lib/gconv
    cp $PKG_BUILD/iconvdata/gconv-modules $INSTALL/usr/lib/gconv
  # didn't yet find a way to separate only needed modules.
  # the way they are used is described within gconv-modules though
    cp $PKG_BUILD/objdir-$1/iconvdata/*.so $INSTALL/usr/lib/gconv

mkdir -p $INSTALL/etc
    cp $PKG_DIR/config/nsswitch.conf $INSTALL/etc
