# -*- 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 113019 2013-11-07 01:09:20Z jann@macports.org $

PortSystem      1.0

# When updating gnupg2, update gpg-agent also if applicable.

name            gnupg2
version         2.0.22
categories      mail security
maintainers     nomaintainer
license         GPL-3+
installs_libs   no

description     GNU pretty-good-privacy package
long_description        \
        GnuPG is a complete and free replacement for PGP. Because       \
        it does not use the patented IDEA algorithm, it can be used     \
        without any restrictions. GnuPG is a RFC2440 (OpenPGP)          \
        compliant application.
homepage        http://www.gnupg.org
platforms       darwin freebsd sunos
use_bzip2   yes
distname    gnupg-${version}
master_sites    gnupg:gnupg

use_bzip2       yes

checksums       rmd160  0d47b3218438c9ddf7f91b73f2a46bbefefdb106 \
                sha256  437d0ab259854359fc48aa8795af80cff4975e559c111c92c03d0bc91408e251

# gpg-agent is built separately from the rest of gnupg2 to enable gnupg 1.x
# users to use gpg-agent as well.  gnupg2, however, requires gpg-agent to run,
# and so gnupg2 depends on gpg-agent.

configure.args  --disable-agent

# glib fails to find the right stdint.h  It picks clang's internal one rather
# than the system header
configure.env   gl_cv_absolute_stdint_h=/usr/include/stdint.h

depends_lib     port:libiconv           \
                port:gettext            \
                port:zlib               \
                port:bzip2              \
                port:bison              \
                port:gpg-agent          \
                port:libassuan          \
                port:libksba            \
                port:libgcrypt          \
                port:libgpg-error       \
                port:pth                \
                port:curl               \
                port:libusb-compat

patchfiles      patch-common-homedir.c.diff \
                patch-configure.diff \
                patch-tests__openpgp__Makefile.in.diff

post-patch {
    reinplace "s|@PREFIX@|${prefix}|g" ${worksrcpath}/common/homedir.c
}

post-destroot {
        delete ${destroot}${prefix}/share/man/man1/gpg-zip.1
}

test.run        yes
test.dir        ${worksrcpath}/tests
test.target     check

# See also the post-patch above.
# Apparently we have no way of forcing gnupg2 to build without DirMngr support,
# so we have to just hope we don't run into any problems.
variant dirmngr description {Enable the use of DirMngr by gpgsm} {
        depends_lib-append  port:dirmngr
}

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