configure: Allow choice of backend for PDF generation.
authorIan Abbott <abbotti@mev.co.uk>
Wed, 25 Apr 2012 16:14:16 +0000 (17:14 +0100)
committerIan Abbott <abbotti@mev.co.uk>
Wed, 25 Apr 2012 16:14:16 +0000 (17:14 +0100)
Add --with-pdf-backend=[yes|no|dblatex|fop|default] option which
defaults to "yes".  This controls the option passed to 'xmlto' to
generate PDFs.

If set to "yes" (the default) it looks for 'dblatex' and uses it as the
backend for 'xmlto' if found, otherwise 'xmlto' will use the default
backend.

If set to "no" (same as --without-pdf-backend), PDF generation is
disabled.

If set to "dblatex" it looks for 'dblatex' and uses it as the backend
for 'xmlto' if found, otherwise PDF generation is disabled.

If set to "fop" it looks for 'fop' and uses it as the backend
for 'xmlto' if found, otherwise PDF generation is disabled.

If set to "default", 'xmlto' will use the default backend.

configure.ac
doc/Makefile.am

index 900978ee5ffa28fc0e9111112e95920ec8ad27fd..7a7fddc09107b4ac356e2ccb4ae3338f47f1d8f0 100644 (file)
@@ -180,16 +180,53 @@ if test "$ENABLE_DOCBOOK" == "yes"; then
        if test "$XMLTO" = "no" ; then
                AC_MSG_WARN([xmlto not found, will not be able to rebuild documentation])
        fi
-       AC_PATH_PROG(DBLATEX, dblatex, no)
-        if test "$DBLATEX" = "no" ; then
-                AC_MSG_WARN([dblatex not found, will not be able to generate pdfs])
-        fi
 else
        XMLTO="no"
-       DBLATEX="no"
 fi
+
+if test "$XMLTO" != "no"; then
+       AC_ARG_WITH([pdf-backend],
+               [AS_HELP_STRING([--with-pdf-backend=[[yes|no|dblatex|fop|default]]],
+                       [Enable or disable PDF generation with backend])],
+               [WITH_PDF_BACKEND=$withval],[WITH_PDF_BACKEND="yes"])
+       case "$WITH_PDF_BACKEND" in
+       no)
+               PDF_BACKEND="no"
+               ;;
+       yes)
+               # Prefer dblatex, then default backend.
+               # Could use [dblatex fop] to prefer dblatex or fop.
+               AC_CHECK_PROGS([PDF_BACKEND], [dblatex], [default])
+               AC_MSG_NOTICE([Will use $PDF_BACKEND backend for PDF generation])
+               ;;
+       default)
+               # Use xmlto's default backend.
+               PDF_BACKEND="default"
+               ;;
+       dblatex|fop)
+               AC_CHECK_PROG([PDF_BACKEND], [$WITH_PDF_BACKEND],
+                       [$WITH_PDF_BACKEND], [no])
+               if test "$PDF_BACKEND" = "no"; then
+                       AC_MSG_WARN([$WITH_PDF_BACKEND not found, disabling PDF generation])
+               fi
+               ;;
+       *)
+               AC_MSG_WARN([Bad --with-pdf-backend option, disabling PDF generation])
+               PDF_BACKEND="no"
+               ;;
+       esac
+else
+       PDF_BACKEND="no"
+fi
+case $PDF_BACKEND in
+fop|default)
+       AC_MSG_WARN([$PDF_BACKEND PDF backend might not work.  --without-pdf-backend disables PDF generation.])
+       ;;
+esac
 AM_CONDITIONAL(HAVE_XMLTO, [test "$XMLTO" != "no"])
-AM_CONDITIONAL(HAVE_DBLATEX, [test "$DBLATEX" != "no"])
+AM_CONDITIONAL(BUILD_PDF, [test "$PDF_BACKEND" != "no"])
+AM_CONDITIONAL(BUILD_PDF_USING_DBLATEX, [test "$PDF_BACKEND" = "dblatex"])
+AM_CONDITIONAL(BUILD_PDF_USING_FOP, [test "$PDF_BACKEND" = "fop"])
 
 pcmciadir="\${sysconfdir}/pcmcia"
 AC_SUBST(pcmciadir)
index 2bdb0619d50e44e66ece272387f14e9dc745ef65..117e11df8b38612a21c7a7ca1aa2c3dde7ba45c5 100644 (file)
@@ -19,13 +19,6 @@ if HAVE_XMLTO
 all_html = $(srcdir)/doc_html
 install_html = install_html
 uninstall_html = uninstall_html
-
-if HAVE_DBLATEX
-dist_pdf_DATA = $(srcdir)/pdf/comedilib.pdf
-else
-dist_pdf_DATA =
-endif
-
 all_man = $(srcdir)/man
 install_man = install_man
 uninstall_man = uninstall_man
@@ -33,14 +26,27 @@ else
 all_html =
 install_html =
 uninstall_html =
-
-dist_pdf_DATA =
-
 all_man =
 install_man =
 uninstall_man =
 endif
 
+if BUILD_PDF
+dist_pdf_DATA = $(srcdir)/pdf/comedilib.pdf
+else
+dist_pdf_DATA =
+endif
+
+if BUILD_PDF_USING_DBLATEX
+XMLTO_PDF_WITH = --with-dblatex
+else
+if BUILD_PDF_USING_FOP
+XMLTO_PDF_WITH = --with-fop
+else
+XMLTO_PDF_WITH =
+endif
+endif
+
 all-local: $(all_html) $(all_man)
 
 install-data-local: $(install_html) $(install_man)
@@ -77,8 +83,7 @@ uninstall_man:
        for each in `find $(srcdir)/man/ -name '*.3'`; do $(RM) $(DESTDIR)$(mandir)/man3/`basename $$each` ; done
 
 $(srcdir)/pdf/comedilib.pdf: $(XML)
-       $(mkdir_p) $(srcdir)/pdf
-       $(DBLATEX) -o $(srcdir)/pdf -t pdf $(srcdir)/comedilib.xml
+       $(XMLTO) -o $(srcdir)/pdf --skip-validation $(XMLTO_PDF_WITH) pdf $(srcdir)/comedilib.xml
 
 funcref.xml: funcref mkref
        $(srcdir)/mkref $(srcdir)/funcref >$(srcdir)/funcref.xml