#
# spec file for package bluez (Version 4.62)
#
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           bluez
BuildRequires:  dbus-1-devel flex
BuildRequires:  glib2-devel libnl-devel libusb-devel
BuildRequires:  alsa-devel libsndfile-devel pkg-config udev
Url:            http://www.bluez.org
Version:        4.62
Release:        1
Summary:        Bluetooth Stack for Linux
Group:          Hardware/Mobile
License:        GPLv2+
Group:          Hardware/Mobile
AutoReqProv:    on
Source:         http://www.kernel.org/pub/linux/bluetooth/bluez-%{version}.tar.bz2
Source2:        bluez-coldplug.init
Source3:        bluetooth.sysconfig
Source4:        bluetooth.sh
Source6:        README.SUSE
Source7:        bluetooth.modprobe
Patch1:         bluez-4.44-udev-use-helperscript.diff
Patch2:         001-remove-rule-dell-mouse.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
Provides:       bluez-utils = 3.36
Obsoletes:      bluez-utils <= 3.36
Provides:       bluez-audio = 3.36
Obsoletes:      bluez-audio <= 3.36
Requires:       libbluetooth3 = %{version}
%if %( echo `rpm -q --queryformat %%{version} udev` ) < 144
%define OLD_UDEV 1
%else
%define OLD_UDEV 0
%endif

%description
The Bluetooth stack for Linux.



Authors:
--------
    Marcel Holtmann <marcel@holtmann.org>
    and others, see AUTHORS

%package devel
License:        GPLv2+
Summary:        Files needed for BlueZ development
Group:          Development/Sources
Requires:       libbluetooth3 = %{version}

%description devel
Files needed to develop applications for the BlueZ Bluetooth protocol
stack.



Authors:
--------
    Marcel Holtmann <marcel@holtmann.org>
    and others, see AUTHORS

%package -n libbluetooth3
License:        GPLv2+
Summary:        Bluetooth Libraries
Group:          Hardware/Mobile
Provides:       bluez-libs = 3.36
Obsoletes:      bluez-libs <= 3.36

%description -n libbluetooth3
Bluetooth protocol stack libraries.



Authors:
--------
    Marcel Holtmann <marcel@holtmann.org>
    and others, see AUTHORS in the documentation of the "bluez" package.

%package cups
Group:          Hardware/Printing
License:        GPLv2+
Summary:        CUPS Driver for Bluetooth Printers
Requires:       libbluetooth3 = %{version}

%description cups
Contains the files required by CUPS for printing to Bluetooth-connected
printers.



Authors:
--------
    Marcel Holtmann <marcel@holtmann.org>
    and others, see AUTHORS in the documentation of the "bluez" package.

%package test
Group:          Development/Tools/Debuggers
License:        GPLv2+ ; MIT License (or similar)
Summary:        Tools for testing of various Bluetooth-functions
Requires:       libbluetooth3 = %{version} python-gobject2 dbus-1-python

%description test
Contains a few tools for testing various bluetooth functions. The
BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., U.S.A.



Authors:
--------
    Marcel Holtmann <marcel@holtmann.org>
    and others, see AUTHORS in the documentation of the "bluez" package.

%package alsa
Group:          Productivity/Multimedia/Sound/Utilities
License:        GPLv2+
Summary:        Bluetooth Sound Support
Requires:       libbluetooth3 = %{version}
Provides:       bluez-audio:%_libdir/alsa-lib/libasound_module_pcm_bluetooth.so

%description alsa
The package contains libraries for using bluetooth audio services.

The BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., USA.



Authors:
--------
    Marcel Holtmann <marcel@holtmann.org>
    and others, see AUTHORS in the documentation of the "bluez" package.

%package compat
Group:          Hardware/Mobile
License:        GPLv2+
Summary:        Bluetooth Stack for Linux
Requires:       libbluetooth3 = %{version}

%description compat
The Bluetooth stack for Linux. This package contains older and partly
deprecated binaries that might still be needed for compatibility.



Authors:
--------
    Marcel Holtmann <marcel@holtmann.org>
    and others, see AUTHORS

