1 #***************************************************************************
3 # Copyright (C) 2009-2012 by Daniel Stenberg et al
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.
15 #***************************************************************************
17 # File version for 'aclocal' use. Keep it a single number.
21 dnl CARES_CHECK_COMPILER
22 dnl -------------------------------------------------
23 dnl Verify if the C compiler being used is known.
25 AC_DEFUN([CARES_CHECK_COMPILER], [
26 AC_BEFORE([$0],[CARES_CHECK_NO_UNDEFINED])dnl
31 flags_dbg_all="unknown"
32 flags_dbg_yes="unknown"
33 flags_dbg_off="unknown"
34 flags_opt_all="unknown"
35 flags_opt_yes="unknown"
36 flags_opt_off="unknown"
38 flags_prefer_cppflags="no"
40 CARES_CHECK_COMPILER_DEC_C
41 CARES_CHECK_COMPILER_HPUX_C
42 CARES_CHECK_COMPILER_IBM_C
43 CARES_CHECK_COMPILER_INTEL_C
44 CARES_CHECK_COMPILER_CLANG
45 CARES_CHECK_COMPILER_GNU_C
46 CARES_CHECK_COMPILER_LCC
47 CARES_CHECK_COMPILER_SGI_MIPSPRO_C
48 CARES_CHECK_COMPILER_SGI_MIPS_C
49 CARES_CHECK_COMPILER_SUNPRO_C
50 CARES_CHECK_COMPILER_TINY_C
51 CARES_CHECK_COMPILER_WATCOM_C
53 if test "$compiler_id" = "unknown"; then
56 *** Warning: This configure script does not have information about the
57 *** compiler you are using, relative to the flags required to enable or
58 *** disable generation of debug info, optimization options or warnings.
60 *** Whatever settings are present in CFLAGS will be used for this run.
62 *** If you wish to help the c-ares project to better support your compiler
63 *** you can report this and the required info on the c-ares development
64 *** mailing list: http://cool.haxx.se/mailman/listinfo/c-ares/
71 dnl CARES_CHECK_COMPILER_CLANG
72 dnl -------------------------------------------------
73 dnl Verify if compiler being used is clang.
75 AC_DEFUN([CARES_CHECK_COMPILER_CLANG], [
76 AC_BEFORE([$0],[CARES_CHECK_COMPILER_GNU_C])dnl
77 AC_MSG_CHECKING([if compiler is clang])
78 CURL_CHECK_DEF([__clang__], [], [silent])
79 if test "$curl_cv_have_def___clang__" = "yes"; then
82 clangver=`$CC -dumpversion`
83 clangvhi=`echo $clangver | cut -d . -f1`
84 clangvlo=`echo $clangver | cut -d . -f2`
85 compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
86 flags_dbg_all="-g -g0 -g1 -g2 -g3"
87 flags_dbg_all="$flags_dbg_all -ggdb"
88 flags_dbg_all="$flags_dbg_all -gstabs"
89 flags_dbg_all="$flags_dbg_all -gstabs+"
90 flags_dbg_all="$flags_dbg_all -gcoff"
91 flags_dbg_all="$flags_dbg_all -gxcoff"
92 flags_dbg_all="$flags_dbg_all -gdwarf-2"
93 flags_dbg_all="$flags_dbg_all -gvms"
96 flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4"
105 dnl CARES_CHECK_COMPILER_DEC_C
106 dnl -------------------------------------------------
107 dnl Verify if compiler being used is DEC C.
109 AC_DEFUN([CARES_CHECK_COMPILER_DEC_C], [
110 AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
111 CURL_CHECK_DEF([__DECC], [], [silent])
112 CURL_CHECK_DEF([__DECC_VER], [], [silent])
113 if test "$curl_cv_have_def___DECC" = "yes" &&
114 test "$curl_cv_have_def___DECC_VER" = "yes"; then
117 flags_dbg_all="-g -g0 -g1 -g2 -g3"
120 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
129 dnl CARES_CHECK_COMPILER_GNU_C
130 dnl -------------------------------------------------
131 dnl Verify if compiler being used is GNU C.
133 AC_DEFUN([CARES_CHECK_COMPILER_GNU_C], [
134 AC_REQUIRE([CARES_CHECK_COMPILER_INTEL_C])dnl
135 AC_REQUIRE([CARES_CHECK_COMPILER_CLANG])dnl
136 AC_MSG_CHECKING([if compiler is GNU C])
137 CURL_CHECK_DEF([__GNUC__], [], [silent])
138 if test "$curl_cv_have_def___GNUC__" = "yes" &&
139 test "$compiler_id" = "unknown"; then
142 gccver=`$CC -dumpversion`
143 gccvhi=`echo $gccver | cut -d . -f1`
144 gccvlo=`echo $gccver | cut -d . -f2`
145 compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
146 flags_dbg_all="-g -g0 -g1 -g2 -g3"
147 flags_dbg_all="$flags_dbg_all -ggdb"
148 flags_dbg_all="$flags_dbg_all -gstabs"
149 flags_dbg_all="$flags_dbg_all -gstabs+"
150 flags_dbg_all="$flags_dbg_all -gcoff"
151 flags_dbg_all="$flags_dbg_all -gxcoff"
152 flags_dbg_all="$flags_dbg_all -gdwarf-2"
153 flags_dbg_all="$flags_dbg_all -gvms"
156 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
159 CURL_CHECK_DEF([_WIN32], [], [silent])
166 dnl CARES_CHECK_COMPILER_HPUX_C
167 dnl -------------------------------------------------
168 dnl Verify if compiler being used is HP-UX C.
170 AC_DEFUN([CARES_CHECK_COMPILER_HPUX_C], [
171 AC_MSG_CHECKING([if compiler is HP-UX C])
172 CURL_CHECK_DEF([__HP_cc], [], [silent])
173 if test "$curl_cv_have_def___HP_cc" = "yes"; then
175 compiler_id="HP_UX_C"
176 flags_dbg_all="-g -s"
179 flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
188 dnl CARES_CHECK_COMPILER_IBM_C
189 dnl -------------------------------------------------
190 dnl Verify if compiler being used is IBM C.
192 AC_DEFUN([CARES_CHECK_COMPILER_IBM_C], [
193 AC_MSG_CHECKING([if compiler is IBM C])
194 CURL_CHECK_DEF([__IBMC__], [], [silent])
195 if test "$curl_cv_have_def___IBMC__" = "yes"; then
198 flags_dbg_all="-g -g0 -g1 -g2 -g3"
201 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
202 flags_opt_all="$flags_opt_all -qnooptimize"
203 flags_opt_all="$flags_opt_all -qoptimize=0"
204 flags_opt_all="$flags_opt_all -qoptimize=1"
205 flags_opt_all="$flags_opt_all -qoptimize=2"
206 flags_opt_all="$flags_opt_all -qoptimize=3"
207 flags_opt_all="$flags_opt_all -qoptimize=4"
208 flags_opt_all="$flags_opt_all -qoptimize=5"
210 flags_opt_off="-qnooptimize"
211 flags_prefer_cppflags="yes"
218 dnl CARES_CHECK_COMPILER_INTEL_C
219 dnl -------------------------------------------------
220 dnl Verify if compiler being used is Intel C.
222 AC_DEFUN([CARES_CHECK_COMPILER_INTEL_C], [
223 AC_BEFORE([$0],[CARES_CHECK_COMPILER_GNU_C])dnl
224 AC_MSG_CHECKING([if compiler is Intel C])
225 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
226 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
228 compiler_num="$curl_cv_def___INTEL_COMPILER"
229 CURL_CHECK_DEF([__unix__], [], [silent])
230 if test "$curl_cv_have_def___unix__" = "yes"; then
231 compiler_id="INTEL_UNIX_C"
232 flags_dbg_all="-g -g0"
235 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
239 compiler_id="INTEL_WINDOWS_C"
240 flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
241 flags_dbg_all="$flags_dbg_all /debug"
242 flags_dbg_all="$flags_dbg_all /debug:none"
243 flags_dbg_all="$flags_dbg_all /debug:minimal"
244 flags_dbg_all="$flags_dbg_all /debug:partial"
245 flags_dbg_all="$flags_dbg_all /debug:full"
246 flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
247 flags_dbg_all="$flags_dbg_all /debug:extended"
248 flags_dbg_yes="/Zi /Oy-"
249 flags_dbg_off="/debug:none /Oy-"
250 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
260 dnl CARES_CHECK_COMPILER_LCC
261 dnl -------------------------------------------------
262 dnl Verify if compiler being used is LCC.
264 AC_DEFUN([CARES_CHECK_COMPILER_LCC], [
265 AC_MSG_CHECKING([if compiler is LCC])
266 CURL_CHECK_DEF([__LCC__], [], [silent])
267 if test "$curl_cv_have_def___LCC__" = "yes"; then
282 dnl CARES_CHECK_COMPILER_SGI_MIPS_C
283 dnl -------------------------------------------------
284 dnl Verify if compiler being used is SGI MIPS C.
286 AC_DEFUN([CARES_CHECK_COMPILER_SGI_MIPS_C], [
287 AC_REQUIRE([CARES_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
288 AC_MSG_CHECKING([if compiler is SGI MIPS C])
289 CURL_CHECK_DEF([__GNUC__], [], [silent])
290 CURL_CHECK_DEF([__sgi], [], [silent])
291 if test "$curl_cv_have_def___GNUC__" = "no" &&
292 test "$curl_cv_have_def___sgi" = "yes" &&
293 test "$compiler_id" = "unknown"; then
295 compiler_id="SGI_MIPS_C"
296 flags_dbg_all="-g -g0 -g1 -g2 -g3"
299 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
308 dnl CARES_CHECK_COMPILER_SGI_MIPSPRO_C
309 dnl -------------------------------------------------
310 dnl Verify if compiler being used is SGI MIPSpro C.
312 AC_DEFUN([CARES_CHECK_COMPILER_SGI_MIPSPRO_C], [
313 AC_BEFORE([$0],[CARES_CHECK_COMPILER_SGI_MIPS_C])dnl
314 AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
315 CURL_CHECK_DEF([__GNUC__], [], [silent])
316 CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
317 CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
318 if test "$curl_cv_have_def___GNUC__" = "no" &&
319 (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
320 test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
322 compiler_id="SGI_MIPSPRO_C"
323 flags_dbg_all="-g -g0 -g1 -g2 -g3"
326 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
335 dnl CARES_CHECK_COMPILER_SUNPRO_C
336 dnl -------------------------------------------------
337 dnl Verify if compiler being used is SunPro C.
339 AC_DEFUN([CARES_CHECK_COMPILER_SUNPRO_C], [
340 AC_MSG_CHECKING([if compiler is SunPro C])
341 CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
342 if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
344 compiler_id="SUNPRO_C"
345 flags_dbg_all="-g -s"
348 flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
357 dnl CARES_CHECK_COMPILER_TINY_C
358 dnl -------------------------------------------------
359 dnl Verify if compiler being used is Tiny C.
361 AC_DEFUN([CARES_CHECK_COMPILER_TINY_C], [
362 AC_MSG_CHECKING([if compiler is Tiny C])
363 CURL_CHECK_DEF([__TINYC__], [], [silent])
364 if test "$curl_cv_have_def___TINYC__" = "yes"; then
367 flags_dbg_all="-g -b"
379 dnl CARES_CHECK_COMPILER_WATCOM_C
380 dnl -------------------------------------------------
381 dnl Verify if compiler being used is Watcom C.
383 AC_DEFUN([CARES_CHECK_COMPILER_WATCOM_C], [
384 AC_MSG_CHECKING([if compiler is Watcom C])
385 CURL_CHECK_DEF([__WATCOMC__], [], [silent])
386 if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
388 CURL_CHECK_DEF([__UNIX__], [], [silent])
389 if test "$curl_cv_have_def___UNIX__" = "yes"; then
390 compiler_id="WATCOM_UNIX_C"
391 flags_dbg_all="-g1 -g1+ -g2 -g3"
394 flags_opt_all="-O0 -O1 -O2 -O3"
398 compiler_id="WATCOM_WINDOWS_C"
412 dnl CARES_CONVERT_INCLUDE_TO_ISYSTEM
413 dnl -------------------------------------------------
414 dnl Changes standard include paths present in CFLAGS
415 dnl and CPPFLAGS into isystem include paths. This is
416 dnl done to prevent GNUC from generating warnings on
417 dnl headers from these locations, although on ancient
418 dnl GNUC versions these warnings are not silenced.
420 AC_DEFUN([CARES_CONVERT_INCLUDE_TO_ISYSTEM], [
421 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
422 AC_REQUIRE([CARES_CHECK_COMPILER])dnl
423 if test "$compiler_id" = "GNU_C" ||
424 test "$compiler_id" = "CLANG"; then
426 tmp_chg_FLAGS="$CFLAGS"
427 for word1 in $tmp_chg_FLAGS; do
430 tmp_has_include="yes"
434 if test "$tmp_has_include" = "yes"; then
435 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
436 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
437 CFLAGS="$tmp_chg_FLAGS"
441 tmp_chg_FLAGS="$CPPFLAGS"
442 for word1 in $tmp_chg_FLAGS; do
445 tmp_has_include="yes"
449 if test "$tmp_has_include" = "yes"; then
450 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
451 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
452 CPPFLAGS="$tmp_chg_FLAGS"
459 dnl CARES_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
460 dnl -------------------------------------------------
461 dnl Verify if the C compiler seems to work with the
462 dnl settings that are 'active' at the time the test
465 AC_DEFUN([CARES_COMPILER_WORKS_IFELSE], [
466 dnl compilation capability verification
467 tmp_compiler_works="unknown"
475 tmp_compiler_works="yes"
477 tmp_compiler_works="no"
479 sed 's/^/cc-fail: /' conftest.err >&6
482 dnl linking capability verification
483 if test "$tmp_compiler_works" = "yes"; then
491 tmp_compiler_works="yes"
493 tmp_compiler_works="no"
495 sed 's/^/link-fail: /' conftest.err >&6
499 dnl only do runtime verification when not cross-compiling
500 if test "x$cross_compiling" != "xyes" &&
501 test "$tmp_compiler_works" = "yes"; then
512 tmp_compiler_works="yes"
514 tmp_compiler_works="no"
516 echo "run-fail: test program exited with status $ac_status" >&6
520 dnl branch upon test result
521 if test "$tmp_compiler_works" = "yes"; then
529 dnl CARES_SET_COMPILER_BASIC_OPTS
530 dnl -------------------------------------------------
531 dnl Sets compiler specific options/flags which do not
532 dnl depend on configure's debug, optimize or warnings
535 AC_DEFUN([CARES_SET_COMPILER_BASIC_OPTS], [
536 AC_REQUIRE([CARES_CHECK_COMPILER])dnl
537 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
539 if test "$compiler_id" != "unknown"; then
541 if test "$compiler_id" = "GNU_C" ||
542 test "$compiler_id" = "CLANG"; then
543 CARES_CONVERT_INCLUDE_TO_ISYSTEM
546 tmp_save_CPPFLAGS="$CPPFLAGS"
547 tmp_save_CFLAGS="$CFLAGS"
551 case "$compiler_id" in
555 dnl Disable warnings for unused arguments, otherwise clang will
556 dnl warn about compile-time arguments used during link-time, like
557 dnl -O and -g and -pedantic.
558 tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
563 dnl Select strict ANSI C compiler mode
564 tmp_CFLAGS="$tmp_CFLAGS -std1"
565 dnl Turn off optimizer ANSI C aliasing rules
566 tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
567 dnl Generate warnings for missing function prototypes
568 tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
569 dnl Change some warnings into fatal errors
570 tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
576 tmp_CFLAGS="$tmp_CFLAGS"
581 dnl Disallow run-time dereferencing of null pointers
582 tmp_CFLAGS="$tmp_CFLAGS -z"
583 dnl Disable some remarks
584 dnl #4227: padding struct with n bytes to align member
585 dnl #4255: padding size of struct with n bytes to alignment boundary
586 tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
591 dnl Ensure that compiler optimizations are always thread-safe.
592 tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
593 dnl Disable type based strict aliasing optimizations, using worst
594 dnl case aliasing assumptions when compiling. Type based aliasing
595 dnl would restrict the lvalues that could be safely used to access
597 tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
598 dnl Force compiler to stop after the compilation phase, without
599 dnl generating an object code file when compilation has errors.
600 tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
605 dnl On unix this compiler uses gcc's header files, so
606 dnl we select ANSI C89 dialect plus GNU extensions.
607 tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
608 dnl Change some warnings into errors
609 dnl #140: too many arguments in function call
610 dnl #147: declaration is incompatible with 'previous one'
611 dnl #165: too few arguments in function call
612 dnl #266: function declared implicitly
613 tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
614 dnl Disable some remarks
615 dnl #279: controlling expression is constant
616 dnl #981: operands are evaluated in unspecified order
617 dnl #1469: "cc" clobber ignored
618 tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
624 tmp_CFLAGS="$tmp_CFLAGS"
629 dnl Disallow run-time dereferencing of null pointers
630 tmp_CFLAGS="$tmp_CFLAGS -n"
636 tmp_CFLAGS="$tmp_CFLAGS"
642 tmp_CFLAGS="$tmp_CFLAGS"
648 tmp_CFLAGS="$tmp_CFLAGS"
654 tmp_CFLAGS="$tmp_CFLAGS"
660 tmp_CFLAGS="$tmp_CFLAGS"
666 tmp_CFLAGS="$tmp_CFLAGS"
674 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
675 AC_MSG_CHECKING([if compiler accepts some basic options])
676 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
677 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
680 CARES_COMPILER_WORKS_IFELSE([
682 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
685 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
686 dnl restore initial settings
687 CPPFLAGS="$tmp_save_CPPFLAGS"
688 CFLAGS="$tmp_save_CFLAGS"
696 dnl CARES_SET_COMPILER_DEBUG_OPTS
697 dnl -------------------------------------------------
698 dnl Sets compiler specific options/flags which depend
699 dnl on configure's debug option.
701 AC_DEFUN([CARES_SET_COMPILER_DEBUG_OPTS], [
702 AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl
703 AC_REQUIRE([CARES_CHECK_COMPILER])dnl
704 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
706 if test "$compiler_id" != "unknown"; then
708 tmp_save_CFLAGS="$CFLAGS"
709 tmp_save_CPPFLAGS="$CPPFLAGS"
713 tmp_CPPFLAGS="$CPPFLAGS"
714 CARES_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
715 CARES_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
717 if test "$want_debug" = "yes"; then
718 AC_MSG_CHECKING([if compiler accepts debug enabling options])
719 tmp_options="$flags_dbg_yes"
721 if test "$want_debug" = "no"; then
722 AC_MSG_CHECKING([if compiler accepts debug disabling options])
723 tmp_options="$flags_dbg_off"
726 if test "$flags_prefer_cppflags" = "yes"; then
727 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
730 CPPFLAGS="$tmp_CPPFLAGS"
731 CFLAGS="$tmp_CFLAGS $tmp_options"
735 CARES_COMPILER_WORKS_IFELSE([
737 AC_MSG_NOTICE([compiler options added: $tmp_options])
740 AC_MSG_WARN([compiler options rejected: $tmp_options])
741 dnl restore initial settings
742 CPPFLAGS="$tmp_save_CPPFLAGS"
743 CFLAGS="$tmp_save_CFLAGS"
750 dnl CARES_SET_COMPILER_OPTIMIZE_OPTS
751 dnl -------------------------------------------------
752 dnl Sets compiler specific options/flags which depend
753 dnl on configure's optimize option.
755 AC_DEFUN([CARES_SET_COMPILER_OPTIMIZE_OPTS], [
756 AC_REQUIRE([CARES_CHECK_OPTION_OPTIMIZE])dnl
757 AC_REQUIRE([CARES_CHECK_COMPILER])dnl
758 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
760 if test "$compiler_id" != "unknown"; then
762 tmp_save_CFLAGS="$CFLAGS"
763 tmp_save_CPPFLAGS="$CPPFLAGS"
767 tmp_CPPFLAGS="$CPPFLAGS"
768 honor_optimize_option="yes"
770 dnl If optimization request setting has not been explicitly specified,
771 dnl it has been derived from the debug setting and initially assumed.
772 dnl This initially assumed optimizer setting will finally be ignored
773 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
774 dnl that an initially assumed optimizer setting might not be honored.
776 if test "$want_optimize" = "assume_no" ||
777 test "$want_optimize" = "assume_yes"; then
778 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
779 CARES_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
780 honor_optimize_option="no"
782 CARES_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
783 honor_optimize_option="no"
785 AC_MSG_RESULT([$honor_optimize_option])
786 if test "$honor_optimize_option" = "yes"; then
787 if test "$want_optimize" = "assume_yes"; then
790 if test "$want_optimize" = "assume_no"; then
796 if test "$honor_optimize_option" = "yes"; then
797 CARES_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
798 CARES_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
799 if test "$want_optimize" = "yes"; then
800 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
801 tmp_options="$flags_opt_yes"
803 if test "$want_optimize" = "no"; then
804 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
805 tmp_options="$flags_opt_off"
807 if test "$flags_prefer_cppflags" = "yes"; then
808 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
811 CPPFLAGS="$tmp_CPPFLAGS"
812 CFLAGS="$tmp_CFLAGS $tmp_options"
816 CARES_COMPILER_WORKS_IFELSE([
818 AC_MSG_NOTICE([compiler options added: $tmp_options])
821 AC_MSG_WARN([compiler options rejected: $tmp_options])
822 dnl restore initial settings
823 CPPFLAGS="$tmp_save_CPPFLAGS"
824 CFLAGS="$tmp_save_CFLAGS"
832 dnl CARES_SET_COMPILER_WARNING_OPTS
833 dnl -------------------------------------------------
834 dnl Sets compiler options/flags which depend on
835 dnl configure's warnings given option.
837 AC_DEFUN([CARES_SET_COMPILER_WARNING_OPTS], [
838 AC_REQUIRE([CARES_CHECK_OPTION_WARNINGS])dnl
839 AC_REQUIRE([CARES_CHECK_COMPILER])dnl
840 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
842 if test "$compiler_id" != "unknown"; then
844 tmp_save_CPPFLAGS="$CPPFLAGS"
845 tmp_save_CFLAGS="$CFLAGS"
849 case "$compiler_id" in
853 if test "$want_warnings" = "yes"; then
854 dnl All versions of clang support the same warnings as at least
855 dnl gcc 4.2.1 except -Wunused.
856 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
857 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
858 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
859 tmp_CFLAGS="$tmp_CFLAGS -Wshadow"
860 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
861 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
862 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
863 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
864 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
865 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
866 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
867 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
868 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
869 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
870 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
871 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
872 tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32"
873 tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
875 dnl Only clang 1.1 or later
876 if test "$compiler_num" -ge "101"; then
877 tmp_CFLAGS="$tmp_CFLAGS -Wunused"
884 if test "$want_warnings" = "yes"; then
885 dnl Select a higher warning level than default level2
886 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
892 if test "$want_warnings" = "yes"; then
894 dnl Do not enable -pedantic when cross-compiling with a gcc older
895 dnl than 3.0, to avoid warnings from third party system headers.
896 if test "x$cross_compiling" != "xyes" ||
897 test "$compiler_num" -ge "300"; then
898 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
901 dnl Set of options we believe *ALL* gcc versions support:
902 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
904 dnl Only gcc 1.4 or later
905 if test "$compiler_num" -ge "104"; then
906 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
907 dnl If not cross-compiling with a gcc older than 3.0
908 if test "x$cross_compiling" != "xyes" ||
909 test "$compiler_num" -ge "300"; then
910 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
914 dnl Only gcc 2.7 or later
915 if test "$compiler_num" -ge "207"; then
916 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
917 dnl If not cross-compiling with a gcc older than 3.0
918 if test "x$cross_compiling" != "xyes" ||
919 test "$compiler_num" -ge "300"; then
920 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
921 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
925 dnl Only gcc 2.95 or later
926 if test "$compiler_num" -ge "295"; then
927 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
930 dnl Only gcc 2.96 or later
931 if test "$compiler_num" -ge "296"; then
932 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
933 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
934 dnl -Wundef used only if gcc is 2.96 or later since we get
935 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
936 dnl headers with gcc 2.95.4 on FreeBSD 4.9
937 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
940 dnl Only gcc 2.97 or later
941 if test "$compiler_num" -ge "297"; then
942 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
945 dnl Only gcc 3.0 or later
946 if test "$compiler_num" -ge "300"; then
947 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
948 dnl on i686-Linux as it gives us heaps with false positives.
949 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
950 dnl over making it unusable for generic purposes. Let's not use it.
951 tmp_CFLAGS="$tmp_CFLAGS"
954 dnl Only gcc 3.3 or later
955 if test "$compiler_num" -ge "303"; then
956 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
959 dnl Only gcc 3.4 or later
960 if test "$compiler_num" -ge "304"; then
961 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
964 dnl Only gcc 4.0 or later
965 if test "$compiler_num" -ge "400"; then
966 tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
969 dnl Only gcc 4.2 or later
970 if test "$compiler_num" -ge "402"; then
971 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
974 dnl Only gcc 4.3 or later
975 if test "$compiler_num" -ge "403"; then
976 tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
977 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
978 tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
979 tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
982 dnl Only gcc 4.5 or later
983 if test "$compiler_num" -ge "405"; then
984 dnl Only windows targets
985 if test "$curl_cv_have_def__WIN32" = "yes"; then
986 tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
992 dnl Do not issue warnings for code in system include paths.
993 if test "$compiler_num" -ge "300"; then
994 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
996 dnl When cross-compiling with a gcc older than 3.0, disable
997 dnl some warnings triggered on third party system headers.
998 if test "x$cross_compiling" = "xyes"; then
999 if test "$compiler_num" -ge "104"; then
1000 dnl gcc 1.4 or later
1001 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
1003 if test "$compiler_num" -ge "207"; then
1004 dnl gcc 2.7 or later
1005 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
1006 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
1014 if test "$want_warnings" = "yes"; then
1015 dnl Issue all warnings
1016 tmp_CFLAGS="$tmp_CFLAGS +w1"
1023 tmp_CFLAGS="$tmp_CFLAGS"
1028 if test "$want_warnings" = "yes"; then
1029 if test "$compiler_num" -gt "600"; then
1030 dnl Show errors, warnings, and remarks
1031 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1032 dnl Perform extra compile-time code checking
1033 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1034 dnl Warn on nested comments
1035 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1036 dnl Show warnings relative to deprecated features
1037 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1038 dnl Enable warnings for missing prototypes
1039 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1040 dnl Enable warnings for 64-bit portability issues
1041 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1042 dnl Enable warnings for questionable pointer arithmetic
1043 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1044 dnl Check for function return typw issues
1045 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1046 dnl Warn on variable declarations hiding a previous one
1047 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1048 dnl Warn when a variable is used before initialized
1049 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1050 dnl Warn if a declared function is not used
1051 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1054 dnl Disable using EBP register in optimizations
1055 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1056 dnl Disable use of ANSI C aliasing rules in optimizations
1057 tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1058 dnl Value-safe optimizations on floating-point data
1059 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1060 dnl Only icc 10.0 or later
1061 if test "$compiler_num" -ge "1000"; then
1062 dnl Disable vectorizer diagnostic information
1063 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1070 tmp_CFLAGS="$tmp_CFLAGS"
1075 if test "$want_warnings" = "yes"; then
1076 dnl Highest warning level is double -A, next is single -A.
1077 dnl Due to the big number of warnings these trigger on third
1078 dnl party header files it is impractical for us to use any of
1079 dnl them here. If you want them simply define it in CPPFLAGS.
1080 tmp_CFLAGS="$tmp_CFLAGS"
1086 if test "$want_warnings" = "yes"; then
1087 dnl Perform stricter semantic and lint-like checks
1088 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1094 if test "$want_warnings" = "yes"; then
1095 dnl Perform stricter semantic and lint-like checks
1096 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1097 dnl Disable some remarks
1098 dnl #1209: controlling expression is constant
1099 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1105 if test "$want_warnings" = "yes"; then
1106 dnl Perform stricter semantic and lint-like checks
1107 tmp_CFLAGS="$tmp_CFLAGS -v"
1113 if test "$want_warnings" = "yes"; then
1114 dnl Activate all warnings
1115 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1116 dnl Make string constants be of type const char *
1117 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1118 dnl Warn use of unsupported GCC features ignored by TCC
1119 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1125 if test "$want_warnings" = "yes"; then
1126 dnl Issue all warnings
1127 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1134 tmp_CFLAGS="$tmp_CFLAGS"
1139 squeeze tmp_CPPFLAGS
1142 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1143 AC_MSG_CHECKING([if compiler accepts strict warning options])
1144 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1145 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1148 CARES_COMPILER_WORKS_IFELSE([
1149 AC_MSG_RESULT([yes])
1150 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1153 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1154 dnl restore initial settings
1155 CPPFLAGS="$tmp_save_CPPFLAGS"
1156 CFLAGS="$tmp_save_CFLAGS"
1164 dnl CARES_SHFUNC_SQUEEZE
1165 dnl -------------------------------------------------
1166 dnl Declares a shell function squeeze() which removes
1167 dnl redundant whitespace out of a shell variable.
1169 AC_DEFUN([CARES_SHFUNC_SQUEEZE], [
1172 eval _sqz_input=\[$][$]1
1173 for _sqz_token in $_sqz_input; do
1174 if test -z "$_sqz_result"; then
1175 _sqz_result="$_sqz_token"
1177 _sqz_result="$_sqz_result $_sqz_token"
1180 eval [$]1=\$_sqz_result
1186 dnl CARES_CHECK_CURLDEBUG
1187 dnl -------------------------------------------------
1188 dnl Settings which depend on configure's curldebug given
1189 dnl option, and other additional configure pre-requisites.
1190 dnl Using the curl debug memory tracking feature in c-ares
1191 dnl is a hack that actually can only be used/enabled when
1192 dnl c-ares is built directly in curl's CVS tree, as a static
1193 dnl library or as a shared one on those systems on which
1194 dnl shared libraries support undefined symbols, along with
1195 dnl an equally configured libcurl.
1197 AC_DEFUN([CARES_CHECK_CURLDEBUG], [
1198 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
1199 cares_builddir=`pwd`
1200 supports_curldebug="unknown"
1201 if test "$want_curldebug" = "yes"; then
1202 if test "x$enable_shared" != "xno" &&
1203 test "x$enable_shared" != "xyes"; then
1204 AC_MSG_WARN([unknown enable_shared setting.])
1205 supports_curldebug="no"
1207 if test "x$enable_static" != "xno" &&
1208 test "x$enable_static" != "xyes"; then
1209 AC_MSG_WARN([unknown enable_static setting.])
1210 supports_curldebug="no"
1212 if test "$supports_curldebug" != "no"; then
1213 if test "$enable_shared" = "yes" &&
1214 test "$need_no_undefined" = "yes"; then
1215 supports_curldebug="no"
1216 AC_MSG_WARN([shared library does not support undefined symbols.])
1218 if test ! -f "$srcdir/../include/curl/curlbuild.h.dist"; then
1219 AC_MSG_WARN([c-ares source not embedded in curl's CVS tree.])
1220 supports_curldebug="no"
1221 elif test ! -f "$srcdir/../include/curl/Makefile.in"; then
1222 AC_MSG_WARN([curl's buildconf has not been run.])
1223 supports_curldebug="no"
1224 elif test ! -f "$cares_builddir/../libcurl.pc" ||
1225 test ! -f "$cares_builddir/../include/curl/curlbuild.h"; then
1226 AC_MSG_WARN([curl's configure has not been run.])
1227 supports_curldebug="no"
1228 elif test ! -f "$cares_builddir/../lib/curl_config.h"; then
1229 AC_MSG_WARN([libcurl's curl_config.h is missing.])
1230 supports_curldebug="no"
1231 elif test ! -f "$cares_builddir/../config.status"; then
1232 AC_MSG_WARN([curl's config.status is missing.])
1233 supports_curldebug="no"
1235 if test "$supports_curldebug" != "no"; then
1236 grep '^#define USE_ARES' "$cares_builddir/../lib/curl_config.h" >/dev/null
1237 if test "$?" -ne "0"; then
1238 AC_MSG_WARN([libcurl configured without c-ares support.])
1239 supports_curldebug="no"
1242 if test "$supports_curldebug" != "no"; then
1243 grep 'CPPFLAGS.*CURLDEBUG' "$cares_builddir/../config.status" >/dev/null
1244 if test "$?" -ne "0"; then
1245 AC_MSG_WARN([libcurl configured without curldebug support.])
1246 supports_curldebug="no"
1252 if test "$want_curldebug" = "yes"; then
1253 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1254 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1255 AC_MSG_RESULT([$supports_curldebug])
1256 if test "$supports_curldebug" = "no"; then
1257 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1262 if test "$want_curldebug" = "yes"; then
1263 dnl TODO: Verify if the BUILDING_LIBCURL definition is still required.
1264 AC_DEFINE(BUILDING_LIBCURL, 1, [when building as static part of libcurl])
1265 CPPFLAGS="-DCURLDEBUG $CPPFLAGS"
1269 if test "$want_debug" = "yes"; then
1270 CPPFLAGS="-DDEBUGBUILD $CPPFLAGS"
1276 dnl CARES_CHECK_NO_UNDEFINED
1277 dnl -------------------------------------------------
1278 dnl Checks if the -no-undefined flag must be used when
1279 dnl building shared libraries. This is required on all
1280 dnl systems on which shared libraries should not have
1281 dnl references to undefined symbols. This check should
1282 dnl not be done before AC-PROG-LIBTOOL.
1284 AC_DEFUN([CARES_CHECK_NO_UNDEFINED], [
1285 AC_BEFORE([$0],[CARES_CHECK_CURLDEBUG])dnl
1286 AC_MSG_CHECKING([if shared libraries need -no-undefined])
1287 need_no_undefined="no"
1289 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1290 need_no_undefined="yes"
1293 if test "x$allow_undefined" = "xno"; then
1294 need_no_undefined="yes"
1295 elif test "x$allow_undefined_flag" = "xunsupported"; then
1296 need_no_undefined="yes"
1298 AC_MSG_RESULT($need_no_undefined)
1302 dnl CARES_CHECK_PROG_CC
1303 dnl -------------------------------------------------
1304 dnl Check for compiler program, preventing CFLAGS and
1305 dnl CPPFLAGS from being unexpectedly changed.
1307 AC_DEFUN([CARES_CHECK_PROG_CC], [
1308 ac_save_CFLAGS="$CFLAGS"
1309 ac_save_CPPFLAGS="$CPPFLAGS"
1311 CFLAGS="$ac_save_CFLAGS"
1312 CPPFLAGS="$ac_save_CPPFLAGS"
1316 dnl CARES_CHECK_COMPILER_HALT_ON_ERROR
1317 dnl -------------------------------------------------
1318 dnl Verifies if the compiler actually halts after the
1319 dnl compilation phase without generating any object
1320 dnl code file, when the source compiles with errors.
1322 AC_DEFUN([CARES_CHECK_COMPILER_HALT_ON_ERROR], [
1323 AC_MSG_CHECKING([if compiler halts on compilation errors])
1327 force compilation error
1331 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1333 AC_MSG_RESULT([yes])
1338 dnl CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1339 dnl -------------------------------------------------
1340 dnl Verifies if the compiler actually halts after the
1341 dnl compilation phase without generating any object
1342 dnl code file, when the source code tries to define a
1343 dnl type for a constant array with negative dimension.
1345 AC_DEFUN([CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1346 AC_REQUIRE([CARES_CHECK_COMPILER_HALT_ON_ERROR])dnl
1347 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1350 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1356 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1358 AC_MSG_RESULT([yes])
1363 dnl CARES_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1364 dnl -------------------------------------------------
1365 dnl Verifies if the compiler is capable of handling the
1366 dnl size of a struct member, struct which is a function
1367 dnl result, as a compilation-time condition inside the
1368 dnl type definition of a constant array.
1370 AC_DEFUN([CARES_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1371 AC_REQUIRE([CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1372 AC_MSG_CHECKING([if compiler struct member size checking works])
1373 tst_compiler_check_one_works="unknown"
1379 struct mystruct *next;
1381 struct mystruct myfunc();
1382 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1383 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1389 tst_compiler_check_one_works="yes"
1391 tst_compiler_check_one_works="no"
1392 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1393 sed 's/^/cc-err: /' conftest.err >&6
1395 tst_compiler_check_two_works="unknown"
1401 struct mystruct *next;
1403 struct mystruct myfunc();
1404 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1405 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1411 tst_compiler_check_two_works="no"
1413 tst_compiler_check_two_works="yes"
1415 if test "$tst_compiler_check_one_works" = "yes" &&
1416 test "$tst_compiler_check_two_works" = "yes"; then
1417 AC_MSG_RESULT([yes])
1420 AC_MSG_ERROR([compiler fails struct member size checking.])
1425 dnl CARES_CHECK_COMPILER_SYMBOL_HIDING
1426 dnl -------------------------------------------------
1427 dnl Verify if compiler supports hiding library internal symbols, setting
1428 dnl shell variable supports_symbol_hiding value as appropriate, as well as
1429 dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported.
1431 AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [
1432 AC_REQUIRE([CARES_CHECK_COMPILER])dnl
1433 AC_BEFORE([$0],[CARES_CONFIGURE_SYMBOL_HIDING])dnl
1434 AC_MSG_CHECKING([if compiler supports hiding library internal symbols])
1435 supports_symbol_hiding="no"
1436 symbol_hiding_CFLAGS=""
1437 symbol_hiding_EXTERN=""
1440 case "$compiler_id" in
1442 dnl All versions of clang support -fvisibility=
1443 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1444 tmp_CFLAGS="-fvisibility=hidden"
1445 supports_symbol_hiding="yes"
1448 dnl Only gcc 3.4 or later
1449 if test "$compiler_num" -ge "304"; then
1450 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
1451 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1452 tmp_CFLAGS="-fvisibility=hidden"
1453 supports_symbol_hiding="yes"
1458 dnl Only icc 9.0 or later
1459 if test "$compiler_num" -ge "900"; then
1460 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
1461 tmp_save_CFLAGS="$CFLAGS"
1462 CFLAGS="$CFLAGS -fvisibility=hidden"
1467 printf("icc fvisibility bug test");
1470 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1471 tmp_CFLAGS="-fvisibility=hidden"
1472 supports_symbol_hiding="yes"
1474 CFLAGS="$tmp_save_CFLAGS"
1479 if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
1480 tmp_EXTERN="__global"
1481 tmp_CFLAGS="-xldscope=hidden"
1482 supports_symbol_hiding="yes"
1486 if test "$supports_symbol_hiding" = "yes"; then
1487 tmp_save_CFLAGS="$CFLAGS"
1488 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1492 $tmp_EXTERN char *dummy(char *buff);
1493 char *dummy(char *buff)
1502 char *r = dummy(&b[0]);
1507 supports_symbol_hiding="yes"
1508 if test -f conftest.err; then
1509 grep 'visibility' conftest.err >/dev/null
1510 if test "$?" -eq "0"; then
1511 supports_symbol_hiding="no"
1515 supports_symbol_hiding="no"
1517 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1518 sed 's/^/cc-err: /' conftest.err >&6
1521 CFLAGS="$tmp_save_CFLAGS"
1523 if test "$supports_symbol_hiding" = "yes"; then
1524 AC_MSG_RESULT([yes])
1525 symbol_hiding_CFLAGS="$tmp_CFLAGS"
1526 symbol_hiding_EXTERN="$tmp_EXTERN"
1533 dnl CARES_VAR_MATCH (VARNAME, VALUE)
1534 dnl -------------------------------------------------
1535 dnl Verifies if shell variable VARNAME contains VALUE.
1536 dnl Contents of variable VARNAME and VALUE are handled
1537 dnl as whitespace separated lists of words. If at least
1538 dnl one word of VALUE is present in VARNAME the match
1539 dnl is considered positive, otherwise false.
1541 AC_DEFUN([CARES_VAR_MATCH], [
1542 ac_var_match_word="no"
1543 for word1 in $[$1]; do
1544 for word2 in [$2]; do
1545 if test "$word1" = "$word2"; then
1546 ac_var_match_word="yes"
1553 dnl CARES_VAR_MATCH_IFELSE (VARNAME, VALUE,
1554 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1555 dnl -------------------------------------------------
1556 dnl This performs a CURL_VAR_MATCH check and executes
1557 dnl first branch if the match is positive, otherwise
1558 dnl the second branch is executed.
1560 AC_DEFUN([CARES_VAR_MATCH_IFELSE], [
1561 CARES_VAR_MATCH([$1],[$2])
1562 if test "$ac_var_match_word" = "yes"; then
1570 dnl CARES_VAR_STRIP (VARNAME, VALUE)
1571 dnl -------------------------------------------------
1572 dnl Contents of variable VARNAME and VALUE are handled
1573 dnl as whitespace separated lists of words. Each word
1574 dnl from VALUE is removed from VARNAME when present.
1576 AC_DEFUN([CARES_VAR_STRIP], [
1577 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
1579 for word1 in $[$1]; do
1580 ac_var_strip_word="no"
1581 for word2 in [$2]; do
1582 if test "$word1" = "$word2"; then
1583 ac_var_strip_word="yes"
1586 if test "$ac_var_strip_word" = "no"; then
1587 ac_var_stripped="$ac_var_stripped $word1"
1590 dnl squeeze whitespace out of result
1591 [$1]="$ac_var_stripped"