curl-compilers.m4: serial number bump
[platform/upstream/curl.git] / m4 / curl-compilers.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2011, 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 #***************************************************************************
22
23 # File version for 'aclocal' use. Keep it a single number.
24 # serial 58
25
26
27 dnl CURL_CHECK_COMPILER
28 dnl -------------------------------------------------
29 dnl Verify if the C compiler being used is known.
30
31 AC_DEFUN([CURL_CHECK_COMPILER], [
32   #
33   compiler_id="unknown"
34   compiler_num="0"
35   #
36   flags_dbg_all="unknown"
37   flags_dbg_yes="unknown"
38   flags_dbg_off="unknown"
39   flags_opt_all="unknown"
40   flags_opt_yes="unknown"
41   flags_opt_off="unknown"
42   #
43   flags_prefer_cppflags="no"
44   #
45   CURL_CHECK_COMPILER_DEC_C
46   CURL_CHECK_COMPILER_HPUX_C
47   CURL_CHECK_COMPILER_IBM_C
48   CURL_CHECK_COMPILER_INTEL_C
49   CURL_CHECK_COMPILER_CLANG
50   CURL_CHECK_COMPILER_GNU_C
51   CURL_CHECK_COMPILER_LCC
52   CURL_CHECK_COMPILER_SGI_MIPSPRO_C
53   CURL_CHECK_COMPILER_SGI_MIPS_C
54   CURL_CHECK_COMPILER_SUNPRO_C
55   CURL_CHECK_COMPILER_TINY_C
56   CURL_CHECK_COMPILER_WATCOM_C
57   #
58   if test "$compiler_id" = "unknown"; then
59   cat <<_EOF 1>&2
60 ***
61 *** Warning: This configure script does not have information about the
62 *** compiler you are using, relative to the flags required to enable or
63 *** disable generation of debug info, optimization options or warnings.
64 ***
65 *** Whatever settings are present in CFLAGS will be used for this run.
66 ***
67 *** If you wish to help the cURL project to better support your compiler
68 *** you can report this and the required info on the libcurl development
69 *** mailing list: http://cool.haxx.se/mailman/listinfo/curl-library/
70 ***
71 _EOF
72   fi
73 ])
74
75
76 dnl CURL_CHECK_COMPILER_CLANG
77 dnl -------------------------------------------------
78 dnl Verify if compiler being used is clang.
79
80 AC_DEFUN([CURL_CHECK_COMPILER_CLANG], [
81   AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
82   AC_MSG_CHECKING([if compiler is clang])
83   CURL_CHECK_DEF([__clang__], [], [silent])
84   if test "$curl_cv_have_def___clang__" = "yes"; then
85     AC_MSG_RESULT([yes])
86     compiler_id="CLANG"
87     clangver=`$CC -dumpversion`
88     clangvhi=`echo $clangver | cut -d . -f1`
89     clangvlo=`echo $clangver | cut -d . -f2`
90     compiler_num=`(expr $clangvhi "*" 100 + $clangvlo) 2>/dev/null`
91     flags_dbg_all="-g -g0 -g1 -g2 -g3"
92     flags_dbg_all="$flags_dbg_all -ggdb"
93     flags_dbg_all="$flags_dbg_all -gstabs"
94     flags_dbg_all="$flags_dbg_all -gstabs+"
95     flags_dbg_all="$flags_dbg_all -gcoff"
96     flags_dbg_all="$flags_dbg_all -gxcoff"
97     flags_dbg_all="$flags_dbg_all -gdwarf-2"
98     flags_dbg_all="$flags_dbg_all -gvms"
99     flags_dbg_yes="-g"
100     flags_dbg_off="-g0"
101     flags_opt_all="-O -O0 -O1 -O2 -Os -O3 -O4"
102     flags_opt_yes="-Os"
103     flags_opt_off="-O0"
104   else
105     AC_MSG_RESULT([no])
106   fi
107 ])
108
109
110 dnl CURL_CHECK_COMPILER_DEC_C
111 dnl -------------------------------------------------
112 dnl Verify if compiler being used is DEC C.
113
114 AC_DEFUN([CURL_CHECK_COMPILER_DEC_C], [
115   AC_MSG_CHECKING([if compiler is DEC/Compaq/HP C])
116   CURL_CHECK_DEF([__DECC], [], [silent])
117   CURL_CHECK_DEF([__DECC_VER], [], [silent])
118   if test "$curl_cv_have_def___DECC" = "yes" &&
119     test "$curl_cv_have_def___DECC_VER" = "yes"; then
120     AC_MSG_RESULT([yes])
121     compiler_id="DEC_C"
122     flags_dbg_all="-g -g0 -g1 -g2 -g3"
123     flags_dbg_yes="-g2"
124     flags_dbg_off="-g0"
125     flags_opt_all="-O -O0 -O1 -O2 -O3 -O4"
126     flags_opt_yes="-O1"
127     flags_opt_off="-O0"
128   else
129     AC_MSG_RESULT([no])
130   fi
131 ])
132
133
134 dnl CURL_CHECK_COMPILER_GNU_C
135 dnl -------------------------------------------------
136 dnl Verify if compiler being used is GNU C.
137
138 AC_DEFUN([CURL_CHECK_COMPILER_GNU_C], [
139   AC_REQUIRE([CURL_CHECK_COMPILER_INTEL_C])dnl
140   AC_REQUIRE([CURL_CHECK_COMPILER_CLANG])dnl
141   AC_MSG_CHECKING([if compiler is GNU C])
142   CURL_CHECK_DEF([__GNUC__], [], [silent])
143   if test "$curl_cv_have_def___GNUC__" = "yes" &&
144     test "$compiler_id" = "unknown"; then
145     AC_MSG_RESULT([yes])
146     compiler_id="GNU_C"
147     gccver=`$CC -dumpversion`
148     gccvhi=`echo $gccver | cut -d . -f1`
149     gccvlo=`echo $gccver | cut -d . -f2`
150     compiler_num=`(expr $gccvhi "*" 100 + $gccvlo) 2>/dev/null`
151     flags_dbg_all="-g -g0 -g1 -g2 -g3"
152     flags_dbg_all="$flags_dbg_all -ggdb"
153     flags_dbg_all="$flags_dbg_all -gstabs"
154     flags_dbg_all="$flags_dbg_all -gstabs+"
155     flags_dbg_all="$flags_dbg_all -gcoff"
156     flags_dbg_all="$flags_dbg_all -gxcoff"
157     flags_dbg_all="$flags_dbg_all -gdwarf-2"
158     flags_dbg_all="$flags_dbg_all -gvms"
159     flags_dbg_yes="-g"
160     flags_dbg_off="-g0"
161     flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
162     flags_opt_yes="-O2"
163     flags_opt_off="-O0"
164   else
165     AC_MSG_RESULT([no])
166   fi
167 ])
168
169
170 dnl CURL_CHECK_COMPILER_HPUX_C
171 dnl -------------------------------------------------
172 dnl Verify if compiler being used is HP-UX C.
173
174 AC_DEFUN([CURL_CHECK_COMPILER_HPUX_C], [
175   AC_MSG_CHECKING([if compiler is HP-UX C])
176   CURL_CHECK_DEF([__HP_cc], [], [silent])
177   if test "$curl_cv_have_def___HP_cc" = "yes"; then
178     AC_MSG_RESULT([yes])
179     compiler_id="HP_UX_C"
180     flags_dbg_all="-g -s"
181     flags_dbg_yes="-g"
182     flags_dbg_off="-s"
183     flags_opt_all="-O +O0 +O1 +O2 +O3 +O4"
184     flags_opt_yes="+O2"
185     flags_opt_off="+O0"
186   else
187     AC_MSG_RESULT([no])
188   fi
189 ])
190
191
192 dnl CURL_CHECK_COMPILER_IBM_C
193 dnl -------------------------------------------------
194 dnl Verify if compiler being used is IBM C.
195
196 AC_DEFUN([CURL_CHECK_COMPILER_IBM_C], [
197   AC_MSG_CHECKING([if compiler is IBM C])
198   CURL_CHECK_DEF([__IBMC__], [], [silent])
199   if test "$curl_cv_have_def___IBMC__" = "yes"; then
200     AC_MSG_RESULT([yes])
201     compiler_id="IBM_C"
202     flags_dbg_all="-g -g0 -g1 -g2 -g3"
203     flags_dbg_yes="-g"
204     flags_dbg_off=""
205     flags_opt_all="-O -O0 -O1 -O2 -O3 -O4 -O5"
206     flags_opt_all="$flags_opt_all -qnooptimize"
207     flags_opt_all="$flags_opt_all -qoptimize=0"
208     flags_opt_all="$flags_opt_all -qoptimize=1"
209     flags_opt_all="$flags_opt_all -qoptimize=2"
210     flags_opt_all="$flags_opt_all -qoptimize=3"
211     flags_opt_all="$flags_opt_all -qoptimize=4"
212     flags_opt_all="$flags_opt_all -qoptimize=5"
213     flags_opt_yes="-O2"
214     flags_opt_off="-qnooptimize"
215     flags_prefer_cppflags="yes"
216   else
217     AC_MSG_RESULT([no])
218   fi
219 ])
220
221
222 dnl CURL_CHECK_COMPILER_INTEL_C
223 dnl -------------------------------------------------
224 dnl Verify if compiler being used is Intel C.
225
226 AC_DEFUN([CURL_CHECK_COMPILER_INTEL_C], [
227   AC_BEFORE([$0],[CURL_CHECK_COMPILER_GNU_C])dnl
228   AC_MSG_CHECKING([if compiler is Intel C])
229   CURL_CHECK_DEF([__INTEL_COMPILER], [], [silent])
230   if test "$curl_cv_have_def___INTEL_COMPILER" = "yes"; then
231     AC_MSG_RESULT([yes])
232     compiler_num="$curl_cv_def___INTEL_COMPILER"
233     CURL_CHECK_DEF([__unix__], [], [silent])
234     if test "$curl_cv_have_def___unix__" = "yes"; then
235       compiler_id="INTEL_UNIX_C"
236       flags_dbg_all="-g -g0"
237       flags_dbg_yes="-g"
238       flags_dbg_off="-g0"
239       flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
240       flags_opt_yes="-O2"
241       flags_opt_off="-O0"
242     else
243       compiler_id="INTEL_WINDOWS_C"
244       flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
245       flags_dbg_all="$flags_dbg_all /debug"
246       flags_dbg_all="$flags_dbg_all /debug:none"
247       flags_dbg_all="$flags_dbg_all /debug:minimal"
248       flags_dbg_all="$flags_dbg_all /debug:partial"
249       flags_dbg_all="$flags_dbg_all /debug:full"
250       flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
251       flags_dbg_all="$flags_dbg_all /debug:extended"
252       flags_dbg_yes="/Zi /Oy-"
253       flags_dbg_off="/debug:none /Oy-"
254       flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
255       flags_opt_yes="/O2"
256       flags_opt_off="/Od"
257     fi
258   else
259     AC_MSG_RESULT([no])
260   fi
261 ])
262
263
264 dnl CURL_CHECK_COMPILER_LCC
265 dnl -------------------------------------------------
266 dnl Verify if compiler being used is LCC.
267
268 AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
269   AC_MSG_CHECKING([if compiler is LCC])
270   CURL_CHECK_DEF([__LCC__], [], [silent])
271   if test "$curl_cv_have_def___LCC__" = "yes"; then
272     AC_MSG_RESULT([yes])
273     compiler_id="LCC"
274     flags_dbg_all="-g"
275     flags_dbg_yes="-g"
276     flags_dbg_off=""
277     flags_opt_all=""
278     flags_opt_yes=""
279     flags_opt_off=""
280   else
281     AC_MSG_RESULT([no])
282   fi
283 ])
284
285
286 dnl CURL_CHECK_COMPILER_SGI_MIPS_C
287 dnl -------------------------------------------------
288 dnl Verify if compiler being used is SGI MIPS C.
289
290 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
291   AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
292   AC_MSG_CHECKING([if compiler is SGI MIPS C])
293   CURL_CHECK_DEF([__GNUC__], [], [silent])
294   CURL_CHECK_DEF([__sgi], [], [silent])
295   if test "$curl_cv_have_def___GNUC__" = "no" &&
296     test "$curl_cv_have_def___sgi" = "yes" &&
297     test "$compiler_id" = "unknown"; then
298     AC_MSG_RESULT([yes])
299     compiler_id="SGI_MIPS_C"
300     flags_dbg_all="-g -g0 -g1 -g2 -g3"
301     flags_dbg_yes="-g"
302     flags_dbg_off="-g0"
303     flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
304     flags_opt_yes="-O2"
305     flags_opt_off="-O0"
306   else
307     AC_MSG_RESULT([no])
308   fi
309 ])
310
311
312 dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
313 dnl -------------------------------------------------
314 dnl Verify if compiler being used is SGI MIPSpro C.
315
316 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
317   AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
318   AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
319   CURL_CHECK_DEF([__GNUC__], [], [silent])
320   CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
321   CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
322   if test "$curl_cv_have_def___GNUC__" = "no" &&
323     (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
324      test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
325     AC_MSG_RESULT([yes])
326     compiler_id="SGI_MIPSPRO_C"
327     flags_dbg_all="-g -g0 -g1 -g2 -g3"
328     flags_dbg_yes="-g"
329     flags_dbg_off="-g0"
330     flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
331     flags_opt_yes="-O2"
332     flags_opt_off="-O0"
333   else
334     AC_MSG_RESULT([no])
335   fi
336 ])
337
338
339 dnl CURL_CHECK_COMPILER_SUNPRO_C
340 dnl -------------------------------------------------
341 dnl Verify if compiler being used is SunPro C.
342
343 AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
344   AC_MSG_CHECKING([if compiler is SunPro C])
345   CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
346   if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
347     AC_MSG_RESULT([yes])
348     compiler_id="SUNPRO_C"
349     flags_dbg_all="-g -s"
350     flags_dbg_yes="-g"
351     flags_dbg_off="-s"
352     flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
353     flags_opt_yes="-xO2"
354     flags_opt_off=""
355   else
356     AC_MSG_RESULT([no])
357   fi
358 ])
359
360
361 dnl CURL_CHECK_COMPILER_TINY_C
362 dnl -------------------------------------------------
363 dnl Verify if compiler being used is Tiny C.
364
365 AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
366   AC_MSG_CHECKING([if compiler is Tiny C])
367   CURL_CHECK_DEF([__TINYC__], [], [silent])
368   if test "$curl_cv_have_def___TINYC__" = "yes"; then
369     AC_MSG_RESULT([yes])
370     compiler_id="TINY_C"
371     flags_dbg_all="-g -b"
372     flags_dbg_yes="-g"
373     flags_dbg_off=""
374     flags_opt_all=""
375     flags_opt_yes=""
376     flags_opt_off=""
377   else
378     AC_MSG_RESULT([no])
379   fi
380 ])
381
382
383 dnl CURL_CHECK_COMPILER_WATCOM_C
384 dnl -------------------------------------------------
385 dnl Verify if compiler being used is Watcom C.
386
387 AC_DEFUN([CURL_CHECK_COMPILER_WATCOM_C], [
388   AC_MSG_CHECKING([if compiler is Watcom C])
389   CURL_CHECK_DEF([__WATCOMC__], [], [silent])
390   if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
391     AC_MSG_RESULT([yes])
392     CURL_CHECK_DEF([__UNIX__], [], [silent])
393     if test "$curl_cv_have_def___UNIX__" = "yes"; then
394       compiler_id="WATCOM_UNIX_C"
395       flags_dbg_all="-g1 -g1+ -g2 -g3"
396       flags_dbg_yes="-g2"
397       flags_dbg_off=""
398       flags_opt_all="-O0 -O1 -O2 -O3"
399       flags_opt_yes="-O2"
400       flags_opt_off="-O0"
401     else
402       compiler_id="WATCOM_WINDOWS_C"
403       flags_dbg_all=""
404       flags_dbg_yes=""
405       flags_dbg_off=""
406       flags_opt_all=""
407       flags_opt_yes=""
408       flags_opt_off=""
409     fi
410   else
411     AC_MSG_RESULT([no])
412   fi
413 ])
414
415
416 dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
417 dnl -------------------------------------------------
418 dnl Changes standard include paths present in CFLAGS
419 dnl and CPPFLAGS into isystem include paths. This is
420 dnl done to prevent GNUC from generating warnings on
421 dnl headers from these locations, although on ancient
422 dnl GNUC versions these warnings are not silenced.
423
424 AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
425   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
426   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
427   if test "$compiler_id" = "GNU_C" ||
428     test "$compiler_id" = "CLANG"; then
429     tmp_has_include="no"
430     tmp_chg_FLAGS="$CFLAGS"
431     for word1 in $tmp_chg_FLAGS; do
432       case "$word1" in
433         -I*)
434           tmp_has_include="yes"
435           ;;
436       esac
437     done
438     if test "$tmp_has_include" = "yes"; then
439       tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
440       tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
441       CFLAGS="$tmp_chg_FLAGS"
442       squeeze CFLAGS
443     fi
444     tmp_has_include="no"
445     tmp_chg_FLAGS="$CPPFLAGS"
446     for word1 in $tmp_chg_FLAGS; do
447       case "$word1" in
448         -I*)
449           tmp_has_include="yes"
450           ;;
451       esac
452     done
453     if test "$tmp_has_include" = "yes"; then
454       tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
455       tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
456       CPPFLAGS="$tmp_chg_FLAGS"
457       squeeze CPPFLAGS
458     fi
459   fi
460 ])
461
462
463 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
464 dnl -------------------------------------------------
465 dnl Verify if the C compiler seems to work with the
466 dnl settings that are 'active' at the time the test
467 dnl is performed.
468
469 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
470   dnl compilation capability verification
471   tmp_compiler_works="unknown"
472   AC_COMPILE_IFELSE([
473     AC_LANG_PROGRAM([[
474     ]],[[
475       int i = 1;
476       return i;
477     ]])
478   ],[
479     tmp_compiler_works="yes"
480   ],[
481     tmp_compiler_works="no"
482     echo " " >&6
483     sed 's/^/cc-fail: /' conftest.err >&6
484     echo " " >&6
485   ])
486   dnl linking capability verification
487   if test "$tmp_compiler_works" = "yes"; then
488     AC_LINK_IFELSE([
489       AC_LANG_PROGRAM([[
490       ]],[[
491         int i = 1;
492         return i;
493       ]])
494     ],[
495       tmp_compiler_works="yes"
496     ],[
497       tmp_compiler_works="no"
498       echo " " >&6
499       sed 's/^/link-fail: /' conftest.err >&6
500       echo " " >&6
501     ])
502   fi
503   dnl only do runtime verification when not cross-compiling
504   if test "x$cross_compiling" != "xyes" &&
505     test "$tmp_compiler_works" = "yes"; then
506     AC_RUN_IFELSE([
507       AC_LANG_PROGRAM([[
508 #       ifdef __STDC__
509 #         include <stdlib.h>
510 #       endif
511       ]],[[
512         int i = 0;
513         exit(i);
514       ]])
515     ],[
516       tmp_compiler_works="yes"
517     ],[
518       tmp_compiler_works="no"
519       echo " " >&6
520       echo "run-fail: test program exited with status $ac_status" >&6
521       echo " " >&6
522     ])
523   fi
524   dnl branch upon test result
525   if test "$tmp_compiler_works" = "yes"; then
526   ifelse($1,,:,[$1])
527   ifelse($2,,,[else
528     $2])
529   fi
530 ])
531
532
533 dnl CURL_SET_COMPILER_BASIC_OPTS
534 dnl -------------------------------------------------
535 dnl Sets compiler specific options/flags which do not
536 dnl depend on configure's debug, optimize or warnings
537 dnl options.
538
539 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
540   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
541   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
542   #
543   if test "$compiler_id" != "unknown"; then
544     #
545     if test "$compiler_id" = "GNU_C" ||
546       test "$compiler_id" = "CLANG"; then
547       CURL_CONVERT_INCLUDE_TO_ISYSTEM
548     fi
549     #
550     tmp_save_CPPFLAGS="$CPPFLAGS"
551     tmp_save_CFLAGS="$CFLAGS"
552     tmp_CPPFLAGS=""
553     tmp_CFLAGS=""
554     #
555     case "$compiler_id" in
556         #
557       CLANG)
558         #
559         dnl Disable warnings for unused arguments, otherwise clang will
560         dnl warn about compile-time arguments used during link-time, like
561         dnl -O and -g and -pedantic.
562         tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
563         ;;
564         #
565       DEC_C)
566         #
567         dnl Select strict ANSI C compiler mode
568         tmp_CFLAGS="$tmp_CFLAGS -std1"
569         dnl Turn off optimizer ANSI C aliasing rules
570         tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
571         dnl Generate warnings for missing function prototypes
572         tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
573         dnl Change some warnings into fatal errors
574         tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
575         ;;
576         #
577       GNU_C)
578         #
579         dnl Placeholder
580         tmp_CFLAGS="$tmp_CFLAGS"
581         ;;
582         #
583       HP_UX_C)
584         #
585         dnl Disallow run-time dereferencing of null pointers
586         tmp_CFLAGS="$tmp_CFLAGS -z"
587         dnl Disable some remarks
588         dnl #4227: padding struct with n bytes to align member
589         dnl #4255: padding size of struct with n bytes to alignment boundary
590         tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
591         ;;
592         #
593       IBM_C)
594         #
595         dnl Ensure that compiler optimizations are always thread-safe.
596         tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
597         dnl Disable type based strict aliasing optimizations, using worst
598         dnl case aliasing assumptions when compiling. Type based aliasing
599         dnl would restrict the lvalues that could be safely used to access
600         dnl a data object.
601         tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
602         dnl Force compiler to stop after the compilation phase, without
603         dnl generating an object code file when compilation has errors.
604         tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
605         ;;
606         #
607       INTEL_UNIX_C)
608         #
609         dnl On unix this compiler uses gcc's header files, so
610         dnl we select ANSI C89 dialect plus GNU extensions.
611         tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
612         dnl Change some warnings into errors
613         dnl #140: too many arguments in function call
614         dnl #147: declaration is incompatible with 'previous one'
615         dnl #165: too few arguments in function call
616         dnl #266: function declared implicitly
617         tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
618         dnl Disable some remarks
619         dnl #279: controlling expression is constant
620         dnl #981: operands are evaluated in unspecified order
621         dnl #1469: "cc" clobber ignored
622         tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
623         ;;
624         #
625       INTEL_WINDOWS_C)
626         #
627         dnl Placeholder
628         tmp_CFLAGS="$tmp_CFLAGS"
629         ;;
630         #
631       LCC)
632         #
633         dnl Disallow run-time dereferencing of null pointers
634         tmp_CFLAGS="$tmp_CFLAGS -n"
635         ;;
636         #
637       SGI_MIPS_C)
638         #
639         dnl Placeholder
640         tmp_CFLAGS="$tmp_CFLAGS"
641         ;;
642         #
643       SGI_MIPSPRO_C)
644         #
645         dnl Placeholder
646         tmp_CFLAGS="$tmp_CFLAGS"
647         ;;
648         #
649       SUNPRO_C)
650         #
651         dnl Placeholder
652         tmp_CFLAGS="$tmp_CFLAGS"
653         ;;
654         #
655       TINY_C)
656         #
657         dnl Placeholder
658         tmp_CFLAGS="$tmp_CFLAGS"
659         ;;
660         #
661       WATCOM_UNIX_C)
662         #
663         dnl Placeholder
664         tmp_CFLAGS="$tmp_CFLAGS"
665         ;;
666         #
667       WATCOM_WINDOWS_C)
668         #
669         dnl Placeholder
670         tmp_CFLAGS="$tmp_CFLAGS"
671         ;;
672         #
673     esac
674     #
675     squeeze tmp_CPPFLAGS
676     squeeze tmp_CFLAGS
677     #
678     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
679       AC_MSG_CHECKING([if compiler accepts some basic options])
680       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
681       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
682       squeeze CPPFLAGS
683       squeeze CFLAGS
684       CURL_COMPILER_WORKS_IFELSE([
685         AC_MSG_RESULT([yes])
686         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
687       ],[
688         AC_MSG_RESULT([no])
689         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
690         dnl restore initial settings
691         CPPFLAGS="$tmp_save_CPPFLAGS"
692         CFLAGS="$tmp_save_CFLAGS"
693       ])
694     fi
695     #
696   fi
697 ])
698
699
700 dnl CURL_SET_COMPILER_DEBUG_OPTS
701 dnl -------------------------------------------------
702 dnl Sets compiler specific options/flags which depend
703 dnl on configure's debug option.
704
705 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
706   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
707   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
708   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
709   #
710   if test "$compiler_id" != "unknown"; then
711     #
712     tmp_save_CFLAGS="$CFLAGS"
713     tmp_save_CPPFLAGS="$CPPFLAGS"
714     #
715     tmp_options=""
716     tmp_CFLAGS="$CFLAGS"
717     tmp_CPPFLAGS="$CPPFLAGS"
718     CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
719     CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
720     #
721     if test "$want_debug" = "yes"; then
722       AC_MSG_CHECKING([if compiler accepts debug enabling options])
723       tmp_options="$flags_dbg_yes"
724     fi
725     if test "$want_debug" = "no"; then
726       AC_MSG_CHECKING([if compiler accepts debug disabling options])
727       tmp_options="$flags_dbg_off"
728     fi
729     #
730     if test "$flags_prefer_cppflags" = "yes"; then
731       CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
732       CFLAGS="$tmp_CFLAGS"
733     else
734       CPPFLAGS="$tmp_CPPFLAGS"
735       CFLAGS="$tmp_CFLAGS $tmp_options"
736     fi
737     squeeze CPPFLAGS
738     squeeze CFLAGS
739     CURL_COMPILER_WORKS_IFELSE([
740       AC_MSG_RESULT([yes])
741       AC_MSG_NOTICE([compiler options added: $tmp_options])
742     ],[
743       AC_MSG_RESULT([no])
744       AC_MSG_WARN([compiler options rejected: $tmp_options])
745       dnl restore initial settings
746       CPPFLAGS="$tmp_save_CPPFLAGS"
747       CFLAGS="$tmp_save_CFLAGS"
748     ])
749     #
750   fi
751 ])
752
753
754 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
755 dnl -------------------------------------------------
756 dnl Sets compiler specific options/flags which depend
757 dnl on configure's optimize option.
758
759 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
760   AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
761   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
762   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
763   #
764   if test "$compiler_id" != "unknown"; then
765     #
766     tmp_save_CFLAGS="$CFLAGS"
767     tmp_save_CPPFLAGS="$CPPFLAGS"
768     #
769     tmp_options=""
770     tmp_CFLAGS="$CFLAGS"
771     tmp_CPPFLAGS="$CPPFLAGS"
772     honor_optimize_option="yes"
773     #
774     dnl If optimization request setting has not been explicitly specified,
775     dnl it has been derived from the debug setting and initially assumed.
776     dnl This initially assumed optimizer setting will finally be ignored
777     dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
778     dnl that an initially assumed optimizer setting might not be honored.
779     #
780     if test "$want_optimize" = "assume_no" ||
781        test "$want_optimize" = "assume_yes"; then
782       AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
783       CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
784         honor_optimize_option="no"
785       ])
786       CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
787         honor_optimize_option="no"
788       ])
789       AC_MSG_RESULT([$honor_optimize_option])
790       if test "$honor_optimize_option" = "yes"; then
791         if test "$want_optimize" = "assume_yes"; then
792           want_optimize="yes"
793         fi
794         if test "$want_optimize" = "assume_no"; then
795           want_optimize="no"
796         fi
797       fi
798     fi
799     #
800     if test "$honor_optimize_option" = "yes"; then
801       CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
802       CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
803       if test "$want_optimize" = "yes"; then
804         AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
805         tmp_options="$flags_opt_yes"
806       fi
807       if test "$want_optimize" = "no"; then
808         AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
809         tmp_options="$flags_opt_off"
810       fi
811       if test "$flags_prefer_cppflags" = "yes"; then
812         CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
813         CFLAGS="$tmp_CFLAGS"
814       else
815         CPPFLAGS="$tmp_CPPFLAGS"
816         CFLAGS="$tmp_CFLAGS $tmp_options"
817       fi
818       squeeze CPPFLAGS
819       squeeze CFLAGS
820       CURL_COMPILER_WORKS_IFELSE([
821         AC_MSG_RESULT([yes])
822         AC_MSG_NOTICE([compiler options added: $tmp_options])
823       ],[
824         AC_MSG_RESULT([no])
825         AC_MSG_WARN([compiler options rejected: $tmp_options])
826         dnl restore initial settings
827         CPPFLAGS="$tmp_save_CPPFLAGS"
828         CFLAGS="$tmp_save_CFLAGS"
829       ])
830     fi
831     #
832   fi
833 ])
834
835
836 dnl CURL_SET_COMPILER_WARNING_OPTS
837 dnl -------------------------------------------------
838 dnl Sets compiler options/flags which depend on
839 dnl configure's warnings given option.
840
841 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
842   AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
843   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
844   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
845   #
846   if test "$compiler_id" != "unknown"; then
847     #
848     tmp_save_CPPFLAGS="$CPPFLAGS"
849     tmp_save_CFLAGS="$CFLAGS"
850     tmp_CPPFLAGS=""
851     tmp_CFLAGS=""
852     #
853     case "$compiler_id" in
854         #
855       CLANG)
856         #
857         if test "$want_warnings" = "yes"; then
858           dnl All versions of clang support the same warnings as at least
859           dnl gcc 4.2.1 except -Wunused.
860           tmp_CFLAGS="$tmp_CFLAGS -pedantic"
861           tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
862           tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
863           tmp_CFLAGS="$tmp_CFLAGS -Wshadow"
864           tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
865           tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
866           tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
867           tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
868           tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
869           tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
870           tmp_CFLAGS="$tmp_CFLAGS -Wundef"
871           tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
872           tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
873           tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
874           tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
875           tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
876           tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32"
877           #
878           dnl Only clang 1.1 or later
879           if test "$compiler_num" -ge "101"; then
880             tmp_CFLAGS="$tmp_CFLAGS -Wunused"
881           fi
882         fi
883         ;;
884         #
885       DEC_C)
886         #
887         if test "$want_warnings" = "yes"; then
888           dnl Select a higher warning level than default level2
889           tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
890         fi
891         ;;
892         #
893       GNU_C)
894         #
895         if test "$want_warnings" = "yes"; then
896           #
897           dnl Do not enable -pedantic when cross-compiling with a gcc older
898           dnl than 3.0, to avoid warnings from third party system headers.
899           if test "x$cross_compiling" != "xyes" ||
900             test "$compiler_num" -ge "300"; then
901             tmp_CFLAGS="$tmp_CFLAGS -pedantic"
902           fi
903           #
904           dnl Set of options we believe *ALL* gcc versions support:
905           tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
906           #
907           dnl Only gcc 1.4 or later
908           if test "$compiler_num" -ge "104"; then
909             tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
910             dnl If not cross-compiling with a gcc older than 3.0
911             if test "x$cross_compiling" != "xyes" ||
912               test "$compiler_num" -ge "300"; then
913               tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
914             fi
915           fi
916           #
917           dnl Only gcc 2.7 or later
918           if test "$compiler_num" -ge "207"; then
919             tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
920             dnl If not cross-compiling with a gcc older than 3.0
921             if test "x$cross_compiling" != "xyes" ||
922               test "$compiler_num" -ge "300"; then
923               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
924               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
925             fi
926           fi
927           #
928           dnl Only gcc 2.95 or later
929           if test "$compiler_num" -ge "295"; then
930             tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
931           fi
932           #
933           dnl Only gcc 2.96 or later
934           if test "$compiler_num" -ge "296"; then
935             tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
936             tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
937             dnl -Wundef used only if gcc is 2.96 or later since we get
938             dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
939             dnl headers with gcc 2.95.4 on FreeBSD 4.9
940             tmp_CFLAGS="$tmp_CFLAGS -Wundef"
941           fi
942           #
943           dnl Only gcc 2.97 or later
944           if test "$compiler_num" -ge "297"; then
945             tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
946           fi
947           #
948           dnl Only gcc 3.0 or later
949           if test "$compiler_num" -ge "300"; then
950             dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
951             dnl on i686-Linux as it gives us heaps with false positives.
952             dnl Also, on gcc 4.0.X it is totally unbearable and complains all
953             dnl over making it unusable for generic purposes. Let's not use it.
954             tmp_CFLAGS="$tmp_CFLAGS"
955           fi
956           #
957           dnl Only gcc 3.3 or later
958           if test "$compiler_num" -ge "303"; then
959             tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
960           fi
961           #
962           dnl Only gcc 3.4 or later
963           if test "$compiler_num" -ge "304"; then
964             tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
965           fi
966           #
967           dnl Only gcc 4.2 or later
968           if test "$compiler_num" -ge "402"; then
969             tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
970           fi
971           #
972           dnl Only gcc 4.3 or later
973           if test "$compiler_num" -ge "403"; then
974             tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
975             tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
976             tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
977             tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
978           fi
979           #
980         fi
981         #
982         dnl Do not issue warnings for code in system include paths.
983         if test "$compiler_num" -ge "300"; then
984           tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
985         else
986           dnl When cross-compiling with a gcc older than 3.0, disable
987           dnl some warnings triggered on third party system headers.
988           if test "x$cross_compiling" = "xyes"; then
989             if test "$compiler_num" -ge "104"; then
990               dnl gcc 1.4 or later
991               tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
992             fi
993             if test "$compiler_num" -ge "207"; then
994               dnl gcc 2.7 or later
995               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
996               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
997             fi
998           fi
999         fi
1000         ;;
1001         #
1002       HP_UX_C)
1003         #
1004         if test "$want_warnings" = "yes"; then
1005           dnl Issue all warnings
1006           tmp_CFLAGS="$tmp_CFLAGS +w1"
1007         fi
1008         ;;
1009         #
1010       IBM_C)
1011         #
1012         dnl Placeholder
1013         tmp_CFLAGS="$tmp_CFLAGS"
1014         ;;
1015         #
1016       INTEL_UNIX_C)
1017         #
1018         if test "$want_warnings" = "yes"; then
1019           if test "$compiler_num" -gt "600"; then
1020             dnl Show errors, warnings, and remarks
1021             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1022             dnl Perform extra compile-time code checking
1023             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1024             dnl Warn on nested comments
1025             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1026             dnl Show warnings relative to deprecated features
1027             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1028             dnl Enable warnings for missing prototypes
1029             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1030             dnl Enable warnings for 64-bit portability issues
1031             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1032             dnl Enable warnings for questionable pointer arithmetic
1033             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1034             dnl Check for function return typw issues
1035             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1036             dnl Warn on variable declarations hiding a previous one
1037             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1038             dnl Warn when a variable is used before initialized
1039             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1040             dnl Warn if a declared function is not used
1041             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1042           fi
1043         fi
1044         dnl Disable using EBP register in optimizations
1045         tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1046         dnl Disable use of ANSI C aliasing rules in optimizations
1047         tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1048         dnl Value-safe optimizations on floating-point data
1049         tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1050         dnl Only icc 10.0 or later
1051         if test "$compiler_num" -ge "1000"; then
1052           dnl Disable vectorizer diagnostic information
1053           tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1054         fi
1055         ;;
1056         #
1057       INTEL_WINDOWS_C)
1058         #
1059         dnl Placeholder
1060         tmp_CFLAGS="$tmp_CFLAGS"
1061         ;;
1062         #
1063       LCC)
1064         #
1065         if test "$want_warnings" = "yes"; then
1066           dnl Highest warning level is double -A, next is single -A.
1067           dnl Due to the big number of warnings these trigger on third
1068           dnl party header files it is impractical for us to use any of
1069           dnl them here. If you want them simply define it in CPPFLAGS.
1070           tmp_CFLAGS="$tmp_CFLAGS"
1071         fi
1072         ;;
1073         #
1074       SGI_MIPS_C)
1075         #
1076         if test "$want_warnings" = "yes"; then
1077           dnl Perform stricter semantic and lint-like checks
1078           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1079         fi
1080         ;;
1081         #
1082       SGI_MIPSPRO_C)
1083         #
1084         if test "$want_warnings" = "yes"; then
1085           dnl Perform stricter semantic and lint-like checks
1086           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1087           dnl Disable some remarks
1088           dnl #1209: controlling expression is constant
1089           tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1090         fi
1091         ;;
1092         #
1093       SUNPRO_C)
1094         #
1095         if test "$want_warnings" = "yes"; then
1096           dnl Perform stricter semantic and lint-like checks
1097           tmp_CFLAGS="$tmp_CFLAGS -v"
1098         fi
1099         ;;
1100         #
1101       TINY_C)
1102         #
1103         if test "$want_warnings" = "yes"; then
1104           dnl Activate all warnings
1105           tmp_CFLAGS="$tmp_CFLAGS -Wall"
1106           dnl Make string constants be of type const char *
1107           tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1108           dnl Warn use of unsupported GCC features ignored by TCC
1109           tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1110         fi
1111         ;;
1112         #
1113       WATCOM_UNIX_C)
1114         #
1115         if test "$want_warnings" = "yes"; then
1116           dnl Issue all warnings
1117           tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1118         fi
1119         ;;
1120         #
1121       WATCOM_WINDOWS_C)
1122         #
1123         dnl Placeholder
1124         tmp_CFLAGS="$tmp_CFLAGS"
1125         ;;
1126         #
1127     esac
1128     #
1129     squeeze tmp_CPPFLAGS
1130     squeeze tmp_CFLAGS
1131     #
1132     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1133       AC_MSG_CHECKING([if compiler accepts strict warning options])
1134       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1135       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1136       squeeze CPPFLAGS
1137       squeeze CFLAGS
1138       CURL_COMPILER_WORKS_IFELSE([
1139         AC_MSG_RESULT([yes])
1140         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1141       ],[
1142         AC_MSG_RESULT([no])
1143         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1144         dnl restore initial settings
1145         CPPFLAGS="$tmp_save_CPPFLAGS"
1146         CFLAGS="$tmp_save_CFLAGS"
1147       ])
1148     fi
1149     #
1150   fi
1151 ])
1152
1153
1154 dnl CURL_SHFUNC_SQUEEZE
1155 dnl -------------------------------------------------
1156 dnl Declares a shell function squeeze() which removes
1157 dnl redundant whitespace out of a shell variable.
1158
1159 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1160 squeeze() {
1161   _sqz_result=""
1162   eval _sqz_input=\[$][$]1
1163   for _sqz_token in $_sqz_input; do
1164     if test -z "$_sqz_result"; then
1165       _sqz_result="$_sqz_token"
1166     else
1167       _sqz_result="$_sqz_result $_sqz_token"
1168     fi
1169   done
1170   eval [$]1=\$_sqz_result
1171   return 0
1172 }
1173 ])
1174
1175
1176 dnl CURL_CHECK_CURLDEBUG
1177 dnl -------------------------------------------------
1178 dnl Settings which depend on configure's curldebug given
1179 dnl option, and other additional configure pre-requisites.
1180 dnl Actually the curl debug memory tracking feature can
1181 dnl only be used/enabled when libcurl is built as a static
1182 dnl library or as a shared one on those systems on which
1183 dnl shared libraries support undefined symbols.
1184
1185 AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1186   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1187   supports_curldebug="unknown"
1188   if test "$want_curldebug" = "yes"; then
1189     if test "x$enable_shared" != "xno" &&
1190       test "x$enable_shared" != "xyes"; then
1191       AC_MSG_WARN([unknown enable_shared setting.])
1192       supports_curldebug="no"
1193     fi
1194     if test "x$enable_static" != "xno" &&
1195       test "x$enable_static" != "xyes"; then
1196       AC_MSG_WARN([unknown enable_static setting.])
1197       supports_curldebug="no"
1198     fi
1199     if test "$supports_curldebug" != "no"; then
1200       if test "$enable_shared" = "yes" &&
1201         test "$need_no_undefined" = "yes"; then
1202         supports_curldebug="no"
1203         AC_MSG_WARN([shared library does not support undefined symbols.])
1204       fi
1205     fi
1206   fi
1207   #
1208   if test "$want_curldebug" = "yes"; then
1209     AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1210     test "$supports_curldebug" = "no" || supports_curldebug="yes"
1211     AC_MSG_RESULT([$supports_curldebug])
1212     if test "$supports_curldebug" = "no"; then
1213       AC_MSG_WARN([cannot enable curl debug memory tracking.])
1214       want_curldebug="no"
1215     fi
1216   fi
1217   #
1218   if test "$want_curldebug" = "yes"; then
1219     CPPFLAGS="-DCURLDEBUG $CPPFLAGS"
1220     squeeze CPPFLAGS
1221   fi
1222   if test "$want_debug" = "yes"; then
1223     CPPFLAGS="-DDEBUGBUILD $CPPFLAGS"
1224     squeeze CPPFLAGS
1225   fi
1226 ])
1227
1228
1229 dnl CURL_CHECK_NO_UNDEFINED
1230 dnl -------------------------------------------------
1231 dnl Checks if the -no-undefined flag must be used when
1232 dnl building shared libraries. This is required on all
1233 dnl systems on which shared libraries should not have
1234 dnl references to undefined symbols. This check should
1235 dnl not be done before AC-PROG-LIBTOOL.
1236
1237 AC_DEFUN([CURL_CHECK_NO_UNDEFINED], [
1238   AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl
1239   AC_MSG_CHECKING([if shared libraries need -no-undefined])
1240   need_no_undefined="no"
1241   case $host in
1242     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1243       need_no_undefined="yes"
1244       ;;
1245   esac
1246   if test "x$allow_undefined" = "xno"; then
1247     need_no_undefined="yes"
1248   elif test "x$allow_undefined_flag" = "xunsupported"; then
1249     need_no_undefined="yes"
1250   fi
1251   AC_MSG_RESULT($need_no_undefined)
1252 ])
1253
1254
1255 dnl CURL_CHECK_PROG_CC
1256 dnl -------------------------------------------------
1257 dnl Check for compiler program, preventing CFLAGS and
1258 dnl CPPFLAGS from being unexpectedly changed.
1259
1260 AC_DEFUN([CURL_CHECK_PROG_CC], [
1261   ac_save_CFLAGS="$CFLAGS"
1262   ac_save_CPPFLAGS="$CPPFLAGS"
1263   AC_PROG_CC
1264   CFLAGS="$ac_save_CFLAGS"
1265   CPPFLAGS="$ac_save_CPPFLAGS"
1266 ])
1267
1268
1269 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1270 dnl -------------------------------------------------
1271 dnl Verifies if the compiler actually halts after the
1272 dnl compilation phase without generating any object
1273 dnl code file, when the source compiles with errors.
1274
1275 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1276   AC_MSG_CHECKING([if compiler halts on compilation errors])
1277   AC_COMPILE_IFELSE([
1278     AC_LANG_PROGRAM([[
1279     ]],[[
1280       force compilation error
1281     ]])
1282   ],[
1283     AC_MSG_RESULT([no])
1284     AC_MSG_ERROR([compiler does not halt on compilation errors.])
1285   ],[
1286     AC_MSG_RESULT([yes])
1287   ])
1288 ])
1289
1290
1291 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1292 dnl -------------------------------------------------
1293 dnl Verifies if the compiler actually halts after the
1294 dnl compilation phase without generating any object
1295 dnl code file, when the source code tries to define a
1296 dnl type for a constant array with negative dimension.
1297
1298 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1299   AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1300   AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1301   AC_COMPILE_IFELSE([
1302     AC_LANG_PROGRAM([[
1303       typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1304     ]],[[
1305       bad_t dummy;
1306     ]])
1307   ],[
1308     AC_MSG_RESULT([no])
1309     AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1310   ],[
1311     AC_MSG_RESULT([yes])
1312   ])
1313 ])
1314
1315
1316 dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1317 dnl -------------------------------------------------
1318 dnl Verifies if the compiler is capable of handling the
1319 dnl size of a struct member, struct which is a function
1320 dnl result, as a compilation-time condition inside the
1321 dnl type definition of a constant array.
1322
1323 AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1324   AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1325   AC_MSG_CHECKING([if compiler struct member size checking works])
1326   tst_compiler_check_one_works="unknown"
1327   AC_COMPILE_IFELSE([
1328     AC_LANG_PROGRAM([[
1329       struct mystruct {
1330         int  mi;
1331         char mc;
1332         struct mystruct *next;
1333       };
1334       struct mystruct myfunc();
1335       typedef char good_t1[sizeof(myfunc().mi) == sizeof(int)  ? 1 : -1 ];
1336       typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1337     ]],[[
1338       good_t1 dummy1;
1339       good_t2 dummy2;
1340     ]])
1341   ],[
1342     tst_compiler_check_one_works="yes"
1343   ],[
1344     tst_compiler_check_one_works="no"
1345     sed 's/^/cc-src: /' conftest.$ac_ext >&6
1346     sed 's/^/cc-err: /' conftest.err >&6
1347   ])
1348   tst_compiler_check_two_works="unknown"
1349   AC_COMPILE_IFELSE([
1350     AC_LANG_PROGRAM([[
1351       struct mystruct {
1352         int  mi;
1353         char mc;
1354         struct mystruct *next;
1355       };
1356       struct mystruct myfunc();
1357       typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int)  ? 1 : -1 ];
1358       typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1359     ]],[[
1360       bad_t1 dummy1;
1361       bad_t2 dummy2;
1362     ]])
1363   ],[
1364     tst_compiler_check_two_works="no"
1365   ],[
1366     tst_compiler_check_two_works="yes"
1367   ])
1368   if test "$tst_compiler_check_one_works" = "yes" &&
1369     test "$tst_compiler_check_two_works" = "yes"; then
1370     AC_MSG_RESULT([yes])
1371   else
1372     AC_MSG_RESULT([no])
1373     AC_MSG_ERROR([compiler fails struct member size checking.])
1374   fi
1375 ])
1376
1377
1378 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1379 dnl -------------------------------------------------
1380 dnl Verifies if shell variable VARNAME contains VALUE.
1381 dnl Contents of variable VARNAME and VALUE are handled
1382 dnl as whitespace separated lists of words. If at least
1383 dnl one word of VALUE is present in VARNAME the match
1384 dnl is considered positive, otherwise false.
1385
1386 AC_DEFUN([CURL_VAR_MATCH], [
1387   ac_var_match_word="no"
1388   for word1 in $[$1]; do
1389     for word2 in [$2]; do
1390       if test "$word1" = "$word2"; then
1391         ac_var_match_word="yes"
1392       fi
1393     done
1394   done
1395 ])
1396
1397
1398 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1399 dnl                        [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1400 dnl -------------------------------------------------
1401 dnl This performs a CURL_VAR_MATCH check and executes
1402 dnl first branch if the match is positive, otherwise
1403 dnl the second branch is executed.
1404
1405 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1406   CURL_VAR_MATCH([$1],[$2])
1407   if test "$ac_var_match_word" = "yes"; then
1408   ifelse($3,,:,[$3])
1409   ifelse($4,,,[else
1410     $4])
1411   fi
1412 ])
1413
1414
1415 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1416 dnl -------------------------------------------------
1417 dnl Contents of variable VARNAME and VALUE are handled
1418 dnl as whitespace separated lists of words. Each word
1419 dnl from VALUE is removed from VARNAME when present.
1420
1421 AC_DEFUN([CURL_VAR_STRIP], [
1422   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1423   ac_var_stripped=""
1424   for word1 in $[$1]; do
1425     ac_var_strip_word="no"
1426     for word2 in [$2]; do
1427       if test "$word1" = "$word2"; then
1428         ac_var_strip_word="yes"
1429       fi
1430     done
1431     if test "$ac_var_strip_word" = "no"; then
1432       ac_var_stripped="$ac_var_stripped $word1"
1433     fi
1434   done
1435   dnl squeeze whitespace out of result
1436   [$1]="$ac_var_stripped"
1437   squeeze [$1]
1438 ])
1439