#!/bin/sh
#
# Copyright (C) 2001-2013 Graeme Walker <graeme_walker@users.sourceforge.net>
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ===
#
# doxygen.sh
#
# Used by doc/Makefile to run doxygen with a bit of config-file pre-processing.
#
# usage: doxygen <have-doxygen> <top-srcdir> <top-builddir> [<doxyfile-out>]
#

HAVE_DOXYGEN="$1"
top_srcdir="$2"
top_builddir="$3"
doxyfile_out="$4"

if test "$HAVE_DOXYGEN" = "yes"
then 
	if test "${doxyfile_out}" != ""
	then
		cat "${top_srcdir}/doc/doxygen.cfg" | \
		sed "s:__TOP_SRC__:${top_srcdir}:g" | \
		sed "s:__TOP_BUILD__:${top_builddir}:g" | \
		cat > "${doxyfile_out}"
	fi
	cat "${top_srcdir}/doc/doxygen.cfg" | \
	sed "s:__TOP_SRC__:${top_srcdir}:g" | \
	sed "s:__TOP_BUILD__:${top_builddir}:g" | \
	doxygen -
else 
	mkdir doxygen 2>/dev/null
	cp -f "${top_srcdir}/doc/doxygen-missing.html" doxygen/index.html
fi

