description="The BlueZ package contains the Bluetooth protocol stack for Linux."
url="http://www.bluez.org/"

packager="spiky <spiky@nutyx.org>"
contributors="Pierre,Tnut"

makedepends=(readline dbus libical libvorbis alsa-lib
             libusb-compat libsndfile cups glib)

name=bluez
version=5.66

runyx_version=20201011

PKGMK_GROUPS=(man devel doc)

source=(http://downloads.tuxfamily.org/nutyx/files/runyx-${runyx_version}.tar.xz
	    https://www.kernel.org/pub/linux/bluetooth/$name-$version.tar.xz)


build() {
cd $name-$version

##sed 's/pause(/bluez_&/' -i profiles/audio/media.c

./configure --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --enable-gstreamer \
    --enable-alsa \
    --enable-usb \
    --enable-tools \
    --enable-bccmd \
    --enable-dfutool \
    --enable-hid2hci \
    --enable-hidd \
    --enable-pand \
    --enable-dund \
    --enable-cups \
    --disable-test \
    --disable-manpages    \
    --enable-library
make
make DESTDIR=$PKG install

install -v -dm755 $PKG/{etc/bluetooth,usr/sbin}
install -v -m644 src/main.conf $PKG/etc/bluetooth/main.conf
ln -svf ../libexec/bluetooth/bluetoothd $PKG/usr/sbin

cat > $PKG/etc/bluetooth/rfcomm.conf << "EOF"
# rfcomm.conf
# Set up the RFCOMM configuration of the Bluetooth subsystem in the Linux kernel.
# Use one line per command
# See the rfcomm man page for options


# End of rfcomm.conf
EOF

cat > $PKG/etc/bluetooth/uart.conf << "EOF"
#uart.conf
# Attach serial devices via UART HCI to BlueZ stack
# Use one line per device
# See the hciattach man page for options

# End of uart.conf
EOF


install -m644 profiles/network/network.conf \
	profiles/input/input.conf \
	$PKG/etc/bluetooth

install -v -dm755 $PKG/usr/share/doc/$name-$version
install -v -m644 doc/*.txt $PKG/usr/share/doc/$name-$version

# Obsolet lib
rm $PKG/usr/lib/libbluetooth.la

# Service
cd $SRC/runyx-${runyx_version}
make DESTDIR=$PKG install-sysv-bluetooth
mkdir -p $PKG/etc/sysconfig
#ln -sv ../sysv/sysconfig services/runyx/
sed -i 's@${EXTDIR}/@${PKG}/etc/@' services/runyx/Makefile
make DESTDIR=$PKG install-runyx-bluetooth
}
