aboutsummaryrefslogtreecommitdiff
path: root/m4/check-latex-package.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/check-latex-package.m4')
-rw-r--r--m4/check-latex-package.m442
1 files changed, 42 insertions, 0 deletions
diff --git a/m4/check-latex-package.m4 b/m4/check-latex-package.m4
new file mode 100644
index 000000000..7b7861134
--- /dev/null
+++ b/m4/check-latex-package.m4
@@ -0,0 +1,42 @@
1dnl
2dnl CHECK_LATEX_PACKAGE(FEATURE-NAME,
3dnl PACKAGE-NAME,
4dnl ACTION-IF-FOUND,
5dnl ACTION-IF-NOT-FOUND)
6dnl
7dnl Tries to compile a small LaTeX document to see if the requested package is
8dnl available to be used with \usepackage.
9dnl
10dnl The result will be cached in the ac_cv_tex_PACKAGE-NAME variable.
11dnl
12dnl This macro also checks for pdflatex as in AC_CHECK_PROGS and the result
13dnl is made available in the PDFLATEX_BINARY variable (all capitals like that.)
14dnl
15dnl FEATURE-NAME is one or more words to identify the check;
16dnl PACKAGE-NAME is the package as it appears in the \usepackage statement
17dnl ACTION-IF-FOUND (optional) commands to execute if the package is installed
18dnl ACTION-IF-NOT-FOUND (optional) the inverse of ACTION-IF-FOUND
19dnl
20AC_DEFUN([CHECK_LATEX_PACKAGE],
21[AC_CHECK_PROGS([PDFLATEX_BINARY], [pdflatex], [no])
22
23 AS_IF([test "x$ac_cv_prog_PDFLATEX_BINARY" = "xno"],
24 [m4_if([$4], ,:,[$4])],
25 [AC_CACHE_CHECK([for the $1 package for LaTeX], [AS_TR_SH([ac_cv_tex_][$2])],
26 [cat <<EOF > conftest.tex
27\\documentclass{article}
28\\usepackage{$2}
29\\begin{document}
30Hello
31\\end{document}
32EOF
33
34 "$ac_cv_prog_PDFLATEX_BINARY" conftest.tex 1>/dev/null 2>&1
35 AS_IF([test "x$?" = "x0"],
36 [AS_VAR_SET([AS_TR_SH([ac_cv_tex_][$2])], [yes])],
37 [AS_VAR_SET([AS_TR_SH([ac_cv_tex_][$2])], [no])])])
38
39 AS_VAR_IF([AS_TR_SH([ac_cv_tex_][$2])], [xyes],
40 [m4_if([$3], ,:,[$3])],
41 [m4_if([$4], ,:,[$4])])])
42])dnl