lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | #*************************************************************************** |
| 2 | # |
| 3 | # Copyright (C) 2009-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 75 |
| 19 | |
| 20 | |
| 21 | dnl CARES_CHECK_COMPILER |
| 22 | dnl ------------------------------------------------- |
| 23 | dnl Verify if the C compiler being used is known. |
| 24 | |
| 25 | AC_DEFUN([CARES_CHECK_COMPILER], [ |
| 26 | # |
| 27 | compiler_id="unknown" |
| 28 | compiler_num="0" |
| 29 | # |
| 30 | flags_dbg_all="unknown" |
| 31 | flags_dbg_yes="unknown" |
| 32 | flags_dbg_off="unknown" |
| 33 | flags_opt_all="unknown" |
| 34 | flags_opt_yes="unknown" |
| 35 | flags_opt_off="unknown" |
| 36 | # |
| 37 | flags_prefer_cppflags="no" |
| 38 | # |
| 39 | CARES_CHECK_COMPILER_DEC_C |
| 40 | CARES_CHECK_COMPILER_HPUX_C |
| 41 | CARES_CHECK_COMPILER_IBM_C |
| 42 | CARES_CHECK_COMPILER_INTEL_C |
| 43 | CARES_CHECK_COMPILER_CLANG |
| 44 | CARES_CHECK_COMPILER_GNU_C |
| 45 | CARES_CHECK_COMPILER_LCC |
| 46 | CARES_CHECK_COMPILER_SGI_MIPSPRO_C |
| 47 | CARES_CHECK_COMPILER_SGI_MIPS_C |
| 48 | CARES_CHECK_COMPILER_SUNPRO_C |
| 49 | CARES_CHECK_COMPILER_TINY_C |
| 50 | CARES_CHECK_COMPILER_WATCOM_C |
| 51 | # |
| 52 | if test "$compiler_id" = "unknown"; then |
| 53 | cat <<_EOF 1>&2 |
| 54 | *** |
| 55 | *** Warning: This configure script does not have information about the |
| 56 | *** compiler you are using, relative to the flags required to enable or |
| 57 | *** disable generation of debug info, optimization options or warnings. |
| 58 | *** |
| 59 | *** Whatever settings are present in CFLAGS will be used for this run. |
| 60 | *** |
| 61 | *** If you wish to help the c-ares project to better support your compiler |
| 62 | *** you can report this and the required info on the c-ares development |
| 63 | *** mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/ |
| 64 | *** |
| 65 | _EOF |
| 66 | fi |
| 67 | ]) |
| 68 | |
| 69 | |
| 70 | dnl CARES_CHECK_COMPILER_CLANG |
| 71 | dnl ------------------------------------------------- |
| 72 | dnl Verify if compiler being used is clang. |
| 73 | |
| 74 | AC_DEFUN([CARES_CHECK_COMPILER_CLANG], [ |
| 75 | AC_BEFORE([$0],[CARES_CHECK_COMPILER_GNU_C])dnl |
| 76 | AC_MSG_CHECKING([if compiler is clang]) |
| 77 | CURL_CHECK_DEF([__clang__], [], [silent]) |
| 78 | if test "$curl_cv_have_def___clang__" = "yes"; then |
| 79 | AC_MSG_RESULT([yes]) |
| 80 | compiler_id="CLANG" |
| 81 | clangver=`$CC -dumpversion` |
| 82 | clangvhi=`echo $clangver | cut -d . -f1` |
| 83 | clangvlo=`echo $clangver | cut -d . -f2` |
| 84 | compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null` |
| 85 | flags_dbg_all="-g -g0 -g1 -g2 -g3" |
| 86 | flags_dbg_all="$flags_dbg_all -ggdb" |
| 87 | flags_dbg_all="$flags_dbg_all -gstabs" |
| 88 | flags_dbg_all="$flags_dbg_all -gstabs+" |
| 89 | flags_dbg_all="$flags_dbg_all -gcoff" |
| 90 | flags_dbg_all="$flags_dbg_all -gxcoff" |
| 91 | flags_dbg_all="$flags_dbg_all -gdwarf-2" |
| 92 | flags_dbg_all="$flags_dbg_all -gvms" |
| 93 | flags_dbg_yes="-g" |
| 94 | flags_dbg_off="-g0" |
| 95 | flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4" |
| 96 | flags_opt_yes="-Os" |
| 97 | flags_opt_off="-O0" |
| 98 | else |
| 99 | AC_MSG_RESULT([no]) |
| 100 | fi |
| 101 | ]) |
| 102 | |
| 103 | |
| 104 | dnl CARES_CHECK_COMPILER_DEC_C |
| 105 | dnl ------------------------------------------------- |
| 106 | dnl Verify if compiler being used is DEC C. |
| 107 | |
| 108 | AC_DEFUN([CARES_CHECK_COMPILER_DEC_C], [ |
| 109 | AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C]) |
| 110 | CURL_CHECK_DEF([__DECC], [], [silent]) |
| 111 | CURL_CHECK_DEF([__DECC_VER], [], [silent]) |
| 112 | if test "$curl_cv_have_def___DECC" = "yes" && |
| 113 | test "$curl_cv_have_def___DECC_VER" = "yes"; then |
| 114 | AC_MSG_RESULT([yes]) |
| 115 | compiler_id="DEC_C" |
| 116 | flags_dbg_all="-g -g0 -g1 -g2 -g3" |
| 117 | flags_dbg_yes="-g2" |
| 118 | flags_dbg_off="-g0" |
| 119 | flags_opt_all="-O -O0 -O1 -O2 -O3 -O4" |
| 120 | flags_opt_yes="-O1" |
| 121 | flags_opt_off="-O0" |
| 122 | else |
| 123 | AC_MSG_RESULT([no]) |
| 124 | fi |
| 125 | ]) |
| 126 | |
| 127 | |
| 128 | dnl CARES_CHECK_COMPILER_GNU_C |
| 129 | dnl ------------------------------------------------- |
| 130 | dnl Verify if compiler being used is GNU C. |
| 131 | |
| 132 | AC_DEFUN([CARES_CHECK_COMPILER_GNU_C], [ |
| 133 | AC_REQUIRE([CARES_CHECK_COMPILER_INTEL_C])dnl |
| 134 | AC_REQUIRE([CARES_CHECK_COMPILER_CLANG])dnl |
| 135 | AC_MSG_CHECKING([if compiler is GNU C]) |
| 136 | CURL_CHECK_DEF([__GNUC__], [], [silent]) |
| 137 | if test "$curl_cv_have_def___GNUC__" = "yes" && |
| 138 | test "$compiler_id" = "unknown"; then |
| 139 | AC_MSG_RESULT([yes]) |
| 140 | compiler_id="GNU_C" |
| 141 | gccver=`$CC -dumpversion` |
| 142 | gccvhi=`echo $gccver | cut -d . -f1` |
| 143 | gccvlo=`echo $gccver | cut -d . -f2` |
| 144 | compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null` |
| 145 | flags_dbg_all="-g -g0 -g1 -g2 -g3" |
| 146 | flags_dbg_all="$flags_dbg_all -ggdb" |
| 147 | flags_dbg_all="$flags_dbg_all -gstabs" |
| 148 | flags_dbg_all="$flags_dbg_all -gstabs+" |
| 149 | flags_dbg_all="$flags_dbg_all -gcoff" |
| 150 | flags_dbg_all="$flags_dbg_all -gxcoff" |
| 151 | flags_dbg_all="$flags_dbg_all -gdwarf-2" |
| 152 | flags_dbg_all="$flags_dbg_all -gvms" |
| 153 | flags_dbg_yes="-g" |
| 154 | flags_dbg_off="-g0" |
| 155 | flags_opt_all="-O -O0 -O1 -O2 -O3 -Os" |
| 156 | flags_opt_yes="-O2" |
| 157 | flags_opt_off="-O0" |
| 158 | CURL_CHECK_DEF([_WIN32], [], [silent]) |
| 159 | else |
| 160 | AC_MSG_RESULT([no]) |
| 161 | fi |
| 162 | ]) |
| 163 | |
| 164 | |
| 165 | dnl CARES_CHECK_COMPILER_HPUX_C |
| 166 | dnl ------------------------------------------------- |
| 167 | dnl Verify if compiler being used is HP-UX C. |
| 168 | |
| 169 | AC_DEFUN([CARES_CHECK_COMPILER_HPUX_C], [ |
| 170 | AC_MSG_CHECKING([if compiler is HP-UX C]) |
| 171 | CURL_CHECK_DEF([__HP_cc], [], [silent]) |
| 172 | if test "$curl_cv_have_def___HP_cc" = "yes"; then |
| 173 | AC_MSG_RESULT([yes]) |
| 174 | compiler_id="HP_UX_C" |
| 175 | flags_dbg_all="-g -s" |
| 176 | flags_dbg_yes="-g" |
| 177 | flags_dbg_off="-s" |
| 178 | flags_opt_all="-O +O0 +O1 +O2 +O3 +O4" |
| 179 | flags_opt_yes="+O2" |
| 180 | flags_opt_off="+O0" |
| 181 | else |
| 182 | AC_MSG_RESULT([no]) |
| 183 | fi |
| 184 | ]) |
| 185 | |
| 186 | |
| 187 | dnl CARES_CHECK_COMPILER_IBM_C |
| 188 | dnl ------------------------------------------------- |
| 189 | dnl Verify if compiler being used is IBM C. |
| 190 | |
| 191 | AC_DEFUN([CARES_CHECK_COMPILER_IBM_C], [ |
| 192 | AC_MSG_CHECKING([if compiler is IBM C]) |
| 193 | CURL_CHECK_DEF([__IBMC__], [], [silent]) |
| 194 | if test "$curl_cv_have_def___IBMC__" = "yes"; then |
| 195 | AC_MSG_RESULT([yes]) |
| 196 | compiler_id="IBM_C" |
| 197 | flags_dbg_all="-g -g0 -g1 -g2 -g3" |
| 198 | flags_dbg_yes="-g" |
| 199 | flags_dbg_off="" |
| 200 | flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5" |
| 201 | flags_opt_all="$flags_opt_all -qnooptimize" |
| 202 | flags_opt_all="$flags_opt_all -qoptimize=0" |
| 203 | flags_opt_all="$flags_opt_all -qoptimize=1" |
| 204 | flags_opt_all="$flags_opt_all -qoptimize=2" |
| 205 | flags_opt_all="$flags_opt_all -qoptimize=3" |
| 206 | flags_opt_all="$flags_opt_all -qoptimize=4" |
| 207 | flags_opt_all="$flags_opt_all -qoptimize=5" |
| 208 | flags_opt_yes="-O2" |
| 209 | flags_opt_off="-qnooptimize" |
| 210 | flags_prefer_cppflags="yes" |
| 211 | else |
| 212 | AC_MSG_RESULT([no]) |
| 213 | fi |
| 214 | ]) |
| 215 | |
| 216 | |
| 217 | dnl CARES_CHECK_COMPILER_INTEL_C |
| 218 | dnl ------------------------------------------------- |
| 219 | dnl Verify if compiler being used is Intel C. |
| 220 | |
| 221 | AC_DEFUN([CARES_CHECK_COMPILER_INTEL_C], [ |
| 222 | AC_BEFORE([$0],[CARES_CHECK_COMPILER_GNU_C])dnl |
| 223 | AC_MSG_CHECKING([if compiler is Intel C]) |
| 224 | CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent]) |
| 225 | if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then |
| 226 | AC_MSG_RESULT([yes]) |
| 227 | compiler_num="$curl_cv_def___INTEL_COMPILER" |
| 228 | CURL_CHECK_DEF([__unix__], [], [silent]) |
| 229 | if test "$curl_cv_have_def___unix__" = "yes"; then |
| 230 | compiler_id="INTEL_UNIX_C" |
| 231 | flags_dbg_all="-g -g0" |
| 232 | flags_dbg_yes="-g" |
| 233 | flags_dbg_off="-g0" |
| 234 | flags_opt_all="-O -O0 -O1 -O2 -O3 -Os" |
| 235 | flags_opt_yes="-O2" |
| 236 | flags_opt_off="-O0" |
| 237 | else |
| 238 | compiler_id="INTEL_WINDOWS_C" |
| 239 | flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-" |
| 240 | flags_dbg_all="$flags_dbg_all /debug" |
| 241 | flags_dbg_all="$flags_dbg_all /debug:none" |
| 242 | flags_dbg_all="$flags_dbg_all /debug:minimal" |
| 243 | flags_dbg_all="$flags_dbg_all /debug:partial" |
| 244 | flags_dbg_all="$flags_dbg_all /debug:full" |
| 245 | flags_dbg_all="$flags_dbg_all /debug:semantic_stepping" |
| 246 | flags_dbg_all="$flags_dbg_all /debug:extended" |
| 247 | flags_dbg_yes="/Zi /Oy-" |
| 248 | flags_dbg_off="/debug:none /Oy-" |
| 249 | flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-" |
| 250 | flags_opt_yes="/O2" |
| 251 | flags_opt_off="/Od" |
| 252 | fi |
| 253 | else |
| 254 | AC_MSG_RESULT([no]) |
| 255 | fi |
| 256 | ]) |
| 257 | |
| 258 | |
| 259 | dnl CARES_CHECK_COMPILER_LCC |
| 260 | dnl ------------------------------------------------- |
| 261 | dnl Verify if compiler being used is LCC. |
| 262 | |
| 263 | AC_DEFUN([CARES_CHECK_COMPILER_LCC], [ |
| 264 | AC_MSG_CHECKING([if compiler is LCC]) |
| 265 | CURL_CHECK_DEF([__LCC__], [], [silent]) |
| 266 | if test "$curl_cv_have_def___LCC__" = "yes"; then |
| 267 | AC_MSG_RESULT([yes]) |
| 268 | compiler_id="LCC" |
| 269 | flags_dbg_all="-g" |
| 270 | flags_dbg_yes="-g" |
| 271 | flags_dbg_off="" |
| 272 | flags_opt_all="" |
| 273 | flags_opt_yes="" |
| 274 | flags_opt_off="" |
| 275 | else |
| 276 | AC_MSG_RESULT([no]) |
| 277 | fi |
| 278 | ]) |
| 279 | |
| 280 | |
| 281 | dnl CARES_CHECK_COMPILER_SGI_MIPS_C |
| 282 | dnl ------------------------------------------------- |
| 283 | dnl Verify if compiler being used is SGI MIPS C. |
| 284 | |
| 285 | AC_DEFUN([CARES_CHECK_COMPILER_SGI_MIPS_C], [ |
| 286 | AC_REQUIRE([CARES_CHECK_COMPILER_SGI_MIPSPRO_C])dnl |
| 287 | AC_MSG_CHECKING([if compiler is SGI MIPS C]) |
| 288 | CURL_CHECK_DEF([__GNUC__], [], [silent]) |
| 289 | CURL_CHECK_DEF([__sgi], [], [silent]) |
| 290 | if test "$curl_cv_have_def___GNUC__" = "no" && |
| 291 | test "$curl_cv_have_def___sgi" = "yes" && |
| 292 | test "$compiler_id" = "unknown"; then |
| 293 | AC_MSG_RESULT([yes]) |
| 294 | compiler_id="SGI_MIPS_C" |
| 295 | flags_dbg_all="-g -g0 -g1 -g2 -g3" |
| 296 | flags_dbg_yes="-g" |
| 297 | flags_dbg_off="-g0" |
| 298 | flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast" |
| 299 | flags_opt_yes="-O2" |
| 300 | flags_opt_off="-O0" |
| 301 | else |
| 302 | AC_MSG_RESULT([no]) |
| 303 | fi |
| 304 | ]) |
| 305 | |
| 306 | |
| 307 | dnl CARES_CHECK_COMPILER_SGI_MIPSPRO_C |
| 308 | dnl ------------------------------------------------- |
| 309 | dnl Verify if compiler being used is SGI MIPSpro C. |
| 310 | |
| 311 | AC_DEFUN([CARES_CHECK_COMPILER_SGI_MIPSPRO_C], [ |
| 312 | AC_BEFORE([$0],[CARES_CHECK_COMPILER_SGI_MIPS_C])dnl |
| 313 | AC_MSG_CHECKING([if compiler is SGI MIPSpro C]) |
| 314 | CURL_CHECK_DEF([__GNUC__], [], [silent]) |
| 315 | CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent]) |
| 316 | CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent]) |
| 317 | if test "$curl_cv_have_def___GNUC__" = "no" && |
| 318 | (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" || |
| 319 | test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then |
| 320 | AC_MSG_RESULT([yes]) |
| 321 | compiler_id="SGI_MIPSPRO_C" |
| 322 | flags_dbg_all="-g -g0 -g1 -g2 -g3" |
| 323 | flags_dbg_yes="-g" |
| 324 | flags_dbg_off="-g0" |
| 325 | flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast" |
| 326 | flags_opt_yes="-O2" |
| 327 | flags_opt_off="-O0" |
| 328 | else |
| 329 | AC_MSG_RESULT([no]) |
| 330 | fi |
| 331 | ]) |
| 332 | |
| 333 | |
| 334 | dnl CARES_CHECK_COMPILER_SUNPRO_C |
| 335 | dnl ------------------------------------------------- |
| 336 | dnl Verify if compiler being used is SunPro C. |
| 337 | |
| 338 | AC_DEFUN([CARES_CHECK_COMPILER_SUNPRO_C], [ |
| 339 | AC_MSG_CHECKING([if compiler is SunPro C]) |
| 340 | CURL_CHECK_DEF([__SUNPRO_C], [], [silent]) |
| 341 | if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then |
| 342 | AC_MSG_RESULT([yes]) |
| 343 | compiler_id="SUNPRO_C" |
| 344 | flags_dbg_all="-g -s" |
| 345 | flags_dbg_yes="-g" |
| 346 | flags_dbg_off="-s" |
| 347 | flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5" |
| 348 | flags_opt_yes="-xO2" |
| 349 | flags_opt_off="" |
| 350 | else |
| 351 | AC_MSG_RESULT([no]) |
| 352 | fi |
| 353 | ]) |
| 354 | |
| 355 | |
| 356 | dnl CARES_CHECK_COMPILER_TINY_C |
| 357 | dnl ------------------------------------------------- |
| 358 | dnl Verify if compiler being used is Tiny C. |
| 359 | |
| 360 | AC_DEFUN([CARES_CHECK_COMPILER_TINY_C], [ |
| 361 | AC_MSG_CHECKING([if compiler is Tiny C]) |
| 362 | CURL_CHECK_DEF([__TINYC__], [], [silent]) |
| 363 | if test "$curl_cv_have_def___TINYC__" = "yes"; then |
| 364 | AC_MSG_RESULT([yes]) |
| 365 | compiler_id="TINY_C" |
| 366 | flags_dbg_all="-g -b" |
| 367 | flags_dbg_yes="-g" |
| 368 | flags_dbg_off="" |
| 369 | flags_opt_all="" |
| 370 | flags_opt_yes="" |
| 371 | flags_opt_off="" |
| 372 | else |
| 373 | AC_MSG_RESULT([no]) |
| 374 | fi |
| 375 | ]) |
| 376 | |
| 377 | |
| 378 | dnl CARES_CHECK_COMPILER_WATCOM_C |
| 379 | dnl ------------------------------------------------- |
| 380 | dnl Verify if compiler being used is Watcom C. |
| 381 | |
| 382 | AC_DEFUN([CARES_CHECK_COMPILER_WATCOM_C], [ |
| 383 | AC_MSG_CHECKING([if compiler is Watcom C]) |
| 384 | CURL_CHECK_DEF([__WATCOMC__], [], [silent]) |
| 385 | if test "$curl_cv_have_def___WATCOMC__" = "yes"; then |
| 386 | AC_MSG_RESULT([yes]) |
| 387 | CURL_CHECK_DEF([__UNIX__], [], [silent]) |
| 388 | if test "$curl_cv_have_def___UNIX__" = "yes"; then |
| 389 | compiler_id="WATCOM_UNIX_C" |
| 390 | flags_dbg_all="-g1 -g1+ -g2 -g3" |
| 391 | flags_dbg_yes="-g2" |
| 392 | flags_dbg_off="" |
| 393 | flags_opt_all="-O0 -O1 -O2 -O3" |
| 394 | flags_opt_yes="-O2" |
| 395 | flags_opt_off="-O0" |
| 396 | else |
| 397 | compiler_id="WATCOM_WINDOWS_C" |
| 398 | flags_dbg_all="" |
| 399 | flags_dbg_yes="" |
| 400 | flags_dbg_off="" |
| 401 | flags_opt_all="" |
| 402 | flags_opt_yes="" |
| 403 | flags_opt_off="" |
| 404 | fi |
| 405 | else |
| 406 | AC_MSG_RESULT([no]) |
| 407 | fi |
| 408 | ]) |
| 409 | |
| 410 | |
| 411 | dnl CARES_CONVERT_INCLUDE_TO_ISYSTEM |
| 412 | dnl ------------------------------------------------- |
| 413 | dnl Changes standard include paths present in CFLAGS |
| 414 | dnl and CPPFLAGS into isystem include paths. This is |
| 415 | dnl done to prevent GNUC from generating warnings on |
| 416 | dnl headers from these locations, although on ancient |
| 417 | dnl GNUC versions these warnings are not silenced. |
| 418 | |
| 419 | AC_DEFUN([CARES_CONVERT_INCLUDE_TO_ISYSTEM], [ |
| 420 | AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl |
| 421 | AC_REQUIRE([CARES_CHECK_COMPILER])dnl |
| 422 | if test "$compiler_id" = "GNU_C" || |
| 423 | test "$compiler_id" = "CLANG"; then |
| 424 | tmp_has_include="no" |
| 425 | tmp_chg_FLAGS="$CFLAGS" |
| 426 | for word1 in $tmp_chg_FLAGS; do |
| 427 | case "$word1" in |
| 428 | -I*) |
| 429 | tmp_has_include="yes" |
| 430 | ;; |
| 431 | esac |
| 432 | done |
| 433 | if test "$tmp_has_include" = "yes"; then |
| 434 | tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'` |
| 435 | tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'` |
| 436 | CFLAGS="$tmp_chg_FLAGS" |
| 437 | squeeze CFLAGS |
| 438 | fi |
| 439 | tmp_has_include="no" |
| 440 | tmp_chg_FLAGS="$CPPFLAGS" |
| 441 | for word1 in $tmp_chg_FLAGS; do |
| 442 | case "$word1" in |
| 443 | -I*) |
| 444 | tmp_has_include="yes" |
| 445 | ;; |
| 446 | esac |
| 447 | done |
| 448 | if test "$tmp_has_include" = "yes"; then |
| 449 | tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'` |
| 450 | tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'` |
| 451 | CPPFLAGS="$tmp_chg_FLAGS" |
| 452 | squeeze CPPFLAGS |
| 453 | fi |
| 454 | fi |
| 455 | ]) |
| 456 | |
| 457 | |
| 458 | dnl CARES_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS]) |
| 459 | dnl ------------------------------------------------- |
| 460 | dnl Verify if the C compiler seems to work with the |
| 461 | dnl settings that are 'active' at the time the test |
| 462 | dnl is performed. |
| 463 | |
| 464 | AC_DEFUN([CARES_COMPILER_WORKS_IFELSE], [ |
| 465 | dnl compilation capability verification |
| 466 | tmp_compiler_works="unknown" |
| 467 | AC_COMPILE_IFELSE([ |
| 468 | AC_LANG_PROGRAM([[ |
| 469 | ]],[[ |
| 470 | int i = 1; |
| 471 | return i; |
| 472 | ]]) |
| 473 | ],[ |
| 474 | tmp_compiler_works="yes" |
| 475 | ],[ |
| 476 | tmp_compiler_works="no" |
| 477 | echo " " >&6 |
| 478 | sed 's/^/cc-fail: /' conftest.err >&6 |
| 479 | echo " " >&6 |
| 480 | ]) |
| 481 | dnl linking capability verification |
| 482 | if test "$tmp_compiler_works" = "yes"; then |
| 483 | AC_LINK_IFELSE([ |
| 484 | AC_LANG_PROGRAM([[ |
| 485 | ]],[[ |
| 486 | int i = 1; |
| 487 | return i; |
| 488 | ]]) |
| 489 | ],[ |
| 490 | tmp_compiler_works="yes" |
| 491 | ],[ |
| 492 | tmp_compiler_works="no" |
| 493 | echo " " >&6 |
| 494 | sed 's/^/link-fail: /' conftest.err >&6 |
| 495 | echo " " >&6 |
| 496 | ]) |
| 497 | fi |
| 498 | dnl only do runtime verification when not cross-compiling |
| 499 | if test "x$cross_compiling" != "xyes" && |
| 500 | test "$tmp_compiler_works" = "yes"; then |
| 501 | AC_RUN_IFELSE([ |
| 502 | AC_LANG_PROGRAM([[ |
| 503 | # ifdef __STDC__ |
| 504 | # include <stdlib.h> |
| 505 | # endif |
| 506 | ]],[[ |
| 507 | int i = 0; |
| 508 | exit(i); |
| 509 | ]]) |
| 510 | ],[ |
| 511 | tmp_compiler_works="yes" |
| 512 | ],[ |
| 513 | tmp_compiler_works="no" |
| 514 | echo " " >&6 |
| 515 | echo "run-fail: test program exited with status $ac_status" >&6 |
| 516 | echo " " >&6 |
| 517 | ]) |
| 518 | fi |
| 519 | dnl branch upon test result |
| 520 | if test "$tmp_compiler_works" = "yes"; then |
| 521 | ifelse($1,,:,[$1]) |
| 522 | ifelse($2,,,[else |
| 523 | $2]) |
| 524 | fi |
| 525 | ]) |
| 526 | |
| 527 | |
| 528 | dnl CARES_SET_COMPILER_BASIC_OPTS |
| 529 | dnl ------------------------------------------------- |
| 530 | dnl Sets compiler specific options/flags which do not |
| 531 | dnl depend on configure's debug, optimize or warnings |
| 532 | dnl options. |
| 533 | |
| 534 | AC_DEFUN([CARES_SET_COMPILER_BASIC_OPTS], [ |
| 535 | AC_REQUIRE([CARES_CHECK_COMPILER])dnl |
| 536 | AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl |
| 537 | # |
| 538 | if test "$compiler_id" != "unknown"; then |
| 539 | # |
| 540 | if test "$compiler_id" = "GNU_C" || |
| 541 | test "$compiler_id" = "CLANG"; then |
| 542 | CARES_CONVERT_INCLUDE_TO_ISYSTEM |
| 543 | fi |
| 544 | # |
| 545 | tmp_save_CPPFLAGS="$CPPFLAGS" |
| 546 | tmp_save_CFLAGS="$CFLAGS" |
| 547 | tmp_CPPFLAGS="" |
| 548 | tmp_CFLAGS="" |
| 549 | # |
| 550 | case "$compiler_id" in |
| 551 | # |
| 552 | CLANG) |
| 553 | # |
| 554 | dnl Disable warnings for unused arguments, otherwise clang will |
| 555 | dnl warn about compile-time arguments used during link-time, like |
| 556 | dnl -O and -g and -pedantic. |
| 557 | tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments" |
| 558 | ;; |
| 559 | # |
| 560 | DEC_C) |
| 561 | # |
| 562 | dnl Select strict ANSI C compiler mode |
| 563 | tmp_CFLAGS="$tmp_CFLAGS -std1" |
| 564 | dnl Turn off optimizer ANSI C aliasing rules |
| 565 | tmp_CFLAGS="$tmp_CFLAGS -noansi_alias" |
| 566 | dnl Generate warnings for missing function prototypes |
| 567 | tmp_CFLAGS="$tmp_CFLAGS -warnprotos" |
| 568 | dnl Change some warnings into fatal errors |
| 569 | tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs" |
| 570 | ;; |
| 571 | # |
| 572 | GNU_C) |
| 573 | # |
| 574 | dnl Placeholder |
| 575 | tmp_CFLAGS="$tmp_CFLAGS" |
| 576 | ;; |
| 577 | # |
| 578 | HP_UX_C) |
| 579 | # |
| 580 | dnl Disallow run-time dereferencing of null pointers |
| 581 | tmp_CFLAGS="$tmp_CFLAGS -z" |
| 582 | dnl Disable some remarks |
| 583 | dnl #4227: padding struct with n bytes to align member |
| 584 | dnl #4255: padding size of struct with n bytes to alignment boundary |
| 585 | tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255" |
| 586 | ;; |
| 587 | # |
| 588 | IBM_C) |
| 589 | # |
| 590 | dnl Ensure that compiler optimizations are always thread-safe. |
| 591 | tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded" |
| 592 | dnl Disable type based strict aliasing optimizations, using worst |
| 593 | dnl case aliasing assumptions when compiling. Type based aliasing |
| 594 | dnl would restrict the lvalues that could be safely used to access |
| 595 | dnl a data object. |
| 596 | tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias" |
| 597 | dnl Force compiler to stop after the compilation phase, without |
| 598 | dnl generating an object code file when compilation has errors. |
| 599 | tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e" |
| 600 | ;; |
| 601 | # |
| 602 | INTEL_UNIX_C) |
| 603 | # |
| 604 | dnl On unix this compiler uses gcc's header files, so |
| 605 | dnl we select ANSI C89 dialect plus GNU extensions. |
| 606 | tmp_CFLAGS="$tmp_CFLAGS -std=gnu89" |
| 607 | dnl Change some warnings into errors |
| 608 | dnl #140: too many arguments in function call |
| 609 | dnl #147: declaration is incompatible with 'previous one' |
| 610 | dnl #165: too few arguments in function call |
| 611 | dnl #266: function declared implicitly |
| 612 | tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266" |
| 613 | dnl Disable some remarks |
| 614 | dnl #279: controlling expression is constant |
| 615 | dnl #981: operands are evaluated in unspecified order |
| 616 | dnl #1469: "cc" clobber ignored |
| 617 | tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469" |
| 618 | ;; |
| 619 | # |
| 620 | INTEL_WINDOWS_C) |
| 621 | # |
| 622 | dnl Placeholder |
| 623 | tmp_CFLAGS="$tmp_CFLAGS" |
| 624 | ;; |
| 625 | # |
| 626 | LCC) |
| 627 | # |
| 628 | dnl Disallow run-time dereferencing of null pointers |
| 629 | tmp_CFLAGS="$tmp_CFLAGS -n" |
| 630 | ;; |
| 631 | # |
| 632 | SGI_MIPS_C) |
| 633 | # |
| 634 | dnl Placeholder |
| 635 | tmp_CFLAGS="$tmp_CFLAGS" |
| 636 | ;; |
| 637 | # |
| 638 | SGI_MIPSPRO_C) |
| 639 | # |
| 640 | dnl Placeholder |
| 641 | tmp_CFLAGS="$tmp_CFLAGS" |
| 642 | ;; |
| 643 | # |
| 644 | SUNPRO_C) |
| 645 | # |
| 646 | dnl Placeholder |
| 647 | tmp_CFLAGS="$tmp_CFLAGS" |
| 648 | ;; |
| 649 | # |
| 650 | TINY_C) |
| 651 | # |
| 652 | dnl Placeholder |
| 653 | tmp_CFLAGS="$tmp_CFLAGS" |
| 654 | ;; |
| 655 | # |
| 656 | WATCOM_UNIX_C) |
| 657 | # |
| 658 | dnl Placeholder |
| 659 | tmp_CFLAGS="$tmp_CFLAGS" |
| 660 | ;; |
| 661 | # |
| 662 | WATCOM_WINDOWS_C) |
| 663 | # |
| 664 | dnl Placeholder |
| 665 | tmp_CFLAGS="$tmp_CFLAGS" |
| 666 | ;; |
| 667 | # |
| 668 | esac |
| 669 | # |
| 670 | squeeze tmp_CPPFLAGS |
| 671 | squeeze tmp_CFLAGS |
| 672 | # |
| 673 | if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then |
| 674 | AC_MSG_CHECKING([if compiler accepts some basic options]) |
| 675 | CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" |
| 676 | CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" |
| 677 | squeeze CPPFLAGS |
| 678 | squeeze CFLAGS |
| 679 | CARES_COMPILER_WORKS_IFELSE([ |
| 680 | AC_MSG_RESULT([yes]) |
| 681 | AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS]) |
| 682 | ],[ |
| 683 | AC_MSG_RESULT([no]) |
| 684 | AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS]) |
| 685 | dnl restore initial settings |
| 686 | CPPFLAGS="$tmp_save_CPPFLAGS" |
| 687 | CFLAGS="$tmp_save_CFLAGS" |
| 688 | ]) |
| 689 | fi |
| 690 | # |
| 691 | fi |
| 692 | ]) |
| 693 | |
| 694 | |
| 695 | dnl CARES_SET_COMPILER_DEBUG_OPTS |
| 696 | dnl ------------------------------------------------- |
| 697 | dnl Sets compiler specific options/flags which depend |
| 698 | dnl on configure's debug option. |
| 699 | |
| 700 | AC_DEFUN([CARES_SET_COMPILER_DEBUG_OPTS], [ |
| 701 | AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl |
| 702 | AC_REQUIRE([CARES_CHECK_COMPILER])dnl |
| 703 | AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl |
| 704 | # |
| 705 | if test "$compiler_id" != "unknown"; then |
| 706 | # |
| 707 | tmp_save_CFLAGS="$CFLAGS" |
| 708 | tmp_save_CPPFLAGS="$CPPFLAGS" |
| 709 | # |
| 710 | tmp_options="" |
| 711 | tmp_CFLAGS="$CFLAGS" |
| 712 | tmp_CPPFLAGS="$CPPFLAGS" |
| 713 | CARES_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all]) |
| 714 | CARES_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all]) |
| 715 | # |
| 716 | if test "$want_debug" = "yes"; then |
| 717 | AC_MSG_CHECKING([if compiler accepts debug enabling options]) |
| 718 | tmp_options="$flags_dbg_yes" |
| 719 | fi |
| 720 | if test "$want_debug" = "no"; then |
| 721 | AC_MSG_CHECKING([if compiler accepts debug disabling options]) |
| 722 | tmp_options="$flags_dbg_off" |
| 723 | fi |
| 724 | # |
| 725 | if test "$flags_prefer_cppflags" = "yes"; then |
| 726 | CPPFLAGS="$tmp_CPPFLAGS $tmp_options" |
| 727 | CFLAGS="$tmp_CFLAGS" |
| 728 | else |
| 729 | CPPFLAGS="$tmp_CPPFLAGS" |
| 730 | CFLAGS="$tmp_CFLAGS $tmp_options" |
| 731 | fi |
| 732 | squeeze CPPFLAGS |
| 733 | squeeze CFLAGS |
| 734 | CARES_COMPILER_WORKS_IFELSE([ |
| 735 | AC_MSG_RESULT([yes]) |
| 736 | AC_MSG_NOTICE([compiler options added: $tmp_options]) |
| 737 | ],[ |
| 738 | AC_MSG_RESULT([no]) |
| 739 | AC_MSG_WARN([compiler options rejected: $tmp_options]) |
| 740 | dnl restore initial settings |
| 741 | CPPFLAGS="$tmp_save_CPPFLAGS" |
| 742 | CFLAGS="$tmp_save_CFLAGS" |
| 743 | ]) |
| 744 | # |
| 745 | fi |
| 746 | ]) |
| 747 | |
| 748 | |
| 749 | dnl CARES_SET_COMPILER_OPTIMIZE_OPTS |
| 750 | dnl ------------------------------------------------- |
| 751 | dnl Sets compiler specific options/flags which depend |
| 752 | dnl on configure's optimize option. |
| 753 | |
| 754 | AC_DEFUN([CARES_SET_COMPILER_OPTIMIZE_OPTS], [ |
| 755 | AC_REQUIRE([CARES_CHECK_OPTION_OPTIMIZE])dnl |
| 756 | AC_REQUIRE([CARES_CHECK_COMPILER])dnl |
| 757 | AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl |
| 758 | # |
| 759 | if test "$compiler_id" != "unknown"; then |
| 760 | # |
| 761 | tmp_save_CFLAGS="$CFLAGS" |
| 762 | tmp_save_CPPFLAGS="$CPPFLAGS" |
| 763 | # |
| 764 | tmp_options="" |
| 765 | tmp_CFLAGS="$CFLAGS" |
| 766 | tmp_CPPFLAGS="$CPPFLAGS" |
| 767 | honor_optimize_option="yes" |
| 768 | # |
| 769 | dnl If optimization request setting has not been explicitly specified, |
| 770 | dnl it has been derived from the debug setting and initially assumed. |
| 771 | dnl This initially assumed optimizer setting will finally be ignored |
| 772 | dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies |
| 773 | dnl that an initially assumed optimizer setting might not be honored. |
| 774 | # |
| 775 | if test "$want_optimize" = "assume_no" || |
| 776 | test "$want_optimize" = "assume_yes"; then |
| 777 | AC_MSG_CHECKING([if compiler optimizer assumed setting might be used]) |
| 778 | CARES_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[ |
| 779 | honor_optimize_option="no" |
| 780 | ]) |
| 781 | CARES_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[ |
| 782 | honor_optimize_option="no" |
| 783 | ]) |
| 784 | AC_MSG_RESULT([$honor_optimize_option]) |
| 785 | if test "$honor_optimize_option" = "yes"; then |
| 786 | if test "$want_optimize" = "assume_yes"; then |
| 787 | want_optimize="yes" |
| 788 | fi |
| 789 | if test "$want_optimize" = "assume_no"; then |
| 790 | want_optimize="no" |
| 791 | fi |
| 792 | fi |
| 793 | fi |
| 794 | # |
| 795 | if test "$honor_optimize_option" = "yes"; then |
| 796 | CARES_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all]) |
| 797 | CARES_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all]) |
| 798 | if test "$want_optimize" = "yes"; then |
| 799 | AC_MSG_CHECKING([if compiler accepts optimizer enabling options]) |
| 800 | tmp_options="$flags_opt_yes" |
| 801 | fi |
| 802 | if test "$want_optimize" = "no"; then |
| 803 | AC_MSG_CHECKING([if compiler accepts optimizer disabling options]) |
| 804 | tmp_options="$flags_opt_off" |
| 805 | fi |
| 806 | if test "$flags_prefer_cppflags" = "yes"; then |
| 807 | CPPFLAGS="$tmp_CPPFLAGS $tmp_options" |
| 808 | CFLAGS="$tmp_CFLAGS" |
| 809 | else |
| 810 | CPPFLAGS="$tmp_CPPFLAGS" |
| 811 | CFLAGS="$tmp_CFLAGS $tmp_options" |
| 812 | fi |
| 813 | squeeze CPPFLAGS |
| 814 | squeeze CFLAGS |
| 815 | CARES_COMPILER_WORKS_IFELSE([ |
| 816 | AC_MSG_RESULT([yes]) |
| 817 | AC_MSG_NOTICE([compiler options added: $tmp_options]) |
| 818 | ],[ |
| 819 | AC_MSG_RESULT([no]) |
| 820 | AC_MSG_WARN([compiler options rejected: $tmp_options]) |
| 821 | dnl restore initial settings |
| 822 | CPPFLAGS="$tmp_save_CPPFLAGS" |
| 823 | CFLAGS="$tmp_save_CFLAGS" |
| 824 | ]) |
| 825 | fi |
| 826 | # |
| 827 | fi |
| 828 | ]) |
| 829 | |
| 830 | |
| 831 | dnl CARES_SET_COMPILER_WARNING_OPTS |
| 832 | dnl ------------------------------------------------- |
| 833 | dnl Sets compiler options/flags which depend on |
| 834 | dnl configure's warnings given option. |
| 835 | |
| 836 | AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [ |
| 837 | AC_REQUIRE([CARES_CHECK_OPTION_WARNINGS])dnl |
| 838 | AC_REQUIRE([CARES_CHECK_COMPILER])dnl |
| 839 | AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl |
| 840 | # |
| 841 | if test "$compiler_id" != "unknown"; then |
| 842 | # |
| 843 | tmp_save_CPPFLAGS="$CPPFLAGS" |
| 844 | tmp_save_CFLAGS="$CFLAGS" |
| 845 | tmp_CPPFLAGS="" |
| 846 | tmp_CFLAGS="" |
| 847 | # |
| 848 | case "$compiler_id" in |
| 849 | # |
| 850 | CLANG) |
| 851 | # |
| 852 | if test "$want_warnings" = "yes"; then |
| 853 | tmp_CFLAGS="$tmp_CFLAGS -pedantic" |
| 854 | tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra" |
| 855 | tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" |
| 856 | tmp_CFLAGS="$tmp_CFLAGS -Wshadow" |
| 857 | tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs" |
| 858 | tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations" |
| 859 | tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" |
| 860 | tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long" |
| 861 | tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal" |
| 862 | tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare" |
| 863 | tmp_CFLAGS="$tmp_CFLAGS -Wundef" |
| 864 | tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" |
| 865 | tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes" |
| 866 | tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement" |
| 867 | tmp_CFLAGS="$tmp_CFLAGS -Wcast-align" |
| 868 | tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" |
| 869 | tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32" |
| 870 | # |
| 871 | dnl Only clang 1.1 or later |
| 872 | if test "$compiler_num" -ge "101"; then |
| 873 | tmp_CFLAGS="$tmp_CFLAGS -Wunused" |
| 874 | fi |
| 875 | fi |
| 876 | ;; |
| 877 | # |
| 878 | DEC_C) |
| 879 | # |
| 880 | if test "$want_warnings" = "yes"; then |
| 881 | dnl Select a higher warning level than default level2 |
| 882 | tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3" |
| 883 | fi |
| 884 | ;; |
| 885 | # |
| 886 | GNU_C) |
| 887 | # |
| 888 | if test "$want_warnings" = "yes"; then |
| 889 | # |
| 890 | dnl Do not enable -pedantic when cross-compiling with a gcc older |
| 891 | dnl than 3.0, to avoid warnings from third party system headers. |
| 892 | if test "x$cross_compiling" != "xyes" || |
| 893 | test "$compiler_num" -ge "300"; then |
| 894 | tmp_CFLAGS="$tmp_CFLAGS -pedantic" |
| 895 | fi |
| 896 | # |
| 897 | dnl Set of options we believe *ALL* gcc versions support: |
| 898 | tmp_CFLAGS="$tmp_CFLAGS -Wall -W" |
| 899 | # |
| 900 | dnl Only gcc 1.4 or later |
| 901 | if test "$compiler_num" -ge "104"; then |
| 902 | tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings" |
| 903 | dnl If not cross-compiling with a gcc older than 3.0 |
| 904 | if test "x$cross_compiling" != "xyes" || |
| 905 | test "$compiler_num" -ge "300"; then |
| 906 | tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow" |
| 907 | fi |
| 908 | fi |
| 909 | # |
| 910 | dnl Only gcc 2.7 or later |
| 911 | if test "$compiler_num" -ge "207"; then |
| 912 | tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs" |
| 913 | dnl If not cross-compiling with a gcc older than 3.0 |
| 914 | if test "x$cross_compiling" != "xyes" || |
| 915 | test "$compiler_num" -ge "300"; then |
| 916 | tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations" |
| 917 | tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes" |
| 918 | fi |
| 919 | fi |
| 920 | # |
| 921 | dnl Only gcc 2.95 or later |
| 922 | if test "$compiler_num" -ge "295"; then |
| 923 | tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long" |
| 924 | fi |
| 925 | # |
| 926 | dnl Only gcc 2.96 or later |
| 927 | if test "$compiler_num" -ge "296"; then |
| 928 | tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal" |
| 929 | tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare" |
| 930 | dnl -Wundef used only if gcc is 2.96 or later since we get |
| 931 | dnl lots of "`_POSIX_C_SOURCE' is not defined" in system |
| 932 | dnl headers with gcc 2.95.4 on FreeBSD 4.9 |
| 933 | tmp_CFLAGS="$tmp_CFLAGS -Wundef" |
| 934 | fi |
| 935 | # |
| 936 | dnl Only gcc 2.97 or later |
| 937 | if test "$compiler_num" -ge "297"; then |
| 938 | tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral" |
| 939 | fi |
| 940 | # |
| 941 | dnl Only gcc 3.0 or later |
| 942 | if test "$compiler_num" -ge "300"; then |
| 943 | dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on |
| 944 | dnl on i686-Linux as it gives us heaps with false positives. |
| 945 | dnl Also, on gcc 4.0.X it is totally unbearable and complains all |
| 946 | dnl over making it unusable for generic purposes. Let's not use it. |
| 947 | tmp_CFLAGS="$tmp_CFLAGS" |
| 948 | fi |
| 949 | # |
| 950 | dnl Only gcc 3.3 or later |
| 951 | if test "$compiler_num" -ge "303"; then |
| 952 | tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes" |
| 953 | fi |
| 954 | # |
| 955 | dnl Only gcc 3.4 or later |
| 956 | if test "$compiler_num" -ge "304"; then |
| 957 | tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement" |
| 958 | fi |
| 959 | # |
| 960 | dnl Only gcc 4.0 or later |
| 961 | if test "$compiler_num" -ge "400"; then |
| 962 | tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3" |
| 963 | fi |
| 964 | # |
| 965 | dnl Only gcc 4.2 or later |
| 966 | if test "$compiler_num" -ge "402"; then |
| 967 | tmp_CFLAGS="$tmp_CFLAGS -Wcast-align" |
| 968 | fi |
| 969 | # |
| 970 | dnl Only gcc 4.3 or later |
| 971 | if test "$compiler_num" -ge "403"; then |
| 972 | tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration" |
| 973 | tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body" |
| 974 | tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers" |
| 975 | tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla" |
| 976 | fi |
| 977 | # |
| 978 | dnl Only gcc 4.5 or later |
| 979 | if test "$compiler_num" -ge "405"; then |
| 980 | dnl Only windows targets |
| 981 | if test "$curl_cv_have_def__WIN32" = "yes"; then |
| 982 | tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format" |
| 983 | fi |
| 984 | fi |
| 985 | # |
| 986 | fi |
| 987 | # |
| 988 | dnl Do not issue warnings for code in system include paths. |
| 989 | if test "$compiler_num" -ge "300"; then |
| 990 | tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers" |
| 991 | else |
| 992 | dnl When cross-compiling with a gcc older than 3.0, disable |
| 993 | dnl some warnings triggered on third party system headers. |
| 994 | if test "x$cross_compiling" = "xyes"; then |
| 995 | if test "$compiler_num" -ge "104"; then |
| 996 | dnl gcc 1.4 or later |
| 997 | tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow" |
| 998 | fi |
| 999 | if test "$compiler_num" -ge "207"; then |
| 1000 | dnl gcc 2.7 or later |
| 1001 | tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations" |
| 1002 | tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes" |
| 1003 | fi |
| 1004 | fi |
| 1005 | fi |
| 1006 | ;; |
| 1007 | # |
| 1008 | HP_UX_C) |
| 1009 | # |
| 1010 | if test "$want_warnings" = "yes"; then |
| 1011 | dnl Issue all warnings |
| 1012 | tmp_CFLAGS="$tmp_CFLAGS +w1" |
| 1013 | fi |
| 1014 | ;; |
| 1015 | # |
| 1016 | IBM_C) |
| 1017 | # |
| 1018 | dnl Placeholder |
| 1019 | tmp_CFLAGS="$tmp_CFLAGS" |
| 1020 | ;; |
| 1021 | # |
| 1022 | INTEL_UNIX_C) |
| 1023 | # |
| 1024 | if test "$want_warnings" = "yes"; then |
| 1025 | if test "$compiler_num" -gt "600"; then |
| 1026 | dnl Show errors, warnings, and remarks |
| 1027 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2" |
| 1028 | dnl Perform extra compile-time code checking |
| 1029 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck" |
| 1030 | dnl Warn on nested comments |
| 1031 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment" |
| 1032 | dnl Show warnings relative to deprecated features |
| 1033 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated" |
| 1034 | dnl Enable warnings for missing prototypes |
| 1035 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes" |
| 1036 | dnl Enable warnings for 64-bit portability issues |
| 1037 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64" |
| 1038 | dnl Enable warnings for questionable pointer arithmetic |
| 1039 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith" |
| 1040 | dnl Check for function return typw issues |
| 1041 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type" |
| 1042 | dnl Warn on variable declarations hiding a previous one |
| 1043 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow" |
| 1044 | dnl Warn when a variable is used before initialized |
| 1045 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized" |
| 1046 | dnl Warn if a declared function is not used |
| 1047 | tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function" |
| 1048 | fi |
| 1049 | fi |
| 1050 | dnl Disable using EBP register in optimizations |
| 1051 | tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer" |
| 1052 | dnl Disable use of ANSI C aliasing rules in optimizations |
| 1053 | tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing" |
| 1054 | dnl Value-safe optimizations on floating-point data |
| 1055 | tmp_CFLAGS="$tmp_CFLAGS -fp-model precise" |
| 1056 | dnl Only icc 10.0 or later |
| 1057 | if test "$compiler_num" -ge "1000"; then |
| 1058 | dnl Disable vectorizer diagnostic information |
| 1059 | tmp_CFLAGS="$tmp_CFLAGS -vec-report0" |
| 1060 | fi |
| 1061 | ;; |
| 1062 | # |
| 1063 | INTEL_WINDOWS_C) |
| 1064 | # |
| 1065 | dnl Placeholder |
| 1066 | tmp_CFLAGS="$tmp_CFLAGS" |
| 1067 | ;; |
| 1068 | # |
| 1069 | LCC) |
| 1070 | # |
| 1071 | if test "$want_warnings" = "yes"; then |
| 1072 | dnl Highest warning level is double -A, next is single -A. |
| 1073 | dnl Due to the big number of warnings these trigger on third |
| 1074 | dnl party header files it is impractical for us to use any of |
| 1075 | dnl them here. If you want them simply define it in CPPFLAGS. |
| 1076 | tmp_CFLAGS="$tmp_CFLAGS" |
| 1077 | fi |
| 1078 | ;; |
| 1079 | # |
| 1080 | SGI_MIPS_C) |
| 1081 | # |
| 1082 | if test "$want_warnings" = "yes"; then |
| 1083 | dnl Perform stricter semantic and lint-like checks |
| 1084 | tmp_CFLAGS="$tmp_CFLAGS -fullwarn" |
| 1085 | fi |
| 1086 | ;; |
| 1087 | # |
| 1088 | SGI_MIPSPRO_C) |
| 1089 | # |
| 1090 | if test "$want_warnings" = "yes"; then |
| 1091 | dnl Perform stricter semantic and lint-like checks |
| 1092 | tmp_CFLAGS="$tmp_CFLAGS -fullwarn" |
| 1093 | dnl Disable some remarks |
| 1094 | dnl #1209: controlling expression is constant |
| 1095 | tmp_CFLAGS="$tmp_CFLAGS -woff 1209" |
| 1096 | fi |
| 1097 | ;; |
| 1098 | # |
| 1099 | SUNPRO_C) |
| 1100 | # |
| 1101 | if test "$want_warnings" = "yes"; then |
| 1102 | dnl Perform stricter semantic and lint-like checks |
| 1103 | tmp_CFLAGS="$tmp_CFLAGS -v" |
| 1104 | fi |
| 1105 | ;; |
| 1106 | # |
| 1107 | TINY_C) |
| 1108 | # |
| 1109 | if test "$want_warnings" = "yes"; then |
| 1110 | dnl Activate all warnings |
| 1111 | tmp_CFLAGS="$tmp_CFLAGS -Wall" |
| 1112 | dnl Make string constants be of type const char * |
| 1113 | tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings" |
| 1114 | dnl Warn use of unsupported GCC features ignored by TCC |
| 1115 | tmp_CFLAGS="$tmp_CFLAGS -Wunsupported" |
| 1116 | fi |
| 1117 | ;; |
| 1118 | # |
| 1119 | WATCOM_UNIX_C) |
| 1120 | # |
| 1121 | if test "$want_warnings" = "yes"; then |
| 1122 | dnl Issue all warnings |
| 1123 | tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra" |
| 1124 | fi |
| 1125 | ;; |
| 1126 | # |
| 1127 | WATCOM_WINDOWS_C) |
| 1128 | # |
| 1129 | dnl Placeholder |
| 1130 | tmp_CFLAGS="$tmp_CFLAGS" |
| 1131 | ;; |
| 1132 | # |
| 1133 | esac |
| 1134 | # |
| 1135 | squeeze tmp_CPPFLAGS |
| 1136 | squeeze tmp_CFLAGS |
| 1137 | # |
| 1138 | if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then |
| 1139 | AC_MSG_CHECKING([if compiler accepts strict warning options]) |
| 1140 | CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS" |
| 1141 | CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" |
| 1142 | squeeze CPPFLAGS |
| 1143 | squeeze CFLAGS |
| 1144 | CARES_COMPILER_WORKS_IFELSE([ |
| 1145 | AC_MSG_RESULT([yes]) |
| 1146 | AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS]) |
| 1147 | ],[ |
| 1148 | AC_MSG_RESULT([no]) |
| 1149 | AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS]) |
| 1150 | dnl restore initial settings |
| 1151 | CPPFLAGS="$tmp_save_CPPFLAGS" |
| 1152 | CFLAGS="$tmp_save_CFLAGS" |
| 1153 | ]) |
| 1154 | fi |
| 1155 | # |
| 1156 | fi |
| 1157 | ]) |
| 1158 | |
| 1159 | |
| 1160 | dnl CARES_SHFUNC_SQUEEZE |
| 1161 | dnl ------------------------------------------------- |
| 1162 | dnl Declares a shell function squeeze() which removes |
| 1163 | dnl redundant whitespace out of a shell variable. |
| 1164 | |
| 1165 | AC_DEFUN([CARES_SHFUNC_SQUEEZE], [ |
| 1166 | squeeze() { |
| 1167 | _sqz_result="" |
| 1168 | eval _sqz_input=\[$][$]1 |
| 1169 | for _sqz_token in $_sqz_input; do |
| 1170 | if test -z "$_sqz_result"; then |
| 1171 | _sqz_result="$_sqz_token" |
| 1172 | else |
| 1173 | _sqz_result="$_sqz_result $_sqz_token" |
| 1174 | fi |
| 1175 | done |
| 1176 | eval [$]1=\$_sqz_result |
| 1177 | return 0 |
| 1178 | } |
| 1179 | ]) |
| 1180 | |
| 1181 | |
| 1182 | dnl CARES_CHECK_CURLDEBUG |
| 1183 | dnl ------------------------------------------------- |
| 1184 | dnl Settings which depend on configure's curldebug given |
| 1185 | dnl option, and other additional configure pre-requisites. |
| 1186 | dnl Using the curl debug memory tracking feature in c-ares |
| 1187 | dnl is a hack that actually can only be used/enabled when |
| 1188 | dnl c-ares is built directly in curl's CVS tree, as a static |
| 1189 | dnl library or as a shared one on those systems on which |
| 1190 | dnl shared libraries support undefined symbols, along with |
| 1191 | dnl an equally configured libcurl. |
| 1192 | |
| 1193 | AC_DEFUN([CARES_CHECK_CURLDEBUG], [ |
| 1194 | AC_REQUIRE([XC_LIBTOOL])dnl |
| 1195 | AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl |
| 1196 | cares_builddir=`pwd` |
| 1197 | supports_curldebug="unknown" |
| 1198 | if test "$want_curldebug" = "yes"; then |
| 1199 | if test "x$enable_shared" != "xno" && |
| 1200 | test "x$enable_shared" != "xyes"; then |
| 1201 | AC_MSG_WARN([unknown enable_shared setting.]) |
| 1202 | supports_curldebug="no" |
| 1203 | fi |
| 1204 | if test "x$enable_static" != "xno" && |
| 1205 | test "x$enable_static" != "xyes"; then |
| 1206 | AC_MSG_WARN([unknown enable_static setting.]) |
| 1207 | supports_curldebug="no" |
| 1208 | fi |
| 1209 | if test "$supports_curldebug" != "no"; then |
| 1210 | if test "$enable_shared" = "yes" && |
| 1211 | test "x$xc_lt_shlib_use_no_undefined" = 'xyes'; then |
| 1212 | supports_curldebug="no" |
| 1213 | AC_MSG_WARN([shared library does not support undefined symbols.]) |
| 1214 | fi |
| 1215 | if test ! -f "$srcdir/../include/curl/curlbuild.h.dist"; then |
| 1216 | AC_MSG_WARN([c-ares source not embedded in curl's CVS tree.]) |
| 1217 | supports_curldebug="no" |
| 1218 | elif test ! -f "$srcdir/../include/curl/Makefile.in"; then |
| 1219 | AC_MSG_WARN([curl's buildconf has not been run.]) |
| 1220 | supports_curldebug="no" |
| 1221 | elif test ! -f "$cares_builddir/../libcurl.pc" || |
| 1222 | test ! -f "$cares_builddir/../include/curl/curlbuild.h"; then |
| 1223 | AC_MSG_WARN([curl's configure has not been run.]) |
| 1224 | supports_curldebug="no" |
| 1225 | elif test ! -f "$cares_builddir/../lib/curl_config.h"; then |
| 1226 | AC_MSG_WARN([libcurl's curl_config.h is missing.]) |
| 1227 | supports_curldebug="no" |
| 1228 | elif test ! -f "$cares_builddir/../config.status"; then |
| 1229 | AC_MSG_WARN([curl's config.status is missing.]) |
| 1230 | supports_curldebug="no" |
| 1231 | fi |
| 1232 | if test "$supports_curldebug" != "no"; then |
| 1233 | grep '^#define USE_ARES' "$cares_builddir/../lib/curl_config.h" >/dev/null |
| 1234 | if test "$?" -ne "0"; then |
| 1235 | AC_MSG_WARN([libcurl configured without c-ares support.]) |
| 1236 | supports_curldebug="no" |
| 1237 | fi |
| 1238 | fi |
| 1239 | if test "$supports_curldebug" != "no"; then |
| 1240 | grep 'CPPFLAGS.*CURLDEBUG' "$cares_builddir/../config.status" >/dev/null |
| 1241 | if test "$?" -ne "0"; then |
| 1242 | AC_MSG_WARN([libcurl configured without curldebug support.]) |
| 1243 | supports_curldebug="no" |
| 1244 | fi |
| 1245 | fi |
| 1246 | fi |
| 1247 | fi |
| 1248 | # |
| 1249 | if test "$want_curldebug" = "yes"; then |
| 1250 | AC_MSG_CHECKING([if curl debug memory tracking can be enabled]) |
| 1251 | test "$supports_curldebug" = "no" || supports_curldebug="yes" |
| 1252 | AC_MSG_RESULT([$supports_curldebug]) |
| 1253 | if test "$supports_curldebug" = "no"; then |
| 1254 | AC_MSG_WARN([cannot enable curl debug memory tracking.]) |
| 1255 | want_curldebug="no" |
| 1256 | fi |
| 1257 | fi |
| 1258 | # |
| 1259 | if test "$want_curldebug" = "yes"; then |
| 1260 | dnl TODO: Verify if the BUILDING_LIBCURL definition is still required. |
| 1261 | AC_DEFINE(BUILDING_LIBCURL, 1, [when building as static part of libcurl]) |
| 1262 | CPPFLAGS="-DCURLDEBUG $CPPFLAGS" |
| 1263 | squeeze CPPFLAGS |
| 1264 | fi |
| 1265 | # |
| 1266 | if test "$want_debug" = "yes"; then |
| 1267 | CPPFLAGS="-DDEBUGBUILD $CPPFLAGS" |
| 1268 | squeeze CPPFLAGS |
| 1269 | fi |
| 1270 | ]) |
| 1271 | |
| 1272 | |
| 1273 | dnl CARES_CHECK_COMPILER_HALT_ON_ERROR |
| 1274 | dnl ------------------------------------------------- |
| 1275 | dnl Verifies if the compiler actually halts after the |
| 1276 | dnl compilation phase without generating any object |
| 1277 | dnl code file, when the source compiles with errors. |
| 1278 | |
| 1279 | AC_DEFUN([CARES_CHECK_COMPILER_HALT_ON_ERROR], [ |
| 1280 | AC_MSG_CHECKING([if compiler halts on compilation errors]) |
| 1281 | AC_COMPILE_IFELSE([ |
| 1282 | AC_LANG_PROGRAM([[ |
| 1283 | ]],[[ |
| 1284 | force compilation error |
| 1285 | ]]) |
| 1286 | ],[ |
| 1287 | AC_MSG_RESULT([no]) |
| 1288 | AC_MSG_ERROR([compiler does not halt on compilation errors.]) |
| 1289 | ],[ |
| 1290 | AC_MSG_RESULT([yes]) |
| 1291 | ]) |
| 1292 | ]) |
| 1293 | |
| 1294 | |
| 1295 | dnl CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE |
| 1296 | dnl ------------------------------------------------- |
| 1297 | dnl Verifies if the compiler actually halts after the |
| 1298 | dnl compilation phase without generating any object |
| 1299 | dnl code file, when the source code tries to define a |
| 1300 | dnl type for a constant array with negative dimension. |
| 1301 | |
| 1302 | AC_DEFUN([CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [ |
| 1303 | AC_REQUIRE([CARES_CHECK_COMPILER_HALT_ON_ERROR])dnl |
| 1304 | AC_MSG_CHECKING([if compiler halts on negative sized arrays]) |
| 1305 | AC_COMPILE_IFELSE([ |
| 1306 | AC_LANG_PROGRAM([[ |
| 1307 | typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ]; |
| 1308 | ]],[[ |
| 1309 | bad_t dummy; |
| 1310 | ]]) |
| 1311 | ],[ |
| 1312 | AC_MSG_RESULT([no]) |
| 1313 | AC_MSG_ERROR([compiler does not halt on negative sized arrays.]) |
| 1314 | ],[ |
| 1315 | AC_MSG_RESULT([yes]) |
| 1316 | ]) |
| 1317 | ]) |
| 1318 | |
| 1319 | |
| 1320 | dnl CARES_CHECK_COMPILER_STRUCT_MEMBER_SIZE |
| 1321 | dnl ------------------------------------------------- |
| 1322 | dnl Verifies if the compiler is capable of handling the |
| 1323 | dnl size of a struct member, struct which is a function |
| 1324 | dnl result, as a compilation-time condition inside the |
| 1325 | dnl type definition of a constant array. |
| 1326 | |
| 1327 | AC_DEFUN([CARES_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [ |
| 1328 | AC_REQUIRE([CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl |
| 1329 | AC_MSG_CHECKING([if compiler struct member size checking works]) |
| 1330 | tst_compiler_check_one_works="unknown" |
| 1331 | AC_COMPILE_IFELSE([ |
| 1332 | AC_LANG_PROGRAM([[ |
| 1333 | struct mystruct { |
| 1334 | int mi; |
| 1335 | char mc; |
| 1336 | struct mystruct *next; |
| 1337 | }; |
| 1338 | struct mystruct myfunc(); |
| 1339 | typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ]; |
| 1340 | typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ]; |
| 1341 | ]],[[ |
| 1342 | good_t1 dummy1; |
| 1343 | good_t2 dummy2; |
| 1344 | ]]) |
| 1345 | ],[ |
| 1346 | tst_compiler_check_one_works="yes" |
| 1347 | ],[ |
| 1348 | tst_compiler_check_one_works="no" |
| 1349 | sed 's/^/cc-src: /' conftest.$ac_ext >&6 |
| 1350 | sed 's/^/cc-err: /' conftest.err >&6 |
| 1351 | ]) |
| 1352 | tst_compiler_check_two_works="unknown" |
| 1353 | AC_COMPILE_IFELSE([ |
| 1354 | AC_LANG_PROGRAM([[ |
| 1355 | struct mystruct { |
| 1356 | int mi; |
| 1357 | char mc; |
| 1358 | struct mystruct *next; |
| 1359 | }; |
| 1360 | struct mystruct myfunc(); |
| 1361 | typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ]; |
| 1362 | typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ]; |
| 1363 | ]],[[ |
| 1364 | bad_t1 dummy1; |
| 1365 | bad_t2 dummy2; |
| 1366 | ]]) |
| 1367 | ],[ |
| 1368 | tst_compiler_check_two_works="no" |
| 1369 | ],[ |
| 1370 | tst_compiler_check_two_works="yes" |
| 1371 | ]) |
| 1372 | if test "$tst_compiler_check_one_works" = "yes" && |
| 1373 | test "$tst_compiler_check_two_works" = "yes"; then |
| 1374 | AC_MSG_RESULT([yes]) |
| 1375 | else |
| 1376 | AC_MSG_RESULT([no]) |
| 1377 | AC_MSG_ERROR([compiler fails struct member size checking.]) |
| 1378 | fi |
| 1379 | ]) |
| 1380 | |
| 1381 | |
| 1382 | dnl CARES_CHECK_COMPILER_SYMBOL_HIDING |
| 1383 | dnl ------------------------------------------------- |
| 1384 | dnl Verify if compiler supports hiding library internal symbols, setting |
| 1385 | dnl shell variable supports_symbol_hiding value as appropriate, as well as |
| 1386 | dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported. |
| 1387 | |
| 1388 | AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [ |
| 1389 | AC_REQUIRE([CARES_CHECK_COMPILER])dnl |
| 1390 | AC_BEFORE([$0],[CARES_CONFIGURE_SYMBOL_HIDING])dnl |
| 1391 | AC_MSG_CHECKING([if compiler supports hiding library internal symbols]) |
| 1392 | supports_symbol_hiding="no" |
| 1393 | symbol_hiding_CFLAGS="" |
| 1394 | symbol_hiding_EXTERN="" |
| 1395 | tmp_CFLAGS="" |
| 1396 | tmp_EXTERN="" |
| 1397 | case "$compiler_id" in |
| 1398 | CLANG) |
| 1399 | dnl All versions of clang support -fvisibility= |
| 1400 | tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" |
| 1401 | tmp_CFLAGS="-fvisibility=hidden" |
| 1402 | supports_symbol_hiding="yes" |
| 1403 | ;; |
| 1404 | GNU_C) |
| 1405 | dnl Only gcc 3.4 or later |
| 1406 | if test "$compiler_num" -ge "304"; then |
| 1407 | if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then |
| 1408 | tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" |
| 1409 | tmp_CFLAGS="-fvisibility=hidden" |
| 1410 | supports_symbol_hiding="yes" |
| 1411 | fi |
| 1412 | fi |
| 1413 | ;; |
| 1414 | INTEL_UNIX_C) |
| 1415 | dnl Only icc 9.0 or later |
| 1416 | if test "$compiler_num" -ge "900"; then |
| 1417 | if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then |
| 1418 | tmp_save_CFLAGS="$CFLAGS" |
| 1419 | CFLAGS="$CFLAGS -fvisibility=hidden" |
| 1420 | AC_LINK_IFELSE([ |
| 1421 | AC_LANG_PROGRAM([[ |
| 1422 | # include <stdio.h> |
| 1423 | ]],[[ |
| 1424 | printf("icc fvisibility bug test"); |
| 1425 | ]]) |
| 1426 | ],[ |
| 1427 | tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))" |
| 1428 | tmp_CFLAGS="-fvisibility=hidden" |
| 1429 | supports_symbol_hiding="yes" |
| 1430 | ]) |
| 1431 | CFLAGS="$tmp_save_CFLAGS" |
| 1432 | fi |
| 1433 | fi |
| 1434 | ;; |
| 1435 | SUNPRO_C) |
| 1436 | if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then |
| 1437 | tmp_EXTERN="__global" |
| 1438 | tmp_CFLAGS="-xldscope=hidden" |
| 1439 | supports_symbol_hiding="yes" |
| 1440 | fi |
| 1441 | ;; |
| 1442 | esac |
| 1443 | if test "$supports_symbol_hiding" = "yes"; then |
| 1444 | tmp_save_CFLAGS="$CFLAGS" |
| 1445 | CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS" |
| 1446 | squeeze CFLAGS |
| 1447 | AC_COMPILE_IFELSE([ |
| 1448 | AC_LANG_PROGRAM([[ |
| 1449 | $tmp_EXTERN char *dummy(char *buff); |
| 1450 | char *dummy(char *buff) |
| 1451 | { |
| 1452 | if(buff) |
| 1453 | return ++buff; |
| 1454 | else |
| 1455 | return buff; |
| 1456 | } |
| 1457 | ]],[[ |
| 1458 | char b[16]; |
| 1459 | char *r = dummy(&b[0]); |
| 1460 | if(r) |
| 1461 | return (int)*r; |
| 1462 | ]]) |
| 1463 | ],[ |
| 1464 | supports_symbol_hiding="yes" |
| 1465 | if test -f conftest.err; then |
| 1466 | grep 'visibility' conftest.err >/dev/null |
| 1467 | if test "$?" -eq "0"; then |
| 1468 | supports_symbol_hiding="no" |
| 1469 | fi |
| 1470 | fi |
| 1471 | ],[ |
| 1472 | supports_symbol_hiding="no" |
| 1473 | echo " " >&6 |
| 1474 | sed 's/^/cc-src: /' conftest.$ac_ext >&6 |
| 1475 | sed 's/^/cc-err: /' conftest.err >&6 |
| 1476 | echo " " >&6 |
| 1477 | ]) |
| 1478 | CFLAGS="$tmp_save_CFLAGS" |
| 1479 | fi |
| 1480 | if test "$supports_symbol_hiding" = "yes"; then |
| 1481 | AC_MSG_RESULT([yes]) |
| 1482 | symbol_hiding_CFLAGS="$tmp_CFLAGS" |
| 1483 | symbol_hiding_EXTERN="$tmp_EXTERN" |
| 1484 | else |
| 1485 | AC_MSG_RESULT([no]) |
| 1486 | fi |
| 1487 | ]) |
| 1488 | |
| 1489 | |
| 1490 | dnl CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH |
| 1491 | dnl ------------------------------------------------- |
| 1492 | dnl Verifies if the compiler actually halts after the |
| 1493 | dnl compilation phase without generating any object |
| 1494 | dnl code file, when the source code tries to redefine |
| 1495 | dnl a prototype which does not match previous one. |
| 1496 | |
| 1497 | AC_DEFUN([CARES_CHECK_COMPILER_PROTOTYPE_MISMATCH], [ |
| 1498 | AC_REQUIRE([CARES_CHECK_COMPILER_HALT_ON_ERROR])dnl |
| 1499 | AC_MSG_CHECKING([if compiler halts on function prototype mismatch]) |
| 1500 | AC_COMPILE_IFELSE([ |
| 1501 | AC_LANG_PROGRAM([[ |
| 1502 | # include <stdlib.h> |
| 1503 | int rand(int n); |
| 1504 | int rand(int n) |
| 1505 | { |
| 1506 | if(n) |
| 1507 | return ++n; |
| 1508 | else |
| 1509 | return n; |
| 1510 | } |
| 1511 | ]],[[ |
| 1512 | int i[2]; |
| 1513 | int j = rand(i[0]); |
| 1514 | if(j) |
| 1515 | return j; |
| 1516 | ]]) |
| 1517 | ],[ |
| 1518 | AC_MSG_RESULT([no]) |
| 1519 | AC_MSG_ERROR([compiler does not halt on function prototype mismatch.]) |
| 1520 | ],[ |
| 1521 | AC_MSG_RESULT([yes]) |
| 1522 | ]) |
| 1523 | ]) |
| 1524 | |
| 1525 | |
| 1526 | dnl CARES_VAR_MATCH (VARNAME, VALUE) |
| 1527 | dnl ------------------------------------------------- |
| 1528 | dnl Verifies if shell variable VARNAME contains VALUE. |
| 1529 | dnl Contents of variable VARNAME and VALUE are handled |
| 1530 | dnl as whitespace separated lists of words. If at least |
| 1531 | dnl one word of VALUE is present in VARNAME the match |
| 1532 | dnl is considered positive, otherwise false. |
| 1533 | |
| 1534 | AC_DEFUN([CARES_VAR_MATCH], [ |
| 1535 | ac_var_match_word="no" |
| 1536 | for word1 in $[$1]; do |
| 1537 | for word2 in [$2]; do |
| 1538 | if test "$word1" = "$word2"; then |
| 1539 | ac_var_match_word="yes" |
| 1540 | fi |
| 1541 | done |
| 1542 | done |
| 1543 | ]) |
| 1544 | |
| 1545 | |
| 1546 | dnl CARES_VAR_MATCH_IFELSE (VARNAME, VALUE, |
| 1547 | dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH]) |
| 1548 | dnl ------------------------------------------------- |
| 1549 | dnl This performs a CURL_VAR_MATCH check and executes |
| 1550 | dnl first branch if the match is positive, otherwise |
| 1551 | dnl the second branch is executed. |
| 1552 | |
| 1553 | AC_DEFUN([CARES_VAR_MATCH_IFELSE], [ |
| 1554 | CARES_VAR_MATCH([$1],[$2]) |
| 1555 | if test "$ac_var_match_word" = "yes"; then |
| 1556 | ifelse($3,,:,[$3]) |
| 1557 | ifelse($4,,,[else |
| 1558 | $4]) |
| 1559 | fi |
| 1560 | ]) |
| 1561 | |
| 1562 | |
| 1563 | dnl CARES_VAR_STRIP (VARNAME, VALUE) |
| 1564 | dnl ------------------------------------------------- |
| 1565 | dnl Contents of variable VARNAME and VALUE are handled |
| 1566 | dnl as whitespace separated lists of words. Each word |
| 1567 | dnl from VALUE is removed from VARNAME when present. |
| 1568 | |
| 1569 | AC_DEFUN([CARES_VAR_STRIP], [ |
| 1570 | AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl |
| 1571 | ac_var_stripped="" |
| 1572 | for word1 in $[$1]; do |
| 1573 | ac_var_strip_word="no" |
| 1574 | for word2 in [$2]; do |
| 1575 | if test "$word1" = "$word2"; then |
| 1576 | ac_var_strip_word="yes" |
| 1577 | fi |
| 1578 | done |
| 1579 | if test "$ac_var_strip_word" = "no"; then |
| 1580 | ac_var_stripped="$ac_var_stripped $word1" |
| 1581 | fi |
| 1582 | done |
| 1583 | dnl squeeze whitespace out of result |
| 1584 | [$1]="$ac_var_stripped" |
| 1585 | squeeze [$1] |
| 1586 | ]) |
| 1587 | |