%prep
%setup -q
%patch1 -p1
%patch2 -p1
cp %{S:6} .
%{?suse_update_config:%{suse_update_config -f . }}
mkdir dbus-apis
cp -a doc/*.txt dbus-apis/

%build
# autoreconf -sfi
CFLAGS="$RPM_OPT_FLAGS -g" \
	./configure	--prefix=%{_prefix} \
			--mandir=%{_mandir} \
			--sysconfdir=%{_sysconfdir} \
			--libdir=%{_libdir} \
			--libexecdir=/lib \
			--localstatedir=/var	\
			--enable-gstreamer	\
			--enable-alsa		\
			--enable-usb		\
			--enable-netlink	\
			--enable-tools		\
			--enable-bccmd		\
			--enable-hid2hci	\
			--enable-dfutool	\
			--enable-cups		\
			--enable-test		\
			--enable-pand		\
			--enable-dund		\
			--enable-manpages	\
			--enable-configfiles	\
			--enable-pcmcia
make %{?jobs:-j %jobs} all

%install
make DESTDIR=$RPM_BUILD_ROOT install
# bluez-test
cd test
install --mode=0755	\
	apitest		\
	simple-agent	\
	simple-service	\
	list-devices	\
	test-audio	\
	test-adapter	\
	test-device	\
	test-discovery	\
	test-input	\
	test-manager	\
	test-network	\
	test-serial	\
	test-service	\
	test-telephony	\
	$RPM_BUILD_ROOT/%{_bindir}/
cd ..
rm -v $RPM_BUILD_ROOT/%{_libdir}/bluetooth/plugins/*.la $RPM_BUILD_ROOT/%{_libdir}/libbluetooth.la
rm -rvf $RPM_BUILD_ROOT/%{_libdir}/gstreamer-*
rm -v $RPM_BUILD_ROOT/%{_libdir}/alsa-lib/*.la
install --mode=0755 -D %{S:2} $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/bluez-coldplug
install --mode=0644 -D %{S:3} $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.bluetooth
install --mode=0755 -D %{S:4} $RPM_BUILD_ROOT/lib/udev/bluetooth.sh
install --mode=0644 -D %{S:7} $RPM_BUILD_ROOT/%{_sysconfdir}/modprobe.d/50-bluetooth.conf

%clean
rm -rf $RPM_BUILD_ROOT

%post
%{fillup_only -n bluetooth}
%{insserv_force_if_yast bluez-coldplug}

%preun
%stop_on_removal bluez-coldplug

%postun
%{insserv_cleanup}

%post -n libbluetooth3 -p /sbin/ldconfig

%postun -n libbluetooth3 -p /sbin/ldconfig

%files
%defattr(-, root, root)
%doc AUTHORS COPYING ChangeLog README README.SUSE dbus-apis
%{_bindir}/hcitool
%{_bindir}/l2ping
%{_bindir}/rfcomm
%{_bindir}/sdptool
%{_bindir}/ciptool
%{_bindir}/dfutool
%{_sbindir}/hciattach
%{_sbindir}/hciconfig
%{_sbindir}/bluetoothd
%{_sbindir}/hid2hci
%{_sbindir}/bccmd
%dir /lib/udev
/lib/udev/*
%if 0%{OLD_UDEV}
%dir %{_sysconfdir}/udev/rules.d
%config %{_sysconfdir}/udev/rules.d/*
%endif
%{_sysconfdir}/init.d/bluez-coldplug
%dir %{_libdir}/bluetooth
%dir %{_libdir}/bluetooth/plugins
%{_libdir}/bluetooth/plugins/netlink.so
%doc %{_mandir}/man8/hciattach.8.gz
%doc %{_mandir}/man8/hciconfig.8.gz
#%doc %{_mandir}/man5/hcid.conf.5.gz
%doc %{_mandir}/man8/bluetoothd.8.gz
%doc %{_mandir}/man8/hid2hci.8.gz
%doc %{_mandir}/man8/bccmd.8.gz
%doc %{_mandir}/man8/l2ping.8.gz
%doc %{_mandir}/man1/hcitool.1.gz
%doc %{_mandir}/man1/sdptool.1.gz
%doc %{_mandir}/man1/ciptool.1.gz
%doc %{_mandir}/man1/rfcomm.1.gz
%doc %{_mandir}/man1/dfutool.1.gz
%doc %{_mandir}/man1/hciemu.1.gz
%doc %{_mandir}/man1/rctest.1.gz
%dir %{_sysconfdir}/bluetooth
%config(noreplace) %{_sysconfdir}/bluetooth/main.conf
%config(noreplace) %{_sysconfdir}/bluetooth/rfcomm.conf
/var/adm/fillup-templates/sysconfig.bluetooth
%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
#%doc %{_defaultdocdir}/bluez-utils/
%dir /var/lib/bluetooth
%dir %{_sysconfdir}/modprobe.d
%config(noreplace) %{_sysconfdir}/modprobe.d/50-bluetooth.conf

%files devel
%defattr(-, root, root)
/usr/include/bluetooth
%{_libdir}/libbluetooth.so
%{_libdir}/pkgconfig/bluez.pc
#%{_datadir}/aclocal/bluez.m4

%files -n libbluetooth3
%defattr(-, root, root)
%{_libdir}/libbluetooth.so.*
%doc AUTHORS COPYING INSTALL ChangeLog README

%files cups
%defattr(-,root,root)
%dir %{_libdir}/cups
%dir %{_libdir}/cups/backend
%{_libdir}/cups/backend/bluetooth
#%doc %{_defaultdocdir}/bluez-cups

%files test
%defattr(-,root,root)
%{_sbindir}/hciemu
%{_bindir}/l2test
%{_bindir}/rctest
%{_bindir}/apitest
%{_bindir}/list-devices
%{_bindir}/simple-agent
%{_bindir}/simple-service
%{_bindir}/test-adapter
%{_bindir}/test-audio
%{_bindir}/test-device
%{_bindir}/test-discovery
%{_bindir}/test-input
%{_bindir}/test-manager
%{_bindir}/test-network
%{_bindir}/test-serial
%{_bindir}/test-service
%{_bindir}/test-telephony
#%{_bindir}/hsmicro
#%{_bindir}/hsplay
#%{_bindir}/hstest
#%{_bindir}/attest
#%{_bindir}/passkey-agent
#%{_bindir}/auth-agent
#%doc %{_defaultdocdir}/bluez-test

%files alsa
%defattr(-,root,root)
%dir %{_sysconfdir}/alsa
%config %{_sysconfdir}/alsa/bluetooth.conf
%{_libdir}/alsa-lib/*.so

%files compat
%defattr(-,root,root)
%{_bindir}/dund
%{_bindir}/pand
%doc %{_mandir}/man1/pand.1.gz
%doc %{_mandir}/man1/dund.1.gz

%changelog