-%bcond_without tests
+#
+# Conditional build:
+%bcond_without tests # build without tests
+%bcond_without php # PHP bindings
+%bcond_without python # Python bindings
+
+%define php_name php55
Summary: Kolab XML format collection parser library
Name: libkolabxml
-Version: 0.8.1
-Release: 1
-License: LGPLv3+
+Version: 1.1.0
+Release: 8
+License: LGPL v3+
Group: Libraries
-URL: http://www.kolab.org
Source0: http://mirror.kolabsys.com/pub/releases/%{name}-%{version}.tar.gz
+# Source0-md5: a7166537c869ec065613f6b15a3ab86a
+URL: http://www.kolab.org/
BuildRequires: QtCore-devel
BuildRequires: boost-devel
BuildRequires: cmake >= 2.6
BuildRequires: kde4-kdepimlibs-devel
BuildRequires: libstdc++-devel
BuildRequires: libuuid-devel
-BuildRequires: php-devel >= 5.3
-BuildRequires: python-devel
BuildRequires: qt4-build
+BuildRequires: rpmbuild(macros) >= 1.600
BuildRequires: swig
-BuildRequires: swig-php
BuildRequires: xerces-c-devel
BuildRequires: xsd
+%if %{with python}
+BuildRequires: python-devel
+BuildRequires: swig-python
+%endif
+%if %{with php}
+BuildRequires: %{php_name}-cli
+%if %{with tests}
+BuildRequires: %{php_name}-pcre
+%endif
+BuildRequires: %{php_name}-program
+BuildRequires: %{php_name}-devel
+BuildRequires: swig-php
+%endif
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
Requires: kde4-kdepimlibs-devel
Requires: libstdc++-devel
Requires: libuuid-devel
-Requires: php-devel >= 5.3
-Requires: python-devel
Requires: swig
Requires: xerces-c-devel
Requires: xsd
%description devel
Development headers for the Kolab XML libraries.
-%package -n php-kolabformat
+%package -n %{php_name}-kolabformat
Summary: PHP bindings for libkolabxml
-Group: Libraries
+Group: Development/Languages/PHP
Requires: %{name} = %{version}-%{release}
%{?requires_php_extension}
-%description -n php-kolabformat
+%description -n %{php_name}-kolabformat
The PHP kolabformat package offers a comprehensible PHP library using
the bindings provided through libkolabxml.
%build
install -d build
cd build
-%{cmake} -Wno-fatal-errors -Wno-errors \
+%cmake \
+ -Wno-fatal-errors -Wno-errors \
-DCMAKE_SKIP_RPATH=ON \
-DCMAKE_PREFIX_PATH=%{_libdir} \
-DINCLUDE_INSTALL_DIR=%{_includedir}/kolabxml \
- -DPYTHON_INCLUDE_DIRS=%{python_include} \
+ -DLIB_INSTALL_DIR:PATH=%{_libdir} \
+%if %{with php}
+ -DPHP_EXECUTABLE=%{__php} \
-DPHP_BINDINGS=ON \
-DPHP_INSTALL_DIR=%{php_extensiondir} \
+%endif
+%if %{with python}
-DPYTHON_BINDINGS=ON \
+ -DPYTHON_INCLUDE_DIRS=%{python_include} \
-DPYTHON_INSTALL_DIR=%{py_sitedir} \
+%endif
..
%{__make}
cd ..
%if %{with tests}
cd build
# Make sure libkolabxml.so.* is found, otherwise the tests fail
-export LD_LIBRARY_PATH=$( pwd )/src/
+export LD_LIBRARY_PATH=$(pwd)/src
cd tests
-./bindingstest ||:
-./conversiontest ||:
-./parsingtest ||:
+./bindingstest
+./conversiontest
+./parsingtest
+cd ..
+%if %{with php}
+cd src/php
+php -d 'enable_dl=On' '-dextension=../../src/php/kolabformat.so' test.php
+cd ..
+%endif
+%if %{with python}
+cd python
+# FIXME
+%{__python} test.py ||
cd ..
-php -d enable_dl=On -dextension=src/php/kolabformat.so src/php/test.php ||:
-python src/python/test.py ||:
+%endif
%endif
%install
rm -rf $RPM_BUILD_ROOT
-
%{__make} -C build install \
- DESTDIR=$RPM_BUILD_ROOT \
- INSTALL='install -p'
-
-install -d $RPM_BUILD_ROOT/%{_datadir}/php
-mv $RPM_BUILD_ROOT/%{php_extensiondir}/kolabformat.php $RPM_BUILD_ROOT/%{php_data_dir}/kolabformat.php
-
-install -d $RPM_BUILD_ROOT/%{php_sysconfdir}/
-cat >$RPM_BUILD_ROOT/%{php_sysconfdir}/kolabformat.ini <<EOF
+ INSTALL='install -p' \
+ DESTDIR=$RPM_BUILD_ROOT
+
+%if %{with php}
+install -d $RPM_BUILD_ROOT{%{php_sysconfdir}/conf.d,%{php_data_dir}}
+mv $RPM_BUILD_ROOT%{php_extensiondir}/kolabformat.php $RPM_BUILD_ROOT%{php_data_dir}/kolabformat.php
+cat > $RPM_BUILD_ROOT%{php_sysconfdir}/conf.d/kolabformat.ini <<EOF
+; Enable kolabformat extension module
extension=kolabformat.so
EOF
+%endif
+
+%if %{with python}
+%py_ocomp $RPM_BUILD_ROOT%{py_sitedir}
+%py_comp $RPM_BUILD_ROOT%{py_sitedir}
+%py_postclean
+%endif
%clean
rm -rf $RPM_BUILD_ROOT
-%post -p /sbin/ldconfig
-%postun -p /sbin/ldconfig
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
%files
%defattr(644,root,root,755)
%doc DEVELOPMENT NEWS README
%attr(755,root,root) %{_libdir}/libkolabxml.so.*.*
-%attr(755,root,root) %ghost %{_libdir}/libkolabxml.so.0
+%attr(755,root,root) %ghost %{_libdir}/libkolabxml.so.1
%files devel
%defattr(644,root,root,755)
%{_includedir}/kolabxml
-%{_libdir}/*.so
+%{_libdir}/libkolabxml.so
%{_libdir}/cmake/Libkolabxml
-%files -n php-kolabformat
+%if %{with php}
+%files -n %{php_name}-kolabformat
%defattr(644,root,root,755)
-%config(noreplace) %{php_sysconfdir}/kolabformat.ini
+%config(noreplace) %{php_sysconfdir}/conf.d/kolabformat.ini
+%attr(755,root,root) %{php_extensiondir}/kolabformat.so
%{php_data_dir}/kolabformat.php
-%{php_extensiondir}/kolabformat.so
+%endif
+%if %{with python}
%files -n python-kolabformat
%defattr(644,root,root,755)
-%{py_sitedir}/kolabformat.py*
-%{py_sitedir}/_kolabformat.so
+%attr(755,root,root) %{py_sitedir}/_kolabformat.so
+%{py_sitedir}/kolabformat.py[co]
+%endif