%global varnishver %(pkg-config --silence-errors --modversion varnishapi || echo 0)

%global varnishname varnish
#global vplus  -plus

Name: vmod-blobdigest
Summary: Varnish module for digests and hmacs with the VCL data type BLOB
Version: 1.1
Release: 1.20191125git83ea688%{?dist}
License: BSD
Group: System Environment/Daemons
URL: https://github.com/varnish/libvmod-blobdigest
Source0: %{url}/archive/lib%{name}-%{version}.tar.gz

# Built a tarball like this
# git clone https://code.uplex.de/uplex-varnish/libvmod-blobdigest.git
# cd libvmod-blobdigest
# git fetch --all --tags --prune
# git checkout 83ea688
# ./autogen.sh && ./configure && make && make dist

Requires: varnish%{?_isa} = %varnishver

BuildRequires: make
BuildRequires: gcc
BuildRequires: pkgconfig
BuildRequires: varnish
BuildRequires: varnish%{?vplus}-devel

%description
Varnish module to access blobdigest servers from VCL

%prep
%autosetup -n lib%{name}-%{version}

%build
export RST2MAN=/bin/true
%configure \
  --docdir=%{?_pkgdocdir}%{!?_pkgdocdir:%{_docdir}/%{name}-%{version}}

# We have to remove rpath - not allowed in Fedora
# (This problem only visible on 64 bit arches)
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g;
        s|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool

make


%check
make check


%install
%make_install
#make install DESTDIR=#{buildroot}
# None of these for fedora/epel
find %{buildroot}/%{_libdir}/ -name '*.la' -exec rm -f {} ';'
find %{buildroot}/%{_libdir}/ -name  '*.a' -exec rm -f {} ';'

# Include this explicitly below
#rm %{buildroot}%{_docdir}/%{name}*/LICENSE
rm %{buildroot}%{_pkgdocdir}/LICENSE


%clean
rm -rf %{buildroot}


%files
%{_libdir}/varnish*/vmods/
%license LICENSE
%doc COPYING README.rst
%{_mandir}/man3/*.3*

%changelog
* Mon Nov 25 2019 Ingvar Hagelund <ingvar@redpill-linpro.com> - 1.1-1
- First rpm cut of vmod-blobdigest