# $Id: Portfile 50449 2009-05-01 03:37:38Z devans@macports.org $

PortSystem          1.0

name                gpgme
version             1.1.8
categories          devel security crypto
maintainers         boeyms openmaintainer
description         A library for easy acces to GnuPG.
long_description \
    GnuPG Made Easy (GPGME) is a library designed to make access \
    to GnuPG easier for applications. It provides a High-Level \
    Crypto API for encryption, decryption, signing, signature \
    verification and key management. Currently it uses GnuPG \
    as its backend but the API isn't restricted to this engine \
    in fact we have already developed a backend for CMS (S/MIME).

platforms           darwin

homepage            http://www.gnupg.org/related_software/gpgme/
master_sites        gnupg
use_bzip2           yes

checksums           md5     39bd929d5f3dc6d3d91cf465ec91b4af \
                    sha1    e56da614f3e6acc1cb51af767c77f4a95b05b1e8 \
                    rmd160  ce6ac04c120a932178ff690c338dbf6b54c93257

patchfiles          patch-assuan_assuan.h.diff

depends_lib         port:gnupg port:pth port:libgpg-error

use_parallel_build  no

post-patch {
    reinplace "s|thread_modules=\"\"|thread_modules=\"pthread\"|" ${worksrcpath}/src/gpgme-config.in
}

configure.args      --with-gpg=${prefix}/bin/gpg --enable-static

post-configure {
    if {[variant_isset universal]} {
        reinplace "s|CC -dynamiclib|CC -dynamiclib ${configure.universal_ldflags}|g" ${worksrcpath}/libtool
    }
}

test.run    yes
test.target check

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING COPYING.LESSER \
        ChangeLog INSTALL NEWS README THANKS TODO \
        ${destroot}${prefix}/share/doc/${name}
}

platform darwin 7 {
    configure.env-append    LIBS="-lpth"
}

# S/MIME needs gpgsm which comes with gnupg2 only; so use all gnupg2 here
variant smime description {Enable S/MIME support} {
    depends_lib-append      port:gnupg2
    depends_lib-delete      port:gnupg
    configure.args-append   --with-gpg=${prefix}/bin/gpg2
}

livecheck.check regex
livecheck.url   ftp://ftp.gnupg.org/gcrypt/gpgme/
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
