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"
874 dnl Only clang 1.1 or later
875 if test "$compiler_num" -ge "101"; then
876 tmp_CFLAGS="$tmp_CFLAGS -Wunused"
883 if test "$want_warnings" = "yes"; then
884 dnl Select a higher warning level than default level2
885 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
891 if test "$want_warnings" = "yes"; then
893 dnl Do not enable -pedantic when cross-compiling with a gcc older
894 dnl than 3.0, to avoid warnings from third party system headers.
895 if test "x$cross_compiling" != "xyes" ||
896 test "$compiler_num" -ge "300"; then
897 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
900 dnl Set of options we believe *ALL* gcc versions support:
901 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
903 dnl Only gcc 1.4 or later
904 if test "$compiler_num" -ge "104"; then
905 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
906 dnl If not cross-compiling with a gcc older than 3.0
907 if test "x$cross_compiling" != "xyes" ||
908 test "$compiler_num" -ge "300"; then
909 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
913 dnl Only gcc 2.7 or later
914 if test "$compiler_num" -ge "207"; then
915 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
916 dnl If not cross-compiling with a gcc older than 3.0
917 if test "x$cross_compiling" != "xyes" ||
918 test "$compiler_num" -ge "300"; then
919 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
920 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
924 dnl Only gcc 2.95 or later
925 if test "$compiler_num" -ge "295"; then
926 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
929 dnl Only gcc 2.96 or later
930 if test "$compiler_num" -ge "296"; then
931 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
932 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
933 dnl -Wundef used only if gcc is 2.96 or later since we get
934 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
935 dnl headers with gcc 2.95.4 on FreeBSD 4.9
936 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
939 dnl Only gcc 2.97 or later
940 if test "$compiler_num" -ge "297"; then
941 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
944 dnl Only gcc 3.0 or later
945 if test "$compiler_num" -ge "300"; then
946 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
947 dnl on i686-Linux as it gives us heaps with false positives.
948 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
949 dnl over making it unusable for generic purposes. Let's not use it.
950 tmp_CFLAGS="$tmp_CFLAGS"
953 dnl Only gcc 3.3 or later
954 if test "$compiler_num" -ge "303"; then
955 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
958 dnl Only gcc 3.4 or later
959 if test "$compiler_num" -ge "304"; then
960 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
963 dnl Only gcc 4.2 or later
964 if test "$compiler_num" -ge "402"; then
965 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
968 dnl Only gcc 4.3 or later
969 if test "$compiler_num" -ge "403"; then
970 tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
971 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
972 tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
973 tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
976 dnl Only gcc 4.5 or later
977 if test "$compiler_num" -ge "405"; then
978 dnl Only windows targets
979 if test "$curl_cv_have_def__WIN32" = "yes"; then
980 tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
986 dnl Do not issue warnings for code in system include paths.
987 if test "$compiler_num" -ge "300"; then
988 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
990 dnl When cross-compiling with a gcc older than 3.0, disable
991 dnl some warnings triggered on third party system headers.
992 if test "x$cross_compiling" = "xyes"; then
993 if test "$compiler_num" -ge "104"; then
995 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
997 if test "$compiler_num" -ge "207"; then
999 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
1000 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
1008 if test "$want_warnings" = "yes"; then
1009 dnl Issue all warnings
1010 tmp_CFLAGS="$tmp_CFLAGS +w1"
1017 tmp_CFLAGS="$tmp_CFLAGS"
1022 if test "$want_warnings" = "yes"; then
1023 if test "$compiler_num" -gt "600"; then
1024 dnl Show errors, warnings, and remarks
1025 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1026 dnl Perform extra compile-time code checking
1027 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1028 dnl Warn on nested comments
1029 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1030 dnl Show warnings relative to deprecated features
1031 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1032 dnl Enable warnings for missing prototypes
1033 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1034 dnl Enable warnings for 64-bit portability issues
1035 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1036 dnl Enable warnings for questionable pointer arithmetic
1037 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1038 dnl Check for function return typw issues
1039 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1040 dnl Warn on variable declarations hiding a previous one
1041 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1042 dnl Warn when a variable is used before initialized
1043 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1044 dnl Warn if a declared function is not used
1045 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1048 dnl Disable using EBP register in optimizations
1049 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1050 dnl Disable use of ANSI C aliasing rules in optimizations
1051 tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1052 dnl Value-safe optimizations on floating-point data
1053 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1054 dnl Only icc 10.0 or later
1055 if test "$compiler_num" -ge "1000"; then
1056 dnl Disable vectorizer diagnostic information
1057 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1064 tmp_CFLAGS="$tmp_CFLAGS"
1069 if test "$want_warnings" = "yes"; then
1070 dnl Highest warning level is double -A, next is single -A.
1071 dnl Due to the big number of warnings these trigger on third
1072 dnl party header files it is impractical for us to use any of
1073 dnl them here. If you want them simply define it in CPPFLAGS.
1074 tmp_CFLAGS="$tmp_CFLAGS"
1080 if test "$want_warnings" = "yes"; then
1081 dnl Perform stricter semantic and lint-like checks
1082 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1088 if test "$want_warnings" = "yes"; then
1089 dnl Perform stricter semantic and lint-like checks
1090 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1091 dnl Disable some remarks
1092 dnl #1209: controlling expression is constant
1093 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1099 if test "$want_warnings" = "yes"; then
1100 dnl Perform stricter semantic and lint-like checks
1101 tmp_CFLAGS="$tmp_CFLAGS -v"
1107 if test "$want_warnings" = "yes"; then
1108 dnl Activate all warnings
1109 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1110 dnl Make string constants be of type const char *
1111 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1112 dnl Warn use of unsupported GCC features ignored by TCC
1113 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1119 if test "$want_warnings" = "yes"; then
1120 dnl Issue all warnings
1121 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1128 tmp_CFLAGS="$tmp_CFLAGS"
1133 squeeze tmp_CPPFLAGS
1136 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1137 AC_MSG_CHECKING([if compiler accepts strict warning options])
1138 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1139 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1142 CARES_COMPILER_WORKS_IFELSE([
1143 AC_MSG_RESULT([yes])
1144 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1147 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1148 dnl restore initial settings
1149 CPPFLAGS="$tmp_save_CPPFLAGS"
1150 CFLAGS="$tmp_save_CFLAGS"
1158 dnl CARES_SHFUNC_SQUEEZE
1159 dnl -------------------------------------------------
1160 dnl Declares a shell function squeeze() which removes
1161 dnl redundant whitespace out of a shell variable.
1163 AC_DEFUN([CARES_SHFUNC_SQUEEZE], [
1166 eval _sqz_input=\[$][$]1
1167 for _sqz_token in $_sqz_input; do
1168 if test -z "$_sqz_result"; then
1169 _sqz_result="$_sqz_token"
1171 _sqz_result="$_sqz_result $_sqz_token"
1174 eval [$]1=\$_sqz_result
1180 dnl CARES_CHECK_CURLDEBUG
1181 dnl -------------------------------------------------
1182 dnl Settings which depend on configure's curldebug given
1183 dnl option, and other additional configure pre-requisites.
1184 dnl Using the curl debug memory tracking feature in c-ares
1185 dnl is a hack that actually can only be used/enabled when
1186 dnl c-ares is built directly in curl's CVS tree, as a static
1187 dnl library or as a shared one on those systems on which
1188 dnl shared libraries support undefined symbols, along with
1189 dnl an equally configured libcurl.
1191 AC_DEFUN([CARES_CHECK_CURLDEBUG], [
1192 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
1193 cares_builddir=`pwd`
1194 supports_curldebug="unknown"
1195 if test "$want_curldebug" = "yes"; then
1196 if test "x$enable_shared" != "xno" &&
1197 test "x$enable_shared" != "xyes"; then
1198 AC_MSG_WARN([unknown enable_shared setting.])
1199 supports_curldebug="no"
1201 if test "x$enable_static" != "xno" &&
1202 test "x$enable_static" != "xyes"; then
1203 AC_MSG_WARN([unknown enable_static setting.])
1204 supports_curldebug="no"
1206 if test "$supports_curldebug" != "no"; then
1207 if test "$enable_shared" = "yes" &&
1208 test "$need_no_undefined" = "yes"; then
1209 supports_curldebug="no"
1210 AC_MSG_WARN([shared library does not support undefined symbols.])
1212 if test ! -f "$srcdir/../include/curl/curlbuild.h.dist"; then
1213 AC_MSG_WARN([c-ares source not embedded in curl's CVS tree.])
1214 supports_curldebug="no"
1215 elif test ! -f "$srcdir/../include/curl/Makefile.in"; then
1216 AC_MSG_WARN([curl's buildconf has not been run.])
1217 supports_curldebug="no"
1218 elif test ! -f "$cares_builddir/../libcurl.pc" ||
1219 test ! -f "$cares_builddir/../include/curl/curlbuild.h"; then
1220 AC_MSG_WARN([curl's configure has not been run.])
1221 supports_curldebug="no"
1222 elif test ! -f "$cares_builddir/../lib/curl_config.h"; then
1223 AC_MSG_WARN([libcurl's curl_config.h is missing.])
1224 supports_curldebug="no"
1225 elif test ! -f "$cares_builddir/../config.status"; then
1226 AC_MSG_WARN([curl's config.status is missing.])
1227 supports_curldebug="no"
1229 if test "$supports_curldebug" != "no"; then
1230 grep '^#define USE_ARES' "$cares_builddir/../lib/curl_config.h" >/dev/null
1231 if test "$?" -ne "0"; then
1232 AC_MSG_WARN([libcurl configured without c-ares support.])
1233 supports_curldebug="no"
1236 if test "$supports_curldebug" != "no"; then
1237 grep 'CPPFLAGS.*CURLDEBUG' "$cares_builddir/../config.status" >/dev/null
1238 if test "$?" -ne "0"; then
1239 AC_MSG_WARN([libcurl configured without curldebug support.])
1240 supports_curldebug="no"
1246 if test "$want_curldebug" = "yes"; then
1247 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1248 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1249 AC_MSG_RESULT([$supports_curldebug])
1250 if test "$supports_curldebug" = "no"; then
1251 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1256 if test "$want_curldebug" = "yes"; then
1257 dnl TODO: Verify if the BUILDING_LIBCURL definition is still required.
1258 AC_DEFINE(BUILDING_LIBCURL, 1, [when building as static part of libcurl])
1259 CPPFLAGS="-DCURLDEBUG $CPPFLAGS"
1263 if test "$want_debug" = "yes"; then
1264 CPPFLAGS="-DDEBUGBUILD $CPPFLAGS"
1270 dnl CARES_CHECK_NO_UNDEFINED
1271 dnl -------------------------------------------------
1272 dnl Checks if the -no-undefined flag must be used when
1273 dnl building shared libraries. This is required on all
1274 dnl systems on which shared libraries should not have
1275 dnl references to undefined symbols. This check should
1276 dnl not be done before AC-PROG-LIBTOOL.
1278 AC_DEFUN([CARES_CHECK_NO_UNDEFINED], [
1279 AC_BEFORE([$0],[CARES_CHECK_CURLDEBUG])dnl
1280 AC_MSG_CHECKING([if shared libraries need -no-undefined])
1281 need_no_undefined="no"
1283 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1284 need_no_undefined="yes"
1287 if test "x$allow_undefined" = "xno"; then
1288 need_no_undefined="yes"
1289 elif test "x$allow_undefined_flag" = "xunsupported"; then
1290 need_no_undefined="yes"
1292 AC_MSG_RESULT($need_no_undefined)
1296 dnl CARES_CHECK_PROG_CC
1297 dnl -------------------------------------------------
1298 dnl Check for compiler program, preventing CFLAGS and
1299 dnl CPPFLAGS from being unexpectedly changed.
1301 AC_DEFUN([CARES_CHECK_PROG_CC], [
1302 ac_save_CFLAGS="$CFLAGS"
1303 ac_save_CPPFLAGS="$CPPFLAGS"
1305 CFLAGS="$ac_save_CFLAGS"
1306 CPPFLAGS="$ac_save_CPPFLAGS"
1310 dnl CARES_CHECK_COMPILER_HALT_ON_ERROR
1311 dnl -------------------------------------------------
1312 dnl Verifies if the compiler actually halts after the
1313 dnl compilation phase without generating any object
1314 dnl code file, when the source compiles with errors.
1316 AC_DEFUN([CARES_CHECK_COMPILER_HALT_ON_ERROR], [
1317 AC_MSG_CHECKING([if compiler halts on compilation errors])
1321 force compilation error
1325 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1327 AC_MSG_RESULT([yes])
1332 dnl CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1333 dnl -------------------------------------------------
1334 dnl Verifies if the compiler actually halts after the
1335 dnl compilation phase without generating any object
1336 dnl code file, when the source code tries to define a
1337 dnl type for a constant array with negative dimension.
1339 AC_DEFUN([CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1340 AC_REQUIRE([CARES_CHECK_COMPILER_HALT_ON_ERROR])dnl
1341 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1344 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1350 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1352 AC_MSG_RESULT([yes])
1357 dnl CARES_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1358 dnl -------------------------------------------------
1359 dnl Verifies if the compiler is capable of handling the
1360 dnl size of a struct member, struct which is a function
1361 dnl result, as a compilation-time condition inside the
1362 dnl type definition of a constant array.
1364 AC_DEFUN([CARES_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1365 AC_REQUIRE([CARES_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1366 AC_MSG_CHECKING([if compiler struct member size checking works])
1367 tst_compiler_check_one_works="unknown"
1373 struct mystruct *next;
1375 struct mystruct myfunc();
1376 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1377 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1383 tst_compiler_check_one_works="yes"
1385 tst_compiler_check_one_works="no"
1386 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1387 sed 's/^/cc-err: /' conftest.err >&6
1389 tst_compiler_check_two_works="unknown"
1395 struct mystruct *next;
1397 struct mystruct myfunc();
1398 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1399 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1405 tst_compiler_check_two_works="no"
1407 tst_compiler_check_two_works="yes"
1409 if test "$tst_compiler_check_one_works" = "yes" &&
1410 test "$tst_compiler_check_two_works" = "yes"; then
1411 AC_MSG_RESULT([yes])
1414 AC_MSG_ERROR([compiler fails struct member size checking.])
1419 dnl CARES_CHECK_COMPILER_SYMBOL_HIDING
1420 dnl -------------------------------------------------
1421 dnl Verify if compiler supports hiding library internal symbols, setting
1422 dnl shell variable supports_symbol_hiding value as appropriate, as well as
1423 dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported.
1425 AC_DEFUN([CARES_CHECK_COMPILER_SYMBOL_HIDING], [
1426 AC_REQUIRE([CARES_CHECK_COMPILER])dnl
1427 AC_BEFORE([$0],[CARES_CONFIGURE_SYMBOL_HIDING])dnl
1428 AC_MSG_CHECKING([if compiler supports hiding library internal symbols])
1429 supports_symbol_hiding="no"
1430 symbol_hiding_CFLAGS=""
1431 symbol_hiding_EXTERN=""
1434 case "$compiler_id" in
1436 dnl All versions of clang support -fvisibility=
1437 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1438 tmp_CFLAGS="-fvisibility=hidden"
1439 supports_symbol_hiding="yes"
1442 dnl Only gcc 3.4 or later
1443 if test "$compiler_num" -ge "304"; then
1444 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
1445 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1446 tmp_CFLAGS="-fvisibility=hidden"
1447 supports_symbol_hiding="yes"
1452 dnl Only icc 9.0 or later
1453 if test "$compiler_num" -ge "900"; then
1454 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
1455 tmp_save_CFLAGS="$CFLAGS"
1456 CFLAGS="$CFLAGS -fvisibility=hidden"
1461 printf("icc fvisibility bug test");
1464 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1465 tmp_CFLAGS="-fvisibility=hidden"
1466 supports_symbol_hiding="yes"
1468 CFLAGS="$tmp_save_CFLAGS"
1473 if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
1474 tmp_EXTERN="__global"
1475 tmp_CFLAGS="-xldscope=hidden"
1476 supports_symbol_hiding="yes"
1480 if test "$supports_symbol_hiding" = "yes"; then
1481 tmp_save_CFLAGS="$CFLAGS"
1482 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1486 $tmp_EXTERN char *dummy(char *buff);
1487 char *dummy(char *buff)
1496 char *r = dummy(&b[0]);
1501 supports_symbol_hiding="yes"
1502 if test -f conftest.err; then
1503 grep 'visibility' conftest.err >/dev/null
1504 if test "$?" -eq "0"; then
1505 supports_symbol_hiding="no"
1509 supports_symbol_hiding="no"
1511 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1512 sed 's/^/cc-err: /' conftest.err >&6
1515 CFLAGS="$tmp_save_CFLAGS"
1517 if test "$supports_symbol_hiding" = "yes"; then
1518 AC_MSG_RESULT([yes])
1519 symbol_hiding_CFLAGS="$tmp_CFLAGS"
1520 symbol_hiding_EXTERN="$tmp_EXTERN"
1527 dnl CARES_VAR_MATCH (VARNAME, VALUE)
1528 dnl -------------------------------------------------
1529 dnl Verifies if shell variable VARNAME contains VALUE.
1530 dnl Contents of variable VARNAME and VALUE are handled
1531 dnl as whitespace separated lists of words. If at least
1532 dnl one word of VALUE is present in VARNAME the match
1533 dnl is considered positive, otherwise false.
1535 AC_DEFUN([CARES_VAR_MATCH], [
1536 ac_var_match_word="no"
1537 for word1 in $[$1]; do
1538 for word2 in [$2]; do
1539 if test "$word1" = "$word2"; then
1540 ac_var_match_word="yes"
1547 dnl CARES_VAR_MATCH_IFELSE (VARNAME, VALUE,
1548 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1549 dnl -------------------------------------------------
1550 dnl This performs a CURL_VAR_MATCH check and executes
1551 dnl first branch if the match is positive, otherwise
1552 dnl the second branch is executed.
1554 AC_DEFUN([CARES_VAR_MATCH_IFELSE], [
1555 CARES_VAR_MATCH([$1],[$2])
1556 if test "$ac_var_match_word" = "yes"; then
1564 dnl CARES_VAR_STRIP (VARNAME, VALUE)
1565 dnl -------------------------------------------------
1566 dnl Contents of variable VARNAME and VALUE are handled
1567 dnl as whitespace separated lists of words. Each word
1568 dnl from VALUE is removed from VARNAME when present.
1570 AC_DEFUN([CARES_VAR_STRIP], [
1571 AC_REQUIRE([CARES_SHFUNC_SQUEEZE])dnl
1573 for word1 in $[$1]; do
1574 ac_var_strip_word="no"
1575 for word2 in [$2]; do
1576 if test "$word1" = "$word2"; then
1577 ac_var_strip_word="yes"
1580 if test "$ac_var_strip_word" = "no"; then
1581 ac_var_stripped="$ac_var_stripped $word1"
1584 dnl squeeze whitespace out of result
1585 [$1]="$ac_var_stripped"