Index: LinearAlgebra/Makefile.am
===================================================================
--- LinearAlgebra/Makefile.am	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ LinearAlgebra/Makefile.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -1,13 +1,22 @@
 ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = src/LinearAlgebra src/unittests tests/CodeChecks doc 
+SUBDIRS = src/LinearAlgebra src/unittests tests/CodeChecks doc
 
 AUTOMAKE_OPTIONS = subdir-objects
 
-EXTRA_DIST = bootstrap
+#include doc/am_doxygen_include.am
+
+EXTRA_DIST = \
+	bootstrap \
+	m4/ac_doxygen.m4 \
+	m4/ax_codepatterns.m4 \
+	m4/boost.m4 \
+	m4/cppunit.m4
+
+#        doc/am_doxygen_include.am
 
 .PHONY: doc
 doc:
-	cd doc && make doxygen-docs
-	
+	cd doc && make doxygen-doc
+
 unity:
 	cd src && make unity
Index: LinearAlgebra/configure.ac
===================================================================
--- LinearAlgebra/configure.ac	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ LinearAlgebra/configure.ac	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -19,10 +19,9 @@
 AC_PROG_CC
 AC_PROG_INSTALL
-AC_CHECK_PROG([LATEX],[latex],[latex],[:])
-AC_CHECK_PROG([BIBTEX],[bibtex],[bibtex],[:])
-AC_CHECK_PROG([DVIPS],[dvips],[dvips],[:])
-AC_CHECK_PROG([PDFLATEX],[pdflatex],[pdflatex],[:])
-AC_CHECK_PROG([XMLTO],[xmlto],[xmlto],[:])
-AM_MISSING_PROG([DOXYGEN], [doxygen])
+
+DX_HTML_FEATURE(ON)
+DX_PS_FEATURE(OFF)
+DX_PDF_FEATURE(OFF)
+DX_INIT_DOXYGEN(LinearAlgebra, Doxyfile, $(docdir))
 
 LT_INIT([static])
Index: LinearAlgebra/doc/Doxyfile
===================================================================
--- LinearAlgebra/doc/Doxyfile	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ LinearAlgebra/doc/Doxyfile	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -4,7 +4,7 @@
 # Project related configuration options
 #---------------------------------------------------------------------------
-PROJECT_NAME           = Molecuilder
-PROJECT_NUMBER         = 1.0
-OUTPUT_DIRECTORY       = ../doc
+PROJECT_NAME           = $(PROJECT)
+PROJECT_NUMBER         = $(VERSION)
+OUTPUT_DIRECTORY       = $(DOCDIR)
 CREATE_SUBDIRS         = NO
 OUTPUT_LANGUAGE        = English
@@ -83,5 +83,5 @@
 # configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = ../src
+INPUT                  = $(TOPSRCDIR)/src
 FILE_PATTERNS          = *.c \
                          *.cc \
Index: LinearAlgebra/doc/Makefile.am
===================================================================
--- LinearAlgebra/doc/Makefile.am	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ LinearAlgebra/doc/Makefile.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -1,35 +1,4 @@
-EXTRA_DIST = \
-	Doxyfile \
-	html
 
-SRCMANDOCS =
+include am_doxygen_include.am
 
-GENMANDOCS =
-
-dist_man_MANS = $(SRCMANDOCS) $(GENMANDOCS)
-dist_doc_DATA = $(PDFFILES)
-
-SUFFIXES = .pdf .ps .dvi .tex .xml .html
-
-html-local: doxygen-docs
-
-doxygen-docs:
-	cd $(srcdir) && $(DOXYGEN)
-
-.xml.ps:
-	$(XMLTO) $(XMLTOFLAGS) ps $<
-	@touch $@
-
-.xml.html:
-	$(XMLTO) $(XMLTOFLAGS) html-nochunks $<
-	@touch $@
-
-clean-local: 
-	rm -f *.aux *.bbl *.blg *.log *.aux.bak
-distclean-local:
-	rm -f *.dvi *.ps *.pdf *.html $(GENMANDOCS)
-
-.PHONY: allclean doxygen-docs
-allclean: distclean
-
-
+EXTRA_DIST = am_doxygen_include.am
Index: LinearAlgebra/doc/am_doxygen_include.am
===================================================================
--- LinearAlgebra/doc/am_doxygen_include.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
+++ LinearAlgebra/doc/am_doxygen_include.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -0,0 +1,1 @@
+../../doc/am_doxygen_include.am
Index: Makefile.am
===================================================================
--- Makefile.am	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ Makefile.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -1,13 +1,26 @@
 ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = LinearAlgebra src src/unittests doc tests 
