# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem                  1.0

name                        pinentry
version                     1.2.1
revision                    0
categories                  security
license                     GPL-2+
maintainers                 {ionic @Ionic} openmaintainer
homepage                    https://gnupg.org/software/pinentry/
master_sites                gnupg

description                 Passphrase entry dialog utilizing the Assuan protocol

long_description            This is a collection of simple PIN or passphrase entry \
                            dialogs in a secure manner.

use_bzip2                   yes

checksums                   rmd160  041b14eacdbd72e204603e9f27d9140454f0474d \
                            sha256  457a185e5a85238fb945a955dc6352ab962dc8b48720b62fc9fa48c7540a4067 \
                            size    547698

configure.args              --with-libiconv-prefix=${prefix} \
                            --with-ncurses-include-dir=${prefix}/include/ncurses \
                            --enable-pinentry-curses \
                            --enable-pinentry-emacs \
                            --enable-pinentry-tty \
                            --disable-pinentry-gtk2 \
                            --disable-pinentry-gnome3 \
                            --disable-libsecret \
                            --disable-pinentry-tqt \
                            --disable-pinentry-qt \
                            --disable-pinentry-qt5 \
                            --disable-pinentry-fltk

configure.cflags-append     -DNCURSES_WIDECHAR=1

# Fix picking up the correct assuan version.
# -isystem has the added benefit of moving the include
# directory specified to the end of the include path list.
# This will help the build system respect custom include
# paths correctly (i.e., searching them before the MP include
# directory.)
configure.cppflags-replace  -I${prefix}/include -isystem${prefix}/include

depends_build               port:pkgconfig
depends_lib                 port:libiconv \
                            port:ncurses \
                            port:libassuan \
                            port:libgpg-error

platform darwin 10 {
    # Rosetta misdetects the arch and gives a warning of a mismatch:
    # *** The config script "/opt/local/bin/gpgrt-config --libdir=/opt/local/lib gpg-error" was
    # *** built for powerpc-apple-darwin10 and thus may not match the used host x86_64-apple-darwin10.8.0.
    if {${build_arch} eq "ppc"} {
        configure.args-append --build=powerpc-apple-darwin${os.major}
    }
}

variant gtk2 description {Enable gtk2-based pinentry tool} {
    depends_lib-append      path:lib/pkgconfig/gtk+-2.0.pc:gtk2
    configure.args-delete   --disable-pinentry-gtk2
    configure.args-append   --enable-pinentry-gtk2 \
                            --enable-fallback-curses
}

variant gnome3 description {Enable GNOME3/gtk3-based pinentry tool} {
    depends_lib-append      port:gcr \
                            port:libsecret
    configure.args-delete   --disable-pinentry-gnome3 \
                            --disable-libsecret
    configure.args-append   --enable-pinentry-gnome3 \
                            --enable-fallback-curses \
                            --enable-libsecret
}

#variant tqt conflicts qt5 qt4 description {Enable tqt-based pinentry tool} {
#    PortGroup               tqt 1.0
#    configure.args-delete   --disable-pinentry-tqt
#    configure.args-append   --enable-pinentry-tqt \
#                            --enable-fallback-curses
#}

variant qt4 conflicts qt5 description {Enable qt4-based pinentry tool} {
    PortGroup               qt4 1.0

    configure.args-delete   --disable-pinentry-qt
    configure.args-append   --enable-pinentry-qt \
                            --enable-fallback-curses
}

variant qt5 conflicts qt4 description {Enable qt5-based pinentry tool} {
    PortGroup               qt5 1.0

    # FIXME: why do we have a qt5 PortGroup if it doesn't set PATH correctly?!
    configure.env-append    MOC=${qt_moc_cmd}

    configure.args-delete   --disable-pinentry-qt \
                            --disable-pinentry-qt5
    configure.args-append   --enable-pinentry-qt \
                            --enable-pinentry-qt5 \
                            --enable-fallback-curses
}

variant fltk description {Enable FLTK-based pinentry tool} {
    # fltk-devel is currently unsupported, only version 1.3.x.
    depends_lib-append      port:fltk

    configure.args-replace  --disable-pinentry-fltk \
                            --enable-pinentry-fltk
}

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