# $Id: Portfile 78173 2011-04-27 13:09:51Z ryandesign@macports.org $

PortSystem		1.0

name			cryptlib
version             3.4.0
set branch          [join [lrange [split ${version} .] 0 1] .]
categories		devel security crypto
maintainers		nomaintainer
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           sha1    78f7599971c889a55346ddf858e3ef147a5270f0 \
                    rmd160  d38cf69841942670f84e4c2d64a708f5cb3d4299

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

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.args		LIBDIR="${prefix}/lib" \
                CFLAGS="${configure.cflags} ${configure.cc_archflags} -c -D__UNIX__ -DNDEBUG -I." \
                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
}
