# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>

pkgname=pinentry
pkgver=1.3.3
pkgrel=1
pkgdesc='Collection of simple PIN or passphrase entry dialogs which utilize the Assuan protocol'
url='https://gnupg.org/related_software/pinentry/'
arch=('x86_64')
license=('GPL')
depends=(
  'glibc' 'ncurses' 'libassuan' 'libsecret' 'glib2'
)
makedepends=('qt6-base' 'gtk2-compat' 'gcr' 'kguiaddons' 'kwindowsystem')
optdepends=(
  'gcr: GNOME backend'
  'gtk3: GTK backend'
  'kguiaddons: Qt6 backend'
  'kwindowsystem: Qt6 backend'
)
source=("https://www.gnupg.org/ftp/gcrypt/${pkgname}/${pkgname}-${pkgver}.tar.bz2"{,.sig}
        'pinentry')
sha256sums=('c2970f16d6afb66ecddfca767d743936c86239bff936eed7fd7597a678414b63'
            'SKIP'
            'b902d07c061e0cf6d661014516172f7a35f477362edb779f863935733d1c4dde')
validpgpkeys=(
  'D8692123C4065DEA5E0F3AB5249B39D24F25E3B6' # Werner Koch (dist sig)
  '6DAA6E64A76D2840571B4902528897B826403ADA' # Werner Koch (dist signing 2020)
  'AC8E115BF73E2D8D47FA9908E98E9B2D19C6C8BD' # Niibe Yutaka (GnuPG Release Key)
)

build() {
  cd "${pkgname}-${pkgver}"
  CXXFLAGS="-std=c++17" ./configure \
    --prefix=/usr \
    --enable-pinentry-tty \
    --enable-pinentry-curses \
    --enable-fallback-curses \
    --enable-pinentry-emacs \
    --enable-pinentry-gnome3 \
    --enable-pinentry-qt \
    --enable-libsecret

  make
}

package() {
  depends+=(
    libglib-2.0.so
    libncursesw.so
    libsecret-1.so
  )

  cd "${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install
  install -Dm 755 ../pinentry -t "${pkgdir}/usr/bin"

  # The -gtk backend has been built to be used with GTK3.
  mv "${pkgdir}/usr/bin/pinentry-gtk"{-2,}
}

# vim: ts=2 sw=2 et:
