File libgpiod.spec of Package libgpiod
#global candidate rc3
Name: libgpiod
Version: 2.1.3
Release: 1%{?candidate:.%{candidate}}%{?dist}
Summary: C library and tools for interacting with linux GPIO char device
License: LGPL-2.1-or-later
URL: https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/
Source0: https://mirrors.edge.kernel.org/pub/software/libs/%{name}/%{name}-%{version}%{?candidate:-%{candidate}}.tar.xz
Patch0: libgpiod-older-setuptools.patch
BuildRequires: automake autoconf autoconf-archive libtool
BuildRequires: doxygen
BuildRequires: gcc gcc-c++
BuildRequires: help2man
BuildRequires: kernel-headers
BuildRequires: kmod-devel
BuildRequires: libstdc++-devel
BuildRequires: make
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: systemd-devel
%description
libgpiod is a C library and tools for interacting with the linux GPIO character
device (gpiod stands for GPIO device) The new character device interface
guarantees all allocated resources are freed after closing the device file
descriptor and adds several new features that are not present in the obsolete
sysfs interface (like event polling, setting/reading multiple values at once or
open-source and open-drain GPIOs).
%package utils
Summary: Utilities for GPIO
License: GPL-2.0-or-later
Requires: %{name}%{?_isa} = %{version}-%{release}
%description utils
Utilities for interacting with GPIO character devices.
%package c++
Summary: C++ bindings for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description c++
C++ bindings for use with %{name}.
%package -n python3-%{name}
Summary: Python 3 bindings for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%{?python_provide:%python_provide python3-%{name}}
%description -n python3-%{name}
Python 3 bindings for development with %{name}.
%package devel
Summary: Development package for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: %{name}-c++ = %{version}-%{release}
Requires: python3-%{name} = %{version}-%{release}
%description devel
Files for development with %{name}.
%prep
%autosetup -p1
# to prevent setuptools from installing an .egg, we need to pass --root to setup.py install
# see https://github.com/pypa/setuptools/issues/3143
# and https://github.com/pypa/pip/issues/11501
sed -i 's/--prefix=$(DESTDIR)$(prefix)/--root=$(DESTDIR) --prefix=$(prefix)/' bindings/python/Makefile*
%build
autoreconf -vif
%configure --enable-tools=yes --disable-static \
--enable-bindings-cxx --enable-bindings-python
%make_build
%install
%make_install
#Remove libtool archives.
find %{buildroot} -name '*.la' -delete
%ldconfig_scriptlets
%files
%license COPYING
%doc README
%{_libdir}/%{name}.so.3*
%files utils
%{_bindir}/gpio*
%{_mandir}/man*/gpio*
%files c++
%{_libdir}/libgpiodcxx.so.2*
%files -n python3-%{name}
%{python3_sitearch}/gpiod/
%{python3_sitearch}/gpiod-*.egg-info/
%files devel
%{_includedir}/gpiod.*
%{_includedir}/gpiodcxx/
%{_libdir}/pkgconfig/libgpiod*.pc
%{_libdir}/%{name}*.so