commit 8c9d9c442d77c6bfecccddb3683ab809d9aca743
parent f0b2df09127d9225f72839432a6276cf6c4cb4f0
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date: Mon, 11 Jan 2016 20:15:15 +0000
configure.ac: cleaned up and refactored threading lib selection for clarity
Diffstat:
| M | configure.ac | | | 110 | +++++++++++++++++++++++++++++++++---------------------------------------------- |
1 file changed, 46 insertions(+), 64 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -86,32 +86,6 @@ MHD_LIBDEPS=""
MHD_REQ_PRIVATE=''
MHD_LIBDEPS_PKGCFG=''
-AC_ARG_WITH([threads],
- [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto) [auto]])],
- [], [with_threads='auto'])
-test "x$with_threads" = "xwin32" && with_threads='w32'
-test "x$with_threads" = "xpthreads" && with_threads='posix'
-
-# Check for posix threads support
-AX_PTHREAD([HAVE_POSIX_THREADS='yes'],[HAVE_POSIX_THREADS='no'])
-AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$HAVE_POSIX_THREADS" = "xyes"])
-# Simple check for W32 threads support
-AC_CHECK_HEADER([windows.h],
- [
- AC_MSG_CHECKING([for CreateThread()])
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([#include <windows.h>], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])],
- [
- AC_MSG_RESULT([yes])
- HAVE_W32_THREADS='yes'
- ],
- [
- AC_MSG_RESULT([no])
- HAVE_W32_THREADS='no'
- ])
- ],
- [HAVE_W32_THREADS='no'])
-
# Check system type
AC_MSG_CHECKING([[for target host OS]])
case "$host_os" in
@@ -205,45 +179,52 @@ netbsd*)
;;
esac
-if test "x$with_threads" = "xposix"; then
-# forced posix threads
- if test "x$HAVE_POSIX_THREADS" = "xyes"; then
- USE_THREADS='posix'
- else
- if test "x$HAVE_W32_THREADS" = "xyes"; then
- AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])
- else
- AC_MSG_ERROR([[Posix threads are not available]])
- fi
- fi
-elif test "x$with_threads" = "xw32"; then
-# forced w32 threads
- if test "x$HAVE_W32_THREADS" = "xyes"; then
- USE_THREADS='w32'
- else
- if test "x$HAVE_POSIX_THREADS" = "xyes"; then
- AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])
- else
- AC_MSG_ERROR([[W32 threads are not available]])
- fi
- fi
-else
-# automatic threads lib selection
- if test "x$HAVE_POSIX_THREADS" = "xyes" && test "x$HAVE_W32_THREADS" = "xyes"; then
- if test "x$os_is_native_w32" = "xyes"; then
- USE_THREADS='w32'
- else
- USE_THREADS='posix'
- fi
- elif test "x$HAVE_POSIX_THREADS" = "xyes"; then
- USE_THREADS='posix'
- elif test "x$HAVE_W32_THREADS" = "xyes"; then
- USE_THREADS='w32'
- else
- AC_MSG_ERROR([[No threading lib is available. Cosider installing pthreads]])
- fi
-fi
+AC_ARG_WITH([threads],
+ [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto) [auto]])],
+ [], [with_threads='auto'])
+test "x$with_threads" = "xwin32" && with_threads='w32'
+test "x$with_threads" = "xpthreads" && with_threads='posix'
+
+# Check for posix threads support, regardless of configure parameters as
+# posix threads are used in some tests even on W32.
+AX_PTHREAD([HAVE_POSIX_THREADS='yes'],[HAVE_POSIX_THREADS='no'])
+AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$HAVE_POSIX_THREADS" = "xyes"])
+
+HAVE_W32_THREADS='no'
+AS_IF([[test "x$os_is_windows" = "xyes"]],
+ [
+ AC_MSG_CHECKING([[for W32 threads]])
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([#include <windows.h>], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])]
+ , [[HAVE_W32_THREADS='yes']], [[HAVE_W32_THREADS='no']]
+ )
+ AC_MSG_RESULT([[$HAVE_W32_THREADS]])
+ ])
+AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd]])
+AS_IF([[test "x$with_threads" = "xposix"]],
+ [ # forced posix threads
+ AS_IF([[test "x$HAVE_POSIX_THREADS" = "xyes"]], [[ USE_THREADS='posix' ]],
+ [ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
+ [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])],
+ [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] )
+ ])
+ ] ,
+ [[ test "x$with_threads" = "xw32" ]] ,
+ [ # forced w32 threads
+ AS_IF([[test "x$HAVE_W32_THREADS" = "xyes"]],
+ [[ USE_THREADS='w32' ]],
+ [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])])
+ ] ,
+ [ # automatic threads lib selection
+ AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$HAVE_W32_THREADS" = "xyes"]] ,
+ [[ USE_THREADS='w32' ]] ,
+ [[ test "x$HAVE_POSIX_THREADS" = "xyes" ]], [[ USE_THREADS='posix' ]],
+ [[ test "x$HAVE_W32_THREADS" = "xyes" ]], [[ USE_THREADS='w32' ]],
+ [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ]
+ )
+ ]
+ )
if test "x$USE_THREADS" = "xposix"; then
CC="$PTHREAD_CC"
AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
@@ -255,6 +236,7 @@ elif test "x$USE_THREADS" = "xw32"; then
fi
AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
+AC_MSG_RESULT([[$USE_THREADS]])
AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"])