From 598d60a0c248a915ebc407675ef955e98fc51a6a Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Mon, 21 Sep 2009 10:30:04 +0000
Subject: [PATCH] Build system: added test for beamer

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2955 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 configure.ac                   | 10 +++++
 doc/macroprocessor/Makefile.am |  2 +
 doc/preprocessor/Makefile.am   |  2 +
 m4/ax_latex_class.m4           | 68 ++++++++++++++++++++++++++++++++++
 m4/ax_latex_test.m4            | 56 ++++++++++++++++++++++++++++
 5 files changed, 138 insertions(+)
 create mode 100644 m4/ax_latex_class.m4
 create mode 100644 m4/ax_latex_test.m4

diff --git a/configure.ac b/configure.ac
index c69bd14f89..46014d0c90 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,8 +95,11 @@ if test "x$PDFLATEX" != "x" -a "x$BIBTEX" != "x"; then
 	Year = {1996}}
 ], [ax_latex_have_econometrica])
   AC_MSG_RESULT([$ax_latex_have_econometrica])
+
+  AX_LATEX_CLASS([beamer], [ax_latex_have_beamer])
 fi
 AM_CONDITIONAL([HAVE_ECONOMETRICA], [test "x$ax_latex_have_econometrica" = "xyes"])
+AM_CONDITIONAL([HAVE_BEAMER], [test "x$ax_latex_have_beamer" = "xyes"])
 
 AC_CHECK_PROG([DBLATEX], [dblatex], [dblatex])
 AM_CONDITIONAL([HAVE_DBLATEX], [test "x$DBLATEX" != "x"])
@@ -228,6 +231,12 @@ else
   BUILD_DYNARE_USERGUIDE="no (missing one of: pdflatex, bibtex, econometrica BST)"
 fi
 
+if test "x$PDFLATEX" != "x" -a "x$ax_latex_have_beamer" = "xyes"; then
+  BUILD_BEAMER_DOC="yes"
+else
+  BUILD_BEAMER_DOC="no (missing one of: pdflatex, beamer)"
+fi
+
 if test "x$PDFLATEX" != "x"; then
   BUILD_OTHER_PDF_DOC="yes"
 else
@@ -278,6 +287,7 @@ PDF documentation (with "make pdf"):
  Dynare reference manual:               $BUILD_DYNARE_PDF_MANUAL
  Dynare user guide:                     $BUILD_DYNARE_USERGUIDE
  Dynare++ developer documentation:      $BUILD_DYNAREPLUSPLUS_SRCDOC
+ Beamer presentations:                  $BUILD_BEAMER_DOC
  Various other documents:               $BUILD_OTHER_PDF_DOC
 
 HTML documentation (with "make html"):
diff --git a/doc/macroprocessor/Makefile.am b/doc/macroprocessor/Makefile.am
index aaef0a7937..dc3f7df0bd 100644
--- a/doc/macroprocessor/Makefile.am
+++ b/doc/macroprocessor/Makefile.am
@@ -1,6 +1,8 @@
 if HAVE_PDFLATEX
+if HAVE_BEAMER
 pdf-local: macroprocessor.pdf
 endif
+endif
 
 SRC = macroprocessor.tex old-design.pdf new-design.pdf
 
diff --git a/doc/preprocessor/Makefile.am b/doc/preprocessor/Makefile.am
index 9b70186365..afdbb73a5c 100644
--- a/doc/preprocessor/Makefile.am
+++ b/doc/preprocessor/Makefile.am
@@ -1,6 +1,8 @@
 if HAVE_PDFLATEX
+if HAVE_BEAMER
 pdf-local: preprocessor.pdf
 endif
+endif
 
 SRC = preprocessor.tex expr.png expr-sharing.png matrices.png overview.png
 
