configure: get API info for a couple of OpenSSL functions (followup 1)
[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 57
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   tmp_has_include="no"
427   tmp_chg_FLAGS="$CFLAGS"
428   for word1 in $tmp_chg_FLAGS; do
429     case "$word1" in
430       -I*)
431         tmp_has_include="yes"
432         ;;
433     esac
434   done
435   if test "$tmp_has_include" = "yes"; then
436     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
437     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
438     CFLAGS="$tmp_chg_FLAGS"
439     squeeze CFLAGS
440   fi
441   tmp_has_include="no"
442   tmp_chg_FLAGS="$CPPFLAGS"
443   for word1 in $tmp_chg_FLAGS; do
444     case "$word1" in
445       -I*)
446         tmp_has_include="yes"
447         ;;
448     esac
449   done
450   if test "$tmp_has_include" = "yes"; then
451     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
452     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
453     CPPFLAGS="$tmp_chg_FLAGS"
454     squeeze CPPFLAGS
455   fi
456 ])
457
458
459 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
460 dnl -------------------------------------------------
461 dnl Verify if the C compiler seems to work with the
462 dnl settings that are 'active' at the time the test
463 dnl is performed.
464
465 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
466   dnl compilation capability verification
467   tmp_compiler_works="unknown"
468   AC_COMPILE_IFELSE([
469     AC_LANG_PROGRAM([[
470     ]],[[
471       int i = 1;
472       return i;
473     ]])
474   ],[
475     tmp_compiler_works="yes"
476   ],[
477     tmp_compiler_works="no"
478     echo " " >&6
479     sed 's/^/cc-fail: /' conftest.err >&6
480     echo " " >&6
481   ])
482   dnl linking capability verification
483   if test "$tmp_compiler_works" = "yes"; then
484     AC_LINK_IFELSE([
485       AC_LANG_PROGRAM([[
486       ]],[[
487         int i = 1;
488         return i;
489       ]])
490     ],[
491       tmp_compiler_works="yes"
492     ],[
493       tmp_compiler_works="no"
494       echo " " >&6
495       sed 's/^/link-fail: /' conftest.err >&6
496       echo " " >&6
497     ])
498   fi
499   dnl only do runtime verification when not cross-compiling
500   if test "x$cross_compiling" != "xyes" &&
501     test "$tmp_compiler_works" = "yes"; then
502     AC_RUN_IFELSE([
503       AC_LANG_PROGRAM([[
504 #       ifdef __STDC__
505 #         include <stdlib.h>
506 #       endif
507       ]],[[
508         int i = 0;
509         exit(i);
510       ]])
511     ],[
512       tmp_compiler_works="yes"
513     ],[
514       tmp_compiler_works="no"
515       echo " " >&6
516       echo "run-fail: test program exited with status $ac_status" >&6
517       echo " " >&6
518     ])
519   fi
520   dnl branch upon test result
521   if test "$tmp_compiler_works" = "yes"; then
522   ifelse($1,,:,[$1])
523   ifelse($2,,,[else
524     $2])
525   fi
526 ])
527
528
529 dnl CURL_SET_COMPILER_BASIC_OPTS
530 dnl -------------------------------------------------
531 dnl Sets compiler specific options/flags which do not
532 dnl depend on configure's debug, optimize or warnings
533 dnl options.
534
535 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
536   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
537   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
538   #
539   if test "$compiler_id" != "unknown"; then
540     #
541     if test "$compiler_id" = "GNU_C" ||
542       test "$compiler_id" = "CLANG"; then
543       CURL_CONVERT_INCLUDE_TO_ISYSTEM
544     fi
545     #
546     tmp_save_CPPFLAGS="$CPPFLAGS"
547     tmp_save_CFLAGS="$CFLAGS"
548     tmp_CPPFLAGS=""
549     tmp_CFLAGS=""
550     #
551     case "$compiler_id" in
552         #
553       CLANG)
554         #
555         dnl Disable warnings for unused arguments, otherwise clang will
556         dnl warn about compile-time arguments used during link-time, like
557         dnl -O and -g and -pedantic.
558         tmp_CFLAGS="$tmp_CFLAGS -Qunused-arguments"
559         ;;
560         #
561       DEC_C)
562         #
563         dnl Select strict ANSI C compiler mode
564         tmp_CFLAGS="$tmp_CFLAGS -std1"
565         dnl Turn off optimizer ANSI C aliasing rules
566         tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
567         dnl Generate warnings for missing function prototypes
568         tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
569         dnl Change some warnings into fatal errors
570         tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
571         ;;
572         #
573       GNU_C)
574         #
575         dnl Placeholder
576         tmp_CFLAGS="$tmp_CFLAGS"
577         ;;
578         #
579       HP_UX_C)
580         #
581         dnl Disallow run-time dereferencing of null pointers
582         tmp_CFLAGS="$tmp_CFLAGS -z"
583         dnl Disable some remarks
584         dnl #4227: padding struct with n bytes to align member
585         dnl #4255: padding size of struct with n bytes to alignment boundary
586         tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
587         ;;
588         #
589       IBM_C)
590         #
591         dnl Ensure that compiler optimizations are always thread-safe.
592         tmp_CPPFLAGS="$tmp_CPPFLAGS -qthreaded"
593         dnl Disable type based strict aliasing optimizations, using worst
594         dnl case aliasing assumptions when compiling. Type based aliasing
595         dnl would restrict the lvalues that could be safely used to access
596         dnl a data object.
597         tmp_CPPFLAGS="$tmp_CPPFLAGS -qnoansialias"
598         dnl Force compiler to stop after the compilation phase, without
599         dnl generating an object code file when compilation has errors.
600         tmp_CPPFLAGS="$tmp_CPPFLAGS -qhalt=e"
601         ;;
602         #
603       INTEL_UNIX_C)
604         #
605         dnl On unix this compiler uses gcc's header files, so
606         dnl we select ANSI C89 dialect plus GNU extensions.
607         tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
608         dnl Change some warnings into errors
609         dnl #140: too many arguments in function call
610         dnl #147: declaration is incompatible with 'previous one'
611         dnl #165: too few arguments in function call
612         dnl #266: function declared implicitly
613         tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
614         dnl Disable some remarks
615         dnl #279: controlling expression is constant
616         dnl #981: operands are evaluated in unspecified order
617         dnl #1469: "cc" clobber ignored
618         tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
619         ;;
620         #
621       INTEL_WINDOWS_C)
622         #
623         dnl Placeholder
624         tmp_CFLAGS="$tmp_CFLAGS"
625         ;;
626         #
627       LCC)
628         #
629         dnl Disallow run-time dereferencing of null pointers
630         tmp_CFLAGS="$tmp_CFLAGS -n"
631         ;;
632         #
633       SGI_MIPS_C)
634         #
635         dnl Placeholder
636         tmp_CFLAGS="$tmp_CFLAGS"
637         ;;
638         #
639       SGI_MIPSPRO_C)
640         #
641         dnl Placeholder
642         tmp_CFLAGS="$tmp_CFLAGS"
643         ;;
644         #
645       SUNPRO_C)
646         #
647         dnl Placeholder
648         tmp_CFLAGS="$tmp_CFLAGS"
649         ;;
650         #
651       TINY_C)
652         #
653         dnl Placeholder
654         tmp_CFLAGS="$tmp_CFLAGS"
655         ;;
656         #
657       WATCOM_UNIX_C)
658         #
659         dnl Placeholder
660         tmp_CFLAGS="$tmp_CFLAGS"
661         ;;
662         #
663       WATCOM_WINDOWS_C)
664         #
665         dnl Placeholder
666         tmp_CFLAGS="$tmp_CFLAGS"
667         ;;
668         #
669     esac
670     #
671     squeeze tmp_CPPFLAGS
672     squeeze tmp_CFLAGS
673     #
674     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
675       AC_MSG_CHECKING([if compiler accepts some basic options])
676       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
677       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
678       squeeze CPPFLAGS
679       squeeze CFLAGS
680       CURL_COMPILER_WORKS_IFELSE([
681         AC_MSG_RESULT([yes])
682         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
683       ],[
684         AC_MSG_RESULT([no])
685         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
686         dnl restore initial settings
687         CPPFLAGS="$tmp_save_CPPFLAGS"
688         CFLAGS="$tmp_save_CFLAGS"
689       ])
690     fi
691     #
692   fi
693 ])
694
695
696 dnl CURL_SET_COMPILER_DEBUG_OPTS
697 dnl -------------------------------------------------
698 dnl Sets compiler specific options/flags which depend
699 dnl on configure's debug option.
700
701 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
702   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
703   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
704   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
705   #
706   if test "$compiler_id" != "unknown"; then
707     #
708     tmp_save_CFLAGS="$CFLAGS"
709     tmp_save_CPPFLAGS="$CPPFLAGS"
710     #
711     tmp_options=""
712     tmp_CFLAGS="$CFLAGS"
713     tmp_CPPFLAGS="$CPPFLAGS"
714     CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
715     CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
716     #
717     if test "$want_debug" = "yes"; then
718       AC_MSG_CHECKING([if compiler accepts debug enabling options])
719       tmp_options="$flags_dbg_yes"
720     fi
721     if test "$want_debug" = "no"; then
722       AC_MSG_CHECKING([if compiler accepts debug disabling options])
723       tmp_options="$flags_dbg_off"
724     fi
725     #
726     if test "$flags_prefer_cppflags" = "yes"; then
727       CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
728       CFLAGS="$tmp_CFLAGS"
729     else
730       CPPFLAGS="$tmp_CPPFLAGS"
731       CFLAGS="$tmp_CFLAGS $tmp_options"
732     fi
733     squeeze CPPFLAGS
734     squeeze CFLAGS
735     CURL_COMPILER_WORKS_IFELSE([
736       AC_MSG_RESULT([yes])
737       AC_MSG_NOTICE([compiler options added: $tmp_options])
738     ],[
739       AC_MSG_RESULT([no])
740       AC_MSG_WARN([compiler options rejected: $tmp_options])
741       dnl restore initial settings
742       CPPFLAGS="$tmp_save_CPPFLAGS"
743       CFLAGS="$tmp_save_CFLAGS"
744     ])
745     #
746   fi
747 ])
748
749
750 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
751 dnl -------------------------------------------------
752 dnl Sets compiler specific options/flags which depend
753 dnl on configure's optimize option.
754
755 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
756   AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
757   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
758   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
759   #
760   if test "$compiler_id" != "unknown"; then
761     #
762     tmp_save_CFLAGS="$CFLAGS"
763     tmp_save_CPPFLAGS="$CPPFLAGS"
764     #
765     tmp_options=""
766     tmp_CFLAGS="$CFLAGS"
767     tmp_CPPFLAGS="$CPPFLAGS"
768     honor_optimize_option="yes"
769     #
770     dnl If optimization request setting has not been explicitly specified,
771     dnl it has been derived from the debug setting and initially assumed.
772     dnl This initially assumed optimizer setting will finally be ignored
773     dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
774     dnl that an initially assumed optimizer setting might not be honored.
775     #
776     if test "$want_optimize" = "assume_no" ||
777        test "$want_optimize" = "assume_yes"; then
778       AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
779       CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
780         honor_optimize_option="no"
781       ])
782       CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
783         honor_optimize_option="no"
784       ])
785       AC_MSG_RESULT([$honor_optimize_option])
786       if test "$honor_optimize_option" = "yes"; then
787         if test "$want_optimize" = "assume_yes"; then
788           want_optimize="yes"
789         fi
790         if test "$want_optimize" = "assume_no"; then
791           want_optimize="no"
792         fi
793       fi
794     fi
795     #
796     if test "$honor_optimize_option" = "yes"; then
797       CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
798       CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
799       if test "$want_optimize" = "yes"; then
800         AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
801         tmp_options="$flags_opt_yes"
802       fi
803       if test "$want_optimize" = "no"; then
804         AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
805         tmp_options="$flags_opt_off"
806       fi
807       if test "$flags_prefer_cppflags" = "yes"; then
808         CPPFLAGS="$tmp_CPPFLAGS $tmp_options"
809         CFLAGS="$tmp_CFLAGS"
810       else
811         CPPFLAGS="$tmp_CPPFLAGS"
812         CFLAGS="$tmp_CFLAGS $tmp_options"
813       fi
814       squeeze CPPFLAGS
815       squeeze CFLAGS
816       CURL_COMPILER_WORKS_IFELSE([
817         AC_MSG_RESULT([yes])
818         AC_MSG_NOTICE([compiler options added: $tmp_options])
819       ],[
820         AC_MSG_RESULT([no])
821         AC_MSG_WARN([compiler options rejected: $tmp_options])
822         dnl restore initial settings
823         CPPFLAGS="$tmp_save_CPPFLAGS"
824         CFLAGS="$tmp_save_CFLAGS"
825       ])
826     fi
827     #
828   fi
829 ])
830
831
832 dnl CURL_SET_COMPILER_WARNING_OPTS
833 dnl -------------------------------------------------
834 dnl Sets compiler options/flags which depend on
835 dnl configure's warnings given option.
836
837 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
838   AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
839   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
840   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
841   #
842   if test "$compiler_id" != "unknown"; then
843     #
844     tmp_save_CPPFLAGS="$CPPFLAGS"
845     tmp_save_CFLAGS="$CFLAGS"
846     tmp_CPPFLAGS=""
847     tmp_CFLAGS=""
848     #
849     case "$compiler_id" in
850         #
851       CLANG)
852         #
853         if test "$want_warnings" = "yes"; then
854           dnl All versions of clang support the same warnings as at least
855           dnl gcc 4.2.1 except -Wunused.
856           tmp_CFLAGS="$tmp_CFLAGS -pedantic"
857           tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
858           tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
859           tmp_CFLAGS="$tmp_CFLAGS -Wshadow"
860           tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
861           tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
862           tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
863           tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
864           tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
865           tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
866           tmp_CFLAGS="$tmp_CFLAGS -Wundef"
867           tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
868           tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
869           tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
870           tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
871           tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
872           tmp_CFLAGS="$tmp_CFLAGS -Wshorten-64-to-32"
873           #
874           dnl Only clang 1.1 or later
875           if test "$compiler_num" -ge "101"; then
876             tmp_CFLAGS="$tmp_CFLAGS -Wunused"
877           fi
878         fi
879         ;;
880         #
881       DEC_C)
882         #
883         if test "$want_warnings" = "yes"; then
884           dnl Select a higher warning level than default level2
885           tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
886         fi
887         ;;
888         #
889       GNU_C)
890         #
891         if test "$want_warnings" = "yes"; then
892           #
893           dnl Do not enable -pedantic when cross-compiling with a gcc older
894           dnl than 3.0, to avoid warnings from third party system headers.
895           if test "x$cross_compiling" != "xyes" ||
896             test "$compiler_num" -ge "300"; then
897             tmp_CFLAGS="$tmp_CFLAGS -pedantic"
898           fi
899           #
900           dnl Set of options we believe *ALL* gcc versions support:
901           tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
902           #
903           dnl Only gcc 1.4 or later
904           if test "$compiler_num" -ge "104"; then
905             tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
906             dnl If not cross-compiling with a gcc older than 3.0
907             if test "x$cross_compiling" != "xyes" ||
908               test "$compiler_num" -ge "300"; then
909               tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
910             fi
911           fi
912           #
913           dnl Only gcc 2.7 or later
914           if test "$compiler_num" -ge "207"; then
915             tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
916             dnl If not cross-compiling with a gcc older than 3.0
917             if test "x$cross_compiling" != "xyes" ||
918               test "$compiler_num" -ge "300"; then
919               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
920               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
921             fi
922           fi
923           #
924           dnl Only gcc 2.95 or later
925           if test "$compiler_num" -ge "295"; then
926             tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
927           fi
928           #
929           dnl Only gcc 2.96 or later
930           if test "$compiler_num" -ge "296"; then
931             tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
932             tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
933             dnl -Wundef used only if gcc is 2.96 or later since we get
934             dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
935             dnl headers with gcc 2.95.4 on FreeBSD 4.9
936             tmp_CFLAGS="$tmp_CFLAGS -Wundef"
937           fi
938           #
939           dnl Only gcc 2.97 or later
940           if test "$compiler_num" -ge "297"; then
941             tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
942           fi
943           #
944           dnl Only gcc 3.0 or later
945           if test "$compiler_num" -ge "300"; then
946             dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
947             dnl on i686-Linux as it gives us heaps with false positives.
948             dnl Also, on gcc 4.0.X it is totally unbearable and complains all
949             dnl over making it unusable for generic purposes. Let's not use it.
950             tmp_CFLAGS="$tmp_CFLAGS"
951           fi
952           #
953           dnl Only gcc 3.3 or later
954           if test "$compiler_num" -ge "303"; then
955             tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
956           fi
957           #
958           dnl Only gcc 3.4 or later
959           if test "$compiler_num" -ge "304"; then
960             tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
961           fi
962           #
963           dnl Only gcc 4.2 or later
964           if test "$compiler_num" -ge "402"; then
965             tmp_CFLAGS="$tmp_CFLAGS -Wcast-align"
966           fi
967           #
968           dnl Only gcc 4.3 or later
969           if test "$compiler_num" -ge "403"; then
970             tmp_CFLAGS="$tmp_CFLAGS -Wtype-limits -Wold-style-declaration"
971             tmp_CFLAGS="$tmp_CFLAGS -Wmissing-parameter-type -Wempty-body"
972             tmp_CFLAGS="$tmp_CFLAGS -Wclobbered -Wignored-qualifiers"
973             tmp_CFLAGS="$tmp_CFLAGS -Wconversion -Wno-sign-conversion -Wvla"
974           fi
975           #
976         fi
977         #
978         dnl Do not issue warnings for code in system include paths.
979         if test "$compiler_num" -ge "300"; then
980           tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
981         else
982           dnl When cross-compiling with a gcc older than 3.0, disable
983           dnl some warnings triggered on third party system headers.
984           if test "x$cross_compiling" = "xyes"; then
985             if test "$compiler_num" -ge "104"; then
986               dnl gcc 1.4 or later
987               tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
988             fi
989             if test "$compiler_num" -ge "207"; then
990               dnl gcc 2.7 or later
991               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
992               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
993             fi
994           fi
995         fi
996         ;;
997         #
998       HP_UX_C)
999         #
1000         if test "$want_warnings" = "yes"; then
1001           dnl Issue all warnings
1002           tmp_CFLAGS="$tmp_CFLAGS +w1"
1003         fi
1004         ;;
1005         #
1006       IBM_C)
1007         #
1008         dnl Placeholder
1009         tmp_CFLAGS="$tmp_CFLAGS"
1010         ;;
1011         #
1012       INTEL_UNIX_C)
1013         #
1014         if test "$want_warnings" = "yes"; then
1015           if test "$compiler_num" -gt "600"; then
1016             dnl Show errors, warnings, and remarks
1017             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
1018             dnl Perform extra compile-time code checking
1019             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
1020             dnl Warn on nested comments
1021             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
1022             dnl Show warnings relative to deprecated features
1023             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
1024             dnl Enable warnings for missing prototypes
1025             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
1026             dnl Enable warnings for 64-bit portability issues
1027             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
1028             dnl Enable warnings for questionable pointer arithmetic
1029             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
1030             dnl Check for function return typw issues
1031             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
1032             dnl Warn on variable declarations hiding a previous one
1033             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
1034             dnl Warn when a variable is used before initialized
1035             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
1036             dnl Warn if a declared function is not used
1037             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
1038           fi
1039         fi
1040         dnl Disable using EBP register in optimizations
1041         tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
1042         dnl Disable use of ANSI C aliasing rules in optimizations
1043         tmp_CFLAGS="$tmp_CFLAGS -fno-strict-aliasing"
1044         dnl Value-safe optimizations on floating-point data
1045         tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
1046         dnl Only icc 10.0 or later
1047         if test "$compiler_num" -ge "1000"; then
1048           dnl Disable vectorizer diagnostic information
1049           tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
1050         fi
1051         ;;
1052         #
1053       INTEL_WINDOWS_C)
1054         #
1055         dnl Placeholder
1056         tmp_CFLAGS="$tmp_CFLAGS"
1057         ;;
1058         #
1059       LCC)
1060         #
1061         if test "$want_warnings" = "yes"; then
1062           dnl Highest warning level is double -A, next is single -A.
1063           dnl Due to the big number of warnings these trigger on third
1064           dnl party header files it is impractical for us to use any of
1065           dnl them here. If you want them simply define it in CPPFLAGS.
1066           tmp_CFLAGS="$tmp_CFLAGS"
1067         fi
1068         ;;
1069         #
1070       SGI_MIPS_C)
1071         #
1072         if test "$want_warnings" = "yes"; then
1073           dnl Perform stricter semantic and lint-like checks
1074           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1075         fi
1076         ;;
1077         #
1078       SGI_MIPSPRO_C)
1079         #
1080         if test "$want_warnings" = "yes"; then
1081           dnl Perform stricter semantic and lint-like checks
1082           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1083           dnl Disable some remarks
1084           dnl #1209: controlling expression is constant
1085           tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1086         fi
1087         ;;
1088         #
1089       SUNPRO_C)
1090         #
1091         if test "$want_warnings" = "yes"; then
1092           dnl Perform stricter semantic and lint-like checks
1093           tmp_CFLAGS="$tmp_CFLAGS -v"
1094         fi
1095         ;;
1096         #
1097       TINY_C)
1098         #
1099         if test "$want_warnings" = "yes"; then
1100           dnl Activate all warnings
1101           tmp_CFLAGS="$tmp_CFLAGS -Wall"
1102           dnl Make string constants be of type const char *
1103           tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1104           dnl Warn use of unsupported GCC features ignored by TCC
1105           tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1106         fi
1107         ;;
1108         #
1109       WATCOM_UNIX_C)
1110         #
1111         if test "$want_warnings" = "yes"; then
1112           dnl Issue all warnings
1113           tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1114         fi
1115         ;;
1116         #
1117       WATCOM_WINDOWS_C)
1118         #
1119         dnl Placeholder
1120         tmp_CFLAGS="$tmp_CFLAGS"
1121         ;;
1122         #
1123     esac
1124     #
1125     squeeze tmp_CPPFLAGS
1126     squeeze tmp_CFLAGS
1127     #
1128     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1129       AC_MSG_CHECKING([if compiler accepts strict warning options])
1130       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1131       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1132       squeeze CPPFLAGS
1133       squeeze CFLAGS
1134       CURL_COMPILER_WORKS_IFELSE([
1135         AC_MSG_RESULT([yes])
1136         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1137       ],[
1138         AC_MSG_RESULT([no])
1139         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1140         dnl restore initial settings
1141         CPPFLAGS="$tmp_save_CPPFLAGS"
1142         CFLAGS="$tmp_save_CFLAGS"
1143       ])
1144     fi
1145     #
1146   fi
1147 ])
1148
1149
1150 dnl CURL_SHFUNC_SQUEEZE
1151 dnl -------------------------------------------------
1152 dnl Declares a shell function squeeze() which removes
1153 dnl redundant whitespace out of a shell variable.
1154
1155 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1156 squeeze() {
1157   _sqz_result=""
1158   eval _sqz_input=\[$][$]1
1159   for _sqz_token in $_sqz_input; do
1160     if test -z "$_sqz_result"; then
1161       _sqz_result="$_sqz_token"
1162     else
1163       _sqz_result="$_sqz_result $_sqz_token"
1164     fi
1165   done
1166   eval [$]1=\$_sqz_result
1167   return 0
1168 }
1169 ])
1170
1171
1172 dnl CURL_CHECK_CURLDEBUG
1173 dnl -------------------------------------------------
1174 dnl Settings which depend on configure's curldebug given
1175 dnl option, and other additional configure pre-requisites.
1176 dnl Actually the curl debug memory tracking feature can
1177 dnl only be used/enabled when libcurl is built as a static
1178 dnl library or as a shared one on those systems on which
1179 dnl shared libraries support undefined symbols.
1180
1181 AC_DEFUN([CURL_CHECK_CURLDEBUG], [
1182   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1183   supports_curldebug="unknown"
1184   if test "$want_curldebug" = "yes"; then
1185     if test "x$enable_shared" != "xno" &&
1186       test "x$enable_shared" != "xyes"; then
1187       AC_MSG_WARN([unknown enable_shared setting.])
1188       supports_curldebug="no"
1189     fi
1190     if test "x$enable_static" != "xno" &&
1191       test "x$enable_static" != "xyes"; then
1192       AC_MSG_WARN([unknown enable_static setting.])
1193       supports_curldebug="no"
1194     fi
1195     if test "$supports_curldebug" != "no"; then
1196       if test "$enable_shared" = "yes" &&
1197         test "$need_no_undefined" = "yes"; then
1198         supports_curldebug="no"
1199         AC_MSG_WARN([shared library does not support undefined symbols.])
1200       fi
1201     fi
1202   fi
1203   #
1204   if test "$want_curldebug" = "yes"; then
1205     AC_MSG_CHECKING([if curl debug memory tracking can be enabled])
1206     test "$supports_curldebug" = "no" || supports_curldebug="yes"
1207     AC_MSG_RESULT([$supports_curldebug])
1208     if test "$supports_curldebug" = "no"; then
1209       AC_MSG_WARN([cannot enable curl debug memory tracking.])
1210       want_curldebug="no"
1211     fi
1212   fi
1213   #
1214   if test "$want_curldebug" = "yes"; then
1215     CPPFLAGS="-DCURLDEBUG $CPPFLAGS"
1216     squeeze CPPFLAGS
1217   fi
1218   if test "$want_debug" = "yes"; then
1219     CPPFLAGS="-DDEBUGBUILD $CPPFLAGS"
1220     squeeze CPPFLAGS
1221   fi
1222 ])
1223
1224
1225 dnl CURL_CHECK_NO_UNDEFINED
1226 dnl -------------------------------------------------
1227 dnl Checks if the -no-undefined flag must be used when
1228 dnl building shared libraries. This is required on all
1229 dnl systems on which shared libraries should not have
1230 dnl references to undefined symbols. This check should
1231 dnl not be done before AC-PROG-LIBTOOL.
1232
1233 AC_DEFUN([CURL_CHECK_NO_UNDEFINED], [
1234   AC_BEFORE([$0],[CURL_CHECK_CURLDEBUG])dnl
1235   AC_MSG_CHECKING([if shared libraries need -no-undefined])
1236   need_no_undefined="no"
1237   case $host in
1238     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc* | *-*-aix*)
1239       need_no_undefined="yes"
1240       ;;
1241   esac
1242   if test "x$allow_undefined" = "xno"; then
1243     need_no_undefined="yes"
1244   elif test "x$allow_undefined_flag" = "xunsupported"; then
1245     need_no_undefined="yes"
1246   fi
1247   AC_MSG_RESULT($need_no_undefined)
1248 ])
1249
1250
1251 dnl CURL_CHECK_PROG_CC
1252 dnl -------------------------------------------------
1253 dnl Check for compiler program, preventing CFLAGS and
1254 dnl CPPFLAGS from being unexpectedly changed.
1255
1256 AC_DEFUN([CURL_CHECK_PROG_CC], [
1257   ac_save_CFLAGS="$CFLAGS"
1258   ac_save_CPPFLAGS="$CPPFLAGS"
1259   AC_PROG_CC
1260   CFLAGS="$ac_save_CFLAGS"
1261   CPPFLAGS="$ac_save_CPPFLAGS"
1262 ])
1263
1264
1265 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
1266 dnl -------------------------------------------------
1267 dnl Verifies if the compiler actually halts after the
1268 dnl compilation phase without generating any object
1269 dnl code file, when the source compiles with errors.
1270
1271 AC_DEFUN([CURL_CHECK_COMPILER_HALT_ON_ERROR], [
1272   AC_MSG_CHECKING([if compiler halts on compilation errors])
1273   AC_COMPILE_IFELSE([
1274     AC_LANG_PROGRAM([[
1275     ]],[[
1276       force compilation error
1277     ]])
1278   ],[
1279     AC_MSG_RESULT([no])
1280     AC_MSG_ERROR([compiler does not halt on compilation errors.])
1281   ],[
1282     AC_MSG_RESULT([yes])
1283   ])
1284 ])
1285
1286
1287 dnl CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE
1288 dnl -------------------------------------------------
1289 dnl Verifies if the compiler actually halts after the
1290 dnl compilation phase without generating any object
1291 dnl code file, when the source code tries to define a
1292 dnl type for a constant array with negative dimension.
1293
1294 AC_DEFUN([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE], [
1295   AC_REQUIRE([CURL_CHECK_COMPILER_HALT_ON_ERROR])dnl
1296   AC_MSG_CHECKING([if compiler halts on negative sized arrays])
1297   AC_COMPILE_IFELSE([
1298     AC_LANG_PROGRAM([[
1299       typedef char bad_t[sizeof(char) == sizeof(int) ? -1 : -1 ];
1300     ]],[[
1301       bad_t dummy;
1302     ]])
1303   ],[
1304     AC_MSG_RESULT([no])
1305     AC_MSG_ERROR([compiler does not halt on negative sized arrays.])
1306   ],[
1307     AC_MSG_RESULT([yes])
1308   ])
1309 ])
1310
1311
1312 dnl CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE
1313 dnl -------------------------------------------------
1314 dnl Verifies if the compiler is capable of handling the
1315 dnl size of a struct member, struct which is a function
1316 dnl result, as a compilation-time condition inside the
1317 dnl type definition of a constant array.
1318
1319 AC_DEFUN([CURL_CHECK_COMPILER_STRUCT_MEMBER_SIZE], [
1320   AC_REQUIRE([CURL_CHECK_COMPILER_ARRAY_SIZE_NEGATIVE])dnl
1321   AC_MSG_CHECKING([if compiler struct member size checking works])
1322   tst_compiler_check_one_works="unknown"
1323   AC_COMPILE_IFELSE([
1324     AC_LANG_PROGRAM([[
1325       struct mystruct {
1326         int  mi;
1327         char mc;
1328         struct mystruct *next;
1329       };
1330       struct mystruct myfunc();
1331       typedef char good_t1[sizeof(myfunc().mi) == sizeof(int)  ? 1 : -1 ];
1332       typedef char good_t2[sizeof(myfunc().mc) == sizeof(char) ? 1 : -1 ];
1333     ]],[[
1334       good_t1 dummy1;
1335       good_t2 dummy2;
1336     ]])
1337   ],[
1338     tst_compiler_check_one_works="yes"
1339   ],[
1340     tst_compiler_check_one_works="no"
1341     sed 's/^/cc-src: /' conftest.$ac_ext >&6
1342     sed 's/^/cc-err: /' conftest.err >&6
1343   ])
1344   tst_compiler_check_two_works="unknown"
1345   AC_COMPILE_IFELSE([
1346     AC_LANG_PROGRAM([[
1347       struct mystruct {
1348         int  mi;
1349         char mc;
1350         struct mystruct *next;
1351       };
1352       struct mystruct myfunc();
1353       typedef char bad_t1[sizeof(myfunc().mi) != sizeof(int)  ? 1 : -1 ];
1354       typedef char bad_t2[sizeof(myfunc().mc) != sizeof(char) ? 1 : -1 ];
1355     ]],[[
1356       bad_t1 dummy1;
1357       bad_t2 dummy2;
1358     ]])
1359   ],[
1360     tst_compiler_check_two_works="no"
1361   ],[
1362     tst_compiler_check_two_works="yes"
1363   ])
1364   if test "$tst_compiler_check_one_works" = "yes" &&
1365     test "$tst_compiler_check_two_works" = "yes"; then
1366     AC_MSG_RESULT([yes])
1367   else
1368     AC_MSG_RESULT([no])
1369     AC_MSG_ERROR([compiler fails struct member size checking.])
1370   fi
1371 ])
1372
1373
1374 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1375 dnl -------------------------------------------------
1376 dnl Verifies if shell variable VARNAME contains VALUE.
1377 dnl Contents of variable VARNAME and VALUE are handled
1378 dnl as whitespace separated lists of words. If at least
1379 dnl one word of VALUE is present in VARNAME the match
1380 dnl is considered positive, otherwise false.
1381
1382 AC_DEFUN([CURL_VAR_MATCH], [
1383   ac_var_match_word="no"
1384   for word1 in $[$1]; do
1385     for word2 in [$2]; do
1386       if test "$word1" = "$word2"; then
1387         ac_var_match_word="yes"
1388       fi
1389     done
1390   done
1391 ])
1392
1393
1394 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1395 dnl                        [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1396 dnl -------------------------------------------------
1397 dnl This performs a CURL_VAR_MATCH check and executes
1398 dnl first branch if the match is positive, otherwise
1399 dnl the second branch is executed.
1400
1401 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1402   CURL_VAR_MATCH([$1],[$2])
1403   if test "$ac_var_match_word" = "yes"; then
1404   ifelse($3,,:,[$3])
1405   ifelse($4,,,[else
1406     $4])
1407   fi
1408 ])
1409
1410
1411 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1412 dnl -------------------------------------------------
1413 dnl Contents of variable VARNAME and VALUE are handled
1414 dnl as whitespace separated lists of words. Each word
1415 dnl from VALUE is removed from VARNAME when present.
1416
1417 AC_DEFUN([CURL_VAR_STRIP], [
1418   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1419   ac_var_stripped=""
1420   for word1 in $[$1]; do
1421     ac_var_strip_word="no"
1422     for word2 in [$2]; do
1423       if test "$word1" = "$word2"; then
1424         ac_var_strip_word="yes"
1425       fi
1426     done
1427     if test "$ac_var_strip_word" = "no"; then
1428       ac_var_stripped="$ac_var_stripped $word1"
1429     fi
1430   done
1431   dnl squeeze whitespace out of result
1432   [$1]="$ac_var_stripped"
1433   squeeze [$1]
1434 ])
1435