File gammu.spec of Package gammu

#
# spec file for package gammu
#
# Copyright (c) 2015 SUSE LINUX 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/
#


%define so_ver 7

Name:           gammu
Version:        1.36.5
Release:        0
Summary:        Mobile phone management utility
License:        GPL-2.0
Group:          Productivity/Telephony/Utilities
Url:            http://wammu.eu/gammu/
Source0:        http://dl.cihar.com/gammu/releases/%{name}-%{version}.tar.xz
# PATCH-FIX-OPENSUSE gammu-remove-gplv3-files.patch idoenmez@suse.de -- Remove GPLv3 files bnc#775397
Patch1:         gammu-remove-gplv3-files.patch
# Docdir
%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
# Detect build requires
# SUSE
%if 0%{?suse_version}
%define dist_usb_libs libusb-1_0-devel
%define dist_dbi_libs libdbi-devel libdbi-drivers-dbd-sqlite3 sqlite3
%define dist_bluez_libs bluez-devel
%define dist_postgres_libs postgresql-devel
%else
# Mandriva
%if 0%{?mandriva_version}
# 64-bit Mandriva has 64 in package name
%ifarch x86_64
%define mandriva_hack 64
%endif
%if 0%{?mandriva_version} > 200910
%define dist_usb_libs lib%{?mandriva_hack}usb1.0-devel
%else
%define dist_usb_libs lib%{?mandriva_hack}usb-devel
%endif
%if 0%{?mandriva_version} > 2010
%define dist_dbi_libs lib%{?mandriva_hack}dbi-devel libdbi-drivers-dbd-sqlite3 sqlite3-tools
%endif
%define dist_bluez_libs lib%{?mandriva_hack}bluez-devel
# 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-devel >= 2.0
%define dist_postgres_libs postgresql-devel
%else
# Defaults for not known distributions
%define dist_usb_libs libusb1-devel
%define dist_dbi_libs libdbi-devel libdbi-dbd-sqlite sqlite
%define dist_bluez_libs bluez-libs-devel >= 2.0
%define dist_postgres_libs postgresql-devel
%endif
%endif
%endif
BuildRequires:  cmake >= 2.8
BuildRequires:  doxygen
BuildRequires:  gettext
BuildRequires:  glib2-devel
%if 0%{?suse_version} > 1210
BuildRequires:  gnu-free-fonts
%else
%if 0%{?suse_version} == 1210
BuildRequires:  freefont
%endif
%endif
%if 0%{?suse_version} > 1140
BuildRequires:  graphviz
BuildRequires:  graphviz-gd
%endif
%if 0%{?centos_version} || 0%{?rhel_version} || 0%{?rhel}
BuildRequires:  curl-devel
%else
BuildRequires:  libcurl-devel
%endif
%if 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} || 0%{?fedora} || 0%{?rhel}
BuildRequires:  libgudev1-devel
%else
%if 0%{?mandriva_version}
%ifarch x86_64
%define mandriva_hack 64
%endif
BuildRequires:  lib%{?mandriva_hack}gudev1.0-devel
%else
%if 0%{?suse_version} > 1110
BuildRequires:  libgudev-1_0-devel
%endif
%endif
%endif
BuildRequires:  mysql-devel
%if 0%{?suse_version}
BuildRequires:  pkg-config
%else
BuildRequires:  pkgconfig
%endif
BuildRequires:  %{dist_bluez_libs}
%if 0%{?suse_version} > 1140
BuildRequires:  python-Sphinx
BuildRequires:  python-sphinxcontrib-breathe
%endif
BuildRequires:  unixODBC-devel
%if 0%{?suse_version} && 0%{?suse_version} <= 1210
BuildRequires:  xz
%endif
%if 0%{?suse_version} > 1130 || 0%{?mandriva_version} > 2010 || 0%{?fedora_version} || 0%{?centos_version} || 0%{?rhel_version} || 0%{?fedora} || 0%{?rhel}
BuildRequires:  %{dist_dbi_libs}
%endif
BuildRequires:  %{dist_postgres_libs}
BuildRequires:  %{dist_usb_libs}
Requires:       bluez
Requires:       dialog
Recommends:     gammu-doc
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.

This package contains Gammu binary as well as some examples.

%package devel
Summary:        Development files for Gammu
Group:          Development/Libraries/C and C++
Requires:       libGammu%{so_ver} = %{version}
Requires:       libgsmsd%{so_ver} = %{version}
%if 0%{?suse_version}
Requires:       pkg-config
%else
Requires:       pkgconfig
%endif

%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.

%if 0%{?suse_version} > 1140
%package doc
Summary:        Documentation of Gammu
Group:          Documentation/HTML
BuildArch:      noarch

%description doc
This package contains the manual for gammu.
%endif

%package smsd
Summary:        SMS message daemon
Group:          Hardware/Mobile

%description smsd
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 contains the Gammu SMS Daemon and tool to inject messages
into the queue.

%package -n libGammu%{so_ver}
Summary:        Mobile phone management library
Group:          System/Libraries

