%global debug_package %{nil}

# Versions numbers
%global major        1
%global minor        5
%global patch        0
%global fullversion  %{major}.%{minor}.%{patch}

# GitHub properties
%global githubname   intel-ipsec-mb
%global githubver    %{major}.%{minor}
%global githubfull   %{githubname}-%{githubver}

Summary:            IPSEC cryptography library optimized for Intel Architecture
Name:               %{githubname}
Release:            1
Version:            %{fullversion}
License:            BSD

ExclusiveArch:      x86_64

URL:                https://github.com/intel/%{githubname}
Source0:            %{githubfull}.tar.gz
BuildRequires:      make
BuildRequires:      gcc >= 4.8.3
BuildRequires:      nasm >= 2.14

%description
IPSEC cryptography library optimized for Intel Architecture

%package devel
Summary:            IPSEC cryptography library optimized for Intel Architecture
License:            BSD
Requires:           %{name} = %{version}-%{release}
Group:              Development/Tools
ExclusiveArch:      x86_64

%description devel
IPSEC cryptography library optimized for Intel Architecture

%package doc
Summary:            Documentation files for %{name}
Requires:           %{name} = %{version}-%{release}
BuildArch:          noarch

%description doc
The %{name}-doc package contains documentation files for %{name}

%prep
%autosetup -n %{githubfull}

%build
cd lib
make EXTRA_CFLAGS='%{optflags}' %{?_smp_mflags}

%install
install -d %{buildroot}/%{_includedir}
install -m 0644 %{_builddir}/%{githubfull}/lib/intel-ipsec-mb.h %{buildroot}/%{_includedir}
install -d %{buildroot}/%{_libdir}
install -s -m 0755 %{_builddir}/%{githubfull}/lib/libIPSec_MB.so.%{fullversion} %{buildroot}/%{_libdir}
install -d %{buildroot}/%{_mandir}/man7
install -m 0444 lib/libipsec-mb.7 %{buildroot}/%{_mandir}/man7
install -m 0444 lib/libipsec-mb-dev.7 %{buildroot}/%{_mandir}/man7
cd %{buildroot}/%{_libdir}
ln -s libIPSec_MB.so.%{fullversion} libIPSec_MB.so.%{major}
ln -s libIPSec_MB.so.%{fullversion} libIPSec_MB.so

%files
%license LICENSE
%{_libdir}/libIPSec_MB.so.%{fullversion}
%{_libdir}/libIPSec_MB.so.%{major}
%{_mandir}/man7/libipsec-mb.7.gz

%files devel
%{_includedir}/intel-ipsec-mb.h
%{_mandir}/man7/libipsec-mb-dev.7.gz
%{_libdir}/libIPSec_MB.so

%files doc
%doc README.md ReleaseNotes.txt

%changelog
* Wed Aug 28 2024 Aichun Shi <aichun.shi@intel.com> 1.5.0-1
- Initial Package
