##
##  cryptlib.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package version
%define       V_full  3.4.3.1
%define       V_comp  3431
%define       V_track 3431

#   package information
Name:         cryptlib
Summary:      Cryptography Library
URL:          http://www.cs.auckland.ac.nz/~pgut001/cryptlib/
Vendor:       Peter Gutmann
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        Cryptography
License:      MIT-style
Version:      %{V_full}
Release:      20170116

#   list of sources
Source0:      ftp://ftp.franken.de/pub/crypt/cryptlib/cl%{V_comp}.zip
Source1:      ftp://ftp.franken.de/pub/crypt/cryptlib/manual.pdf
Patch0:       cryptlib.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, infozip, make, gcc, perl
PreReq:       OpenPKG, openpkg >= 20160101

%description
    CryptLib is a powerful security toolkit which allows even
    inexperienced crypto programmers to easily add encryption and
    authentication services to their software. The high-level interface
    provides anyone with the ability to add strong security capabilities
    to an application in as little as half an hour, without needing
    to know any of the low-level details which make the encryption
    or authentication work. Because of this, cryptlib dramatically
    reduces the cost involved in adding security to new or existing
    applications. CryptLib provides a standardised interface to a number
    of popular encryption algorithms, as well as providing a high-level
    interface which hides most of the implementation details and
    provides an operating-system-independent encoding method which makes
    it easy to transfer secured data from one operating environment to
    another.

%track
    prog cryptlib = {
        version   = %{V_track}
        url       = ftp://ftp.franken.de/pub/crypt/cryptlib/
        regex     = cl(__VER__)\.zip
        transform = "s/^(\d\d)$/${1}0/, $_"
    }

%prep
    %setup -q -c -T
    %{l_prefix}/bin/unzip -q -x %{SOURCE0}
    %patch -p0
    %{l_prefix}/bin/perl -p -i -e 's;\r$;;m' tools/*.pl tools/*.sh

%build
    %{l_make} %{l_mflags} \
        CC="%{l_cc} %{l_cflags -O}"

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/include \
        $RPM_BUILD_ROOT%{l_prefix}/lib \
        $RPM_BUILD_ROOT%{l_prefix}/share/cryptlib
    %{l_shtool} install -c -m 644 \
        cryptlib.h $RPM_BUILD_ROOT%{l_prefix}/include/
    %{l_shtool} install -c -m 644 \
        libcl.a $RPM_BUILD_ROOT%{l_prefix}/lib/libcryptlib.a
    %{l_shtool} install -c -m 644 \
        %{SOURCE manual.pdf} $RPM_BUILD_ROOT%{l_prefix}/share/cryptlib/
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        '%doc %{l_prefix}/share/cryptlib/manual.pdf'

%files -f files

%clean

