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.
21
# $Id: curl-compilers.m4,v 1.46 2008-11-18 20:13:56 yangtse Exp $
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
tmp_CFLAGS="$tmp_CFLAGS -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"
884
dnl Only gcc 4.3 or later
885
if test "$compiler_num" -ge "403"; then
886
tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
887
tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
888
tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
893
dnl Do not issue warnings for code in system include paths.
894
if test "$compiler_num" -ge "300"; then
895
tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
897
dnl When cross-compiling with a gcc older than 3.0, disable
898
dnl some warnings triggered on third party system headers.
899
if test "x$cross_compiling" = "xyes"; then
900
if test "$compiler_num" -ge "104"; then
902
tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
904
if test "$compiler_num" -ge "207"; then
906
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
907
tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
915
if test "$want_warnings" = "yes"; then
916
dnl Issue all warnings
917
dnl tmp_CFLAGS="$tmp_CFLAGS +w1"
918
dnl Due to the HP-UX socklen_t issue it is insane to use the +w1
919
dnl warning level. Until the issue is somehow fixed we will just
920
dnl use the +w2 warning level.
921
tmp_CFLAGS="$tmp_CFLAGS +w2"
928
tmp_CFLAGS="$tmp_CFLAGS"
933
if test "$want_warnings" = "yes"; then
934
if test "$compiler_num" -gt "600"; then
935
dnl Show errors, warnings, and remarks
936
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
937
dnl Perform extra compile-time code checking
938
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
939
dnl Warn on nested comments
940
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
941
dnl Show warnings relative to deprecated features
942
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
943
dnl Enable warnings for missing prototypes
944
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
945
dnl Enable warnings for 64-bit portability issues
946
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
947
dnl Enable warnings for questionable pointer arithmetic
948
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
949
dnl Check for function return typw issues
950
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
951
dnl Warn on variable declarations hiding a previous one
952
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
953
dnl Warn when a variable is used before initialized
954
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
955
dnl Warn if a declared function is not used
956
tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
959
dnl Disable using EBP register in optimizations
960
tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
961
dnl Disable use of ANSI C aliasing rules in optimizations
962
tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
963
dnl Value-safe optimizations on floating-point data
964
tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
965
dnl Only icc 10.0 or later
966
if test "$compiler_num" -ge "1000"; then
967
dnl Disable vectorizer diagnostic information
968
tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
970
dnl Disable some optimizations to debug icc 9.1 SIGSEGV
971
if test "$INTEL_UNIX_C_OPT_SIGSEGV" = "yes"; then
972
dnl Disable interprocedural optimizations
973
tmp_CFLAGS="$tmp_CFLAGS -no-ip -no-ipo"
974
dnl Separate functions for the linker
975
tmp_CFLAGS="$tmp_CFLAGS -ffunction-sections"
976
dnl Disable inlining of user-defined functions
977
tmp_CFLAGS="$tmp_CFLAGS -Ob0"
978
dnl Disable inline expansion of intrinsic functions
979
tmp_CFLAGS="$tmp_CFLAGS -fno-builtin"
980
dnl Disable inlining of functions
981
tmp_CFLAGS="$tmp_CFLAGS -fno-inline"
982
dnl Disable some IPO for single file optimizations
983
tmp_CFLAGS="$tmp_CFLAGS -fno-inline-functions"
984
dnl Disable inlining of standard library functions
985
tmp_CFLAGS="$tmp_CFLAGS -nolib-inline"
986
dnl Disable full and partial inlining when IPO
987
tmp_CFLAGS="$tmp_CFLAGS -ip-no-inlining"
988
dnl Enable floating-point stack integrity checks
989
tmp_CFLAGS="$tmp_CFLAGS -fpstkchk"
990
dnl Enable run-time detection of buffer overruns.
991
tmp_CFLAGS="$tmp_CFLAGS -fstack-security-check"
992
dnl Assume aliasing in the program.
993
tmp_CFLAGS="$tmp_CFLAGS -falias"
994
dnl Assume that arguments may be aliased.
995
tmp_CFLAGS="$tmp_CFLAGS -alias-args"
996
dnl Assume aliasing within functions
997
tmp_CFLAGS="$tmp_CFLAGS -ffnalias"
998
dnl Disable prefetch insertion optimization
999
tmp_CFLAGS="$tmp_CFLAGS -no-prefetch"
1000
dnl Disable loop unrolling optimization
1001
tmp_CFLAGS="$tmp_CFLAGS -unroll0"
1008
tmp_CFLAGS="$tmp_CFLAGS"
1013
if test "$want_warnings" = "yes"; then
1014
dnl Highest warning level is double -A, next is single -A.
1015
dnl Due to the big number of warnings these trigger on third
1016
dnl party header files it is impractical for us to use any of
1017
dnl them here. If you want them simply define it in CPPFLAGS.
1018
tmp_CFLAGS="$tmp_CFLAGS"
1024
if test "$want_warnings" = "yes"; then
1025
dnl Perform stricter semantic and lint-like checks
1026
tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1032
if test "$want_warnings" = "yes"; then
1033
dnl Perform stricter semantic and lint-like checks
1034
tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1035
dnl Disable some remarks
1036
dnl #1209: controlling expression is constant
1037
tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1043
if test "$want_warnings" = "yes"; then
1044
dnl Perform stricter semantic and lint-like checks
1045
tmp_CFLAGS="$tmp_CFLAGS -v"
1051
if test "$want_warnings" = "yes"; then
1052
dnl Activate all warnings
1053
tmp_CFLAGS="$tmp_CFLAGS -Wall"
1054
dnl Make string constants be of type const char *
1055
tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1056
dnl Warn use of unsupported GCC features ignored by TCC
1057
tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1063
if test "$want_warnings" = "yes"; then
1064
dnl Issue all warnings
1065
tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1072
tmp_CFLAGS="$tmp_CFLAGS"
1077
squeeze tmp_CPPFLAGS
1080
if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1081
AC_MSG_CHECKING([if compiler accepts strict warning options])
1082
CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1083
CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1086
CURL_COMPILER_WORKS_IFELSE([
1087
AC_MSG_RESULT([yes])
1088
AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1091
AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1092
dnl restore initial settings
1093
CPPFLAGS="$tmp_save_CPPFLAGS"
1094
CFLAGS="$tmp_save_CFLAGS"
1102
dnl CURL_SHFUNC_SQUEEZE
1103
dnl -------------------------------------------------
1104
dnl Declares a shell function squeeze() which removes
1105
dnl redundant whitespace out of a shell variable.
1107
AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1110
eval _sqz_input=\[$][$]1
1111
for _sqz_token in $_sqz_input; do
1112
if test -z "$_sqz_result"; then
1113
_sqz_result="$_sqz_token"
1115
_sqz_result="$_sqz_result $_sqz_token"
1118
eval [$]1=\$_sqz_result
1124
dnl CURL_PROCESS_DEBUG_BUILD_OPTS
1125
dnl -------------------------------------------------
1126
dnl Settings which depend on configure's debug given
1127
dnl option, and further configure the build process.
1128
dnl Don't use this macro for compiler dependant stuff.
1130
AC_DEFUN([CURL_PROCESS_DEBUG_BUILD_OPTS], [
1131
AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
1132
AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1133
AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
1135
if test "$want_debug" = "yes"; then
1136
CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1143
dnl CURL_CHECK_PROG_CC
1144
dnl -------------------------------------------------
1145
dnl Check for compiler program, preventing CFLAGS and
1146
dnl CPPFLAGS from being unexpectedly changed.
1148
AC_DEFUN([CURL_CHECK_PROG_CC], [
1149
ac_save_CFLAGS="$CFLAGS"
1150
ac_save_CPPFLAGS="$CPPFLAGS"
1152
CFLAGS="$ac_save_CFLAGS"
1153
CPPFLAGS="$ac_save_CPPFLAGS"
1157
dnl CURL_VAR_MATCH (VARNAME, VALUE)
1158
dnl -------------------------------------------------
1159
dnl Verifies if shell variable VARNAME contains VALUE.
1160
dnl Contents of variable VARNAME and VALUE are handled
1161
dnl as whitespace separated lists of words. If at least
1162
dnl one word of VALUE is present in VARNAME the match
1163
dnl is considered positive, otherwise false.
1165
AC_DEFUN([CURL_VAR_MATCH], [
1166
ac_var_match_word="no"
1167
for word1 in $[$1]; do
1168
for word2 in [$2]; do
1169
if test "$word1" = "$word2"; then
1170
ac_var_match_word="yes"
1177
dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1178
dnl [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1179
dnl -------------------------------------------------
1180
dnl This performs a CURL_VAR_MATCH check and executes
1181
dnl first branch if the match is positive, otherwise
1182
dnl the second branch is executed.
1184
AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1185
CURL_VAR_MATCH([$1],[$2])
1186
if test "$ac_var_match_word" = "yes"; then
1194
dnl CURL_VAR_STRIP (VARNAME, VALUE)
1195
dnl -------------------------------------------------
1196
dnl Contents of variable VARNAME and VALUE are handled
1197
dnl as whitespace separated lists of words. Each word
1198
dnl from VALUE is removed from VARNAME when present.
1200
AC_DEFUN([CURL_VAR_STRIP], [
1201
AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1203
for word1 in $[$1]; do
1204
ac_var_strip_word="no"
1205
for word2 in [$2]; do
1206
if test "$word1" = "$word2"; then
1207
ac_var_strip_word="yes"
1210
if test "$ac_var_strip_word" = "no"; then
1211
ac_var_stripped="$ac_var_stripped $word1"
1214
dnl squeeze whitespace out of result
1215
[$1]="$ac_var_stripped"