#!/bin/sh

################################################################################
#      This file is part of OpenELEC - http://www.openelec.tv
#      Copyright (C) 2009-2012 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, 51 Franklin Street, Suite 500, Boston, MA 02110, USA.
#  http://www.gnu.org/copyleft/gpl.html
################################################################################

. config/options

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

mkdir -p $INSTALL/usr/lib/bluetooth
  cp $PKG_BUILD/src/bluetoothd $INSTALL/usr/lib/bluetooth
  cp $PKG_BUILD/obexd/src/obexd $INSTALL/usr/lib/bluetooth

# client
  mkdir -p $INSTALL/usr/bin
    cp $PKG_BUILD/client/bluetoothctl $INSTALL/usr/bin

# tools
#  mkdir -p $INSTALL/lib/udev
#    cp $PKG_BUILD/tools/hid2hci $INSTALL/lib/udev

#  mkdir -p $INSTALL/lib/udev/rules.d
#    cp $PKG_BUILD/tools/97-hid2hci.rules $INSTALL/lib/udev/rules.d

if [ "$DEVTOOLS" = "yes" ]; then
# tools
  mkdir -p $INSTALL/usr/bin
    cp $PKG_BUILD/tools/bccmd $INSTALL/usr/bin
    cp $PKG_BUILD/tools/ciptool $INSTALL/usr/bin
    cp $PKG_BUILD/tools/hciattach $INSTALL/usr/bin
    cp $PKG_BUILD/tools/hciconfig $INSTALL/usr/bin
    cp $PKG_BUILD/tools/hcidump $INSTALL/usr/bin
    cp $PKG_BUILD/tools/hcitool $INSTALL/usr/bin
    cp $PKG_BUILD/tools/l2ping $INSTALL/usr/bin
    cp $PKG_BUILD/tools/l2test $INSTALL/usr/bin
    cp $PKG_BUILD/tools/rctest $INSTALL/usr/bin
    cp $PKG_BUILD/tools/rfcomm $INSTALL/usr/bin
    cp $PKG_BUILD/tools/sdptool $INSTALL/usr/bin

# monitor
  mkdir -p $INSTALL/usr/bin
    cp $PKG_BUILD/monitor/btmon $INSTALL/usr/bin

# test
  mkdir -p $INSTALL/usr/lib/bluez/test
    cp -P $PKG_BUILD/test/* $INSTALL/usr/lib/bluez/test
    chmod +x $INSTALL/usr/lib/bluez/test/*
fi
