729d413646a4b1abb7d1f7793c8dafb709252c64
[platform/upstream/curl.git] / m4 / curl-compilers.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
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.
13 #
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.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 # $Id$
22 #***************************************************************************
23
24 # File version for 'aclocal' use. Keep it a single number.
25 # serial 8
26
27
28 dnl CURL_CHECK_COMPILER
29 dnl -------------------------------------------------
30 dnl Verify if the C compiler being used is known.
31
32 AC_DEFUN([CURL_CHECK_COMPILER], [
33   #
34   compiler_id="unknown"
35   compiler_num="0"
36   #
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"
43   #
44   CURL_CHECK_COMPILER_DEC
45   CURL_CHECK_COMPILER_HP
46   CURL_CHECK_COMPILER_IBM
47   CURL_CHECK_COMPILER_INTEL
48   CURL_CHECK_COMPILER_GNU
49   CURL_CHECK_COMPILER_SUN
50   #
51   if test "$compiler_id" = "unknown"; then
52   cat <<_EOF 1>&2
53 ***
54 *** Warning: This configure script does not have information about the
55 *** compiler you are using, relative to the flags required to enable or
56 *** disable generation of debug info, optimization options or warnings.
57 ***
58 *** Whatever settings are present in CFLAGS will be used for this run.
59 ***
60 *** If you wish to help the cURL project to better support your compiler
61 *** you can report this and the required info on the libcurl development
62 *** mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/
63 ***
64 _EOF
65   fi
66 ])
67
68
69 dnl CURL_CHECK_COMPILER_DEC
70 dnl -------------------------------------------------
71 dnl Verify if the C compiler being used is DEC's.
72
73 AC_DEFUN([CURL_CHECK_COMPILER_DEC], [
74   AC_MSG_CHECKING([whether we are using the DEC/Compaq C compiler])
75   CURL_CHECK_DEF([__DECC], [], [silent])
76   CURL_CHECK_DEF([__DECC_VER], [], [silent])
77   if test "$curl_cv_have_def___DECC" = "yes" &&
78     test "$curl_cv_have_def___DECC_VER" = "yes"; then
79     AC_MSG_RESULT([yes])
80     compiler_id="DECC"
81     flags_dbg_all="-g -g0 -g1 -g2 -g3"
82     flags_dbg_yes="-g2"
83     flags_dbg_off="-g0"
84     flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
85     flags_opt_yes="-O1"
86     flags_opt_off="-O0"
87   else
88     AC_MSG_RESULT([no])
89   fi
90 ])
91
92
93 dnl CURL_CHECK_COMPILER_GNU
94 dnl -------------------------------------------------
95 dnl Verify if the C compiler being used is GNU's.
96
97 AC_DEFUN([CURL_CHECK_COMPILER_GNU], [
98   AC_REQUIRE([CURL_CHECK_COMPILER_INTEL])dnl
99   #
100   AC_MSG_CHECKING([whether we are using the GNU C compiler])
101   CURL_CHECK_DEF([__GNUC__], [], [silent])
102   if test "$curl_cv_have_def___GNUC__" = "yes" &&
103     test "$compiler_id" = "unknown"; then
104     AC_MSG_RESULT([yes])
105     compiler_id="GNUC"
106     gccver=`$CC -dumpversion`
107     gccvhi=`echo $gccver | cut -d . -f1`
108     gccvlo=`echo $gccver | cut -d . -f2`
109     compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
110     flags_dbg_all="-g -g0 -g1 -g2 -g3"
111     flags_dbg_all="$flags_dbg_all -ggdb"
112     flags_dbg_all="$flags_dbg_all -gstabs"
113     flags_dbg_all="$flags_dbg_all -gstabs+"
114     flags_dbg_all="$flags_dbg_all -gcoff"
115     flags_dbg_all="$flags_dbg_all -gxcoff"
116     flags_dbg_all="$flags_dbg_all -gdwarf-2"
117     flags_dbg_all="$flags_dbg_all -gvms"
118     flags_dbg_yes="-g"
119     flags_dbg_off="-g0"
120     flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
121     flags_opt_yes="-O2"
122     flags_opt_off="-O0"
123   else
124     AC_MSG_RESULT([no])
125   fi
126 ])
127
128
129 dnl CURL_CHECK_COMPILER_HP
130 dnl -------------------------------------------------
131 dnl Verify if the C compiler being used is HP's.
132
133 AC_DEFUN([CURL_CHECK_COMPILER_HP], [
134   AC_MSG_CHECKING([whether we are using the HP C compiler])
135   CURL_CHECK_DEF([__HP_cc], [], [silent])
136   if test "$curl_cv_have_def___HP_cc" = "yes"; then
137     AC_MSG_RESULT([yes])
138     compiler_id="HPUXC"
139     flags_dbg_all="-g -s"
140     flags_dbg_yes="-g"
141     flags_dbg_off="-s"
142     flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
143     flags_opt_yes="+O2"
144     flags_opt_off="+O0"
145   else
146     AC_MSG_RESULT([no])
147   fi
148 ])
149
150
151 dnl CURL_CHECK_COMPILER_IBM
152 dnl -------------------------------------------------
153 dnl Verify if the C compiler being used is IBM's.
154
155 AC_DEFUN([CURL_CHECK_COMPILER_IBM], [
156   AC_MSG_CHECKING([whether we are using the IBM C compiler])
157   CURL_CHECK_DEF([__IBMC__], [], [silent])
158   if test "$curl_cv_have_def___IBMC__" = "yes"; then
159     AC_MSG_RESULT([yes])
160     compiler_id="IBMC"
161     flags_dbg_all="-g -g0 -g1 -g2 -g3"
162     flags_dbg_yes="-g"
163     flags_dbg_off=""
164     flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
165     flags_opt_all="$flags_opt_all -qnooptimize"
166     flags_opt_all="$flags_opt_all -qoptimize=0"
167     flags_opt_all="$flags_opt_all -qoptimize=1"
168     flags_opt_all="$flags_opt_all -qoptimize=2"
169     flags_opt_all="$flags_opt_all -qoptimize=3"
170     flags_opt_all="$flags_opt_all -qoptimize=4"
171     flags_opt_all="$flags_opt_all -qoptimize=5"
172     flags_opt_yes="-O2"
173     flags_opt_off="-qnooptimize"
174   else
175     AC_MSG_RESULT([no])
176   fi
177 ])
178
179
180 dnl CURL_CHECK_COMPILER_INTEL
181 dnl -------------------------------------------------
182 dnl Verify if the C compiler being used is Intel's.
183
184 AC_DEFUN([CURL_CHECK_COMPILER_INTEL], [
185   AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU])dnl
186   AC_MSG_CHECKING([whether we are using the Intel C compiler])
187   CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
188   if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
189     AC_MSG_RESULT([yes])
190     CURL_CHECK_DEF([__unix__], [], [silent])
191     if test "$curl_cv_have_def___unix__" = "yes"; then
192       compiler_id="ICC_unix"
193       flags_dbg_all="-g -g0"
194       flags_dbg_yes="-g"
195       flags_dbg_off="-g0"
196       flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
197       flags_opt_yes="-O2"
198       flags_opt_off="-O0"
199     else
200       compiler_id="ICC_windows"
201       flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
202       flags_dbg_all="$flags_dbg_all /debug"
203       flags_dbg_all="$flags_dbg_all /debug:none"
204       flags_dbg_all="$flags_dbg_all /debug:minimal"
205       flags_dbg_all="$flags_dbg_all /debug:partial"
206       flags_dbg_all="$flags_dbg_all /debug:full"
207       flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
208       flags_dbg_all="$flags_dbg_all /debug:extended"
209       flags_dbg_yes="/Zi /Oy-"
210       flags_dbg_off="/debug:none /Oy-"
211       flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
212       flags_opt_yes="/O2"
213       flags_opt_off="/Od"
214     fi
215     compiler_num="$curl_cv_def___INTEL_COMPILER"
216   else
217     AC_MSG_RESULT([no])
218   fi
219 ])
220
221
222 dnl CURL_CHECK_COMPILER_SUN
223 dnl -------------------------------------------------
224 dnl Verify if the C compiler being used is SUN's.
225
226 AC_DEFUN([CURL_CHECK_COMPILER_SUN], [
227   AC_MSG_CHECKING([whether we are using the SUN C compiler])
228   CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
229   if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
230     AC_MSG_RESULT([yes])
231     compiler_id="SUNC"
232     flags_dbg_all="-g -s"
233     flags_dbg_yes="-g"
234     flags_dbg_off="-s"
235     flags_opt_all="-O -xO1 -xO2 -xO3 -xO4 -xO5"
236     flags_opt_yes="-xO2"
237     flags_opt_off=""
238   else
239     AC_MSG_RESULT([no])
240   fi
241 ])
242
243
244 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
245 dnl -------------------------------------------------
246 dnl Verify if the C compiler seems to work with the
247 dnl settings that are 'active' at the time the test
248 dnl is performed.
249
250 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
251   dnl compilation capability verification
252   tmp_compiler_works="unknown"
253   AC_COMPILE_IFELSE([
254     AC_LANG_PROGRAM([[
255     ]],[[
256       int i = 1;
257       return i;
258     ]])
259   ],[
260     tmp_compiler_works="yes"
261   ],[
262     tmp_compiler_works="no"
263   ])
264   dnl linking capability verification
265   if test "$tmp_compiler_works" = "yes"; then
266     AC_LINK_IFELSE([
267       AC_LANG_PROGRAM([[
268       ]],[[
269         int i = 1;
270         return i;
271       ]])
272     ],[
273       tmp_compiler_works="yes"
274     ],[
275       tmp_compiler_works="no"
276     ])
277   fi
278   dnl only do runtime verification when not cross-compiling
279   if test "x$cross_compiling" != "xyes" &&
280     test "$tmp_compiler_works" = "yes"; then
281     AC_RUN_IFELSE([
282       AC_LANG_PROGRAM([[
283       ]],[[
284         int i = 0;
285         exit(i);
286       ]])
287     ],[
288       tmp_compiler_works="yes"
289     ],[
290       tmp_compiler_works="no"
291     ])
292   fi
293   dnl branch upon test result
294   if test "$tmp_compiler_works" = "yes"; then
295   ifelse($1,,:,[$1])
296   ifelse($2,,,[else
297     $2])
298   fi
299 ])
300
301
302 dnl CURL_SET_COMPILER_BASIC_OPTS
303 dnl -------------------------------------------------
304 dnl Sets compiler specific options/flags which do not
305 dnl depend on configure's debug, optimize or warnings
306 dnl options.
307
308 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
309   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
310   #
311   if test "$compiler_id" != "unknown"; then
312     #
313     tmp_save_CPPFLAGS="$CPPFLAGS"
314     tmp_save_CFLAGS="$CFLAGS"
315     tmp_CPPFLAGS=""
316     tmp_CFLAGS=""
317     #
318     case "$compiler_id" in
319         #
320       DECC)
321         #
322         dnl Select strict ANSI C compiler mode
323         tmp_CFLAGS="$tmp_CFLAGS -std1"
324         dnl Turn off optimizer ANSI C aliasing rules
325         tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
326         dnl Generate warnings for missing function prototypes
327         tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
328         dnl Change some warnings into fatal errors
329         tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
330         ;;
331         #
332       GNUC)
333         #
334         dnl Placeholder
335         tmp_CFLAGS="$tmp_CFLAGS"
336         ;;
337         #
338       HPUXC)
339         #
340         dnl Disallow run-time dereferencing of null pointers
341         tmp_CFLAGS="$tmp_CFLAGS -z"
342         dnl Disable some remarks
343         dnl #4227: padding struct with n bytes to align member
344         dnl #4255: padding size of struct with n bytes to alignment boundary
345         tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
346         ;;
347         #
348       IBMC)
349         #
350         dnl Ensure that compiler optimizations are always thread-safe.
351         tmp_CFLAGS="$tmp_CFLAGS -qthreaded"
352         dnl Disable type based strict aliasing optimizations, using worst
353         dnl case aliasing assumptions when compiling. Type based aliasing
354         dnl would restrict the lvalues that could be safely used to access
355         dnl a data object.
356         tmp_CFLAGS="$tmp_CFLAGS -qnoansialias"
357         dnl Force compiler to stop after the compilation phase, without
358         dnl generating an object code file when compilation has errors.
359         tmp_CFLAGS="$tmp_CFLAGS -qhalt=e"
360         ;;
361         #
362       ICC_unix)
363         #
364         dnl On unix this compiler uses gcc's header files, so
365         dnl we select ANSI C89 dialect plus GNU extensions.
366         tmp_CPPFLAGS="$tmp_CPPFLAGS -std=gnu89"
367         dnl Change some warnings into errors
368         dnl #140: too many arguments in function call
369         dnl #147: declaration is incompatible with 'previous one'
370         dnl #165: too few arguments in function call
371         dnl #266: function declared implicitly
372         tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
373         dnl Disable some remarks
374         dnl #279: controlling expression is constant
375         dnl #981: operands are evaluated in unspecified order
376         dnl #1469: "cc" clobber ignored
377         tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
378         dnl Disable use of ANSI C aliasing rules in optimizations
379         tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
380         dnl Disable floating point optimizations
381         tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
382         ;;
383         #
384       ICC_windows)
385         #
386         dnl Placeholder
387         tmp_CFLAGS="$tmp_CFLAGS"
388         ;;
389         #
390       SUNC)
391         #
392         dnl Placeholder
393         tmp_CFLAGS="$tmp_CFLAGS"
394         ;;
395         #
396     esac
397     #
398     tmp_CPPFLAGS=`eval echo $tmp_CPPFLAGS`
399     tmp_CFLAGS=`eval echo $tmp_CFLAGS`
400     #
401     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
402       AC_MSG_CHECKING([if compiler accepts some basic options])
403       CPPFLAGS=`eval echo $tmp_save_CPPFLAGS $tmp_CPPFLAGS`
404       CFLAGS=`eval echo $tmp_save_CFLAGS $tmp_CFLAGS`
405       CURL_COMPILER_WORKS_IFELSE([
406         AC_MSG_RESULT([yes])
407         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
408       ],[
409         AC_MSG_RESULT([no])
410         AC_MSG_NOTICE([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
411         dnl restore initial settings
412         CPPFLAGS="$tmp_save_CPPFLAGS"
413         CFLAGS="$tmp_save_CFLAGS"
414       ])
415     fi
416     #
417   fi
418 ])
419
420
421 dnl CURL_SET_COMPILER_DEBUG_OPTS
422 dnl -------------------------------------------------
423 dnl Sets compiler specific options/flags which depend
424 dnl on configure's debug option.
425
426 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
427   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
428   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
429   #
430   if test "$compiler_id" != "unknown"; then
431     #
432     tmp_save_CFLAGS="$CFLAGS"
433     tmp_save_CPPFLAGS="$CPPFLAGS"
434     #
435     tmp_options=""
436     tmp_CFLAGS="$CFLAGS"
437     tmp_CPPFLAGS="$CPPFLAGS"
438     CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
439     CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
440     #
441     if test "$want_debug" = "yes"; then
442       AC_MSG_CHECKING([if compiler accepts debug enabling options])
443       tmp_options="$flags_dbg_yes"
444     fi
445     if test "$want_debug" = "no"; then
446       AC_MSG_CHECKING([if compiler accepts debug disabling options])
447       tmp_options="$flags_dbg_off"
448     fi
449     #
450     CPPFLAGS=`eval echo $tmp_CPPFLAGS`
451     CFLAGS=`eval echo $tmp_CFLAGS $tmp_options`
452     CURL_COMPILER_WORKS_IFELSE([
453       AC_MSG_RESULT([yes])
454       AC_MSG_NOTICE([compiler options added: $tmp_options])
455     ],[
456       AC_MSG_RESULT([no])
457       AC_MSG_NOTICE([compiler options rejected: $tmp_options])
458       dnl restore initial settings
459       CPPFLAGS="$tmp_save_CPPFLAGS"
460       CFLAGS="$tmp_save_CFLAGS"
461     ])
462     #
463   fi
464 ])
465
466
467 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
468 dnl -------------------------------------------------
469 dnl Sets compiler specific options/flags which depend
470 dnl on configure's optimize option.
471
472 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
473   AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
474   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
475   #
476   if test "$compiler_id" != "unknown"; then
477     #
478     tmp_save_CFLAGS="$CFLAGS"
479     tmp_save_CPPFLAGS="$CPPFLAGS"
480     #
481     tmp_options=""
482     tmp_CFLAGS="$CFLAGS"
483     tmp_CPPFLAGS="$CPPFLAGS"
484     honor_optimize_option="yes"
485     #
486     dnl If optimization request setting has not been explicitly specified,
487     dnl it has been derived from the debug setting and initially assumed.
488     dnl This initially assumed optimizer setting will finally be ignored
489     dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
490     dnl that an initially assumed optimizer setting might not be honored.
491     #
492     if test "$want_optimize" = "assume_no" ||
493        test "$want_optimize" = "assume_yes"; then
494       AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
495       CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
496         honor_optimize_option="no"
497       ])
498       CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
499         honor_optimize_option="no"
500       ])
501       AC_MSG_RESULT([$honor_optimize_option])
502       if test "$honor_optimize_option" = "yes"; then
503         if test "$want_optimize" = "assume_yes"; then
504           want_optimize="yes"
505         fi
506         if test "$want_optimize" = "assume_no"; then
507           want_optimize="no"
508         fi
509       fi
510     fi
511     #
512     if test "$honor_optimize_option" = "yes"; then
513       CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
514       CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
515       if test "$want_optimize" = "yes"; then
516         AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
517         tmp_options="$flags_opt_yes"
518       fi
519       if test "$want_optimize" = "no"; then
520         AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
521         tmp_options="$flags_opt_off"
522       fi
523       CPPFLAGS=`eval echo $tmp_CPPFLAGS`
524       CFLAGS=`eval echo $tmp_CFLAGS $tmp_options`
525       CURL_COMPILER_WORKS_IFELSE([
526         AC_MSG_RESULT([yes])
527         AC_MSG_NOTICE([compiler options added: $tmp_options])
528       ],[
529         AC_MSG_RESULT([no])
530         AC_MSG_NOTICE([compiler options rejected: $tmp_options])
531         dnl restore initial settings
532         CPPFLAGS="$tmp_save_CPPFLAGS"
533         CFLAGS="$tmp_save_CFLAGS"
534       ])
535     fi
536     #
537   fi
538 ])
539
540
541 dnl CURL_SET_COMPILER_WARNING_OPTS
542 dnl -------------------------------------------------
543 dnl Sets compiler options/flags which depend on
544 dnl configure's warnings given option.
545
546 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
547   AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
548   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
549   #
550   if test "$compiler_id" = "DECC"; then
551     if test "$want_warnings" = "yes"; then
552       dnl Select a higher warning level than default level2
553       CFLAGS="$CFLAGS -msg_enable level3"
554     fi
555   fi
556   #
557   if test "$compiler_id" = "GNUC"; then
558     #
559     # FIXME: Some of these warnings should be changed into errors
560     #        and moved to CURL-SET-COMPILER-BASIC-OPTS
561     #
562     if test "$want_warnings" = "yes"; then
563       dnl this is a set of options we believe *ALL* gcc versions support:
564       WARN="-W -Wall -Wwrite-strings -pedantic -Wpointer-arith -Wnested-externs -Winline -Wmissing-prototypes"
565       dnl -Wcast-align is a bit too annoying on all gcc versions ;-)
566       if test "$compiler_num" -ge "207"; then
567         dnl gcc 2.7 or later
568         WARN="$WARN -Wmissing-declarations"
569       fi
570       if test "$compiler_num" -gt "295"; then
571         dnl only if the compiler is newer than 2.95 since we got lots of
572         dnl "`_POSIX_C_SOURCE' is not defined" in system headers with
573         dnl gcc 2.95.4 on FreeBSD 4.9!
574         WARN="$WARN -Wundef -Wno-long-long -Wsign-compare -Wshadow -Wno-multichar"
575       fi
576       if test "$compiler_num" -ge "296"; then
577         dnl gcc 2.96 or later
578         WARN="$WARN -Wfloat-equal"
579       fi
580       if test "$compiler_num" -gt "296"; then
581         dnl this option does not exist in 2.96
582         WARN="$WARN -Wno-format-nonliteral"
583       fi
584       dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
585       dnl on i686-Linux as it gives us heaps with false positives.
586       dnl Also, on gcc 4.0.X it is totally unbearable and complains all
587       dnl over making it unusable for generic purposes. Let's not use it.
588       if test "$compiler_num" -ge "303"; then
589         dnl gcc 3.3 and later
590         WARN="$WARN -Wendif-labels -Wstrict-prototypes"
591       fi
592       if test "$compiler_num" -ge "304"; then
593         # try these on gcc 3.4
594         WARN="$WARN -Wdeclaration-after-statement"
595       fi
596       for flag in $CPPFLAGS; do
597         case "$flag" in
598           -I*)
599             dnl Include path, provide a -isystem option for the same dir
600             dnl to prevent warnings in those dirs. The -isystem was not very
601             dnl reliable on earlier gcc versions.
602             add=`echo $flag | sed 's/^-I/-isystem /g'`
603             WARN="$WARN $add"
604             ;;
605         esac
606       done
607       CFLAGS="$CFLAGS $WARN"
608       AC_MSG_NOTICE([Added this set of compiler options: $WARN])
609     fi
610   fi
611   #
612   if test "$compiler_id" = "HPUXC"; then
613     if test "$want_warnings" = "yes"; then
614       dnl Issue all warnings
615       CFLAGS="$CFLAGS +w1"
616     fi
617   fi
618   #
619   if test "$compiler_id" = "ICC_unix"; then
620     if test "$want_warnings" = "yes"; then
621       if test "$compiler_num" -gt "600"; then
622         dnl Show errors, warnings, and remarks
623         CPPFLAGS="$CPPFLAGS -Wall"
624         dnl Perform extra compile-time code checking
625         CPPFLAGS="$CPPFLAGS -Wcheck"
626       fi
627     fi
628   fi
629   #
630   if test "$compiler_id" = "SUNC"; then
631     if test "$want_warnings" = "yes"; then
632       dnl Perform stricter semantic and lint-like checks
633       CFLAGS="$CFLAGS -v"
634     fi
635   fi
636   #
637 ])
638
639
640 dnl CURL_PROCESS_DEBUG_BUILD_OPTS
641 dnl -------------------------------------------------
642 dnl Settings which depend on configure's debug given
643 dnl option, and further configure the build process.
644 dnl Don't use this macro for compiler dependant stuff.
645
646 AC_DEFUN([CURL_PROCESS_DEBUG_BUILD_OPTS], [
647   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
648   AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
649   #
650   if test "$want_debug" = "yes"; then
651     CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
652   fi
653   #
654 ])
655
656
657 dnl CURL_CHECK_PROG_CC
658 dnl -------------------------------------------------
659 dnl Check for compiler program, preventing CFLAGS and
660 dnl CPPFLAGS from being unexpectedly changed.
661
662 AC_DEFUN([CURL_CHECK_PROG_CC], [
663   ac_save_CFLAGS="$CFLAGS"
664   ac_save_CPPFLAGS="$CPPFLAGS"
665   AC_PROG_CC
666   CFLAGS="$ac_save_CFLAGS"
667   CPPFLAGS="$ac_save_CPPFLAGS"
668 ])
669
670
671 dnl CURL_VAR_MATCH (VARNAME, VALUE)
672 dnl -------------------------------------------------
673 dnl Verifies if shell variable VARNAME contains VALUE.
674 dnl Contents of variable VARNAME and VALUE are handled
675 dnl as whitespace separated lists of words. If at least
676 dnl one word of VALUE is present in VARNAME the match
677 dnl is considered positive, otherwise false.
678
679 AC_DEFUN([CURL_VAR_MATCH], [
680   ac_var_match_word="no"
681   for word1 in "$[$1]"; do
682     for word2 in "[$2]"; do
683       if test "$word1" = "$word2"; then
684         ac_var_match_word="yes"
685       fi
686     done
687   done
688 ])
689
690
691 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
692 dnl                        [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
693 dnl -------------------------------------------------
694 dnl This performs a CURL_VAR_MATCH check and executes
695 dnl first branch if the match is positive, otherwise
696 dnl the second branch is executed.
697
698 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
699   CURL_VAR_MATCH([$1],[$2])
700   if test "$ac_var_match_word" = "yes"; then
701   ifelse($3,,:,[$3])
702   ifelse($4,,,[else
703     $4])
704   fi
705 ])
706
707
708 dnl CURL_VAR_STRIP (VARNAME, VALUE)
709 dnl -------------------------------------------------
710 dnl Contents of variable VARNAME and VALUE are handled
711 dnl as whitespace separated lists of words. Each word
712 dnl from VALUE is removed from VARNAME when present.
713
714 AC_DEFUN([CURL_VAR_STRIP], [
715   ac_var_stripped=""
716   for word1 in "$[$1]"; do
717     ac_var_strip_word="no"
718     for word2 in "[$2]"; do
719       if test "$word1" = "$word2"; then
720         ac_var_strip_word="yes"
721       fi
722     done
723     if test "$ac_var_strip_word" = "no"; then
724       ac_var_stripped="$ac_var_stripped $word1"
725     fi
726   done
727   dnl squeeze whitespace out of result
728   [$1]=`eval echo $ac_var_stripped`
729 ])