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