# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Gaetan Bisson <bisson@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: James Rayner <james@archlinux.org>
# Contributor: Partha Chowdhury <kira.laucas@gmail.com>

pkgname=conky
pkgver=1.18.1
_gitcommit=a21a8f7d26f07f1dc5c144be2120e8bc6721159f
pkgrel=1
pkgdesc='Lightweight system monitor for X'
url='https://github.com/brndnmtthws/conky'
license=('BSD' 'GPL')
arch=('x86_64')
makedepends=('cmake' 'docbook2x' 'docbook-xsl' 'man-db' 'git' 'catch2' 'pandoc' 'python-yaml' 'python-jinja')
depends=(
  'glibc' 'glib2' 'lua' 'wireless_tools' 'libxdamage' 'libxinerama' 'libxft' 'imlib2'
  'libxml2' 'libpulse' 'libxnvctrl' 'systemd-libs' 'ncurses' 'curl'
  libncursesw.so libXNVCtrl.so libsystemd.so libpulse.so libcurl.so)
#source=("git+https://github.com/brndnmtthws/conky.git#commit=${_gitcommit}?signed")
#v1.17.0 commit not signed
source=("git+https://github.com/brndnmtthws/conky.git#tag=v$pkgver?signed")
sha512sums=('SKIP')
b2sums=('SKIP')
validpgpkeys=(
  'EB2E847572A71BE20F59AFBEB49ABB7270D9D4FD' # Brenden Matthews
)

pkgver() {
  cd ${pkgname}
  git describe --tags --match 'v*' | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
  cd $pkgname
# Unbundle catch2 to fix build with glibc 2.35
  rm -r tests/catch2
  ln -s /usr/include/catch2 tests
}

build() {
  cd ${pkgname}
  cmake \
    -B build \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_CXX_FLAGS="$CXXFLAGS -ffat-lto-objects" \
    -D MAINTAINER_MODE=OFF \
    -D BUILD_TESTS=ON \
    -D BUILD_DOCS=ON \
    -D BUILD_EXTRAS=ON \
    -D BUILD_WLAN=ON \
    -D BUILD_XDBE=ON \
    -D BUILD_XSHAPE=ON \
    -D BUILD_IMLIB2=ON \
    -D BUILD_CURL=ON \
    -D BUILD_RSS=ON \
    -D BUILD_NVIDIA=ON \
    -D BUILD_PULSEAUDIO=ON \
    -D BUILD_JOURNAL=ON \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -Wno-dev \
    -S .

  make -C build
}

package() {
  cd ${pkgname}
  make -C build DESTDIR="${pkgdir}" install
  install -Dm 644 COPYING -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 build/extras/vim/syntax/conkyrc.vim -t "${pkgdir}"/usr/share/vim/vimfiles/syntax
  install -Dm 644 extras/vim/ftdetect/conkyrc.vim -t "${pkgdir}"/usr/share/vim/vimfiles/ftdetect
}

# vim: ts=2 sw=2 et:
