# file: libaxc.spec #

Source1000:     vdb.lua
%include        %{S:1000}

%global         nam     axc
%global         ver     0.3.7
%global         rel     0.vdb.1

Name:           lib%{nam}
Version:        %{ver}
Release:        %{rel}%{?dist}
Summary:        Wrapper for libsignal-protocol-c library

License:        GPLv3
URL:            https://github.com/gkdr/%{nam}
Source0:        https://github.com/gkdr/%{nam}/archive/refs/tags/v%{ver}.tar.gz#/%{nam}-%{ver}.tar.gz

BuildRequires:  gcc
BuildRequires:  make
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(sqlite3)
BuildRequires:  pkgconfig(libsignal-protocol-c)
BuildRequires:  pkgconfig(cmocka)
BuildRequires:  /usr/bin/libgcrypt-config

%package devel
Summary:        Development files for %{name}
Requires:       %{name}%{?_isa} = %{version}-%{release}

%description
Client lib for libsignal-protocol-c, implementing the needed database and
crypto interfaces using SQLite and gcrypt. Initially, the
libsignal-protocol-c project was named libaxolotl, hence the name axc.

Additionally it provides utility functions for common use cases like encrypting
and decrypting, ultimately making direct use of libsignal-protocol-c
unnecessary.

%description devel
Header files, pkgconfig file, and other development files of %{name}.

%prep
%autosetup -n %{nam}-%{ver}

%build
%make_build PREFIX=%{_prefix}

%install
%make_install PREFIX=%{_prefix}
# Makefile installs 64-bit libraries to `lib/` directory. Let's move them to `lib64/`:
if [[ "%{_prefix}/lib" != "%{_libdir}" ]]; then
    %{__mv} "%{buildroot}/%{_prefix}"/lib "%{buildroot}/%{_libdir}"
fi
# If shared library is not executable, building debug info rpm will fail.
%{__chmod} a+x %{buildroot}/%{_libdir}/%{name}.so.%{ver}
# Drop static library:
%{__rm} %{buildroot}/%{_libdir}/*.a

%check
# Some tests fail.
# %make_build PREFIX=%{_prefix} test

%files
            %{_libdir}/%{name}.so.*
%license    LICENSE

%files devel
%dir        %{_includedir}/%{nam}/
            %{_includedir}/%{nam}/*
            %{_libdir}/%{name}.so
            %{_libdir}/pkgconfig/%{name}.pc

%changelog

* Mon Feb 21 2022 Van de Bugger - 0.3.7-0.vdb.1
- Initial release