1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2008, 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.
22 #***************************************************************************
24 # File version for 'aclocal' use. Keep it a single number.
28 dnl CURL_CHECK_COMPILER
29 dnl -------------------------------------------------
30 dnl Verify if the C compiler being used is known.
32 AC_DEFUN([CURL_CHECK_COMPILER], [
37 flags_dbg_all="unknown"
38 flags_dbg_yes="unknown"
39 flags_dbg_off="unknown"
40 flags_opt_all="unknown"
41 flags_opt_yes="unknown"
42 flags_opt_off="unknown"
44 CURL_CHECK_COMPILER_DEC_C
45 CURL_CHECK_COMPILER_HPUX_C
46 CURL_CHECK_COMPILER_IBM_C
47 CURL_CHECK_COMPILER_INTEL_C
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_DEC_C
75 dnl -------------------------------------------------
76 dnl Verify if compiler being used is DEC C.
78 AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
79 AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
80 CURL_CHECK_DEF([__DECC], [], [silent])
81 CURL_CHECK_DEF([__DECC_VER], [], [silent])
82 if test "$curl_cv_have_def___DECC" = "yes" &&
83 test "$curl_cv_have_def___DECC_VER" = "yes"; then
86 flags_dbg_all="-g -g0 -g1 -g2 -g3"
89 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
98 dnl CURL_CHECK_COMPILER_GNU_C
99 dnl -------------------------------------------------
100 dnl Verify if compiler being used is GNU C.
102 AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
103 AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
104 AC_MSG_CHECKING([if compiler is GNU C])
105 CURL_CHECK_DEF([__GNUC__], [], [silent])
106 if test "$curl_cv_have_def___GNUC__" = "yes" &&
107 test "$compiler_id" = "unknown"; then
110 gccver=`$CC -dumpversion`
111 gccvhi=`echo $gccver | cut -d . -f1`
112 gccvlo=`echo $gccver | cut -d . -f2`
113 compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
114 flags_dbg_all="-g -g0 -g1 -g2 -g3"
115 flags_dbg_all="$flags_dbg_all -ggdb"
116 flags_dbg_all="$flags_dbg_all -gstabs"
117 flags_dbg_all="$flags_dbg_all -gstabs+"
118 flags_dbg_all="$flags_dbg_all -gcoff"
119 flags_dbg_all="$flags_dbg_all -gxcoff"
120 flags_dbg_all="$flags_dbg_all -gdwarf-2"
121 flags_dbg_all="$flags_dbg_all -gvms"
124 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
133 dnl CURL_CHECK_COMPILER_HPUX_C
134 dnl -------------------------------------------------
135 dnl Verify if compiler being used is HP-UX C.
137 AC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [
138 AC_MSG_CHECKING([if compiler is HP-UX C])
139 CURL_CHECK_DEF([__HP_cc], [], [silent])
140 if test "$curl_cv_have_def___HP_cc" = "yes"; then
142 compiler_id="HP_UX_C"
143 flags_dbg_all="-g -s"
146 flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
155 dnl CURL_CHECK_COMPILER_IBM_C
156 dnl -------------------------------------------------
157 dnl Verify if compiler being used is IBM C.
159 AC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [
160 AC_MSG_CHECKING([if compiler is IBM C])
161 CURL_CHECK_DEF([__IBMC__], [], [silent])
162 if test "$curl_cv_have_def___IBMC__" = "yes"; then
165 flags_dbg_all="-g -g0 -g1 -g2 -g3"
168 flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
169 flags_opt_all="$flags_opt_all -qnooptimize"
170 flags_opt_all="$flags_opt_all -qoptimize=0"
171 flags_opt_all="$flags_opt_all -qoptimize=1"
172 flags_opt_all="$flags_opt_all -qoptimize=2"
173 flags_opt_all="$flags_opt_all -qoptimize=3"
174 flags_opt_all="$flags_opt_all -qoptimize=4"
175 flags_opt_all="$flags_opt_all -qoptimize=5"
177 flags_opt_off="-qnooptimize"
184 dnl CURL_CHECK_COMPILER_INTEL_C
185 dnl -------------------------------------------------
186 dnl Verify if compiler being used is Intel C.
188 AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
189 AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
190 AC_MSG_CHECKING([if compiler is Intel C])
191 CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
192 if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
194 compiler_num="$curl_cv_def___INTEL_COMPILER"
195 CURL_CHECK_DEF([__i386__], [], [silent])
196 CURL_CHECK_DEF([__unix__], [], [silent])
197 if test "$curl_cv_have_def___unix__" = "yes"; then
198 compiler_id="INTEL_UNIX_C"
199 flags_dbg_all="-g -g0"
202 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
205 dnl icc 9.1 optimization on IA32 triggers SIGSEGV
206 if test "$curl_cv_have_def___i386__" = "yes" &&
207 test "$compiler_num" -eq "910"; then
208 INTEL_UNIX_C_OPT_SIGSEGV="yes"
210 INTEL_UNIX_C_OPT_SIGSEGV="no"
213 compiler_id="INTEL_WINDOWS_C"
214 flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
215 flags_dbg_all="$flags_dbg_all /debug"
216 flags_dbg_all="$flags_dbg_all /debug:none"
217 flags_dbg_all="$flags_dbg_all /debug:minimal"
218 flags_dbg_all="$flags_dbg_all /debug:partial"
219 flags_dbg_all="$flags_dbg_all /debug:full"
220 flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
221 flags_dbg_all="$flags_dbg_all /debug:extended"
222 flags_dbg_yes="/Zi /Oy-"
223 flags_dbg_off="/debug:none /Oy-"
224 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
234 dnl CURL_CHECK_COMPILER_LCC
235 dnl -------------------------------------------------
236 dnl Verify if compiler being used is LCC.
238 AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
239 AC_MSG_CHECKING([if compiler is LCC])
240 CURL_CHECK_DEF([__LCC__], [], [silent])
241 if test "$curl_cv_have_def___LCC__" = "yes"; then
256 dnl CURL_CHECK_COMPILER_SGI_MIPS_C
257 dnl -------------------------------------------------
258 dnl Verify if compiler being used is SGI MIPS C.
260 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
261 AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
262 AC_MSG_CHECKING([if compiler is SGI MIPS C])
263 CURL_CHECK_DEF([__GNUC__], [], [silent])
264 CURL_CHECK_DEF([__sgi], [], [silent])
265 if test "$curl_cv_have_def___GNUC__" = "no" &&
266 test "$curl_cv_have_def___sgi" = "yes" &&
267 test "$compiler_id" = "unknown"; then
269 compiler_id="SGI_MIPS_C"
270 flags_dbg_all="-g -g0 -g1 -g2 -g3"
273 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
282 dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
283 dnl -------------------------------------------------
284 dnl Verify if compiler being used is SGI MIPSpro C.
286 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
287 AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
288 AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
289 CURL_CHECK_DEF([__GNUC__], [], [silent])
290 CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
291 CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
292 if test "$curl_cv_have_def___GNUC__" = "no" &&
293 (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
294 test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
296 compiler_id="SGI_MIPSPRO_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_SUNPRO_C
310 dnl -------------------------------------------------
311 dnl Verify if compiler being used is SunPro C.
313 AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
314 AC_MSG_CHECKING([if compiler is SunPro C])
315 CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
316 if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
318 compiler_id="SUNPRO_C"
319 flags_dbg_all="-g -s"
322 flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
331 dnl CURL_CHECK_COMPILER_TINY_C
332 dnl -------------------------------------------------
333 dnl Verify if compiler being used is Tiny C.
335 AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
336 AC_MSG_CHECKING([if compiler is Tiny C])
337 CURL_CHECK_DEF([__TINYC__], [], [silent])
338 if test "$curl_cv_have_def___TINYC__" = "yes"; then
341 flags_dbg_all="-g -b"
353 dnl CURL_CHECK_COMPILER_WATCOM_C
354 dnl -------------------------------------------------
355 dnl Verify if compiler being used is Watcom C.
357 AC_DEFUN([CURL_CHECK_COMPILER_WATCOM_C], [
358 AC_MSG_CHECKING([if compiler is Watcom C])
359 CURL_CHECK_DEF([__WATCOMC__], [], [silent])
360 if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
362 CURL_CHECK_DEF([__UNIX__], [], [silent])
363 if test "$curl_cv_have_def___UNIX__" = "yes"; then
364 compiler_id="WATCOM_UNIX_C"
365 flags_dbg_all="-g1 -g1+ -g2 -g3"
368 flags_opt_all="-O0 -O1 -O2 -O3"
372 compiler_id="WATCOM_WINDOWS_C"
386 dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
387 dnl -------------------------------------------------
388 dnl Changes standard include paths present in CFLAGS
389 dnl and CPPFLAGS into isystem include paths. This is
390 dnl done to prevent GNUC from generating warnings on
391 dnl headers from these locations, even though this is
392 dnl not reliable on ancient GNUC versions.
394 AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
395 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
397 tmp_chg_FLAGS="$CFLAGS"
398 for word1 in $tmp_chg_FLAGS; do
401 tmp_has_include="yes"
405 if test "$tmp_has_include" = "yes"; then
406 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
407 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
408 CFLAGS="$tmp_chg_FLAGS"
412 tmp_chg_FLAGS="$CPPFLAGS"
413 for word1 in $tmp_chg_FLAGS; do
416 tmp_has_include="yes"
420 if test "$tmp_has_include" = "yes"; then
421 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
422 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
423 CPPFLAGS="$tmp_chg_FLAGS"
429 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
430 dnl -------------------------------------------------
431 dnl Verify if the C compiler seems to work with the
432 dnl settings that are 'active' at the time the test
435 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
436 dnl compilation capability verification
437 tmp_compiler_works="unknown"
445 tmp_compiler_works="yes"
447 tmp_compiler_works="no"
449 sed 's/^/cc-fail: /' conftest.err >&6
452 dnl linking capability verification
453 if test "$tmp_compiler_works" = "yes"; then
461 tmp_compiler_works="yes"
463 tmp_compiler_works="no"
465 sed 's/^/link-fail: /' conftest.err >&6
469 dnl only do runtime verification when not cross-compiling
470 if test "x$cross_compiling" != "xyes" &&
471 test "$tmp_compiler_works" = "yes"; then
482 tmp_compiler_works="yes"
484 tmp_compiler_works="no"
486 echo "run-fail: test program exited with status $ac_status" >&6
490 dnl branch upon test result
491 if test "$tmp_compiler_works" = "yes"; then
499 dnl CURL_SET_COMPILER_BASIC_OPTS
500 dnl -------------------------------------------------
501 dnl Sets compiler specific options/flags which do not
502 dnl depend on configure's debug, optimize or warnings
505 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
506 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
507 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
509 if test "$compiler_id" != "unknown"; then
511 if test "$compiler_id" = "GNU_C"; then
512 CURL_CONVERT_INCLUDE_TO_ISYSTEM
515 tmp_save_CPPFLAGS="$CPPFLAGS"
516 tmp_save_CFLAGS="$CFLAGS"
520 case "$compiler_id" in
524 dnl Select strict ANSI C compiler mode
525 tmp_CFLAGS="$tmp_CFLAGS -std1"
526 dnl Turn off optimizer ANSI C aliasing rules
527 tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
528 dnl Generate warnings for missing function prototypes
529 tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
530 dnl Change some warnings into fatal errors
531 tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
537 tmp_CFLAGS="$tmp_CFLAGS"
542 dnl Disallow run-time dereferencing of null pointers
543 tmp_CFLAGS="$tmp_CFLAGS -z"
544 dnl Disable some remarks
545 dnl #4227: padding struct with n bytes to align member
546 dnl #4255: padding size of struct with n bytes to alignment boundary
547 tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
552 dnl Ensure that compiler optimizations are always thread-safe.
553 tmp_CFLAGS="$tmp_CFLAGS -qthreaded"
554 dnl Disable type based strict aliasing optimizations, using worst
555 dnl case aliasing assumptions when compiling. Type based aliasing
556 dnl would restrict the lvalues that could be safely used to access
558 tmp_CFLAGS="$tmp_CFLAGS -qnoansialias"
559 dnl Force compiler to stop after the compilation phase, without
560 dnl generating an object code file when compilation has errors.
561 tmp_CFLAGS="$tmp_CFLAGS -qhalt=e"
566 dnl On unix this compiler uses gcc's header files, so
567 dnl we select ANSI C89 dialect plus GNU extensions.
568 dnl tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
569 dnl Select ANSI C89 dialect without GNU extensions.
570 tmp_CFLAGS="$tmp_CFLAGS -std=c89"
571 dnl Change some warnings into errors
572 dnl #140: too many arguments in function call
573 dnl #147: declaration is incompatible with 'previous one'
574 dnl #165: too few arguments in function call
575 dnl #266: function declared implicitly
576 tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
577 dnl Disable some remarks
578 dnl #279: controlling expression is constant
579 dnl #981: operands are evaluated in unspecified order
580 dnl #1469: "cc" clobber ignored
581 tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
587 tmp_CFLAGS="$tmp_CFLAGS"
592 dnl Disallow run-time dereferencing of null pointers
593 tmp_CFLAGS="$tmp_CFLAGS -n"
599 tmp_CFLAGS="$tmp_CFLAGS"
605 tmp_CFLAGS="$tmp_CFLAGS"
611 tmp_CFLAGS="$tmp_CFLAGS"
617 tmp_CFLAGS="$tmp_CFLAGS"
623 tmp_CFLAGS="$tmp_CFLAGS"
629 tmp_CFLAGS="$tmp_CFLAGS"
637 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
638 AC_MSG_CHECKING([if compiler accepts some basic options])
639 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
640 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
643 CURL_COMPILER_WORKS_IFELSE([
645 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
648 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
649 dnl restore initial settings
650 CPPFLAGS="$tmp_save_CPPFLAGS"
651 CFLAGS="$tmp_save_CFLAGS"
659 dnl CURL_SET_COMPILER_DEBUG_OPTS
660 dnl -------------------------------------------------
661 dnl Sets compiler specific options/flags which depend
662 dnl on configure's debug option.
664 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
665 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
666 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
667 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
669 if test "$compiler_id" != "unknown"; then
671 tmp_save_CFLAGS="$CFLAGS"
672 tmp_save_CPPFLAGS="$CPPFLAGS"
676 tmp_CPPFLAGS="$CPPFLAGS"
677 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
678 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
680 if test "$want_debug" = "yes"; then
681 AC_MSG_CHECKING([if compiler accepts debug enabling options])
682 tmp_options="$flags_dbg_yes"
684 if test "$want_debug" = "no"; then
685 AC_MSG_CHECKING([if compiler accepts debug disabling options])
686 tmp_options="$flags_dbg_off"
689 CPPFLAGS="$tmp_CPPFLAGS"
690 CFLAGS="$tmp_CFLAGS $tmp_options"
693 CURL_COMPILER_WORKS_IFELSE([
695 AC_MSG_NOTICE([compiler options added: $tmp_options])
698 AC_MSG_WARN([compiler options rejected: $tmp_options])
699 dnl restore initial settings
700 CPPFLAGS="$tmp_save_CPPFLAGS"
701 CFLAGS="$tmp_save_CFLAGS"
708 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
709 dnl -------------------------------------------------
710 dnl Sets compiler specific options/flags which depend
711 dnl on configure's optimize option.
713 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
714 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
715 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
716 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
718 if test "$compiler_id" != "unknown"; then
720 tmp_save_CFLAGS="$CFLAGS"
721 tmp_save_CPPFLAGS="$CPPFLAGS"
725 tmp_CPPFLAGS="$CPPFLAGS"
726 honor_optimize_option="yes"
728 dnl If optimization request setting has not been explicitly specified,
729 dnl it has been derived from the debug setting and initially assumed.
730 dnl This initially assumed optimizer setting will finally be ignored
731 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
732 dnl that an initially assumed optimizer setting might not be honored.
734 if test "$want_optimize" = "assume_no" ||
735 test "$want_optimize" = "assume_yes"; then
736 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
737 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
738 honor_optimize_option="no"
740 CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
741 honor_optimize_option="no"
743 AC_MSG_RESULT([$honor_optimize_option])
744 if test "$honor_optimize_option" = "yes"; then
745 if test "$want_optimize" = "assume_yes"; then
748 if test "$want_optimize" = "assume_no"; then
754 if test "$honor_optimize_option" = "yes"; then
755 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
756 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
757 if test "$want_optimize" = "yes"; then
758 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
759 tmp_options="$flags_opt_yes"
761 if test "$want_optimize" = "no"; then
762 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
763 tmp_options="$flags_opt_off"
765 CPPFLAGS="$tmp_CPPFLAGS"
766 CFLAGS="$tmp_CFLAGS $tmp_options"
769 CURL_COMPILER_WORKS_IFELSE([
771 AC_MSG_NOTICE([compiler options added: $tmp_options])
774 AC_MSG_WARN([compiler options rejected: $tmp_options])
775 dnl restore initial settings
776 CPPFLAGS="$tmp_save_CPPFLAGS"
777 CFLAGS="$tmp_save_CFLAGS"
785 dnl CURL_SET_COMPILER_WARNING_OPTS
786 dnl -------------------------------------------------
787 dnl Sets compiler options/flags which depend on
788 dnl configure's warnings given option.
790 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
791 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
792 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
793 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
795 if test "$compiler_id" != "unknown"; then
797 tmp_save_CPPFLAGS="$CPPFLAGS"
798 tmp_save_CFLAGS="$CFLAGS"
802 case "$compiler_id" in
806 if test "$want_warnings" = "yes"; then
807 dnl Select a higher warning level than default level2
808 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
814 if test "$want_warnings" = "yes"; then
816 dnl Do not enable -pedantic when cross-compiling with a gcc older
817 dnl than 3.0, to avoid warnings from third party system headers.
818 if test "x$cross_compiling" != "xyes" ||
819 test "$compiler_num" -ge "300"; then
820 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
823 dnl Set of options we believe *ALL* gcc versions support:
824 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
826 dnl Only gcc 1.4 or later
827 if test "$compiler_num" -ge "104"; then
828 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
829 dnl If not cross-compiling with a gcc older than 3.0
830 if test "x$cross_compiling" != "xyes" ||
831 test "$compiler_num" -ge "300"; then
832 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
836 dnl Only gcc 2.7 or later
837 if test "$compiler_num" -ge "207"; then
838 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
839 dnl If not cross-compiling with a gcc older than 3.0
840 if test "x$cross_compiling" != "xyes" ||
841 test "$compiler_num" -ge "300"; then
842 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
843 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
847 dnl Only gcc 2.95 or later
848 if test "$compiler_num" -ge "295"; then
849 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
852 dnl Only gcc 2.96 or later
853 if test "$compiler_num" -ge "296"; then
854 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
855 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
856 dnl -Wundef used only if gcc is 2.96 or later since we get
857 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
858 dnl headers with gcc 2.95.4 on FreeBSD 4.9
859 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
862 dnl Only gcc 2.97 or later
863 if test "$compiler_num" -ge "297"; then
864 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
867 dnl Only gcc 3.0 or later
868 if test "$compiler_num" -ge "300"; then
869 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
870 dnl on i686-Linux as it gives us heaps with false positives.
871 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
872 dnl over making it unusable for generic purposes. Let's not use it.
873 tmp_CFLAGS="$tmp_CFLAGS"
876 dnl Only gcc 3.3 or later
877 if test "$compiler_num" -ge "303"; then
878 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
881 dnl Only gcc 3.4 or later
882 if test "$compiler_num" -ge "304"; then
883 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
888 dnl Do not issue warnings for code in system include paths.
889 if test "$compiler_num" -ge "300"; then
890 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
892 dnl When cross-compiling with a gcc older than 3.0, disable
893 dnl some warnings triggered on third party system headers.
894 if test "x$cross_compiling" = "xyes"; then
895 if test "$compiler_num" -ge "104"; then
897 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
899 if test "$compiler_num" -ge "207"; then
901 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
902 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
910 if test "$want_warnings" = "yes"; then
911 dnl Issue all warnings
912 dnl tmp_CFLAGS="$tmp_CFLAGS +w1"
913 dnl Due to the HP-UX socklen_t issue it is insane to use the +w1
914 dnl warning level. Until the issue is somehow fixed we will just
915 dnl use the +w2 warning level.
916 tmp_CFLAGS="$tmp_CFLAGS +w2"
923 tmp_CFLAGS="$tmp_CFLAGS"
928 if test "$want_warnings" = "yes"; then
929 if test "$compiler_num" -gt "600"; then
930 dnl Show errors, warnings, and remarks
931 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
932 dnl Perform extra compile-time code checking
933 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
934 dnl Warn on nested comments
935 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
936 dnl Show warnings relative to deprecated features
937 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
938 dnl Enable warnings for missing prototypes
939 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
940 dnl Enable warnings for 64-bit portability issues
941 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
942 dnl Enable warnings for questionable pointer arithmetic
943 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
944 dnl Check for function return typw issues
945 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
946 dnl Warn on variable declarations hiding a previous one
947 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
948 dnl Warn when a variable is used before initialized
949 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
950 dnl Warn if a declared function is not used
951 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
954 dnl Disable using EBP register in optimizations
955 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
956 dnl Disable use of ANSI C aliasing rules in optimizations
957 tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
958 dnl Value-safe optimizations on floating-point data
959 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
960 dnl Only icc 10.0 or later
961 if test "$compiler_num" -ge "1000"; then
962 dnl Disable vectorizer diagnostic information
963 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
965 dnl Disable some optimizations to debug icc 9.1 SIGSEGV
966 if test "$INTEL_UNIX_C_OPT_SIGSEGV" = "yes"; then
967 dnl Disable interprocedural optimizations
968 tmp_CFLAGS="$tmp_CFLAGS -no-ip -no-ipo"
969 dnl Separate functions for the linker
970 tmp_CFLAGS="$tmp_CFLAGS -ffunction-sections"
971 dnl Disable inlining of user-defined functions
972 tmp_CFLAGS="$tmp_CFLAGS -Ob0"
973 dnl Disable inline expansion of intrinsic functions
974 tmp_CFLAGS="$tmp_CFLAGS -fno-builtin"
975 dnl Disable inlining of functions
976 tmp_CFLAGS="$tmp_CFLAGS -fno-inline"
977 dnl Disable some IPO for single file optimizations
978 tmp_CFLAGS="$tmp_CFLAGS -fno-inline-functions"
979 dnl Disable inlining of standard library functions
980 tmp_CFLAGS="$tmp_CFLAGS -nolib-inline"
981 dnl Disable full and partial inlining when IPO
982 tmp_CFLAGS="$tmp_CFLAGS -ip-no-inlining"
983 dnl Enable floating-point stack integrity checks
984 tmp_CFLAGS="$tmp_CFLAGS -fpstkchk"
985 dnl Enable run-time detection of buffer overruns.
986 tmp_CFLAGS="$tmp_CFLAGS -fstack-security-check"
987 dnl Assume aliasing in the program.
988 tmp_CFLAGS="$tmp_CFLAGS -falias"
989 dnl Assume that arguments may be aliased.
990 tmp_CFLAGS="$tmp_CFLAGS -alias-args"
991 dnl Assume aliasing within functions
992 tmp_CFLAGS="$tmp_CFLAGS -ffnalias"
993 dnl Disable prefetch insertion optimization
994 tmp_CFLAGS="$tmp_CFLAGS -no-prefetch"
995 dnl Disable loop unrolling optimization
996 tmp_CFLAGS="$tmp_CFLAGS -unroll0"
1003 tmp_CFLAGS="$tmp_CFLAGS"
1008 if test "$want_warnings" = "yes"; then
1009 dnl Highest warning level is double -A, next is single -A.
1010 dnl Due to the big number of warnings these trigger on third
1011 dnl party header files it is impractical for us to use any of
1012 dnl them here. If you want them simply define it in CPPFLAGS.
1013 tmp_CFLAGS="$tmp_CFLAGS"
1019 if test "$want_warnings" = "yes"; then
1020 dnl Perform stricter semantic and lint-like checks
1021 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1027 if test "$want_warnings" = "yes"; then
1028 dnl Perform stricter semantic and lint-like checks
1029 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1030 dnl Disable some remarks
1031 dnl #1209: controlling expression is constant
1032 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1038 if test "$want_warnings" = "yes"; then
1039 dnl Perform stricter semantic and lint-like checks
1040 tmp_CFLAGS="$tmp_CFLAGS -v"
1046 if test "$want_warnings" = "yes"; then
1047 dnl Activate all warnings
1048 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1049 dnl Make string constants be of type const char *
1050 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1051 dnl Warn use of unsupported GCC features ignored by TCC
1052 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1058 if test "$want_warnings" = "yes"; then
1059 dnl Issue all warnings
1060 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1067 tmp_CFLAGS="$tmp_CFLAGS"
1072 squeeze tmp_CPPFLAGS
1075 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1076 AC_MSG_CHECKING([if compiler accepts strict warning options])
1077 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1078 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1081 CURL_COMPILER_WORKS_IFELSE([
1082 AC_MSG_RESULT([yes])
1083 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1086 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1087 dnl restore initial settings
1088 CPPFLAGS="$tmp_save_CPPFLAGS"
1089 CFLAGS="$tmp_save_CFLAGS"
1097 dnl CURL_SHFUNC_SQUEEZE
1098 dnl -------------------------------------------------
1099 dnl Declares a shell function squeeze() which removes
1100 dnl redundant whitespace out of a shell variable.
1102 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1105 eval _sqz_input=\[$][$]1
1106 for _sqz_token in $_sqz_input; do
1107 if test -z "$_sqz_result"; then
1108 _sqz_result="$_sqz_token"
1110 _sqz_result="$_sqz_result $_sqz_token"
1113 eval [$]1=\$_sqz_result
1119 dnl CURL_PROCESS_DEBUG_BUILD_OPTS
1120 dnl -------------------------------------------------
1121 dnl Settings which depend on configure's debug given
1122 dnl option, and further configure the build process.
1123 dnl Don't use this macro for compiler dependant stuff.
1125 AC_DEFUN([CURL_PROCESS_DEBUG_BUILD_OPTS], [
1126 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
1127 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1128 AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
1130 if test "$want_debug" = "yes"; then
1131 CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1138 dnl CURL_CHECK_PROG_CC
1139 dnl -------------------------------------------------
1140 dnl Check for compiler program, preventing CFLAGS and
1141 dnl CPPFLAGS from being unexpectedly changed.
1143 AC_DEFUN([CURL_CHECK_PROG_CC], [
1144 ac_save_CFLAGS="$CFLAGS"
1145 ac_save_CPPFLAGS="$CPPFLAGS"
1147 CFLAGS="$ac_save_CFLAGS"
1148 CPPFLAGS="$ac_save_CPPFLAGS"
1152 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1153 dnl -------------------------------------------------
1154 dnl Verifies if shell variable VARNAME contains VALUE.
1155 dnl Contents of variable VARNAME and VALUE are handled
1156 dnl as whitespace separated lists of words. If at least
1157 dnl one word of VALUE is present in VARNAME the match
1158 dnl is considered positive, otherwise false.
1160 AC_DEFUN([CURL_VAR_MATCH], [
1161 ac_var_match_word="no"
1162 for word1 in $[$1]; do
1163 for word2 in [$2]; do
1164 if test "$word1" = "$word2"; then
1165 ac_var_match_word="yes"
1172 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1173 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1174 dnl -------------------------------------------------
1175 dnl This performs a CURL_VAR_MATCH check and executes
1176 dnl first branch if the match is positive, otherwise
1177 dnl the second branch is executed.
1179 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1180 CURL_VAR_MATCH([$1],[$2])
1181 if test "$ac_var_match_word" = "yes"; then
1189 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1190 dnl -------------------------------------------------
1191 dnl Contents of variable VARNAME and VALUE are handled
1192 dnl as whitespace separated lists of words. Each word
1193 dnl from VALUE is removed from VARNAME when present.
1195 AC_DEFUN([CURL_VAR_STRIP], [
1196 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1198 for word1 in $[$1]; do
1199 ac_var_strip_word="no"
1200 for word2 in [$2]; do
1201 if test "$word1" = "$word2"; then
1202 ac_var_strip_word="yes"
1205 if test "$ac_var_strip_word" = "no"; then
1206 ac_var_stripped="$ac_var_stripped $word1"
1209 dnl squeeze whitespace out of result
1210 [$1]="$ac_var_stripped"