1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2011, 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 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: http://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 clangver=`$CC -dumpversion`
88 clangvhi=`echo $clangver | cut -d . -f1`
89 clangvlo=`echo $clangver | cut -d . -f2`
90 compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
91 flags_dbg_all="-g -g0 -g1 -g2 -g3"
92 flags_dbg_all="$flags_dbg_all -ggdb"
93 flags_dbg_all="$flags_dbg_all -gstabs"
94 flags_dbg_all="$flags_dbg_all -gstabs+"
95 flags_dbg_all="$flags_dbg_all -gcoff"
96 flags_dbg_all="$flags_dbg_all -gxcoff"
97 flags_dbg_all="$flags_dbg_all -gdwarf-2"
98 flags_dbg_all="$flags_dbg_all -gvms"
101 flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4"
110 dnl CURL_CHECK_COMPILER_DEC_C
111 dnl -------------------------------------------------
112 dnl Verify if compiler being used is DEC C.
114 AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
115 AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
116 CURL_CHECK_DEF([__DECC], [], [silent])
117 CURL_CHECK_DEF([__DECC_VER], [], [silent])
118 if test "$curl_cv_have_def___DECC" = "yes" &&
119 test "$curl_cv_have_def___DECC_VER" = "yes"; then
122 flags_dbg_all="-g -g0 -g1 -g2 -g3"
125 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
134 dnl CURL_CHECK_COMPILER_GNU_C
135 dnl -------------------------------------------------
136 dnl Verify if compiler being used is GNU C.
138 AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
139 AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
140 AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl
141 AC_MSG_CHECKING([if compiler is GNU C])
142 CURL_CHECK_DEF([__GNUC__], [], [silent])
143 if test "$curl_cv_have_def___GNUC__" = "yes" &&
144 test "$compiler_id" = "unknown"; then
147 gccver=`$CC -dumpversion`
148 gccvhi=`echo $gccver | cut -d . -f1`
149 gccvlo=`echo $gccver | cut -d . -f2`
150 compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
151 flags_dbg_all="-g -g0 -g1 -g2 -g3"
152 flags_dbg_all="$flags_dbg_all -ggdb"
153 flags_dbg_all="$flags_dbg_all -gstabs"
154 flags_dbg_all="$flags_dbg_all -gstabs+"
155 flags_dbg_all="$flags_dbg_all -gcoff"
156 flags_dbg_all="$flags_dbg_all -gxcoff"
157 flags_dbg_all="$flags_dbg_all -gdwarf-2"
158 flags_dbg_all="$flags_dbg_all -gvms"
161 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
170 dnl CURL_CHECK_COMPILER_HPUX_C
171 dnl -------------------------------------------------
172 dnl Verify if compiler being used is HP-UX C.
174 AC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [
175 AC_MSG_CHECKING([if compiler is HP-UX C])
176 CURL_CHECK_DEF([__HP_cc], [], [silent])
177 if test "$curl_cv_have_def___HP_cc" = "yes"; then
179 compiler_id="HP_UX_C"
180 flags_dbg_all="-g -s"
183 flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
192 dnl CURL_CHECK_COMPILER_IBM_C
193 dnl -------------------------------------------------
194 dnl Verify if compiler being used is IBM C.
196 AC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [
197 AC_MSG_CHECKING([if compiler is IBM C])
198 CURL_CHECK_DEF([__IBMC__], [], [silent])
199 if test "$curl_cv_have_def___IBMC__" = "yes"; then
202 flags_dbg_all="-g -g0 -g1 -g2 -g3"
205 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
206 flags_opt_all="$flags_opt_all -qnooptimize"
207 flags_opt_all="$flags_opt_all -qoptimize=0"
208 flags_opt_all="$flags_opt_all -qoptimize=1"
209 flags_opt_all="$flags_opt_all -qoptimize=2"
210 flags_opt_all="$flags_opt_all -qoptimize=3"
211 flags_opt_all="$flags_opt_all -qoptimize=4"
212 flags_opt_all="$flags_opt_all -qoptimize=5"
214 flags_opt_off="-qnooptimize"
215 flags_prefer_cppflags="yes"
222 dnl CURL_CHECK_COMPILER_INTEL_C
223 dnl -------------------------------------------------
224 dnl Verify if compiler being used is Intel C.
226 AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
227 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
228 AC_MSG_CHECKING([if compiler is Intel C])
229 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
230 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
232 compiler_num="$curl_cv_def___INTEL_COMPILER"
233 CURL_CHECK_DEF([__unix__], [], [silent])
234 if test "$curl_cv_have_def___unix__" = "yes"; then
235 compiler_id="INTEL_UNIX_C"
236 flags_dbg_all="-g -g0"
239 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
243 compiler_id="INTEL_WINDOWS_C"
244 flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
245 flags_dbg_all="$flags_dbg_all /debug"
246 flags_dbg_all="$flags_dbg_all /debug:none"
247 flags_dbg_all="$flags_dbg_all /debug:minimal"
248 flags_dbg_all="$flags_dbg_all /debug:partial"
249 flags_dbg_all="$flags_dbg_all /debug:full"
250 flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
251 flags_dbg_all="$flags_dbg_all /debug:extended"
252 flags_dbg_yes="/Zi /Oy-"
253 flags_dbg_off="/debug:none /Oy-"
254 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
264 dnl CURL_CHECK_COMPILER_LCC
265 dnl -------------------------------------------------
266 dnl Verify if compiler being used is LCC.
268 AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
269 AC_MSG_CHECKING([if compiler is LCC])
270 CURL_CHECK_DEF([__LCC__], [], [silent])
271 if test "$curl_cv_have_def___LCC__" = "yes"; then
286 dnl CURL_CHECK_COMPILER_SGI_MIPS_C
287 dnl -------------------------------------------------
288 dnl Verify if compiler being used is SGI MIPS C.
290 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
291 AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
292 AC_MSG_CHECKING([if compiler is SGI MIPS C])
293 CURL_CHECK_DEF([__GNUC__], [], [silent])
294 CURL_CHECK_DEF([__sgi], [], [silent])
295 if test "$curl_cv_have_def___GNUC__" = "no" &&
296 test "$curl_cv_have_def___sgi" = "yes" &&
297 test "$compiler_id" = "unknown"; then
299 compiler_id="SGI_MIPS_C"
300 flags_dbg_all="-g -g0 -g1 -g2 -g3"
303 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
312 dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
313 dnl -------------------------------------------------
314 dnl Verify if compiler being used is SGI MIPSpro C.
316 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
317 AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
318 AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
319 CURL_CHECK_DEF([__GNUC__], [], [silent])
320 CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
321 CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
322 if test "$curl_cv_have_def___GNUC__" = "no" &&
323 (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
324 test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
326 compiler_id="SGI_MIPSPRO_C"
327 flags_dbg_all="-g -g0 -g1 -g2 -g3"
330 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
339 dnl CURL_CHECK_COMPILER_SUNPRO_C
340 dnl -------------------------------------------------
341 dnl Verify if compiler being used is SunPro C.
343 AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
344 AC_MSG_CHECKING([if compiler is SunPro C])
345 CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
346 if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
348 compiler_id="SUNPRO_C"
349 flags_dbg_all="-g -s"
352 flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
361 dnl CURL_CHECK_COMPILER_TINY_C
362 dnl -------------------------------------------------
363 dnl Verify if compiler being used is Tiny C.
365 AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
366 AC_MSG_CHECKING([if compiler is Tiny C])
367 CURL_CHECK_DEF([__TINYC__], [], [silent])
368 if test "$curl_cv_have_def___TINYC__" = "yes"; then
371 flags_dbg_all="-g -b"
383 dnl CURL_CHECK_COMPILER_WATCOM_C
384 dnl -------------------------------------------------
385 dnl Verify if compiler being used is Watcom C.
387 AC_DEFUN([CURL_CHECK_COMPILER_WATCOM_C], [
388 AC_MSG_CHECKING([if compiler is Watcom C])
389 CURL_CHECK_DEF([__WATCOMC__], [], [silent])
390 if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
392 CURL_CHECK_DEF([__UNIX__], [], [silent])
393 if test "$curl_cv_have_def___UNIX__" = "yes"; then
394 compiler_id="WATCOM_UNIX_C"
395 flags_dbg_all="-g1 -g1+ -g2 -g3"
398 flags_opt_all="-O0 -O1 -O2 -O3"
402 compiler_id="WATCOM_WINDOWS_C"
416 dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
417 dnl -------------------------------------------------
418 dnl Changes standard include paths present in CFLAGS
419 dnl and CPPFLAGS into isystem include paths. This is
420 dnl done to prevent GNUC from generating warnings on
421 dnl headers from these locations, although on ancient
422 dnl GNUC versions these warnings are not silenced.
424 AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
425 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
427 tmp_chg_FLAGS="$CFLAGS"
428 for word1 in $tmp_chg_FLAGS; do
431 tmp_has_include="yes"
435 if test "$tmp_has_include" = "yes"; then
436 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
437 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
438 CFLAGS="$tmp_chg_FLAGS"
442 tmp_chg_FLAGS="$CPPFLAGS"
443 for word1 in $tmp_chg_FLAGS; do
446 tmp_has_include="yes"
450 if test "$tmp_has_include" = "yes"; then
451 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
452 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
453 CPPFLAGS="$tmp_chg_FLAGS"
459 dnl CURL_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([CURL_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 CURL_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([CURL_SET_COMPILER_BASIC_OPTS], [
536 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
537 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
539 if test "$compiler_id" != "unknown"; then
541 if test "$compiler_id" = "GNU_C" ||
542 test "$compiler_id" = "CLANG"; then
543 CURL_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 CURL_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 CURL_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([CURL_SET_COMPILER_DEBUG_OPTS], [
702 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
703 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
704 AC_REQUIRE([CURL_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 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
715 CURL_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 CURL_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 CURL_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([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
756 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
757 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
758 AC_REQUIRE([CURL_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 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
780 honor_optimize_option="no"
782 CURL_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 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
798 CURL_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 CURL_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 CURL_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([CURL_SET_COMPILER_WARNING_OPTS], [
838 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
839 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
840 AC_REQUIRE([CURL_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"
978 dnl Do not issue warnings for code in system include paths.
979 if test "$compiler_num" -ge "300"; then
980 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
982 dnl When cross-compiling with a gcc older than 3.0, disable
983 dnl some warnings triggered on third party system headers.
984 if test "x$cross_compiling" = "xyes"; then
985 if test "$compiler_num" -ge "104"; then
987 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
989 if test "$compiler_num" -ge "207"; then
991 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
992 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
1000 if test "$want_warnings" = "yes"; then
1001 dnl Issue all warnings
1002 tmp_CFLAGS="$tmp_CFLAGS +w1"
1009 tmp_CFLAGS="$tmp_CFLAGS"
1014 if test "$want_warnings" = "yes"; then
1015 if test "$compiler_num" -gt "600"; then
1016 dnl Show errors, warnings, and remarks
1017 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1018 dnl Perform extra compile-time code checking
1019 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1020 dnl Warn on nested comments
1021 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1022 dnl Show warnings relative to deprecated features
1023 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1024 dnl Enable warnings for missing prototypes
1025 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1026 dnl Enable warnings for 64-bit portability issues
1027 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1028 dnl Enable warnings for questionable pointer arithmetic
1029 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1030 dnl Check for function return typw issues
1031 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1032 dnl Warn on variable declarations hiding a previous one
1033 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1034 dnl Warn when a variable is used before initialized
1035 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1036 dnl Warn if a declared function is not used
1037 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1040 dnl Disable using EBP register in optimizations
1041 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1042 dnl Disable use of ANSI C aliasing rules in optimizations
1043 tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1044 dnl Value-safe optimizations on floating-point data
1045 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1046 dnl Only icc 10.0 or later
1047 if test "$compiler_num" -ge "1000"; then
1048 dnl Disable vectorizer diagnostic information
1049 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1056 tmp_CFLAGS="$tmp_CFLAGS"
1061 if test "$want_warnings" = "yes"; then
1062 dnl Highest warning level is double -A, next is single -A.
1063 dnl Due to the big number of warnings these trigger on third
1064 dnl party header files it is impractical for us to use any of
1065 dnl them here. If you want them simply define it in CPPFLAGS.
1066 tmp_CFLAGS="$tmp_CFLAGS"
1072 if test "$want_warnings" = "yes"; then
1073 dnl Perform stricter semantic and lint-like checks
1074 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1080 if test "$want_warnings" = "yes"; then
1081 dnl Perform stricter semantic and lint-like checks
1082 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1083 dnl Disable some remarks
1084 dnl #1209: controlling expression is constant
1085 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1091 if test "$want_warnings" = "yes"; then
1092 dnl Perform stricter semantic and lint-like checks
1093 tmp_CFLAGS="$tmp_CFLAGS -v"
1099 if test "$want_warnings" = "yes"; then
1100 dnl Activate all warnings
1101 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1102 dnl Make string constants be of type const char *
1103 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1104 dnl Warn use of unsupported GCC features ignored by TCC
1105 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1111 if test "$want_warnings" = "yes"; then
1112 dnl Issue all warnings
1113 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1120 tmp_CFLAGS="$tmp_CFLAGS"
1125 squeeze tmp_CPPFLAGS
1128 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1129 AC_MSG_CHECKING([if compiler accepts strict warning options])
1130 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1131 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1134 CURL_COMPILER_WORKS_IFELSE([
1135 AC_MSG_RESULT([yes])
1136 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1139 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1140 dnl restore initial settings
1141 CPPFLAGS="$tmp_save_CPPFLAGS"
1142 CFLAGS="$tmp_save_CFLAGS"
1150 dnl CURL_SHFUNC_SQUEEZE
1151 dnl -------------------------------------------------
1152 dnl Declares a shell function squeeze() which removes
1153 dnl redundant whitespace out of a shell variable.
1155 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1158 eval _sqz_input=\[$][$]1
1159 for _sqz_token in $_sqz_input; do
1160 if test -z "$_sqz_result"; then
1161 _sqz_result="$_sqz_token"
1163 _sqz_result="$_sqz_result $_sqz_token"
1166 eval [$]1=\$_sqz_result
1172 dnl CURL_CHECK_CURLDEBUG
1173 dnl -------------------------------------------------
1174 dnl Settings which depend on configure's curldebug given
1175 dnl option, and other additional configure pre-requisites.
1176 dnl Actually the curl debug memory tracking feature can
1177 dnl only be used/enabled when libcurl is built as a static
1178 dnl library or as a shared one on those systems on which
1179 dnl shared libraries support undefined symbols.
1181 AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1182 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1183 supports_curldebug="unknown"
1184 if test "$want_curldebug" = "yes"; then
1185 if test "x$enable_shared" != "xno" &&
1186 test "x$enable_shared" != "xyes"; then
1187 AC_MSG_WARN([unknown enable_shared setting.])
1188 supports_curldebug="no"
1190 if test "x$enable_static" != "xno" &&
1191 test "x$enable_static" != "xyes"; then
1192 AC_MSG_WARN([unknown enable_static setting.])
1193 supports_curldebug="no"
1195 if test "$supports_curldebug" != "no"; then
1196 if test "$enable_shared" = "yes" &&
1197 test "$need_no_undefined" = "yes"; then
1198 supports_curldebug="no"
1199 AC_MSG_WARN([shared library does not support undefined symbols.])
1204 if test "$want_curldebug" = "yes"; then
1205 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1206 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1207 AC_MSG_RESULT([$supports_curldebug])
1208 if test "$supports_curldebug" = "no"; then
1209 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1214 if test "$want_curldebug" = "yes"; then
1215 CPPFLAGS="-DCURLDEBUG $CPPFLAGS"
1218 if test "$want_debug" = "yes"; then
1219 CPPFLAGS="-DDEBUGBUILD $CPPFLAGS"
1225 dnl CURL_CHECK_NO_UNDEFINED
1226 dnl -------------------------------------------------
1227 dnl Checks if the -no-undefined flag must be used when
1228 dnl building shared libraries. This is required on all
1229 dnl systems on which shared libraries should not have
1230 dnl references to undefined symbols. This check should
1231 dnl not be done before AC-PROG-LIBTOOL.
1233 AC_DEFUN([CURL_CHECK_NO_UNDEFINED], [
1234 AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl
1235 AC_MSG_CHECKING([if shared libraries need -no-undefined])
1236 need_no_undefined="no"
1238 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1239 need_no_undefined="yes"
1242 if test "x$allow_undefined" = "xno"; then
1243 need_no_undefined="yes"
1244 elif test "x$allow_undefined_flag" = "xunsupported"; then
1245 need_no_undefined="yes"
1247 AC_MSG_RESULT($need_no_undefined)
1251 dnl CURL_CHECK_PROG_CC
1252 dnl -------------------------------------------------
1253 dnl Check for compiler program, preventing CFLAGS and
1254 dnl CPPFLAGS from being unexpectedly changed.
1256 AC_DEFUN([CURL_CHECK_PROG_CC], [
1257 ac_save_CFLAGS="$CFLAGS"
1258 ac_save_CPPFLAGS="$CPPFLAGS"
1260 CFLAGS="$ac_save_CFLAGS"
1261 CPPFLAGS="$ac_save_CPPFLAGS"
1265 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1266 dnl -------------------------------------------------
1267 dnl Verifies if the compiler actually halts after the
1268 dnl compilation phase without generating any object
1269 dnl code file, when the source compiles with errors.
1271 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1272 AC_MSG_CHECKING([if compiler halts on compilation errors])
1276 force compilation error
1280 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1282 AC_MSG_RESULT([yes])
1287 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1288 dnl -------------------------------------------------
1289 dnl Verifies if the compiler actually halts after the
1290 dnl compilation phase without generating any object
1291 dnl code file, when the source code tries to define a
1292 dnl type for a constant array with negative dimension.
1294 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1295 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1296 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1299 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1305 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1307 AC_MSG_RESULT([yes])
1312 dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1313 dnl -------------------------------------------------
1314 dnl Verifies if the compiler is capable of handling the
1315 dnl size of a struct member, struct which is a function
1316 dnl result, as a compilation-time condition inside the
1317 dnl type definition of a constant array.
1319 AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1320 AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1321 AC_MSG_CHECKING([if compiler struct member size checking works])
1322 tst_compiler_check_one_works="unknown"
1328 struct mystruct *next;
1330 struct mystruct myfunc();
1331 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1332 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1338 tst_compiler_check_one_works="yes"
1340 tst_compiler_check_one_works="no"
1341 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1342 sed 's/^/cc-err: /' conftest.err >&6
1344 tst_compiler_check_two_works="unknown"
1350 struct mystruct *next;
1352 struct mystruct myfunc();
1353 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1354 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1360 tst_compiler_check_two_works="no"
1362 tst_compiler_check_two_works="yes"
1364 if test "$tst_compiler_check_one_works" = "yes" &&
1365 test "$tst_compiler_check_two_works" = "yes"; then
1366 AC_MSG_RESULT([yes])
1369 AC_MSG_ERROR([compiler fails struct member size checking.])
1374 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1375 dnl -------------------------------------------------
1376 dnl Verifies if shell variable VARNAME contains VALUE.
1377 dnl Contents of variable VARNAME and VALUE are handled
1378 dnl as whitespace separated lists of words. If at least
1379 dnl one word of VALUE is present in VARNAME the match
1380 dnl is considered positive, otherwise false.
1382 AC_DEFUN([CURL_VAR_MATCH], [
1383 ac_var_match_word="no"
1384 for word1 in $[$1]; do
1385 for word2 in [$2]; do
1386 if test "$word1" = "$word2"; then
1387 ac_var_match_word="yes"
1394 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1395 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1396 dnl -------------------------------------------------
1397 dnl This performs a CURL_VAR_MATCH check and executes
1398 dnl first branch if the match is positive, otherwise
1399 dnl the second branch is executed.
1401 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1402 CURL_VAR_MATCH([$1],[$2])
1403 if test "$ac_var_match_word" = "yes"; then
1411 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1412 dnl -------------------------------------------------
1413 dnl Contents of variable VARNAME and VALUE are handled
1414 dnl as whitespace separated lists of words. Each word
1415 dnl from VALUE is removed from VARNAME when present.
1417 AC_DEFUN([CURL_VAR_STRIP], [
1418 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1420 for word1 in $[$1]; do
1421 ac_var_strip_word="no"
1422 for word2 in [$2]; do
1423 if test "$word1" = "$word2"; then
1424 ac_var_strip_word="yes"
1427 if test "$ac_var_strip_word" = "no"; then
1428 ac_var_stripped="$ac_var_stripped $word1"
1431 dnl squeeze whitespace out of result
1432 [$1]="$ac_var_stripped"