1#*************************************************************************** 2# 3# Copyright (C) 2008 - 2013 by Daniel Stenberg et al 4# 5# Permission to use, copy, modify, and distribute this software and its 6# documentation for any purpose and without fee is hereby granted, provided 7# that the above copyright notice appear in all copies and that both that 8# copyright notice and this permission notice appear in supporting 9# documentation, and that the name of M.I.T. not be used in advertising or 10# publicity pertaining to distribution of the software without specific, 11# written prior permission. M.I.T. makes no representations about the 12# suitability of this software for any purpose. It is provided "as is" 13# without express or implied warranty. 14# 15#*************************************************************************** 16 17# File version for 'aclocal' use. Keep it a single number. 18# serial 11 19 20 21dnl CARES_CHECK_OPTION_DEBUG 22dnl ------------------------------------------------- 23dnl Verify if configure has been invoked with option 24dnl --enable-debug or --disable-debug, and set shell 25dnl variable want_debug value as appropriate. 26 27AC_DEFUN([CARES_CHECK_OPTION_DEBUG], [ 28 AC_BEFORE([$0],[CARES_CHECK_OPTION_WARNINGS])dnl 29 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl 30 AC_MSG_CHECKING([whether to enable debug build options]) 31 OPT_DEBUG_BUILD="default" 32 AC_ARG_ENABLE(debug, 33AS_HELP_STRING([--enable-debug],[Enable debug build options]) 34AS_HELP_STRING([--disable-debug],[Disable debug build options]), 35 OPT_DEBUG_BUILD=$enableval) 36 case "$OPT_DEBUG_BUILD" in 37 no) 38 dnl --disable-debug option used 39 want_debug="no" 40 ;; 41 default) 42 dnl configure option not specified 43 want_debug="no" 44 ;; 45 *) 46 dnl --enable-debug option used 47 want_debug="yes" 48 ;; 49 esac 50 AC_MSG_RESULT([$want_debug]) 51]) 52 53 54dnl CARES_CHECK_OPTION_NONBLOCKING 55dnl ------------------------------------------------- 56dnl Verify if configure has been invoked with option 57dnl --enable-nonblocking or --disable-nonblocking, and 58dnl set shell variable want_nonblocking as appropriate. 59 60AC_DEFUN([CARES_CHECK_OPTION_NONBLOCKING], [ 61 AC_BEFORE([$0],[CARES_CHECK_NONBLOCKING_SOCKET])dnl 62 AC_MSG_CHECKING([whether to enable non-blocking communications]) 63 OPT_NONBLOCKING="default" 64 AC_ARG_ENABLE(nonblocking, 65AS_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications]) 66AS_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 85 86dnl CARES_CHECK_OPTION_OPTIMIZE 87dnl ------------------------------------------------- 88dnl Verify if configure has been invoked with option 89dnl --enable-optimize or --disable-optimize, and set 90dnl shell variable want_optimize value as appropriate. 91 92AC_DEFUN([CARES_CHECK_OPTION_OPTIMIZE], [ 93 AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl 94 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl 95 AC_MSG_CHECKING([whether to enable compiler optimizer]) 96 OPT_COMPILER_OPTIMIZE="default" 97 AC_ARG_ENABLE(optimize, 98AS_HELP_STRING([--enable-optimize(=OPT)],[Enable compiler optimizations (default=-O2)]) 99AS_HELP_STRING([--disable-optimize],[Disable compiler optimizations]), 100 OPT_COMPILER_OPTIMIZE=$enableval) 101 case "$OPT_COMPILER_OPTIMIZE" in 102 no) 103 dnl --disable-optimize option used. We will handle this as 104 dnl a request to disable compiler optimizations if possible. 105 dnl If the compiler is known CFLAGS and CPPFLAGS will be 106 dnl overridden, otherwise this can not be honored. 107 want_optimize="no" 108 AC_MSG_RESULT([no]) 109 ;; 110 default) 111 dnl configure's optimize option not specified. Initially we will 112 dnl handle this as a a request contrary to configure's setting 113 dnl for --enable-debug. IOW, initially, for debug-enabled builds 114 dnl this will be handled as a request to disable optimizations if 115 dnl possible, and for debug-disabled builds this will be handled 116 dnl initially as a request to enable optimizations if possible. 117 dnl Finally, if the compiler is known and CFLAGS and CPPFLAGS do 118 dnl not have any optimizer flag the request will be honored, in 119 dnl any other case the request can not be honored. 120 dnl IOW, existing optimizer flags defined in CFLAGS or CPPFLAGS 121 dnl will always take precedence over any initial assumption. 122 if test "$want_debug" = "yes"; then 123 want_optimize="assume_no" 124 AC_MSG_RESULT([not specified (assuming no)]) 125 else 126 want_optimize="assume_yes" 127 AC_MSG_RESULT([not specified (assuming yes)]) 128 fi 129 ;; 130 *) 131 dnl --enable-optimize option used. We will handle this as 132 dnl a request to enable compiler optimizations if possible. 133 dnl If the compiler is known CFLAGS and CPPFLAGS will be 134 dnl overridden, otherwise this can not be honored. 135 want_optimize="yes" 136 AC_MSG_RESULT([yes]) 137 ;; 138 esac 139]) 140 141 142dnl CARES_CHECK_OPTION_SYMBOL_HIDING 143dnl ------------------------------------------------- 144dnl Verify if configure has been invoked with option 145dnl --enable-symbol-hiding or --disable-symbol-hiding, 146dnl setting shell variable want_symbol_hiding value. 147 148AC_DEFUN([CARES_CHECK_OPTION_SYMBOL_HIDING], [ 149 AC_BEFORE([$0],[CARES_CHECK_COMPILER_SYMBOL_HIDING])dnl 150 AC_MSG_CHECKING([whether to enable hiding of library internal symbols]) 151 OPT_SYMBOL_HIDING="default" 152 AC_ARG_ENABLE(symbol-hiding, 153AS_HELP_STRING([--enable-symbol-hiding],[Enable hiding of library internal symbols]) 154AS_HELP_STRING([--disable-symbol-hiding],[Disable hiding of library internal symbols]), 155 OPT_SYMBOL_HIDING=$enableval) 156 case "$OPT_SYMBOL_HIDING" in 157 no) 158 dnl --disable-symbol-hiding option used. 159 dnl This is an indication to not attempt hiding of library internal 160 dnl symbols. Default symbol visibility will be used, which normally 161 dnl exposes all library internal symbols. 162 want_symbol_hiding="no" 163 AC_MSG_RESULT([no]) 164 ;; 165 default) 166 dnl configure's symbol-hiding option not specified. 167 dnl Handle this as if --enable-symbol-hiding option was given. 168 want_symbol_hiding="yes" 169 AC_MSG_RESULT([yes]) 170 ;; 171 *) 172 dnl --enable-symbol-hiding option used. 173 dnl This is an indication to attempt hiding of library internal 174 dnl symbols. This is only supported on some compilers/linkers. 175 want_symbol_hiding="yes" 176 AC_MSG_RESULT([yes]) 177 ;; 178 esac 179]) 180 181 182dnl CARES_CHECK_OPTION_EXPOSE_STATICS 183dnl ------------------------------------------------- 184dnl Verify if configure has been invoked with option 185dnl --enable-expose-statics or --disable-expose-statics, 186dnl setting shell variable want_expose_statics value. 187 188AC_DEFUN([CARES_CHECK_OPTION_EXPOSE_STATICS], [ 189 AC_MSG_CHECKING([whether to expose internal static functions for testing]) 190 OPT_EXPOSE_STATICS="default" 191 AC_ARG_ENABLE(expose-statics, 192AS_HELP_STRING([--enable-expose-statics],[Enable exposure of internal static functions for testing]) 193AS_HELP_STRING([--disable-expose-statics],[Disable exposure of internal static functions for testing]), 194 OPT_EXPOSE_STATICS=$enableval) 195 case "$OPT_EXPOSE_STATICS" in 196 no) 197 dnl --disable-expose-statics option used. 198 want_expose_statics="no" 199 AC_MSG_RESULT([no]) 200 ;; 201 default) 202 dnl configure's expose-statics option not specified. 203 dnl Handle this as if --disable-expose-statics option was given. 204 want_expose_statics="no" 205 AC_MSG_RESULT([no]) 206 ;; 207 *) 208 dnl --enable-expose-statics option used. 209 want_expose_statics="yes" 210 AC_MSG_RESULT([yes]) 211 ;; 212 esac 213 if test "$want_expose_statics" = "yes"; then 214 AC_DEFINE_UNQUOTED(CARES_EXPOSE_STATICS, 1, 215 [Defined for build that exposes internal static functions for testing.]) 216 fi 217]) 218 219 220dnl CARES_CHECK_OPTION_WARNINGS 221dnl ------------------------------------------------- 222dnl Verify if configure has been invoked with option 223dnl --enable-warnings or --disable-warnings, and set 224dnl shell variable want_warnings as appropriate. 225 226AC_DEFUN([CARES_CHECK_OPTION_WARNINGS], [ 227 AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl 228 AC_BEFORE([$0],[CARES_CHECK_OPTION_WERROR])dnl 229 AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl 230 AC_MSG_CHECKING([whether to enable strict compiler warnings]) 231 OPT_COMPILER_WARNINGS="default" 232 AC_ARG_ENABLE(warnings, 233AS_HELP_STRING([--enable-warnings],[Enable strict compiler warnings]) 234AS_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]), 235 OPT_COMPILER_WARNINGS=$enableval) 236 case "$OPT_COMPILER_WARNINGS" in 237 no) 238 dnl --disable-warnings option used 239 want_warnings="no" 240 ;; 241 default) 242 dnl configure option not specified, so 243 dnl use same setting as --enable-debug 244 want_warnings="$want_debug" 245 ;; 246 *) 247 dnl --enable-warnings option used 248 want_warnings="yes" 249 ;; 250 esac 251 AC_MSG_RESULT([$want_warnings]) 252]) 253 254dnl CARES_CHECK_OPTION_WERROR 255dnl ------------------------------------------------- 256dnl Verify if configure has been invoked with option 257dnl --enable-werror or --disable-werror, and set 258dnl shell variable want_werror as appropriate. 259 260AC_DEFUN([CARES_CHECK_OPTION_WERROR], [ 261 AC_BEFORE([$0],[CARES_CHECK_COMPILER])dnl 262 AC_MSG_CHECKING([whether to enable compiler warnings as errors]) 263 OPT_COMPILER_WERROR="default" 264 AC_ARG_ENABLE(werror, 265AS_HELP_STRING([--enable-werror],[Enable compiler warnings as errors]) 266AS_HELP_STRING([--disable-werror],[Disable compiler warnings as errors]), 267 OPT_COMPILER_WERROR=$enableval) 268 case "$OPT_COMPILER_WERROR" in 269 no) 270 dnl --disable-werror option used 271 want_werror="no" 272 ;; 273 default) 274 dnl configure option not specified 275 want_werror="no" 276 ;; 277 *) 278 dnl --enable-werror option used 279 want_werror="yes" 280 ;; 281 esac 282 AC_MSG_RESULT([$want_werror]) 283]) 284 285 286dnl CARES_CHECK_NONBLOCKING_SOCKET 287dnl ------------------------------------------------- 288dnl Check for how to set a socket into non-blocking state. 289 290AC_DEFUN([CARES_CHECK_NONBLOCKING_SOCKET], [ 291 AC_REQUIRE([CARES_CHECK_OPTION_NONBLOCKING])dnl 292 AC_REQUIRE([CARES_CHECK_FUNC_FCNTL])dnl 293 AC_REQUIRE([CARES_CHECK_FUNC_IOCTL])dnl 294 AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET])dnl 295 AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl 296 AC_REQUIRE([CARES_CHECK_FUNC_SETSOCKOPT])dnl 297 # 298 tst_method="unknown" 299 if test "$want_nonblocking" = "yes"; then 300 AC_MSG_CHECKING([how to set a socket into non-blocking mode]) 301 if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then 302 tst_method="fcntl O_NONBLOCK" 303 elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then 304 tst_method="ioctl FIONBIO" 305 elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then 306 tst_method="ioctlsocket FIONBIO" 307 elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then 308 tst_method="IoctlSocket FIONBIO" 309 elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then 310 tst_method="setsockopt SO_NONBLOCK" 311 fi 312 AC_MSG_RESULT([$tst_method]) 313 if test "$tst_method" = "unknown"; then 314 AC_MSG_WARN([cannot determine non-blocking socket method.]) 315 fi 316 fi 317 if test "$tst_method" = "unknown"; then 318 AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1, 319 [Define to disable non-blocking sockets.]) 320 AC_MSG_WARN([non-blocking sockets disabled.]) 321 fi 322]) 323 324 325dnl CARES_CONFIGURE_SYMBOL_HIDING 326dnl ------------------------------------------------- 327dnl Depending on --enable-symbol-hiding or --disable-symbol-hiding 328dnl configure option, and compiler capability to actually honor such 329dnl option, this will modify compiler flags as appropriate and also 330dnl provide needed definitions for configuration and Makefile.am files. 331dnl This macro should not be used until all compilation tests have 332dnl been done to prevent interferences on other tests. 333 334AC_DEFUN([CARES_CONFIGURE_SYMBOL_HIDING], [ 335 AC_MSG_CHECKING([whether hiding of library internal symbols will actually happen]) 336 CFLAG_CARES_SYMBOL_HIDING="" 337 doing_symbol_hiding="no" 338 if test x"$ac_cv_native_windows" != "xyes" && 339 test "$want_symbol_hiding" = "yes" && 340 test "$supports_symbol_hiding" = "yes"; then 341 doing_symbol_hiding="yes" 342 CFLAG_CARES_SYMBOL_HIDING="$symbol_hiding_CFLAGS" 343 AC_DEFINE_UNQUOTED(CARES_SYMBOL_SCOPE_EXTERN, $symbol_hiding_EXTERN, 344 [Definition to make a library symbol externally visible.]) 345 AC_MSG_RESULT([yes]) 346 else 347 AC_MSG_RESULT([no]) 348 fi 349 AM_CONDITIONAL(DOING_CARES_SYMBOL_HIDING, test x$doing_symbol_hiding = xyes) 350 AC_SUBST(CFLAG_CARES_SYMBOL_HIDING) 351 if test "$doing_symbol_hiding" = "yes"; then 352 AC_DEFINE_UNQUOTED(CARES_SYMBOL_HIDING, 1, 353 [Defined for build with symbol hiding.]) 354 fi 355]) 356 357