doxygen_configfile = Doxyfile
doxygen_configfile_source = $(srcdir)/Doxyfile.in
beautify_docs = @GMMPROC_DIR@/beautify_docs.pl
devhelp_file = gtkmm-2.4.devhelp

include $(top_srcdir)/docs/Makefile_web.am_fragment
web_path_reference = $(web_path_docs)reference

hierarchy_files = widget_hierarchy.png widget_hierarchy.html widget_hierarchy.dia

EXTRA_DIST = README Doxyfile.in \
             gtkmm_header.html_fragment gtkmm_footer.html_fragment \
             html gtkmm_doxygen_tags doxygen_to_devhelp.xsl $(devhelp_file) \
             $(hierarchy_files) \
             xml/index.xml #Just to satisfy the dependency when building from the tarball.

# The html is generated by doxygen. We generate xml also, but we are not distributing it yet.
# The installdox thing is part of doxygen - it fixes the URLs to point to the glibmm reference docs.
# beautify_docs moves the * and & next to the C++ types rather than the parameter names.
html/index.html: $(doxygen_configfile_source)
	-rm -rf html
	image_path=""; \
	dir="`pkg-config --silence-errors --variable=prefix gtk+-2.0`/share/gtk-doc/html/gtk"; \
	test -d "$$dir" && image_path="$$dir"; \
	dir="$(top_srcdir)/../gtk+/gtk/stock-icons"; \
	test -d "$$dir" && image_path="$$image_path $$dir"; \
	DOXYGEN_IMAGE_PATH="$${DOXYGEN_IMAGE_PATH:=$$image_path}" doxygen $(doxygen_configfile) \
	2> doxygen-warnings.txt | tee doxygen-output.txt && cat doxygen-warnings.txt
	cd html && ./installdox -l glibmm_doxygen_tags@../../../../glibmm-2.4/docs/reference/html \
	2>> doxygen-warnings.txt | tee -a doxygen-output.txt && cd ..
	$(beautify_docs) html 2>> doxygen-warnings.txt | tee -a doxygen-output.txt


# DevHelp reference
gtkmm-2.4.devhelp: xml/index.xml
	xsltproc -o $(devhelp_file) doxygen_to_devhelp.xsl xml/index.xml

gtkmm-reference-html.tar.gz: $(hierarchy_files) html/index.html
	tar cf - html | gzip -c --best >$@

gtkmm-reference-html.tar.bz2: $(hierarchy_files) html/index.html
	tar cf - html | bzip2 -c >$@

post-html: html/index.html $(hierarchy_files)
	rsync $(rsync_args) -r html/ doxygen-warnings.txt doxygen-output.txt $$USER@$(web_host):$(web_path_reference)/html/
	rsync $(rsync_args) -r $(hierarchy_files) $$USER@$(web_host):$(web_path_reference)/

doc-clean: html-clean
	-rm -rf xml
	-rm -f gtkmm_doxygen_tags
	-rm -f $(devhelp_file)  
	-rm -f gtkmm-reference-html.tar.gz gtkmm-reference-html.tar.bz2

html-clean:
	-rm -rf html

referencetopdir = $(gtkmm_docdir)/reference
referencedir = $(referencetopdir)/html
devhelpdir = $(datadir)/devhelp/books/gtkmm-2.4

hierarchy_to_install = widget_hierarchy.png widget_hierarchy.html

install-reference: html/index.html $(devhelp_file)
	@$(NORMAL_INSTALL)
	$(mkinstalldirs) $(DESTDIR)$(referencedir)
	@dir='$(<D)'; for p in $$dir/*.html $$dir/*.css $$dir/*.png $$dir/*.dot ; do \
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
	  echo " $(INSTALL_DATA) $$p $(DESTDIR)$(referencedir)/$$f"; \
	  $(INSTALL_DATA) $$p $(DESTDIR)$(referencedir)/$$f; \
	done
	$(mkinstalldirs) $(DESTDIR)$(devhelpdir)
	$(INSTALL_DATA) $(srcdir)/$(devhelp_file) $(DESTDIR)$(devhelpdir)/$$f;
	$(INSTALL_DATA) $(srcdir)/widget_hierarchy.png $(DESTDIR)$(referencetopdir)/$$f;
	$(INSTALL_DATA) $(srcdir)/widget_hierarchy.html $(DESTDIR)$(referencetopdir)/$$f;


uninstall-reference: html/index.html
	@$(NORMAL_UNINSTALL)
	@dir='$(<D)'; for p in $$dir/*.html $$dir/*.css $$dir/*.png $$dir/*.dot ; do \
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
	  echo " rm -f $(DESTDIR)$(referencedir)/$$f"; \
	  rm -f $(DESTDIR)$(referencedir)/$$f; \
	done
	rm -f $(DESTDIR)$(devhelpdir)/$(devhelp_file)
	rm -f $(DESTDIR)$(referencetopdir)/widget_hierarchy.png
	rm -f $(DESTDIR)$(referencetopdir)/widget_hierarchy.html

all-local: html/index.html

install-data-local: install-reference

uninstall-local: uninstall-reference

maintainer-clean-local: doc-clean

.PHONY: post-html doc-clean install-reference uninstall-reference html-clean


# Direct all the doxygen console output to a text file, so we can read it later:
# In doxywizard, disable EXTRACT_ALL to get warnings about undocumented methods.
doxygen-warnings: html-clean html/index.html
