Summary: The Berkeley DB database library for C
Name: lmdbx
Version: 0.8.2
Release: 1%{?dist}
Source0: https://github.com/erthink/libmdbx/releases/download/v%{version}/amalgamated.tar.gz
URL: https://github.com/erthink/libmdbxx
License: The OpenLDAP Public License Version 2.8
BuildRequires: gcc g++

%description
libmdbx is an extremely fast, compact, powerful, embedded,
transactional key-value database, with permissive license.
MDBX has a specific set of properties and capabilities,
focused on creating unique lightweight solutions.

%package utils
Summary: Command line tools for managing Berkeley DB databases
Requires: %{name}%{?_isa} = %{version}-%{release}

%description utils
libmdbx is an extremely fast, compact, powerful, embedded,
transactional key-value database, with permissive license.
MDBX has a specific set of properties and capabilities,
focused on creating unique lightweight solutions.
Provides check, copy, dump, load, stat unitility.

%package devel
Summary: C development files for the LMDBX library
Requires: %{name}%{?_isa} = %{version}-%{release}

%description devel
libmdbx is an extremely fast, compact, powerful, embedded,
transactional key-value database, with permissive license.
MDBX has a specific set of properties and capabilities,
focused on creating unique lightweight solutions.

%prep
%setup -c -n %{name}-%{version}

%build
%make_build

%install
mkdir -p ${RPM_BUILD_ROOT}%{_includedir}
mkdir -p ${RPM_BUILD_ROOT}%{_libdir}
mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
mkdir -p ${RPM_BUILD_ROOT}%{_mandir}/man1

install -m 755 mdbx_load mdbx_stat mdbx_copy mdbx_dump mdbx_chk ${RPM_BUILD_ROOT}%{_bindir}
install -D -p -s -t ${RPM_BUILD_ROOT}%{_libdir} libmdbx.so
install -D -p -m 444 -t ${RPM_BUILD_ROOT}%{_includedir} mdbx.h
install -D -p -m 444 -t ${RPM_BUILD_ROOT}%{_mandir}/man1 man1/mdbx_stat.1 man1/mdbx_copy.1 man1/mdbx_dump.1 man1/mdbx_load.1 man1/mdbx_chk.1
# Create symlinks to includes so that "use <db.h> and link with -ldb" works.
#for i in db.h db_cxx.h db_185.h; do
#	ln -s %{name}/$i ${RPM_BUILD_ROOT}%{_includedir}
#done

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

%files devel
%{_libdir}/libmdbx.so
%{_includedir}/mdbx.h

%files utils
%{_bindir}/mdbx_chk
%{_bindir}/mdbx_copy
%{_bindir}/mdbx_dump
%{_bindir}/mdbx_load
%{_bindir}/mdbx_stat
%{_mandir}/man1/*

%changelog
* Mon Aug 17 2020 Filip Janus <fjanus@redhat.com> - 0.8.2-1
- Initial build