diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-01-11 20:15:15 +0000 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2016-01-11 20:15:15 +0000 |
commit | 8c9d9c442d77c6bfecccddb3683ab809d9aca743 (patch) | |
tree | 9982f62cc032dc6ef6a30165baa217bf28732578 /configure.ac | |
parent | f0b2df09127d9225f72839432a6276cf6c4cb4f0 (diff) | |
download | libmicrohttpd-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.ac | 110 |
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="" | |||
86 | MHD_REQ_PRIVATE='' | 86 | MHD_REQ_PRIVATE='' |
87 | MHD_LIBDEPS_PKGCFG='' | 87 | MHD_LIBDEPS_PKGCFG='' |
88 | 88 | ||
89 | AC_ARG_WITH([threads], | ||
90 | [AS_HELP_STRING([--with-threads=LIB],[choose threading library (posix, w32, auto) [auto]])], | ||
91 | [], [with_threads='auto']) | ||
92 | test "x$with_threads" = "xwin32" && with_threads='w32' | ||
93 | test "x$with_threads" = "xpthreads" && with_threads='posix' | ||
94 | |||
95 | # Check for posix threads support | ||
96 | AX_PTHREAD([HAVE_POSIX_THREADS='yes'],[HAVE_POSIX_THREADS='no']) | ||
97 | AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$HAVE_POSIX_THREADS" = "xyes"]) | ||
98 | # Simple check for W32 threads support | ||
99 | AC_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 |
116 | AC_MSG_CHECKING([[for target host OS]]) | 90 | AC_MSG_CHECKING([[for target host OS]]) |
117 | case "$host_os" in | 91 | case "$host_os" in |
@@ -205,45 +179,52 @@ netbsd*) | |||
205 | ;; | 179 | ;; |
206 | esac | 180 | esac |
207 | 181 | ||
208 | if test "x$with_threads" = "xposix"; then | 182 | AC_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' | 185 | test "x$with_threads" = "xwin32" && with_threads='w32' |
212 | else | 186 | test "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]]) | 190 | AX_PTHREAD([HAVE_POSIX_THREADS='yes'],[HAVE_POSIX_THREADS='no']) |
217 | fi | 191 | AM_CONDITIONAL([HAVE_POSIX_THREADS],[test "x$HAVE_POSIX_THREADS" = "xyes"]) |
218 | fi | 192 | |
219 | elif test "x$with_threads" = "xw32"; then | 193 | HAVE_W32_THREADS='no' |
220 | # forced w32 threads | 194 | AS_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 | ||
230 | else | ||
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 | ||
245 | fi | ||
246 | 203 | ||
204 | AC_MSG_CHECKING([[for threading lib to use with libmicrohttpd]]) | ||
205 | AS_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 | ) | ||
247 | if test "x$USE_THREADS" = "xposix"; then | 228 | if 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 | |||
255 | fi | 236 | fi |
256 | AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) | 237 | AM_CONDITIONAL([USE_POSIX_THREADS], [test "x$USE_THREADS" = "xposix"]) |
257 | AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) | 238 | AM_CONDITIONAL([USE_W32_THREADS], [test "x$USE_THREADS" = "xw32"]) |
239 | AC_MSG_RESULT([[$USE_THREADS]]) | ||
258 | 240 | ||
259 | 241 | ||
260 | AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"]) | 242 | AM_CONDITIONAL(HAVE_W32, [test "x$os_is_native_w32" = "xyes"]) |