# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Dan McGee <dan@archlinux.org>

pkgbase=doxygen
pkgname=('doxygen' 'doxygen-docs')
pkgver=1.9.7
pkgrel=1
pkgdesc='Documentation system for C++, C, Java, IDL and PHP'
url='http://www.doxygen.nl'
arch=('x86_64')
license=('GPL')
makedepends=('cmake' 'gcc-libs' 'flex' 'qt5-base' 'texlive-core' 'ghostscript'
             'texlive-latexextra' 'graphviz' 'python' 'git')
source=(${pkgbase}-${pkgver}.tar.gz::https://github.com/doxygen/doxygen/archive/Release_${pkgver//./_}.tar.gz)
sha256sums=('691777992a7240ed1f822a5c2ff2c4273b57c1cf9fc143553d87f91a0c5970ee')
sha512sums=('2986ea60f9b683d92d81083af74ed17cffa283b9893f61c1d8d62a9d7f0daa8b16057e952163046c96aa9b26a83f8fd55d27b124a3d65f0129acd18866fdb8be')
b2sums=('69f30fc701e55c9cca0a14da141acbc16403c7c35bb60720415e5851c16ea2ee68bca90a6d88c9b14b98d794c80dc93d2c9e085a8dcd4fd9e6f8111544ce678e')

prepare() {
  cd ${pkgbase}-Release_${pkgver//./_}
  # Install the man pages in the right place
  sed -i 's:DESTINATION man/man1:DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1":g' \
    doc/CMakeLists.txt
}

build() {
  cd ${pkgbase}-Release_${pkgver//./_}

  cmake -B build \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DDOC_INSTALL_DIR:PATH=share/doc/doxygen \
    -DPYTHON_EXECUTABLE:FILE=/usr/bin/python \
    -Dbuild_doc:BOOL=ON \
    -Dbuild_wizard:BOOL=ON
  make -C build
  export CAIRO_DEBUG_PDF=1 # https://github.com/doxygen/doxygen/issues/9319
  make -C build docs -j1
}

check() {
  cd ${pkgbase}-Release_${pkgver//./_}
  make -C build tests
}

package_doxygen() {
  pkgdesc='Documentation system for C++, C, Java, IDL and PHP'
  depends=('gcc-libs')
  optdepends=('graphviz: for caller/callee graph generation'
              'qt5-base: for doxywizard')

  cd ${pkgbase}-Release_${pkgver//./_}
  make -C build DESTDIR="${pkgdir}" install

  rm -rf "${pkgdir}/usr/share/doc"
}

package_doxygen-docs() {
  pkgdesc='Developer documentation for doxygen'

  cd ${pkgbase}-Release_${pkgver//./_}
  make -C build DESTDIR="${pkgdir}" install

  rm -rf "${pkgdir}/usr/bin"
  rm -rf "${pkgdir}/usr/share/man"
}

# vim: ts=2 sw=2 et:
