%bcond_with tests

Name:           libmemcached-awesome
Summary:        Client library and command line tools for memcached server
Version:        1.1.4
Release:        1%{?_dist_release}
Group:          system
Vendor:         Project Vine
Distribution:   Vine Linux

License:        BSD
URL:            https://github.com/awesomized/libmemcached
Source0:        https://github.com/awesomized/libmemcached/archive/refs/tags/%{version}.tar.gz#/libmemcached-%{version}.tar.gz

BuildRequires:  bison
BuildRequires:  cmake
BuildRequires:  cyrus-sasl-devel
BuildRequires:  flex
BuildRequires:  libevent-devel
BuildRequires:  openssl-devel
BuildRequires:  python3-sphinx
%if %{with tests}
BuildRequires:  memcached
%endif
Obsoletes:      libmemcached < 1.0.19
Provides:       libmemcached = %{version}-%{release}
Provides:       libmemcached%{?_isa} = %{version}-%{release}

%description
libmemcached is a C/C++ client library and tools for the memcached server
(http://memcached.org/). It has been designed to be light on memory
usage, and provide full access to server side methods.

It also implements several command line tools:

memcapable  Checking a Memcached server capibilities and compatibility
memcat      Copy the value of a key to standard output
memcp       Copy data to a server
memdump     Dumping your server
memerror    Translate an error code to a string
memexist    Check for the existance of a key
memflush    Flush the contents of your servers
memparse    Parse an option string
memping     Test to see if a server is available.
memrm       Remove a key(s) from the server
memslap     Generate testing loads on a memcached cluster
memstat     Dump the stats of your servers to standard output
memtouch    Touches a key


%package  devel
Summary:  Header files and development libraries for %{name}
Group:    programming
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: pkgconfig
Requires: cyrus-sasl-devel%{?_isa}
Obsoletes:libmemcached-devel < 1.0.19
Provides: libmemcached-devel = %{version}-%{release}
Provides: libmemcached-devel%{?_isa} = %{version}-%{release}

%description devel
This package contains the header files and development libraries
for %{name}. If you like to develop programs using %{name}, 
you will need to install %{name}-devel.


%debug_package


%prep
%setup -q -n libmemcached-%{version}

# drop test hanging in mock
# and requiring some memcached build options
rm test/tests/memcached/sasl.cpp
rm test/tests/memcached/regression/lp_001-630-615.cpp
# temporarily ignore with erratic failure
rm test/tests/memcached/udp.cpp


%build
	
%cmake \
%if %{with tests}
  -DBUILD_TESTING:BOOL=ON \
%endif
  -DBUILD_DOCS_MAN:BOOL=ON \
  -DBUILD_DOCS_MANGZ:BOOL=OFF \
  -DENABLE_SASL:BOOL=ON \
  -DENABLE_DTRACE:BOOL=ON \
  -DENABLE_OPENSSL_CRYPTO:BOOL=ON \
  -DENABLE_HASH_HSIEH:BOOL=ON \
  -DENABLE_HASH_FNV64:BOOL=ON \
  -DENABLE_HASH_MURMUR:BOOL=ON \
  -DENABLE_MEMASLAP:BOOL=ON

%cmake_build


%install
%cmake_install
mv %{buildroot}%{_datadir}/%{name}/example.cnf support
rm -r %{buildroot}%{_datadir}/doc/%{name}/


%if %{with tests}
%check
%ctest
%endif


%clean
rm -rf %{buildroot}


%files
%license LICENSE
%doc AUTHORS *.md
%{_bindir}/mem*
%{_libdir}/lib*.so.*
%{_mandir}/man1/mem*
%exclude %{_libdir}/libp9y.a

%files devel
%doc example
%doc support/example.cnf
%{_datadir}/aclocal/ax_libmemcached.m4
%{_includedir}/*
%{_libdir}/lib*.so
%dir %{_libdir}/pkgconfig
%{_libdir}/pkgconfig/libmemcached.pc
%dir %{_libdir}/cmake
%{_libdir}/cmake/%{name}
%exclude %{_libdir}/cmake/%{name}/p9y*
%{_mandir}/man3/libmemcached*
%{_mandir}/man3/libhashkit*
%{_mandir}/man3/memcached*
%{_mandir}/man3/hashkit*


%changelog
* Wed Mar 15 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.1.4-1
- new upstream release.

* Sat Dec 04 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.1.1-1
- initial build.
