File mingw-pdcom5.spec of Package mingw-pdcom5

#-----------------------------------------------------------------------------
#
# Copyright (C) 2012-2017  Richard Hacker <lerich@gmx.net>
#               2021-2021  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

%{?mingw_package_header}

Name: mingw-%{libname}

# 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:  cmake

BuildRequires:  mingw32-filesystem >= 95
BuildRequires:  mingw32-gcc-c++
BuildRequires:  mingw32-cyrus-sasl-devel
BuildRequires:  mingw32-expat
BuildRequires:  mingw32-python3
BuildRequires:  mingw32-python3-pybind11
BuildRequires:  mingw32-python3-setuptools
%if 0%{?fedora} >= 37
BuildRequires:  mingw32-dlfcn-static
%endif

BuildRequires:  mingw64-filesystem >= 95
BuildRequires:  mingw64-gcc-c++
BuildRequires:  mingw64-cyrus-sasl-devel
BuildRequires:  mingw64-expat
BuildRequires:  mingw64-python3
BuildRequires:  mingw64-python3-setuptools
BuildRequires:  mingw64-python3-pybind11
%if 0%{?fedora} >= 37
BuildRequires:  mingw64-dlfcn-static
%endif

# choice fix for fedora 38
%if 0%{fedora} == 38
BuildRequires:  glibc-langpack-en
%endif

BuildArch: noarch

#-----------------------------------------------------------------------------
# Main Package
#-----------------------------------------------------------------------------


Summary: Process data communication library
Group: EtherLab


%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 mingw32-lib%{libname}
Summary: Process data communication library
Group: EtherLab

%description -n mingw32-lib%{libname}
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 mingw64-lib%{libname}
Summary: Process data communication library
Group: EtherLab

%description -n mingw64-lib%{libname}
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.

#-----------------------------------------------------------------------------
# Python package
#-----------------------------------------------------------------------------

%package -n mingw32-python3-%{libname}
Summary: Process data communication library
Group: EtherLab
Requires: mingw32-lib%{libname} = %{version}
Requires: mingw32-lib%{libname}-sasl = %{version}
Requires: mingw32-python3-numpy

%description -n mingw32-python3-%{libname}
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 mingw64-python3-%{libname}
Summary: Process data communication library
Group: EtherLab
Requires: mingw64-lib%{libname} = %{version}
Requires: mingw64-lib%{libname}-sasl = %{version}
Requires: mingw64-python3-numpy

%description -n mingw64-python3-%{libname}
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 mingw32-lib%{libname}-devel
Summary: Development files for PdCom
Group: Development/Libraries/C and C++
Requires: mingw32-lib%{libname} = %{version}
Requires: mingw32-lib%{libname}-sasl = %{version}

%description -n mingw32-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.

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

%description -n mingw64-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.

%{?mingw_debug_package}

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

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

%build

%define cmake_options -DBUILD_TESTING=0 -DEXAMPLE=0 -DVERSION_HASH=%{version}

mkdir -p build_win32 build_win64
pushd build_win32
%mingw32_cmake %cmake_options -DCMAKE_MODULE_PATH=%{mingw32_datadir}/cmake/CyrusSASL
%mingw32_make %{?_smp_mflags}
cd ../python
%mingw32_py3_build
# save setup.py for later usage, as the library path is changed for 64 bit
mv setup.py setup.py32
popd

pushd build_win64
%mingw64_cmake %cmake_options -DCMAKE_MODULE_PATH=%{mingw64_datadir}/cmake/CyrusSASL
%mingw64_make %{?_smp_mflags}
cd ../python
%mingw64_py3_build
popd


%install

pushd .
%mingw_make install DESTDIR=$RPM_BUILD_ROOT
popd
cd python
%mingw64_py3_install
# restore 32bit setup file
mv setup.py32 setup.py
%mingw32_py3_install



%files -n mingw32-lib%{libname}
%{mingw32_bindir}/libpdcom5.dll

%files -n mingw64-lib%{libname}
%{mingw64_bindir}/libpdcom5.dll

%files -n mingw32-lib%{libname}-devel
%doc AUTHORS COPYING NEWS
%{mingw32_includedir}/%{libname}.h
%{mingw32_includedir}/%{libname}_export.h
%{mingw32_includedir}/%{libname}
%{mingw32_libdir}/cmake/%{libname}
%{mingw32_libdir}/lib%{libname}.dll.a
%{mingw32_libdir}/lib%{libname}-sasl.dll.a
%{mingw32_libdir}/pkgconfig/lib%{libname}.pc

%files -n mingw64-lib%{libname}-devel
%doc AUTHORS COPYING NEWS
%{mingw64_includedir}/%{libname}.h
%{mingw64_includedir}/%{libname}_export.h
%{mingw64_includedir}/%{libname}
%{mingw64_libdir}/cmake/%{libname}
%{mingw64_libdir}/lib%{libname}.dll.a
%{mingw64_libdir}/lib%{libname}-sasl.dll.a
%{mingw64_libdir}/pkgconfig/lib%{libname}.pc

%files -n mingw32-python3-%{libname}
%{mingw32_python3_sitearch}/pdcom5*/

%files -n mingw64-python3-%{libname}
%{mingw64_python3_sitearch}/pdcom5*/

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

%package -n mingw32-lib%{libname}-sasl
Summary: SASL authentication plugin for PdCom
Group: EtherLab

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

%files -n mingw32-lib%{libname}-sasl
%{mingw32_bindir}/lib%{libname}-sasl.dll

%package -n mingw64-lib%{libname}-sasl
Summary: SASL authentication plugin for PdCom
Group: EtherLab

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

%files -n mingw64-lib%{libname}-sasl
%{mingw64_bindir}/lib%{libname}-sasl.dll

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

%changelog
* Wed Sep 14 2022 vh@igh.de
- Adapt to MingGW packaging
* 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