# Maintainer: Alexey Pavlov <Alexpux@gmail.com>
# Contributor: Ray Donnelly <mingw.android@gmail.com>

pkgname=doxygen
pkgver=1.14.0
pkgrel=1
pkgdesc="A documentation system for C++, C, Java, IDL and PHP"
arch=('i686' 'x86_64')
url="http://www.doxygen.org/"
msys2_repository_url="https://github.com/doxygen/doxygen"
msys2_references=(
  "cpe: cpe:/a:doxygen:doxygen"
)
license=('spdx:GPL-2.0-only')
depends=("gcc-libs" "libsqlite" "libiconv")
makedepends=("cmake" "ninja" "flex" "python" "libsqlite-devel" "libiconv-devel" 'gcc')
source=(https://www.doxygen.nl/files/${pkgname}-${pkgver}.src.tar.gz
        001-fix-linking.patch)
sha256sums=('d4536d11ab13037327d8d026b75f5a86b7ccb2093e2f546235faf61fd86e6b5d'
            '0efe17145002fc2abd349e051762faf45c89a2db8e8eb83f99660942a9116319')

prepare() {
  cd ${pkgname}-${pkgver}
  patch -p1 -i "${srcdir}"/001-fix-linking.patch
}

build() {
  local extra_config=Release
  if check_option "debug" "y"; then
    extra_config=Debug
  fi

  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  /usr/bin/cmake \
    -GNinja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=${extra_config} \
    -Dbuild_wizard=OFF \
    -Dbuild_search=OFF \
    -Duse_sys_sqlite3=ON \
    -Duse_libclang=OFF \
    ../${pkgname}-${pkgver}

  /usr/bin/cmake --build .
}

package() {
  cd ${srcdir}/build-${MSYSTEM}

  DESTDIR="${pkgdir}" /usr/bin/cmake --install .

  install -Dm644 "${srcdir}"/${pkgname}-${pkgver}/LICENSE \
    "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
