]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Modernize the cups-threads autoconf source file.
authorMichael R Sweet <msweet@msweet.org>
Sat, 6 Mar 2021 16:13:03 +0000 (11:13 -0500)
committerMichael R Sweet <msweet@msweet.org>
Sat, 6 Mar 2021 16:13:03 +0000 (11:13 -0500)
config-scripts/cups-threads.m4
configure

index f054899f62e294ce812d00e739f6815cd1ee489d..ee308ea2bc8caf57550ee8c40489b072871dabed 100644 (file)
@@ -1,44 +1,52 @@
 dnl
 dnl Threading stuff for CUPS.
 dnl
-dnl Copyright 2007-2017 by Apple Inc.
-dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
+dnl Copyright © 2021 by OpenPrinting.
+dnl Copyright © 2007-2017 by Apple Inc.
+dnl Copyright © 1997-2005 by Easy Software Products, all rights reserved.
 dnl
 dnl Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
 dnl
 
-AC_ARG_ENABLE(threads, [  --disable-threads       disable multi-threading support])
+AC_ARG_ENABLE([threads], AS_HELP_STRING([--disable-threads], [disable multi-threading support]))
 
-have_pthread=no
+have_pthread="no"
 PTHREAD_FLAGS=""
 
-if test "x$enable_threads" != xno; then
-       AC_CHECK_HEADER(pthread.h, AC_DEFINE(HAVE_PTHREAD_H))
+AS_IF([test "x$enable_threads" != xno], [
+    AC_CHECK_HEADER([pthread.h], [
+        AC_DEFINE([HAVE_PTHREAD_H], [1], [Do we have the <pthread.h> header?])
+    ])
 
-       if test x$ac_cv_header_pthread_h = xyes; then
-               dnl Check various threading options for the platforms we support
-               for flag in -lpthreads -lpthread -pthread; do
-                       AC_MSG_CHECKING([for pthread_create using $flag])
-                       SAVELIBS="$LIBS"
-                       LIBS="$flag $LIBS"
-                       AC_TRY_LINK([#include <pthread.h>],
-                               [pthread_create(0, 0, 0, 0);],
-                               have_pthread=yes,
-                               LIBS="$SAVELIBS")
-                       AC_MSG_RESULT([$have_pthread])
+    AS_IF([test x$ac_cv_header_pthread_h = xyes], [
+       dnl Check various threading options for the platforms we support
+       for flag in -lpthreads -lpthread -pthread; do
+           AC_MSG_CHECKING([for pthread_create using $flag])
+           SAVELIBS="$LIBS"
+           LIBS="$flag $LIBS"
+           AC_LINK_IFELSE([
+               AC_LANG_PROGRAM([[#include <pthread.h>]], [[
+                   pthread_create(0, 0, 0, 0);
+               ]])
+           ], [
+               have_pthread="yes"
+           ], [
+               LIBS="$SAVELIBS"
+           ])
+           AC_MSG_RESULT([$have_pthread])
 
-                       if test $have_pthread = yes; then
-                               PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
+           AS_IF([test $have_pthread = yes], [
+               PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
 
-                               # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
-                               # be POSIX-compliant... :(
-                               if test $host_os_name = sunos; then
-                                       PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
-                               fi
-                               break
-                       fi
-               done
-       fi
-fi
+               # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to be POSIX-
+               compliant... :(
+               AS_IF([test $host_os_name = sunos], [
+                   PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
+               ])
+               break
+           ])
+       done
+    ])
+])
 
-AC_SUBST(PTHREAD_FLAGS)
+AC_SUBST([PTHREAD_FLAGS])
index ae710b3935d23f6408ea68f63a9b97175df1d132..e7f3f6f1db1bea752445d3c5afe7cfa0aae73951 100755 (executable)
--- a/configure
+++ b/configure
@@ -9340,58 +9340,81 @@ then :
 fi
 
 
-have_pthread=no
+have_pthread="no"
 PTHREAD_FLAGS=""
 
-if test "x$enable_threads" != xno; then
-       ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
+if test "x$enable_threads" != xno
+then :
+
+    ac_fn_c_check_header_compile "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
 if test "x$ac_cv_header_pthread_h" = xyes
 then :
-  printf "%s\n" "#define HAVE_PTHREAD_H 1" >>confdefs.h
+
+
+printf "%s\n" "#define HAVE_PTHREAD_H 1" >>confdefs.h
+
 
 fi
 
 
-       if test x$ac_cv_header_pthread_h = xyes; then
-                               for flag in -lpthreads -lpthread -pthread; do
-                       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_create using $flag" >&5
+    if test x$ac_cv_header_pthread_h = xyes
+then :
+
+               for flag in -lpthreads -lpthread -pthread; do
+           { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_create using $flag" >&5
 printf %s "checking for pthread_create using $flag... " >&6; }
-                       SAVELIBS="$LIBS"
-                       LIBS="$flag $LIBS"
-                       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+           SAVELIBS="$LIBS"
+           LIBS="$flag $LIBS"
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include <pthread.h>
+
+               #include <pthread.h>
 int
 main (void)
 {
-pthread_create(0, 0, 0, 0);
+
+                   pthread_create(0, 0, 0, 0);
+
   ;
   return 0;
 }
+
 _ACEOF
 if ac_fn_c_try_link "$LINENO"
 then :
-  have_pthread=yes
+
+               have_pthread="yes"
+
 else $as_nop
-  LIBS="$SAVELIBS"
+
+               LIBS="$SAVELIBS"
+
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.beam \
     conftest$ac_exeext conftest.$ac_ext
-                       { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_pthread" >&5
+           { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_pthread" >&5
 printf "%s\n" "$have_pthread" >&6; }
 
-                       if test $have_pthread = yes; then
-                               PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
+           if test $have_pthread = yes
+then :
+
+               PTHREAD_FLAGS="-D_THREAD_SAFE -D_REENTRANT"
+
+               # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to be POSIX-
+               # compliant... :(
+               if test $host_os_name = sunos
+then :
+
+                   PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
+
+fi
+               break
+
+fi
+       done
+
+fi
 
-                               # Solaris requires -D_POSIX_PTHREAD_SEMANTICS to
-                               # be POSIX-compliant... :(
-                               if test $host_os_name = sunos; then
-                                       PTHREAD_FLAGS="$PTHREAD_FLAGS -D_POSIX_PTHREAD_SEMANTICS"
-                               fi
-                               break
-                       fi
-               done
-       fi
 fi