#!/bin/sh

################################################################################
#      This file is part of OpenELEC - http://www.openelec.tv
#      Copyright (C) 2009-2011 Stephan Raue (stephan@openelec.tv)
#
#  This Program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2, or (at your option)
#  any later version.
#
#  This Program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with OpenELEC.tv; see the file COPYING.  If not, write to
#  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#  http://www.gnu.org/copyleft/gpl.html
################################################################################

. 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

# libiconv replacement:
#  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
  cp $PKG_BUILD/sunrpc/etc.rpc $INSTALL/etc/rpc
