%global _lib_path /usr/lib
%global _include_path /usr/include
%global _bin_path /usr/bin
%global _man1_path /usr/man/man1
%global _man3_path /usr/man/man3
%global _opt_path /opt/pigpio/cgi
%global _doc_path /usr/share/doc/pigpio
%global _service_path /usr/lib/systemd/system
%global debug_package %{nil}

Name:	 pigpio
Version: 1.79
Release: 1
Summary: library for GPIO on RPi
License: Unlicense
URL:	 https://github.com/joan2937/pigpio
Source0: https://github.com/joan2937/pigpio/archive/%{version}/pigpio-%{version}.tar.gz

Patch0000: 09-filelayout.patch
Patch0001: remove-broken-comments-from-top-of-manpa.patch
Patch0002: pigpiod-service.patch

BuildRequires: make >= 3.78
BuildRequires: gcc >= 3.4.2
AutoReq: no
AutoProv: yes

Provides: pigpio = %{version}-%{release}

ExclusiveArch: aarch64
ExclusiveOS: Linux

%description
Library for the Raspberry which allows control of the General Purpose Input Outputs (GPIO)

%prep
%setup -q -n %{name}-%{version} -c
mv %{name} %{name}-%{version}

cd %{name}-%{version}
%patch0000 -p1
%patch0001 -p1
%patch0002 -p1

%build
cd %{name}-%{version}
make

%install
mkdir -p %{buildroot}%{_service_path}
mkdir -p %{buildroot}%{_doc_path}
cd %{name}-%{version}
make install DESTDIR=%{buildroot}
install -p -m 644 util/pigpiod.service %{buildroot}%{_service_path}
install -p -m 644 UNLICENCE %{buildroot}%{_doc_path}

%files
%defattr (-, root, root)
%doc
/usr/lib/*
/usr/include/*
/usr/bin/*
/usr/lib/systemd/system/*
/usr/man/man1/*
/usr/man/man3/*
/usr/share/doc/pigpio/*

%changelog
* Mon May 17 2021 Yafen Fang<yafen@iscas.ac.cn> - 1.79-1
- init package