]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Build system: Improvements for ./configure script
authorTill Kamppeter <till.kamppeter@gmail.com>
Thu, 1 Sep 2022 21:58:21 +0000 (23:58 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 1 Sep 2022 21:58:21 +0000 (23:58 +0200)
- Make sure that always a valid PDF-to-PostScript renderer is
  selected, especially if one or another renderer is disabled, like
  "hybrid" ("--with-pdftops=hybrid") does not make sense if Ghostscipt
  is disabled ("--disable ghostscript"). In this case the first valid
  renderer found will beused.

- In the summary at the end report which PDF-to-PostScript renderer
  gets actually used.

- Changed oder of treating the PDF-to-PostScript renderer, so that as
  first choice Ghostscript would be taken and as second choice
  Poppler's pdftops.

- Generate for each supported PDF renderer a "HAVE_..." macro in
  config.h, for easily excluding unnecessary code.

configure.ac
cupsfilters/universal.c
mime/cupsfilters-universal-postscript.convs [new file with mode: 0644]
mime/cupsfilters-universal.convs

index d1940502d29217475699507981924de4c539afcb..8f86036f96eb3623a1c3fbc77940bec149222aaf 100644 (file)
@@ -552,21 +552,6 @@ AS_IF([test x"$long_long_found" = "xyes"], [
        AC_DEFINE([HAVE_LONG_LONG], [], [Platform supports long long type])
 ])
 
-# ================
-# Check for Mutool
-# ================
-AC_ARG_ENABLE([mutool],
-       [AS_HELP_STRING([--disable-mutool], [Disable filters using mutool.])],
-       [enable_mutool="$enableval"],
-       [enable_mutool=yes]
-)
-
-AC_ARG_WITH([mutool-path],
-       [AS_HELP_STRING([--with-mutool-path=value], [Set path to mutool binary (default: system).])],
-       [with_mutool_path="$withval"],
-       [with_mutool_path=system]
-)
-
 # ================
 # Check for pdf2ps
 # ================
@@ -575,6 +560,11 @@ AC_ARG_ENABLE([ghostscript],
        [enable_ghostscript="$enableval"],
        [enable_ghostscript=yes]
 )
+AC_ARG_ENABLE([pdftops],
+       [AS_HELP_STRING([--disable-pdftops], [Disable filters using Poppler's pdftops.])],
+       [enable_pdftops="$enableval"],
+       [enable_pdftops=yes]
+)
 AC_ARG_WITH([pdftops],
        [AS_HELP_STRING([--with-pdftops=value], [Set which pdftops to use (gs,pdftops,pdftocairo,acroread,mupdf,hybrid).])],
        [with_pdftops="$withval"],
@@ -625,6 +615,8 @@ AC_ARG_ENABLE([gs-ps2write],
        [enable_gs_ps2write=yes]
 )
 
+CUPS_PDFTOPS_RENDERER=""
+
 CUPS_GHOSTSCRIPT=""
 AS_IF([test "x$enable_ghostscript" != "xyes"], [
        with_gs_path=""
@@ -642,7 +634,7 @@ AS_IF([test "x$enable_ghostscript" != "xyes"], [
                AC_MSG_ERROR([Required gs binary is missing. Please install ghostscript package.])
        ])
        AC_DEFINE([HAVE_GHOSTSCRIPT], [], [Define that we provide ghostscript binary])
-       AS_IF([test x"$with_pdftops" = xgs], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [GS], [Define default renderer])])
+       AS_IF([test x"$with_pdftops" = xgs -o x"$CUPS_PDFTOPS_RENDERER" = x], [CUPS_PDFTOPS_RENDERER=GS])
 
        AS_IF([test "x$cross_compiling" != "xyes"], [
                AC_MSG_CHECKING(whether gs supports the ps2write device)
@@ -660,6 +652,59 @@ AS_IF([test "x$enable_ghostscript" != "xyes"], [
 AM_CONDITIONAL(ENABLE_GHOSTSCRIPT, test "x$enable_ghostscript" = xyes)
 AC_SUBST(CUPS_GHOSTSCRIPT)
 
+AS_IF([test "x$enable_pdftops" != "xyes"], [
+       with_pdftops_path=""
+], [
+       AS_IF([test "x$with_pdftops_path" != "xsystem"], [
+               CUPS_PDFTOPS="$with_pdftops_path"
+       ], [
+               AS_IF([test "x$cross_compiling" = "xyes"], [
+                       CUPS_PDFTOPS="/usr/bin/pdftops"
+               ], [
+                       AC_CHECK_PROG(CUPS_PDFTOPS, pdftops, /usr/bin/pdftops)
+               ])
+               AS_IF([test "x$CUPS_PDFTOPS" = "x"], [
+                       AC_MSG_ERROR([Required pdftops is missing. Please install the pdftops utility of Poppler.])
+               ])
+       ])
+       AS_IF([test "x$CUPS_PDFTOPS" != "x"], [
+               AC_DEFINE([HAVE_POPPLER_PDFTOPS], [], [Define that we provide poppler pdftops.])
+               AS_IF([test x"$with_pdftops" = xpdftops -o x"$CUPS_PDFTOPS_RENDERER" = x], [CUPS_PDFTOPS_RENDERER=PDFTOPS])
+
+               AS_IF([test "x$cross_compiling" != "xyes"], [
+                       AC_MSG_CHECKING([whether pdftops supports -origpagesizes])
+                       AS_IF([`$CUPS_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes`], [
+                               AC_MSG_RESULT([yes])
+                               AC_DEFINE([HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES], [] , [pdftops supports -origpagesizes.])
+                       ], [
+                               AC_MSG_RESULT([no])
+                       ])
+                       AC_MSG_CHECKING([whether pdftops supports -r])
+                       AS_IF([`$CUPS_PDFTOPS -h 2>&1 | grep -q -- '-r '`], [
+                               AC_MSG_RESULT([yes])
+                               AC_DEFINE([HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION], [] , [pdftops supports -r argument.])
+                       ], [
+                               AC_MSG_RESULT([no])
+                       ])
+               ])
+       ])
+])
+
+# ================
+# Check for Mutool
+# ================
+AC_ARG_ENABLE([mutool],
+       [AS_HELP_STRING([--disable-mutool], [Disable filters using mutool.])],
+       [enable_mutool="$enableval"],
+       [enable_mutool=yes]
+)
+
+AC_ARG_WITH([mutool-path],
+       [AS_HELP_STRING([--with-mutool-path=value], [Set path to mutool binary (default: system).])],
+       [with_mutool_path="$withval"],
+       [with_mutool_path=system]
+)
+
 CUPS_MUTOOL=""
 AS_IF([test "x$enable_mutool" != "xyes"], [
        with_mutool_path=""
@@ -676,72 +721,66 @@ AS_IF([test "x$enable_mutool" != "xyes"], [
        AS_IF([test "x$CUPS_MUTOOL" = "x"], [
                AC_MSG_ERROR([Required mutool binary is missing. Please install mutool.])
        ])
-       AS_IF([test x"$with_pdftops" = xmupdf], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [MUPDF], [Define default renderer])])
+       AC_DEFINE([HAVE_MUTOOL], [], [Define that we provide mutool binary])
+       AS_IF([test x"$with_pdftops" = xmupdf -o x"$CUPS_PDFTOPS_RENDERER" = x], [CUPS_PDFTOPS_RENDERER=MUPDF])
 ])
 AM_CONDITIONAL(ENABLE_MUTOOL, test "x$enable_mutool" = xyes)
 AC_SUBST(CUPS_MUTOOL)
 
-AS_IF([test "x$with_pdftops_path" != "xsystem"], [
-       CUPS_PDFTOPS="$with_pdftops_path"
+AC_ARG_ENABLE([pdftocairo],
+       [AS_HELP_STRING([--disable-pdftocairo], [Disable filters using pdftocairo.])],
+       [enable_pdftocairo="$enableval"],
+       [enable_pdftocairo=yes]
+)
+
+CUPS_PDFTOCAIRO=""
+AS_IF([test "x$enable_pdftocairo" != "xyes"], [
+       with_pdftocairo_path=""
 ], [
-       AS_IF([test "x$cross_compiling" = "xyes"], [
-               CUPS_PDFTOPS="/usr/bin/pdftops"
+       AS_IF([test "x$with_pdftocairo_path" != "xsystem"], [
+               CUPS_PDFTOCAIRO="$with_pdftocairo_path"
        ], [
-               AC_CHECK_PROG(CUPS_PDFTOPS, pdftops, /usr/bin/pdftops)
+               CUPS_PDFTOCAIRO="pdftocairo"
        ])
-       AS_IF([test "x$CUPS_PDFTOPS" = "x"], [
-               AC_MSG_ERROR([Required pdftops is missing. Please install the pdftops utility of Poppler.])
+       AS_IF([test "x$CUPS_PDFTOCAIRO" != "x"], [
+               AC_DEFINE([HAVE_PDFTOCAIRO], [], [Define that we provide pdftocairo binary])
+               AS_IF([test x"$with_pdftops" = xpdftocairo -o x"$CUPS_PDFTOPS_RENDERER" = x], [CUPS_PDFTOPS_RENDERER=PDFTOCAIRO])
+       ], [
+               AC_MSG_ERROR([Required pdftocairo is missing. Please install Poppler developer packages.])
        ])
 ])
-AS_IF([test "x$CUPS_PDFTOPS" != "x"], [
-       AC_DEFINE([HAVE_POPPLER_PDFTOPS], [], [Define that we provide poppler pdftops.])
-       AS_IF([test x"$with_pdftops" = xpdftops], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [PDFTOPS], [Define default renderer])])
 
-       AS_IF([test "x$cross_compiling" != "xyes"], [
-               AC_MSG_CHECKING([whether pdftops supports -origpagesizes])
-               AS_IF([`$CUPS_PDFTOPS -h 2>&1 | grep -q -- -origpagesizes`], [
-                       AC_MSG_RESULT([yes])
-                       AC_DEFINE([HAVE_POPPLER_PDFTOPS_WITH_ORIGPAGESIZES], [] , [pdftops supports -origpagesizes.])
-               ], [
-                       AC_MSG_RESULT([no])
-               ])
-               AC_MSG_CHECKING([whether pdftops supports -r])
-               AS_IF([`$CUPS_PDFTOPS -h 2>&1 | grep -q -- '-r '`], [
-                       AC_MSG_RESULT([yes])
-                       AC_DEFINE([HAVE_POPPLER_PDFTOPS_WITH_RESOLUTION], [] , [pdftops supports -r argument.])
-               ], [
-                       AC_MSG_RESULT([no])
-               ])
-       ])
-])
-AS_IF([test "x$with_pdftocairo_path" != "xsystem"], [
-       CUPS_PDFTOCAIRO="$with_pdftocairo_path"
-], [
-       CUPS_PDFTOCAIRO="pdftocairo"
-])
-AS_IF([test "x$CUPS_PDFTOCAIRO" != "x"], [
-       AS_IF([test x"$with_pdftops" = xpdftocairo], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [PDFTOCAIRO], [Define default renderer])])
-], [
-       AC_MSG_ERROR([Required pdftocairo is missing. Please install Poppler developer packages.])
-])
-AS_IF([test "x$with_acroread_path" != "xsystem"], [
-       CUPS_ACROREAD="$with_acroread_path"
+AC_ARG_ENABLE([acroread],
+       [AS_HELP_STRING([--disable-acroread], [Disable filters using acroread.])],
+       [enable_acroread="$enableval"],
+       [enable_acroread=yes]
+)
+
+CUPS_ACROREAD=""
+AS_IF([test "x$enable_acroread" != "xyes"], [
+       with_acroread_path=""
 ], [
-       CUPS_ACROREAD="acroread"
+       AS_IF([test "x$with_acroread_path" != "xsystem"], [
+               CUPS_ACROREAD="$with_acroread_path"
+       ], [
+               CUPS_ACROREAD="acroread"
+       ])
+       AS_IF([test "x$CUPS_ACROREAD" != "x"], [
+               AC_DEFINE([HAVE_ACROREAD], [], [Define that we provide acroread binary])
+               AS_IF([test x"$with_pdftops" = xacroread -o x"$CUPS_PDFTOPS_RENDERER" = x], [CUPS_PDFTOPS_RENDERER=ACROREAD])
+       ])
 ])
-AS_IF([test "x$CUPS_ACROREAD" != "x"], [
-       AS_IF([test x"$with_pdftops" = xacroread], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [ACROREAD], [Define default renderer])])
+
+AS_IF([test "x$CUPS_GHOSTSCRIPT" != "x" -a "x$CUPS_PDFTOPS" != "x"], [
+       AS_IF([test x"$with_pdftops" = xhybrid -o x"$CUPS_PDFTOPS_RENDERER" = x], [CUPS_PDFTOPS_RENDERER=HYBRID])
 ])
+
 AS_IF([test "x$with_ippfind_path" != "xsystem"], [
        CUPS_IPPFIND="$with_ippfind_path"
 ], [
        CUPS_IPPFIND="ippfind"
 ])
 
-AS_IF([test "x$CUPS_GHOSTSCRIPT" != "x" -a "x$CUPS_PDFTOPS" != "x"], [
-       AS_IF([test x"$with_pdftops" = xhybrid], [AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [HYBRID], [Define default renderer])])
-])
-
 AC_DEFINE_UNQUOTED([CUPS_GHOSTSCRIPT], "$CUPS_GHOSTSCRIPT", [gs binary to use])
 AC_DEFINE_UNQUOTED([CUPS_MUTOOL],"$CUPS_MUTOOL",[mutool binary to use])
 AC_DEFINE_UNQUOTED([CUPS_POPPLER_PDFTOPS], "$CUPS_PDFTOPS", [pdftops binary to use.])
@@ -749,6 +788,7 @@ AC_DEFINE_UNQUOTED([CUPS_POPPLER_PDFTOCAIRO], "$CUPS_PDFTOCAIRO", [pdftocairo bi
 AC_DEFINE_UNQUOTED([CUPS_ACROREAD], "$CUPS_ACROREAD", [acroread binary to use.])
 AC_DEFINE_UNQUOTED([CUPS_IPPFIND], "$CUPS_IPPFIND", [ippfind binary to use.])
 AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_MAX_RESOLUTION], [$CUPS_PDFTOPS_MAXRES], [max resolution used for pdftops when converting images])
+AC_DEFINE_UNQUOTED([CUPS_PDFTOPS_RENDERER], [$CUPS_PDFTOPS_RENDERER], [Define default renderer])
 
 # ==================
 # Check for foomatic
@@ -1003,8 +1043,12 @@ Build configuration:
        imagefilters:    ${enable_imagefilters}
        jpeg:            ${with_jpeg}
        exif:            ${enable_exif}
+       pdftocairo:      ${enable_pdftocairo}
        pdftocairo-path: ${with_pdftocairo_path}
-       pdftops:         ${with_pdftops}
+       acroread:        ${enable_acroread}
+       acroread-path:   ${with_acroread_path}
+       pdftops:         ${CUPS_PDFTOPS_RENDERER}
+       Poppler's pdftops: ${enable_pdftops}
        pdftops-path:    ${with_pdftops_path}
        png:             ${with_png}
        php:             ${with_php}
@@ -1023,7 +1067,6 @@ Build configuration:
        universal CUPS filter: ${enable_universal_cups_filter}
        individual CUPS filters: ${enable_individual_cups_filters}
        driverless:      ${enable_driverless}
-       pclm:            ${enable_pclm}
        ppdc utilities:  ${enable_ppdc_utils}
        local queue naming for remote CUPS queues: ${REMOTE_CUPS_LOCAL_QUEUE_NAMING}
        keep generated queues during shutdown:     ${SAVING_CREATED_QUEUES}
index 7b398b7df48cbe1ed46e3eb9b64eb6dc9dd6edf0..63d4a68569663a44a462d4728c0e40dec74103eb 100644 (file)
@@ -154,6 +154,7 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
   }
   else
   {
+#ifdef HAVE_GHOSTSCRIPT
     if (!strcasecmp(input, "application/postscript"))
     {
       outformat = malloc(sizeof(cf_filter_out_format_t));
@@ -166,8 +167,10 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterUniversal: Adding %s to chain", filter->name);
     }
-    else if (!strcasecmp(input_super, "text") ||
-            (!strcasecmp(input_super, "application") && input_type[0] == 'x'))
+    else
+#endif /* HAVE_GHOSTSCRIPT */
+    if (!strcasecmp(input_super, "text") ||
+       (!strcasecmp(input_super, "application") && input_type[0] == 'x'))
     {
       filter = malloc(sizeof(cf_filter_filter_in_chain_t));
       cf_filter_texttopdf_parameter_t* tparameters =
@@ -195,6 +198,7 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
       if (log) log(ld, CF_LOGLEVEL_DEBUG,
                   "cfFilterUniversal: Adding %s to chain", filter->name);
     }
+#ifdef HAVE_GHOSTSCRIPT
     else if (!strcasecmp(input_type, "vnd.adobe-reader-postscript"))
     {
       outformat = malloc(sizeof(cf_filter_out_format_t));
@@ -228,6 +232,7 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
                     "cfFilterUniversal: Adding %s to chain", filter->name);
       }
     }
+#endif /* HAVE_GHOSTSCRIPT */
     else if (!strcasecmp(input, "application/vnd.cups-pdf-banner"))
     {
       filter = malloc(sizeof(cf_filter_filter_in_chain_t));
@@ -266,6 +271,7 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
                     "cfFilterUniversal: Adding %s to chain", filter->name);
       }
 
+#if defined(HAVE_GHOSTSCRIPT) || defined(HAVE_POPPLER_PDFTOPS)
       if (strcasecmp(output_type, "vnd.cups-pdf"))
       {
        if (!strcasecmp(output_type, "vnd.cups-raster") ||
@@ -273,6 +279,7 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
            !strcasecmp(output_type, "pwg-raster") ||
            !strcasecmp(output_type, "PCLm"))
        {
+#  ifdef HAVE_GHOSTSCRIPT
          outformat = malloc(sizeof(cf_filter_out_format_t));
          *outformat = CF_FILTER_OUT_FORMAT_CUPS_RASTER;
          if (!strcasecmp(output_type, "pwg-raster"))
@@ -289,13 +296,40 @@ cfFilterUniversal(int inputfd,         /* I - File descriptor input stream */
          if (log) log(ld, CF_LOGLEVEL_DEBUG,
                       "cfFilterUniversal: Adding %s to chain",
                       filter->name);
+#  else
+#    ifdef HAVE_POPPLER_PDFTOPS
+         filter = malloc(sizeof(cf_filter_filter_in_chain_t));
+         filter->function = cfFilterPDFToRaster;
+         filter->parameters = NULL;
+         filter->name = "pdftoraster";
+         cupsArrayAdd(filter_chain, filter);
+         if (log) log(ld, CF_LOGLEVEL_DEBUG,
+                      "cfFilterUniversal: Adding %s to chain",
+                      filter->name);
+         if (!strcasecmp(output_type, "PCLm"))
+         {
+           outformat = malloc(sizeof(cf_filter_out_format_t));
+           *outformat = CF_FILTER_OUT_FORMAT_PCLM;
+           filter = malloc(sizeof(cf_filter_filter_in_chain_t));
+           filter->function = cfFilterRasterToPDF;
+           filter->parameters = outformat;
+           filter->name = "rastertopclm";
+           cupsArrayAdd(filter_chain, filter);
+           if (log) log(ld, CF_LOGLEVEL_DEBUG,
+                        "cfFilterUniversal: Adding %s to chain", filter->name);
+         }
+#    endif /* HAVE_POPPLER_PDFTOPS */
+#  endif /* HAVE_GHOSTSCRIPT */
        }
        else
        {
+#endif /* HAVE_GHOSTSCRIPT || HAVE_POPPLER_PDFTOPS */
          // Output format is not PDF and unknown -> Error
          ret = 1;
          goto out;
+#if defined(HAVE_GHOSTSCRIPT) || defined(HAVE_POPPLER_PDFTOPS)
        }
+#endif /* HAVE_GHOSTSCRIPT || HAVE_POPPLER_PDFTOPS */
       }
     }
   }
diff --git a/mime/cupsfilters-universal-postscript.convs b/mime/cupsfilters-universal-postscript.convs
new file mode 100644 (file)
index 0000000..970f735
--- /dev/null
@@ -0,0 +1,47 @@
+#
+#   MIME conversions file for OpenPrinting CUPS Filters.
+#
+#   Copyright 2007-2011 by Apple Inc.
+#   Copyright 1997-2007 by Easy Software Products.
+#   Copyright 2012-2016 by Till Kamppeter.
+#   Copyright 2017 by Sahil Arora.
+#
+#   These coded instructions, statements, and computer programs are the
+#   property of Apple Inc. and are protected by Federal copyright
+#   law.  Distribution and use rights are outlined in the file "COPYING"
+#   which should have been included with this file.
+#
+
+########################################################################
+#
+# Format of Lines:
+#
+#   source/type destination/type cost filter
+#
+# General Notes:
+#
+#   The "cost" field is used to find the least costly filters to run
+#   when converting a job file to a printable format.
+#
+#   All filters *must* accept the standard command-line arguments
+#   (job-id, user, title, copies, options, [filename or stdin]) to
+#   work with CUPS.
+#
+
+########################################################################
+#
+# Input formats
+#
+
+application/postscript                   application/vnd.universal-input   0  -
+
+# CUPS file conversion rules for PostScript input when we are working
+# with the PDF printing workflow: General PostScript input should be
+# converted to PDF, so that pdftopdf() is doing the page management on
+# PDF data and the renderer/driver part renders PDF. An exception is
+# made for PostScript coming from the Adobe Reader. As this PostScript
+# cannot be converted to PDF if it comes from an encrypted PDF file,
+# we simply override pstopdf() and the PDF workflow.
+
+application/vnd.adobe-reader-postscript  application/vnd.universal-input   0  -
+
index 5bd2797a2b3ab942664c12017abd6dd7125fdf98..a23f62b524531ea746006c0a6de7938767f41f53 100644 (file)
@@ -52,22 +52,11 @@ image/pwg-raster                application/vnd.universal-input      0    -
 application/vnd.cups-pdf        application/vnd.universal-input      0    -
 application/vnd.cups-raster     application/vnd.universal-input      0    -
 image/urf                       application/vnd.universal-input      0    -
-application/postscript          application/vnd.universal-input      0    -
 application/pdf                 application/vnd.universal-input      0    -
 text/plain                      application/vnd.universal-input      0    -
 application/PCLm                application/vnd.universal-input      0    -
 application/vnd.cups-pdf-banner application/vnd.universal-input      0    -
 
-# CUPS file conversion rules for PostScript input when we are working
-# with the PDF printing workflow: General PostScript input should be
-# converted to PDF, so that pdftopdf() is doing the page management on
-# PDF data and the renderer/driver part renders PDF. An exception is
-# made for PostScript coming from the Adobe Reader. As this PostScript
-# cannot be converted to PDF if it comes from an encrypted PDF file,
-# we simply override pstopdf() and the PDF workflow.
-
-application/vnd.adobe-reader-postscript  application/vnd.universal-input   0  -
-
 ########################################################################
 #
 # Output formats