File libkolabxml.spec of Package libkolabxml

#
# spec file for package libkolabxml
#
# Copyright (c) 2017 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/
#


%if 0%{?suse_version} < 1220
%define _without_java 1
%endif
%bcond_without java
%bcond_without mono
%bcond_with tests

%global php_extdir %{_libdir}/php5/extensions
%global php_confdir %{_sysconfdir}/php5/conf.d
%define libname %{name}1
Name:           libkolabxml
Version:        1.1.6
Release:        0
Summary:        Kolab XML Format Schema Definitions Library
License:        LGPL-3.0+
Group:          Development/Libraries/C and C++
Url:            https://kolab.org/about/libkolabxml
Source:         http://mirror.kolabsys.com/pub/releases/%{name}-%{version}.tar.gz
# PATCH-FIX-SLE libkolabxml-0.8.3_fix_uuid_includes_SLE.patch -- Fix uuid.h path on SLE 11
Patch0:         libkolabxml-0.8.3_fix_uuid_includes_SLE.patch
# PATCH-FIX-SLE libkolabxml-1.0.1_no-maybe-uninitialized.patch -- Fix php and python bindings on SLE 11
Patch2:         libkolabxml-1.0.1_no-maybe-uninitialized.patch
%if 0%{?suse_version} > 1325
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
%else
BuildRequires:  boost-devel >= 1.4.1
%endif
BuildRequires:  cmake >= 2.6
BuildRequires:  gcc-c++
BuildRequires:  libcurl-devel
BuildRequires:  libxerces-c-devel >= 3.0
BuildRequires:  php-devel >= 5.3
BuildRequires:  pkgconfig
BuildRequires:  python-devel
BuildRequires:  swig >= 2.0
BuildRequires:  xsd >= 3.0
%if 0%{?suse_version} < 1140
BuildRequires:  uuid-devel = 1.6.2
%endif
%if %{with java}
BuildRequires:  gcc-java
BuildRequires:  java-openjdk
%endif
%if %{with mono}
BuildRequires:  mono-devel
%endif
%if %{with tests}
%if 0%{?suse_version} > 1314
BuildRequires:  extra-cmake-modules
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5Test)
%else
BuildRequires:  libqt4-devel
%endif
%endif

BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
Libkolabxml serves as a serialization/de-serialization library for the the Kolab XML Format

Features:
- Based on official standards:
- Todos/Events/Journals are fully xCal compliant
- Contacts/Distributionlists are fully xCard compliant
- Can model everything which is used in the Kolab XML Format 2.0, Kontact and Roundcube.
- Easily extensible
- Canonical storage format
- Supports Todos/Events/Journals/Contacts/Distribution Lists/Notes/Configurations

%package -n %{libname}
Summary:        Kolab XML Format Schema Definitions Library
Group:          System/Libraries

%description -n %{libname}
Libkolabxml serves as a serialization/de-serialization library for the the Kolab XML Format

Features:
- Based on official standards:
- Todos/Events/Journals are fully xCal compliant
- Contacts/Distributionlists are fully xCard compliant
- Can model everything which is used in the Kolab XML Format 2.0, Kontact and Roundcube.
- Easily extensible
- Canonical storage format
- Supports Todos/Events/Journals/Contacts/Distribution Lists/Notes/Configurations

%package devel
Summary:        Kolab XML Format Schema Definitions Library
Group:          Development/Libraries/C and C++
Requires:       %{libname} = %{version}
Requires:       libcurl-devel
%if 0%{?suse_version} > 1325
Requires:       libboost_chrono-devel
Requires:       libboost_date_time-devel
Requires:       libboost_system-devel
Requires:       libboost_thread-devel
%else
Requires:       boost-devel
%endif

%description devel
Libkolabxml serves as a serialization/de-serialization library for the the Kolab XML Format

Features:
- Based on official standards:
- Todos/Events/Journals are fully xCal compliant
- Contacts/Distributionlists are fully xCard compliant
- Can model everything which is used in the Kolab XML Format 2.0, Kontact and Roundcube.
- Easily extensible
- Canonical storage format
- Supports Todos/Events/Journals/Contacts/Distribution Lists/Notes/Configurations

%package -n java-%{libname}
Summary:        Java bindings for %{name}
Group:          Development/Languages/Java
Requires:       %{libname} = %{version}
Provides:       java-kolabformat = %{version}

%description -n java-%{libname}
Libkolabxml serves as a serialization/de-serialization library for the the Kolab XML Format

Features:
- Based on official standards:
- Todos/Events/Journals are fully xCal compliant
- Contacts/Distributionlists are fully xCard compliant
- Can model everything which is used in the Kolab XML Format 2.0, Kontact and Roundcube.
- Easily extensible
- Canonical storage format
- Supports Todos/Events/Journals/Contacts/Distribution Lists/Notes/Configurations

This package provides the java bindings for Libkolabxml

