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 CURL_CHECK_DEF([__i386__], [], [silent])
195 CURL_CHECK_DEF([__unix__], [], [silent])
196 if test "$curl_cv_have_def___unix__" = "yes"; then
197 compiler_id="INTEL_UNIX_C"
198 flags_dbg_all="-g -g0"
201 flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
204 dnl icc 9.1 optimization on IA32 triggers SIGSEGV
205 if test "$curl_cv_have_def___i386__" = "yes" &&
206 test "$compiler_num" -eq "910"; then
207 INTEL_UNIX_C_OPT_SIGSEGV="yes"
209 INTEL_UNIX_C_OPT_SIGSEGV="no"
212 compiler_id="INTEL_WINDOWS_C"
213 flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
214 flags_dbg_all="$flags_dbg_all /debug"
215 flags_dbg_all="$flags_dbg_all /debug:none"
216 flags_dbg_all="$flags_dbg_all /debug:minimal"
217 flags_dbg_all="$flags_dbg_all /debug:partial"
218 flags_dbg_all="$flags_dbg_all /debug:full"
219 flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
220 flags_dbg_all="$flags_dbg_all /debug:extended"
221 flags_dbg_yes="/Zi /Oy-"
222 flags_dbg_off="/debug:none /Oy-"
223 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
227 compiler_num="$curl_cv_def___INTEL_COMPILER"
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 tmp_CPPFLAGS="$tmp_CPPFLAGS -std=gnu89"
569 dnl Change some warnings into errors
570 dnl #140: too many arguments in function call
571 dnl #147: declaration is incompatible with 'previous one'
572 dnl #165: too few arguments in function call
573 dnl #266: function declared implicitly
574 tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
575 dnl Disable some remarks
576 dnl #279: controlling expression is constant
577 dnl #981: operands are evaluated in unspecified order
578 dnl #1469: "cc" clobber ignored
579 tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
585 tmp_CFLAGS="$tmp_CFLAGS"
590 dnl Disallow run-time dereferencing of null pointers
591 tmp_CFLAGS="$tmp_CFLAGS -n"
597 tmp_CFLAGS="$tmp_CFLAGS"
603 tmp_CFLAGS="$tmp_CFLAGS"
609 tmp_CFLAGS="$tmp_CFLAGS"
615 tmp_CFLAGS="$tmp_CFLAGS"
621 tmp_CFLAGS="$tmp_CFLAGS"
627 tmp_CFLAGS="$tmp_CFLAGS"
635 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
636 AC_MSG_CHECKING([if compiler accepts some basic options])
637 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
638 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
641 CURL_COMPILER_WORKS_IFELSE([
643 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
646 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
647 dnl restore initial settings
648 CPPFLAGS="$tmp_save_CPPFLAGS"
649 CFLAGS="$tmp_save_CFLAGS"
657 dnl CURL_SET_COMPILER_DEBUG_OPTS
658 dnl -------------------------------------------------
659 dnl Sets compiler specific options/flags which depend
660 dnl on configure's debug option.
662 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
663 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
664 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
665 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
667 if test "$compiler_id" != "unknown"; then
669 tmp_save_CFLAGS="$CFLAGS"
670 tmp_save_CPPFLAGS="$CPPFLAGS"
674 tmp_CPPFLAGS="$CPPFLAGS"
675 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
676 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
678 if test "$want_debug" = "yes"; then
679 AC_MSG_CHECKING([if compiler accepts debug enabling options])
680 tmp_options="$flags_dbg_yes"
682 if test "$want_debug" = "no"; then
683 AC_MSG_CHECKING([if compiler accepts debug disabling options])
684 tmp_options="$flags_dbg_off"
687 CPPFLAGS="$tmp_CPPFLAGS"
688 CFLAGS="$tmp_CFLAGS $tmp_options"
691 CURL_COMPILER_WORKS_IFELSE([
693 AC_MSG_NOTICE([compiler options added: $tmp_options])
696 AC_MSG_WARN([compiler options rejected: $tmp_options])
697 dnl restore initial settings
698 CPPFLAGS="$tmp_save_CPPFLAGS"
699 CFLAGS="$tmp_save_CFLAGS"
706 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
707 dnl -------------------------------------------------
708 dnl Sets compiler specific options/flags which depend
709 dnl on configure's optimize option.
711 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
712 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
713 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
714 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
716 if test "$compiler_id" != "unknown"; then
718 tmp_save_CFLAGS="$CFLAGS"
719 tmp_save_CPPFLAGS="$CPPFLAGS"
723 tmp_CPPFLAGS="$CPPFLAGS"
724 honor_optimize_option="yes"
726 dnl If optimization request setting has not been explicitly specified,
727 dnl it has been derived from the debug setting and initially assumed.
728 dnl This initially assumed optimizer setting will finally be ignored
729 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
730 dnl that an initially assumed optimizer setting might not be honored.
732 if test "$want_optimize" = "assume_no" ||
733 test "$want_optimize" = "assume_yes"; then
734 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
735 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
736 honor_optimize_option="no"
738 CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
739 honor_optimize_option="no"
741 AC_MSG_RESULT([$honor_optimize_option])
742 if test "$honor_optimize_option" = "yes"; then
743 if test "$want_optimize" = "assume_yes"; then
746 if test "$want_optimize" = "assume_no"; then
752 if test "$honor_optimize_option" = "yes"; then
753 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
754 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
755 if test "$want_optimize" = "yes"; then
756 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
757 tmp_options="$flags_opt_yes"
759 if test "$want_optimize" = "no"; then
760 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
761 tmp_options="$flags_opt_off"
763 CPPFLAGS="$tmp_CPPFLAGS"
764 CFLAGS="$tmp_CFLAGS $tmp_options"
767 CURL_COMPILER_WORKS_IFELSE([
769 AC_MSG_NOTICE([compiler options added: $tmp_options])
772 AC_MSG_WARN([compiler options rejected: $tmp_options])
773 dnl restore initial settings
774 CPPFLAGS="$tmp_save_CPPFLAGS"
775 CFLAGS="$tmp_save_CFLAGS"
783 dnl CURL_SET_COMPILER_WARNING_OPTS
784 dnl -------------------------------------------------
785 dnl Sets compiler options/flags which depend on
786 dnl configure's warnings given option.
788 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
789 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
790 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
791 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
793 if test "$compiler_id" != "unknown"; then
795 tmp_save_CPPFLAGS="$CPPFLAGS"
796 tmp_save_CFLAGS="$CFLAGS"
800 case "$compiler_id" in
804 if test "$want_warnings" = "yes"; then
805 dnl Select a higher warning level than default level2
806 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
812 if test "$want_warnings" = "yes"; then
814 dnl Do not enable -pedantic when cross-compiling with a gcc older
815 dnl than 3.0, to avoid warnings from third party system headers.
816 if test "x$cross_compiling" != "xyes" ||
817 test "$compiler_num" -ge "300"; then
818 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
821 dnl Set of options we believe *ALL* gcc versions support:
822 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
824 dnl Only gcc 1.4 or later
825 if test "$compiler_num" -ge "104"; then
826 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
827 dnl If not cross-compiling with a gcc older than 3.0
828 if test "x$cross_compiling" != "xyes" ||
829 test "$compiler_num" -ge "300"; then
830 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
834 dnl Only gcc 2.7 or later
835 if test "$compiler_num" -ge "207"; then
836 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
837 dnl If not cross-compiling with a gcc older than 3.0
838 if test "x$cross_compiling" != "xyes" ||
839 test "$compiler_num" -ge "300"; then
840 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
841 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
845 dnl Only gcc 2.95 or later
846 if test "$compiler_num" -ge "295"; then
847 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
850 dnl Only gcc 2.96 or later
851 if test "$compiler_num" -ge "296"; then
852 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
853 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
854 dnl -Wundef used only if gcc is 2.96 or later since we get
855 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
856 dnl headers with gcc 2.95.4 on FreeBSD 4.9
857 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
860 dnl Only gcc 2.97 or later
861 if test "$compiler_num" -ge "297"; then
862 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
865 dnl Only gcc 3.0 or later
866 if test "$compiler_num" -ge "300"; then
867 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
868 dnl on i686-Linux as it gives us heaps with false positives.
869 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
870 dnl over making it unusable for generic purposes. Let's not use it.
871 tmp_CFLAGS="$tmp_CFLAGS"
874 dnl Only gcc 3.3 or later
875 if test "$compiler_num" -ge "303"; then
876 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
879 dnl Only gcc 3.4 or later
880 if test "$compiler_num" -ge "304"; then
881 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
886 dnl Do not issue warnings for code in system include paths.
887 if test "$compiler_num" -ge "300"; then
888 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
890 dnl When cross-compiling with a gcc older than 3.0, disable
891 dnl some warnings triggered on third party system headers.
892 if test "x$cross_compiling" = "xyes"; then
893 if test "$compiler_num" -ge "104"; then
895 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
897 if test "$compiler_num" -ge "207"; then
899 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
900 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
908 if test "$want_warnings" = "yes"; then
909 dnl Issue all warnings
910 dnl tmp_CFLAGS="$tmp_CFLAGS +w1"
911 dnl Due to the HP-UX socklen_t issue it is insane to use the +w1
912 dnl warning level. Until the issue is somehow fixed we will just
913 dnl use the +w2 warning level.
914 tmp_CFLAGS="$tmp_CFLAGS +w2"
921 tmp_CFLAGS="$tmp_CFLAGS"
926 if test "$want_warnings" = "yes"; then
927 if test "$compiler_num" -gt "600"; then
928 dnl Show errors, warnings, and remarks
929 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
930 dnl Perform extra compile-time code checking
931 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
932 dnl Warn on nested comments
933 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
934 dnl Show warnings relative to deprecated features
935 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
936 dnl Enable warnings for missing prototypes
937 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
938 dnl Enable warnings for 64-bit portability issues
939 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
940 dnl Enable warnings for questionable pointer arithmetic
941 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
942 dnl Check for function return typw issues
943 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
944 dnl Warn on variable declarations hiding a previous one
945 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
946 dnl Warn when a variable is used before initialized
947 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
948 dnl Warn if a declared function is not used
949 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
951 dnl Disable using EBP register in optimizations
952 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
953 dnl Disable use of ANSI C aliasing rules in optimizations
954 tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
955 dnl Disable some optimizations to debug icc 9.1 SIGSEGV
956 if test "$INTEL_UNIX_C_OPT_SIGSEGV" = "yes"; then
957 dnl Disable inlining of user-defined functions
958 tmp_CFLAGS="$tmp_CFLAGS -Ob0"
959 dnl Disable inline expansion of intrinsic functions
960 tmp_CFLAGS="$tmp_CFLAGS -fno-builtin"
961 dnl Disable inlining of functions
962 tmp_CFLAGS="$tmp_CFLAGS -fno-inline"
963 dnl Disable some IPO for single file optimizations
964 tmp_CFLAGS="$tmp_CFLAGS -fno-inline-functions"
965 dnl Disable inlining of standard library functions
966 tmp_CFLAGS="$tmp_CFLAGS -nolib-inline"
967 dnl Disable full and partial inlining when IPO
968 tmp_CFLAGS="$tmp_CFLAGS -ip-no-inlining"
969 dnl Enable floating-point stack integrity checks
970 tmp_CFLAGS="$tmp_CFLAGS -fpstkchk"
971 dnl Enable run-time detection of buffer overruns.
972 tmp_CFLAGS="$tmp_CFLAGS -fstack-security-check"
973 dnl Disable floating point optimizations
974 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
975 dnl Assume aliasing in the program.
976 tmp_CFLAGS="$tmp_CFLAGS -falias"
977 dnl Assume that arguments may be aliased.
978 tmp_CFLAGS="$tmp_CFLAGS -alias-args"
979 dnl Assume aliasing within functions
980 tmp_CFLAGS="$tmp_CFLAGS -ffnalias"
981 dnl Disable prefetch insertion optimization
982 tmp_CFLAGS="$tmp_CFLAGS -no-prefetch"
983 dnl Disable loop unrolling optimization
984 tmp_CFLAGS="$tmp_CFLAGS -unroll0"
992 tmp_CFLAGS="$tmp_CFLAGS"
997 if test "$want_warnings" = "yes"; then
998 dnl Highest warning level is double -A, next is single -A.
999 dnl Due to the big number of warnings these trigger on third
1000 dnl party header files it is impractical for us to use any of
1001 dnl them here. If you want them simply define it in CPPFLAGS.
1002 tmp_CFLAGS="$tmp_CFLAGS"
1008 if test "$want_warnings" = "yes"; then
1009 dnl Perform stricter semantic and lint-like checks
1010 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1016 if test "$want_warnings" = "yes"; then
1017 dnl Perform stricter semantic and lint-like checks
1018 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1019 dnl Disable some remarks
1020 dnl #1209: controlling expression is constant
1021 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1027 if test "$want_warnings" = "yes"; then
1028 dnl Perform stricter semantic and lint-like checks
1029 tmp_CFLAGS="$tmp_CFLAGS -v"
1035 if test "$want_warnings" = "yes"; then
1036 dnl Activate all warnings
1037 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1038 dnl Make string constants be of type const char *
1039 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1040 dnl Warn use of unsupported GCC features ignored by TCC
1041 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1047 if test "$want_warnings" = "yes"; then
1048 dnl Issue all warnings
1049 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1056 tmp_CFLAGS="$tmp_CFLAGS"
1061 squeeze tmp_CPPFLAGS
1064 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1065 AC_MSG_CHECKING([if compiler accepts strict warning options])
1066 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1067 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1070 CURL_COMPILER_WORKS_IFELSE([
1071 AC_MSG_RESULT([yes])
1072 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1075 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1076 dnl restore initial settings
1077 CPPFLAGS="$tmp_save_CPPFLAGS"
1078 CFLAGS="$tmp_save_CFLAGS"
1086 dnl CURL_SHFUNC_SQUEEZE
1087 dnl -------------------------------------------------
1088 dnl Declares a shell function squeeze() which removes
1089 dnl redundant whitespace out of a shell variable.
1091 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1094 eval _sqz_input=\[$][$]1
1095 for _sqz_token in $_sqz_input; do
1096 if test -z "$_sqz_result"; then
1097 _sqz_result="$_sqz_token"
1099 _sqz_result="$_sqz_result $_sqz_token"
1102 eval [$]1=\$_sqz_result
1108 dnl CURL_PROCESS_DEBUG_BUILD_OPTS
1109 dnl -------------------------------------------------
1110 dnl Settings which depend on configure's debug given
1111 dnl option, and further configure the build process.
1112 dnl Don't use this macro for compiler dependant stuff.
1114 AC_DEFUN([CURL_PROCESS_DEBUG_BUILD_OPTS], [
1115 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
1116 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1117 AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
1119 if test "$want_debug" = "yes"; then
1120 CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1127 dnl CURL_CHECK_PROG_CC
1128 dnl -------------------------------------------------
1129 dnl Check for compiler program, preventing CFLAGS and
1130 dnl CPPFLAGS from being unexpectedly changed.
1132 AC_DEFUN([CURL_CHECK_PROG_CC], [
1133 ac_save_CFLAGS="$CFLAGS"
1134 ac_save_CPPFLAGS="$CPPFLAGS"
1136 CFLAGS="$ac_save_CFLAGS"
1137 CPPFLAGS="$ac_save_CPPFLAGS"
1141 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1142 dnl -------------------------------------------------
1143 dnl Verifies if shell variable VARNAME contains VALUE.
1144 dnl Contents of variable VARNAME and VALUE are handled
1145 dnl as whitespace separated lists of words. If at least
1146 dnl one word of VALUE is present in VARNAME the match
1147 dnl is considered positive, otherwise false.
1149 AC_DEFUN([CURL_VAR_MATCH], [
1150 ac_var_match_word="no"
1151 for word1 in $[$1]; do
1152 for word2 in [$2]; do
1153 if test "$word1" = "$word2"; then
1154 ac_var_match_word="yes"
1161 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1162 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1163 dnl -------------------------------------------------
1164 dnl This performs a CURL_VAR_MATCH check and executes
1165 dnl first branch if the match is positive, otherwise
1166 dnl the second branch is executed.
1168 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1169 CURL_VAR_MATCH([$1],[$2])
1170 if test "$ac_var_match_word" = "yes"; then
1178 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1179 dnl -------------------------------------------------
1180 dnl Contents of variable VARNAME and VALUE are handled
1181 dnl as whitespace separated lists of words. Each word
1182 dnl from VALUE is removed from VARNAME when present.
1184 AC_DEFUN([CURL_VAR_STRIP], [
1185 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1187 for word1 in $[$1]; do
1188 ac_var_strip_word="no"
1189 for word2 in [$2]; do
1190 if test "$word1" = "$word2"; then
1191 ac_var_strip_word="yes"
1194 if test "$ac_var_strip_word" = "no"; then
1195 ac_var_stripped="$ac_var_stripped $word1"
1198 dnl squeeze whitespace out of result
1199 [$1]="$ac_var_stripped"