+SUBDIRS = LinearAlgebra src src/unittests tests doc
 
 AUTOMAKE_OPTIONS = subdir-objects
 
-EXTRA_DIST = bootstrap
+#include doc/am_doxygen_include.am
+
+EXTRA_DIST = \
+	bootstrap \
+	m4/ac_doxygen.m4 \
+	m4/acx_compilerflags.m4 \
+	m4/ax_check_gl.m4 \
+	m4/ax_check_glu.m4 \
+	m4/ax_codepatterns.m4 \
+	m4/boost.m4 \
+	m4/cppunit.m4 \
+	m4/gwqt4.m4
+
+#	doc/am_doxygen_include.am
 
 .PHONY: doc
 doc:
-	cd doc && make doxygen-docs
-	
+	cd doc && make doxygen-doc
+
 unity:
 	cd src && make unity
Index: configure.ac
===================================================================
--- configure.ac	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ configure.ac	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -20,11 +20,12 @@
 AC_PROG_CC
 AC_PROG_INSTALL
-AC_CHECK_PROG([LATEX],[latex],[latex],[:])
-AC_CHECK_PROG([BIBTEX],[bibtex],[bibtex],[:])
-AC_CHECK_PROG([DVIPS],[dvips],[dvips],[:])
-AC_CHECK_PROG([PDFLATEX],[pdflatex],[pdflatex],[:])
-AC_CHECK_PROG([XMLTO],[xmlto],[xmlto],[:])
-AM_MISSING_PROG([DOXYGEN], [doxygen])
-
+
+# use doxygen
+DX_HTML_FEATURE(ON)
+DX_PS_FEATURE(OFF)
+DX_PDF_FEATURE(OFF)
+DX_INIT_DOXYGEN(MoleCuilder, Doxyfile, $(docdir))
+
+# use libtool
 LT_INIT([static])
 
@@ -224,5 +225,5 @@
 AC_CONFIG_FILES([
 	Makefile 
-	doc/Makefile 
+	doc/Makefile
 	src/Makefile 
 ])
Index: doc/Doxyfile
===================================================================
--- doc/Doxyfile	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ doc/Doxyfile	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -4,7 +4,7 @@
 # Project related configuration options
 #---------------------------------------------------------------------------
-PROJECT_NAME           = Molecuilder
-PROJECT_NUMBER         = 1.0
-OUTPUT_DIRECTORY       = ../doc
+PROJECT_NAME           = $(PROJECT)
+PROJECT_NUMBER         = $(VERSION)
+OUTPUT_DIRECTORY       = $(DOCDIR)
 CREATE_SUBDIRS         = NO
 OUTPUT_LANGUAGE        = English
@@ -83,5 +83,5 @@
 # configuration options related to the input files
 #---------------------------------------------------------------------------
-INPUT                  = ../src
+INPUT                  = $(TOPSRCDIR)/src
 FILE_PATTERNS          = *.c \
                          *.cc \
Index: doc/Makefile.am
===================================================================
--- doc/Makefile.am	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ doc/Makefile.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -1,52 +1,4 @@
-EXTRA_DIST = \
-	Doxyfile \
-	html \
-	molecuilder.xml \
-	userguide.xml
+include am_doxygen_include.am
 
-SRCMANDOCS =
+EXTRA_DIST = am_doxygen_include.am
 
