summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2021-11-24 21:21:32 +0100
committerAlessio Vanni <vannilla@firemail.cc>2021-11-24 21:21:32 +0100
commit0bd99177d2424a76bcf26b5347bfe8ee568348e8 (patch)
tree967868de686d524a2bbd7283cf013a129d48870f
parentf38383e58c2286531359d1b7755e5cb4952543b2 (diff)
-also check for LaTeX packages used by gnunet-bcddev/vanni/bcd-new
Just checking if the command is available is not enough; for example, some people might not have TikZ installed, a package required to draw the logo on the business cards.
-rw-r--r--configure.ac8
-rw-r--r--m4/check-latex-package.m442
2 files changed, 47 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 6ad98cfc2..840bc48d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -265,9 +265,11 @@ AS_IF([test -x "$AWK_BINARY"],
[AC_DEFINE([HAVE_AWK], [1], [Define to 1 if awk is available])],
[AC_DEFINE([HAVE_AWK], [0], [Define to 1 if awk is available])])
-# check for pdflatex to build gnunet-bcd
-AC_CHECK_PROG([PDFLATEX_BINARY], [pdflatex], [true], [false])
-AM_CONDITIONAL([HAVE_PDFLATEX], [$PDFLATEX_BINARY])
+# check for some LaTeX packages used by gnunet-bcd
+CHECK_LATEX_PACKAGE([TikZ], [tikz])
+CHECK_LATEX_PACKAGE([QR Code], [qrcode])
+CHECK_LATEX_PACKAGE([Labels], [labels])
+AM_CONDITIONAL([HAVE_PDFLATEX], [test "x$PDFLATEX_BINARY" != "xno"])
AC_ARG_WITH([gnunet-logread],
[AS_HELP_STRING([--with-gnunet-logread], [Install gnunet-logread])],
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 @@
+dnl
+dnl CHECK_LATEX_PACKAGE(FEATURE-NAME,
+dnl PACKAGE-NAME,
+dnl ACTION-IF-FOUND,
+dnl ACTION-IF-NOT-FOUND)
+dnl
+dnl Tries to compile a small LaTeX document to see if the requested package is
+dnl available to be used with \usepackage.
+dnl
+dnl The result will be cached in the ac_cv_tex_PACKAGE-NAME variable.
+dnl
+dnl This macro also checks for pdflatex as in AC_CHECK_PROGS and the result
+dnl is made available in the PDFLATEX_BINARY variable (all capitals like that.)
+dnl
+dnl FEATURE-NAME is one or more words to identify the check;
+dnl PACKAGE-NAME is the package as it appears in the \usepackage statement
+dnl ACTION-IF-FOUND (optional) commands to execute if the package is installed
+dnl ACTION-IF-NOT-FOUND (optional) the inverse of ACTION-IF-FOUND
+dnl
+AC_DEFUN([CHECK_LATEX_PACKAGE],
+[AC_CHECK_PROGS([PDFLATEX_BINARY], [pdflatex], [no])
+
+ AS_IF([test "x$ac_cv_prog_PDFLATEX_BINARY" = "xno"],
+ [m4_if([$4], ,:,[$4])],
+ [AC_CACHE_CHECK([for the $1 package for LaTeX], [AS_TR_SH([ac_cv_tex_][$2])],
+ [cat <<EOF > conftest.tex
+\\documentclass{article}
+\\usepackage{$2}
+\\begin{document}
+Hello
+\\end{document}
+EOF
+
+ "$ac_cv_prog_PDFLATEX_BINARY" conftest.tex 1>/dev/null 2>&1
+ AS_IF([test "x$?" = "x0"],
+ [AS_VAR_SET([AS_TR_SH([ac_cv_tex_][$2])], [yes])],
+ [AS_VAR_SET([AS_TR_SH([ac_cv_tex_][$2])], [no])])])
+
+ AS_VAR_IF([AS_TR_SH([ac_cv_tex_][$2])], [xyes],
+ [m4_if([$3], ,:,[$3])],
+ [m4_if([$4], ,:,[$4])])])
+])dnl