# bluez
# Builds from https://github.com/puppylinux-woof-CE/petbuilds
# File auto generated by ./mk_petbuild.sh. Edit as necessary.

. ../func
. ../build.conf

URL=http://www.kernel.org/pub/linux/bluetooth
PKG=bluez
VER=5.38
COMP=tar.xz
DESC="bluez is a set of utilities for bluetooth funcionality"
DEPS=
CAT=Network
DESKTOP=bluez.desktop
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
# comment these 2 below if you use a custom package() function
[ -f "$DESKTOP" ] || DESKTOP=not
[ -z "$DEPS" ] && DEPS=not

ARCH=$(uname -m)
case $ARCH in # set in build.conf
 *64) 	LIBDIR=$LIBCONF64 ;;
 arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ;;
esac

patch_me() { #from https://slackbuilds.org/mirror/slackware/slackware-current/source/n/bluez/bluez.SlackBuild
cd ${PKG}-${VER}
	patch -p0 < ../bluez-5.30-obexd_without_systemd-1.patch
	sed -i -e 's|-lreadline|\0 -lncursesw|g' Makefile.{in,tools}
	cd -
}

build() {
	cd ${PKG}-${VER}
	./configure --prefix=/usr \
				--sysconfdir=/etc \
				--localstatedir=/var \
				--libdir=/usr/${LIBDIR} \
				--disable-systemd \
				--disable-cups \
				|| exit 1
	make -j2 || exit 1
	make DESTDIR=${CWD}/${PKG}-install install
	mkdir -p ${CWD}/${PKG}-install/usr/sbin
	(cd ${CWD}/${PKG}-install/usr/sbin; ln -sf ../libexec/bluetooth/bluetoothd . )
	install -d -m 0755 ${CWD}/${PKG}-install/etc/init.d
	install -m 0755 ${CWD}/rc.bluetooth ${CWD}/${PKG}-install/etc/init.d
	install -d -m 0755 ${CWD}/${PKG}-install/lib/modprobe.d
	install -m 0644 ${CWD}/btusb.conf ${CWD}/${PKG}-install/lib/modprobe.d/
	cd -
}

# main
retrieve ${PKG}-${VER}.${COMP}
extract ${PKG}-${VER}.${COMP}
patch_me
build
package_std $PKG $VER $ARCH $DESKTOP "$DESC" $DEPS $CAT
