%global pkgvers 0
%global scdate0 20240616
%global schash0 560c60d342a76076f0557a3946924c6478470044
%global branch0 master
%global source0 https://github.com/Maratyszcza/pthreadpool.git

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

Name:           pthreadpool
Version:        0.1
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        Thread pool implementation
License:        BSD
Epoch:          1

URL:            https://github.com/Maratyszcza/pthreadpool

BuildRequires:  cmake gcc-c++ git fxdiv-devel

%global __cmake_in_source_build 1

%description
Portable and efficient thread pool implementation.

%package        devel
Summary:        Development files
Requires:       %{name} = %{epoch}:%{version}-%{release}

%description    devel
This package contains the development files for %{name}.


%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
sed -i 's|ADD_LIBRARY(pthreadpool SHARED ${PTHREADPOOL_SRCS})|ADD_LIBRARY(pthreadpool SHARED ${PTHREADPOOL_SRCS})\nSET_TARGET_PROPERTIES(pthreadpool PROPERTIES SOVERSION 1 VERSION 1.0)|' CMakeLists.txt
# external fxdiv
sed -i '/TARGET fxdiv/,/ENDIF/d' CMakeLists.txt
sed -i '/TARGET_LINK_LIBRARIES(pthreadpool PRIVATE fxdiv)/d' CMakeLists.txt

mkdir build
pushd build
%cmake .. \
       -DCMAKE_SKIP_RPATH=ON \
       -DCMAKE_VERBOSE_MAKEFILE=OFF \
       -DCMAKE_BUILD_TYPE=RelWithDebInfo \
       -DCMAKE_INSTALL_LIBDIR=%{_libdir} \
       -DPTHREADPOOL_LIBRARY_TYPE="shared" \
       -DFXDIV_SOURCE_DIR="%{_incudedir}" \
       -DPTHREADPOOL_BUILD_TESTS=OFF \
       -DPTHREADPOOL_BUILD_BENCHMARKS=OFF
make %{?_smp_mflags}
popd


%install
rm -rf %{buildroot}
pushd build
make install DESTDIR=%{buildroot}
popd


%files
%license LICENSE
%doc README.md
%{_libdir}/*.so.*

%files devel
%license LICENSE
%doc README.md
%{_includedir}/*
%{_libdir}/*.so


%changelog
* Fri Sep 25 2020 Cristian Balint <cristian.balint@gmail.com>
- github update releases