include $(top_srcdir)/config/mk/doc.mk
include $(top_srcdir)/config/mk/dist.mk

EXTRA_DIST = Doxyfile.in script.sed

doc-dir:
	test -d include || mkdir include

Doxyfile: Doxyfile.in
	sed -e "s,@PROJECT_NAME@,${PACKAGE_NAME}," \
	    -e "s,@PROJECT_NUMBER@,${PACKAGE_VERSION}," \
	    -e "s,@PROJECT_RELEASE@,${PACKAGE_RELEASE}," \
	    -e "s,@STRIP_FROM_PATH@,$(top_builddir)/doc/include," \
	    -e "s,@INPUTFILES@,$(top_builddir)/doc/include," \
	    -e "s,@HAVE_DOT@,NO," \
	    $(top_srcdir)/doc/Doxyfile.in > $(top_builddir)/doc/Doxyfile


all-local: doc-dir Doxyfile 
	cd $(top_builddir); make doc-findheader
	if test -e files-changed; then  \
          $(DOXYGEN) $(top_builddir)/doc/Doxyfile; \
          rm -f files-changed;  \
        else \
          echo "\nNothing to do.";  \
        fi


clean-local:
	if test -d html; then rm -rf html; fi;
	if test -d man; then rm -rf man; fi;
	if test -d latex; then rm -rf latex; fi;
	if test -d include; then rm -rf include; fi;
	if test -f Doxyfile; then rm -f Doxyfile; fi;
	if test -f files-changed; then rm -f files-changed; fi;


install-data-hook: 
	if ! test -d $(DESTDIR)$(mandir)/man3; then mkdir -p $(DESTDIR)$(mandir)/man3; fi;
	@list=`ls man/man3`; DSTDIR=$(DESTDIR)${mandir}/man3; SRCDIR=man/man3; \
        for i in $$list; do \
             $(INSTALL_DATA) $$SRCDIR/$$i $$DSTDIR/; \
        done;



uninstall-hook:
	@list=`ls man/man3`; DSTDIR=$(DESTDIR)${mandir}/man3;\
        for i in $$list; do \
             if test -e $$DSTDIR/$$i; then rm -f $$DSTDIR/$$i; fi; \
        done;