%package -n mono-%{libname}
Summary:        Mono (C#) bindings for %{name}
Group:          Development/Languages/Mono
Requires:       %{libname} = %{version}
Provides:       csharp-kolabformat = %{version}

%description -n mono-%{libname}
Libkolabxml serves as a serialization/de-serialization library for the the Kolab XML Format

Features:
- Based on official standards:
- Todos/Events/Journals are fully xCal compliant
- Contacts/Distributionlists are fully xCard compliant
- Can model everything which is used in the Kolab XML Format 2.0, Kontact and Roundcube.
- Easily extensible
- Canonical storage format
- Supports Todos/Events/Journals/Contacts/Distribution Lists/Notes/Configurations

This package provides the mono (C#) bindings for Libkolabxml

%package -n php-%{libname}
Summary:        PHP bindings for %{name}
Group:          Development/Languages/Other
Requires:       %{libname} = %{version}
Provides:       php-kolabformat = %{version}

%description -n php-%{libname}
Libkolabxml serves as a serialization/de-serialization library for the the Kolab XML Format

Features:
- Based on official standards:
- Todos/Events/Journals are fully xCal compliant
- Contacts/Distributionlists are fully xCard compliant
- Can model everything which is used in the Kolab XML Format 2.0, Kontact and Roundcube.
- Easily extensible
- Canonical storage format
- Supports Todos/Events/Journals/Contacts/Distribution Lists/Notes/Configurations

This package provides the php bindings for Libkolabxml

%package -n python-%{libname}
Summary:        Python bindings for %{name}
Group:          Development/Languages/Python
Requires:       %{libname} = %{version}
Provides:       python-kolabformat = %{version}

%description -n python-%{libname}
Libkolabxml serves as a serialization/de-serialization library for the the Kolab XML Format

Features:
- Based on official standards:
- Todos/Events/Journals are fully xCal compliant
- Contacts/Distributionlists are fully xCard compliant
- Can model everything which is used in the Kolab XML Format 2.0, Kontact and Roundcube.
- Easily extensible
- Canonical storage format
- Supports Todos/Events/Journals/Contacts/Distribution Lists/Notes/Configurations

This package provides the python bindings for Libkolabxml

%prep
%setup -q
%if 0%{?suse_version} < 1140
%patch0
%patch2 -p1
%endif

%build
# cmake: with earlier releases, we have to create and cd manually, as %%cmake is not available
%if 0%{?suse_version} < 1310
%define cmake cmake
mkdir build
cd build
%endif

# libexecdir: SLE11 expands to libdir, but we want /usr/lib/
%if 0%{?suse_version} < 1140
%define _libexecdir %{_prefix}/lib
%endif

# Tests require X server and net
# no-undefined does not work as the php bindings are "magic"
%cmake \
    -DCMAKE_EXE_LINKER_FLAGS=-Wl,--as-needed \
    -DCMAKE_MODULE_LINKER_FLAGS=-Wl,--as-needed \
    -DCMAKE_SHARED_LINKER_FLAGS=-Wl,--as-needed \
%if %{with java}
    -DJAVA_BINDINGS=TRUE -DJAVA_INSTALL_DIR=%{_jnidir} \
%endif
    -DPHP_BINDINGS=TRUE -DPHP_INSTALL_DIR=%{php_extdir}\
    -DPYTHON_BINDINGS=TRUE -DPYTHON_INSTALL_DIR=%{python_sitearch} \
%if %{with mono}
    -DCSHARP_BINDINGS=TRUE -DCSHARP_INSTALL_DIR=%{_libexecdir}/mono/ \
%endif
%if %{with tests}
    -DBUILD_TESTS=TRUE \
%if 0%{?suse_version} > 1314
    -DBUILD_QT5=TRUE \
%endif
%else
    -DBUILD_TESTS=FALSE \
%endif
%if 0%{?suse_version} < 1310
    -DCMAKE_INSTALL_PREFIX="%{_prefix}" \
    -DLIB_INSTALL_DIR=%{_lib} \
    ..
%endif

# parallel build is too unstable currently
#make %{?_smp_mflags}
make -j1

%install
# cmake: with earlier releases, we have to change dir manually, as %%cmake_install is not available
%if 0%{?suse_version} < 1310
cd build/
make DESTDIR=%{buildroot} install
%else
%cmake_install
%endif

mkdir -p %{buildroot}/%{_datadir}/php5
mv %{buildroot}/%{php_extdir}/kolabformat.php %{buildroot}/%{_datadir}/php5/kolabformat.php

mkdir -p %{buildroot}/%{php_confdir}/
cat >%{buildroot}/%{php_confdir}/kolabformat.ini <<EOF
extension=kolabformat.so
EOF

%if %{with tests}
%check
export LD_LIBRARY_PATH=$(pwd)/build/src/
cd build/
ctest -V ||:
python src/python/test.py ||:
%endif

%post   -n %{libname} -p /sbin/ldconfig

%postun -n %{libname} -p /sbin/ldconfig

%files -n %{libname}
%defattr(-,root,root)
%doc AUTHORS COPYING README
%{_libdir}/libkolabxml.so.*

%files -n python-%{libname}
%defattr(-,root,root)
%doc COPYING
%{python_sitearch}/_kolabformat.so
%{python_sitearch}/kolabformat.py*

%files -n php-%{libname}
%defattr(-,root,root)
%doc COPYING
%config(noreplace) %{php_confdir}/kolabformat.ini
%{_datadir}/php5/kolabformat.php
%{php_extdir}/kolabformat.so

%if %{with java}
%files -n java-%{libname}
%defattr(-,root,root)
%doc COPYING
%dir %{_libdir}/java/
%{_libdir}/java/*
%endif

%if %{with mono}
%files -n mono-%{libname}
%defattr(-,root,root)
%doc COPYING
%{_libexecdir}/mono/*
%endif

%files devel
%defattr(-,root,root)
%doc DEVELOPMENT
%dir %{_libdir}/cmake/
%{_libdir}/cmake/Libkolabxml/
%{_libdir}/libkolabxml.so
%{_includedir}/kolabxml/

%changelog