cares-confopts.m4 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. #***************************************************************************
  2. # $Id$
  3. #
  4. # Copyright (C) 2008 by Daniel Stenberg et al
  5. #
  6. # Permission to use, copy, modify, and distribute this software and its
  7. # documentation for any purpose and without fee is hereby granted, provided
  8. # that the above copyright notice appear in all copies and that both that
  9. # copyright notice and this permission notice appear in supporting
  10. # documentation, and that the name of M.I.T. not be used in advertising or
  11. # publicity pertaining to distribution of the software without specific,
  12. # written prior permission. M.I.T. makes no representations about the
  13. # suitability of this software for any purpose. It is provided "as is"
  14. # without express or implied warranty.
  15. #
  16. #***************************************************************************
  17. # File version for 'aclocal' use. Keep it a single number.
  18. # serial 3
  19. dnl CARES_CHECK_OPTION_DEBUG
  20. dnl -------------------------------------------------
  21. dnl Verify if configure has been invoked with option
  22. dnl --enable-debug or --disable-debug, and set shell
  23. dnl variable want_debug value as appropriate.
  24. AC_DEFUN([CARES_CHECK_OPTION_DEBUG], [
  25. AC_BEFORE([$0],[CARES_CHECK_OPTION_WARNINGS])dnl
  26. AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl
  27. AC_MSG_CHECKING([whether to enable debug build options])
  28. OPT_DEBUG_BUILD="default"
  29. AC_ARG_ENABLE(debug,
  30. AC_HELP_STRING([--enable-debug],[Enable debug build options])
  31. AC_HELP_STRING([--disable-debug],[Disable debug build options]),
  32. OPT_DEBUG_BUILD=$enableval)
  33. case "$OPT_DEBUG_BUILD" in
  34. no)
  35. dnl --disable-debug option used
  36. want_debug="no"
  37. ;;
  38. default)
  39. dnl configure option not specified
  40. want_debug="no"
  41. ;;
  42. *)
  43. dnl --enable-debug option used
  44. want_debug="yes"
  45. ;;
  46. esac
  47. AC_MSG_RESULT([$want_debug])
  48. ])
  49. dnl CARES_CHECK_OPTION_NONBLOCKING
  50. dnl -------------------------------------------------
  51. dnl Verify if configure has been invoked with option
  52. dnl --enable-nonblocking or --disable-nonblocking, and
  53. dnl set shell variable want_nonblocking as appropriate.
  54. AC_DEFUN([CARES_CHECK_OPTION_NONBLOCKING], [
  55. AC_BEFORE([$0],[CARES_CHECK_NONBLOCKING_SOCKET])dnl
  56. AC_MSG_CHECKING([whether to enable non-blocking communications])
  57. OPT_NONBLOCKING="default"
  58. AC_ARG_ENABLE(nonblocking,
  59. AC_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications])
  60. AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking communications]),
  61. OPT_NONBLOCKING=$enableval)
  62. case "$OPT_NONBLOCKING" in
  63. no)
  64. dnl --disable-nonblocking option used
  65. want_nonblocking="no"
  66. ;;
  67. default)
  68. dnl configure option not specified
  69. want_nonblocking="yes"
  70. ;;
  71. *)
  72. dnl --enable-nonblocking option used
  73. want_nonblocking="yes"
  74. ;;
  75. esac
  76. AC_MSG_RESULT([$want_nonblocking])
  77. ])
  78. dnl CARES_CHECK_OPTION_OPTIMIZE
  79. dnl -------------------------------------------------
  80. dnl Verify if configure has been invoked with option
  81. dnl --enable-optimize or --disable-optimize, and set
  82. dnl shell variable want_optimize value as appropriate.
  83. AC_DEFUN([CARES_CHECK_OPTION_OPTIMIZE], [
  84. AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl
  85. AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl
  86. AC_MSG_CHECKING([whether to enable compiler optimizer])
  87. OPT_COMPILER_OPTIMIZE="default"
  88. AC_ARG_ENABLE(optimize,
  89. AC_HELP_STRING([--enable-optimize(=OPT)],[Enable compiler optimizations (default=-O2)])
  90. AC_HELP_STRING([--disable-optimize],[Disable compiler optimizations]),
  91. OPT_COMPILER_OPTIMIZE=$enableval)
  92. case "$OPT_COMPILER_OPTIMIZE" in
  93. no)
  94. dnl --disable-optimize option used. We will handle this as
  95. dnl a request to disable compiler optimizations if possible.
  96. dnl If the compiler is known CFLAGS and CPPFLAGS will be
  97. dnl overridden, otherwise this can not be honored.
  98. want_optimize="no"
  99. AC_MSG_RESULT([no])
  100. ;;
  101. default)
  102. dnl configure's optimize option not specified. Initially we will
  103. dnl handle this as a a request contrary to configure's setting
  104. dnl for --enable-debug. IOW, initially, for debug-enabled builds
  105. dnl this will be handled as a request to disable optimizations if
  106. dnl possible, and for debug-disabled builds this will be handled
  107. dnl initially as a request to enable optimizations if possible.
  108. dnl Finally, if the compiler is known and CFLAGS and CPPFLAGS do
  109. dnl not have any optimizer flag the request will be honored, in
  110. dnl any other case the request can not be honored.
  111. dnl IOW, existing optimizer flags defined in CFLAGS or CPPFLAGS
  112. dnl will always take precedence over any initial assumption.
  113. if test "$want_debug" = "yes"; then
  114. want_optimize="assume_no"
  115. AC_MSG_RESULT([not specified (assuming no)])
  116. else
  117. want_optimize="assume_yes"
  118. AC_MSG_RESULT([not specified (assuming yes)])
  119. fi
  120. ;;
  121. *)
  122. dnl --enable-optimize option used. We will handle this as
  123. dnl a request to enable compiler optimizations if possible.
  124. dnl If the compiler is known CFLAGS and CPPFLAGS will be
  125. dnl overridden, otherwise this can not be honored.
  126. want_optimize="yes"
  127. AC_MSG_RESULT([yes])
  128. ;;
  129. esac
  130. ])
  131. dnl CARES_CHECK_OPTION_WARNINGS
  132. dnl -------------------------------------------------
  133. dnl Verify if configure has been invoked with option
  134. dnl --enable-warnings or --disable-warnings, and set
  135. dnl shell variable want_warnings as appropriate.
  136. AC_DEFUN([CARES_CHECK_OPTION_WARNINGS], [
  137. AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl
  138. AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl
  139. AC_MSG_CHECKING([whether to enable strict compiler warnings])
  140. OPT_COMPILER_WARNINGS="default"
  141. AC_ARG_ENABLE(warnings,
  142. AC_HELP_STRING([--enable-warnings],[Enable strict compiler warnings])
  143. AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]),
  144. OPT_COMPILER_WARNINGS=$enableval)
  145. case "$OPT_COMPILER_WARNINGS" in
  146. no)
  147. dnl --disable-warnings option used
  148. want_warnings="no"
  149. ;;
  150. default)
  151. dnl configure option not specified, so
  152. dnl use same setting as --enable-debug
  153. want_warnings="$want_debug"
  154. ;;
  155. *)
  156. dnl --enable-warnings option used
  157. want_warnings="yes"
  158. ;;
  159. esac
  160. AC_MSG_RESULT([$want_warnings])
  161. ])
  162. dnl CARES_CHECK_NONBLOCKING_SOCKET
  163. dnl -------------------------------------------------
  164. dnl Check for how to set a socket into non-blocking state.
  165. AC_DEFUN([CARES_CHECK_NONBLOCKING_SOCKET], [
  166. AC_REQUIRE([CARES_CHECK_OPTION_NONBLOCKING])dnl
  167. AC_REQUIRE([CARES_CHECK_FUNC_FCNTL])dnl
  168. AC_REQUIRE([CARES_CHECK_FUNC_IOCTL])dnl
  169. AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET])dnl
  170. AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl
  171. AC_REQUIRE([CARES_CHECK_FUNC_SETSOCKOPT])dnl
  172. #
  173. tst_method="unknown"
  174. if test "$want_nonblocking" = "yes"; then
  175. AC_MSG_CHECKING([how to set a socket into non-blocking mode])
  176. if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then
  177. tst_method="fcntl O_NONBLOCK"
  178. elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then
  179. tst_method="ioctl FIONBIO"
  180. elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then
  181. tst_method="ioctlsocket FIONBIO"
  182. elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then
  183. tst_method="IoctlSocket FIONBIO"
  184. elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then
  185. tst_method="setsockopt SO_NONBLOCK"
  186. fi
  187. AC_MSG_RESULT([$tst_method])
  188. if test "$tst_method" = "unknown"; then
  189. AC_MSG_WARN([cannot determine non-blocking socket method.])
  190. fi
  191. fi
  192. if test "$tst_method" = "unknown"; then
  193. AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1,
  194. [Define to disable non-blocking sockets.])
  195. AC_MSG_WARN([non-blocking sockets disabled.])
  196. fi
  197. ])