1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at https://curl.haxx.se/docs/copyright.html.
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
21 #***************************************************************************
23 # File version for 'aclocal' use. Keep it a single number.
27 dnl CURL_CHECK_COMPILER
28 dnl -------------------------------------------------
29 dnl Verify if the C compiler being used is known.
31 AC_DEFUN([CURL_CHECK_COMPILER], [
36 flags_dbg_all="unknown"
37 flags_dbg_yes="unknown"
38 flags_dbg_off="unknown"
39 flags_opt_all="unknown"
40 flags_opt_yes="unknown"
41 flags_opt_off="unknown"
43 flags_prefer_cppflags="no"
45 CURL_CHECK_COMPILER_DEC_C
46 CURL_CHECK_COMPILER_HPUX_C
47 CURL_CHECK_COMPILER_IBM_C
48 CURL_CHECK_COMPILER_INTEL_C
49 CURL_CHECK_COMPILER_CLANG
50 CURL_CHECK_COMPILER_GNU_C
51 CURL_CHECK_COMPILER_LCC
52 CURL_CHECK_COMPILER_SGI_MIPSPRO_C
53 CURL_CHECK_COMPILER_SGI_MIPS_C
54 CURL_CHECK_COMPILER_SUNPRO_C
55 CURL_CHECK_COMPILER_TINY_C
56 CURL_CHECK_COMPILER_WATCOM_C
58 if test "$compiler_id" = "unknown"; then
61 *** Warning: This configure script does not have information about the
62 *** compiler you are using, relative to the flags required to enable or
63 *** disable generation of debug info, optimization options or warnings.
65 *** Whatever settings are present in CFLAGS will be used for this run.
67 *** If you wish to help the curl project to better support your compiler
68 *** you can report this and the required info on the libcurl development
69 *** mailing list: https://cool.haxx.se/mailman/listinfo/curl-library/
76 dnl CURL_CHECK_COMPILER_CLANG
77 dnl -------------------------------------------------
78 dnl Verify if compiler being used is clang.
80 AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [
81 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
82 AC_MSG_CHECKING([if compiler is clang])
83 CURL_CHECK_DEF([__clang__], [], [silent])
84 if test "$curl_cv_have_def___clang__" = "yes"; then
87 fullclangver=`$CC -v 2>&1 | grep version`
88 clangver=`echo $fullclangver | grep "based on LLVM " | "$SED" 's/.*(based on LLVM \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*)/\1/'`
89 if test -z "$clangver"; then
90 if echo $fullclangver | grep "Apple LLVM version " >/dev/null; then
91 dnl Starting with XCode 7 / clang 3.7, Apple clang won't tell its upstream version
94 clangver=`echo $fullclangver | "$SED" 's/.*version \(@<:@0-9@:>@*\.@<:@0-9@:>@*\).*/\1/'`
97 clangvhi=`echo $clangver | cut -d . -f1`
98 clangvlo=`echo $clangver | cut -d . -f2`
99 compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
100 flags_dbg_all="-g -g0 -g1 -g2 -g3"
101 flags_dbg_all="$flags_dbg_all -ggdb"
102 flags_dbg_all="$flags_dbg_all -gstabs"
103 flags_dbg_all="$flags_dbg_all -gstabs+"
104 flags_dbg_all="$flags_dbg_all -gcoff"
105 flags_dbg_all="$flags_dbg_all -gxcoff"
106 flags_dbg_all="$flags_dbg_all -gdwarf-2"
107 flags_dbg_all="$flags_dbg_all -gvms"
110 flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4"
119 dnl CURL_CHECK_COMPILER_DEC_C
120 dnl -------------------------------------------------
121 dnl Verify if compiler being used is DEC C.
123 AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
124 AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
125 CURL_CHECK_DEF([__DECC], [], [silent])
126 CURL_CHECK_DEF([__DECC_VER], [], [silent])
127 if test "$curl_cv_have_def___DECC" = "yes" &&
128 test "$curl_cv_have_def___DECC_VER" = "yes"; then
131 flags_dbg_all="-g -g0 -g1 -g2 -g3"
134 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
143 dnl CURL_CHECK_COMPILER_GNU_C
144 dnl -------------------------------------------------
145 dnl Verify if compiler being used is GNU C.
147 AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
148 AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
149 AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl
150 AC_MSG_CHECKING([if compiler is GNU C])
151 CURL_CHECK_DEF([__GNUC__], [], [silent])
152 if test "$curl_cv_have_def___GNUC__" = "yes" &&
153 test "$compiler_id" = "unknown"; then
156 gccver=`$CC -dumpversion`
157 gccvhi=`echo $gccver | cut -d . -f1`
158 gccvlo=`echo $gccver | cut -d . -f2`
159 compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
160 flags_dbg_all="-g -g0 -g1 -g2 -g3"
161 flags_dbg_all="$flags_dbg_all -ggdb"
162 flags_dbg_all="$flags_dbg_all -gstabs"
163 flags_dbg_all="$flags_dbg_all -gstabs+"
164 flags_dbg_all="$flags_dbg_all -gcoff"
165 flags_dbg_all="$flags_dbg_all -gxcoff"
166 flags_dbg_all="$flags_dbg_all -gdwarf-2"
167 flags_dbg_all="$flags_dbg_all -gvms"
170 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os -Og -Ofast"
173 CURL_CHECK_DEF([_WIN32], [], [silent])
180 dnl CURL_CHECK_COMPILER_HPUX_C
181 dnl -------------------------------------------------
182 dnl Verify if compiler being used is HP-UX C.
184 AC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [
185 AC_MSG_CHECKING([if compiler is HP-UX C])
186 CURL_CHECK_DEF([__HP_cc], [], [silent])
187 if test "$curl_cv_have_def___HP_cc" = "yes"; then
189 compiler_id="HP_UX_C"
190 flags_dbg_all="-g -s"
193 flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
202 dnl CURL_CHECK_COMPILER_IBM_C
203 dnl -------------------------------------------------
204 dnl Verify if compiler being used is IBM C.
206 AC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [
207 AC_MSG_CHECKING([if compiler is IBM C])
208 CURL_CHECK_DEF([__IBMC__], [], [silent])
209 if test "$curl_cv_have_def___IBMC__" = "yes"; then
212 flags_dbg_all="-g -g0 -g1 -g2 -g3"
215 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
216 flags_opt_all="$flags_opt_all -qnooptimize"
217 flags_opt_all="$flags_opt_all -qoptimize=0"
218 flags_opt_all="$flags_opt_all -qoptimize=1"
219 flags_opt_all="$flags_opt_all -qoptimize=2"
220 flags_opt_all="$flags_opt_all -qoptimize=3"
221 flags_opt_all="$flags_opt_all -qoptimize=4"
222 flags_opt_all="$flags_opt_all -qoptimize=5"
224 flags_opt_off="-qnooptimize"
225 flags_prefer_cppflags="yes"
232 dnl CURL_CHECK_COMPILER_INTEL_C
233 dnl -------------------------------------------------
234 dnl Verify if compiler being used is Intel C.
236 AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
237 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
238 AC_MSG_CHECKING([if compiler is Intel C])
239 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
240 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
242 compiler_num="$curl_cv_def___INTEL_COMPILER"
243 CURL_CHECK_DEF([__unix__], [], [silent])
244 if test "$curl_cv_have_def___unix__" = "yes"; then
245 compiler_id="INTEL_UNIX_C"
246 flags_dbg_all="-g -g0"
249 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
253 compiler_id="INTEL_WINDOWS_C"
254 flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
255 flags_dbg_all="$flags_dbg_all /debug"
256 flags_dbg_all="$flags_dbg_all /debug:none"
257 flags_dbg_all="$flags_dbg_all /debug:minimal"
258 flags_dbg_all="$flags_dbg_all /debug:partial"
259 flags_dbg_all="$flags_dbg_all /debug:full"
260 flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
261 flags_dbg_all="$flags_dbg_all /debug:extended"
262 flags_dbg_yes="/Zi /Oy-"
263 flags_dbg_off="/debug:none /Oy-"
264 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
274 dnl CURL_CHECK_COMPILER_LCC
275 dnl -------------------------------------------------
276 dnl Verify if compiler being used is LCC.
278 AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
279 AC_MSG_CHECKING([if compiler is LCC])
280 CURL_CHECK_DEF([__LCC__], [], [silent])
281 if test "$curl_cv_have_def___LCC__" = "yes"; then
296 dnl CURL_CHECK_COMPILER_SGI_MIPS_C
297 dnl -------------------------------------------------
298 dnl Verify if compiler being used is SGI MIPS C.
300 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
301 AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
302 AC_MSG_CHECKING([if compiler is SGI MIPS C])
303 CURL_CHECK_DEF([__GNUC__], [], [silent])
304 CURL_CHECK_DEF([__sgi], [], [silent])
305 if test "$curl_cv_have_def___GNUC__" = "no" &&
306 test "$curl_cv_have_def___sgi" = "yes" &&
307 test "$compiler_id" = "unknown"; then
309 compiler_id="SGI_MIPS_C"
310 flags_dbg_all="-g -g0 -g1 -g2 -g3"
313 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
322 dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
323 dnl -------------------------------------------------
324 dnl Verify if compiler being used is SGI MIPSpro C.
326 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
327 AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
328 AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
329 CURL_CHECK_DEF([__GNUC__], [], [silent])
330 CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
331 CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
332 if test "$curl_cv_have_def___GNUC__" = "no" &&
333 (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
334 test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
336 compiler_id="SGI_MIPSPRO_C"
337 flags_dbg_all="-g -g0 -g1 -g2 -g3"
340 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
349 dnl CURL_CHECK_COMPILER_SUNPRO_C
350 dnl -------------------------------------------------
351 dnl Verify if compiler being used is SunPro C.
353 AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
354 AC_MSG_CHECKING([if compiler is SunPro C])
355 CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
356 if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
358 compiler_id="SUNPRO_C"
359 flags_dbg_all="-g -s"
362 flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
371 dnl CURL_CHECK_COMPILER_TINY_C
372 dnl -------------------------------------------------
373 dnl Verify if compiler being used is Tiny C.
375 AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
376 AC_MSG_CHECKING([if compiler is Tiny C])
377 CURL_CHECK_DEF([__TINYC__], [], [silent])
378 if test "$curl_cv_have_def___TINYC__" = "yes"; then
381 flags_dbg_all="-g -b"
393 dnl CURL_CHECK_COMPILER_WATCOM_C
394 dnl -------------------------------------------------
395 dnl Verify if compiler being used is Watcom C.
397 AC_DEFUN([CURL_CHECK_COMPILER_WATCOM_C], [
398 AC_MSG_CHECKING([if compiler is Watcom C])
399 CURL_CHECK_DEF([__WATCOMC__], [], [silent])
400 if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
402 CURL_CHECK_DEF([__UNIX__], [], [silent])
403 if test "$curl_cv_have_def___UNIX__" = "yes"; then
404 compiler_id="WATCOM_UNIX_C"
405 flags_dbg_all="-g1 -g1+ -g2 -g3"
408 flags_opt_all="-O0 -O1 -O2 -O3"
412 compiler_id="WATCOM_WINDOWS_C"
426 dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
427 dnl -------------------------------------------------
428 dnl Changes standard include paths present in CFLAGS
429 dnl and CPPFLAGS into isystem include paths. This is
430 dnl done to prevent GNUC from generating warnings on
431 dnl headers from these locations, although on ancient
432 dnl GNUC versions these warnings are not silenced.
434 AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
435 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
436 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
437 if test "$compiler_id" = "GNU_C" ||
438 test "$compiler_id" = "CLANG"; then
440 tmp_chg_FLAGS="$CFLAGS"
441 for word1 in $tmp_chg_FLAGS; do
444 tmp_has_include="yes"
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 CFLAGS="$tmp_chg_FLAGS"
455 tmp_chg_FLAGS="$CPPFLAGS"
456 for word1 in $tmp_chg_FLAGS; do
459 tmp_has_include="yes"
463 if test "$tmp_has_include" = "yes"; then
464 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
465 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
466 CPPFLAGS="$tmp_chg_FLAGS"
473 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
474 dnl -------------------------------------------------
475 dnl Verify if the C compiler seems to work with the
476 dnl settings that are 'active' at the time the test
479 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
480 dnl compilation capability verification
481 tmp_compiler_works="unknown"
489 tmp_compiler_works="yes"
491 tmp_compiler_works="no"
493 sed 's/^/cc-fail: /' conftest.err >&6
496 dnl linking capability verification
497 if test "$tmp_compiler_works" = "yes"; then
505 tmp_compiler_works="yes"
507 tmp_compiler_works="no"
509 sed 's/^/link-fail: /' conftest.err >&6
513 dnl only do runtime verification when not cross-compiling
514 if test "x$cross_compiling" != "xyes" &&
515 test "$tmp_compiler_works" = "yes"; then
526 tmp_compiler_works="yes"
528 tmp_compiler_works="no"
530 echo "run-fail: test program exited with status $ac_status" >&6
534 dnl branch upon test result
535 if test "$tmp_compiler_works" = "yes"; then
543 dnl CURL_SET_COMPILER_BASIC_OPTS
544 dnl -------------------------------------------------
545 dnl Sets compiler specific options/flags which do not
546 dnl depend on configure's debug, optimize or warnings
549 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
550 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
551 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
553 if test "$compiler_id" != "unknown"; then
555 if test "$compiler_id" = "GNU_C" ||
556 test "$compiler_id" = "CLANG"; then
557 CURL_CONVERT_INCLUDE_TO_ISYSTEM
560 tmp_save_CPPFLAGS="$CPPFLAGS"
561 tmp_save_CFLAGS="$CFLAGS"
565 case "$compiler_id" in
569 dnl Disable warnings for unused arguments, otherwise clang will
570 dnl warn about compile-time arguments used during link-time, like
571 dnl -O and -g and -pedantic.
572 tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
577 dnl Select strict ANSI C compiler mode
578 tmp_CFLAGS="$tmp_CFLAGS -std1"
579 dnl Turn off optimizer ANSI C aliasing rules
580 tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
581 dnl Generate warnings for missing function prototypes
582 tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
583 dnl Change some warnings into fatal errors
584 tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
589 dnl turn implicit-function-declaration warning into error,
590 dnl at least gcc 2.95 and later support this
591 if test "$compiler_num" -ge "295"; then
592 tmp_CFLAGS="$tmp_CFLAGS -Werror-implicit-function-declaration"
598 dnl Disallow run-time dereferencing of null pointers
599 tmp_CFLAGS="$tmp_CFLAGS -z"
600 dnl Disable some remarks
601 dnl #4227: padding struct with n bytes to align member
602 dnl #4255: padding size of struct with n bytes to alignment boundary
603 tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
608 dnl Ensure that compiler optimizations are always thread-safe.
609 tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
610 dnl Disable type based strict aliasing optimizations, using worst
611 dnl case aliasing assumptions when compiling. Type based aliasing
612 dnl would restrict the lvalues that could be safely used to access
614 tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
615 dnl Force compiler to stop after the compilation phase, without
616 dnl generating an object code file when compilation has errors.
617 tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
622 dnl On unix this compiler uses gcc's header files, so
623 dnl we select ANSI C89 dialect plus GNU extensions.
624 tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
625 dnl Change some warnings into errors
626 dnl #140: too many arguments in function call
627 dnl #147: declaration is incompatible with 'previous one'
628 dnl #165: too few arguments in function call
629 dnl #266: function declared implicitly
630 tmp_CPPFLAGS="$tmp_CPPFLAGS -we140,147,165,266"
631 dnl Disable some remarks
632 dnl #279: controlling expression is constant
633 dnl #981: operands are evaluated in unspecified order
634 dnl #1469: "cc" clobber ignored
635 tmp_CPPFLAGS="$tmp_CPPFLAGS -wd279,981,1469"
641 tmp_CFLAGS="$tmp_CFLAGS"
646 dnl Disallow run-time dereferencing of null pointers
647 tmp_CFLAGS="$tmp_CFLAGS -n"
653 tmp_CFLAGS="$tmp_CFLAGS"
659 tmp_CFLAGS="$tmp_CFLAGS"
665 tmp_CFLAGS="$tmp_CFLAGS"
671 tmp_CFLAGS="$tmp_CFLAGS"
677 tmp_CFLAGS="$tmp_CFLAGS"
683 tmp_CFLAGS="$tmp_CFLAGS"
691 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
692 AC_MSG_CHECKING([if compiler accepts some basic options])
693 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
694 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
697 CURL_COMPILER_WORKS_IFELSE([
699 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
702 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
703 dnl restore initial settings
704 CPPFLAGS="$tmp_save_CPPFLAGS"
705 CFLAGS="$tmp_save_CFLAGS"
713 dnl CURL_SET_COMPILER_DEBUG_OPTS
714 dnl -------------------------------------------------
715 dnl Sets compiler specific options/flags which depend
716 dnl on configure's debug option.
718 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
719 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
720 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
721 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
723 if test "$compiler_id" != "unknown"; then
725 tmp_save_CFLAGS="$CFLAGS"
726 tmp_save_CPPFLAGS="$CPPFLAGS"
730 tmp_CPPFLAGS="$CPPFLAGS"
731 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
732 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
734 if test "$want_debug" = "yes"; then
735 AC_MSG_CHECKING([if compiler accepts debug enabling options])
736 tmp_options="$flags_dbg_yes"
738 if test "$want_debug" = "no"; then
739 AC_MSG_CHECKING([if compiler accepts debug disabling options])
740 tmp_options="$flags_dbg_off"
743 if test "$flags_prefer_cppflags" = "yes"; then
744 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
747 CPPFLAGS="$tmp_CPPFLAGS"
748 CFLAGS="$tmp_CFLAGS $tmp_options"
752 CURL_COMPILER_WORKS_IFELSE([
754 AC_MSG_NOTICE([compiler options added: $tmp_options])
757 AC_MSG_WARN([compiler options rejected: $tmp_options])
758 dnl restore initial settings
759 CPPFLAGS="$tmp_save_CPPFLAGS"
760 CFLAGS="$tmp_save_CFLAGS"
767 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
768 dnl -------------------------------------------------
769 dnl Sets compiler specific options/flags which depend
770 dnl on configure's optimize option.
772 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
773 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
774 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
775 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
777 if test "$compiler_id" != "unknown"; then
779 tmp_save_CFLAGS="$CFLAGS"
780 tmp_save_CPPFLAGS="$CPPFLAGS"
784 tmp_CPPFLAGS="$CPPFLAGS"
785 honor_optimize_option="yes"
787 dnl If optimization request setting has not been explicitly specified,
788 dnl it has been derived from the debug setting and initially assumed.
789 dnl This initially assumed optimizer setting will finally be ignored
790 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
791 dnl that an initially assumed optimizer setting might not be honored.
793 if test "$want_optimize" = "assume_no" ||
794 test "$want_optimize" = "assume_yes"; then
795 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
796 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
797 honor_optimize_option="no"
799 CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
800 honor_optimize_option="no"
802 AC_MSG_RESULT([$honor_optimize_option])
803 if test "$honor_optimize_option" = "yes"; then
804 if test "$want_optimize" = "assume_yes"; then
807 if test "$want_optimize" = "assume_no"; then
813 if test "$honor_optimize_option" = "yes"; then
814 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
815 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
816 if test "$want_optimize" = "yes"; then
817 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
818 tmp_options="$flags_opt_yes"
820 if test "$want_optimize" = "no"; then
821 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
822 tmp_options="$flags_opt_off"
824 if test "$flags_prefer_cppflags" = "yes"; then
825 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
828 CPPFLAGS="$tmp_CPPFLAGS"
829 CFLAGS="$tmp_CFLAGS $tmp_options"
833 CURL_COMPILER_WORKS_IFELSE([
835 AC_MSG_NOTICE([compiler options added: $tmp_options])
838 AC_MSG_WARN([compiler options rejected: $tmp_options])
839 dnl restore initial settings
840 CPPFLAGS="$tmp_save_CPPFLAGS"
841 CFLAGS="$tmp_save_CFLAGS"
849 dnl CURL_SET_COMPILER_WARNING_OPTS
850 dnl -------------------------------------------------
851 dnl Sets compiler options/flags which depend on
852 dnl configure's warnings given option.
854 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
855 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
856 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
857 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
859 if test "$compiler_id" != "unknown"; then
861 tmp_save_CPPFLAGS="$CPPFLAGS"
862 tmp_save_CFLAGS="$CFLAGS"
866 case "$compiler_id" in
870 if test "$want_warnings" = "yes"; then
871 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
872 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
873 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
874 tmp_CFLAGS="$tmp_CFLAGS -Wshadow"
875 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
876 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
877 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
878 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
879 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
880 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
881 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
882 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
883 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
884 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
885 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
886 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
887 tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32"
889 dnl Only clang 1.1 or later
890 if test "$compiler_num" -ge "101"; then
891 tmp_CFLAGS="$tmp_CFLAGS -Wunused"
894 dnl Only clang 2.8 or later
895 if test "$compiler_num" -ge "208"; then
896 tmp_CFLAGS="$tmp_CFLAGS -Wvla"
899 dnl Only clang 2.9 or later
900 if test "$compiler_num" -ge "209"; then
901 tmp_CFLAGS="$tmp_CFLAGS -Wshift-sign-overflow"
904 dnl Only clang 3.2 or later
905 if test "$compiler_num" -ge "302"; then
908 dnl skip missing-variable-declarations warnings for cygwin and
909 dnl mingw because the libtool wrapper executable causes them
912 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-variable-declarations"
917 dnl Only clang 3.6 or later
918 if test "$compiler_num" -ge "306"; then
919 tmp_CFLAGS="$tmp_CFLAGS -Wdouble-promotion"
922 dnl Only clang 3.9 or later
923 if test "$compiler_num" -ge "309"; then
924 tmp_CFLAGS="$tmp_CFLAGS -Wcomma"
925 # avoid the varargs warning, fixed in 4.0
926 # https://bugs.llvm.org/show_bug.cgi?id=29140
927 if test "$compiler_num" -lt "400"; then
928 tmp_CFLAGS="$tmp_CFLAGS -Wno-varargs"
936 if test "$want_warnings" = "yes"; then
937 dnl Select a higher warning level than default level2
938 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
944 if test "$want_warnings" = "yes"; then
946 dnl Do not enable -pedantic when cross-compiling with a gcc older
947 dnl than 3.0, to avoid warnings from third party system headers.
948 if test "x$cross_compiling" != "xyes" ||
949 test "$compiler_num" -ge "300"; then
950 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
953 dnl Set of options we believe *ALL* gcc versions support:
954 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
956 dnl Only gcc 1.4 or later
957 if test "$compiler_num" -ge "104"; then
958 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
959 dnl If not cross-compiling with a gcc older than 3.0
960 if test "x$cross_compiling" != "xyes" ||
961 test "$compiler_num" -ge "300"; then
962 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
966 dnl Only gcc 2.7 or later
967 if test "$compiler_num" -ge "207"; then
968 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
969 dnl If not cross-compiling with a gcc older than 3.0
970 if test "x$cross_compiling" != "xyes" ||
971 test "$compiler_num" -ge "300"; then
972 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
973 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
977 dnl Only gcc 2.95 or later
978 if test "$compiler_num" -ge "295"; then
979 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
982 dnl Only gcc 2.96 or later
983 if test "$compiler_num" -ge "296"; then
984 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
985 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
986 dnl -Wundef used only if gcc is 2.96 or later since we get
987 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
988 dnl headers with gcc 2.95.4 on FreeBSD 4.9
989 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
992 dnl Only gcc 2.97 or later
993 if test "$compiler_num" -ge "297"; then
994 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
997 dnl Only gcc 3.0 or later
998 if test "$compiler_num" -ge "300"; then
999 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
1000 dnl on i686-Linux as it gives us heaps with false positives.
1001 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
1002 dnl over making it unusable for generic purposes. Let's not use it.
1003 tmp_CFLAGS="$tmp_CFLAGS"
1006 dnl Only gcc 3.3 or later
1007 if test "$compiler_num" -ge "303"; then
1008 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
1011 dnl Only gcc 3.4 or later
1012 if test "$compiler_num" -ge "304"; then
1013 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
1016 dnl Only gcc 4.0 or later
1017 if test "$compiler_num" -ge "400"; then
1018 tmp_CFLAGS="$tmp_CFLAGS -Wstrict-aliasing=3"
1021 dnl Only gcc 4.2 or later
1022 if test "$compiler_num" -ge "402"; then
1023 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
1026 dnl Only gcc 4.3 or later
1027 if test "$compiler_num" -ge "403"; then
1028 tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
1029 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
1030 tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
1031 tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
1034 dnl Only gcc 4.5 or later
1035 if test "$compiler_num" -ge "405"; then
1036 dnl Only windows targets
1037 if test "$curl_cv_have_def__WIN32" = "yes"; then
1038 tmp_CFLAGS="$tmp_CFLAGS -Wno-pedantic-ms-format"
1042 dnl Only gcc 4.6 or later
1043 if test "$compiler_num" -ge "406"; then
1044 tmp_CFLAGS="$tmp_CFLAGS -Wdouble-promotion"
1049 dnl Do not issue warnings for code in system include paths.
1050 if test "$compiler_num" -ge "300"; then
1051 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
1053 dnl When cross-compiling with a gcc older than 3.0, disable
1054 dnl some warnings triggered on third party system headers.
1055 if test "x$cross_compiling" = "xyes"; then
1056 if test "$compiler_num" -ge "104"; then
1057 dnl gcc 1.4 or later
1058 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
1060 if test "$compiler_num" -ge "207"; then
1061 dnl gcc 2.7 or later
1062 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
1063 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
1071 if test "$want_warnings" = "yes"; then
1072 dnl Issue all warnings
1073 tmp_CFLAGS="$tmp_CFLAGS +w1"
1080 tmp_CFLAGS="$tmp_CFLAGS"
1085 if test "$want_warnings" = "yes"; then
1086 if test "$compiler_num" -gt "600"; then
1087 dnl Show errors, warnings, and remarks
1088 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1089 dnl Perform extra compile-time code checking
1090 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1091 dnl Warn on nested comments
1092 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1093 dnl Show warnings relative to deprecated features
1094 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1095 dnl Enable warnings for missing prototypes
1096 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1097 dnl Enable warnings for 64-bit portability issues
1098 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1099 dnl Enable warnings for questionable pointer arithmetic
1100 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1101 dnl Check for function return typw issues
1102 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1103 dnl Warn on variable declarations hiding a previous one
1104 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1105 dnl Warn when a variable is used before initialized
1106 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1107 dnl Warn if a declared function is not used
1108 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1111 dnl Disable using EBP register in optimizations
1112 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1113 dnl Disable use of ANSI C aliasing rules in optimizations
1114 tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1115 dnl Value-safe optimizations on floating-point data
1116 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1117 dnl Only icc 10.0 or later
1118 if test "$compiler_num" -ge "1000"; then
1119 dnl Disable vectorizer diagnostic information
1120 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1127 tmp_CFLAGS="$tmp_CFLAGS"
1132 if test "$want_warnings" = "yes"; then
1133 dnl Highest warning level is double -A, next is single -A.
1134 dnl Due to the big number of warnings these trigger on third
1135 dnl party header files it is impractical for us to use any of
1136 dnl them here. If you want them simply define it in CPPFLAGS.
1137 tmp_CFLAGS="$tmp_CFLAGS"
1143 if test "$want_warnings" = "yes"; then
1144 dnl Perform stricter semantic and lint-like checks
1145 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1151 if test "$want_warnings" = "yes"; then
1152 dnl Perform stricter semantic and lint-like checks
1153 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1154 dnl Disable some remarks
1155 dnl #1209: controlling expression is constant
1156 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1162 if test "$want_warnings" = "yes"; then
1163 dnl Perform stricter semantic and lint-like checks
1164 tmp_CFLAGS="$tmp_CFLAGS -v"
1170 if test "$want_warnings" = "yes"; then
1171 dnl Activate all warnings
1172 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1173 dnl Make string constants be of type const char *
1174 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1175 dnl Warn use of unsupported GCC features ignored by TCC
1176 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1182 if test "$want_warnings" = "yes"; then
1183 dnl Issue all warnings
1184 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1191 tmp_CFLAGS="$tmp_CFLAGS"
1196 squeeze tmp_CPPFLAGS
1199 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1200 AC_MSG_CHECKING([if compiler accepts strict warning options])
1201 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1202 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1205 CURL_COMPILER_WORKS_IFELSE([
1206 AC_MSG_RESULT([yes])
1207 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1210 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1211 dnl restore initial settings
1212 CPPFLAGS="$tmp_save_CPPFLAGS"
1213 CFLAGS="$tmp_save_CFLAGS"
1221 dnl CURL_SHFUNC_SQUEEZE
1222 dnl -------------------------------------------------
1223 dnl Declares a shell function squeeze() which removes
1224 dnl redundant whitespace out of a shell variable.
1226 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1229 eval _sqz_input=\[$][$]1
1230 for _sqz_token in $_sqz_input; do
1231 if test -z "$_sqz_result"; then
1232 _sqz_result="$_sqz_token"
1234 _sqz_result="$_sqz_result $_sqz_token"
1237 eval [$]1=\$_sqz_result
1243 dnl CURL_CHECK_CURLDEBUG
1244 dnl -------------------------------------------------
1245 dnl Settings which depend on configure's curldebug given
1246 dnl option, and other additional configure pre-requisites.
1247 dnl Actually the curl debug memory tracking feature can
1248 dnl only be used/enabled when libcurl is built as a static
1249 dnl library or as a shared one on those systems on which
1250 dnl shared libraries support undefined symbols.
1252 AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1253 AC_REQUIRE([XC_LIBTOOL])dnl
1254 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1255 supports_curldebug="unknown"
1256 if test "$want_curldebug" = "yes"; then
1257 if test "x$enable_shared" != "xno" &&
1258 test "x$enable_shared" != "xyes"; then
1259 AC_MSG_WARN([unknown enable_shared setting.])
1260 supports_curldebug="no"
1262 if test "x$enable_static" != "xno" &&
1263 test "x$enable_static" != "xyes"; then
1264 AC_MSG_WARN([unknown enable_static setting.])
1265 supports_curldebug="no"
1267 if test "$supports_curldebug" != "no"; then
1268 if test "$enable_shared" = "yes" &&
1269 test "x$xc_lt_shlib_use_no_undefined" = 'xyes'; then
1270 supports_curldebug="no"
1271 AC_MSG_WARN([shared library does not support undefined symbols.])
1276 if test "$want_curldebug" = "yes"; then
1277 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1278 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1279 AC_MSG_RESULT([$supports_curldebug])
1280 if test "$supports_curldebug" = "no"; then
1281 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1286 if test "$want_curldebug" = "yes"; then
1287 CPPFLAGS="-DCURLDEBUG $CPPFLAGS"
1290 if test "$want_debug" = "yes"; then
1291 CPPFLAGS="-DDEBUGBUILD $CPPFLAGS"
1298 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1299 dnl -------------------------------------------------
1300 dnl Verifies if the compiler actually halts after the
1301 dnl compilation phase without generating any object
1302 dnl code file, when the source compiles with errors.
1304 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1305 AC_MSG_CHECKING([if compiler halts on compilation errors])
1309 force compilation error
1313 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1315 AC_MSG_RESULT([yes])
1320 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1321 dnl -------------------------------------------------
1322 dnl Verifies if the compiler actually halts after the
1323 dnl compilation phase without generating any object
1324 dnl code file, when the source code tries to define a
1325 dnl type for a constant array with negative dimension.
1327 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1328 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1329 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1332 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1338 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1340 AC_MSG_RESULT([yes])
1345 dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1346 dnl -------------------------------------------------
1347 dnl Verifies if the compiler is capable of handling the
1348 dnl size of a struct member, struct which is a function
1349 dnl result, as a compilation-time condition inside the
1350 dnl type definition of a constant array.
1352 AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1353 AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1354 AC_MSG_CHECKING([if compiler struct member size checking works])
1355 tst_compiler_check_one_works="unknown"
1361 struct mystruct *next;
1363 struct mystruct myfunc();
1364 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1365 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1371 tst_compiler_check_one_works="yes"
1373 tst_compiler_check_one_works="no"
1374 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1375 sed 's/^/cc-err: /' conftest.err >&6
1377 tst_compiler_check_two_works="unknown"
1383 struct mystruct *next;
1385 struct mystruct myfunc();
1386 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1387 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1393 tst_compiler_check_two_works="no"
1395 tst_compiler_check_two_works="yes"
1397 if test "$tst_compiler_check_one_works" = "yes" &&
1398 test "$tst_compiler_check_two_works" = "yes"; then
1399 AC_MSG_RESULT([yes])
1402 AC_MSG_ERROR([compiler fails struct member size checking.])
1407 dnl CURL_CHECK_COMPILER_SYMBOL_HIDING
1408 dnl -------------------------------------------------
1409 dnl Verify if compiler supports hiding library internal symbols, setting
1410 dnl shell variable supports_symbol_hiding value as appropriate, as well as
1411 dnl variables symbol_hiding_CFLAGS and symbol_hiding_EXTERN when supported.
1413 AC_DEFUN([CURL_CHECK_COMPILER_SYMBOL_HIDING], [
1414 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
1415 AC_BEFORE([$0],[CURL_CONFIGURE_SYMBOL_HIDING])dnl
1416 AC_MSG_CHECKING([if compiler supports hiding library internal symbols])
1417 supports_symbol_hiding="no"
1418 symbol_hiding_CFLAGS=""
1419 symbol_hiding_EXTERN=""
1422 case "$compiler_id" in
1424 dnl All versions of clang support -fvisibility=
1425 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1426 tmp_CFLAGS="-fvisibility=hidden"
1427 supports_symbol_hiding="yes"
1430 dnl Only gcc 3.4 or later
1431 if test "$compiler_num" -ge "304"; then
1432 if $CC --help --verbose 2>/dev/null | grep fvisibility= >/dev/null ; then
1433 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1434 tmp_CFLAGS="-fvisibility=hidden"
1435 supports_symbol_hiding="yes"
1440 dnl Only icc 9.0 or later
1441 if test "$compiler_num" -ge "900"; then
1442 if $CC --help --verbose 2>&1 | grep fvisibility= > /dev/null ; then
1443 tmp_save_CFLAGS="$CFLAGS"
1444 CFLAGS="$CFLAGS -fvisibility=hidden"
1449 printf("icc fvisibility bug test");
1452 tmp_EXTERN="__attribute__ ((__visibility__ (\"default\")))"
1453 tmp_CFLAGS="-fvisibility=hidden"
1454 supports_symbol_hiding="yes"
1456 CFLAGS="$tmp_save_CFLAGS"
1461 if $CC 2>&1 | grep flags >/dev/null && $CC -flags | grep xldscope= >/dev/null ; then
1462 tmp_EXTERN="__global"
1463 tmp_CFLAGS="-xldscope=hidden"
1464 supports_symbol_hiding="yes"
1468 if test "$supports_symbol_hiding" = "yes"; then
1469 tmp_save_CFLAGS="$CFLAGS"
1470 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1474 $tmp_EXTERN char *dummy(char *buff);
1475 char *dummy(char *buff)
1484 char *r = dummy(&b[0]);
1489 supports_symbol_hiding="yes"
1490 if test -f conftest.err; then
1491 grep 'visibility' conftest.err >/dev/null
1492 if test "$?" -eq "0"; then
1493 supports_symbol_hiding="no"
1497 supports_symbol_hiding="no"
1499 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1500 sed 's/^/cc-err: /' conftest.err >&6
1503 CFLAGS="$tmp_save_CFLAGS"
1505 if test "$supports_symbol_hiding" = "yes"; then
1506 AC_MSG_RESULT([yes])
1507 symbol_hiding_CFLAGS="$tmp_CFLAGS"
1508 symbol_hiding_EXTERN="$tmp_EXTERN"
1515 dnl CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH
1516 dnl -------------------------------------------------
1517 dnl Verifies if the compiler actually halts after the
1518 dnl compilation phase without generating any object
1519 dnl code file, when the source code tries to redefine
1520 dnl a prototype which does not match previous one.
1522 AC_DEFUN([CURL_CHECK_COMPILER_PROTOTYPE_MISMATCH], [
1523 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1524 AC_MSG_CHECKING([if compiler halts on function prototype mismatch])
1527 # include <stdlib.h>
1544 AC_MSG_ERROR([compiler does not halt on function prototype mismatch.])
1546 AC_MSG_RESULT([yes])
1551 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1552 dnl -------------------------------------------------
1553 dnl Verifies if shell variable VARNAME contains VALUE.
1554 dnl Contents of variable VARNAME and VALUE are handled
1555 dnl as whitespace separated lists of words. If at least
1556 dnl one word of VALUE is present in VARNAME the match
1557 dnl is considered positive, otherwise false.
1559 AC_DEFUN([CURL_VAR_MATCH], [
1560 ac_var_match_word="no"
1561 for word1 in $[$1]; do
1562 for word2 in [$2]; do
1563 if test "$word1" = "$word2"; then
1564 ac_var_match_word="yes"
1571 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1572 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1573 dnl -------------------------------------------------
1574 dnl This performs a CURL_VAR_MATCH check and executes
1575 dnl first branch if the match is positive, otherwise
1576 dnl the second branch is executed.
1578 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1579 CURL_VAR_MATCH([$1],[$2])
1580 if test "$ac_var_match_word" = "yes"; then
1588 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1589 dnl -------------------------------------------------
1590 dnl Contents of variable VARNAME and VALUE are handled
1591 dnl as whitespace separated lists of words. Each word
1592 dnl from VALUE is removed from VARNAME when present.
1594 AC_DEFUN([CURL_VAR_STRIP], [
1595 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1597 for word1 in $[$1]; do
1598 ac_var_strip_word="no"
1599 for word2 in [$2]; do
1600 if test "$word1" = "$word2"; then
1601 ac_var_strip_word="yes"
1604 if test "$ac_var_strip_word" = "no"; then
1605 ac_var_stripped="$ac_var_stripped $word1"
1608 dnl squeeze whitespace out of result
1609 [$1]="$ac_var_stripped"