-GENMANDOCS = \
-	molecuilder.1 \
-	espack.conf.5
-
-dist_man_MANS = $(SRCMANDOCS) $(GENMANDOCS)
-dist_doc_DATA = $(PDFFILES)
-
-SUFFIXES = .pdf .ps .dvi .tex .xml .html
-
-html-local: doxygen-docs
-
-doxygen-docs:
-	cd $(srcdir) && $(DOXYGEN)
-
-.xml.ps:
-	$(XMLTO) $(XMLTOFLAGS) ps $<
-	@touch $@
-
-.xml.html:
-	$(XMLTO) $(XMLTOFLAGS) html-nochunks $<
-	@touch $@
-
-molecuilder.stamp: molecuilder.xml
-	@rm -f molecuilder.tmp
-	@touch molecuilder.tmp
-	$(XMLTO) $(XMLTOFLAGS) man $<
-	@touch $(GENMANDOCS)
-	@mv -f molecuilder.tmp $@
-
-$(GENMANDOCS): molecuilder.stamp
-	@if test -f $@; then touch $@; else \
-	  rm -f molecuilder.stamp; \
-	  $(MAKE) $(AM_MAKEFLAGS) molecuilder.stamp; \
-	fi
-
-clean-local: 
-	rm -f *.aux *.bbl *.blg *.log *.aux.bak
-distclean-local:
-	rm -f *.dvi *.ps *.pdf *.html $(GENMANDOCS) molecuilder.stamp
-
-.PHONY: allclean doxygen-docs
-allclean: distclean
-
-
Index: doc/am_doxygen_include.am
===================================================================
--- doc/am_doxygen_include.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
+++ doc/am_doxygen_include.am	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -0,0 +1,186 @@
+# Copyright (C) 2004 Oren Ben-Kiki
+# This file is distributed under the same terms as the Automake macro files.
+
+# Generate automatic documentation using Doxygen. Goals and variables values
+# are controlled by the various DX_COND_??? conditionals set by autoconf.
+#
+# The provided goals are:
+# doxygen-doc: Generate all doxygen documentation.
+# doxygen-run: Run doxygen, which will generate some of the documentation
+#              (HTML, CHM, CHI, MAN, RTF, XML) but will not do the post
+#              processing required for the rest of it (PS, PDF, and some MAN).
+# doxygen-man: Rename some doxygen generated man pages.
+# doxygen-ps: Generate doxygen PostScript documentation.
+# doxygen-pdf: Generate doxygen PDF documentation.
+#
+# Note that by default these are not integrated into the automake goals. If
+# doxygen is used to generate man pages, you can achieve this integration by
+# setting man3_MANS to the list of man pages generated and then adding the
+# dependency:
+#
+#   $(man3_MANS): doxygen-doc
+#
+# This will cause make to run doxygen and generate all the documentation.
+#
+# The following variable is intended for use in Makefile.am:
+#
+# DX_CLEANFILES = everything to clean.
+#
+# This is usually added to MOSTLYCLEANFILES.
+
+## --------------------------------- ##
+## Format-independent Doxygen rules. ##
+## --------------------------------- ##
+
+if DX_COND_doc
+
+## ------------------------------- ##
+## Rules specific for HTML output. ##
+## ------------------------------- ##
+
+if DX_COND_html
+
+DX_CLEAN_HTML = @DX_DOCDIR@/html
+
+endif DX_COND_html
+
+## ------------------------------ ##
+## Rules specific for CHM output. ##
+## ------------------------------ ##
+
+if DX_COND_chm
+
+DX_CLEAN_CHM = @DX_DOCDIR@/chm
+
+if DX_COND_chi
+
+DX_CLEAN_CHI = @DX_DOCDIR@/@PACKAGE@.chi
+
+endif DX_COND_chi
+
+endif DX_COND_chm
+
+## ------------------------------ ##
+## Rules specific for MAN output. ##
+## ------------------------------ ##
+
+if DX_COND_man
+
+DX_CLEAN_MAN = @DX_DOCDIR@/man
+
+endif DX_COND_man
+
+## ------------------------------ ##
+## Rules specific for RTF output. ##
+## ------------------------------ ##
+
+if DX_COND_rtf
+
+DX_CLEAN_RTF = @DX_DOCDIR@/rtf
+
+endif DX_COND_rtf
+
+## ------------------------------ ##
+## Rules specific for XML output. ##
+## ------------------------------ ##
+
+if DX_COND_xml
+
+DX_CLEAN_XML = @DX_DOCDIR@/xml
+
+endif DX_COND_xml
+
+## ----------------------------- ##
+## Rules specific for PS output. ##
+## ----------------------------- ##
+
+if DX_COND_ps
+
+DX_CLEAN_PS = @DX_DOCDIR@/@PACKAGE@.ps
+
+DX_PS_GOAL = doxygen-ps
+
+doxygen-ps: @DX_DOCDIR@/@PACKAGE@.ps
+
+@DX_DOCDIR@/@PACKAGE@.ps: @DX_DOCDIR@/@PACKAGE@.tag
+	cd @DX_DOCDIR@/latex; \
+	rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
+	$(DX_LATEX) refman.tex; \
+	$(MAKEINDEX_PATH) refman.idx; \
+	$(DX_LATEX) refman.tex; \
+	countdown=5; \
+	while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
+	                  refman.log > /dev/null 2>&1 \
+	   && test $$countdown -gt 0; do \
+	    $(DX_LATEX) refman.tex; \
+	    countdown=`expr $$countdown - 1`; \
+	done; \
+	$(DX_DVIPS) -o ../@PACKAGE@.ps refman.dvi
+
+endif DX_COND_ps
+
+## ------------------------------ ##
+## Rules specific for PDF output. ##
+## ------------------------------ ##
+
+if DX_COND_pdf
+
+DX_CLEAN_PDF = @DX_DOCDIR@/@PACKAGE@.pdf
+
+DX_PDF_GOAL = doxygen-pdf
+
+doxygen-pdf: @DX_DOCDIR@/@PACKAGE@.pdf
+
+@DX_DOCDIR@/@PACKAGE@.pdf: @DX_DOCDIR@/@PACKAGE@.tag
+	cd @DX_DOCDIR@/latex; \
+	rm -f *.aux *.toc *.idx *.ind *.ilg *.log *.out; \
+	$(DX_PDFLATEX) refman.tex; \
+	$(DX_MAKEINDEX) refman.idx; \
+	$(DX_PDFLATEX) refman.tex; \
+	countdown=5; \
+	while $(DX_EGREP) 'Rerun (LaTeX|to get cross-references right)' \
+	                  refman.log > /dev/null 2>&1 \
+	   && test $$countdown -gt 0; do \
+	    $(DX_PDFLATEX) refman.tex; \
+	    countdown=`expr $$countdown - 1`; \
+	done; \
+	mv refman.pdf ../@PACKAGE@.pdf
+
+endif DX_COND_pdf
+
+## ------------------------------------------------- ##
+## Rules specific for LaTeX (shared for PS and PDF). ##
+## ------------------------------------------------- ##
+
+if DX_COND_latex
+
+DX_CLEAN_LATEX = @DX_DOCDIR@/latex
+
+endif DX_COND_latex
+
+.PHONY: doxygen-run doxygen-doc $(DX_PS_GOAL) $(DX_PDF_GOAL)
+
+.INTERMEDIATE: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
+
+doxygen-run: @DX_DOCDIR@/@PACKAGE@.tag
+
+doxygen-doc: doxygen-run $(DX_PS_GOAL) $(DX_PDF_GOAL)
+
+@DX_DOCDIR@/@PACKAGE@.tag: $(DX_CONFIG) $(pkginclude_HEADERS)
+	rm -rf @DX_DOCDIR@
+	$(DX_ENV) $(DX_DOXYGEN) $(srcdir)/$(DX_CONFIG)
+
+DX_CLEANFILES = \
+    @DX_DOCDIR@/@PACKAGE@.tag \
+    -r \
+    $(DX_CLEAN_HTML) \
+    $(DX_CLEAN_CHM) \
+    $(DX_CLEAN_CHI) \
+    $(DX_CLEAN_MAN) \
+    $(DX_CLEAN_RTF) \
+    $(DX_CLEAN_XML) \
+    $(DX_CLEAN_PS) \
+    $(DX_CLEAN_PDF) \
+    $(DX_CLEAN_LATEX)
+
+endif DX_COND_doc
Index: m4/ac_doxygen.m4
===================================================================
--- m4/ac_doxygen.m4	(revision 632a52b11abb20d9061552caa17f2fbef9b87353)
+++ m4/ac_doxygen.m4	(revision ec188cd9bf78485f7613e2bea7509b0f99ac5c34)
@@ -79,5 +79,5 @@
 if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
     AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
-    AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+    AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
 fi
 ])
@@ -102,5 +102,5 @@
 # Turn off the DX_CURRENT_FEATURE if the required feature is off.
 AC_DEFUN([DX_CLEAR_DEPEND], [
-test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
 ])
 
@@ -185,4 +185,5 @@
 # Environment variables used inside doxygen.cfg:
 DX_ENV_APPEND(SRCDIR, $srcdir)
+DX_ENV_APPEND(TOPSRCDIR, \$(top_srcdir))
 DX_ENV_APPEND(PROJECT, $DX_PROJECT)
 DX_ENV_APPEND(DOCDIR, $DX_DOCDIR)
