# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 97535 2012-09-08 06:00:09Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           conflicts_build 1.0

name                cryptlib
version             3.4.1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          devel security crypto
platforms           darwin sunos
maintainers         nomaintainer
license             {Sleepycat Restrictive}

description         cryptlib is a powerful security toolkit (library)

long_description    cryptlib is a powerful security toolkit that 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 that make the encryption or \
                    authentication work.

homepage            http://www.cs.auckland.ac.nz/~pgut001/cryptlib/
master_sites        ftp://ftp.franken.de/pub/crypt/cryptlib/ \
                    http://www.cypherpunks.to/~peter/
distname            cl[join [split $version .] ""]
use_zip             yes

checksums           rmd160  2272e20697e3e1d8b484ae9d571b08371b1319fb \
                    sha256  d3057acbf4bc7d45694d8ec2621ee4027f9303d36cebdfe2af770567ec912c94

pre-extract {
    # DOS to UNIX line endings.
    extract.pre_args-append -a
}
extract.mkdir       yes

patchfiles          patch-makefile.diff \
                    patch-tools-ccopts.sh.diff

# Build fails when compiler is gcc or llvm-gcc; warnings are printed when compiler is clang.
conflicts_build     unixODBC

use_configure       no

build.target        default shared
build.env           LIBDIR="${prefix}/lib" \
                    CFLAGS="${configure.cflags} ${configure.cc_archflags}" \
                    LDFLAGS="${configure.ldflags} ${configure.ld_archflags}" \
                    CC="${configure.cc}"

destroot {
    xinstall -m 644 ${worksrcpath}/libcl.a ${worksrcpath}/${cryptlibDylib} ${destroot}${prefix}/lib
    ln -s ${cryptlibDylib} ${destroot}${prefix}/lib/${cryptlibDylibLink}
    xinstall -m 644 ${worksrcpath}/cryptlib.h ${destroot}${prefix}/include
    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/README ${destroot}${prefix}/share/doc/${name}
}

platform darwin {
    patchfiles-append       patch-crypt_osconfig.h
    global cryptlibDylib cryptlibDylibLink
    set cryptlibDylib       libcl.${branch}.dylib
    set cryptlibDylibLink   libcl.dylib
}

platform sunos {
    patchfiles-append       patch-makefile.sunos
    global cryptlibDylib cryptlibDylibLink
    set cryptlibDylib       libcl.so.${branch}
    set cryptlibDylibLink   libcl.so
}

livecheck.type      regex
livecheck.url       ${homepage}download.html
livecheck.regex     ${name} (\[0-9.\]+)
