%define soversion 1
Name:          uadk_engine
Summary:       UADK Accelerator Engine
Version:       1.5.0
Release:       1
License:       Apache-2.0
Source:        %{name}-%{version}.tar.gz
ExclusiveOS:   linux
BuildRoot:     %{_tmppath}/%{name}-%{version}-root
Prefix:        /usr/local/lib/engines-1.1
Conflicts:     %{name} < %{version}-%{release}
Provides:      %{name} = %{version}-%{release}
BuildRequires: libwd >= 2.6.0
BuildRequires: compat-openssl11-libs openssl-devel sed autoconf automake libtool numactl-devel
ExclusiveArch: aarch64

Patch0001:	0001-uadk_provider-add-aead-alg-for-uadk_provider-in-open.patch
Patch0002:	0002-uadk_provider-move-functions-to-uadk_prov_pkey.patch
Patch0003:	0003-uadk_provider-add-query_operation_name-callback-for-.patch
Patch0004:	0004-uadk_provider-support-ec-keymgmt-hardware-accelerati.patch
Patch0005:	0005-uadk_provider-support-ecdh-keyexch-hardware-accelera.patch
Patch0006:	0006-uadk_provider-support-x448-alg.patch
Patch0007:	0007-uadk_engine-Clear-some-compilation-warnings-specific.patch
Patch0008:	0008-uadk_provider_rsa-cleanup-variable-definition-and-re.patch

%description
This package contains the UADK Accelerator Engine.
In this version, uadk_engine.rpm not only supports the engine 1 
function of openssl1.1, but also supports the provider function 
of openssl3.0.

%global debug_package %{nil}
%prep
%autosetup -n %{name}-%{version} -p1

%build
tar -zxvf %{_sourcedir}/openssl.tar.gz
%define pkg_dir %{_builddir}/%{name}-%{version}/openssl%{_libdir}/pkgconfig
%define openssl_dir %{_builddir}/%{name}-%{version}/openssl/usr
echo "prefix=%{openssl_dir}" | cat - %{pkg_dir}/libcrypto.pc > tmp && mv tmp %{pkg_dir}/libcrypto.pc

export PKG_CONFIG_PATH=%{pkg_dir}

autoreconf -i
chmod +x configure
./configure --enable-kae
make

%install
mkdir -p ${RPM_BUILD_ROOT}%{_libdir}/engines-1.1
install -b -m755 src/.libs/uadk_engine.so.%{version} ${RPM_BUILD_ROOT}%{_libdir}/engines-1.1
for lib in $RPM_BUILD_ROOT%{_libdir}/engines-1.1/*.so.%{version} ; do
	ln -s -f `basename ${lib}` $RPM_BUILD_ROOT%{_libdir}/engines-1.1/`basename ${lib} .%{version}`
	ln -s -f `basename ${lib}` $RPM_BUILD_ROOT%{_libdir}/engines-1.1/`basename ${lib} .%{version}`.%{soversion}
done

make clean
unset PKG_CONFIG_PATH
autoreconf -i
./configure --libdir=/usr/lib64/ossl-modules/
make

mkdir -p ${RPM_BUILD_ROOT}%{_libdir}/ossl-modules/
install -b -m755 src/.libs/uadk_provider.so.%{version} ${RPM_BUILD_ROOT}%{_libdir}/ossl-modules/
for lib in $RPM_BUILD_ROOT%{_libdir}/ossl-modules/*.so.%{version} ; do
	ln -s -f `basename ${lib}` $RPM_BUILD_ROOT%{_libdir}/ossl-modules/`basename ${lib} .%{version}`
	ln -s -f `basename ${lib}` $RPM_BUILD_ROOT%{_libdir}/ossl-modules/`basename ${lib} .%{version}`.%{soversion}
done

%clean
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(755,root,root)
%{_libdir}/engines-1.1/*
%{_libdir}/ossl-modules/*

%post
/sbin/ldconfig

%postun
/sbin/ldconfig

%changelog
* Wed Dec 11 2024 JiangShui Yang <yangjiangshui@h-partners.com> 1.5.0-1
 - uadk_engine: adding the uadk_provider library 

* Fri Nov 22 2024 JiangShui Yang <yangjiangshui@h-partners.com> 1.3.0-3
 - Backport uadk engine patch

* Thu Nov 21 2024 JiangShui Yang <yangjiangshui@h-partners.com> 1.3.0-2
 - Backport uadk engine patch

* Mon Jan 22 2024 Zhangfei Gao <zhangfei.gao@linaro.org> 1.3.0-1
- uadk_eingine: update to 1.3.0

* Tue Aug 22 2023 JiangShui Yang <yangjiangshui@h-partners.com> 1.2.0-1
- Backport uadk engine patch form v1.0.1 to 1.2.0

* Mon Mar 20 2023 linwenkai <linwenkai6@hisilicon.com> 1.0.0-10
- Backport uadk engine build patch

* Thu Feb 9 2023 linwenkai <linwenkai6@hisilicon.com> 1.0.0-9
- Fix uadk engine build compatiable problem

* Fri Dec 16 2022 JiangShui Yang <yangjiangshui@h-partners.com> 1.0.0-8
- Backport uadk engine patch for v1.0.1

* Tue Jul 26 2022 Yang Shen <shenyang39@huawei.com> 1.0.0-7
- Backport uadk engine patch from v1.0.0 to v1.0.1

* Mon Mar 21 2022 linwenkai <linwenkai6@hisilicon.com> 1.0.0-6
- Backport uadk engine patch for v1.0.0

* Thu Mar 3 2022 linwenkai <linwenkai6@hisilicon.com> 1.0.0-5
- Backport uadk engine patch for v1.0.0

* Mon Feb 21 2022 linwenkai <linwenkai6@hisilicon.com> 1.0.0-4
- Backport uadk engine patch for v1.0.0

* Wed Jan 12 2022 linwenkai <linwenkai6@hisilicon.com> 1.0.0-3
- Backport uadk engine patch

* Fri Dec 10 2021 linwenkai <linwenkai6@hisilicon.com> 1.0.0-2
- Delete digest duplicate code

* Fri Dec 10 2021 linwenkai <linwenkai6@hisilicon.com> 1.0.0-1
- First Spec Version Include uadk_engine Code
