# $Id: Portfile 86000 2011-10-18 07:05:19Z ryandesign@macports.org $

PortSystem		1.0

name			cryptlib
version             3.4.1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories		devel security crypto
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.

platforms		darwin sunos

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

use_configure	no

pre-configure {
	foreach {badport badfile} "unixODBC ${prefix}/include/sql.h" {
		if {[file exists ${badfile}]} {
			ui_error "${name} cannot be built while ${badport} is active."
			ui_error "Please deactivate ${badport} and try again."
			ui_error "You can reactivate ${badport} again later."
			return -code error "${badport} is installed"
		}
	}
}

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 {
	global cryptlibDylib cryptlibDylibLink
	patchfiles-append	patch-makefile.sunos
	set cryptlibDylib		libcl.so.${branch}
	set cryptlibDylibLink	libcl.so
}

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