icc adjustments:
[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 41
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     CURL_CHECK_DEF([__i386__], [], [silent])
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       dnl icc 9.1 optimization on IA32 triggers SIGSEGV
205       if test "$curl_cv_have_def___i386__" = "yes" &&
206         test "$compiler_num" -eq "910"; then
207         INTEL_UNIX_C_OPT_SIGSEGV="yes"
208       else
209         INTEL_UNIX_C_OPT_SIGSEGV="no"
210       fi
211     else
212       compiler_id="INTEL_WINDOWS_C"
213       flags_dbg_all="/ZI /Zi /zI /zi /ZD /Zd /zD /zd /Z7 /z7 /Oy /Oy-"
214       flags_dbg_all="$flags_dbg_all /debug"
215       flags_dbg_all="$flags_dbg_all /debug:none"
216       flags_dbg_all="$flags_dbg_all /debug:minimal"
217       flags_dbg_all="$flags_dbg_all /debug:partial"
218       flags_dbg_all="$flags_dbg_all /debug:full"
219       flags_dbg_all="$flags_dbg_all /debug:semantic_stepping"
220       flags_dbg_all="$flags_dbg_all /debug:extended"
221       flags_dbg_yes="/Zi /Oy-"
222       flags_dbg_off="/debug:none /Oy-"
223       flags_opt_all="/O /O0 /O1 /O2 /O3 /Od /Og /Og- /Oi /Oi-"
224       flags_opt_yes="/O2"
225       flags_opt_off="/Od"
226     fi
227     compiler_num="$curl_cv_def___INTEL_COMPILER"
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         tmp_CPPFLAGS="$tmp_CPPFLAGS -std=gnu89"
569         dnl Change some warnings into errors
570         dnl #140: too many arguments in function call
571         dnl #147: declaration is incompatible with 'previous one'
572         dnl #165: too few arguments in function call
573         dnl #266: function declared implicitly
574         tmp_CPPFLAGS="$tmp_CPPFLAGS -we 140,147,165,266"
575         dnl Disable some remarks
576         dnl #279: controlling expression is constant
577         dnl #981: operands are evaluated in unspecified order
578         dnl #1469: "cc" clobber ignored
579         tmp_CPPFLAGS="$tmp_CPPFLAGS -wd 279,981,1469"
580         ;;
581         #
582       INTEL_WINDOWS_C)
583         #
584         dnl Placeholder
585         tmp_CFLAGS="$tmp_CFLAGS"
586         ;;
587         #
588       LCC)
589         #
590         dnl Disallow run-time dereferencing of null pointers
591         tmp_CFLAGS="$tmp_CFLAGS -n"
592         ;;
593         #
594       SGI_MIPS_C)
595         #
596         dnl Placeholder
597         tmp_CFLAGS="$tmp_CFLAGS"
598         ;;
599         #
600       SGI_MIPSPRO_C)
601         #
602         dnl Placeholder
603         tmp_CFLAGS="$tmp_CFLAGS"
604         ;;
605         #
606       SUNPRO_C)
607         #
608         dnl Placeholder
609         tmp_CFLAGS="$tmp_CFLAGS"
610         ;;
611         #
612       TINY_C)
613         #
614         dnl Placeholder
615         tmp_CFLAGS="$tmp_CFLAGS"
616         ;;
617         #
618       WATCOM_UNIX_C)
619         #
620         dnl Placeholder
621         tmp_CFLAGS="$tmp_CFLAGS"
622         ;;
623         #
624       WATCOM_WINDOWS_C)
625         #
626         dnl Placeholder
627         tmp_CFLAGS="$tmp_CFLAGS"
628         ;;
629         #
630     esac
631     #
632     squeeze tmp_CPPFLAGS
633     squeeze tmp_CFLAGS
634     #
635     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
636       AC_MSG_CHECKING([if compiler accepts some basic options])
637       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
638       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
639       squeeze CPPFLAGS
640       squeeze CFLAGS
641       CURL_COMPILER_WORKS_IFELSE([
642         AC_MSG_RESULT([yes])
643         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
644       ],[
645         AC_MSG_RESULT([no])
646         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
647         dnl restore initial settings
648         CPPFLAGS="$tmp_save_CPPFLAGS"
649         CFLAGS="$tmp_save_CFLAGS"
650       ])
651     fi
652     #
653   fi
654 ])
655
656
657 dnl CURL_SET_COMPILER_DEBUG_OPTS
658 dnl -------------------------------------------------
659 dnl Sets compiler specific options/flags which depend
660 dnl on configure's debug option.
661
662 AC_DEFUN([CURL_SET_COMPILER_DEBUG_OPTS], [
663   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
664   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
665   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
666   #
667   if test "$compiler_id" != "unknown"; then
668     #
669     tmp_save_CFLAGS="$CFLAGS"
670     tmp_save_CPPFLAGS="$CPPFLAGS"
671     #
672     tmp_options=""
673     tmp_CFLAGS="$CFLAGS"
674     tmp_CPPFLAGS="$CPPFLAGS"
675     CURL_VAR_STRIP([tmp_CFLAGS],[$flags_dbg_all])
676     CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_dbg_all])
677     #
678     if test "$want_debug" = "yes"; then
679       AC_MSG_CHECKING([if compiler accepts debug enabling options])
680       tmp_options="$flags_dbg_yes"
681     fi
682     if test "$want_debug" = "no"; then
683       AC_MSG_CHECKING([if compiler accepts debug disabling options])
684       tmp_options="$flags_dbg_off"
685     fi
686     #
687     CPPFLAGS="$tmp_CPPFLAGS"
688     CFLAGS="$tmp_CFLAGS $tmp_options"
689     squeeze CPPFLAGS
690     squeeze CFLAGS
691     CURL_COMPILER_WORKS_IFELSE([
692       AC_MSG_RESULT([yes])
693       AC_MSG_NOTICE([compiler options added: $tmp_options])
694     ],[
695       AC_MSG_RESULT([no])
696       AC_MSG_WARN([compiler options rejected: $tmp_options])
697       dnl restore initial settings
698       CPPFLAGS="$tmp_save_CPPFLAGS"
699       CFLAGS="$tmp_save_CFLAGS"
700     ])
701     #
702   fi
703 ])
704
705
706 dnl CURL_SET_COMPILER_OPTIMIZE_OPTS
707 dnl -------------------------------------------------
708 dnl Sets compiler specific options/flags which depend
709 dnl on configure's optimize option.
710
711 AC_DEFUN([CURL_SET_COMPILER_OPTIMIZE_OPTS], [
712   AC_REQUIRE([CURL_CHECK_OPTION_OPTIMIZE])dnl
713   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
714   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
715   #
716   if test "$compiler_id" != "unknown"; then
717     #
718     tmp_save_CFLAGS="$CFLAGS"
719     tmp_save_CPPFLAGS="$CPPFLAGS"
720     #
721     tmp_options=""
722     tmp_CFLAGS="$CFLAGS"
723     tmp_CPPFLAGS="$CPPFLAGS"
724     honor_optimize_option="yes"
725     #
726     dnl If optimization request setting has not been explicitly specified,
727     dnl it has been derived from the debug setting and initially assumed.
728     dnl This initially assumed optimizer setting will finally be ignored
729     dnl if CFLAGS or CPPFLAGS already hold optimizer flags. This implies
730     dnl that an initially assumed optimizer setting might not be honored.
731     #
732     if test "$want_optimize" = "assume_no" ||
733        test "$want_optimize" = "assume_yes"; then
734       AC_MSG_CHECKING([if compiler optimizer assumed setting might be used])
735       CURL_VAR_MATCH_IFELSE([tmp_CFLAGS],[$flags_opt_all],[
736         honor_optimize_option="no"
737       ])
738       CURL_VAR_MATCH_IFELSE([tmp_CPPFLAGS],[$flags_opt_all],[
739         honor_optimize_option="no"
740       ])
741       AC_MSG_RESULT([$honor_optimize_option])
742       if test "$honor_optimize_option" = "yes"; then
743         if test "$want_optimize" = "assume_yes"; then
744           want_optimize="yes"
745         fi
746         if test "$want_optimize" = "assume_no"; then
747           want_optimize="no"
748         fi
749       fi
750     fi
751     #
752     if test "$honor_optimize_option" = "yes"; then
753       CURL_VAR_STRIP([tmp_CFLAGS],[$flags_opt_all])
754       CURL_VAR_STRIP([tmp_CPPFLAGS],[$flags_opt_all])
755       if test "$want_optimize" = "yes"; then
756         AC_MSG_CHECKING([if compiler accepts optimizer enabling options])
757         tmp_options="$flags_opt_yes"
758       fi
759       if test "$want_optimize" = "no"; then
760         AC_MSG_CHECKING([if compiler accepts optimizer disabling options])
761         tmp_options="$flags_opt_off"
762       fi
763       CPPFLAGS="$tmp_CPPFLAGS"
764       CFLAGS="$tmp_CFLAGS $tmp_options"
765       squeeze CPPFLAGS
766       squeeze CFLAGS
767       CURL_COMPILER_WORKS_IFELSE([
768         AC_MSG_RESULT([yes])
769         AC_MSG_NOTICE([compiler options added: $tmp_options])
770       ],[
771         AC_MSG_RESULT([no])
772         AC_MSG_WARN([compiler options rejected: $tmp_options])
773         dnl restore initial settings
774         CPPFLAGS="$tmp_save_CPPFLAGS"
775         CFLAGS="$tmp_save_CFLAGS"
776       ])
777     fi
778     #
779   fi
780 ])
781
782
783 dnl CURL_SET_COMPILER_WARNING_OPTS
784 dnl -------------------------------------------------
785 dnl Sets compiler options/flags which depend on
786 dnl configure's warnings given option.
787
788 AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
789   AC_REQUIRE([CURL_CHECK_OPTION_WARNINGS])dnl
790   AC_REQUIRE([CURL_CHECK_COMPILER])dnl
791   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
792   #
793   if test "$compiler_id" != "unknown"; then
794     #
795     tmp_save_CPPFLAGS="$CPPFLAGS"
796     tmp_save_CFLAGS="$CFLAGS"
797     tmp_CPPFLAGS=""
798     tmp_CFLAGS=""
799     #
800     case "$compiler_id" in
801         #
802       DEC_C)
803         #
804         if test "$want_warnings" = "yes"; then
805           dnl Select a higher warning level than default level2
806           tmp_CFLAGS="$tmp_CFLAGS -msg_enable level3"
807         fi
808         ;;
809         #
810       GNU_C)
811         #
812         if test "$want_warnings" = "yes"; then
813           #
814           dnl Do not enable -pedantic when cross-compiling with a gcc older
815           dnl than 3.0, to avoid warnings from third party system headers.
816           if test "x$cross_compiling" != "xyes" ||
817             test "$compiler_num" -ge "300"; then
818             tmp_CFLAGS="$tmp_CFLAGS -pedantic"
819           fi
820           #
821           dnl Set of options we believe *ALL* gcc versions support:
822           tmp_CFLAGS="$tmp_CFLAGS -Wall -W"
823           #
824           dnl Only gcc 1.4 or later
825           if test "$compiler_num" -ge "104"; then
826             tmp_CFLAGS="$tmp_CFLAGS -Wpointer-arith -Wwrite-strings"
827             dnl If not cross-compiling with a gcc older than 3.0
828             if test "x$cross_compiling" != "xyes" ||
829               test "$compiler_num" -ge "300"; then
830               tmp_CFLAGS="$tmp_CFLAGS -Wunused -Wshadow"
831             fi
832           fi
833           #
834           dnl Only gcc 2.7 or later
835           if test "$compiler_num" -ge "207"; then
836             tmp_CFLAGS="$tmp_CFLAGS -Winline -Wnested-externs"
837             dnl If not cross-compiling with a gcc older than 3.0
838             if test "x$cross_compiling" != "xyes" ||
839               test "$compiler_num" -ge "300"; then
840               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-declarations"
841               tmp_CFLAGS="$tmp_CFLAGS -Wmissing-prototypes"
842             fi
843           fi
844           #
845           dnl Only gcc 2.95 or later
846           if test "$compiler_num" -ge "295"; then
847             tmp_CFLAGS="$tmp_CFLAGS -Wno-long-long"
848           fi
849           #
850           dnl Only gcc 2.96 or later
851           if test "$compiler_num" -ge "296"; then
852             tmp_CFLAGS="$tmp_CFLAGS -Wfloat-equal"
853             tmp_CFLAGS="$tmp_CFLAGS -Wno-multichar -Wsign-compare"
854             dnl -Wundef used only if gcc is 2.96 or later since we get
855             dnl lots of "`_POSIX_C_SOURCE' is not defined" in system
856             dnl headers with gcc 2.95.4 on FreeBSD 4.9
857             tmp_CFLAGS="$tmp_CFLAGS -Wundef"
858           fi
859           #
860           dnl Only gcc 2.97 or later
861           if test "$compiler_num" -ge "297"; then
862             tmp_CFLAGS="$tmp_CFLAGS -Wno-format-nonliteral"
863           fi
864           #
865           dnl Only gcc 3.0 or later
866           if test "$compiler_num" -ge "300"; then
867             dnl -Wunreachable-code seems totally unreliable on my gcc 3.3.2 on
868             dnl on i686-Linux as it gives us heaps with false positives.
869             dnl Also, on gcc 4.0.X it is totally unbearable and complains all
870             dnl over making it unusable for generic purposes. Let's not use it.
871             tmp_CFLAGS="$tmp_CFLAGS"
872           fi
873           #
874           dnl Only gcc 3.3 or later
875           if test "$compiler_num" -ge "303"; then
876             tmp_CFLAGS="$tmp_CFLAGS -Wendif-labels -Wstrict-prototypes"
877           fi
878           #
879           dnl Only gcc 3.4 or later
880           if test "$compiler_num" -ge "304"; then
881             tmp_CFLAGS="$tmp_CFLAGS -Wdeclaration-after-statement"
882           fi
883           #
884         fi
885         #
886         dnl Do not issue warnings for code in system include paths.
887         if test "$compiler_num" -ge "300"; then
888           tmp_CFLAGS="$tmp_CFLAGS -Wno-system-headers"
889         else
890           dnl When cross-compiling with a gcc older than 3.0, disable
891           dnl some warnings triggered on third party system headers.
892           if test "x$cross_compiling" = "xyes"; then
893             if test "$compiler_num" -ge "104"; then
894               dnl gcc 1.4 or later
895               tmp_CFLAGS="$tmp_CFLAGS -Wno-unused -Wno-shadow"
896             fi
897             if test "$compiler_num" -ge "207"; then
898               dnl gcc 2.7 or later
899               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-declarations"
900               tmp_CFLAGS="$tmp_CFLAGS -Wno-missing-prototypes"
901             fi
902           fi
903         fi
904         ;;
905         #
906       HP_UX_C)
907         #
908         if test "$want_warnings" = "yes"; then
909           dnl Issue all warnings
910           dnl tmp_CFLAGS="$tmp_CFLAGS +w1"
911           dnl Due to the HP-UX socklen_t issue it is insane to use the +w1
912           dnl warning level. Until the issue is somehow fixed we will just
913           dnl use the +w2 warning level.
914           tmp_CFLAGS="$tmp_CFLAGS +w2"
915         fi
916         ;;
917         #
918       IBM_C)
919         #
920         dnl Placeholder
921         tmp_CFLAGS="$tmp_CFLAGS"
922         ;;
923         #
924       INTEL_UNIX_C)
925         #
926         if test "$want_warnings" = "yes"; then
927           if test "$compiler_num" -gt "600"; then
928             dnl Show errors, warnings, and remarks
929             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wall -w2"
930             dnl Perform extra compile-time code checking
931             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcheck"
932             dnl Warn on nested comments
933             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wcomment"
934             dnl Show warnings relative to deprecated features
935             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wdeprecated"
936             dnl Enable warnings for missing prototypes
937             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wmissing-prototypes"
938             dnl Enable warnings for 64-bit portability issues
939             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wp64"
940             dnl Enable warnings for questionable pointer arithmetic
941             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wpointer-arith"
942             dnl Check for function return typw issues
943             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wreturn-type"
944             dnl Warn on variable declarations hiding a previous one
945             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wshadow"
946             dnl Warn when a variable is used before initialized
947             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wuninitialized"
948             dnl Warn if a declared function is not used
949             tmp_CPPFLAGS="$tmp_CPPFLAGS -Wunused-function"
950           fi
951           dnl Disable using EBP register in optimizations
952           tmp_CFLAGS="$tmp_CFLAGS -fno-omit-frame-pointer"
953           dnl Disable use of ANSI C aliasing rules in optimizations
954           tmp_CFLAGS="$tmp_CFLAGS -no-ansi-alias"
955           dnl Disable some optimizations to debug icc 9.1 SIGSEGV
956           if test "$INTEL_UNIX_C_OPT_SIGSEGV" = "yes"; then
957             dnl Disable inlining of user-defined functions
958             tmp_CFLAGS="$tmp_CFLAGS -Ob0"
959             dnl Disable inline expansion of intrinsic functions
960             tmp_CFLAGS="$tmp_CFLAGS -fno-builtin"
961             dnl Disable inlining of functions
962             tmp_CFLAGS="$tmp_CFLAGS -fno-inline"
963             dnl Disable some IPO for single file optimizations
964             tmp_CFLAGS="$tmp_CFLAGS -fno-inline-functions"
965             dnl Disable inlining of standard library functions
966             tmp_CFLAGS="$tmp_CFLAGS -nolib-inline"
967             dnl Disable full and partial inlining when IPO
968             tmp_CFLAGS="$tmp_CFLAGS -ip-no-inlining"
969             dnl Enable floating-point stack integrity checks
970             tmp_CFLAGS="$tmp_CFLAGS -fpstkchk"
971             dnl Enable run-time detection of buffer overruns.
972             tmp_CFLAGS="$tmp_CFLAGS -fstack-security-check"
973             dnl Disable floating point optimizations
974             tmp_CFLAGS="$tmp_CFLAGS -fp-model precise"
975             dnl Assume aliasing in the program.
976             tmp_CFLAGS="$tmp_CFLAGS -falias"
977             dnl Assume that arguments may be aliased.
978             tmp_CFLAGS="$tmp_CFLAGS -alias-args"
979             dnl Assume aliasing within functions
980             tmp_CFLAGS="$tmp_CFLAGS -ffnalias"
981             dnl Disable prefetch insertion optimization
982             tmp_CFLAGS="$tmp_CFLAGS -no-prefetch"
983             dnl Disable loop unrolling optimization
984             tmp_CFLAGS="$tmp_CFLAGS -unroll0"
985           fi
986         fi
987         ;;
988         #
989       INTEL_WINDOWS_C)
990         #
991         dnl Placeholder
992         tmp_CFLAGS="$tmp_CFLAGS"
993         ;;
994         #
995       LCC)
996         #
997         if test "$want_warnings" = "yes"; then
998           dnl Highest warning level is double -A, next is single -A.
999           dnl Due to the big number of warnings these trigger on third
1000           dnl party header files it is impractical for us to use any of
1001           dnl them here. If you want them simply define it in CPPFLAGS.
1002           tmp_CFLAGS="$tmp_CFLAGS"
1003         fi
1004         ;;
1005         #
1006       SGI_MIPS_C)
1007         #
1008         if test "$want_warnings" = "yes"; then
1009           dnl Perform stricter semantic and lint-like checks
1010           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1011         fi
1012         ;;
1013         #
1014       SGI_MIPSPRO_C)
1015         #
1016         if test "$want_warnings" = "yes"; then
1017           dnl Perform stricter semantic and lint-like checks
1018           tmp_CFLAGS="$tmp_CFLAGS -fullwarn"
1019           dnl Disable some remarks
1020           dnl #1209: controlling expression is constant
1021           tmp_CFLAGS="$tmp_CFLAGS -woff 1209"
1022         fi
1023         ;;
1024         #
1025       SUNPRO_C)
1026         #
1027         if test "$want_warnings" = "yes"; then
1028           dnl Perform stricter semantic and lint-like checks
1029           tmp_CFLAGS="$tmp_CFLAGS -v"
1030         fi
1031         ;;
1032         #
1033       TINY_C)
1034         #
1035         if test "$want_warnings" = "yes"; then
1036           dnl Activate all warnings
1037           tmp_CFLAGS="$tmp_CFLAGS -Wall"
1038           dnl Make string constants be of type const char *
1039           tmp_CFLAGS="$tmp_CFLAGS -Wwrite-strings"
1040           dnl Warn use of unsupported GCC features ignored by TCC
1041           tmp_CFLAGS="$tmp_CFLAGS -Wunsupported"
1042         fi
1043         ;;
1044         #
1045       WATCOM_UNIX_C)
1046         #
1047         if test "$want_warnings" = "yes"; then
1048           dnl Issue all warnings
1049           tmp_CFLAGS="$tmp_CFLAGS -Wall -Wextra"
1050         fi
1051         ;;
1052         #
1053       WATCOM_WINDOWS_C)
1054         #
1055         dnl Placeholder
1056         tmp_CFLAGS="$tmp_CFLAGS"
1057         ;;
1058         #
1059     esac
1060     #
1061     squeeze tmp_CPPFLAGS
1062     squeeze tmp_CFLAGS
1063     #
1064     if test ! -z "$tmp_CFLAGS" || test ! -z "$tmp_CPPFLAGS"; then
1065       AC_MSG_CHECKING([if compiler accepts strict warning options])
1066       CPPFLAGS="$tmp_save_CPPFLAGS $tmp_CPPFLAGS"
1067       CFLAGS="$tmp_save_CFLAGS $tmp_CFLAGS"
1068       squeeze CPPFLAGS
1069       squeeze CFLAGS
1070       CURL_COMPILER_WORKS_IFELSE([
1071         AC_MSG_RESULT([yes])
1072         AC_MSG_NOTICE([compiler options added: $tmp_CFLAGS $tmp_CPPFLAGS])
1073       ],[
1074         AC_MSG_RESULT([no])
1075         AC_MSG_WARN([compiler options rejected: $tmp_CFLAGS $tmp_CPPFLAGS])
1076         dnl restore initial settings
1077         CPPFLAGS="$tmp_save_CPPFLAGS"
1078         CFLAGS="$tmp_save_CFLAGS"
1079       ])
1080     fi
1081     #
1082   fi
1083 ])
1084
1085
1086 dnl CURL_SHFUNC_SQUEEZE
1087 dnl -------------------------------------------------
1088 dnl Declares a shell function squeeze() which removes
1089 dnl redundant whitespace out of a shell variable.
1090
1091 AC_DEFUN([CURL_SHFUNC_SQUEEZE], [
1092 squeeze() {
1093   _sqz_result=""
1094   eval _sqz_input=\[$][$]1
1095   for _sqz_token in $_sqz_input; do
1096     if test -z "$_sqz_result"; then
1097       _sqz_result="$_sqz_token"
1098     else
1099       _sqz_result="$_sqz_result $_sqz_token"
1100     fi
1101   done
1102   eval [$]1=\$_sqz_result
1103   return 0
1104 }
1105 ])
1106
1107
1108 dnl CURL_PROCESS_DEBUG_BUILD_OPTS
1109 dnl -------------------------------------------------
1110 dnl Settings which depend on configure's debug given
1111 dnl option, and further configure the build process.
1112 dnl Don't use this macro for compiler dependant stuff.
1113
1114 AC_DEFUN([CURL_PROCESS_DEBUG_BUILD_OPTS], [
1115   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
1116   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1117   AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
1118   #
1119   if test "$want_debug" = "yes"; then
1120     CPPFLAGS="$CPPFLAGS -DCURLDEBUG"
1121     squeeze CPPFLAGS
1122   fi
1123   #
1124 ])
1125
1126
1127 dnl CURL_CHECK_PROG_CC
1128 dnl -------------------------------------------------
1129 dnl Check for compiler program, preventing CFLAGS and
1130 dnl CPPFLAGS from being unexpectedly changed.
1131
1132 AC_DEFUN([CURL_CHECK_PROG_CC], [
1133   ac_save_CFLAGS="$CFLAGS"
1134   ac_save_CPPFLAGS="$CPPFLAGS"
1135   AC_PROG_CC
1136   CFLAGS="$ac_save_CFLAGS"
1137   CPPFLAGS="$ac_save_CPPFLAGS"
1138 ])
1139
1140
1141 dnl CURL_VAR_MATCH (VARNAME, VALUE)
1142 dnl -------------------------------------------------
1143 dnl Verifies if shell variable VARNAME contains VALUE.
1144 dnl Contents of variable VARNAME and VALUE are handled
1145 dnl as whitespace separated lists of words. If at least
1146 dnl one word of VALUE is present in VARNAME the match
1147 dnl is considered positive, otherwise false.
1148
1149 AC_DEFUN([CURL_VAR_MATCH], [
1150   ac_var_match_word="no"
1151   for word1 in $[$1]; do
1152     for word2 in [$2]; do
1153       if test "$word1" = "$word2"; then
1154         ac_var_match_word="yes"
1155       fi
1156     done
1157   done
1158 ])
1159
1160
1161 dnl CURL_VAR_MATCH_IFELSE (VARNAME, VALUE,
1162 dnl                        [ACTION-IF-MATCH], [ACTION-IF-NOT-MATCH])
1163 dnl -------------------------------------------------
1164 dnl This performs a CURL_VAR_MATCH check and executes
1165 dnl first branch if the match is positive, otherwise
1166 dnl the second branch is executed.
1167
1168 AC_DEFUN([CURL_VAR_MATCH_IFELSE], [
1169   CURL_VAR_MATCH([$1],[$2])
1170   if test "$ac_var_match_word" = "yes"; then
1171   ifelse($3,,:,[$3])
1172   ifelse($4,,,[else
1173     $4])
1174   fi
1175 ])
1176
1177
1178 dnl CURL_VAR_STRIP (VARNAME, VALUE)
1179 dnl -------------------------------------------------
1180 dnl Contents of variable VARNAME and VALUE are handled
1181 dnl as whitespace separated lists of words. Each word
1182 dnl from VALUE is removed from VARNAME when present.
1183
1184 AC_DEFUN([CURL_VAR_STRIP], [
1185   AC_REQUIRE([CURL_SHFUNC_SQUEEZE])dnl
1186   ac_var_stripped=""
1187   for word1 in $[$1]; do
1188     ac_var_strip_word="no"
1189     for word2 in [$2]; do
1190       if test "$word1" = "$word2"; then
1191         ac_var_strip_word="yes"
1192       fi
1193     done
1194     if test "$ac_var_strip_word" = "no"; then
1195       ac_var_stripped="$ac_var_stripped $word1"
1196     fi
1197   done
1198   dnl squeeze whitespace out of result
1199   [$1]="$ac_var_stripped"
1200   squeeze [$1]
1201 ])
1202