# file: libomemo.spec #

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

%global         nam     omemo
%global         ver     0.8.0
%global         rel     0.vdb.1

Name:           lib%{nam}
Version:        %{ver}
Release:        %{rel}%{?dist}
Summary:        Implements OMEMO (XEP-0384 v0.3.0) in C

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

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

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

%description
%{text -- \
    Input and output are XML strings, so it does not force you to use a certain XML lib. While the
    actual protocol functions do not depend on any kind of storage, it comes with a basic
    implementation in SQLite.

    It deals with device lists and bundles as well as encrypting the payload, but does not handle
    the double ratchet sessions for encrypting the key to the payload. However, you can use my axc
    lib for that and easily combine it with this one (or write all the libsignal client code
    yourself if that is better suited to your needs).
}

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

%prep
%autosetup

%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
%make_build PREFIX=%{_prefix} test

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

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

%changelog

* Fri Mar 11 2022 Van de Bugger - 0.8.0-0.vdb.1
- Initial release