#!/bin/sh
set -e

# This is more portable than `which' but comes with
# the caveat of not(?) properly working on busybox's ash:
existence()
{
    type "$1" >/dev/null 2>&1
}

if ! existence doxygen; then
  echo "Doxygen not found"
  exit 1
fi
cd "${MESON_SOURCE_ROOT}/doc/doxygen"

# PACKAGE_VERSION is set by the 'doxygen' run_target in meson.build; the
# makefile falls back to scripts/get_version.sh when it is not set.
make all

echo "Doxygen files generated into ${MESON_SOURCE_ROOT}/doc/doxygen/html!"
