Name:           libmcrypt
Version:        2.5.8
Release:       3
License:        LGPLv2+
Summary:        Encryption algorithms library
URL:            http://mcrypt.sourceforge.net/
Source0:        http://downloads.sourceforge.net/mcrypt/libmcrypt-%{version}.tar.gz

# Build against system libtool-ltdl instead of the bundled libltdl.
Patch0:         libmcrypt-2.5.8-nolibltdl.patch
# Fix uninitialized variables in twofish.c.
# Upstream: http://sourceforge.net/tracker/index.php?func=detail&aid=1872801&group_id=87941&atid=584895
Patch1:         libmcrypt-2.5.8-uninitialized.patch
# Add missing argument types to function prototypes in des.c and tripledes.c.
# Upstream: http://sourceforge.net/tracker/index.php?func=detail&aid=1872799&group_id=87941&atid=584895
Patch2:         libmcrypt-2.5.8-prototypes.patch
# C99 compatibility fixes for the configure script.
Patch3:         libmcrypt-configure-c99.patch
# Add return and argument types to fake prototypes in mcrypt_symb.c.
# Submitted upstream: https://sourceforge.net/p/mcrypt/patches/15/
Patch4:         libmcrypt-c99.patch

BuildRequires:  gcc-c++
BuildRequires:  libtool-ltdl-devel
BuildRequires:  make

%description
Libmcrypt is a thread-safe library providing a uniform interface
to access several block and stream encryption algorithms.

%package devel
Summary:        Development libraries and headers for libmcrypt
Requires:       %{name} = %{version}-%{release}

%description devel
Development libraries and headers for use in building applications that
use libmcrypt.

%prep
%setup -q
%patch0 -p1
%patch1 -p1 -b .uninitialized
%patch2 -p1 -b .prototypes
%patch3 -p1
%patch4 -p1

%build
%configure
%make_build

%install
%make_install
%delete_la

# Multilib fix: remove build-time libdir from libmcrypt-config
sed -i 's|-L%{_libdir}||g' %{buildroot}%{_bindir}/libmcrypt-config
touch -r NEWS %{buildroot}%{_bindir}/libmcrypt-config

%ldconfig_scriptlets

%files
%doc AUTHORS ChangeLog KNOWN-BUGS README NEWS THANKS TODO
%license COPYING.LIB
%{_libdir}/*.so.*
%{_mandir}/man3/*

%files devel
%doc doc/README.key doc/README.xtea doc/example.c
%{_bindir}/libmcrypt-config
%{_includedir}/mutils/
%{_includedir}/mcrypt.h
%{_libdir}/*.so
%{_datadir}/aclocal/libmcrypt.m4

%changelog
* Tue Sep 01 2026 pengmeng <pengmeng@kylinsec.com.cn> - 2.5.8-3
- Replace LGPL-2-or-later with LGPLv2+

* Thu Jul 23 2026 liweigang <liweiganga@gmail.com> - 2.5.8-2
- cleanup spec

* Tue Jun 27 2023 wangtaozhi <wangtaozhi@kylinsec.com.cn> - 2.5.8-1
- Package init