File gammu.spec of Package gammu

#
# spec file for package gammu (Version 1.25.0)
#
# 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/
#



Name:           gammu
Version:        1.25.0
Release:        3
# Set to 0 to disable bluetooth support
%if 0%{?opensuse_bs} && 0%{?sles_version} == 9
%define bluetooth   0
%else
%define bluetooth   1
%endif
# Set to 0 to disable PostgreSQL support
%define pqsql     1
# Set to 0 to disable MySQL support
%define mysql     1
# Set to 0 to disable DBI support
%define dbi       0
# Set to 0 to disable USB support
%define usb       1
# Change if using tar.gz sources
%define extension   bz2
# Python name
%{!?__python: %define __python python}
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} || 0%{?fedora} || 0%{?rhel}
%define gammu_docdir %_docdir/%{name}-%{version}
%else
%define gammu_docdir %_docdir/%{name}
%endif
Summary:        Mobile phone management utility
License:        GPLv2
%if 0%{?suse_version}
Group:          Applications/Communications
%else
Group:          Applications/Communications
%endif
# Detect build requires, I really hate this crap
# SUSE
%if 0%{?suse_version}
%define dist_usb_libs libusb-1_0-devel
%define dist_dbi_libs libdbi-devel libdbi-drivers-dbd-sqlite3 sqlite
# 11.1 changed name of devel package for Bluetooth
%if 0%{?suse_version} >= 1110
%define dist_bluez_libs bluez-devel
%else
%define dist_bluez_libs bluez-libs >= 2.0
%endif
%define dist_postgres_libs postgresql-devel
%else
# Mandriva
%if 0%{?mandriva_version}
%define dist_usb_libs libusb-1_0-devel
%define dist_dbi_libs libdbi-devel libdbi-drivers-dbd-sqlite3 sqlite3-tools
# 64-bit Mandriva has 64 in package name
%ifarch x86_64
%define mandriva_hack 64
%endif
# Bluetooth things got renamed several times
%if 0%{?mandriva_version} > 2007
%define dist_bluez_libs lib%{?mandriva_hack}bluez2 lib%{?mandriva_hack}bluez-devel
%else
%if 0%{?mandriva_version} > 2006
%define dist_bluez_libs lib%{?mandriva_hack}bluez2 lib%{?mandriva_hack}bluez2-devel
%else
%define dist_bluez_libs libbluez1 >= 2.0 libbluez1-devel >= 2.0
%endif
%endif
# postgresql-devel does not work for whatever reason in buildservice
%if 0%{?mandriva_version} == 2009
%define dist_postgres_libs postgresql8.3-devel
%else
%define dist_postgres_libs postgresql-devel
%endif
%else
# Fedora / Redhat / Centos
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} || 0%{?fedora} || 0%{?rhel}
%define dist_usb_libs libusb1-devel
%define dist_dbi_libs libdbi-devel libdbi-dbd-sqlite sqlite
%define dist_bluez_libs bluez-libs >= 2.0 bluez-libs-devel >= 2.0
%define dist_postgres_libs postgresql-devel
%else
#Defaults for not know distributions
%define dist_usb_libs libusb1-devel
%define dist_dbi_libs libdbi-devel libdbi-dbd-sqlite sqlite
%define dist_bluez_libs bluez-libs >= 2.0 bluez-libs-devel >= 2.0
%define dist_postgres_libs postgresql-devel
%endif
%endif
%endif
%if %bluetooth
BuildRequires:  %{dist_bluez_libs}
%endif
%if pqsql
BuildRequires:  %{dist_postgres_libs}
%endif
%if %mysql
BuildRequires:  mysql-devel
%endif
%if %dbi
BuildRequires:  %{dist_dbi_libs}
%endif
BuildRequires:  python-devel
BuildRequires:  libcurl-devel
%if %usb
BuildRequires:  %{dist_usb_libs}
%endif
BuildRequires:  cmake gettext pkgconfig
Source:         http://dl.cihar.com/gammu/releases/gammu-%{version}.tar.%{extension}
Url:            http://cihar.com/gammu/
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Gammu is command line utility and library to work with mobile phones
from many vendors. Support for different models differs, but basic
functions should work with majority of them. Program can work with
contacts, messages (SMS, EMS and MMS), calendar, todos, filesystem,
integrated radio, camera, etc. It also supports daemon mode to send and
receive SMSes.

Currently supported phones include:

* Many Nokia models.
* Alcatel BE5 (501/701), BF5 (715), BH4 (535/735).
* AT capable phones (Siemens, Nokia, Alcatel, IPAQ).
* OBEX and IrMC capable phones (Sony-Ericsson, Motorola).
* Symbian phones through gnapplet.

%package devel
License:        GPLv2
Summary:        Development files for Gammu
%if 0%{?suse_version}
Group:          Development/Libraries
%else
Group:          Development/Libraries
%endif
Requires:       %{name} = %{version}-%{release} pkgconfig

%description devel
Gammu is command line utility and library to work with mobile phones
from many vendors. Support for different models differs, but basic
functions should work with majority of them. Program can work with
contacts, messages (SMS, EMS and MMS), calendar, todos, filesystem,
integrated radio, camera, etc. It also supports daemon mode to send and
receive SMSes.

Currently supported phones include:

* Many Nokia models.
* Alcatel BE5 (501/701), BF5 (715), BH4 (535/735).
* AT capable phones (Siemens, Nokia, Alcatel, IPAQ).
* OBEX and IrMC capable phones (Sony-Ericsson, Motorola).
* Symbian phones through gnapplet.

This package contain files needed for development.

%package -n python-gammu
License:        GPLv2
Summary:        Python module to communicate with mobile phones
%if 0%{?suse_version}
Group:          Development/Languages
%else
Group:          Development/Languages
%endif
Requires:       python
%{?py_requires}
%if %bluetooth
Requires:       python-pybluez
%endif

%description -n python-gammu
This provides gammu module, that can work with any phone Gammu
supports - many Nokias, Siemens, Alcatel, ...

%prep
%setup -q

%build
mkdir build-dir
cd build-dir
cmake ../ \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_PYTHON=/usr/bin/python \
    -DCMAKE_INSTALL_PREFIX=%_prefix \
    -DINSTALL_DOC_DIR=%gammu_docdir \
    -DINSTALL_LIB_DIR=%_lib \
    -DINSTALL_LIBDATA_DIR=%_lib
make %{?_smp_mflags} %{!?_smp_mflags:%{?jobs:-j %jobs}}
# %check
# cd build-dir
# ctest -V

%install
%if 0%{?suse_version} == 0
rm -rf %buildroot
mkdir %buildroot
%endif
make -C build-dir install DESTDIR=%buildroot
%find_lang %{name}
%find_lang libgammu
cat libgammu.lang >> %{name}.lang

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files -f %name.lang
%defattr(-,root,root)
%_bindir/*
%_libdir/*.so.*
%_mandir/man1/*
%_mandir/man5/*
%_mandir/man7/*
%lang(cs) %_mandir/cs
%doc %gammu_docdir
%config /etc/bash_completion.d/gammu

%files devel
%defattr(-,root,root)
%_includedir/%name
%_libdir/pkgconfig/%name.pc
%_libdir/pkgconfig/%name-smsd.pc
%_libdir/*.so

%files -n python-gammu
%defattr(-,root,root)
%doc README.Python python/examples
%python_sitearch/*

%clean
rm -rf %buildroot

%changelog