File libpdcom5-2.spec of Package PdCom5

#-----------------------------------------------------------------------------
#
# Copyright (C) 2012-2017  Richard Hacker <lerich@gmx.net>
#               2021-2024  Florian Pose <fp@igh.de>
#
# This file is part of the PdCom library.
#
# The PdCom library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
#
# The PdCom library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the PdCom Library. If not, see <http://www.gnu.org/licenses/>.
#
# vim: tw=78
#
#-----------------------------------------------------------------------------

%define libname pdcom5
%define soversion 2

# fedora does not support suses rpm macros, duh. Conditionals everywhere
%if 0%{?suse_version}
Name: python-%{libname}
%else
Name: python3-%{libname}
%endif

# version and release will be replaced by set_version
Version: 0
Release: 0

License: LGPL-3.0+
Vendor: Ingenieurgemeinschaft IgH GmbH
URL: http://etherlab.org/en/pdcom

Source0: %{libname}-%{version}.tar.gz

BuildRequires: gcc-c++ cmake fdupes
BuildRequires: cyrus-sasl-devel gnutls-devel
BuildRequires: doxygen graphviz

%define skip_python2 1

%if 0%{?suse_version}
BuildRequires: libexpat-devel libopenssl-devel
BuildRequires: python-rpm-macros
# beginning with openSUSE Leap 15.6 the PyBind11 package was renamed
%if 0%{?sle_version} >= 150600 && 0%{?is_opensuse}
BuildRequires: python3-pybind11-common-devel
%else
BuildRequires: python-pybind11-common-devel
%endif
%{?sle15allpythons}
BuildRequires: %{python_module setuptools >= 38}
BuildRequires: %{python_module pybind11 >= 2.6.1}
BuildRequires: %{python_module devel}
Requires:      python-numpy
BuildRequires: python3 python3-PyYAML
%else
BuildRequires: expat-devel openssl-devel
BuildRequires: python3
BuildRequires: python3-rpm-macros
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-setuptools >= 42
BuildRequires: python3-numpy
BuildRequires: python3-pybind11 >= 2.6.1
BuildRequires: python3-devel
BuildRequires: python3-pip
BuildRequires: python3-pyyaml
BuildRequires: python3-wheel
# for obs service scm
BuildRequires: glibc-langpack-en
%endif
#-----------------------------------------------------------------------------
# Main Package
#-----------------------------------------------------------------------------

Summary: Process data communication library
Group: EtherLab

%if 0%{?suse_version}
%python_subpackages
%endif