%description -n libGammu%{so_ver}
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 contains the Gammu shared library.

%package -n libgsmsd%{so_ver}
Summary:        SMS daemon helper library
Group:          System/Libraries

%description -n libgsmsd%{so_ver}
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 contains the Gammu SMS daemon shared library.

%prep
%setup -q
%patch1 -p1

# Change permissions - Fix rpmlint warning "doc-file-dependency"
chmod 644 contrib/init/gammu-smsd.lsb

# GPL-3.0 licensed files, bnc#775397
rm -rf contrib/sms-gammu2android
rm -rf contrib/smscgi
rm -rf helper/win32-*

%build
mkdir build
cd build
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags}"
cmake ../ \
    -DBUILD_SHARED_LIBS=ON \
    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
    -DINSTALL_DOC_DIR=%{gammu_docdir} \
    -DINSTALL_LIB_DIR=%{_lib} \
    -DINSTALL_LIBDATA_DIR=%{_lib} \
    -DINSTALL_LSB_INIT=OFF \
    -DINSTALL_UDEV_RULES=OFF
make %{?_smp_mflags} VERBOSE=1
%if 0%{?suse_version} > 1140
make manual-html
%endif
cd ..

%check
cd build
ctest -V
cd ..

%install
make -C build install DESTDIR=%{buildroot}

# Install config file
install -pm 0644 docs/config/smsdrc %{buildroot}%{_sysconfdir}/gammu-smsdrc

# Install additional doc files
install -pm 0644 AUTHORS README.cs README.da README.de README.en_GB README.es README.id README.pl README.pt_BR %{buildroot}%{gammu_docdir}/
cp -a contrib/udev/ %{buildroot}%{gammu_docdir}/

%if 0%{?suse_version} > 1140
# Install the html manual
rm -rf %{buildroot}%{gammu_docdir}/manual/
rm -rf build/docs/manual/html/{.doctrees/,.buildinfo,_sources/}
cp -a build/docs/manual/html/ %{buildroot}%{gammu_docdir}/manual
%endif

# Remove unneeded locales
%if 0%{?suse_version} && 0%{?suse_version} < 1140
rm -rf %{buildroot}%{_datadir}/locale/sw/
%endif

%find_lang %{name}
%find_lang libgammu

%post -n libGammu%{so_ver} -p /sbin/ldconfig

%postun -n libGammu%{so_ver} -p /sbin/ldconfig

%post -n libgsmsd%{so_ver} -p /sbin/ldconfig

%postun -n libgsmsd%{so_ver} -p /sbin/ldconfig

%files -f %{name}.lang
%defattr(-,root,root,-)
%config %{_sysconfdir}/bash_completion.d/gammu
%{_bindir}/gammu
%{_bindir}/gammu-config
%{_bindir}/gammu-detect
%{_bindir}/jadmaker
%doc %{gammu_docdir}
%if 0%{?suse_version} > 1140
%exclude %{gammu_docdir}/manual/
%endif
%{_datadir}/gammu/
%doc %{_mandir}/man1/gammu-config.1*
%doc %{_mandir}/man1/gammu-detect.1*
%doc %{_mandir}/man1/gammu.1*
%doc %{_mandir}/man1/jadmaker.1*
%doc %{_mandir}/man5/gammu-backup.5*
%doc %{_mandir}/man5/gammu-smsbackup.5*
%doc %{_mandir}/man5/gammurc.5*

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

%if 0%{?suse_version} > 1140
%files doc
%defattr(-,root,root,-)
%doc %{gammu_docdir}/manual/
%endif

%files smsd
%defattr(-,root,root,-)
%doc contrib/init/gammu-smsd.lsb
%config %{_sysconfdir}/gammu-smsdrc
%{_bindir}/gammu-smsd
%{_bindir}/gammu-smsd-inject
%{_bindir}/gammu-smsd-monitor
%doc %{_mandir}/man1/gammu-smsd-inject.1*
%doc %{_mandir}/man1/gammu-smsd-monitor.1*
%doc %{_mandir}/man1/gammu-smsd.1*
%doc %{_mandir}/man5/gammu-smsdrc.5*
%doc %{_mandir}/man7/gammu-smsd-dbi.7*
%doc %{_mandir}/man7/gammu-smsd-files.7*
%doc %{_mandir}/man7/gammu-smsd-mysql.7*
%doc %{_mandir}/man7/gammu-smsd-null.7*
%doc %{_mandir}/man7/gammu-smsd-odbc.7*
%doc %{_mandir}/man7/gammu-smsd-pgsql.7*
%doc %{_mandir}/man7/gammu-smsd-run.7*
%doc %{_mandir}/man7/gammu-smsd-sql.7*
%doc %{_mandir}/man7/gammu-smsd-tables.7*

%files -n libGammu%{so_ver} -f libgammu.lang
%defattr(-,root,root,-)
%{_libdir}/libGammu.so.%{so_ver}*

%files -n libgsmsd%{so_ver}
%defattr(-,root,root,-)
%{_libdir}/libgsmsd.so.%{so_ver}*

%changelog