diff --git a/m4/ax_latex_class.m4 b/m4/ax_latex_class.m4
new file mode 100644
index 0000000000..0c1a951923
--- /dev/null
+++ b/m4/ax_latex_class.m4
@@ -0,0 +1,68 @@
+# ===========================================================================
+#         http://www.nongnu.org/autoconf-archive/ax_latex_class.html
+# ===========================================================================
+#
+# OBSOLETE MACRO
+#
+#   Deprecated because of licensing issues. The Lesser GPL imposes licensing
+#   restrictions on the generated configure script unless it is augmented
+#   with an Autoconf Exception clause.
+#
+# SYNOPSIS
+#
+#   AX_LATEX_CLASS(CLASSNAME,VARIABLETOSET[,ACTION-IF-FOUND[,ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+#   This macros test is class CLASSNAME exists and work and set
+#   VARIABLETOSET to yes or no If ACTION-IF-FOUND (and ACTION-IF-NOT-FOUND)
+#   are set, do the correct action
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Boretti Mathieu <boretti@eig.unige.ch>
+#   Copyright (c) 2009 Dynare Team
+#
+#   This library is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU Lesser General Public License as published by
+#   the Free Software Foundation; either version 2.1 of the License, or (at
+#   your option) any later version.
+#
+#   This library 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 Lesser
+#   General Public License for more details.
+#
+#   You should have received a copy of the GNU Lesser General Public License
+#   along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([AX_LATEX_CLASS],[
+AC_CACHE_CHECK([for usability of class $1],[ac_cv_latex_class_]translit($1,[-],[_]),[
+AX_LATEX_TEST([\documentclass{$1}
+\begin{document}
+\end{document}],[ac_cv_latex_class_]translit($1,[-],[_]))
+])
+$2=$[ac_cv_latex_class_]translit($1,[-],[_]) ; export $2;
+AC_SUBST($2)
+ifelse($#,2,[],$#,3,[
+    if test "[$]$2" = "yes" ;
+    then
+        $3
+    fi
+],$#,4,[
+    ifelse($3,[],[
+        if test "[$]$2" = "no" ;
+        then
+            $4
+        fi
+    ],[
+        if test "[$]$2" = "yes" ;
+        then
+            $3
+        else
+            $4
+        fi
+    ])
+])
+
+])
diff --git a/m4/ax_latex_test.m4 b/m4/ax_latex_test.m4
new file mode 100644
index 0000000000..4d5b73a348
--- /dev/null
+++ b/m4/ax_latex_test.m4
@@ -0,0 +1,56 @@
+# ===========================================================================
+#          http://www.nongnu.org/autoconf-archive/ax_latex_test.html
+# ===========================================================================
+#
+# OBSOLETE MACRO
+#
+#   Deprecated because of licensing issues. The Lesser GPL imposes licensing
+#   restrictions on the generated configure script unless it is augmented
+#   with an Autoconf Exception clause.
+#
+# SYNOPSIS
+#
+#   AX_LATEX_TEST(FILEDATA,VARIABLETOSET,[NOCLEAN])
+#
+# DESCRIPTION
+#
+#   This macros execute the latex application with FILEDATA as input and set
+#   VARIABLETOSET the yes or no depending of the result if NOCLEAN is set,
+#   the folder used for the test is not delete after testing.
+#
+#   The macro assumes that the variable PDFLATEX is set.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Boretti Mathieu <boretti@eig.unige.ch>
+#   Copyright (c) 2009 Dynare Team
+#
+#   This library is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU Lesser General Public License as published by
+#   the Free Software Foundation; either version 2.1 of the License, or (at
+#   your option) any later version.
+#
+#   This library 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 Lesser
+#   General Public License for more details.
+#
+#   You should have received a copy of the GNU Lesser General Public License
+#   along with this library. If not, see <http://www.gnu.org/licenses/>.
+
+AC_DEFUN([AX_LATEX_TEST],[
+rm -rf conftest.dir/.acltx
+AS_MKDIR_P([conftest.dir/.acltx])
+cd conftest.dir/.acltx
+m4_ifval([$2],[$2="no"; export $2;])
+cat > conftest.tex << ACLEOF
+$1
+ACLEOF
+cat conftest.tex | $PDFLATEX 2>&1 1>output m4_ifval([$2],[&& $2=yes])
+cd ..
+cd ..
+sed 's/^/| /' conftest.dir/.acltx/conftest.tex >&5
+echo "$as_me:$LINENO: executing cat conftest.tex | $PDFLATEX" >&5
+sed 's/^/| /' conftest.dir/.acltx/output >&5
+m4_ifval([$3],,[rm -rf conftest.dir/.acltx])
+])
-- 
GitLab