%description
PdCom shall provide a flexible C++/Python API for non-realtime exchange of
process data and is part of the EtherLab project
(http://etherlab.org/en/pdcom). It is designed to be independent of any
communication protocols and channels, and shall be usable under several
operating systems and platforms. I. e. it has been tested successfully under
Linux and Windows.

%package -n lib%{libname}-%{soversion}
Summary: Process data communication library
Group: EtherLab

%description -n lib%{libname}-%{soversion}
PdCom shall provide a flexible C++/Python API for non-realtime exchange of
process data and is part of the EtherLab project
(http://etherlab.org/en/pdcom). It is designed to be independent of any
communication protocols and channels, and shall be usable under several
operating systems and platforms. I. e. it has been tested successfully under
Linux and Windows.

#-----------------------------------------------------------------------------
# Development package
#-----------------------------------------------------------------------------

%package -n lib%{libname}-devel
Summary: Development files for PdCom
Group: Development/Libraries/C and C++
Requires: lib%{libname}-%{soversion} = %{version}
Requires: lib%{libname}-sasl%{soversion} = %{version}
Requires: lib%{libname}-gnutls%{soversion} = %{version}
Requires: cyrus-sasl-devel gnutls-devel

%description -n lib%{libname}-devel
PdCom shall provide a flexible C++/Python API for non-realtime exchange of
process data and is part of the EtherLab project
(http://etherlab.org/en/pdcom). It is designed to be independent of any
communication protocols and channels, and shall be usable under several
operating systems and platforms. I. e. it has been tested successfully under
Linux and Windows.

#-----------------------------------------------------------------------------

%prep
%setup -n %{libname}-%{version}

%build
pushd .
%cmake \
    -DBUILD_TESTING=0 \
    -DEXAMPLE=0 \
    -DSET_PYTHON_RPATH=0 \
    -DVERSION_HASH=%{version} \
    -DUSE_SYMBOL_VERSIONING=1
%cmake_build

popd
cd python

%if 0%{?suse_version}
%python_build
%else
%pyproject_wheel
%endif

%install

pushd .
%cmake_install
popd
cd python
%if 0%{?suse_version}
%python_install
%else
%pyproject_install
%pyproject_save_files pdcom5
%endif

%fdupes -s $RPM_BUILD_ROOT/%{_datadir}/doc/%{libname}

%post -n lib%{libname}-%{soversion} -p /sbin/ldconfig
%postun -n lib%{libname}-%{soversion} -p /sbin/ldconfig

%files -n lib%{libname}-%{soversion}
%defattr(-,root,root)
%{_libdir}/lib%{libname}.so.*

%files -n lib%{libname}-devel
%defattr(-,root,root)
%doc AUTHORS COPYING NEWS
%{_includedir}/*.h
%{_includedir}/%{libname}
%{_libdir}/cmake/%{libname}
%{_libdir}/lib%{libname}*.so
%{_libdir}/pkgconfig/lib%{libname}.pc

# yes, I know. making %files at whole conditional makes Factory complain.
%if ! 0%{?suse_version}
%define python_files -f %{pyproject_files}
%endif
%files %{python_files}
%if 0%{?suse_version}
%{python_sitearch}/%{libname}*
%endif

#-----------------------------------------------------------------------------
# SASL Package
#-----------------------------------------------------------------------------

%package -n lib%{libname}-sasl%{soversion}
Summary: SASL authentication plugin for PdCom
Group: EtherLab
Recommends: cyrus-sasl-plain

%description -n lib%{libname}-sasl%{soversion}
Plugin for managing authentication between PdCom and PdServ.

%post -n lib%{libname}-sasl%{soversion} -p /sbin/ldconfig
%postun -n lib%{libname}-sasl%{soversion} -p /sbin/ldconfig

%files -n lib%{libname}-sasl%{soversion}
%defattr(-,root,root)
%{_libdir}/lib%{libname}-sasl.so.*

#-----------------------------------------------------------------------------
# GnuTls Package
#-----------------------------------------------------------------------------

%package -n lib%{libname}-gnutls%{soversion}
Summary: GnuTls transport encryption plugin for PdCom
Group: EtherLab

%description -n lib%{libname}-gnutls%{soversion}
This plugin implements Transport Layer Security for PdCom.

%post -n lib%{libname}-gnutls%{soversion} -p /sbin/ldconfig
%postun -n lib%{libname}-gnutls%{soversion} -p /sbin/ldconfig

%files -n lib%{libname}-gnutls%{soversion}
%defattr(-,root,root)
%{_libdir}/lib%{libname}-gnutls.so.*

#----------------------------------------------------------------------------
# Development documentation package
#----------------------------------------------------------------------------

%package -n lib%{libname}-doc
Summary:        Documentation for %{name}
Group:          System/Libraries
BuildArch:      noarch

%description -n lib%{libname}-doc
Doxygen-generated API documentation for %{name}

%files -n lib%{libname}-doc
%defattr(-,root,root)
%{_datadir}/doc/%{libname}

#-----------------------------------------------------------------------------

%check
%if 0%{?fedora}
%ifnarch ppc64le
export LD_LIBRARY_PATH=%{buildroot}/%{_libdir}
%pyproject_check_import
%endif
%endif

#-----------------------------------------------------------------------------

%changelog
* Fri Jan 6 2023 vh@igh.de
- Add Fedora Compatibility
* Wed Dec 1 2021 vh@igh.de
- Split out plugins and enable python build
* Tue Nov 2 2021 fp@igh.de
- Updated for PdCom 5
* Wed Jan 8 2014 fp@igh.de
- Updated for use with OBS

#-----------------------------------------------------------------------------
openSUSE Build Service is sponsored by