%global 	_version CRYPTOPP_8_2_0
Name:		cryptopp
Version:	8.2.0 
Release:	1
Summary:	Crypto++ Library is a free C++ class library of cryptographic schemes

License:	BSL-1.0

URL:		https://www.cryptopp.com/
Source0:	https://github.com/weidai11/cryptopp/archive/%{_version}.tar.gz

BuildRequires:  gcc make

%description
Crypto++ Library is a free C++ class library of cryptographic schemes.
The Crypto++ library was orginally written by Wei Dai. The library is now maintained by several team members and the community.
Currently the library contains algorithms like AES, RSA, MD5 etc..

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

%description devel
This package contains the header files and libraries for developing with %{name}.

%prep
%autosetup -n %{name}-%{_version}

%build
%make_build

%install
# doc 
mkdir -p %{buildroot}%{_datadir}/%{name}-%{version}/TestData
mkdir -p %{buildroot}%{_datadir}/%{name}-%{version}/TestVectors
cp -a %{_builddir}/%{name}-%{_version}/TestData/*.dat %{buildroot}%{_datadir}/%{name}-%{version}/TestData
cp -a %{_builddir}/%{name}-%{_version}/TestVectors/*.txt %{buildroot}%{_datadir}/%{name}-%{version}/TestVectors

# lib file
mkdir -p %{buildroot}/%{_libdir}
cp -a %{_builddir}/%{name}-%{_version}/libcryptopp.a %{buildroot}%{_libdir}/libcryptopp-%{version}.a

# include file
mkdir -p %{buildroot}/%{_includedir}/%{name}
cp -a %{_builddir}/%{name}-%{_version}/*.h %{buildroot}/%{_includedir}/%{name}

# executable file
mkdir -p %{buildroot}/%{_bindir}
cp -a %{_builddir}/%{name}-%{_version}/cryptest.exe %{buildroot}%{_bindir}

%clean
rm -rf %{buildroot}

%files
%defattr(0644,root,root,0644)
%doc History.txt Install.txt Readme.txt
%license License.txt
%{_datadir}/%{name}-%{version}/TestData/*.dat
%{_datadir}/%{name}-%{version}/TestVectors/*.txt
%attr(0755,root,root) %{_bindir}/cryptest.exe

%files devel
%defattr(0644,root,root,0644)
%{_libdir}/*.a
%{_includedir}/%{name}/*.h

%post devel
ln -s %{_libdir}/libcryptopp-%{version}.a %{_libdir}/libcryptopp.a

%postun devel
if [ -h %{_libdir}/libcryptopp.a ]; then
	rm -f %{_libdir}/libcryptopp.a
fi
if [ -d %{_includedir}/%{name} ]; then
	rm -rf %{_includedir}/%{name}
fi

%postun
if [ -d %{_datadir}/%{name}-%{version} ]; then
	rm -rf %{_datadir}/%{name}-%{version}
fi

%changelog
* Thu Sep 10 2020 <liurenxu@talkweb.com.cn> 
- Package init


