aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-01-11 20:15:15 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-01-11 20:15:15 +0000
commit8c9d9c442d77c6bfecccddb3683ab809d9aca743 (patch)
tree9982f62cc032dc6ef6a30165baa217bf28732578 /configure.ac
parentf0b2df09127d9225f72839432a6276cf6c4cb4f0 (diff)
downloadlibmicrohttpd-8c9d9c442d77c6bfecccddb3683ab809d9aca743.tar.gz
libmicrohttpd-8c9d9c442d77c6bfecccddb3683ab809d9aca743.zip
configure.ac: cleaned up and refactored threading lib selection for clarity
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac110
1 files changed, 46 insertions, 64 deletions
diff --git a/configure.ac b/configure.ac
index a1ee397e..2076b005 100644
--- a/configure.ac
+++ b/configure.ac
@@ -86,32 +86,6 @@ MHD_LIBDEPS=""
86MHD_REQ_PRIVATE='' 86MHD_REQ_PRIVATE=''
87MHD_LIBDEPS_PKGCFG='' 87MHD_LIBDEPS_PKGCFG=''
88 88
89AC_ARG_WITH([threads],
90 [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto) [auto]])],
91 [], [with_threads='auto'])
92test "x$with_threads" = "xwin32" && with_threads='w32'
93test "x$with_threads" = "xpthreads" && with_threads='posix'
94
95# Check for posix threads support
96AX_PTHREAD([HAVE_POSIX_THREADS='yes'],[HAVE_POSIX_THREADS='no'])
97AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$HAVE_POSIX_THREADS" = "xyes"])
98# Simple check for W32 threads support
99AC_CHECK_HEADER([windows.h],
100 [
101 AC_MSG_CHECKING([for CreateThread()])
102 AC_LINK_IFELSE(
103 [AC_LANG_PROGRAM([#include <windows.h>], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])],
104 [
105 AC_MSG_RESULT([yes])
106 HAVE_W32_THREADS='yes'
107 ],
108 [
109 AC_MSG_RESULT([no])
110 HAVE_W32_THREADS='no'
111 ])
112 ],
113 [HAVE_W32_THREADS='no'])
114
115# Check system type 89# Check system type
116AC_MSG_CHECKING([[for target host OS]]) 90AC_MSG_CHECKING([[for target host OS]])
117case "$host_os" in 91case "$host_os" in
@@ -205,45 +179,52 @@ netbsd*)
205;; 179;;
206esac 180esac
207 181
208if test "x$with_threads" = "xposix"; then 182AC_ARG_WITH([threads],
209# forced posix threads 183 [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto) [auto]])],
210 if test "x$HAVE_POSIX_THREADS" = "xyes"; then 184 [], [with_threads='auto'])
211 USE_THREADS='posix' 185test "x$with_threads" = "xwin32" && with_threads='w32'
212 else 186test "x$with_threads" = "xpthreads" && with_threads='posix'
213 if test "x$HAVE_W32_THREADS" = "xyes"; then 187
214 AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]]) 188# Check for posix threads support, regardless of configure parameters as
215 else 189# posix threads are used in some tests even on W32.
216 AC_MSG_ERROR([[Posix threads are not available]]) 190AX_PTHREAD([HAVE_POSIX_THREADS='yes'],[HAVE_POSIX_THREADS='no'])
217 fi 191AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$HAVE_POSIX_THREADS" = "xyes"])
218 fi 192
219elif test "x$with_threads" = "xw32"; then 193HAVE_W32_THREADS='no'
220# forced w32 threads 194AS_IF([[test "x$os_is_windows" = "xyes"]],
221 if test "x$HAVE_W32_THREADS" = "xyes"; then 195 [
222 USE_THREADS='w32' 196 AC_MSG_CHECKING([[for W32 threads]])
223 else 197 AC_LINK_IFELSE(
224 if test "x$HAVE_POSIX_THREADS" = "xyes"; then 198 [AC_LANG_PROGRAM([#include <windows.h>], [ HANDLE h = CreateThread(NULL, 0, NULL, NULL, 0, NULL);])]
225 AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]]) 199 , [[HAVE_W32_THREADS='yes']], [[HAVE_W32_THREADS='no']]
226 else 200 )
227 AC_MSG_ERROR([[W32 threads are not available]]) 201 AC_MSG_RESULT([[$HAVE_W32_THREADS]])
228 fi 202 ])
229 fi
230else
231# automatic threads lib selection
232 if test "x$HAVE_POSIX_THREADS" = "xyes" && test "x$HAVE_W32_THREADS" = "xyes"; then
233 if test "x$os_is_native_w32" = "xyes"; then
234 USE_THREADS='w32'
235 else
236 USE_THREADS='posix'
237 fi
238 elif test "x$HAVE_POSIX_THREADS" = "xyes"; then
239 USE_THREADS='posix'
240 elif test "x$HAVE_W32_THREADS" = "xyes"; then
241 USE_THREADS='w32'
242 else
243 AC_MSG_ERROR([[No threading lib is available. Cosider installing pthreads]])
244 fi
245fi
246 203
204AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd]])
205AS_IF([[test "x$with_threads" = "xposix"]],
206 [ # forced posix threads
207 AS_IF([[test "x$HAVE_POSIX_THREADS" = "xyes"]], [[ USE_THREADS='posix' ]],
208 [ AS_IF([[test "x$os_is_windows" = "xyes"]] ,
209 [ AC_MSG_ERROR([[Posix threads are not available. Try to configure --with-threads=auto]])],
210 [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]])] )
211 ])
212 ] ,
213 [[ test "x$with_threads" = "xw32" ]] ,
214 [ # forced w32 threads
215 AS_IF([[test "x$HAVE_W32_THREADS" = "xyes"]],
216 [[ USE_THREADS='w32' ]],
217 [ AC_MSG_ERROR([[W32 threads are not available. Try to configure --with-threads=auto]])])
218 ] ,
219 [ # automatic threads lib selection
220 AS_IF([[test "x$os_is_native_w32" = "xyes" && test "x$HAVE_W32_THREADS" = "xyes"]] ,
221 [[ USE_THREADS='w32' ]] ,
222 [[ test "x$HAVE_POSIX_THREADS" = "xyes" ]], [[ USE_THREADS='posix' ]],
223 [[ test "x$HAVE_W32_THREADS" = "xyes" ]], [[ USE_THREADS='w32' ]],
224 [ AC_MSG_ERROR([[No threading lib is available. Consider installing pthreads]]) ]
225 )
226 ]
227 )
247if test "x$USE_THREADS" = "xposix"; then 228if test "x$USE_THREADS" = "xposix"; then
248 CC="$PTHREAD_CC" 229 CC="$PTHREAD_CC"
249 AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads]) 230 AC_DEFINE([MHD_USE_POSIX_THREADS],[1],[define to use pthreads])
@@ -255,6 +236,7 @@ elif test "x$USE_THREADS" = "xw32"; then
255fi 236fi
256AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) 237AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"])
257AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) 238AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"])
239AC_MSG_RESULT([[$USE_THREADS]])
258 240
259 241
260AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"]) 242AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"])