#   ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
#   File: libaxc.spec
#   Copyright 🄯 2022, 2023, 2025 Van de Bugger.
#   SPDX-License-Identifier: FSFAP
#   ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

%vdb

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

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

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

Patch0:         libaxc-0.3.7-makefile.vdb.patch
Patch1:         libaxc-0.3.7-warnings-in-tests.vdb.patch

BuildRequires:  gcc
BuildRequires:  make
BuildRequires:  pkgconfig(cmocka)
BuildRequires:  pkgconfig(glib-2.0)
BuildRequires:  pkgconfig(libgcrypt)
BuildRequires:  pkgconfig(libsignal-protocol-c)
BuildRequires:  pkgconfig(sqlite3)
BuildRequires:  vdb-rpm-macros

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

%description
%{text -- \
    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} -p1

%build
%make_build PREFIX=%{_prefix} LIBDIR=%{_libdir} INCLUDEDIR=%{_includedir}

%install
%make_install PREFIX=%{_prefix} LIBDIR=%{_libdir} INCLUDEDIR=%{_includedir}

%check
# Some tests fail if make runs them in parallel.
%make_build -j1 test PREFIX=%{_prefix} LIBDIR=%{_libdir} INCLUDEDIR=%{_includedir}

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

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

%changelog

* Sat Mar 22 2025 Van de Bugger - 0.3.7-0.vdb.4
- vdb.lua is in dedicated package.

* Wed Mar  5 2025 Van de Bugger - 0.3.7-0.vdb.3
- Hack with stripping dropped.
- F41 rebuild.

* Wed Jun 28 2023 Van de Bugger - 0.3.7-0.vdb.2
- Makefile heavily patched to fix multiple issues.
- Tests patched to avoid compiler warnings.
- Tests enabled.

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