%global pkgvers 0
%global lockver 1
%global scdate0 20210320
%global schash0 0a92994d729ff76a58f692d3028ca1b64b145d91
%global branch0 master
%global source0 https://github.com/Maratyszcza/FP16.git

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

Name:           fp16
Version:        0
Release:        %{scdate0}.%{pkgvers}.git%{sshort0}%{?dist}
Summary:        Half-precision floating point conversion
Epoch:          2
License:        BSD

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

BuildRequires:  git cmake gcc-c++ python3-devel psimd-devel

%global debug_package %{nil}
%global __cmake_in_source_build 1

%description
Header-only library for conversion to/from
half-precision floating point formats.

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

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

%package        python3
Summary:        Python files for %{name}
Requires:       %{name}-devel = %{epoch}:%{version}-%{release}

%description    python3
This package contains python 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
# external psimd
sed -i '/TARGET psimd/,/ENDIF/d' CMakeLists.txt
# any cmake
sed -i 's|${CMAKE_VERSION} VERSION_LESS "3.0"|1|' CMakeLists.txt
# shared library
sed -i 's|fp16 STATIC|fp16 SHARED|' CMakeLists.txt

mkdir build
pushd build
%cmake .. -Wno-dev \
       -DCMAKE_SKIP_RPATH=ON \
       -DCMAKE_VERBOSE_MAKEFILE=OFF \
       -DCMAKE_BUILD_TYPE=RelWithDebInfo \
       -DPSIMD_SOURCE_DIR=%{_includedir} \
       -DFP16_BUILD_TESTS=OFF \
       -DFP16_BUILD_BENCHMARKS=OFF
make %{?_smp_mflags}
popd


%install
rm -rf %{buildroot}

pushd build
make install DESTDIR=%{buildroot}
popd

# install libs
mkdir -p %{buildroot}%{_libdir}
install -pm755 build/libfp16.so %{buildroot}%{_libdir}/

mkdir -p %{buildroot}/%{python3_sitelib}/%{name}
for f in `find include/ -type f -name '*.py'`;
do
  cp $f %{buildroot}/%{python3_sitelib}/%{name}/
done

find %{buildroot}%{_includedir} -name "*.py" -type f -prune -exec rm -rf '{}' '+'

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

%files devel
%{_includedir}/*

%files python3
%{python3_sitelib}/*


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