# -*- Mode: Tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:et:sw=4:ts=4:sts=4
# $Id: Portfile 80792 2011-07-17 14:20:09Z jmr@macports.org $

PortSystem 1.0

name            libgcrypt
version         1.5.0
categories      devel security
# libs are LGPL, executables and docs are GPL
license         {GPL-2+ LGPL-2.1+}
maintainers     sfiera openmaintainer
description     Crypto library
homepage        http://www.gnupg.org/
platforms       darwin

long_description \
    This is a general purpose cryptographic library based \
    on the code from GnuPG. It provides functions for all \
    cryptograhic building blocks: symmetric ciphers (AES, \
    DES, Blowfish, CAST5, Twofish, Arcfour), hash algorithms \
    (MD4, MD5, RIPE-MD160, SHA-1, TIGER-192), MACs (HMAC for \
    all hash algorithms), public key algorithms (RSA, ElGamal, \
    DSA), large integer functions, random numbers and a lot of \
    supporting functions.

master_sites    gnupg
use_bzip2       yes

checksums       sha1    3e776d44375dc1a710560b98ae8437d5da6e32cf \
                rmd160  f01e8198dcc379ff2fa5e8d3ac39e7b32fc41dad

depends_lib     port:libgpg-error

configure.args  --disable-asm

# Build fix for compilers that default to c99 (clang)
configure.cflags-append "-std=gnu89"

if {${configure.compiler} == "clang"} {
	# libgcrypt-1.5.0 does some ugly stuff with thwir udiv_qrnnd macro in mpih-div.c
	# error: invalid use of a cast in a inline asm context requiring an l-value: remove the cast
	configure.cflags-append "-fheinous-gnu-extensions"
}

post-configure {
    if {[variant_isset universal]} {
        system "cd ${worksrcpath} && ed - ${worksrcpath}/config.h < ${filespath}/config.h.ed && touch stamp-h1"
    }
}

use_parallel_build  yes

post-destroot {
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING COPYING.LIB ChangeLog \
        NEWS README THANKS TODO VERSION ${destroot}${docdir}
}

test.run        yes
test.target     check

livecheck.type  regex
livecheck.url   ftp://ftp.gnupg.org/gcrypt/${name}/
livecheck.regex ${name}-(\\d+\\.\\d+\\.\\d+)
