+#
+# WARNING: despite unchanged SONAME, the RSA ABI (and API) has changed since 3.x!
+#
+# Conditional build:
+%bcond_without java # build with Java support
+%bcond_with javac # use javac instead of gcj
+%bcond_without python # don't build python module
+%bcond_without doc # don't build documentation
+#
Summary: The BeeCrypt Cryptography Library
+Summary(pl): Biblioteka kryptograficzna BeeCrypt
Name: beecrypt
-Version: 2.1.0
-Release: 1
+Version: 4.1.2
+Release: 4
+Epoch: 2
License: LGPL
-Group: Development/Libraries
-Group(de): Entwicklung/Libraries
-Group(es): Desarrollo/Bibliotecas
-Group(fr): Development/Librairies
-Group(pl): Programowanie/Biblioteki
-Group(pt_BR): Desenvolvimento/Bibliotecas
-Group(ru): òÁÚÒÁÂÏÔËÁ/âÉÂÌÉÏÔÅËÉ
-Group(uk): òÏÚÒÏÂËÁ/â¦Â̦ÏÔÅËÉ
-Source0: http://www.virtualunlimited.com/download/%{name}-%{version}.tar.gz
-URL: http://beecrypt.virtualunlimited.com/
-Buildroot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+Group: Libraries
+Source0: http://heanet.dl.sourceforge.net/beecrypt/%{name}-%{version}.tar.gz
+# Source0-md5: 820d26437843ab0a6a8a5151a73a657c
+Patch0: %{name}-opt.patch
+Patch1: %{name}-lib64_fix.patch
+Patch2: %{name}-ac_python.patch
+URL: http://sourceforge.net/projects/beecrypt/
+BuildRequires: autoconf >= 2.50
+BuildRequires: automake
+%if %{with doc}
+BuildRequires: doxygen
+%endif
+%if %{with java} && !%{with javac}
+BuildRequires: gcc-java
+%endif
+%if %{with doc}
+BuildRequires: ghostscript
+BuildRequires: graphviz
+%endif
+%if %{with java} && %{with javac}
+BuildRequires: jdk
+%endif
+BuildRequires: libtool
+%if %{with java} && !%{with javac}
+BuildRequires: libgcj-devel
+%endif
+%if %{with python}
+BuildRequires: python-devel
+BuildRequires: python-modules
+%endif
+BuildRequires: rpmbuild(macros) >= 1.213
+%if %{with doc}
+BuildRequires: tetex-dvips
+BuildRequires: tetex-format-latex
+BuildRequires: tetex-latex-dstroke
+# note: this is incorrect place, it should be somewhere in tetex packages
+BuildRequires: tetex-metafont
+%endif
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%package devel
-Requires: beecrypt = %{version}
-Summary: The BeeCrypt Cryptography Library headers
-Group: Development/Libraries
-Group(de): Entwicklung/Libraries
-Group(es): Desarrollo/Bibliotecas
-Group(fr): Development/Librairies
-Group(pl): Programowanie/Biblioteki
-Group(pt_BR): Desenvolvimento/Bibliotecas
-Group(ru): òÁÚÒÁÂÏÔËÁ/âÉÂÌÉÏÔÅËÉ
-Group(uk): òÏÚÒÏÂËÁ/â¦Â̦ÏÔÅËÉ
+%define _libaltdir /%{_lib}
+
+%define specflags_alpha -mno-explicit-relocs
%description
BeeCrypt is an open source cryptography library that contains highly
%description -l pl
BeeCrypt jest open sourcow± bibliotek±, która zawiera wysoko
zoptymailzowane funkcje w C oraz assemblerze wielu algorytmów
-szyfrowania m.in. : Blowfish, MD5, SHA-1, Diffie-Hellman oraz ElGamal.
+szyfrowania m.in.: Blowfish, MD5, SHA-1, Diffie-Hellman oraz ElGamal.
+
+%package devel
+Summary: The BeeCrypt Cryptography Library - development files
+Summary(pl): Pliki dla programistów u¿ywaj±cych biblioteki BeeCrypt
+Group: Development/Libraries
+Requires: %{name} = %{epoch}:%{version}-%{release}
%description devel
-Biblioteki do pakietu BeeCrypt.
+The BeeCrypt Cryptography Library - development files.
%description devel -l pl
-Biblioteki do pakietu BeeCrypt.
+Biblioteka kryptograficzna BeeCrypt - pliki dla programistów.
+
+%package static
+Summary: The BeeCrypt Cryptography Library - static library
+Summary(pl): Biblioteka statyczna BeeCrypt
+Group: Development/Libraries
+Requires: %{name}-devel = %{epoch}:%{version}-%{release}
+
+%description static
+The BeeCrypt Cryptography Library - static library.
+
+%description static -l pl
+Biblioteka statyczna BeeCrypt.
+
+%package doc
+Summary: Development documentation for BeeCrypt
+Summary(pl): Dokumentacja programisty dla biblioteki BeeCrypt
+Group: Documentation
+
+%description doc
+Development documentation for BeeCrypt.
+
+%description doc -l pl
+Dokumentacja programisty dla biblioteki BeeCrypt.
+
+%package java
+Summary: BeeCrypt Java glue library
+Summary(pl): Biblioteka ³±cz±ca BeeCrypt z Jav±
+Group: Libraries
+Requires: %{name} = %{epoch}:%{version}-%{release}
+
+%description java
+BeeCrypt Java glue library.
+
+%description java -l pl
+Biblioteka ³±cz±ca BeeCrypt z Jav±.
+
+%package java-devel
+Summary: Development files for BeeCrypt Java glue library
+Summary(pl): Pliki programistyczne biblioteki ³±cz±cej Beecrypt z Jav±
+Group: Development/Libraries
+Requires: %{name}-devel = %{epoch}:%{version}-%{release}
+Requires: %{name}-java = %{epoch}:%{version}-%{release}
+
+%description java-devel
+Development files for BeeCrypt Java glue library.
+
+%description java-devel -l pl
+Pliki programistyczne biblioteki ³±cz±cej Beecrypt z Jav±.
+
+%package java-static
+Summary: BeeCrypt Java glue static library
+Summary(pl): Statyczna biblioteka ³±cz±ca BeeCrypt z Jav±
+Group: Development/Libraries
+Requires: %{name}-java-devel = %{epoch}:%{version}-%{release}
+
+%description java-static
+BeeCrypt Java glue static library.
+
+%description java-static -l pl
+Statyczna biblioteka ³±cz±ca BeeCrypt z Jav±.
+
+%package -n python-beecrypt
+Summary: Python interface to BeeCrypt library
+Summary(pl): Pythonowy interfejs do biblioteki BeeCrypt
+Group: Development/Languages/Python
+Requires: %{name} = %{epoch}:%{version}-%{release}
+%pyrequires_eq python-libs
+
+%description -n python-beecrypt
+The python-beecrypt package contains a module which permits applications
+written in the Python programming language to use the interface
+supplied by BeeCrypt libraries.
+
+%description -n python-beecrypt -l pl
+Pakiet python-beecrypt zawiera modu³, który pozwala aplikacjom napisanym w
+Pythonie na u¿ywanie interfejsu dostarczanego przez bibliotekê BeeCrytp.
%prep
%setup -q
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
+
+# --with-cplusplus or building (even empty) *.cxx into libbeecrypt
+# makes it (and thus rpm) depending on libstdc++ which is unacceptable
+%{__perl} -pi -e 's/ cppglue\.cxx$//' Makefile.am
+# only html docs
+%{__perl} -pi -e 's/^GENERATE_LATEX .*/GENERATE_LATEX = NO/' Doxyfile.in
%build
-./configure --prefix=%{buildroot}%{_prefix} --target=%{_target}
-%{__make}
+%{__libtoolize}
+%{__aclocal}
+%{__autoconf}
+%{__autoheader}
+%{__automake}
+%configure \
+ %{?with_javac:ac_cv_have_gcj=no} \
+ --without-cplusplus \
+ --with%{!?with_java:out}-javaglue \
+ --with-cpu=%{_target_cpu} \
+%ifarch %{x8664}
+ --with-arch=x86_64 \
+%else
+ --with-arch=%{_target_cpu} \
+%endif
+ --with-pic \
+ --with%{!?with_python:out}-python
+
+%{__make} \
+ libaltdir=%{_libaltdir}
+
+%if %{with python}
+%{__make} -C python
+%endif
+
+%if %{with doc}
+doxygen
+%endif
%install
rm -rf $RPM_BUILD_ROOT
-%{__make} install
+install -d $RPM_BUILD_ROOT%{_libdir}
+
+%{__make} install \
+ DESTDIR=$RPM_BUILD_ROOT \
+ libaltdir=%{_libaltdir}
+
+%if %{with python}
+%{__make} install -C python \
+ DESTDIR=$RPM_BUILD_ROOT
+%endif
+
+rm -f $RPM_BUILD_ROOT%{_libexecdir}/lib*.so
+
+ln -sf %{_libaltdir}/$(cd $RPM_BUILD_ROOT%{_libaltdir} ; echo libbeecrypt.so.*.*.*) \
+ $RPM_BUILD_ROOT%{_libdir}/libbeecrypt.so
+%{__sed} "s|libdir='%{_libaltdir}'|libdir='%{_libdir}'|" \
+ $RPM_BUILD_ROOT%{_libaltdir}/libbeecrypt.la > $RPM_BUILD_ROOT%{_libdir}/libbeecrypt.la
+mv $RPM_BUILD_ROOT%{_libaltdir}/libbeecrypt.a $RPM_BUILD_ROOT%{_libdir}/
+
+%if %{with java}
+mv $RPM_BUILD_ROOT%{_libaltdir}/libbeecrypt_java* $RPM_BUILD_ROOT%{_libdir}/
+%{__sed} -i "s|libdir='%{_libaltdir}'|libdir='%{_libdir}'|" \
+ $RPM_BUILD_ROOT%{_libdir}/libbeecrypt_java.la
+%endif
+
+rm -f $RPM_BUILD_ROOT%{py_sitedir}/*.{la,a}
%clean
-make clean
-rm -rf %{buildroot}
+rm -rf $RPM_BUILD_ROOT
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+%post java -p /sbin/ldconfig
+%postun java -p /sbin/ldconfig
%files
%defattr(644,root,root,755)
+%doc AUTHORS BENCHMARKS BUGS CONTRIBUTORS NEWS README
+%attr(755,root,root) %{_libaltdir}/libbeecrypt.so.*.*.*
+
+%files devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libbeecrypt.so
%{_libdir}/libbeecrypt.la
-%{_libdir}/libbeecrypt.so.2.1.0
+%{_includedir}/beecrypt
-%post
-ln -s /usr/lib/libbeecrypt.so.2.1.0 /usr/lib/libbeecrypt.so
-ln -s /usr/lib/libbeecrypt.so.2.1.0 /usr/lib/libbeecrypt.so.2
+%files static
+%defattr(644,root,root,755)
+%{_libdir}/libbeecrypt.a
-%postun
-rm -f /usr/lib/libbeecrypt.so.2.1.0
-rm -f /usr/lib/libbeecrypt.so.2
-rm -f /usr/lib/libbeecrypt.so
+%if %{with java}
+%files java
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libbeecrypt_java.so.*.*.*
-%files devel
+%files java-devel
+%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libbeecrypt_java.so
+%{_libdir}/libbeecrypt_java.la
+
+%files java-static
+%defattr(644,root,root,755)
+%{_libdir}/libbeecrypt_java.a
+%endif
+
+%if %{with doc}
+%files doc
+%defattr(644,root,root,755)
+%doc docs/html/*
+%endif
+
+%if %{with python}
+%files -n python-beecrypt
%defattr(644,root,root,755)
-%{_includedir}/beecrypt/base64.h
-%{_includedir}/beecrypt/beecrypt.h
-%{_includedir}/beecrypt/blockmode.h
-%{_includedir}/beecrypt/blockpad.h
-%{_includedir}/beecrypt/blowfish.h
-%{_includedir}/beecrypt/blowfishopt.h
-%{_includedir}/beecrypt/dhaes.h
-%{_includedir}/beecrypt/dldp.h
-%{_includedir}/beecrypt/dlkp.h
-%{_includedir}/beecrypt/dlpk.h
-%{_includedir}/beecrypt/dlsvdp-dh.h
-%{_includedir}/beecrypt/elgamal.h
-%{_includedir}/beecrypt/endianness.h
-%{_includedir}/beecrypt/entropy.h
-%{_includedir}/beecrypt/fips180.h
-%{_includedir}/beecrypt/fips180opt.h
-%{_includedir}/beecrypt/fips186.h
-%{_includedir}/beecrypt/hmac.h
-%{_includedir}/beecrypt/hmacmd5.h
-%{_includedir}/beecrypt/hmacsha1.h
-%{_includedir}/beecrypt/hmacsha256.h
-%{_includedir}/beecrypt/md5.h
-%{_includedir}/beecrypt/memchunk.h
-%{_includedir}/beecrypt/mp32.h
-%{_includedir}/beecrypt/mp32opt.h
-%{_includedir}/beecrypt/mp32barrett.h
-%{_includedir}/beecrypt/mp32number.h
-%{_includedir}/beecrypt/mp32prime.h
-%{_includedir}/beecrypt/mtprng.h
-%{_includedir}/beecrypt/rsa.h
-%{_includedir}/beecrypt/rsakp.h
-%{_includedir}/beecrypt/rsapk.h
-%{_includedir}/beecrypt/sha256.h
-%{_includedir}/beecrypt/timestamp.h
+%attr(755,root,root) %{py_sitedir}/*.so
+%endif