File swift-im.spec of Package swift-im

#
# spec file for package swift-im
#
# Copyright (c) 2016 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 _name swift
Name:           swift-im
Version:        3.0
Release:        0
Summary:        XMPP client
License:        GPL-3.0
Group:          Productivity/Networking/Talk/Clients
Url:            http://swift.im/
Source0:        http://swift.im/downloads/releases/%{_name}-%{version}/%{_name}-%{version}.tar.gz
BuildRequires:  avahi-devel
BuildRequires:  boost-devel
BuildRequires:  desktop-file-utils
BuildRequires:  docbook-dtds
BuildRequires:  hicolor-icon-theme
BuildRequires:  libQt5Core-devel
BuildRequires:  libQt5DBus-devel
BuildRequires:  libQt5Gui-devel
BuildRequires:  libQt5Network-devel
BuildRequires:  libQt5WebKit5-devel
BuildRequires:  libQt5WebKitWidgets-devel
BuildRequires:  libQt5Widgets-devel
BuildRequires:  libexpat-devel
BuildRequires:  libidn-devel
BuildRequires:  libopenssl-devel
BuildRequires:  libqt5-linguist-devel
BuildRequires:  libqt5-qtbase-devel
BuildRequires:  libqt5-qtdeclarative-devel
BuildRequires:  libqt5-qtmultimedia-devel
BuildRequires:  libqt5-qttools
BuildRequires:  libqt5-qtx11extras-devel
BuildRequires:  libxslt
BuildRequires:  python-xml
BuildRequires:  scons
BuildRequires:  zlib-devel
BuildRequires:  libminiupnpc-devel

%description
Swift is an easy to setup and use Jabber/XMPP instant messaging chat
application.

# -------------------------------- swiften ---------------------------

%package -n libSwiften3
Summary:        Cross-platform XMPP client/server library
Group:          System/Libraries

%description -n libSwiften3
Swiften is a robust, high-quality, standards-compliant, cross-platform,
and performant C++ library for implementing XMPP applications.

# ------------------------------ swiften-devel -----------------------

%package -n swiften-devel
Summary:        Cross-platform XMPP client/server library (development files)
Group:          Development/Libraries/C and C++
Requires:       libSwiften3 = %{version}

%description -n swiften-devel
Swiften is a robust, high-quality, standards-compliant, cross-platform,
and performant C++ library for implementing XMPP applications.

%prep
%setup -q -n %{_name}-%{version}

# Remove 3rd party libraries
# Following ones are used from distro:
find 3rdParty/Boost/src -delete
find 3rdParty/SCons -delete
find 3rdParty/Expat/src -delete
find 3rdParty/LibIDN -delete
find 3rdParty/Lua -delete
find 3rdParty/ZLib -delete
find 3rdParty/OpenSSL -delete
find 3rdParty/DocBook -delete
# P2P
find 3rdParty/LibMiniUPnPc -delete
find 3rdParty/LibNATPMP -delete
# DNS (they use it on Android)
find 3rdParty/Unbound -delete
find 3rdParty/Ldns -delete
# Windows stuff
find 3rdParty/Snarl -delete
# Only for developers
find 3rdParty/LCov -delete
# Not used by swift yet
find 3rdParty/Breakpad/src -delete
find 3rdParty/SQLite -delete
# They use scons in a way that doesnt allow us to use our CppUnit
# find 3rdParty/CppUnit -delete
# Needed for tests
# find 3rdParty/HippoMocks -delete

echo 'ccflags="%{optflags} -fPIC".split(" ")' >> config.py

%build
scons V=1 Swift Swiften swiften_dll=1 test=none %{?_smp_mflags}

%install SWIFTEN_INSTALLDIR=%{buildroot}%{prefix}
# Drop exec rights. Sent upstream: https://github.com/swift/swift/pull/28
chmod 644 Swiften/Network/UnboundDomainNameResolver.*

scons V=1 swiften_dll=1 SWIFTEN_INSTALLDIR=%{buildroot}%{_prefix} SWIFTEN_LIBDIR=%{buildroot}/%{_libdir} %{buildroot}%{_prefix}
install -p -D -m 755 Swift/QtUI/swift-im \
    %{buildroot}%{_bindir}/swift-im

install -p -m 644 -D Swift/resources/logo/logo-icon-32.xpm \
    %{buildroot}%{_datadir}/pixmaps/%{_name}.xpm
install -p -m 644 -D Swift/resources/logo/logo-icon-128.png \
    %{buildroot}%{_datadir}/icons/hicolor/128x128/apps/%{_name}.png
install -p -m 644 -D Swift/resources/logo/logo-icon-16.png \
    %{buildroot}%{_datadir}/icons/hicolor/16x16/apps/%{_name}.png
install -p -m 644 -D Swift/resources/logo/logo-icon-22.png \
    %{buildroot}%{_datadir}/icons/hicolor/22x22/apps/%{_name}.png
install -p -m 644 -D Swift/resources/logo/logo-icon-24.png \
    %{buildroot}%{_datadir}/icons/hicolor/24x24/apps/%{_name}.png
install -p -m 644 -D Swift/resources/logo/logo-icon-512.png \
    %{buildroot}%{_datadir}/icons/hicolor/512x512/apps/%{_name}.png
install -p -m 644 -D Swift/resources/logo/logo-icon-64.png \
    %{buildroot}%{_datadir}/icons/hicolor/64x64/apps/%{_name}.png

# menu
desktop-file-install \
--dir=%{buildroot}%{_datadir}/applications \
Swift/resources/swift.desktop

%check
LD_LIBRARY_PATH=./Swiften scons V=1 %{?_smp_mflags} test=unit QA

%post
%icon_theme_cache_post

%postun
%icon_theme_cache_postun

%post -n libSwiften3 -p /sbin/ldconfig
%postun -n libSwiften3 -p /sbin/ldconfig

%files
%defattr(-,root,root)
%doc COPYING
%dir %{_datadir}/icons/hicolor/512x512
%dir %{_datadir}/icons/hicolor/512x512/apps

%{_bindir}/swift-im
%{_datadir}/applications/%{_name}.desktop
%{_datadir}/pixmaps/%{_name}.xpm
%{_datadir}/icons/hicolor/*/apps/%{_name}.png

%files -n libSwiften3
%defattr(-,root,root)
%{_prefix}/lib/libSwiften.so.*

%files -n swiften-devel
%defattr(-,root,root)
%{_bindir}/swiften-config
%{_includedir}/Swiften
%{_prefix}/lib/libSwiften.so

%changelog