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