%global VERSION  @PACKAGE_BASE_VERSION@
%global MAJOR_VERSION  @WIZARD_MAJOR_VERSION@
%global Patchlevel  @WIZARD_PATCHLEVEL_VERSION@

Name:           @PACKAGE_NAME@
Version:        %{VERSION}
Release:        %{Patchlevel}
Summary:        The Wizard's Toolkit includes command line utilities to convert plaintext to ciphertext, convert ciphertext to plaintext, report properties associated with ciphertext, compute the message digest of a file, and read message digests from a file and authenticate them. In addition, the Wizard's Toolkit includes a a cross-platform C API that includes a number of enciphering and hash methods many developers should find useful in their projects.
Group:          Applications/Multimedia
License:        https://urban-warrior.org/WizardsToolkit/script/license.php
Url:            https://urban-warrior.org/WizardsToolkit/
Source0:        https://urban-warrior.org/WizardsToolkit/download/%{name}/%{name}-%{VERSION}-%{Patchlevel}.tar.bz2

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:  bzip2-devel, zlib-devel

%description
The Wizard's Toolkit includes command line utilities to convert plaintext to ciphertext, convert ciphertext to plaintext, report properties associated with ciphertext, compute the message digest of a file, and read message digests from a file and authenticate them. In addition, the Wizard's Toolkit includes a a cross-platform C API that includes a number of enciphering and hash methods many developers should find useful in their projects.

The Wizard's Toolkit is free software delivered as a ready-to-run binary distribution or as source code that you may freely use, copy, modify, and distribute. Its license is compatible with the GPL. It runs on all major operating systems.

Here are just a few examples of what the Wizard's Toolkit command line utilities can do:

    * Encipher plaintext.
    * Decipher ciphertext.
    * Report properties associated with ciphertext.
    * Compute the message digest of a file.
    * Read message digests from a file and verify them.

Here are just a few examples of what the Wizard's Toolkit Application Programming Interface can do:

    * Return files as Binary Large OBjectS
    * Write/read characters, shorts, words, and long words to/from a file
    * Compute a cyclic redunancy checksum
    * Handle C exceptions
    * Generate a secure hash (includes MD5, SHA-1, SHA-224, SHA-256, SHA-384,
    * and SHA-512)
    * Generate a keyed-hash for message authentication
    * Encipher/decipher messages (includes AES, Serpent, and Twofish)
    * Authenticate a user (only secret-key supported at this time)
    * Map content with its associated mime type and file extension
    * Log events to the console or XML-style file
    * Anonymous memory-mapped memory allocation/deallocation
    * Increase entropy with message compression
    * Generate cryptographically-strong random numbers
    * Acquire/relinquish resources
    * Acquire/relinquish semaphores
    * Store/retrieve key-value pairs to/from a hashmap or linked-list
    * Store/retrieve key-value pairs to/from a self-adjusting binary tree
    * Parse or generate a XML document
    * Convenience methods for dealing with strings

%package devel
Summary: Library links and header files for WizardsToolkit application development
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig

%description devel
WizardsToolkit-devel contains the library links and header files you'll
need to develop Wizard's Toolkit applications. 

If you want to create applications that will use WizardsToolkit code or
APIs, you need to install WizardsToolkit-devel as well as WizardsToolkit.
You do not need to install it if you just want to use WizardsToolkit,
however.

%package doc
Summary: WizardsToolkit HTML documentation
Group: Documentation

%description doc
WizardsToolkit documentation, this package contains usage (for the
commandline tools) and API (for the libraries) documentation in HTML format.
Note this documentation can also be found on the WizardsToolkit website:
https://urban-warrior.org/WizardsToolkit/


%prep
%setup -q -n %{name}-%{VERSION}-%{Patchlevel}
sed -i 's/libltdl.la/libltdl.so/g' configure
iconv -f ISO-8859-1 -t UTF-8 README.txt > README.txt.tmp
touch -r README.txt README.txt.tmp
mv README.txt.tmp README.txt

%build
%configure --enable-shared \
           --disable-static \
           --with-threads
# Disable rpath
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
make %{?_smp_mflags}


%install
rm -rf %{buildroot}

make install DESTDIR=%{buildroot} INSTALL="install -p"
cp -a www/source %{buildroot}%{_datadir}/doc/%{name}-%{MAJOR_VERSION}
rm %{buildroot}%{_libdir}/*.la

# fix multilib issues
%ifarch x86_64 s390x ia64 ppc64 alpha sparc64
%define wordsize 64
%else
%define wordsize 32
%endif

mv %{buildroot}%{_includedir}/%{name}-%{MAJOR_VERSION}/wizard/wizard-config.h \
   %{buildroot}%{_includedir}/%{name}-%{MAJOR_VERSION}/wizard/wizard-config-%{wordsize}.h

cat >%{buildroot}%{_includedir}/%{name}-%{MAJOR_VERSION}/wizard/wizard-config.h <<EOF
#ifndef WIZARDSTOOLKIT_MULTILIB
#define WIZARDSTOOLKIT_MULTILIB

#include <bits/wordsize.h>

#if __WORDSIZE == 32
# include "wizard-config-32.h"
#elif __WORDSIZE == 64
# include "wizard-config-64.h"
#else
# error "unexpected value for __WORDSIZE macro"
#endif

#endif
EOF


%clean
rm -rf %{buildroot}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc QuickStart.txt 
%doc README.txt LICENSE NOTICE AUTHORS.txt NEWS.txt
%{_libdir}/libWizardsToolkit.so.*
%{_libdir}/%{name}-%{VERSION}
%{_bindir}/[a-z]*
%{_datadir}/%{name}-%{MAJOR_VERSION}
%{_mandir}/man[145]/[a-zA-Z]*
%{_sysconfdir}/%{name}-%{MAJOR_VERSION}

%files devel
%defattr(-,root,root,-)
%{_bindir}/WizardsToolkit-config
%{_libdir}/libWizardsToolkit.so
%{_libdir}/pkgconfig/WizardsToolkit.pc
%dir %{_includedir}/%{name}-%{MAJOR_VERSION}
%{_includedir}/%{name}-%{MAJOR_VERSION}/wizard
%{_mandir}/man1/WizardsToolkit-config.*

%files doc
%defattr(-,root,root,-)
%doc %{_datadir}/doc/%{name}-%{MAJOR_VERSION}
%doc LICENSE

%changelog
* Sun May 01 2005 Cristy <cristy@mystic.es.dupont.com> 1.0-0
*  Port of Redhat's RPM script to support WizardsToolkit.
