%global pkgvers 0
%global scdate0 20250302
%global schash0 ee8decdfe6da57bbc2a6508b5d443738dafd347a
%global branch0 master
%global source0 https://github.com/trabucayre/openFPGALoader.git

%global sshort0 %{expand:%%{lua:print(('%{schash0}'):sub(1,8))}}

Name:           openfpgaloader
Version:        %(curl -s https://raw.githubusercontent.com/trabucayre/openFPGALoader/%{schash0}/CMakeLists.txt | grep "^project" | cut -d'"' -f2)
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        Universal utility for programming FPGAs

License:        Apache 2.0

URL:            https://trabucayre.github.io/openFPGALoader

BuildRequires:  git make cmake gcc-c++ pkgconfig systemd-devel
BuildRequires:  libftdi-devel zlib-devel hidapi-devel libusbx-devel libgpiod-devel

%global __cmake_in_source_build 1

%description
Universal utility for programming FPGAs. Compatible with
many boards, cables and FPGA from major manufacturers:
Xilinx, Altera/Intel, Lattice, Gowin, Efinix, Anlogic,
Cologne Chip. Works on Linux, Windows and macOS.


%prep
%setup -T -c -n %{name}
git clone --depth 1 -n -b %{branch0} %{source0} .
git fetch --depth 1 origin %{schash0}
git reset --hard %{schash0}
git log --format=fuller


%build
mkdir build
pushd build
%global optflags $(echo "%{optflags} -Wno-error=narrowing")
%cmake .. -Wno-dev \
       -DCMAKE_SKIP_RPATH=ON \
       -DCMAKE_VERBOSE_MAKEFILE=OFF \
       -DCMAKE_BUILD_TYPE=RelWithDebInfo \
       -DENABLE_LIBGPIOD=ON \
       -DENABLE_REMOTEBITBANG=ON
%make_build
popd


%install
pushd build
%make_install
popd


%files
%license LICENSE
%doc README.md
%doc doc
%{_bindir}/*
%{_datadir}/*


%changelog
* Tue Dec 28 2021 Cristian Balint <cristian.balint@gmail.com>
- github upstream releases