From 01b471ed52133d2dc981be6e40dda42c3fd3600a Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Wed, 13 Sep 2023 16:07:49 -0400 Subject: [PATCH] Add support for old cups-config script. --- .github/workflows/build.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/coverity.yml | 2 +- configure | 151 +++++++++++++++++++++++++++++++-- configure.ac | 28 ++++-- 5 files changed, 167 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d9a36faa..1df71211 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: - name: update build environment run: sudo apt-get update --fix-missing -y - name: install prerequisites - run: sudo apt-get install -y cppcheck libfltk1.3-dev libgnutls28-dev libjpeg-dev libpng-dev zlib1g-dev + run: sudo apt-get install -y cppcheck libfltk1.3-dev libcups2-dev libgnutls28-dev libjpeg-dev libpng-dev zlib1g-dev - name: configure env: CC: /usr/bin/gcc diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 8cb52bb2..d90c6745 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -30,7 +30,7 @@ jobs: run: sudo apt-get update --fix-missing -y - name: Install prerequisites - run: sudo apt-get install -y libfltk1.3-dev libgnutls28-dev libjpeg-dev libpng-dev zlib1g-dev + run: sudo apt-get install -y libfltk1.3-dev libcups2-dev libgnutls28-dev libjpeg-dev libpng-dev zlib1g-dev - name: Initialize CodeQL uses: github/codeql-action/init@v2 diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index c269998e..408adb25 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -11,7 +11,7 @@ jobs: - name: update build environment run: sudo apt-get update --fix-missing -y - name: install prerequisites - run: sudo apt-get install -y libfltk1.3-dev libgnutls28-dev libjpeg-dev libpng-dev zlib1g-dev + run: sudo apt-get install -y libfltk1.3-dev libcups2-dev libgnutls28-dev libjpeg-dev libpng-dev zlib1g-dev - name: Download Coverity Build Tool run: | wget -q https://scan.coverity.com/download/linux64 --post-data token="$TOKEN&project=$GITHUB_REPOSITORY" -O cov-analysis-linux64.tar.gz diff --git a/configure b/configure index 37cd3a2e..4c3e4220 100755 --- a/configure +++ b/configure @@ -651,6 +651,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS WARNINGS POST +CUPSCONFIG LARGEFILE ARFLAGS PKGCONFIG @@ -5031,21 +5032,153 @@ then : fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libcups" >&5 -printf %s "checking for libcups... " >&6; } -if $PKGCONFIG --exists cups +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cups-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}cups-config; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_CUPSCONFIG+y} then : + printf %s "(cached) " >&6 +else $as_nop + case $CUPSCONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_CUPSCONFIG="$CUPSCONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_CUPSCONFIG="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +CUPSCONFIG=$ac_cv_path_CUPSCONFIG +if test -n "$CUPSCONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CUPSCONFIG" >&5 +printf "%s\n" "$CUPSCONFIG" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -printf "%s\n" "yes" >&6; }; - CPPFLAGS="$($PKGCONFIG --cflags cups) $CPPFLAGS" - LIBS="$($PKGCONFIG --libs cups) $LIBS" +fi +if test -z "$ac_cv_path_CUPSCONFIG"; then + ac_pt_CUPSCONFIG=$CUPSCONFIG + # Extract the first word of "cups-config", so it can be a program name with args. +set dummy cups-config; ac_word=$2 +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +printf %s "checking for $ac_word... " >&6; } +if test ${ac_cv_path_ac_pt_CUPSCONFIG+y} +then : + printf %s "(cached) " >&6 else $as_nop + case $ac_pt_CUPSCONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_CUPSCONFIG="$ac_pt_CUPSCONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + case $as_dir in #((( + '') as_dir=./ ;; + */) ;; + *) as_dir=$as_dir/ ;; + esac + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then + ac_cv_path_ac_pt_CUPSCONFIG="$as_dir$ac_word$ac_exec_ext" + printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_CUPSCONFIG=$ac_cv_path_ac_pt_CUPSCONFIG +if test -n "$ac_pt_CUPSCONFIG"; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_pt_CUPSCONFIG" >&5 +printf "%s\n" "$ac_pt_CUPSCONFIG" >&6; } +else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } +fi + + if test "x$ac_pt_CUPSCONFIG" = x; then + CUPSCONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CUPSCONFIG=$ac_pt_CUPSCONFIG + fi +else + CUPSCONFIG="$ac_cv_path_CUPSCONFIG" +fi + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CUPS library v2.2 or higher" >&5 +printf %s "checking for CUPS library v2.2 or higher... " >&6; } +if $PKGCONFIG --exists cups +then : + + CUPS_VERSION="$($PKGCONFIG --modversion cups)" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, v$CUPS_VERSION" >&5 +printf "%s\n" "yes, v$CUPS_VERSION" >&6; } + + CPPFLAGS="$CPPFLAGS $($PKGCONFIG --cflags cups)" + LIBS="$LIBS $($PKGCONFIG --libs cups)" + +elif test "x$CUPSCONFIG" = x +then : { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 -printf "%s\n" "no" >&6; }; - as_fn_error $? "HTMLDOC requires the CUPS libraries for HTTP/HTTPS support." "$LINENO" 5 +printf "%s\n" "no" >&6; } + as_fn_error $? "Sorry, this software requires libcups-dev." "$LINENO" 5 + +else $as_nop + + CUPS_VERSION="$($CUPSCONFIG --api-version)" + case "$CUPS_VERSION" in #( + 1.* | 2.0 | 2.1) : + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 +printf "%s\n" "no" >&6; } + as_fn_error $? "Sorry, you need CUPS 2.2.0 or higher." "$LINENO" 5 + ;; #( + *) : + ;; +esac + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, v$CUPS_VERSION" >&5 +printf "%s\n" "yes, v$CUPS_VERSION" >&6; } + + CPPFLAGS="$CPPFLAGS $($CUPSCONFIG --cflags)" + LDFLAGS="$LDFLAGS $($CUPSCONFIG --ldflags)" + LIBS="$LIBS $($CUPSCONFIG --libs)" fi diff --git a/configure.ac b/configure.ac index 9cb50dfd..0b11bdfb 100644 --- a/configure.ac +++ b/configure.ac @@ -170,14 +170,30 @@ AS_IF([test $ac_cv_c_long_long = yes], [ AC_CHECK_FUNC(strtoll, AC_DEFINE(HAVE_STRTOLL)) dnl Check for CUPS libraries... -AC_MSG_CHECKING([for libcups]) +AC_PATH_TOOL([CUPSCONFIG], [cups-config]) +AC_MSG_CHECKING([for CUPS library v2.2 or higher]) AS_IF([$PKGCONFIG --exists cups], [ - AC_MSG_RESULT([yes]); - CPPFLAGS="$($PKGCONFIG --cflags cups) $CPPFLAGS" - LIBS="$($PKGCONFIG --libs cups) $LIBS" + CUPS_VERSION="$($PKGCONFIG --modversion cups)" + AC_MSG_RESULT([yes, v$CUPS_VERSION]) + + CPPFLAGS="$CPPFLAGS $($PKGCONFIG --cflags cups)" + LIBS="$LIBS $($PKGCONFIG --libs cups)" +], [test "x$CUPSCONFIG" = x], [ + AC_MSG_RESULT(no) + AC_MSG_ERROR([Sorry, this software requires libcups-dev.]) ], [ - AC_MSG_RESULT([no]); - AC_MSG_ERROR([HTMLDOC requires the CUPS libraries for HTTP/HTTPS support.]) + CUPS_VERSION="$($CUPSCONFIG --api-version)" + AS_CASE(["$CUPS_VERSION"], + [1.* | 2.0 | 2.1], [ + AC_MSG_RESULT(no) + AC_MSG_ERROR([Sorry, you need CUPS 2.2.0 or higher.]) + ]) + + AC_MSG_RESULT([yes, v$CUPS_VERSION]) + + CPPFLAGS="$CPPFLAGS $($CUPSCONFIG --cflags)" + LDFLAGS="$LDFLAGS $($CUPSCONFIG --ldflags)" + LIBS="$LIBS $($CUPSCONFIG --libs)" ]) dnl Check for GUI libraries...