Commit 65c77f887a28fea4d4adb010ec1a3e39d398aa63

sammy 2008-05-02T13:17:45

* Generate PDF documentation if a proper LaTeX installation can be found.

diff --git a/.gitignore b/.gitignore
index b483744..4fbdc93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@ demo/FTGLDemo
 demo/FTGLMFontDemo
 test/CTest
 test/CXXTest
-docs/doc-stamp
+docs/stamp-*
 docs/doxygen.cfg
 docs/html
+docs/latex
diff --git a/configure.ac b/configure.ac
index 6d97080..4f08ea8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,10 +57,34 @@ AC_CHECK_FUNCS([memset])
 CPPFLAGS="${CPPFLAGS} -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
 CFLAGS="${CFLAGS} -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs"
 
-# Utility programs
+# Build HTML documentatin?
 AC_PATH_PROG(DOXYGEN, doxygen, no)
 AM_CONDITIONAL(HAVE_DOXYGEN, test "$DOXYGEN" != "no")
 
+# Build PDF documentation?
+AC_PATH_PROG(LATEX, pdflatex, no)
+AC_PATH_PROG(KPSEWHICH, kpsewhich, no)
+AC_PATH_PROG(DVIPS, dvips, no)
+AC_PATH_PROG(EPSTOPDF, epstopdf, no)
+if test "${DVIPS}" = "no" -o "${KPSEWHICH}" = "no" -o "${EPSTOPDF}" = "no"; then
+  LATEX="no"
+fi
+if test "${LATEX}" != "no"; then
+  AC_MSG_CHECKING(for a4.sty and a4wide.sty)
+  if "${KPSEWHICH}" a4.sty >/dev/null 2>&1; then
+    if "${KPSEWHICH}" a4wide.sty >/dev/null 2>&1; then
+      AC_MSG_RESULT(yes)
+    else
+      LATEX="no"
+      AC_MSG_RESULT(no)
+    fi
+  else
+    LATEX="no"
+    AC_MSG_RESULT(no)
+  fi
+fi
+AM_CONDITIONAL(HAVE_LATEX, test "${LATEX}" != "no")
+
 AC_CONFIG_FILES([
   ftgl.pc
 ])
diff --git a/docs/Makefile.am b/docs/Makefile.am
index 753015b..ac1a078 100644
--- a/docs/Makefile.am
+++ b/docs/Makefile.am
@@ -2,6 +2,10 @@
 if HAVE_DOXYGEN
 htmldocdir = $(datadir)/doc/ftgl/html
 htmldoc_DATA = html/doxygen.css
+if HAVE_LATEX
+pdfdocdir = $(datadir)/doc/ftgl
+pdfdoc_DATA = latex/ftgl.pdf
+endif
 endif
 
 IMAGES = \
@@ -9,16 +13,25 @@ IMAGES = \
     images/metrics.png \
     $(NULL)
 
-html/doxygen.css: doc-stamp
-doc-stamp: doxygen.cfg
+html/doxygen.css: stamp-doxygen
+stamp-doxygen: doxygen.cfg
 	$(DOXYGEN) $^
 	cp $(IMAGES) html/
 	touch $@
 
+latex/ftgl.pdf: stamp-latex
+stamp-latex: stamp-doxygen
+	rm -f latex/ftgl.tex latex/ftgl.pdf
+	mv latex/refman.tex latex/ftgl.tex
+	sed 's/setlength{/renewcommand{/' latex/ftgl.tex > latex/refman.tex
+	cd latex && $(MAKE) $(AM_CFLAGS) refman.pdf #|| (cat refman.log; exit 1)
+	mv latex/refman.pdf latex/ftgl.pdf
+	touch stamp-latex
+
 clean: clean-local
 clean-local:
-	$(RM) -rf html
-	$(RM) doc-stamp
+	$(RM) -rf html latex
+	$(RM) stamp-doxygen stamp-latex
 
 if HAVE_DOXYGEN
 install-data-local: html/doxygen.css
diff --git a/docs/doxygen.cfg.in b/docs/doxygen.cfg.in
index b92d25c..65c3fdd 100644
--- a/docs/doxygen.cfg.in
+++ b/docs/doxygen.cfg.in
@@ -593,7 +593,7 @@ EXAMPLE_RECURSIVE      = NO
 # directories that contain image that are included in the documentation (see 
 # the \image command).
 
-IMAGE_PATH             = 
+IMAGE_PATH             = images
 
 # The INPUT_FILTER tag can be used to specify a program that doxygen should 
 # invoke to filter for each input file. Doxygen will invoke the filter program 
@@ -850,7 +850,7 @@ TREEVIEW_WIDTH         = 250
 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will 
 # generate Latex output.
 
-GENERATE_LATEX         = NO
+GENERATE_LATEX         = YES
 
 # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. 
 # If a relative path is entered the value of OUTPUT_DIRECTORY will be 
@@ -904,20 +904,20 @@ PDF_HYPERLINKS         = NO
 # plain latex in the generated Makefile. Set this option to YES to get a 
 # higher quality PDF documentation.
 
-USE_PDFLATEX           = NO
+USE_PDFLATEX           = YES
 
 # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. 
 # command to the generated LaTeX files. This will instruct LaTeX to keep 
 # running if errors occur, instead of asking the user for help. 
 # This option is also used when generating formulas in HTML.
 
-LATEX_BATCHMODE        = NO
+LATEX_BATCHMODE        = YES
 
 # If LATEX_HIDE_INDICES is set to YES then doxygen will not 
 # include the index chapters (such as File Index, Compound Index, etc.) 
 # in the output.
 
-LATEX_HIDE_INDICES     = NO
+LATEX_HIDE_INDICES     = YES
 
 #---------------------------------------------------------------------------
 # configuration options related to the RTF output