# -*- 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
PortGroup               github 1.0
PortGroup               xcode 1.0
PortGroup               xcodeversion 1.0

github.setup            GPGTools pinentry-mac 0.9.4 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
revision                1
categories              aqua security
license                 GPL-3+
maintainers             nomaintainer
platforms               macosx

description             Cocoa interface for the password entry software pinentry.
long_description        {*}${description} \
                        It is based on the upstream version of pinentry, adding a \
                        custom interface based on Cocoa for OS X look and feel.
homepage                https://github.com/GPGTools/pinentry-mac

checksums               rmd160 b4023708d1320bd1b0ad5ce0dc35ec71fc68b33c \
                        sha256 73e649213e17dd46340f202453ed835166245b63f0cf2a78203d51d620b2742c \
                        size   284942

# Utilizes ARC which is x86_64/arm64-only. #45949
supported_archs         x86_64 arm64
installs_libs           no

patchfiles              patch-includes-quotes.diff \
                        patch-includes-quotes-2.diff \
                        patch-apple-silicon.diff

patch.pre_args-replace  -p0 -p1

# This is a temporary kludge. The new Xcode build system fails to
# destroot this for reasons that are poorly understood.
# Remove this when a better fix is known.
if {[vercmp ${xcodeversion} 10.0] >= 0} {
    destroot.pre_args   -UseNewBuildSystem=NO
}

# xcodeproject has been created with Xcode 5 which is only available on 10.8 and up.
minimum_xcodeversions   {12 5.0}

pre-fetch {
    if {${os.major} < 12} {
        ui_error    "This package is only compatible with Xcode 5 and up.
                     Xcode 5 and up is not compatible with 10.7 and below."
        error       "Unsupported operating system."
    }
}

platform macosx {
    notes   "
             If you previously didn't have pinentry or gpg-agent installed\
             and ${name} has been installed as a dependency of gpg-agent\
             you don't need to do anything to use ${name}.

             If you want to switch to the GTK2, ncurses or Qt4 based pinentry\
             program, please install pinentry with the correct use flags and\
             follow the instructions below substituting the ${name} program\
             path with ${prefix}/bin/pinentry.


             If you previously had pinentry and gpg-agent installed and would\
             like to switch to ${name}, you will have to set\
             it as your pinentry program in \$HOME/.gnupg/gpg-agent.conf.

             Add the following line to the mentioned file:
             pinentry-program ${applications_dir}/${name}.app/Contents/MacOS/${name}


             Be sure to comment previous \"pinentry-program\" lines, for example:

             pinentry-program SAMPLE

             becomes

             #pinentry-program SAMPLE


             Afterwards, run
             killall -HUP gpg-agent

             or simply log out and back in again.
            "
}

xcode.target            ${name}
xcode.configuration     Release
