# Description: KeePass Cross-Platform Community Edition
# URL: https://keepassxc.org/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: argon2 botan libgcrypt minizip pcsclite qrencode qt5 yubikey-personalization
# Optional: asciidoctor xorg-libxtst

name=keepassxc
version=2.7.5
release=1
source=(https://github.com/keepassxreboot/keepassxc/releases/download/$version/$name-$version-src.tar.xz)

build() {
  prt-get isinst ccache && PATH="$(echo ${PATH} | awk -v RS=: -v ORS=: '/ccache/ {next} {print}' | sed 's/:*$//')"
  prt-get isinst ccache && PKGMK_KEEPASSXC+=' -D WITH_CCACHE=ON'

  prt-get isinst asciidoctor && PKGMK_KEEPASSXC+=' -D WITH_XC_DOCS=ON' || PKGMK_KEEPASSXC+=' -D WITH_XC_DOCS=OFF'
  prt-get isinst xorg-libxtst || PKGMK_KEEPASSXC+=' -D WITH_XC_X11=OFF'

  cmake -S $name-$version -B build -G Ninja $PKGMK_KEEPASSXC \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D CMAKE_INSTALL_LIBDIR=lib \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
    -D CMAKE_C_FLAGS_RELEASE="$CFLAGS" \
    -D KEEPASSXC_BUILD_TYPE=Release \
    -D WITH_XC_ALL=ON \
    -D WITH_TESTS=OFF \
    -D WITH_APP_BUNDLE=OFF \
    -D WITH_XC_UPDATECHECK=OFF \
    -Wno-dev
  cmake --build build
  DESTDIR=$PKG cmake --install build

  rm -r $PKG/usr/share/keepassxc/translations
  rm -rf $PKG/usr/share/keepassxc/docs
}
