File inputlirc.spec of Package inputlirc

#
# spec file for package inputlirc
#
# Copyright (c) 2021 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


Name:         inputlirc
Version:      34
Release:      0
Summary:      Zeroconf LIRC daemon using input event devices
License:      GPL-2.0-or-later
Group:        Hardware/Other
URL:          https://github.com/gsliepen/inputlirc
Source0:      %{name}-%{version}.tar.xz
Source1:      %{name}.default
%if 0%{?suse_version} <= 1500 
BuildRequires:  gcc10
BuildRequires:  gcc10-c++
%else
BuildRequires:  gcc-c++
%endif
%{?systemd_requires}

%description
%{name} is a Zeroconf LIRC daemon using input event devices.

%prep
%setup -q -n %{name}-%{version}
sed -r 's/^After=.*/After=systemd-udev-settle.service lircd.service/' -i inputlirc.service
sed -i 's/PREFIX ?= \/usr\/local/PREFIX ?= \/usr/g' Makefile

%build
export CFLAGS="%optflags -flto=auto -fpie"
export CXXFLAGS="%optflags -flto=auto -fpie"
export LDFLAGS="$(CFLAGS) ${LDFLAGS} -pie"
test -x "$(type -p gcc)"   && export CC="$_"
test -x "$(type -p g++)"   && export CXX="$_"
test -x "$(type -p gcc-7)" && export CC="$_"
test -x "$(type -p g++-7)" && export CXX="$_"
test -x "$(type -p gcc-8)" && export CC="$_"
test -x "$(type -p g++-8)" && export CXX="$_"
test -x "$(type -p gcc-9)" && export CC="$_"
test -x "$(type -p g++-9)" && export CXX="$_"
test -x "$(type -p gcc-10)" && export CC="$_"
test -x "$(type -p g++-10)" && export CXX="$_"

%make_build

%install
%make_install
mkdir -p %{buildroot}%{_sysconfdir}/default
install -D -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/default/%{name}
install -d -m 0755 %{buildroot}/%{_sbindir}
ln -s %{_sbindir}/service %{buildroot}/%{_sbindir}/rc%{name}

%pre
%service_add_pre %{name}.service

%post
%service_add_post %{name}.service

%preun
%service_del_preun %{name}.service
%stop_on_removal %{name}.service

%postun
%service_del_postun %{name}.service

%files
%config %{_sysconfdir}/default/%{name}
%{_unitdir}/%{name}.service
%{_sbindir}/inputlircd
%{_sbindir}/rc%{name}
%{_mandir}/man8/inputlircd.8.gz

%changelog
openSUSE Build Service is sponsored by