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
426 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
427 if test "$compiler_id" = "GNU_C" ||
428 test "$compiler_id" = "CLANG"; then
430 tmp_chg_FLAGS="$CFLAGS"
431 for word1 in $tmp_chg_FLAGS; do
434 tmp_has_include="yes"
438 if test "$tmp_has_include" = "yes"; then
439 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
440 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
441 CFLAGS="$tmp_chg_FLAGS"
445 tmp_chg_FLAGS="$CPPFLAGS"
446 for word1 in $tmp_chg_FLAGS; do
449 tmp_has_include="yes"
453 if test "$tmp_has_include" = "yes"; then
454 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
455 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
456 CPPFLAGS="$tmp_chg_FLAGS"
463 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
464 dnl -------------------------------------------------
465 dnl Verify if the C compiler seems to work with the
466 dnl settings that are 'active' at the time the test
469 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
470 dnl compilation capability verification
471 tmp_compiler_works="unknown"
479 tmp_compiler_works="yes"
481 tmp_compiler_works="no"
483 sed 's/^/cc-fail: /' conftest.err >&6
486 dnl linking capability verification
487 if test "$tmp_compiler_works" = "yes"; then
495 tmp_compiler_works="yes"
497 tmp_compiler_works="no"
499 sed 's/^/link-fail: /' conftest.err >&6
503 dnl only do runtime verification when not cross-compiling
504 if test "x$cross_compiling" != "xyes" &&
505 test "$tmp_compiler_works" = "yes"; then
516 tmp_compiler_works="yes"
518 tmp_compiler_works="no"
520 echo "run-fail: test program exited with status $ac_status" >&6
524 dnl branch upon test result
525 if test "$tmp_compiler_works" = "yes"; then
533 dnl CURL_SET_COMPILER_BASIC_OPTS
534 dnl -------------------------------------------------
535 dnl Sets compiler specific options/flags which do not
536 dnl depend on configure's debug, optimize or warnings
539 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
540 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
541 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
543 if test "$compiler_id" != "unknown"; then
545 if test "$compiler_id" = "GNU_C" ||
546 test "$compiler_id" = "CLANG"; then
547 CURL_CONVERT_INCLUDE_TO_ISYSTEM
550 tmp_save_CPPFLAGS="$CPPFLAGS"
551 tmp_save_CFLAGS="$CFLAGS"
555 case "$compiler_id" in
559 dnl Disable warnings for unused arguments, otherwise clang will
560 dnl warn about compile-time arguments used during link-time, like
561 dnl -O and -g and -pedantic.
562 tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
567 dnl Select strict ANSI C compiler mode
568 tmp_CFLAGS="$tmp_CFLAGS -std1"
569 dnl Turn off optimizer ANSI C aliasing rules
570 tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
571 dnl Generate warnings for missing function prototypes
572 tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
573 dnl Change some warnings into fatal errors
574 tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
580 tmp_CFLAGS="$tmp_CFLAGS"
585 dnl Disallow run-time dereferencing of null pointers
586 tmp_CFLAGS="$tmp_CFLAGS -z"
587 dnl Disable some remarks
588 dnl #4227: padding struct with n bytes to align member
589 dnl #4255: padding size of struct with n bytes to alignment boundary
590 tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
595 dnl Ensure that compiler optimizations are always thread-safe.
596 tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
597 dnl Disable type based strict aliasing optimizations, using worst
598 dnl case aliasing assumptions when compiling. Type based aliasing
599 dnl would restrict the lvalues that could be safely used to access
601 tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
602 dnl Force compiler to stop after the compilation phase, without
603 dnl generating an object code file when compilation has errors.
604 tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
609 dnl On unix this compiler uses gcc's header files, so
610 dnl we select ANSI C89 dialect plus GNU extensions.
611 tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
612 dnl Change some warnings into errors
613 dnl #140: too many arguments in function call
614 dnl #147: declaration is incompatible with 'previous one'
615 dnl #165: too few arguments in function call
616 dnl #266: function declared implicitly
617 tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
618 dnl Disable some remarks
619 dnl #279: controlling expression is constant
620 dnl #981: operands are evaluated in unspecified order
621 dnl #1469: "cc" clobber ignored
622 tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
628 tmp_CFLAGS="$tmp_CFLAGS"
633 dnl Disallow run-time dereferencing of null pointers
634 tmp_CFLAGS="$tmp_CFLAGS -n"
640 tmp_CFLAGS="$tmp_CFLAGS"
646 tmp_CFLAGS="$tmp_CFLAGS"
652 tmp_CFLAGS="$tmp_CFLAGS"
658 tmp_CFLAGS="$tmp_CFLAGS"
664 tmp_CFLAGS="$tmp_CFLAGS"
670 tmp_CFLAGS="$tmp_CFLAGS"
678 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
679 AC_MSG_CHECKING([if compiler accepts some basic options])
680 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
681 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
684 CURL_COMPILER_WORKS_IFELSE([
686 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
689 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
690 dnl restore initial settings
691 CPPFLAGS="$tmp_save_CPPFLAGS"
692 CFLAGS="$tmp_save_CFLAGS"
700 dnl CURL_SET_COMPILER_DEBUG_OPTS
701 dnl -------------------------------------------------
702 dnl Sets compiler specific options/flags which depend
703 dnl on configure's debug option.
705 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
706 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
707 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
708 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
710 if test "$compiler_id" != "unknown"; then
712 tmp_save_CFLAGS="$CFLAGS"
713 tmp_save_CPPFLAGS="$CPPFLAGS"
717 tmp_CPPFLAGS="$CPPFLAGS"
718 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
719 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
721 if test "$want_debug" = "yes"; then
722 AC_MSG_CHECKING([if compiler accepts debug enabling options])
723 tmp_options="$flags_dbg_yes"
725 if test "$want_debug" = "no"; then
726 AC_MSG_CHECKING([if compiler accepts debug disabling options])
727 tmp_options="$flags_dbg_off"
730 if test "$flags_prefer_cppflags" = "yes"; then
731 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
734 CPPFLAGS="$tmp_CPPFLAGS"
735 CFLAGS="$tmp_CFLAGS $tmp_options"
739 CURL_COMPILER_WORKS_IFELSE([
741 AC_MSG_NOTICE([compiler options added: $tmp_options])
744 AC_MSG_WARN([compiler options rejected: $tmp_options])
745 dnl restore initial settings
746 CPPFLAGS="$tmp_save_CPPFLAGS"
747 CFLAGS="$tmp_save_CFLAGS"
754 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
755 dnl -------------------------------------------------
756 dnl Sets compiler specific options/flags which depend
757 dnl on configure's optimize option.
759 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
760 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
761 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
762 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
764 if test "$compiler_id" != "unknown"; then
766 tmp_save_CFLAGS="$CFLAGS"
767 tmp_save_CPPFLAGS="$CPPFLAGS"
771 tmp_CPPFLAGS="$CPPFLAGS"
772 honor_optimize_option="yes"
774 dnl If optimization request setting has not been explicitly specified,
775 dnl it has been derived from the debug setting and initially assumed.
776 dnl This initially assumed optimizer setting will finally be ignored
777 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
778 dnl that an initially assumed optimizer setting might not be honored.
780 if test "$want_optimize" = "assume_no" ||
781 test "$want_optimize" = "assume_yes"; then
782 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
783 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
784 honor_optimize_option="no"
786 CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
787 honor_optimize_option="no"
789 AC_MSG_RESULT([$honor_optimize_option])
790 if test "$honor_optimize_option" = "yes"; then
791 if test "$want_optimize" = "assume_yes"; then
794 if test "$want_optimize" = "assume_no"; then
800 if test "$honor_optimize_option" = "yes"; then
801 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
802 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
803 if test "$want_optimize" = "yes"; then
804 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
805 tmp_options="$flags_opt_yes"
807 if test "$want_optimize" = "no"; then
808 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
809 tmp_options="$flags_opt_off"
811 if test "$flags_prefer_cppflags" = "yes"; then
812 CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
815 CPPFLAGS="$tmp_CPPFLAGS"
816 CFLAGS="$tmp_CFLAGS $tmp_options"
820 CURL_COMPILER_WORKS_IFELSE([
822 AC_MSG_NOTICE([compiler options added: $tmp_options])
825 AC_MSG_WARN([compiler options rejected: $tmp_options])
826 dnl restore initial settings
827 CPPFLAGS="$tmp_save_CPPFLAGS"
828 CFLAGS="$tmp_save_CFLAGS"
836 dnl CURL_SET_COMPILER_WARNING_OPTS
837 dnl -------------------------------------------------
838 dnl Sets compiler options/flags which depend on
839 dnl configure's warnings given option.
841 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
842 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
843 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
844 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
846 if test "$compiler_id" != "unknown"; then
848 tmp_save_CPPFLAGS="$CPPFLAGS"
849 tmp_save_CFLAGS="$CFLAGS"
853 case "$compiler_id" in
857 if test "$want_warnings" = "yes"; then
858 dnl All versions of clang support the same warnings as at least
859 dnl gcc 4.2.1 except -Wunused.
860 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
861 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
862 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
863 tmp_CFLAGS="$tmp_CFLAGS -Wshadow"
864 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
865 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
866 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
867 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
868 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
869 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
870 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
871 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
872 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
873 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
874 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
875 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
876 tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32"
878 dnl Only clang 1.1 or later
879 if test "$compiler_num" -ge "101"; then
880 tmp_CFLAGS="$tmp_CFLAGS -Wunused"
887 if test "$want_warnings" = "yes"; then
888 dnl Select a higher warning level than default level2
889 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
895 if test "$want_warnings" = "yes"; then
897 dnl Do not enable -pedantic when cross-compiling with a gcc older
898 dnl than 3.0, to avoid warnings from third party system headers.
899 if test "x$cross_compiling" != "xyes" ||
900 test "$compiler_num" -ge "300"; then
901 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
904 dnl Set of options we believe *ALL* gcc versions support:
905 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
907 dnl Only gcc 1.4 or later
908 if test "$compiler_num" -ge "104"; then
909 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
910 dnl If not cross-compiling with a gcc older than 3.0
911 if test "x$cross_compiling" != "xyes" ||
912 test "$compiler_num" -ge "300"; then
913 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
917 dnl Only gcc 2.7 or later
918 if test "$compiler_num" -ge "207"; then
919 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
920 dnl If not cross-compiling with a gcc older than 3.0
921 if test "x$cross_compiling" != "xyes" ||
922 test "$compiler_num" -ge "300"; then
923 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
924 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
928 dnl Only gcc 2.95 or later
929 if test "$compiler_num" -ge "295"; then
930 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
933 dnl Only gcc 2.96 or later
934 if test "$compiler_num" -ge "296"; then
935 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
936 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
937 dnl -Wundef used only if gcc is 2.96 or later since we get
938 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
939 dnl headers with gcc 2.95.4 on FreeBSD 4.9
940 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
943 dnl Only gcc 2.97 or later
944 if test "$compiler_num" -ge "297"; then
945 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
948 dnl Only gcc 3.0 or later
949 if test "$compiler_num" -ge "300"; then
950 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
951 dnl on i686-Linux as it gives us heaps with false positives.
952 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
953 dnl over making it unusable for generic purposes. Let's not use it.
954 tmp_CFLAGS="$tmp_CFLAGS"
957 dnl Only gcc 3.3 or later
958 if test "$compiler_num" -ge "303"; then
959 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
962 dnl Only gcc 3.4 or later
963 if test "$compiler_num" -ge "304"; then
964 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
967 dnl Only gcc 4.2 or later
968 if test "$compiler_num" -ge "402"; then
969 tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
972 dnl Only gcc 4.3 or later
973 if test "$compiler_num" -ge "403"; then
974 tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
975 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
976 tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
977 tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
982 dnl Do not issue warnings for code in system include paths.
983 if test "$compiler_num" -ge "300"; then
984 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
986 dnl When cross-compiling with a gcc older than 3.0, disable
987 dnl some warnings triggered on third party system headers.
988 if test "x$cross_compiling" = "xyes"; then
989 if test "$compiler_num" -ge "104"; then
991 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
993 if test "$compiler_num" -ge "207"; then
995 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
996 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
1004 if test "$want_warnings" = "yes"; then
1005 dnl Issue all warnings
1006 tmp_CFLAGS="$tmp_CFLAGS +w1"
1013 tmp_CFLAGS="$tmp_CFLAGS"
1018 if test "$want_warnings" = "yes"; then
1019 if test "$compiler_num" -gt "600"; then
1020 dnl Show errors, warnings, and remarks
1021 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1022 dnl Perform extra compile-time code checking
1023 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1024 dnl Warn on nested comments
1025 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1026 dnl Show warnings relative to deprecated features
1027 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1028 dnl Enable warnings for missing prototypes
1029 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1030 dnl Enable warnings for 64-bit portability issues
1031 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1032 dnl Enable warnings for questionable pointer arithmetic
1033 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1034 dnl Check for function return typw issues
1035 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1036 dnl Warn on variable declarations hiding a previous one
1037 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1038 dnl Warn when a variable is used before initialized
1039 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1040 dnl Warn if a declared function is not used
1041 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1044 dnl Disable using EBP register in optimizations
1045 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1046 dnl Disable use of ANSI C aliasing rules in optimizations
1047 tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1048 dnl Value-safe optimizations on floating-point data
1049 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1050 dnl Only icc 10.0 or later
1051 if test "$compiler_num" -ge "1000"; then
1052 dnl Disable vectorizer diagnostic information
1053 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1060 tmp_CFLAGS="$tmp_CFLAGS"
1065 if test "$want_warnings" = "yes"; then
1066 dnl Highest warning level is double -A, next is single -A.
1067 dnl Due to the big number of warnings these trigger on third
1068 dnl party header files it is impractical for us to use any of
1069 dnl them here. If you want them simply define it in CPPFLAGS.
1070 tmp_CFLAGS="$tmp_CFLAGS"
1076 if test "$want_warnings" = "yes"; then
1077 dnl Perform stricter semantic and lint-like checks
1078 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1084 if test "$want_warnings" = "yes"; then
1085 dnl Perform stricter semantic and lint-like checks
1086 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1087 dnl Disable some remarks
1088 dnl #1209: controlling expression is constant
1089 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1095 if test "$want_warnings" = "yes"; then
1096 dnl Perform stricter semantic and lint-like checks
1097 tmp_CFLAGS="$tmp_CFLAGS -v"
1103 if test "$want_warnings" = "yes"; then
1104 dnl Activate all warnings
1105 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1106 dnl Make string constants be of type const char *
1107 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1108 dnl Warn use of unsupported GCC features ignored by TCC
1109 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1115 if test "$want_warnings" = "yes"; then
1116 dnl Issue all warnings
1117 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1124 tmp_CFLAGS="$tmp_CFLAGS"
1129 squeeze tmp_CPPFLAGS
1132 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1133 AC_MSG_CHECKING([if compiler accepts strict warning options])
1134 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1135 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1138 CURL_COMPILER_WORKS_IFELSE([
1139 AC_MSG_RESULT([yes])
1140 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1143 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1144 dnl restore initial settings
1145 CPPFLAGS="$tmp_save_CPPFLAGS"
1146 CFLAGS="$tmp_save_CFLAGS"
1154 dnl CURL_SHFUNC_SQUEEZE
1155 dnl -------------------------------------------------
1156 dnl Declares a shell function squeeze() which removes
1157 dnl redundant whitespace out of a shell variable.
1159 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1162 eval _sqz_input=\[$][$]1
1163 for _sqz_token in $_sqz_input; do
1164 if test -z "$_sqz_result"; then
1165 _sqz_result="$_sqz_token"
1167 _sqz_result="$_sqz_result $_sqz_token"
1170 eval [$]1=\$_sqz_result
1176 dnl CURL_CHECK_CURLDEBUG
1177 dnl -------------------------------------------------
1178 dnl Settings which depend on configure's curldebug given
1179 dnl option, and other additional configure pre-requisites.
1180 dnl Actually the curl debug memory tracking feature can
1181 dnl only be used/enabled when libcurl is built as a static
1182 dnl library or as a shared one on those systems on which
1183 dnl shared libraries support undefined symbols.
1185 AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1186 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1187 supports_curldebug="unknown"
1188 if test "$want_curldebug" = "yes"; then
1189 if test "x$enable_shared" != "xno" &&
1190 test "x$enable_shared" != "xyes"; then
1191 AC_MSG_WARN([unknown enable_shared setting.])
1192 supports_curldebug="no"
1194 if test "x$enable_static" != "xno" &&
1195 test "x$enable_static" != "xyes"; then
1196 AC_MSG_WARN([unknown enable_static setting.])
1197 supports_curldebug="no"
1199 if test "$supports_curldebug" != "no"; then
1200 if test "$enable_shared" = "yes" &&
1201 test "$need_no_undefined" = "yes"; then
1202 supports_curldebug="no"
1203 AC_MSG_WARN([shared library does not support undefined symbols.])
1208 if test "$want_curldebug" = "yes"; then
1209 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1210 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1211 AC_MSG_RESULT([$supports_curldebug])
1212 if test "$supports_curldebug" = "no"; then
1213 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1218 if test "$want_curldebug" = "yes"; then
1219 CPPFLAGS="-DCURLDEBUG $CPPFLAGS"
1222 if test "$want_debug" = "yes"; then
1223 CPPFLAGS="-DDEBUGBUILD $CPPFLAGS"
1229 dnl CURL_CHECK_NO_UNDEFINED
1230 dnl -------------------------------------------------
1231 dnl Checks if the -no-undefined flag must be used when
1232 dnl building shared libraries. This is required on all
1233 dnl systems on which shared libraries should not have
1234 dnl references to undefined symbols. This check should
1235 dnl not be done before AC-PROG-LIBTOOL.
1237 AC_DEFUN([CURL_CHECK_NO_UNDEFINED], [
1238 AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl
1239 AC_MSG_CHECKING([if shared libraries need -no-undefined])
1240 need_no_undefined="no"
1242 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1243 need_no_undefined="yes"
1246 if test "x$allow_undefined" = "xno"; then
1247 need_no_undefined="yes"
1248 elif test "x$allow_undefined_flag" = "xunsupported"; then
1249 need_no_undefined="yes"
1251 AC_MSG_RESULT($need_no_undefined)
1255 dnl CURL_CHECK_PROG_CC
1256 dnl -------------------------------------------------
1257 dnl Check for compiler program, preventing CFLAGS and
1258 dnl CPPFLAGS from being unexpectedly changed.
1260 AC_DEFUN([CURL_CHECK_PROG_CC], [
1261 ac_save_CFLAGS="$CFLAGS"
1262 ac_save_CPPFLAGS="$CPPFLAGS"
1264 CFLAGS="$ac_save_CFLAGS"
1265 CPPFLAGS="$ac_save_CPPFLAGS"
1269 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1270 dnl -------------------------------------------------
1271 dnl Verifies if the compiler actually halts after the
1272 dnl compilation phase without generating any object
1273 dnl code file, when the source compiles with errors.
1275 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1276 AC_MSG_CHECKING([if compiler halts on compilation errors])
1280 force compilation error
1284 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1286 AC_MSG_RESULT([yes])
1291 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1292 dnl -------------------------------------------------
1293 dnl Verifies if the compiler actually halts after the
1294 dnl compilation phase without generating any object
1295 dnl code file, when the source code tries to define a
1296 dnl type for a constant array with negative dimension.
1298 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1299 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1300 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1303 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1309 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1311 AC_MSG_RESULT([yes])
1316 dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1317 dnl -------------------------------------------------
1318 dnl Verifies if the compiler is capable of handling the
1319 dnl size of a struct member, struct which is a function
1320 dnl result, as a compilation-time condition inside the
1321 dnl type definition of a constant array.
1323 AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1324 AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1325 AC_MSG_CHECKING([if compiler struct member size checking works])
1326 tst_compiler_check_one_works="unknown"
1332 struct mystruct *next;
1334 struct mystruct myfunc();
1335 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1336 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1342 tst_compiler_check_one_works="yes"
1344 tst_compiler_check_one_works="no"
1345 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1346 sed 's/^/cc-err: /' conftest.err >&6
1348 tst_compiler_check_two_works="unknown"
1354 struct mystruct *next;
1356 struct mystruct myfunc();
1357 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1358 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1364 tst_compiler_check_two_works="no"
1366 tst_compiler_check_two_works="yes"
1368 if test "$tst_compiler_check_one_works" = "yes" &&
1369 test "$tst_compiler_check_two_works" = "yes"; then
1370 AC_MSG_RESULT([yes])
1373 AC_MSG_ERROR([compiler fails struct member size checking.])
1378 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1379 dnl -------------------------------------------------
1380 dnl Verifies if shell variable VARNAME contains VALUE.
1381 dnl Contents of variable VARNAME and VALUE are handled
1382 dnl as whitespace separated lists of words. If at least
1383 dnl one word of VALUE is present in VARNAME the match
1384 dnl is considered positive, otherwise false.
1386 AC_DEFUN([CURL_VAR_MATCH], [
1387 ac_var_match_word="no"
1388 for word1 in $[$1]; do
1389 for word2 in [$2]; do
1390 if test "$word1" = "$word2"; then
1391 ac_var_match_word="yes"
1398 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1399 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1400 dnl -------------------------------------------------
1401 dnl This performs a CURL_VAR_MATCH check and executes
1402 dnl first branch if the match is positive, otherwise
1403 dnl the second branch is executed.
1405 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1406 CURL_VAR_MATCH([$1],[$2])
1407 if test "$ac_var_match_word" = "yes"; then
1415 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1416 dnl -------------------------------------------------
1417 dnl Contents of variable VARNAME and VALUE are handled
1418 dnl as whitespace separated lists of words. Each word
1419 dnl from VALUE is removed from VARNAME when present.
1421 AC_DEFUN([CURL_VAR_STRIP], [
1422 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1424 for word1 in $[$1]; do
1425 ac_var_strip_word="no"
1426 for word2 in [$2]; do
1427 if test "$word1" = "$word2"; then
1428 ac_var_strip_word="yes"
1431 if test "$ac_var_strip_word" = "no"; then
1432 ac_var_stripped="$ac_var_stripped $word1"
1435 dnl squeeze whitespace out of result
1436 [$1]="$ac_var_stripped"