1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2010, 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 http://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 CURL_CHECK_COMPILER_DEC_C
44 CURL_CHECK_COMPILER_HPUX_C
45 CURL_CHECK_COMPILER_IBM_C
46 CURL_CHECK_COMPILER_INTEL_C
47 CURL_CHECK_COMPILER_CLANG
48 CURL_CHECK_COMPILER_GNU_C
49 CURL_CHECK_COMPILER_LCC
50 CURL_CHECK_COMPILER_SGI_MIPSPRO_C
51 CURL_CHECK_COMPILER_SGI_MIPS_C
52 CURL_CHECK_COMPILER_SUNPRO_C
53 CURL_CHECK_COMPILER_TINY_C
54 CURL_CHECK_COMPILER_WATCOM_C
56 if test "$compiler_id" = "unknown"; then
59 *** Warning: This configure script does not have information about the
60 *** compiler you are using, relative to the flags required to enable or
61 *** disable generation of debug info, optimization options or warnings.
63 *** Whatever settings are present in CFLAGS will be used for this run.
65 *** If you wish to help the cURL project to better support your compiler
66 *** you can report this and the required info on the libcurl development
67 *** mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/
74 dnl CURL_CHECK_COMPILER_CLANG
75 dnl -------------------------------------------------
76 dnl Verify if compiler being used is clang.
78 AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [
79 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
80 AC_MSG_CHECKING([if compiler is clang])
81 CURL_CHECK_DEF([__clang__], [], [silent])
82 if test "$curl_cv_have_def___clang__" = "yes"; then
85 clangver=`$CC -dumpversion`
86 clangvhi=`echo $clangver | cut -d . -f1`
87 clangvlo=`echo $clangver | cut -d . -f2`
88 compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
89 flags_dbg_all="-g -g0 -g1 -g2 -g3"
90 flags_dbg_all="$flags_dbg_all -ggdb"
91 flags_dbg_all="$flags_dbg_all -gstabs"
92 flags_dbg_all="$flags_dbg_all -gstabs+"
93 flags_dbg_all="$flags_dbg_all -gcoff"
94 flags_dbg_all="$flags_dbg_all -gxcoff"
95 flags_dbg_all="$flags_dbg_all -gdwarf-2"
96 flags_dbg_all="$flags_dbg_all -gvms"
99 flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4"
108 dnl CURL_CHECK_COMPILER_DEC_C
109 dnl -------------------------------------------------
110 dnl Verify if compiler being used is DEC C.
112 AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
113 AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
114 CURL_CHECK_DEF([__DECC], [], [silent])
115 CURL_CHECK_DEF([__DECC_VER], [], [silent])
116 if test "$curl_cv_have_def___DECC" = "yes" &&
117 test "$curl_cv_have_def___DECC_VER" = "yes"; then
120 flags_dbg_all="-g -g0 -g1 -g2 -g3"
123 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
132 dnl CURL_CHECK_COMPILER_GNU_C
133 dnl -------------------------------------------------
134 dnl Verify if compiler being used is GNU C.
136 AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
137 AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
138 AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl
139 AC_MSG_CHECKING([if compiler is GNU C])
140 CURL_CHECK_DEF([__GNUC__], [], [silent])
141 if test "$curl_cv_have_def___GNUC__" = "yes" &&
142 test "$compiler_id" = "unknown"; then
145 gccver=`$CC -dumpversion`
146 gccvhi=`echo $gccver | cut -d . -f1`
147 gccvlo=`echo $gccver | cut -d . -f2`
148 compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
149 flags_dbg_all="-g -g0 -g1 -g2 -g3"
150 flags_dbg_all="$flags_dbg_all -ggdb"
151 flags_dbg_all="$flags_dbg_all -gstabs"
152 flags_dbg_all="$flags_dbg_all -gstabs+"
153 flags_dbg_all="$flags_dbg_all -gcoff"
154 flags_dbg_all="$flags_dbg_all -gxcoff"
155 flags_dbg_all="$flags_dbg_all -gdwarf-2"
156 flags_dbg_all="$flags_dbg_all -gvms"
159 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
168 dnl CURL_CHECK_COMPILER_HPUX_C
169 dnl -------------------------------------------------
170 dnl Verify if compiler being used is HP-UX C.
172 AC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [
173 AC_MSG_CHECKING([if compiler is HP-UX C])
174 CURL_CHECK_DEF([__HP_cc], [], [silent])
175 if test "$curl_cv_have_def___HP_cc" = "yes"; then
177 compiler_id="HP_UX_C"
178 flags_dbg_all="-g -s"
181 flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
190 dnl CURL_CHECK_COMPILER_IBM_C
191 dnl -------------------------------------------------
192 dnl Verify if compiler being used is IBM C.
194 AC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [
195 AC_MSG_CHECKING([if compiler is IBM C])
196 CURL_CHECK_DEF([__IBMC__], [], [silent])
197 if test "$curl_cv_have_def___IBMC__" = "yes"; then
200 flags_dbg_all="-g -g0 -g1 -g2 -g3"
203 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
204 flags_opt_all="$flags_opt_all -qnooptimize"
205 flags_opt_all="$flags_opt_all -qoptimize=0"
206 flags_opt_all="$flags_opt_all -qoptimize=1"
207 flags_opt_all="$flags_opt_all -qoptimize=2"
208 flags_opt_all="$flags_opt_all -qoptimize=3"
209 flags_opt_all="$flags_opt_all -qoptimize=4"
210 flags_opt_all="$flags_opt_all -qoptimize=5"
212 flags_opt_off="-qnooptimize"
219 dnl CURL_CHECK_COMPILER_INTEL_C
220 dnl -------------------------------------------------
221 dnl Verify if compiler being used is Intel C.
223 AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
224 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
225 AC_MSG_CHECKING([if compiler is Intel C])
226 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
227 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
229 compiler_num="$curl_cv_def___INTEL_COMPILER"
230 CURL_CHECK_DEF([__unix__], [], [silent])
231 if test "$curl_cv_have_def___unix__" = "yes"; then
232 compiler_id="INTEL_UNIX_C"
233 flags_dbg_all="-g -g0"
236 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
240 compiler_id="INTEL_WINDOWS_C"
241 flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
242 flags_dbg_all="$flags_dbg_all /debug"
243 flags_dbg_all="$flags_dbg_all /debug:none"
244 flags_dbg_all="$flags_dbg_all /debug:minimal"
245 flags_dbg_all="$flags_dbg_all /debug:partial"
246 flags_dbg_all="$flags_dbg_all /debug:full"
247 flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
248 flags_dbg_all="$flags_dbg_all /debug:extended"
249 flags_dbg_yes="/Zi /Oy-"
250 flags_dbg_off="/debug:none /Oy-"
251 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
261 dnl CURL_CHECK_COMPILER_LCC
262 dnl -------------------------------------------------
263 dnl Verify if compiler being used is LCC.
265 AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
266 AC_MSG_CHECKING([if compiler is LCC])
267 CURL_CHECK_DEF([__LCC__], [], [silent])
268 if test "$curl_cv_have_def___LCC__" = "yes"; then
283 dnl CURL_CHECK_COMPILER_SGI_MIPS_C
284 dnl -------------------------------------------------
285 dnl Verify if compiler being used is SGI MIPS C.
287 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
288 AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
289 AC_MSG_CHECKING([if compiler is SGI MIPS C])
290 CURL_CHECK_DEF([__GNUC__], [], [silent])
291 CURL_CHECK_DEF([__sgi], [], [silent])
292 if test "$curl_cv_have_def___GNUC__" = "no" &&
293 test "$curl_cv_have_def___sgi" = "yes" &&
294 test "$compiler_id" = "unknown"; then
296 compiler_id="SGI_MIPS_C"
297 flags_dbg_all="-g -g0 -g1 -g2 -g3"
300 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
309 dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
310 dnl -------------------------------------------------
311 dnl Verify if compiler being used is SGI MIPSpro C.
313 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
314 AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
315 AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
316 CURL_CHECK_DEF([__GNUC__], [], [silent])
317 CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
318 CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
319 if test "$curl_cv_have_def___GNUC__" = "no" &&
320 (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
321 test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
323 compiler_id="SGI_MIPSPRO_C"
324 flags_dbg_all="-g -g0 -g1 -g2 -g3"
327 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
336 dnl CURL_CHECK_COMPILER_SUNPRO_C
337 dnl -------------------------------------------------
338 dnl Verify if compiler being used is SunPro C.
340 AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
341 AC_MSG_CHECKING([if compiler is SunPro C])
342 CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
343 if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
345 compiler_id="SUNPRO_C"
346 flags_dbg_all="-g -s"
349 flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
358 dnl CURL_CHECK_COMPILER_TINY_C
359 dnl -------------------------------------------------
360 dnl Verify if compiler being used is Tiny C.
362 AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
363 AC_MSG_CHECKING([if compiler is Tiny C])
364 CURL_CHECK_DEF([__TINYC__], [], [silent])
365 if test "$curl_cv_have_def___TINYC__" = "yes"; then
368 flags_dbg_all="-g -b"
380 dnl CURL_CHECK_COMPILER_WATCOM_C
381 dnl -------------------------------------------------
382 dnl Verify if compiler being used is Watcom C.
384 AC_DEFUN([CURL_CHECK_COMPILER_WATCOM_C], [
385 AC_MSG_CHECKING([if compiler is Watcom C])
386 CURL_CHECK_DEF([__WATCOMC__], [], [silent])
387 if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
389 CURL_CHECK_DEF([__UNIX__], [], [silent])
390 if test "$curl_cv_have_def___UNIX__" = "yes"; then
391 compiler_id="WATCOM_UNIX_C"
392 flags_dbg_all="-g1 -g1+ -g2 -g3"
395 flags_opt_all="-O0 -O1 -O2 -O3"
399 compiler_id="WATCOM_WINDOWS_C"
413 dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
414 dnl -------------------------------------------------
415 dnl Changes standard include paths present in CFLAGS
416 dnl and CPPFLAGS into isystem include paths. This is
417 dnl done to prevent GNUC from generating warnings on
418 dnl headers from these locations, although on ancient
419 dnl GNUC versions these warnings are not silenced.
421 AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
422 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
424 tmp_chg_FLAGS="$CFLAGS"
425 for word1 in $tmp_chg_FLAGS; do
428 tmp_has_include="yes"
432 if test "$tmp_has_include" = "yes"; then
433 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
434 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
435 CFLAGS="$tmp_chg_FLAGS"
439 tmp_chg_FLAGS="$CPPFLAGS"
440 for word1 in $tmp_chg_FLAGS; do
443 tmp_has_include="yes"
447 if test "$tmp_has_include" = "yes"; then
448 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
449 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
450 CPPFLAGS="$tmp_chg_FLAGS"
456 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
457 dnl -------------------------------------------------
458 dnl Verify if the C compiler seems to work with the
459 dnl settings that are 'active' at the time the test
462 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
463 dnl compilation capability verification
464 tmp_compiler_works="unknown"
472 tmp_compiler_works="yes"
474 tmp_compiler_works="no"
476 sed 's/^/cc-fail: /' conftest.err >&6
479 dnl linking capability verification
480 if test "$tmp_compiler_works" = "yes"; then
488 tmp_compiler_works="yes"
490 tmp_compiler_works="no"
492 sed 's/^/link-fail: /' conftest.err >&6
496 dnl only do runtime verification when not cross-compiling
497 if test "x$cross_compiling" != "xyes" &&
498 test "$tmp_compiler_works" = "yes"; then
509 tmp_compiler_works="yes"
511 tmp_compiler_works="no"
513 echo "run-fail: test program exited with status $ac_status" >&6
517 dnl branch upon test result
518 if test "$tmp_compiler_works" = "yes"; then
526 dnl CURL_SET_COMPILER_BASIC_OPTS
527 dnl -------------------------------------------------
528 dnl Sets compiler specific options/flags which do not
529 dnl depend on configure's debug, optimize or warnings
532 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
533 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
534 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
536 if test "$compiler_id" != "unknown"; then
538 if test "$compiler_id" = "GNU_C" ||
539 test "$compiler_id" = "CLANG"; then
540 CURL_CONVERT_INCLUDE_TO_ISYSTEM
543 tmp_save_CPPFLAGS="$CPPFLAGS"
544 tmp_save_CFLAGS="$CFLAGS"
548 case "$compiler_id" in
552 dnl Disable warnings for unused arguments, otherwise clang will
553 dnl warn about compile-time arguments used during link-time, like
554 dnl -O and -g and -pedantic.
555 tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
560 dnl Select strict ANSI C compiler mode
561 tmp_CFLAGS="$tmp_CFLAGS -std1"
562 dnl Turn off optimizer ANSI C aliasing rules
563 tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
564 dnl Generate warnings for missing function prototypes
565 tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
566 dnl Change some warnings into fatal errors
567 tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
573 tmp_CFLAGS="$tmp_CFLAGS"
578 dnl Disallow run-time dereferencing of null pointers
579 tmp_CFLAGS="$tmp_CFLAGS -z"
580 dnl Disable some remarks
581 dnl #4227: padding struct with n bytes to align member
582 dnl #4255: padding size of struct with n bytes to alignment boundary
583 tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
588 dnl Ensure that compiler optimizations are always thread-safe.
589 tmp_CFLAGS="$tmp_CFLAGS -qthreaded"
590 dnl Disable type based strict aliasing optimizations, using worst
591 dnl case aliasing assumptions when compiling. Type based aliasing
592 dnl would restrict the lvalues that could be safely used to access
594 tmp_CFLAGS="$tmp_CFLAGS -qnoansialias"
595 dnl Force compiler to stop after the compilation phase, without
596 dnl generating an object code file when compilation has errors.
597 tmp_CFLAGS="$tmp_CFLAGS -qhalt=e"
602 dnl On unix this compiler uses gcc's header files, so
603 dnl we select ANSI C89 dialect plus GNU extensions.
604 tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
605 dnl Change some warnings into errors
606 dnl #140: too many arguments in function call
607 dnl #147: declaration is incompatible with 'previous one'
608 dnl #165: too few arguments in function call
609 dnl #266: function declared implicitly
610 tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
611 dnl Disable some remarks
612 dnl #279: controlling expression is constant
613 dnl #981: operands are evaluated in unspecified order
614 dnl #1469: "cc" clobber ignored
615 tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
621 tmp_CFLAGS="$tmp_CFLAGS"
626 dnl Disallow run-time dereferencing of null pointers
627 tmp_CFLAGS="$tmp_CFLAGS -n"
633 tmp_CFLAGS="$tmp_CFLAGS"
639 tmp_CFLAGS="$tmp_CFLAGS"
645 tmp_CFLAGS="$tmp_CFLAGS"
651 tmp_CFLAGS="$tmp_CFLAGS"
657 tmp_CFLAGS="$tmp_CFLAGS"
663 tmp_CFLAGS="$tmp_CFLAGS"
671 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
672 AC_MSG_CHECKING([if compiler accepts some basic options])
673 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
674 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
677 CURL_COMPILER_WORKS_IFELSE([
679 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
682 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
683 dnl restore initial settings
684 CPPFLAGS="$tmp_save_CPPFLAGS"
685 CFLAGS="$tmp_save_CFLAGS"
693 dnl CURL_SET_COMPILER_DEBUG_OPTS
694 dnl -------------------------------------------------
695 dnl Sets compiler specific options/flags which depend
696 dnl on configure's debug option.
698 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
699 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
700 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
701 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
703 if test "$compiler_id" != "unknown"; then
705 tmp_save_CFLAGS="$CFLAGS"
706 tmp_save_CPPFLAGS="$CPPFLAGS"
710 tmp_CPPFLAGS="$CPPFLAGS"
711 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
712 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
714 if test "$want_debug" = "yes"; then
715 AC_MSG_CHECKING([if compiler accepts debug enabling options])
716 tmp_options="$flags_dbg_yes"
718 if test "$want_debug" = "no"; then
719 AC_MSG_CHECKING([if compiler accepts debug disabling options])
720 tmp_options="$flags_dbg_off"
723 CPPFLAGS="$tmp_CPPFLAGS"
724 CFLAGS="$tmp_CFLAGS $tmp_options"
727 CURL_COMPILER_WORKS_IFELSE([
729 AC_MSG_NOTICE([compiler options added: $tmp_options])
732 AC_MSG_WARN([compiler options rejected: $tmp_options])
733 dnl restore initial settings
734 CPPFLAGS="$tmp_save_CPPFLAGS"
735 CFLAGS="$tmp_save_CFLAGS"
742 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
743 dnl -------------------------------------------------
744 dnl Sets compiler specific options/flags which depend
745 dnl on configure's optimize option.
747 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
748 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
749 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
750 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
752 if test "$compiler_id" != "unknown"; then
754 tmp_save_CFLAGS="$CFLAGS"
755 tmp_save_CPPFLAGS="$CPPFLAGS"
759 tmp_CPPFLAGS="$CPPFLAGS"
760 honor_optimize_option="yes"
762 dnl If optimization request setting has not been explicitly specified,
763 dnl it has been derived from the debug setting and initially assumed.
764 dnl This initially assumed optimizer setting will finally be ignored
765 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
766 dnl that an initially assumed optimizer setting might not be honored.
768 if test "$want_optimize" = "assume_no" ||
769 test "$want_optimize" = "assume_yes"; then
770 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
771 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
772 honor_optimize_option="no"
774 CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
775 honor_optimize_option="no"
777 AC_MSG_RESULT([$honor_optimize_option])
778 if test "$honor_optimize_option" = "yes"; then
779 if test "$want_optimize" = "assume_yes"; then
782 if test "$want_optimize" = "assume_no"; then
788 if test "$honor_optimize_option" = "yes"; then
789 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
790 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
791 if test "$want_optimize" = "yes"; then
792 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
793 tmp_options="$flags_opt_yes"
795 if test "$want_optimize" = "no"; then
796 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
797 tmp_options="$flags_opt_off"
799 CPPFLAGS="$tmp_CPPFLAGS"
800 CFLAGS="$tmp_CFLAGS $tmp_options"
803 CURL_COMPILER_WORKS_IFELSE([
805 AC_MSG_NOTICE([compiler options added: $tmp_options])
808 AC_MSG_WARN([compiler options rejected: $tmp_options])
809 dnl restore initial settings
810 CPPFLAGS="$tmp_save_CPPFLAGS"
811 CFLAGS="$tmp_save_CFLAGS"
819 dnl CURL_SET_COMPILER_WARNING_OPTS
820 dnl -------------------------------------------------
821 dnl Sets compiler options/flags which depend on
822 dnl configure's warnings given option.
824 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
825 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
826 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
827 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
829 if test "$compiler_id" != "unknown"; then
831 tmp_save_CPPFLAGS="$CPPFLAGS"
832 tmp_save_CFLAGS="$CFLAGS"
836 case "$compiler_id" in
840 if test "$want_warnings" = "yes"; then
841 dnl All versions of clang support the same warnings as at least
842 dnl gcc 4.2.1 except -Wunused.
843 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
844 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
845 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
846 tmp_CFLAGS="$tmp_CFLAGS -Wshadow"
847 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
848 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
849 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
850 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
851 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
852 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
853 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
854 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
855 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
856 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
857 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
858 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
859 tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32"
861 dnl Only clang 1.1 or later
862 if test "$compiler_num" -ge "101"; then
863 tmp_CFLAGS="$tmp_CFLAGS -Wunused"
870 if test "$want_warnings" = "yes"; then
871 dnl Select a higher warning level than default level2
872 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
878 if test "$want_warnings" = "yes"; then
880 dnl Do not enable -pedantic when cross-compiling with a gcc older
881 dnl than 3.0, to avoid warnings from third party system headers.
882 if test "x$cross_compiling" != "xyes" ||
883 test "$compiler_num" -ge "300"; then
884 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
887 dnl Set of options we believe *ALL* gcc versions support:
888 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
890 dnl Only gcc 1.4 or later
891 if test "$compiler_num" -ge "104"; then
892 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
893 dnl If not cross-compiling with a gcc older than 3.0
894 if test "x$cross_compiling" != "xyes" ||
895 test "$compiler_num" -ge "300"; then
896 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
900 dnl Only gcc 2.7 or later
901 if test "$compiler_num" -ge "207"; then
902 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
903 dnl If not cross-compiling with a gcc older than 3.0
904 if test "x$cross_compiling" != "xyes" ||
905 test "$compiler_num" -ge "300"; then
906 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
907 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
911 dnl Only gcc 2.95 or later
912 if test "$compiler_num" -ge "295"; then
913 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
916 dnl Only gcc 2.96 or later
917 if test "$compiler_num" -ge "296"; then
918 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
919 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
920 dnl -Wundef used only if gcc is 2.96 or later since we get
921 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
922 dnl headers with gcc 2.95.4 on FreeBSD 4.9
923 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
926 dnl Only gcc 2.97 or later
927 if test "$compiler_num" -ge "297"; then
928 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
931 dnl Only gcc 3.0 or later
932 if test "$compiler_num" -ge "300"; then
933 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
934 dnl on i686-Linux as it gives us heaps with false positives.
935 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
936 dnl over making it unusable for generic purposes. Let's not use it.
937 tmp_CFLAGS="$tmp_CFLAGS"
940 dnl Only gcc 3.3 or later
941 if test "$compiler_num" -ge "303"; then
942 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
945 dnl Only gcc 3.4 or later
946 if test "$compiler_num" -ge "304"; then
947 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
950 dnl Only gcc 4.2 or later
951 if test "$compiler_num" -ge "402"; then
952 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
954 dnl Only gcc 4.3 or later
955 if test "$compiler_num" -ge "403"; then
956 tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
957 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
958 tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
959 tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
964 dnl Do not issue warnings for code in system include paths.
965 if test "$compiler_num" -ge "300"; then
966 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
968 dnl When cross-compiling with a gcc older than 3.0, disable
969 dnl some warnings triggered on third party system headers.
970 if test "x$cross_compiling" = "xyes"; then
971 if test "$compiler_num" -ge "104"; then
973 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
975 if test "$compiler_num" -ge "207"; then
977 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
978 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
986 if test "$want_warnings" = "yes"; then
987 dnl Issue all warnings
988 tmp_CFLAGS="$tmp_CFLAGS +w1"
995 tmp_CFLAGS="$tmp_CFLAGS"
1000 if test "$want_warnings" = "yes"; then
1001 if test "$compiler_num" -gt "600"; then
1002 dnl Show errors, warnings, and remarks
1003 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1004 dnl Perform extra compile-time code checking
1005 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1006 dnl Warn on nested comments
1007 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1008 dnl Show warnings relative to deprecated features
1009 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1010 dnl Enable warnings for missing prototypes
1011 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1012 dnl Enable warnings for 64-bit portability issues
1013 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1014 dnl Enable warnings for questionable pointer arithmetic
1015 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1016 dnl Check for function return typw issues
1017 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1018 dnl Warn on variable declarations hiding a previous one
1019 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1020 dnl Warn when a variable is used before initialized
1021 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1022 dnl Warn if a declared function is not used
1023 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1026 dnl Disable using EBP register in optimizations
1027 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1028 dnl Disable use of ANSI C aliasing rules in optimizations
1029 tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1030 dnl Value-safe optimizations on floating-point data
1031 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1032 dnl Only icc 10.0 or later
1033 if test "$compiler_num" -ge "1000"; then
1034 dnl Disable vectorizer diagnostic information
1035 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1042 tmp_CFLAGS="$tmp_CFLAGS"
1047 if test "$want_warnings" = "yes"; then
1048 dnl Highest warning level is double -A, next is single -A.
1049 dnl Due to the big number of warnings these trigger on third
1050 dnl party header files it is impractical for us to use any of
1051 dnl them here. If you want them simply define it in CPPFLAGS.
1052 tmp_CFLAGS="$tmp_CFLAGS"
1058 if test "$want_warnings" = "yes"; then
1059 dnl Perform stricter semantic and lint-like checks
1060 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1066 if test "$want_warnings" = "yes"; then
1067 dnl Perform stricter semantic and lint-like checks
1068 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1069 dnl Disable some remarks
1070 dnl #1209: controlling expression is constant
1071 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1077 if test "$want_warnings" = "yes"; then
1078 dnl Perform stricter semantic and lint-like checks
1079 tmp_CFLAGS="$tmp_CFLAGS -v"
1085 if test "$want_warnings" = "yes"; then
1086 dnl Activate all warnings
1087 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1088 dnl Make string constants be of type const char *
1089 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1090 dnl Warn use of unsupported GCC features ignored by TCC
1091 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1097 if test "$want_warnings" = "yes"; then
1098 dnl Issue all warnings
1099 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1106 tmp_CFLAGS="$tmp_CFLAGS"
1111 squeeze tmp_CPPFLAGS
1114 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1115 AC_MSG_CHECKING([if compiler accepts strict warning options])
1116 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1117 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1120 CURL_COMPILER_WORKS_IFELSE([
1121 AC_MSG_RESULT([yes])
1122 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1125 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1126 dnl restore initial settings
1127 CPPFLAGS="$tmp_save_CPPFLAGS"
1128 CFLAGS="$tmp_save_CFLAGS"
1136 dnl CURL_SHFUNC_SQUEEZE
1137 dnl -------------------------------------------------
1138 dnl Declares a shell function squeeze() which removes
1139 dnl redundant whitespace out of a shell variable.
1141 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1144 eval _sqz_input=\[$][$]1
1145 for _sqz_token in $_sqz_input; do
1146 if test -z "$_sqz_result"; then
1147 _sqz_result="$_sqz_token"
1149 _sqz_result="$_sqz_result $_sqz_token"
1152 eval [$]1=\$_sqz_result
1158 dnl CURL_CHECK_CURLDEBUG
1159 dnl -------------------------------------------------
1160 dnl Settings which depend on configure's curldebug given
1161 dnl option, and other additional configure pre-requisites.
1162 dnl Actually the curl debug memory tracking feature can
1163 dnl only be used/enabled when libcurl is built as a static
1164 dnl library or as a shared one on those systems on which
1165 dnl shared libraries support undefined symbols.
1167 AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1168 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1169 supports_curldebug="unknown"
1170 if test "$want_curldebug" = "yes"; then
1171 if test "x$enable_shared" != "xno" &&
1172 test "x$enable_shared" != "xyes"; then
1173 AC_MSG_WARN([unknown enable_shared setting.])
1174 supports_curldebug="no"
1176 if test "x$enable_static" != "xno" &&
1177 test "x$enable_static" != "xyes"; then
1178 AC_MSG_WARN([unknown enable_static setting.])
1179 supports_curldebug="no"
1181 if test "$supports_curldebug" != "no"; then
1182 if test "$enable_shared" = "yes" &&
1183 test "$need_no_undefined" = "yes"; then
1184 supports_curldebug="no"
1185 AC_MSG_WARN([shared library does not support undefined symbols.])
1190 if test "$want_curldebug" = "yes"; then
1191 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1192 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1193 AC_MSG_RESULT([$supports_curldebug])
1194 if test "$supports_curldebug" = "no"; then
1195 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1200 if test "$want_curldebug" = "yes"; then
1201 CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1204 if test "$want_debug" = "yes"; then
1205 CPPFLAGS="$CPPFLAGS -DDEBUGBUILD"
1211 dnl CURL_CHECK_NO_UNDEFINED
1212 dnl -------------------------------------------------
1213 dnl Checks if the -no-undefined flag must be used when
1214 dnl building shared libraries. This is required on all
1215 dnl systems on which shared libraries should not have
1216 dnl references to undefined symbols. This check should
1217 dnl not be done before AC-PROG-LIBTOOL.
1219 AC_DEFUN([CURL_CHECK_NO_UNDEFINED], [
1220 AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl
1221 AC_MSG_CHECKING([if shared libraries need -no-undefined])
1222 need_no_undefined="no"
1224 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1225 need_no_undefined="yes"
1228 if test "x$allow_undefined" = "xno"; then
1229 need_no_undefined="yes"
1230 elif test "x$allow_undefined_flag" = "xunsupported"; then
1231 need_no_undefined="yes"
1233 AC_MSG_RESULT($need_no_undefined)
1237 dnl CURL_CHECK_PROG_CC
1238 dnl -------------------------------------------------
1239 dnl Check for compiler program, preventing CFLAGS and
1240 dnl CPPFLAGS from being unexpectedly changed.
1242 AC_DEFUN([CURL_CHECK_PROG_CC], [
1243 ac_save_CFLAGS="$CFLAGS"
1244 ac_save_CPPFLAGS="$CPPFLAGS"
1246 CFLAGS="$ac_save_CFLAGS"
1247 CPPFLAGS="$ac_save_CPPFLAGS"
1251 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1252 dnl -------------------------------------------------
1253 dnl Verifies if the compiler actually halts after the
1254 dnl compilation phase without generating any object
1255 dnl code file, when the source compiles with errors.
1257 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1258 AC_MSG_CHECKING([if compiler halts on compilation errors])
1262 force compilation error
1266 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1268 AC_MSG_RESULT([yes])
1273 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1274 dnl -------------------------------------------------
1275 dnl Verifies if the compiler actually halts after the
1276 dnl compilation phase without generating any object
1277 dnl code file, when the source code tries to define a
1278 dnl type for a constant array with negative dimension.
1280 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1281 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1282 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1285 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1291 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1293 AC_MSG_RESULT([yes])
1298 dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1299 dnl -------------------------------------------------
1300 dnl Verifies if the compiler is capable of handling the
1301 dnl size of a struct member, struct which is a function
1302 dnl result, as a compilation-time condition inside the
1303 dnl type definition of a constant array.
1305 AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1306 AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1307 AC_MSG_CHECKING([if compiler struct member size checking works])
1308 tst_compiler_check_one_works="unknown"
1314 struct mystruct *next;
1316 struct mystruct myfunc();
1317 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1318 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1324 tst_compiler_check_one_works="yes"
1326 tst_compiler_check_one_works="no"
1327 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1328 sed 's/^/cc-err: /' conftest.err >&6
1330 tst_compiler_check_two_works="unknown"
1336 struct mystruct *next;
1338 struct mystruct myfunc();
1339 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1340 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1346 tst_compiler_check_two_works="no"
1348 tst_compiler_check_two_works="yes"
1350 if test "$tst_compiler_check_one_works" = "yes" &&
1351 test "$tst_compiler_check_two_works" = "yes"; then
1352 AC_MSG_RESULT([yes])
1355 AC_MSG_ERROR([compiler fails struct member size checking.])
1360 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1361 dnl -------------------------------------------------
1362 dnl Verifies if shell variable VARNAME contains VALUE.
1363 dnl Contents of variable VARNAME and VALUE are handled
1364 dnl as whitespace separated lists of words. If at least
1365 dnl one word of VALUE is present in VARNAME the match
1366 dnl is considered positive, otherwise false.
1368 AC_DEFUN([CURL_VAR_MATCH], [
1369 ac_var_match_word="no"
1370 for word1 in $[$1]; do
1371 for word2 in [$2]; do
1372 if test "$word1" = "$word2"; then
1373 ac_var_match_word="yes"
1380 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1381 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1382 dnl -------------------------------------------------
1383 dnl This performs a CURL_VAR_MATCH check and executes
1384 dnl first branch if the match is positive, otherwise
1385 dnl the second branch is executed.
1387 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1388 CURL_VAR_MATCH([$1],[$2])
1389 if test "$ac_var_match_word" = "yes"; then
1397 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1398 dnl -------------------------------------------------
1399 dnl Contents of variable VARNAME and VALUE are handled
1400 dnl as whitespace separated lists of words. Each word
1401 dnl from VALUE is removed from VARNAME when present.
1403 AC_DEFUN([CURL_VAR_STRIP], [
1404 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1406 for word1 in $[$1]; do
1407 ac_var_strip_word="no"
1408 for word2 in [$2]; do
1409 if test "$word1" = "$word2"; then
1410 ac_var_strip_word="yes"
1413 if test "$ac_var_strip_word" = "no"; then
1414 ac_var_stripped="$ac_var_stripped $word1"
1417 dnl squeeze whitespace out of result
1418 [$1]="$ac_var_stripped"