%global commit0 2ed74b5ef63dfbad0d9f99c5f227668b45cb8957
%global shortcommit %(c=%{commit0}; echo ${c:0:7})
%global varnishver %(pkg-config --silence-errors --modversion varnishapi || echo 0)

%global varnishname varnish
#global vplus  -plus

Name: vmod-blobsynth
Summary: Varnish module to use blobs for synthetic responses
Version: 0.2
Release: 0.1.20191126git%{shortcommit}%{?dist}
License: BSD
Group: System Environment/Daemons
URL: https://code.uplex.de/uplex-varnish/libvmod-blobsynth
Source0: %{name}-%{version}.tar.gz

# Built a tarball like this
# git clone https://code.uplex.de/uplex-varnish/libvmod-blobsynth.git
# cd libvmod-blobsynth
# git fetch --all --tags --prune
# git checkout 2ed74b5 # at branch 6.0 HEAD when writing this
# sed -i 's/0\.1/0.2/' configure.ac
# sed -i 's/^\(dist_doc_DATA.*\)/\1 CHANGES.rst/' Makefile.am
# ./autogen.sh && ./configure && make && make dist

Requires: varnish%{?_isa} = %varnishver

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

%description
Trivial vmod to use blobs for synthetic responses, intended only as a
transitional solution until support for generating synthetic responses
is generalised in Varnish Cache.

%prep
%setup -q

%build
%configure --with-rst2man=: \
  --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}%{_pkgdocdir}/LICENSE


%clean
rm -rf %{buildroot}


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

%changelog
* Tue Nov 26 2019 Ingvar Hagelund <ingvar@redpill-linpro.com> - 0.2-0.1.20191126git2ed74b5
- First rpm cut of vmod-blobsynth