curl-confopts.m4 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at http://curl.haxx.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. # $Id$
  22. #***************************************************************************
  23. # File version for 'aclocal' use. Keep it a single number.
  24. # serial 4
  25. dnl CURL_CHECK_OPTION_DEBUG
  26. dnl -------------------------------------------------
  27. dnl Verify if configure has been invoked with option
  28. dnl --enable-debug or --disable-debug, and set shell
  29. dnl variable want_debug value as appropriate.
  30. AC_DEFUN([CURL_CHECK_OPTION_DEBUG], [
  31. AC_BEFORE([$0],[CURL_CHECK_OPTION_WARNINGS])dnl
  32. AC_BEFORE([$0],[CURL_CHECK_PROG_CC])dnl
  33. AC_MSG_CHECKING([whether to enable debug build options])
  34. OPT_DEBUG_BUILD="default"
  35. AC_ARG_ENABLE(debug,
  36. AC_HELP_STRING([--enable-debug],[Enable debug build options])
  37. AC_HELP_STRING([--disable-debug],[Disable debug build options]),
  38. OPT_DEBUG_BUILD=$enableval)
  39. case "$OPT_DEBUG_BUILD" in
  40. no)
  41. dnl --disable-debug option used
  42. want_debug="no"
  43. ;;
  44. default)
  45. dnl configure option not specified
  46. want_debug="no"
  47. ;;
  48. *)
  49. dnl --enable-debug option used
  50. want_debug="yes"
  51. ;;
  52. esac
  53. AC_MSG_RESULT([$want_debug])
  54. ])
  55. dnl CURL_CHECK_OPTION_NONBLOCKING
  56. dnl -------------------------------------------------
  57. dnl Verify if configure has been invoked with option
  58. dnl --enable-nonblocking or --disable-nonblocking, and
  59. dnl set shell variable want_nonblocking as appropriate.
  60. AC_DEFUN([CURL_CHECK_OPTION_NONBLOCKING], [
  61. AC_BEFORE([$0],[CURL_CHECK_NONBLOCKING_SOCKET])dnl
  62. AC_MSG_CHECKING([whether to enable non-blocking communications])
  63. OPT_NONBLOCKING="default"
  64. AC_ARG_ENABLE(nonblocking,
  65. AC_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications])
  66. AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking communications]),
  67. OPT_NONBLOCKING=$enableval)
  68. case "$OPT_NONBLOCKING" in
  69. no)
  70. dnl --disable-nonblocking option used
  71. want_nonblocking="no"
  72. ;;
  73. default)
  74. dnl configure option not specified
  75. want_nonblocking="yes"
  76. ;;
  77. *)
  78. dnl --enable-nonblocking option used
  79. want_nonblocking="yes"
  80. ;;
  81. esac
  82. AC_MSG_RESULT([$want_nonblocking])
  83. ])
  84. dnl CURL_CHECK_OPTION_OPTIMIZE
  85. dnl -------------------------------------------------
  86. dnl Verify if configure has been invoked with option
  87. dnl --enable-optimize or --disable-optimize, and set
  88. dnl shell variable want_optimize value as appropriate.
  89. AC_DEFUN([CURL_CHECK_OPTION_OPTIMIZE], [
  90. AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
  91. AC_BEFORE([$0],[CURL_CHECK_PROG_CC])dnl
  92. AC_MSG_CHECKING([whether to enable compiler optimizer])
  93. OPT_COMPILER_OPTIMIZE="default"
  94. AC_ARG_ENABLE(optimize,
  95. AC_HELP_STRING([--enable-optimize],[Enable compiler optimizations])
  96. AC_HELP_STRING([--disable-optimize],[Disable compiler optimizations]),
  97. OPT_COMPILER_OPTIMIZE=$enableval)
  98. case "$OPT_COMPILER_OPTIMIZE" in
  99. no)
  100. dnl --disable-optimize option used. We will handle this as
  101. dnl a request to disable compiler optimizations if possible.
  102. dnl If the compiler is known CFLAGS and CPPFLAGS will be
  103. dnl overridden, otherwise this can not be honored.
  104. want_optimize="no"
  105. AC_MSG_RESULT([no])
  106. ;;
  107. default)
  108. dnl configure's optimize option not specified. Initially we will
  109. dnl handle this as a a request contrary to configure's setting
  110. dnl for --enable-debug. IOW, initially, for debug-enabled builds
  111. dnl this will be handled as a request to disable optimizations if
  112. dnl possible, and for debug-disabled builds this will be handled
  113. dnl initially as a request to enable optimizations if possible.
  114. dnl Finally, if the compiler is known and CFLAGS and CPPFLAGS do
  115. dnl not have any optimizer flag the request will be honored, in
  116. dnl any other case the request can not be honored.
  117. dnl IOW, existing optimizer flags defined in CFLAGS or CPPFLAGS
  118. dnl will always take precedence over any initial assumption.
  119. if test "$want_debug" = "yes"; then
  120. want_optimize="assume_no"
  121. AC_MSG_RESULT([not specified (assuming no)])
  122. else
  123. want_optimize="assume_yes"
  124. AC_MSG_RESULT([not specified (assuming yes)])
  125. fi
  126. ;;
  127. *)
  128. dnl --enable-optimize option used. We will handle this as
  129. dnl a request to enable compiler optimizations if possible.
  130. dnl If the compiler is known CFLAGS and CPPFLAGS will be
  131. dnl overridden, otherwise this can not be honored.
  132. want_optimize="yes"
  133. AC_MSG_RESULT([yes])
  134. ;;
  135. esac
  136. ])
  137. dnl CURL_CHECK_OPTION_WARNINGS
  138. dnl -------------------------------------------------
  139. dnl Verify if configure has been invoked with option
  140. dnl --enable-warnings or --disable-warnings, and set
  141. dnl shell variable want_warnings as appropriate.
  142. AC_DEFUN([CURL_CHECK_OPTION_WARNINGS], [
  143. AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
  144. AC_BEFORE([$0],[CURL_CHECK_PROG_CC])dnl
  145. AC_MSG_CHECKING([whether to enable strict compiler warnings])
  146. OPT_COMPILER_WARNINGS="default"
  147. AC_ARG_ENABLE(warnings,
  148. AC_HELP_STRING([--enable-warnings],[Enable strict compiler warnings])
  149. AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
  150. OPT_COMPILER_WARNINGS=$enableval)
  151. case "$OPT_COMPILER_WARNINGS" in
  152. no)
  153. dnl --disable-warnings option used
  154. want_warnings="no"
  155. ;;
  156. default)
  157. dnl configure option not specified, so
  158. dnl use same setting as --enable-debug
  159. want_warnings="$want_debug"
  160. ;;
  161. *)
  162. dnl --enable-warnings option used
  163. want_warnings="yes"
  164. ;;
  165. esac
  166. AC_MSG_RESULT([$want_warnings])
  167. ])
  168. dnl CURL_CHECK_NONBLOCKING_SOCKET
  169. dnl -------------------------------------------------
  170. dnl Check for how to set a socket into non-blocking state.
  171. AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [
  172. AC_REQUIRE([CURL_CHECK_OPTION_NONBLOCKING])dnl
  173. AC_REQUIRE([CURL_CHECK_FUNC_FCNTL])dnl
  174. AC_REQUIRE([CURL_CHECK_FUNC_IOCTL])dnl
  175. AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET])dnl
  176. AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl
  177. AC_REQUIRE([CURL_CHECK_FUNC_SETSOCKOPT])dnl
  178. #
  179. tst_method="unknown"
  180. if test "$want_nonblocking" = "yes"; then
  181. AC_MSG_CHECKING([how to set a socket into non-blocking mode])
  182. if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then
  183. tst_method="fcntl O_NONBLOCK"
  184. elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then
  185. tst_method="ioctl FIONBIO"
  186. elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then
  187. tst_method="ioctlsocket FIONBIO"
  188. elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then
  189. tst_method="IoctlSocket FIONBIO"
  190. elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then
  191. tst_method="setsockopt SO_NONBLOCK"
  192. fi
  193. AC_MSG_RESULT([$tst_method])
  194. if test "$tst_method" = "unknown"; then
  195. AC_MSG_WARN([cannot determine non-blocking socket method.])
  196. fi
  197. fi
  198. if test "$tst_method" = "unknown"; then
  199. AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1,
  200. [Define to disable non-blocking sockets.])
  201. AC_MSG_WARN([non-blocking sockets disabled.])
  202. fi
  203. ])