some more temporary magic for the icc seg-fault issue
[platform/upstream/curl.git] / m4 / curl-compilers.m4
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2008, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 # $Id$
22 #***************************************************************************
23
24 # File version for 'aclocal' use. Keep it a single number.
25 # serial 42
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([__i386__], [], [silent])
196     CURL_CHECK_DEF([__unix__], [], [silent])
197     if test "$curl_cv_have_def___unix__" = "yes"; then
198       compiler_id="INTEL_UNIX_C"
199       flags_dbg_all="-g -g0"
200       flags_dbg_yes="-g"
201       flags_dbg_off="-g0"
202       flags_opt_all="-O -O0 -O1 -O2 -O3 -Os"
203       flags_opt_yes="-O2"
204       flags_opt_off="-O0"
205       dnl icc 9.1 optimization on IA32 triggers SIGSEGV
206       if test "$curl_cv_have_def___i386__" = "yes" &&
207         test "$compiler_num" -eq "910"; then
208         INTEL_UNIX_C_OPT_SIGSEGV="yes"
209       else
210         INTEL_UNIX_C_OPT_SIGSEGV="no"
211       fi
212     else
213       compiler_id="INTEL_WINDOWS_C"
214       flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
215       flags_dbg_all="$flags_dbg_all /debug"
216       flags_dbg_all="$flags_dbg_all /debug:none"
217       flags_dbg_all="$flags_dbg_all /debug:minimal"
218       flags_dbg_all="$flags_dbg_all /debug:partial"
219       flags_dbg_all="$flags_dbg_all /debug:full"
220       flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
221       flags_dbg_all="$flags_dbg_all /debug:extended"
222       flags_dbg_yes="/Zi /Oy-"
223       flags_dbg_off="/debug:none /Oy-"
224       flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
225       flags_opt_yes="/O2"
226       flags_opt_off="/Od"
227     fi
228   else
229     AC_MSG_RESULT([no])
230   fi
231 ])
232
233
234 dnl CURL_CHECK_COMPILER_LCC
235 dnl -------------------------------------------------
236 dnl Verify if compiler being used is LCC.
237
238 AC_DEFUN([CURL_CHECK_COMPILER_LCC], [
239   AC_MSG_CHECKING([if compiler is LCC])
240   CURL_CHECK_DEF([__LCC__], [], [silent])
241   if test "$curl_cv_have_def___LCC__" = "yes"; then
242     AC_MSG_RESULT([yes])
243     compiler_id="LCC"
244     flags_dbg_all="-g"
245     flags_dbg_yes="-g"
246     flags_dbg_off=""
247     flags_opt_all=""
248     flags_opt_yes=""
249     flags_opt_off=""
250   else
251     AC_MSG_RESULT([no])
252   fi
253 ])
254
255
256 dnl CURL_CHECK_COMPILER_SGI_MIPS_C
257 dnl -------------------------------------------------
258 dnl Verify if compiler being used is SGI MIPS C.
259
260 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPS_C], [
261   AC_REQUIRE([CURL_CHECK_COMPILER_SGI_MIPSPRO_C])dnl
262   AC_MSG_CHECKING([if compiler is SGI MIPS C])
263   CURL_CHECK_DEF([__GNUC__], [], [silent])
264   CURL_CHECK_DEF([__sgi], [], [silent])
265   if test "$curl_cv_have_def___GNUC__" = "no" &&
266     test "$curl_cv_have_def___sgi" = "yes" &&
267     test "$compiler_id" = "unknown"; then
268     AC_MSG_RESULT([yes])
269     compiler_id="SGI_MIPS_C"
270     flags_dbg_all="-g -g0 -g1 -g2 -g3"
271     flags_dbg_yes="-g"
272     flags_dbg_off="-g0"
273     flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
274     flags_opt_yes="-O2"
275     flags_opt_off="-O0"
276   else
277     AC_MSG_RESULT([no])
278   fi
279 ])
280
281
282 dnl CURL_CHECK_COMPILER_SGI_MIPSPRO_C
283 dnl -------------------------------------------------
284 dnl Verify if compiler being used is SGI MIPSpro C.
285
286 AC_DEFUN([CURL_CHECK_COMPILER_SGI_MIPSPRO_C], [
287   AC_BEFORE([$0],[CURL_CHECK_COMPILER_SGI_MIPS_C])dnl
288   AC_MSG_CHECKING([if compiler is SGI MIPSpro C])
289   CURL_CHECK_DEF([__GNUC__], [], [silent])
290   CURL_CHECK_DEF([_COMPILER_VERSION], [], [silent])
291   CURL_CHECK_DEF([_SGI_COMPILER_VERSION], [], [silent])
292   if test "$curl_cv_have_def___GNUC__" = "no" &&
293     (test "$curl_cv_have_def__SGI_COMPILER_VERSION" = "yes" ||
294      test "$curl_cv_have_def__COMPILER_VERSION" = "yes"); then
295     AC_MSG_RESULT([yes])
296     compiler_id="SGI_MIPSPRO_C"
297     flags_dbg_all="-g -g0 -g1 -g2 -g3"
298     flags_dbg_yes="-g"
299     flags_dbg_off="-g0"
300     flags_opt_all="-O -O0 -O1 -O2 -O3 -Ofast"
301     flags_opt_yes="-O2"
302     flags_opt_off="-O0"
303   else
304     AC_MSG_RESULT([no])
305   fi
306 ])
307
308
309 dnl CURL_CHECK_COMPILER_SUNPRO_C
310 dnl -------------------------------------------------
311 dnl Verify if compiler being used is SunPro C.
312
313 AC_DEFUN([CURL_CHECK_COMPILER_SUNPRO_C], [
314   AC_MSG_CHECKING([if compiler is SunPro C])
315   CURL_CHECK_DEF([__SUNPRO_C], [], [silent])
316   if test "$curl_cv_have_def___SUNPRO_C" = "yes"; then
317     AC_MSG_RESULT([yes])
318     compiler_id="SUNPRO_C"
319     flags_dbg_all="-g -s"
320     flags_dbg_yes="-g"
321     flags_dbg_off="-s"
322     flags_opt_all="-O -xO -xO1 -xO2 -xO3 -xO4 -xO5"
323     flags_opt_yes="-xO2"
324     flags_opt_off=""
325   else
326     AC_MSG_RESULT([no])
327   fi
328 ])
329
330
331 dnl CURL_CHECK_COMPILER_TINY_C
332 dnl -------------------------------------------------
333 dnl Verify if compiler being used is Tiny C.
334
335 AC_DEFUN([CURL_CHECK_COMPILER_TINY_C], [
336   AC_MSG_CHECKING([if compiler is Tiny C])
337   CURL_CHECK_DEF([__TINYC__], [], [silent])
338   if test "$curl_cv_have_def___TINYC__" = "yes"; then
339     AC_MSG_RESULT([yes])
340     compiler_id="TINY_C"
341     flags_dbg_all="-g -b"
342     flags_dbg_yes="-g"
343     flags_dbg_off=""
344     flags_opt_all=""
345     flags_opt_yes=""
346     flags_opt_off=""
347   else
348     AC_MSG_RESULT([no])
349   fi
350 ])
351
352
353 dnl CURL_CHECK_COMPILER_WATCOM_C
354 dnl -------------------------------------------------
355 dnl Verify if compiler being used is Watcom C.
356
357 AC_DEFUN([CURL_CHECK_COMPILER_WATCOM_C], [
358   AC_MSG_CHECKING([if compiler is Watcom C])
359   CURL_CHECK_DEF([__WATCOMC__], [], [silent])
360   if test "$curl_cv_have_def___WATCOMC__" = "yes"; then
361     AC_MSG_RESULT([yes])
362     CURL_CHECK_DEF([__UNIX__], [], [silent])
363     if test "$curl_cv_have_def___UNIX__" = "yes"; then
364       compiler_id="WATCOM_UNIX_C"
365       flags_dbg_all="-g1 -g1+ -g2 -g3"
366       flags_dbg_yes="-g2"
367       flags_dbg_off=""
368       flags_opt_all="-O0 -O1 -O2 -O3"
369       flags_opt_yes="-O2"
370       flags_opt_off="-O0"
371     else
372       compiler_id="WATCOM_WINDOWS_C"
373       flags_dbg_all=""
374       flags_dbg_yes=""
375       flags_dbg_off=""
376       flags_opt_all=""
377       flags_opt_yes=""
378       flags_opt_off=""
379     fi
380   else
381     AC_MSG_RESULT([no])
382   fi
383 ])
384
385
386 dnl CURL_CONVERT_INCLUDE_TO_ISYSTEM
387 dnl -------------------------------------------------
388 dnl Changes standard include paths present in CFLAGS
389 dnl and CPPFLAGS into isystem include paths. This is
390 dnl done to prevent GNUC from generating warnings on
391 dnl headers from these locations, even though this is
392 dnl not reliable on ancient GNUC versions.
393
394 AC_DEFUN([CURL_CONVERT_INCLUDE_TO_ISYSTEM], [
395   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
396   tmp_has_include="no"
397   tmp_chg_FLAGS="$CFLAGS"
398   for word1 in $tmp_chg_FLAGS; do
399     case "$word1" in
400       -I*)
401         tmp_has_include="yes"
402         ;;
403     esac
404   done
405   if test "$tmp_has_include" = "yes"; then
406     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
407     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
408     CFLAGS="$tmp_chg_FLAGS"
409     squeeze CFLAGS
410   fi
411   tmp_has_include="no"
412   tmp_chg_FLAGS="$CPPFLAGS"
413   for word1 in $tmp_chg_FLAGS; do
414     case "$word1" in
415       -I*)
416         tmp_has_include="yes"
417         ;;
418     esac
419   done
420   if test "$tmp_has_include" = "yes"; then
421     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/^-I/ -isystem /g'`
422     tmp_chg_FLAGS=`echo "$tmp_chg_FLAGS" | "$SED" 's/ -I/ -isystem /g'`
423     CPPFLAGS="$tmp_chg_FLAGS"
424     squeeze CPPFLAGS
425   fi
426 ])
427
428
429 dnl CURL_COMPILER_WORKS_IFELSE ([ACTION-IF-WORKS], [ACTION-IF-NOT-WORKS])
430 dnl -------------------------------------------------
431 dnl Verify if the C compiler seems to work with the
432 dnl settings that are 'active' at the time the test
433 dnl is performed.
434
435 AC_DEFUN([CURL_COMPILER_WORKS_IFELSE], [
436   dnl compilation capability verification
437   tmp_compiler_works="unknown"
438   AC_COMPILE_IFELSE([
439     AC_LANG_PROGRAM([[
440     ]],[[
441       int i = 1;
442       return i;
443     ]])
444   ],[
445     tmp_compiler_works="yes"
446   ],[
447     tmp_compiler_works="no"
448     echo " " >&6
449     sed 's/^/cc-fail: /' conftest.err >&6
450     echo " " >&6
451   ])
452   dnl linking capability verification
453   if test "$tmp_compiler_works" = "yes"; then
454     AC_LINK_IFELSE([
455       AC_LANG_PROGRAM([[
456       ]],[[
457         int i = 1;
458         return i;
459       ]])
460     ],[
461       tmp_compiler_works="yes"
462     ],[
463       tmp_compiler_works="no"
464       echo " " >&6
465       sed 's/^/link-fail: /' conftest.err >&6
466       echo " " >&6
467     ])
468   fi
469   dnl only do runtime verification when not cross-compiling
470   if test "x$cross_compiling" != "xyes" &&
471     test "$tmp_compiler_works" = "yes"; then
472     AC_RUN_IFELSE([
473       AC_LANG_PROGRAM([[
474 #       ifdef __STDC__
475 #         include <stdlib.h>
476 #       endif
477       ]],[[
478         int i = 0;
479         exit(i);
480       ]])
481     ],[
482       tmp_compiler_works="yes"
483     ],[
484       tmp_compiler_works="no"
485       echo " " >&6
486       echo "run-fail: test program exited with status $ac_status" >&6
487       echo " " >&6
488     ])
489   fi
490   dnl branch upon test result
491   if test "$tmp_compiler_works" = "yes"; then
492   ifelse($1,,:,[$1])
493   ifelse($2,,,[else
494     $2])
495   fi
496 ])
497
498
499 dnl CURL_SET_COMPILER_BASIC_OPTS
500 dnl -------------------------------------------------
501 dnl Sets compiler specific options/flags which do not
502 dnl depend on configure's debug, optimize or warnings
503 dnl options.
504
505 AC_DEFUN([CURL_SET_COMPILER_BASIC_OPTS], [
506   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
507   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
508   #
509   if test "$compiler_id" != "unknown"; then
510     #
511     if test "$compiler_id" = "GNU_C"; then
512       CURL_CONVERT_INCLUDE_TO_ISYSTEM
513     fi
514     #
515     tmp_save_CPPFLAGS="$CPPFLAGS"
516     tmp_save_CFLAGS="$CFLAGS"
517     tmp_CPPFLAGS=""
518     tmp_CFLAGS=""
519     #
520     case "$compiler_id" in
521         #
522       DEC_C)
523         #
524         dnl Select strict ANSI C compiler mode
525         tmp_CFLAGS="$tmp_CFLAGS -std1"
526         dnl Turn off optimizer ANSI C aliasing rules
527         tmp_CFLAGS="$tmp_CFLAGS -noansi_alias"
528         dnl Generate warnings for missing function prototypes
529         tmp_CFLAGS="$tmp_CFLAGS -warnprotos"
530         dnl Change some warnings into fatal errors
531         tmp_CFLAGS="$tmp_CFLAGS -msg_fatal toofewargs,toomanyargs"
532         ;;
533         #
534       GNU_C)
535         #
536         dnl Placeholder
537         tmp_CFLAGS="$tmp_CFLAGS"
538         ;;
539         #
540       HP_UX_C)
541         #
542         dnl Disallow run-time dereferencing of null pointers
543         tmp_CFLAGS="$tmp_CFLAGS -z"
544         dnl Disable some remarks
545         dnl #4227: padding struct with n bytes to align member
546         dnl #4255: padding size of struct with n bytes to alignment boundary
547         tmp_CFLAGS="$tmp_CFLAGS +W 4227,4255"
548         ;;
549         #
550       IBM_C)
551         #
552         dnl Ensure that compiler optimizations are always thread-safe.
553         tmp_CFLAGS="$tmp_CFLAGS -qthreaded"
554         dnl Disable type based strict aliasing optimizations, using worst
555         dnl case aliasing assumptions when compiling. Type based aliasing
556         dnl would restrict the lvalues that could be safely used to access
557         dnl a data object.
558         tmp_CFLAGS="$tmp_CFLAGS -qnoansialias"
559         dnl Force compiler to stop after the compilation phase, without
560         dnl generating an object code file when compilation has errors.
561         tmp_CFLAGS="$tmp_CFLAGS -qhalt=e"
562         ;;
563         #
564       INTEL_UNIX_C)
565         #
566         dnl On unix this compiler uses gcc's header files, so
567         dnl we select ANSI C89 dialect plus GNU extensions.
568         dnl tmp_CFLAGS="$tmp_CFLAGS -std=gnu89"
569         dnl Select ANSI C89 dialect without GNU extensions.
570         tmp_CFLAGS="$tmp_CFLAGS -std=c89"
571         dnl Change some warnings into errors
572         dnl #140: too many arguments in function call
573         dnl #147: declaration is incompatible with 'previous one'
574         dnl #165: too few arguments in function call
575         dnl #266: function declared implicitly
576         tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
577         dnl Disable some remarks
578         dnl #279: controlling expression is constant
579         dnl #981: operands are evaluated in unspecified order
580         dnl #1469: "cc" clobber ignored
581         tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
582         ;;
583         #
584       INTEL_WINDOWS_C)
585         #
586         dnl Placeholder
587         tmp_CFLAGS="$tmp_CFLAGS"
588         ;;
589         #
590       LCC)
591         #
592         dnl Disallow run-time dereferencing of null pointers
593         tmp_CFLAGS="$tmp_CFLAGS -n"
594         ;;
595         #
596       SGI_MIPS_C)
597         #
598         dnl Placeholder
599         tmp_CFLAGS="$tmp_CFLAGS"
600         ;;
601         #
602       SGI_MIPSPRO_C)
603         #
604         dnl Placeholder
605         tmp_CFLAGS="$tmp_CFLAGS"
606         ;;
607         #
608       SUNPRO_C)
609         #
610         dnl Placeholder
611         tmp_CFLAGS="$tmp_CFLAGS"
612         ;;
613         #
614       TINY_C)
615         #
616         dnl Placeholder
617         tmp_CFLAGS="$tmp_CFLAGS"
618         ;;
619         #
620       WATCOM_UNIX_C)
621         #
622         dnl Placeholder
623         tmp_CFLAGS="$tmp_CFLAGS"
624         ;;
625         #
626       WATCOM_WINDOWS_C)
627         #
628         dnl Placeholder
629         tmp_CFLAGS="$tmp_CFLAGS"
630         ;;
631         #
632     esac
633     #
634     squeeze tmp_CPPFLAGS
635     squeeze tmp_CFLAGS
636     #
637     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
638       AC_MSG_CHECKING([if compiler accepts some basic options])
639       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
640       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
641       squeeze CPPFLAGS
642       squeeze CFLAGS
643       CURL_COMPILER_WORKS_IFELSE([
644         AC_MSG_RESULT([yes])
645         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
646       ],[
647         AC_MSG_RESULT([no])
648         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
649         dnl restore initial settings
650         CPPFLAGS="$tmp_save_CPPFLAGS"
651         CFLAGS="$tmp_save_CFLAGS"
652       ])
653     fi
654     #
655   fi
656 ])
657
658
659 dnl CURL_SET_COMPILER_DEBUG_OPTS
660 dnl -------------------------------------------------
661 dnl Sets compiler specific options/flags which depend
662 dnl on configure's debug option.
663
664 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
665   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
666   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
667   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
668   #
669   if test "$compiler_id" != "unknown"; then
670     #
671     tmp_save_CFLAGS="$CFLAGS"
672     tmp_save_CPPFLAGS="$CPPFLAGS"
673     #
674     tmp_options=""
675     tmp_CFLAGS="$CFLAGS"
676     tmp_CPPFLAGS="$CPPFLAGS"
677     CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
678     CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
679     #
680     if test "$want_debug" = "yes"; then
681       AC_MSG_CHECKING([if compiler accepts debug enabling options])
682       tmp_options="$flags_dbg_yes"
683     fi
684     if test "$want_debug" = "no"; then
685       AC_MSG_CHECKING([if compiler accepts debug disabling options])
686       tmp_options="$flags_dbg_off"
687     fi
688     #
689     CPPFLAGS="$tmp_CPPFLAGS"
690     CFLAGS="$tmp_CFLAGS $tmp_options"
691     squeeze CPPFLAGS
692     squeeze CFLAGS
693     CURL_COMPILER_WORKS_IFELSE([
694       AC_MSG_RESULT([yes])
695       AC_MSG_NOTICE([compiler options added: $tmp_options])
696     ],[
697       AC_MSG_RESULT([no])
698       AC_MSG_WARN([compiler options rejected: $tmp_options])
699       dnl restore initial settings
700       CPPFLAGS="$tmp_save_CPPFLAGS"
701       CFLAGS="$tmp_save_CFLAGS"
702     ])
703     #
704   fi
705 ])
706
707
708 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
709 dnl -------------------------------------------------
710 dnl Sets compiler specific options/flags which depend
711 dnl on configure's optimize option.
712
713 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
714   AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
715   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
716   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
717   #
718   if test "$compiler_id" != "unknown"; then
719     #
720     tmp_save_CFLAGS="$CFLAGS"
721     tmp_save_CPPFLAGS="$CPPFLAGS"
722     #
723     tmp_options=""
724     tmp_CFLAGS="$CFLAGS"
725     tmp_CPPFLAGS="$CPPFLAGS"
726     honor_optimize_option="yes"
727     #
728     dnl If optimization request setting has not been explicitly specified,
729     dnl it has been derived from the debug setting and initially assumed.
730     dnl This initially assumed optimizer setting will finally be ignored
731     dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
732     dnl that an initially assumed optimizer setting might not be honored.
733     #
734     if test "$want_optimize" = "assume_no" ||
735        test "$want_optimize" = "assume_yes"; then
736       AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
737       CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
738         honor_optimize_option="no"
739       ])
740       CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
741         honor_optimize_option="no"
742       ])
743       AC_MSG_RESULT([$honor_optimize_option])
744       if test "$honor_optimize_option" = "yes"; then
745         if test "$want_optimize" = "assume_yes"; then
746           want_optimize="yes"
747         fi
748         if test "$want_optimize" = "assume_no"; then
749           want_optimize="no"
750         fi
751       fi
752     fi
753     #
754     if test "$honor_optimize_option" = "yes"; then
755       CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
756       CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
757       if test "$want_optimize" = "yes"; then
758         AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
759         tmp_options="$flags_opt_yes"
760       fi
761       if test "$want_optimize" = "no"; then
762         AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
763         tmp_options="$flags_opt_off"
764       fi
765       CPPFLAGS="$tmp_CPPFLAGS"
766       CFLAGS="$tmp_CFLAGS $tmp_options"
767       squeeze CPPFLAGS
768       squeeze CFLAGS
769       CURL_COMPILER_WORKS_IFELSE([
770         AC_MSG_RESULT([yes])
771         AC_MSG_NOTICE([compiler options added: $tmp_options])
772       ],[
773         AC_MSG_RESULT([no])
774         AC_MSG_WARN([compiler options rejected: $tmp_options])
775         dnl restore initial settings
776         CPPFLAGS="$tmp_save_CPPFLAGS"
777         CFLAGS="$tmp_save_CFLAGS"
778       ])
779     fi
780     #
781   fi
782 ])
783
784
785 dnl CURL_SET_COMPILER_WARNING_OPTS
786 dnl -------------------------------------------------
787 dnl Sets compiler options/flags which depend on
788 dnl configure's warnings given option.
789
790 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
791   AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
792   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
793   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
794   #
795   if test "$compiler_id" != "unknown"; then
796     #
797     tmp_save_CPPFLAGS="$CPPFLAGS"
798     tmp_save_CFLAGS="$CFLAGS"
799     tmp_CPPFLAGS=""
800     tmp_CFLAGS=""
801     #
802     case "$compiler_id" in
803         #
804       DEC_C)
805         #
806         if test "$want_warnings" = "yes"; then
807           dnl Select a higher warning level than default level2
808           tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
809         fi
810         ;;
811         #
812       GNU_C)
813         #
814         if test "$want_warnings" = "yes"; then
815           #
816           dnl Do not enable -pedantic when cross-compiling with a gcc older
817           dnl than 3.0, to avoid warnings from third party system headers.
818           if test "x$cross_compiling" != "xyes" ||
819             test "$compiler_num" -ge "300"; then
820             tmp_CFLAGS="$tmp_CFLAGS -pedantic"
821           fi
822           #
823           dnl Set of options we believe *ALL* gcc versions support:
824           tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
825           #
826           dnl Only gcc 1.4 or later
827           if test "$compiler_num" -ge "104"; then
828             tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
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 -Wunused -Wshadow"
833             fi
834           fi
835           #
836           dnl Only gcc 2.7 or later
837           if test "$compiler_num" -ge "207"; then
838             tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
839             dnl If not cross-compiling with a gcc older than 3.0
840             if test "x$cross_compiling" != "xyes" ||
841               test "$compiler_num" -ge "300"; then
842               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
843               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
844             fi
845           fi
846           #
847           dnl Only gcc 2.95 or later
848           if test "$compiler_num" -ge "295"; then
849             tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
850           fi
851           #
852           dnl Only gcc 2.96 or later
853           if test "$compiler_num" -ge "296"; then
854             tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
855             tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
856             dnl -Wundef used only if gcc is 2.96 or later since we get
857             dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
858             dnl headers with gcc 2.95.4 on FreeBSD 4.9
859             tmp_CFLAGS="$tmp_CFLAGS -Wundef"
860           fi
861           #
862           dnl Only gcc 2.97 or later
863           if test "$compiler_num" -ge "297"; then
864             tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
865           fi
866           #
867           dnl Only gcc 3.0 or later
868           if test "$compiler_num" -ge "300"; then
869             dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
870             dnl on i686-Linux as it gives us heaps with false positives.
871             dnl Also, on gcc 4.0.X it is totally unbearable and complains all
872             dnl over making it unusable for generic purposes. Let's not use it.
873             tmp_CFLAGS="$tmp_CFLAGS"
874           fi
875           #
876           dnl Only gcc 3.3 or later
877           if test "$compiler_num" -ge "303"; then
878             tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
879           fi
880           #
881           dnl Only gcc 3.4 or later
882           if test "$compiler_num" -ge "304"; then
883             tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
884           fi
885           #
886         fi
887         #
888         dnl Do not issue warnings for code in system include paths.
889         if test "$compiler_num" -ge "300"; then
890           tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
891         else
892           dnl When cross-compiling with a gcc older than 3.0, disable
893           dnl some warnings triggered on third party system headers.
894           if test "x$cross_compiling" = "xyes"; then
895             if test "$compiler_num" -ge "104"; then
896               dnl gcc 1.4 or later
897               tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
898             fi
899             if test "$compiler_num" -ge "207"; then
900               dnl gcc 2.7 or later
901               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
902               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
903             fi
904           fi
905         fi
906         ;;
907         #
908       HP_UX_C)
909         #
910         if test "$want_warnings" = "yes"; then
911           dnl Issue all warnings
912           dnl tmp_CFLAGS="$tmp_CFLAGS +w1"
913           dnl Due to the HP-UX socklen_t issue it is insane to use the +w1
914           dnl warning level. Until the issue is somehow fixed we will just
915           dnl use the +w2 warning level.
916           tmp_CFLAGS="$tmp_CFLAGS +w2"
917         fi
918         ;;
919         #
920       IBM_C)
921         #
922         dnl Placeholder
923         tmp_CFLAGS="$tmp_CFLAGS"
924         ;;
925         #
926       INTEL_UNIX_C)
927         #
928         if test "$want_warnings" = "yes"; then
929           if test "$compiler_num" -gt "600"; then
930             dnl Show errors, warnings, and remarks
931             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
932             dnl Perform extra compile-time code checking
933             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
934             dnl Warn on nested comments
935             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
936             dnl Show warnings relative to deprecated features
937             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
938             dnl Enable warnings for missing prototypes
939             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
940             dnl Enable warnings for 64-bit portability issues
941             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
942             dnl Enable warnings for questionable pointer arithmetic
943             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
944             dnl Check for function return typw issues
945             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
946             dnl Warn on variable declarations hiding a previous one
947             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
948             dnl Warn when a variable is used before initialized
949             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
950             dnl Warn if a declared function is not used
951             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
952           fi
953         fi
954         dnl Disable using EBP register in optimizations
955         tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
956         dnl Disable use of ANSI C aliasing rules in optimizations
957         tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
958         dnl Value-safe optimizations on floating-point data
959         tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
960         dnl Only icc 10.0 or later
961         if test "$compiler_num" -ge "1000"; then
962           dnl Disable vectorizer diagnostic information
963           tmp_CFLAGS="$tmp_CFLAGS -vec-report0"
964         fi
965         dnl Disable some optimizations to debug icc 9.1 SIGSEGV
966         if test "$INTEL_UNIX_C_OPT_SIGSEGV" = "yes"; then
967           dnl Disable interprocedural optimizations
968           tmp_CFLAGS="$tmp_CFLAGS -no-ip -no-ipo"
969           dnl Separate functions for the linker
970           tmp_CFLAGS="$tmp_CFLAGS -ffunction-sections"
971           dnl Disable inlining of user-defined functions
972           tmp_CFLAGS="$tmp_CFLAGS -Ob0"
973           dnl Disable inline expansion of intrinsic functions
974           tmp_CFLAGS="$tmp_CFLAGS -fno-builtin"
975           dnl Disable inlining of functions
976           tmp_CFLAGS="$tmp_CFLAGS -fno-inline"
977           dnl Disable some IPO for single file optimizations
978           tmp_CFLAGS="$tmp_CFLAGS -fno-inline-functions"
979           dnl Disable inlining of standard library functions
980           tmp_CFLAGS="$tmp_CFLAGS -nolib-inline"
981           dnl Disable full and partial inlining when IPO
982           tmp_CFLAGS="$tmp_CFLAGS -ip-no-inlining"
983           dnl Enable floating-point stack integrity checks
984           tmp_CFLAGS="$tmp_CFLAGS -fpstkchk"
985           dnl Enable run-time detection of buffer overruns.
986           tmp_CFLAGS="$tmp_CFLAGS -fstack-security-check"
987           dnl Assume aliasing in the program.
988           tmp_CFLAGS="$tmp_CFLAGS -falias"
989           dnl Assume that arguments may be aliased.
990           tmp_CFLAGS="$tmp_CFLAGS -alias-args"
991           dnl Assume aliasing within functions
992           tmp_CFLAGS="$tmp_CFLAGS -ffnalias"
993           dnl Disable prefetch insertion optimization
994           tmp_CFLAGS="$tmp_CFLAGS -no-prefetch"
995           dnl Disable loop unrolling optimization
996           tmp_CFLAGS="$tmp_CFLAGS -unroll0"
997         fi
998         ;;
999         #
1000       INTEL_WINDOWS_C)
1001         #
1002         dnl Placeholder
1003         tmp_CFLAGS="$tmp_CFLAGS"
1004         ;;
1005         #
1006       LCC)
1007         #
1008         if test "$want_warnings" = "yes"; then
1009           dnl Highest warning level is double -A, next is single -A.
1010           dnl Due to the big number of warnings these trigger on third
1011           dnl party header files it is impractical for us to use any of
1012           dnl them here. If you want them simply define it in CPPFLAGS.
1013           tmp_CFLAGS="$tmp_CFLAGS"
1014         fi
1015         ;;
1016         #
1017       SGI_MIPS_C)
1018         #
1019         if test "$want_warnings" = "yes"; then
1020           dnl Perform stricter semantic and lint-like checks
1021           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1022         fi
1023         ;;
1024         #
1025       SGI_MIPSPRO_C)
1026         #
1027         if test "$want_warnings" = "yes"; then
1028           dnl Perform stricter semantic and lint-like checks
1029           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1030           dnl Disable some remarks
1031           dnl #1209: controlling expression is constant
1032           tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1033         fi
1034         ;;
1035         #
1036       SUNPRO_C)
1037         #
1038         if test "$want_warnings" = "yes"; then
1039           dnl Perform stricter semantic and lint-like checks
1040           tmp_CFLAGS="$tmp_CFLAGS -v"
1041         fi
1042         ;;
1043         #
1044       TINY_C)
1045         #
1046         if test "$want_warnings" = "yes"; then
1047           dnl Activate all warnings
1048           tmp_CFLAGS="$tmp_CFLAGS -Wall"
1049           dnl Make string constants be of type const char *
1050           tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1051           dnl Warn use of unsupported GCC features ignored by TCC
1052           tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1053         fi
1054         ;;
1055         #
1056       WATCOM_UNIX_C)
1057         #
1058         if test "$want_warnings" = "yes"; then
1059           dnl Issue all warnings
1060           tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1061         fi
1062         ;;
1063         #
1064       WATCOM_WINDOWS_C)
1065         #
1066         dnl Placeholder
1067         tmp_CFLAGS="$tmp_CFLAGS"
1068         ;;
1069         #
1070     esac
1071     #
1072     squeeze tmp_CPPFLAGS
1073     squeeze tmp_CFLAGS
1074     #
1075     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1076       AC_MSG_CHECKING([if compiler accepts strict warning options])
1077       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1078       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1079       squeeze CPPFLAGS
1080       squeeze CFLAGS
1081       CURL_COMPILER_WORKS_IFELSE([
1082         AC_MSG_RESULT([yes])
1083         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1084       ],[
1085         AC_MSG_RESULT([no])
1086         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1087         dnl restore initial settings
1088         CPPFLAGS="$tmp_save_CPPFLAGS"
1089         CFLAGS="$tmp_save_CFLAGS"
1090       ])
1091     fi
1092     #
1093   fi
1094 ])
1095
1096
1097 dnl CURL_SHFUNC_SQUEEZE
1098 dnl -------------------------------------------------
1099 dnl Declares a shell function squeeze() which removes
1100 dnl redundant whitespace out of a shell variable.
1101
1102 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1103 squeeze() {
1104   _sqz_result=""
1105   eval _sqz_input=\[$][$]1
1106   for _sqz_token in $_sqz_input; do
1107     if test -z "$_sqz_result"; then
1108       _sqz_result="$_sqz_token"
1109     else
1110       _sqz_result="$_sqz_result $_sqz_token"
1111     fi
1112   done
1113   eval [$]1=\$_sqz_result
1114   return 0
1115 }
1116 ])
1117
1118
1119 dnl CURL_PROCESS_DEBUG_BUILD_OPTS
1120 dnl -------------------------------------------------
1121 dnl Settings which depend on configure's debug given
1122 dnl option, and further configure the build process.
1123 dnl Don't use this macro for compiler dependant stuff.
1124
1125 AC_DEFUN([CURL_PROCESS_DEBUG_BUILD_OPTS], [
1126   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
1127   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1128   AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
1129   #
1130   if test "$want_debug" = "yes"; then
1131     CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1132     squeeze CPPFLAGS
1133   fi
1134   #
1135 ])
1136
1137
1138 dnl CURL_CHECK_PROG_CC
1139 dnl -------------------------------------------------
1140 dnl Check for compiler program, preventing CFLAGS and
1141 dnl CPPFLAGS from being unexpectedly changed.
1142
1143 AC_DEFUN([CURL_CHECK_PROG_CC], [
1144   ac_save_CFLAGS="$CFLAGS"
1145   ac_save_CPPFLAGS="$CPPFLAGS"
1146   AC_PROG_CC
1147   CFLAGS="$ac_save_CFLAGS"
1148   CPPFLAGS="$ac_save_CPPFLAGS"
1149 ])
1150
1151
1152 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1153 dnl -------------------------------------------------
1154 dnl Verifies if shell variable VARNAME contains VALUE.
1155 dnl Contents of variable VARNAME and VALUE are handled
1156 dnl as whitespace separated lists of words. If at least
1157 dnl one word of VALUE is present in VARNAME the match
1158 dnl is considered positive, otherwise false.
1159
1160 AC_DEFUN([CURL_VAR_MATCH], [
1161   ac_var_match_word="no"
1162   for word1 in $[$1]; do
1163     for word2 in [$2]; do
1164       if test "$word1" = "$word2"; then
1165         ac_var_match_word="yes"
1166       fi
1167     done
1168   done
1169 ])
1170
1171
1172 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1173 dnl                        [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1174 dnl -------------------------------------------------
1175 dnl This performs a CURL_VAR_MATCH check and executes
1176 dnl first branch if the match is positive, otherwise
1177 dnl the second branch is executed.
1178
1179 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1180   CURL_VAR_MATCH([$1],[$2])
1181   if test "$ac_var_match_word" = "yes"; then
1182   ifelse($3,,:,[$3])
1183   ifelse($4,,,[else
1184     $4])
1185   fi
1186 ])
1187
1188
1189 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1190 dnl -------------------------------------------------
1191 dnl Contents of variable VARNAME and VALUE are handled
1192 dnl as whitespace separated lists of words. Each word
1193 dnl from VALUE is removed from VARNAME when present.
1194
1195 AC_DEFUN([CURL_VAR_STRIP], [
1196   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1197   ac_var_stripped=""
1198   for word1 in $[$1]; do
1199     ac_var_strip_word="no"
1200     for word2 in [$2]; do
1201       if test "$word1" = "$word2"; then
1202         ac_var_strip_word="yes"
1203       fi
1204     done
1205     if test "$ac_var_strip_word" = "no"; then
1206       ac_var_stripped="$ac_var_stripped $word1"
1207     fi
1208   done
1209   dnl squeeze whitespace out of result
1210   [$1]="$ac_var_stripped"
1211   squeeze [$1]
1212 ])
1213