#!/bin/sh

. config/options

PKG_DIR=`find $PACKAGES -type d -name $1`

mkdir -p $INSTALL/etc/bluetooth
  cp $PKG_BUILD/src/main.conf $INSTALL/etc/bluetooth
  cp $PKG_BUILD/tools/rfcomm.conf $INSTALL/etc/bluetooth
  cp $PKG_BUILD/input/input.conf $INSTALL/etc/bluetooth

mkdir -p $INSTALL/etc/dbus-1/system.d
  cp $PKG_BUILD/src/bluetooth.conf $INSTALL/etc/dbus-1/system.d

mkdir -p $INSTALL/lib/udev
  cp $PKG_BUILD/scripts/bluetooth_serial $INSTALL/lib/udev
  chmod +x $INSTALL/lib/udev/bluetooth_serial

mkdir -p $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/scripts/97-bluetooth.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/scripts/97-bluetooth-hid2hci.rules $INSTALL/lib/udev/rules.d
  cp $PKG_BUILD/scripts/97-bluetooth-serial.rules $INSTALL/lib/udev/rules.d

if [ $DEVTOOLS = yes ]; then
  mkdir -p $INSTALL/usr/bin
    cp $PKG_BUILD/tools/.libs/ciptool $INSTALL/usr/bin
    cp $PKG_BUILD/tools/.libs/hcitool $INSTALL/usr/bin
    cp $PKG_BUILD/tools/.libs/l2ping $INSTALL/usr/bin
    cp $PKG_BUILD/tools/.libs/rfcomm $INSTALL/usr/bin
    cp $PKG_BUILD/tools/.libs/sdptool $INSTALL/usr/bin
    cp $PKG_BUILD/tools/dfutool $INSTALL/usr/bin
    cp $PKG_BUILD/compat/.libs/hidd  $INSTALL/usr/bin
    cp $PKG_BUILD/test/.libs/l2test $INSTALL/usr/bin
    cp $PKG_BUILD/test/.libs/rctest $INSTALL/usr/bin
fi

mkdir -p $INSTALL/usr/lib
  cp $PKG_BUILD/lib/.libs/libbluetooth.so* $INSTALL/usr/lib

mkdir -p $INSTALL/usr/lib/alsa-lib
  cp $PKG_BUILD/audio/.libs/*.so $INSTALL/usr/lib/alsa-lib

mkdir -p $INSTALL/usr/lib/bluetooth/plugins
  #cp $PKG_BUILD/plugins/.libs/*.so $INSTALL/usr/lib/bluetooth/plugins

mkdir -p $INSTALL/usr/sbin
  cp $PKG_BUILD/src/.libs/bluetoothd $INSTALL/usr/sbin
  cp $PKG_BUILD/tools/.libs/bccmd $INSTALL/usr/sbin
  cp $PKG_BUILD/tools/.libs/hciattach $INSTALL/usr/sbin
  cp $PKG_BUILD/tools/.libs/hciconfig $INSTALL/usr/sbin
  cp $PKG_BUILD/test/.libs/hciemu $INSTALL/usr/sbin
  cp $PKG_BUILD/tools/hid2hci $INSTALL/usr/sbin

