1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2009, 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([__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"
205 compiler_id="INTEL_WINDOWS_C"
206 flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
207 flags_dbg_all="$flags_dbg_all /debug"
208 flags_dbg_all="$flags_dbg_all /debug:none"
209 flags_dbg_all="$flags_dbg_all /debug:minimal"
210 flags_dbg_all="$flags_dbg_all /debug:partial"
211 flags_dbg_all="$flags_dbg_all /debug:full"
212 flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
213 flags_dbg_all="$flags_dbg_all /debug:extended"
214 flags_dbg_yes="/Zi /Oy-"
215 flags_dbg_off="/debug:none /Oy-"
216 flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
226 dnl CURL_CHECK_COMPILER_LCC
227 dnl -------------------------------------------------
228 dnl Verify if compiler being used is LCC.
230 AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
231 AC_MSG_CHECKING([if compiler is LCC])
232 CURL_CHECK_DEF([__LCC__], [], [silent])
233 if test "$curl_cv_have_def___LCC__" = "yes"; then
248 dnl CURL_CHECK_COMPILER_SGI_MIPS_C
249 dnl -------------------------------------------------
250 dnl Verify if compiler being used is SGI MIPS C.
252 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
253 AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
254 AC_MSG_CHECKING([if compiler is SGI MIPS C])
255 CURL_CHECK_DEF([__GNUC__], [], [silent])
256 CURL_CHECK_DEF([__sgi], [], [silent])
257 if test "$curl_cv_have_def___GNUC__" = "no" &&
258 test "$curl_cv_have_def___sgi" = "yes" &&
259 test "$compiler_id" = "unknown"; then
261 compiler_id="SGI_MIPS_C"
262 flags_dbg_all="-g -g0 -g1 -g2 -g3"
265 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
274 dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
275 dnl -------------------------------------------------
276 dnl Verify if compiler being used is SGI MIPSpro C.
278 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
279 AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
280 AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
281 CURL_CHECK_DEF([__GNUC__], [], [silent])
282 CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
283 CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
284 if test "$curl_cv_have_def___GNUC__" = "no" &&
285 (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
286 test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
288 compiler_id="SGI_MIPSPRO_C"
289 flags_dbg_all="-g -g0 -g1 -g2 -g3"
292 flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
301 dnl CURL_CHECK_COMPILER_SUNPRO_C
302 dnl -------------------------------------------------
303 dnl Verify if compiler being used is SunPro C.
305 AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
306 AC_MSG_CHECKING([if compiler is SunPro C])
307 CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
308 if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
310 compiler_id="SUNPRO_C"
311 flags_dbg_all="-g -s"
314 flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
323 dnl CURL_CHECK_COMPILER_TINY_C
324 dnl -------------------------------------------------
325 dnl Verify if compiler being used is Tiny C.
327 AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
328 AC_MSG_CHECKING([if compiler is Tiny C])
329 CURL_CHECK_DEF([__TINYC__], [], [silent])
330 if test "$curl_cv_have_def___TINYC__" = "yes"; then
333 flags_dbg_all="-g -b"
345 dnl CURL_CHECK_COMPILER_WATCOM_C
346 dnl -------------------------------------------------
347 dnl Verify if compiler being used is Watcom C.
349 AC_DEFUN([CURL_CHECK_COMPILER_WATCOM_C], [
350 AC_MSG_CHECKING([if compiler is Watcom C])
351 CURL_CHECK_DEF([__WATCOMC__], [], [silent])
352 if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
354 CURL_CHECK_DEF([__UNIX__], [], [silent])
355 if test "$curl_cv_have_def___UNIX__" = "yes"; then
356 compiler_id="WATCOM_UNIX_C"
357 flags_dbg_all="-g1 -g1+ -g2 -g3"
360 flags_opt_all="-O0 -O1 -O2 -O3"
364 compiler_id="WATCOM_WINDOWS_C"
378 dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
379 dnl -------------------------------------------------
380 dnl Changes standard include paths present in CFLAGS
381 dnl and CPPFLAGS into isystem include paths. This is
382 dnl done to prevent GNUC from generating warnings on
383 dnl headers from these locations, although on ancient
384 dnl GNUC versions these warnings are not silenced.
386 AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
387 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
389 tmp_chg_FLAGS="$CFLAGS"
390 for word1 in $tmp_chg_FLAGS; do
393 tmp_has_include="yes"
397 if test "$tmp_has_include" = "yes"; then
398 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
399 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
400 CFLAGS="$tmp_chg_FLAGS"
404 tmp_chg_FLAGS="$CPPFLAGS"
405 for word1 in $tmp_chg_FLAGS; do
408 tmp_has_include="yes"
412 if test "$tmp_has_include" = "yes"; then
413 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
414 tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
415 CPPFLAGS="$tmp_chg_FLAGS"
421 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
422 dnl -------------------------------------------------
423 dnl Verify if the C compiler seems to work with the
424 dnl settings that are 'active' at the time the test
427 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
428 dnl compilation capability verification
429 tmp_compiler_works="unknown"
437 tmp_compiler_works="yes"
439 tmp_compiler_works="no"
441 sed 's/^/cc-fail: /' conftest.err >&6
444 dnl linking capability verification
445 if test "$tmp_compiler_works" = "yes"; then
453 tmp_compiler_works="yes"
455 tmp_compiler_works="no"
457 sed 's/^/link-fail: /' conftest.err >&6
461 dnl only do runtime verification when not cross-compiling
462 if test "x$cross_compiling" != "xyes" &&
463 test "$tmp_compiler_works" = "yes"; then
474 tmp_compiler_works="yes"
476 tmp_compiler_works="no"
478 echo "run-fail: test program exited with status $ac_status" >&6
482 dnl branch upon test result
483 if test "$tmp_compiler_works" = "yes"; then
491 dnl CURL_SET_COMPILER_BASIC_OPTS
492 dnl -------------------------------------------------
493 dnl Sets compiler specific options/flags which do not
494 dnl depend on configure's debug, optimize or warnings
497 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
498 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
499 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
501 if test "$compiler_id" != "unknown"; then
503 if test "$compiler_id" = "GNU_C"; then
504 CURL_CONVERT_INCLUDE_TO_ISYSTEM
507 tmp_save_CPPFLAGS="$CPPFLAGS"
508 tmp_save_CFLAGS="$CFLAGS"
512 case "$compiler_id" in
516 dnl Select strict ANSI C compiler mode
517 tmp_CFLAGS="$tmp_CFLAGS -std1"
518 dnl Turn off optimizer ANSI C aliasing rules
519 tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
520 dnl Generate warnings for missing function prototypes
521 tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
522 dnl Change some warnings into fatal errors
523 tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
529 tmp_CFLAGS="$tmp_CFLAGS"
534 dnl Disallow run-time dereferencing of null pointers
535 tmp_CFLAGS="$tmp_CFLAGS -z"
536 dnl Disable some remarks
537 dnl #4227: padding struct with n bytes to align member
538 dnl #4255: padding size of struct with n bytes to alignment boundary
539 tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
544 dnl Ensure that compiler optimizations are always thread-safe.
545 tmp_CFLAGS="$tmp_CFLAGS -qthreaded"
546 dnl Disable type based strict aliasing optimizations, using worst
547 dnl case aliasing assumptions when compiling. Type based aliasing
548 dnl would restrict the lvalues that could be safely used to access
550 tmp_CFLAGS="$tmp_CFLAGS -qnoansialias"
551 dnl Force compiler to stop after the compilation phase, without
552 dnl generating an object code file when compilation has errors.
553 tmp_CFLAGS="$tmp_CFLAGS -qhalt=e"
558 dnl On unix this compiler uses gcc's header files, so
559 dnl we select ANSI C89 dialect plus GNU extensions.
560 tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
561 dnl Change some warnings into errors
562 dnl #140: too many arguments in function call
563 dnl #147: declaration is incompatible with 'previous one'
564 dnl #165: too few arguments in function call
565 dnl #266: function declared implicitly
566 tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
567 dnl Disable some remarks
568 dnl #279: controlling expression is constant
569 dnl #981: operands are evaluated in unspecified order
570 dnl #1469: "cc" clobber ignored
571 tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
577 tmp_CFLAGS="$tmp_CFLAGS"
582 dnl Disallow run-time dereferencing of null pointers
583 tmp_CFLAGS="$tmp_CFLAGS -n"
589 tmp_CFLAGS="$tmp_CFLAGS"
595 tmp_CFLAGS="$tmp_CFLAGS"
601 tmp_CFLAGS="$tmp_CFLAGS"
607 tmp_CFLAGS="$tmp_CFLAGS"
613 tmp_CFLAGS="$tmp_CFLAGS"
619 tmp_CFLAGS="$tmp_CFLAGS"
627 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
628 AC_MSG_CHECKING([if compiler accepts some basic options])
629 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
630 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
633 CURL_COMPILER_WORKS_IFELSE([
635 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
638 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
639 dnl restore initial settings
640 CPPFLAGS="$tmp_save_CPPFLAGS"
641 CFLAGS="$tmp_save_CFLAGS"
649 dnl CURL_SET_COMPILER_DEBUG_OPTS
650 dnl -------------------------------------------------
651 dnl Sets compiler specific options/flags which depend
652 dnl on configure's debug option.
654 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
655 AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
656 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
657 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
659 if test "$compiler_id" != "unknown"; then
661 tmp_save_CFLAGS="$CFLAGS"
662 tmp_save_CPPFLAGS="$CPPFLAGS"
666 tmp_CPPFLAGS="$CPPFLAGS"
667 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
668 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
670 if test "$want_debug" = "yes"; then
671 AC_MSG_CHECKING([if compiler accepts debug enabling options])
672 tmp_options="$flags_dbg_yes"
674 if test "$want_debug" = "no"; then
675 AC_MSG_CHECKING([if compiler accepts debug disabling options])
676 tmp_options="$flags_dbg_off"
679 CPPFLAGS="$tmp_CPPFLAGS"
680 CFLAGS="$tmp_CFLAGS $tmp_options"
683 CURL_COMPILER_WORKS_IFELSE([
685 AC_MSG_NOTICE([compiler options added: $tmp_options])
688 AC_MSG_WARN([compiler options rejected: $tmp_options])
689 dnl restore initial settings
690 CPPFLAGS="$tmp_save_CPPFLAGS"
691 CFLAGS="$tmp_save_CFLAGS"
698 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
699 dnl -------------------------------------------------
700 dnl Sets compiler specific options/flags which depend
701 dnl on configure's optimize option.
703 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
704 AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
705 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
706 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
708 if test "$compiler_id" != "unknown"; then
710 tmp_save_CFLAGS="$CFLAGS"
711 tmp_save_CPPFLAGS="$CPPFLAGS"
715 tmp_CPPFLAGS="$CPPFLAGS"
716 honor_optimize_option="yes"
718 dnl If optimization request setting has not been explicitly specified,
719 dnl it has been derived from the debug setting and initially assumed.
720 dnl This initially assumed optimizer setting will finally be ignored
721 dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
722 dnl that an initially assumed optimizer setting might not be honored.
724 if test "$want_optimize" = "assume_no" ||
725 test "$want_optimize" = "assume_yes"; then
726 AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
727 CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
728 honor_optimize_option="no"
730 CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
731 honor_optimize_option="no"
733 AC_MSG_RESULT([$honor_optimize_option])
734 if test "$honor_optimize_option" = "yes"; then
735 if test "$want_optimize" = "assume_yes"; then
738 if test "$want_optimize" = "assume_no"; then
744 if test "$honor_optimize_option" = "yes"; then
745 CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
746 CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
747 if test "$want_optimize" = "yes"; then
748 AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
749 tmp_options="$flags_opt_yes"
751 if test "$want_optimize" = "no"; then
752 AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
753 tmp_options="$flags_opt_off"
755 CPPFLAGS="$tmp_CPPFLAGS"
756 CFLAGS="$tmp_CFLAGS $tmp_options"
759 CURL_COMPILER_WORKS_IFELSE([
761 AC_MSG_NOTICE([compiler options added: $tmp_options])
764 AC_MSG_WARN([compiler options rejected: $tmp_options])
765 dnl restore initial settings
766 CPPFLAGS="$tmp_save_CPPFLAGS"
767 CFLAGS="$tmp_save_CFLAGS"
775 dnl CURL_SET_COMPILER_WARNING_OPTS
776 dnl -------------------------------------------------
777 dnl Sets compiler options/flags which depend on
778 dnl configure's warnings given option.
780 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
781 AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
782 AC_REQUIRE([CURL_CHECK_COMPILER])dnl
783 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
785 if test "$compiler_id" != "unknown"; then
787 tmp_save_CPPFLAGS="$CPPFLAGS"
788 tmp_save_CFLAGS="$CFLAGS"
792 case "$compiler_id" in
796 if test "$want_warnings" = "yes"; then
797 dnl Select a higher warning level than default level2
798 tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
804 if test "$want_warnings" = "yes"; then
806 dnl Do not enable -pedantic when cross-compiling with a gcc older
807 dnl than 3.0, to avoid warnings from third party system headers.
808 if test "x$cross_compiling" != "xyes" ||
809 test "$compiler_num" -ge "300"; then
810 tmp_CFLAGS="$tmp_CFLAGS -pedantic"
813 dnl Set of options we believe *ALL* gcc versions support:
814 tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
816 dnl Only gcc 1.4 or later
817 if test "$compiler_num" -ge "104"; then
818 tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
819 dnl If not cross-compiling with a gcc older than 3.0
820 if test "x$cross_compiling" != "xyes" ||
821 test "$compiler_num" -ge "300"; then
822 tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
826 dnl Only gcc 2.7 or later
827 if test "$compiler_num" -ge "207"; then
828 tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
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 -Wmissing-declarations"
833 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
837 dnl Only gcc 2.95 or later
838 if test "$compiler_num" -ge "295"; then
839 tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
842 dnl Only gcc 2.96 or later
843 if test "$compiler_num" -ge "296"; then
844 tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
845 tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
846 dnl -Wundef used only if gcc is 2.96 or later since we get
847 dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
848 dnl headers with gcc 2.95.4 on FreeBSD 4.9
849 tmp_CFLAGS="$tmp_CFLAGS -Wundef"
852 dnl Only gcc 2.97 or later
853 if test "$compiler_num" -ge "297"; then
854 tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
857 dnl Only gcc 3.0 or later
858 if test "$compiler_num" -ge "300"; then
859 dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
860 dnl on i686-Linux as it gives us heaps with false positives.
861 dnl Also, on gcc 4.0.X it is totally unbearable and complains all
862 dnl over making it unusable for generic purposes. Let's not use it.
863 tmp_CFLAGS="$tmp_CFLAGS"
866 dnl Only gcc 3.3 or later
867 if test "$compiler_num" -ge "303"; then
868 tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
871 dnl Only gcc 3.4 or later
872 if test "$compiler_num" -ge "304"; then
873 tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
876 dnl Only gcc 4.3 or later
877 if test "$compiler_num" -ge "403"; then
878 tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
879 tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
880 tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
885 dnl Do not issue warnings for code in system include paths.
886 if test "$compiler_num" -ge "300"; then
887 tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
889 dnl When cross-compiling with a gcc older than 3.0, disable
890 dnl some warnings triggered on third party system headers.
891 if test "x$cross_compiling" = "xyes"; then
892 if test "$compiler_num" -ge "104"; then
894 tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
896 if test "$compiler_num" -ge "207"; then
898 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
899 tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
907 if test "$want_warnings" = "yes"; then
908 dnl Issue all warnings
909 tmp_CFLAGS="$tmp_CFLAGS +w1"
916 tmp_CFLAGS="$tmp_CFLAGS"
921 if test "$want_warnings" = "yes"; then
922 if test "$compiler_num" -gt "600"; then
923 dnl Show errors, warnings, and remarks
924 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
925 dnl Perform extra compile-time code checking
926 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
927 dnl Warn on nested comments
928 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
929 dnl Show warnings relative to deprecated features
930 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
931 dnl Enable warnings for missing prototypes
932 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
933 dnl Enable warnings for 64-bit portability issues
934 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
935 dnl Enable warnings for questionable pointer arithmetic
936 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
937 dnl Check for function return typw issues
938 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
939 dnl Warn on variable declarations hiding a previous one
940 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
941 dnl Warn when a variable is used before initialized
942 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
943 dnl Warn if a declared function is not used
944 tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
947 dnl Disable using EBP register in optimizations
948 tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
949 dnl Disable use of ANSI C aliasing rules in optimizations
950 tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
951 dnl Value-safe optimizations on floating-point data
952 tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
953 dnl Only icc 10.0 or later
954 if test "$compiler_num" -ge "1000"; then
955 dnl Disable vectorizer diagnostic information
956 tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
963 tmp_CFLAGS="$tmp_CFLAGS"
968 if test "$want_warnings" = "yes"; then
969 dnl Highest warning level is double -A, next is single -A.
970 dnl Due to the big number of warnings these trigger on third
971 dnl party header files it is impractical for us to use any of
972 dnl them here. If you want them simply define it in CPPFLAGS.
973 tmp_CFLAGS="$tmp_CFLAGS"
979 if test "$want_warnings" = "yes"; then
980 dnl Perform stricter semantic and lint-like checks
981 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
987 if test "$want_warnings" = "yes"; then
988 dnl Perform stricter semantic and lint-like checks
989 tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
990 dnl Disable some remarks
991 dnl #1209: controlling expression is constant
992 tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
998 if test "$want_warnings" = "yes"; then
999 dnl Perform stricter semantic and lint-like checks
1000 tmp_CFLAGS="$tmp_CFLAGS -v"
1006 if test "$want_warnings" = "yes"; then
1007 dnl Activate all warnings
1008 tmp_CFLAGS="$tmp_CFLAGS -Wall"
1009 dnl Make string constants be of type const char *
1010 tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1011 dnl Warn use of unsupported GCC features ignored by TCC
1012 tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1018 if test "$want_warnings" = "yes"; then
1019 dnl Issue all warnings
1020 tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1027 tmp_CFLAGS="$tmp_CFLAGS"
1032 squeeze tmp_CPPFLAGS
1035 if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1036 AC_MSG_CHECKING([if compiler accepts strict warning options])
1037 CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1038 CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1041 CURL_COMPILER_WORKS_IFELSE([
1042 AC_MSG_RESULT([yes])
1043 AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1046 AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1047 dnl restore initial settings
1048 CPPFLAGS="$tmp_save_CPPFLAGS"
1049 CFLAGS="$tmp_save_CFLAGS"
1057 dnl CURL_SHFUNC_SQUEEZE
1058 dnl -------------------------------------------------
1059 dnl Declares a shell function squeeze() which removes
1060 dnl redundant whitespace out of a shell variable.
1062 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1065 eval _sqz_input=\[$][$]1
1066 for _sqz_token in $_sqz_input; do
1067 if test -z "$_sqz_result"; then
1068 _sqz_result="$_sqz_token"
1070 _sqz_result="$_sqz_result $_sqz_token"
1073 eval [$]1=\$_sqz_result
1079 dnl CURL_CHECK_CURLDEBUG
1080 dnl -------------------------------------------------
1081 dnl Settings which depend on configure's curldebug given
1082 dnl option, and other additional configure pre-requisites.
1083 dnl Actually the curl debug memory tracking feature can
1084 dnl only be used/enabled when libcurl is built as a static
1085 dnl library or as a shared one on those systems on which
1086 dnl shared libraries support undefined symbols.
1088 AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1089 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1090 supports_curldebug="unknown"
1091 if test "$want_curldebug" = "yes"; then
1092 if test "x$enable_shared" != "xno" &&
1093 test "x$enable_shared" != "xyes"; then
1094 AC_MSG_WARN([unknown enable_shared setting.])
1095 supports_curldebug="no"
1097 if test "x$enable_static" != "xno" &&
1098 test "x$enable_static" != "xyes"; then
1099 AC_MSG_WARN([unknown enable_static setting.])
1100 supports_curldebug="no"
1102 if test "$supports_curldebug" != "no"; then
1103 if test "$enable_shared" = "yes" &&
1104 test "$need_no_undefined" = "yes"; then
1105 supports_curldebug="no"
1106 AC_MSG_WARN([shared library does not support undefined symbols.])
1111 if test "$want_curldebug" = "yes"; then
1112 AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1113 test "$supports_curldebug" = "no" || supports_curldebug="yes"
1114 AC_MSG_RESULT([$supports_curldebug])
1115 if test "$supports_curldebug" = "no"; then
1116 AC_MSG_WARN([cannot enable curl debug memory tracking.])
1121 if test "$want_curldebug" = "yes"; then
1122 CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1125 if test "$want_debug" = "yes"; then
1126 CPPFLAGS="$CPPFLAGS -DDEBUGBUILD"
1132 dnl CURL_CHECK_NO_UNDEFINED
1133 dnl -------------------------------------------------
1134 dnl Checks if the -no-undefined flag must be used when
1135 dnl building shared libraries. This is required on all
1136 dnl systems on which shared libraries should not have
1137 dnl references to undefined symbols. This check should
1138 dnl not be done before AC-PROG-LIBTOOL.
1140 AC_DEFUN([CURL_CHECK_NO_UNDEFINED], [
1141 AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl
1142 AC_MSG_CHECKING([if shared libraries need -no-undefined])
1143 need_no_undefined="no"
1145 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1146 need_no_undefined="yes"
1149 if test "x$allow_undefined" = "xno"; then
1150 need_no_undefined="yes"
1151 elif test "x$allow_undefined_flag" = "xunsupported"; then
1152 need_no_undefined="yes"
1154 AC_MSG_RESULT($need_no_undefined)
1158 dnl CURL_CHECK_PROG_CC
1159 dnl -------------------------------------------------
1160 dnl Check for compiler program, preventing CFLAGS and
1161 dnl CPPFLAGS from being unexpectedly changed.
1163 AC_DEFUN([CURL_CHECK_PROG_CC], [
1164 ac_save_CFLAGS="$CFLAGS"
1165 ac_save_CPPFLAGS="$CPPFLAGS"
1167 CFLAGS="$ac_save_CFLAGS"
1168 CPPFLAGS="$ac_save_CPPFLAGS"
1172 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1173 dnl -------------------------------------------------
1174 dnl Verifies if the compiler actually halts after the
1175 dnl compilation phase without generating any object
1176 dnl code file, when the source compiles with errors.
1178 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1179 AC_MSG_CHECKING([if compiler halts on compilation errors])
1183 force compilation error
1187 AC_MSG_ERROR([compiler does not halt on compilation errors.])
1189 AC_MSG_RESULT([yes])
1194 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1195 dnl -------------------------------------------------
1196 dnl Verifies if the compiler actually halts after the
1197 dnl compilation phase without generating any object
1198 dnl code file, when the source code tries to define a
1199 dnl type for a constant array with negative dimension.
1201 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1202 AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1203 AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1206 typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1212 AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1214 AC_MSG_RESULT([yes])
1219 dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1220 dnl -------------------------------------------------
1221 dnl Verifies if the compiler is capable of handling the
1222 dnl size of a struct member, struct which is a function
1223 dnl result, as a compilation-time condition inside the
1224 dnl type definition of a constant array.
1226 AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1227 AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1228 AC_MSG_CHECKING([if compiler struct member size checking works])
1229 tst_compiler_check_one_works="unknown"
1235 struct mystruct *next;
1237 struct mystruct myfunc();
1238 typedef char good_t1[sizeof(myfunc().mi) == sizeof(int) ? 1 : -1 ];
1239 typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1245 tst_compiler_check_one_works="yes"
1247 tst_compiler_check_one_works="no"
1248 sed 's/^/cc-src: /' conftest.$ac_ext >&6
1249 sed 's/^/cc-err: /' conftest.err >&6
1251 tst_compiler_check_two_works="unknown"
1257 struct mystruct *next;
1259 struct mystruct myfunc();
1260 typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int) ? 1 : -1 ];
1261 typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1267 tst_compiler_check_two_works="no"
1269 tst_compiler_check_two_works="yes"
1271 if test "$tst_compiler_check_one_works" = "yes" &&
1272 test "$tst_compiler_check_two_works" = "yes"; then
1273 AC_MSG_RESULT([yes])
1276 AC_MSG_ERROR([compiler fails struct member size checking.])
1281 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1282 dnl -------------------------------------------------
1283 dnl Verifies if shell variable VARNAME contains VALUE.
1284 dnl Contents of variable VARNAME and VALUE are handled
1285 dnl as whitespace separated lists of words. If at least
1286 dnl one word of VALUE is present in VARNAME the match
1287 dnl is considered positive, otherwise false.
1289 AC_DEFUN([CURL_VAR_MATCH], [
1290 ac_var_match_word="no"
1291 for word1 in $[$1]; do
1292 for word2 in [$2]; do
1293 if test "$word1" = "$word2"; then
1294 ac_var_match_word="yes"
1301 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1302 dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1303 dnl -------------------------------------------------
1304 dnl This performs a CURL_VAR_MATCH check and executes
1305 dnl first branch if the match is positive, otherwise
1306 dnl the second branch is executed.
1308 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1309 CURL_VAR_MATCH([$1],[$2])
1310 if test "$ac_var_match_word" = "yes"; then
1318 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1319 dnl -------------------------------------------------
1320 dnl Contents of variable VARNAME and VALUE are handled
1321 dnl as whitespace separated lists of words. Each word
1322 dnl from VALUE is removed from VARNAME when present.
1324 AC_DEFUN([CURL_VAR_STRIP], [
1325 AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1327 for word1 in $[$1]; do
1328 ac_var_strip_word="no"
1329 for word2 in [$2]; do
1330 if test "$word1" = "$word2"; then
1331 ac_var_strip_word="yes"
1334 if test "$ac_var_strip_word" = "no"; then
1335 ac_var_stripped="$ac_var_stripped $word1"
1338 dnl squeeze whitespace out of result
1339 [$1]="$ac_var_stripped"