]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/byacc/aclocal.m4
Add flex 2.5.37 from flex.sourceforge.net to contrib.
[FreeBSD/FreeBSD.git] / contrib / byacc / aclocal.m4
1 dnl $Id: aclocal.m4,v 1.19 2012/01/13 14:10:56 tom Exp $
2 dnl Macros for byacc configure script (Thomas E. Dickey)
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 2004-2011,2012 Thomas E. Dickey
5 dnl 
6 dnl Permission is hereby granted, free of charge, to any person obtaining a
7 dnl copy of this software and associated documentation files (the
8 dnl "Software"), to deal in the Software without restriction, including
9 dnl without limitation the rights to use, copy, modify, merge, publish,
10 dnl distribute, distribute with modifications, sublicense, and/or sell
11 dnl copies of the Software, and to permit persons to whom the Software is
12 dnl furnished to do so, subject to the following conditions:
13 dnl 
14 dnl The above copyright notice and this permission notice shall be included
15 dnl in all copies or portions of the Software.
16 dnl 
17 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 dnl 
25 dnl Except as contained in this notice, the name(s) of the above copyright
26 dnl holders shall not be used in advertising or otherwise to promote the
27 dnl sale, use or other dealings in this Software without prior written
28 dnl authorization.
29 dnl ---------------------------------------------------------------------------
30 dnl ---------------------------------------------------------------------------
31 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
32 dnl -------------
33 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
34 dnl The second parameter if given makes this macro verbose.
35 dnl
36 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
37 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
38 dnl confused by the quotes (which require backslashes to keep them usable).
39 AC_DEFUN([CF_ADD_CFLAGS],
40 [
41 cf_fix_cppflags=no
42 cf_new_cflags=
43 cf_new_cppflags=
44 cf_new_extra_cppflags=
45
46 for cf_add_cflags in $1
47 do
48 case $cf_fix_cppflags in
49 no)
50         case $cf_add_cflags in #(vi
51         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
52                 case $cf_add_cflags in
53                 -D*)
54                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
55
56                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
57                                 && test -z "${cf_tst_cflags}" \
58                                 && cf_fix_cppflags=yes
59
60                         if test $cf_fix_cppflags = yes ; then
61                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
62                                 continue
63                         elif test "${cf_tst_cflags}" = "\"'" ; then
64                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
65                                 continue
66                         fi
67                         ;;
68                 esac
69                 case "$CPPFLAGS" in
70                 *$cf_add_cflags) #(vi
71                         ;;
72                 *) #(vi
73                         case $cf_add_cflags in #(vi
74                         -D*)
75                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
76                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
77                                 ;;
78                         esac
79                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
80                         ;;
81                 esac
82                 ;;
83         *)
84                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
85                 ;;
86         esac
87         ;;
88 yes)
89         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
90
91         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
92
93         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
94                 && test -z "${cf_tst_cflags}" \
95                 && cf_fix_cppflags=no
96         ;;
97 esac
98 done
99
100 if test -n "$cf_new_cflags" ; then
101         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
102         CFLAGS="$CFLAGS $cf_new_cflags"
103 fi
104
105 if test -n "$cf_new_cppflags" ; then
106         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
107         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
108 fi
109
110 if test -n "$cf_new_extra_cppflags" ; then
111         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
112         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
113 fi
114
115 AC_SUBST(EXTRA_CPPFLAGS)
116
117 ])dnl
118 dnl ---------------------------------------------------------------------------
119 dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
120 dnl ----------------
121 dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
122 dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
123 AC_DEFUN([CF_ANSI_CC_CHECK],
124 [
125 # This should have been defined by AC_PROG_CC
126 : ${CC:=cc}
127
128 # Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
129 # into CC.  This will not help with broken scripts that wrap the compiler with
130 # options, but eliminates a more common category of user confusion.
131 AC_MSG_CHECKING(\$CC variable)
132 case "$CC" in #(vi
133 *[[\ \  ]]-[[IUD]]*)
134         AC_MSG_RESULT(broken)
135         AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
136         # humor him...
137         cf_flags=`echo "$CC" | sed -e 's/^[[^   ]]*[[   ]]//'`
138         CC=`echo "$CC" | sed -e 's/[[   ]].*//'`
139         CF_ADD_CFLAGS($cf_flags)
140         ;;
141 *)
142         AC_MSG_RESULT(ok)
143         ;;
144 esac
145
146 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
147 cf_cv_ansi_cc=no
148 cf_save_CFLAGS="$CFLAGS"
149 cf_save_CPPFLAGS="$CPPFLAGS"
150 # Don't try gcc -ansi; that turns off useful extensions and
151 # breaks some systems' header files.
152 # AIX                   -qlanglvl=ansi
153 # Ultrix and OSF/1      -std1
154 # HP-UX                 -Aa -D_HPUX_SOURCE
155 # SVR4                  -Xc
156 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
157 for cf_arg in "-DCC_HAS_PROTOS" \
158         "" \
159         -qlanglvl=ansi \
160         -std1 \
161         -Ae \
162         "-Aa -D_HPUX_SOURCE" \
163         -Xc
164 do
165         CF_ADD_CFLAGS($cf_arg)
166         AC_TRY_COMPILE(
167 [
168 #ifndef CC_HAS_PROTOS
169 #if !defined(__STDC__) || (__STDC__ != 1)
170 choke me
171 #endif
172 #endif
173 ],[
174         int test (int i, double x);
175         struct s1 {int (*f) (int a);};
176         struct s2 {int (*f) (double a);};],
177         [cf_cv_ansi_cc="$cf_arg"; break])
178 done
179 CFLAGS="$cf_save_CFLAGS"
180 CPPFLAGS="$cf_save_CPPFLAGS"
181 ])
182
183 if test "$cf_cv_ansi_cc" != "no"; then
184 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
185         CF_ADD_CFLAGS($cf_cv_ansi_cc)
186 else
187         AC_DEFINE(CC_HAS_PROTOS)
188 fi
189 fi
190 ])dnl
191 dnl ---------------------------------------------------------------------------
192 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
193 dnl ---------------
194 dnl For programs that must use an ANSI compiler, obtain compiler options that
195 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
196 dnl macros, since tools such as unproto can fake prototypes, but only part of
197 dnl the preprocessor.
198 AC_DEFUN([CF_ANSI_CC_REQD],
199 [AC_REQUIRE([CF_ANSI_CC_CHECK])
200 if test "$cf_cv_ansi_cc" = "no"; then
201         AC_MSG_ERROR(
202 [Your compiler does not appear to recognize prototypes.
203 You have the following choices:
204         a. adjust your compiler options
205         b. get an up-to-date compiler
206         c. use a wrapper such as unproto])
207 fi
208 ])dnl
209 dnl ---------------------------------------------------------------------------
210 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
211 dnl --------------
212 dnl Allow user to disable a normally-on option.
213 AC_DEFUN([CF_ARG_DISABLE],
214 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
215 dnl ---------------------------------------------------------------------------
216 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
217 dnl -------------
218 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
219 dnl values.
220 dnl
221 dnl Parameters:
222 dnl $1 = option name
223 dnl $2 = help-string
224 dnl $3 = action to perform if option is not default
225 dnl $4 = action if perform if option is default
226 dnl $5 = default option value (either 'yes' or 'no')
227 AC_DEFUN([CF_ARG_OPTION],
228 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
229   if test "$enableval" != "$5" ; then
230 ifelse([$3],,[    :]dnl
231 ,[    $3]) ifelse([$4],,,[
232   else
233     $4])
234   fi],[enableval=$5 ifelse([$4],,,[
235   $4
236 ])dnl
237   ])])dnl
238 dnl ---------------------------------------------------------------------------
239 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
240 dnl --------------
241 dnl Check if we're accidentally using a cache from a different machine.
242 dnl Derive the system name, as a check for reusing the autoconf cache.
243 dnl
244 dnl If we've packaged config.guess and config.sub, run that (since it does a
245 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
246 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
247 dnl which is useful in cross-compiles.
248 dnl
249 dnl Note: we would use $ac_config_sub, but that is one of the places where
250 dnl autoconf 2.5x broke compatibility with autoconf 2.13
251 AC_DEFUN([CF_CHECK_CACHE],
252 [
253 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
254         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
255         system_name="$host_os"
256 else
257         system_name="`(uname -s -r) 2>/dev/null`"
258         if test -z "$system_name" ; then
259                 system_name="`(hostname) 2>/dev/null`"
260         fi
261 fi
262 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
263 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
264
265 test -z "$system_name" && system_name="$cf_cv_system_name"
266 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
267
268 if test ".$system_name" != ".$cf_cv_system_name" ; then
269         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
270         AC_MSG_ERROR("Please remove config.cache and try again.")
271 fi
272 ])dnl
273 dnl ---------------------------------------------------------------------------
274 dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
275 dnl ---------------
276 dnl You can always use "make -n" to see the actual options, but it's hard to
277 dnl pick out/analyze warning messages when the compile-line is long.
278 dnl
279 dnl Sets:
280 dnl     ECHO_LT - symbol to control if libtool is verbose
281 dnl     ECHO_LD - symbol to prefix "cc -o" lines
282 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
283 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
284 dnl     ECHO_CC - symbol to put before any "cc" line
285 dnl
286 AC_DEFUN([CF_DISABLE_ECHO],[
287 AC_MSG_CHECKING(if you want to see long compiling messages)
288 CF_ARG_DISABLE(echo,
289         [  --disable-echo          display "compiling" commands],
290         [
291     ECHO_LT='--silent'
292     ECHO_LD='@echo linking [$]@;'
293     RULE_CC='@echo compiling [$]<'
294     SHOW_CC='@echo compiling [$]@'
295     ECHO_CC='@'
296 ],[
297     ECHO_LT=''
298     ECHO_LD=''
299     RULE_CC=''
300     SHOW_CC=''
301     ECHO_CC=''
302 ])
303 AC_MSG_RESULT($enableval)
304 AC_SUBST(ECHO_LT)
305 AC_SUBST(ECHO_LD)
306 AC_SUBST(RULE_CC)
307 AC_SUBST(SHOW_CC)
308 AC_SUBST(ECHO_CC)
309 ])dnl
310 dnl ---------------------------------------------------------------------------
311 dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
312 dnl ----------------
313 dnl Combine no-leak checks with the libraries or tools that are used for the
314 dnl checks.
315 AC_DEFUN([CF_DISABLE_LEAKS],[
316
317 AC_REQUIRE([CF_WITH_DMALLOC])
318 AC_REQUIRE([CF_WITH_DBMALLOC])
319 AC_REQUIRE([CF_WITH_VALGRIND])
320
321 AC_MSG_CHECKING(if you want to perform memory-leak testing)
322 AC_ARG_ENABLE(leaks,
323         [  --disable-leaks         test: free permanent memory, analyze leaks],
324         [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
325         : ${with_no_leaks:=no})
326 AC_MSG_RESULT($with_no_leaks)
327
328 if test "$with_no_leaks" = yes ; then
329         AC_DEFINE(NO_LEAKS)
330         AC_DEFINE(YY_NO_LEAKS)
331 fi
332 ])dnl
333 dnl ---------------------------------------------------------------------------
334 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
335 dnl -----------------
336 dnl Test for availability of useful gcc __attribute__ directives to quiet
337 dnl compiler warnings.  Though useful, not all are supported -- and contrary
338 dnl to documentation, unrecognized directives cause older compilers to barf.
339 AC_DEFUN([CF_GCC_ATTRIBUTES],
340 [
341 if test "$GCC" = yes
342 then
343 cat > conftest.i <<EOF
344 #ifndef GCC_PRINTF
345 #define GCC_PRINTF 0
346 #endif
347 #ifndef GCC_SCANF
348 #define GCC_SCANF 0
349 #endif
350 #ifndef GCC_NORETURN
351 #define GCC_NORETURN /* nothing */
352 #endif
353 #ifndef GCC_UNUSED
354 #define GCC_UNUSED /* nothing */
355 #endif
356 EOF
357 if test "$GCC" = yes
358 then
359         AC_CHECKING([for $CC __attribute__ directives])
360 cat > conftest.$ac_ext <<EOF
361 #line __oline__ "${as_me:-configure}"
362 #include "confdefs.h"
363 #include "conftest.h"
364 #include "conftest.i"
365 #if     GCC_PRINTF
366 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
367 #else
368 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
369 #endif
370 #if     GCC_SCANF
371 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
372 #else
373 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
374 #endif
375 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
376 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
377 extern void foo(void) GCC_NORETURN;
378 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
379 EOF
380         cf_printf_attribute=no
381         cf_scanf_attribute=no
382         for cf_attribute in scanf printf unused noreturn
383         do
384                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
385                 cf_directive="__attribute__(($cf_attribute))"
386                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
387
388                 case $cf_attribute in #(vi
389                 printf) #(vi
390                         cf_printf_attribute=yes
391                         cat >conftest.h <<EOF
392 #define GCC_$cf_ATTRIBUTE 1
393 EOF
394                         ;;
395                 scanf) #(vi
396                         cf_scanf_attribute=yes
397                         cat >conftest.h <<EOF
398 #define GCC_$cf_ATTRIBUTE 1
399 EOF
400                         ;;
401                 *) #(vi
402                         cat >conftest.h <<EOF
403 #define GCC_$cf_ATTRIBUTE $cf_directive
404 EOF
405                         ;;
406                 esac
407
408                 if AC_TRY_EVAL(ac_compile); then
409                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
410                         cat conftest.h >>confdefs.h
411                         case $cf_attribute in #(vi
412                         printf) #(vi
413                                 if test "$cf_printf_attribute" = no ; then
414                                         cat >>confdefs.h <<EOF
415 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
416 EOF
417                                 else
418                                         cat >>confdefs.h <<EOF
419 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
420 EOF
421                                 fi
422                                 ;;
423                         scanf) #(vi
424                                 if test "$cf_scanf_attribute" = no ; then
425                                         cat >>confdefs.h <<EOF
426 #define GCC_SCANFLIKE(fmt,var) /* nothing */
427 EOF
428                                 else
429                                         cat >>confdefs.h <<EOF
430 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
431 EOF
432                                 fi
433                                 ;;
434                         esac
435                 fi
436         done
437 else
438         fgrep define conftest.i >>confdefs.h
439 fi
440 rm -rf conftest*
441 fi
442 ])dnl
443 dnl ---------------------------------------------------------------------------
444 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
445 dnl --------------
446 dnl Find version of gcc
447 AC_DEFUN([CF_GCC_VERSION],[
448 AC_REQUIRE([AC_PROG_CC])
449 GCC_VERSION=none
450 if test "$GCC" = yes ; then
451         AC_MSG_CHECKING(version of $CC)
452         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
453         test -z "$GCC_VERSION" && GCC_VERSION=unknown
454         AC_MSG_RESULT($GCC_VERSION)
455 fi
456 ])dnl
457 dnl ---------------------------------------------------------------------------
458 dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
459 dnl ---------------
460 dnl Check if the compiler supports useful warning options.  There's a few that
461 dnl we don't use, simply because they're too noisy:
462 dnl
463 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
464 dnl     -Wredundant-decls (system headers make this too noisy)
465 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
466 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
467 dnl             is enabled for ncurses using "--enable-const".
468 dnl     -pedantic
469 dnl
470 dnl Parameter:
471 dnl     $1 is an optional list of gcc warning flags that a particular
472 dnl             application might want to use, e.g., "no-unused" for
473 dnl             -Wno-unused
474 dnl Special:
475 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
476 dnl
477 AC_DEFUN([CF_GCC_WARNINGS],
478 [
479 AC_REQUIRE([CF_GCC_VERSION])
480 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
481
482 cat > conftest.$ac_ext <<EOF
483 #line __oline__ "${as_me:-configure}"
484 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
485 EOF
486
487 if test "$INTEL_COMPILER" = yes
488 then
489 # The "-wdXXX" options suppress warnings:
490 # remark #1419: external declaration in primary source file
491 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
492 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
493 # remark #193: zero used for undefined preprocessing identifier
494 # remark #593: variable "curs_sb_left_arrow" was set but never used
495 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
496 # remark #869: parameter "tw" was never referenced
497 # remark #981: operands are evaluated in unspecified order
498 # warning #279: controlling expression is constant
499
500         AC_CHECKING([for $CC warning options])
501         cf_save_CFLAGS="$CFLAGS"
502         EXTRA_CFLAGS="-Wall"
503         for cf_opt in \
504                 wd1419 \
505                 wd1683 \
506                 wd1684 \
507                 wd193 \
508                 wd593 \
509                 wd279 \
510                 wd810 \
511                 wd869 \
512                 wd981
513         do
514                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
515                 if AC_TRY_EVAL(ac_compile); then
516                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
517                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
518                 fi
519         done
520         CFLAGS="$cf_save_CFLAGS"
521
522 elif test "$GCC" = yes
523 then
524         AC_CHECKING([for $CC warning options])
525         cf_save_CFLAGS="$CFLAGS"
526         EXTRA_CFLAGS=
527         cf_warn_CONST=""
528         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
529         for cf_opt in W Wall \
530                 Wbad-function-cast \
531                 Wcast-align \
532                 Wcast-qual \
533                 Winline \
534                 Wmissing-declarations \
535                 Wmissing-prototypes \
536                 Wnested-externs \
537                 Wpointer-arith \
538                 Wshadow \
539                 Wstrict-prototypes \
540                 Wundef $cf_warn_CONST $1
541         do
542                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
543                 if AC_TRY_EVAL(ac_compile); then
544                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
545                         case $cf_opt in #(vi
546                         Wcast-qual) #(vi
547                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
548                                 ;;
549                         Winline) #(vi
550                                 case $GCC_VERSION in
551                                 [[34]].*)
552                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
553                                         continue;;
554                                 esac
555                                 ;;
556                         esac
557                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
558                 fi
559         done
560         CFLAGS="$cf_save_CFLAGS"
561 fi
562 rm -rf conftest*
563
564 AC_SUBST(EXTRA_CFLAGS)
565 ])dnl
566 dnl ---------------------------------------------------------------------------
567 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
568 dnl -------------
569 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
570 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
571 dnl (or misfeature) of glibc2, which breaks portability of many applications,
572 dnl since it is interwoven with GNU extensions.
573 dnl
574 dnl Well, yes we could work around it...
575 AC_DEFUN([CF_GNU_SOURCE],
576 [
577 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
578 AC_TRY_COMPILE([#include <sys/types.h>],[
579 #ifndef _XOPEN_SOURCE
580 make an error
581 #endif],
582         [cf_cv_gnu_source=no],
583         [cf_save="$CPPFLAGS"
584          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
585          AC_TRY_COMPILE([#include <sys/types.h>],[
586 #ifdef _XOPEN_SOURCE
587 make an error
588 #endif],
589         [cf_cv_gnu_source=no],
590         [cf_cv_gnu_source=yes])
591         CPPFLAGS="$cf_save"
592         ])
593 ])
594 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
595 ])dnl
596 dnl ---------------------------------------------------------------------------
597 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
598 dnl -----------------
599 dnl Check if the given compiler is really the Intel compiler for Linux.  It
600 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
601 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
602 dnl
603 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
604 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
605 dnl the wrappers for gcc and g++ warnings.
606 dnl
607 dnl $1 = GCC (default) or GXX
608 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
609 dnl $3 = CFLAGS (default) or CXXFLAGS
610 AC_DEFUN([CF_INTEL_COMPILER],[
611 ifelse([$2],,INTEL_COMPILER,[$2])=no
612
613 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
614         case $host_os in
615         linux*|gnu*)
616                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
617                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
618                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
619                 AC_TRY_COMPILE([],[
620 #ifdef __INTEL_COMPILER
621 #else
622 make an error
623 #endif
624 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
625 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
626 ],[])
627                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
628                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
629                 ;;
630         esac
631 fi
632 ])dnl
633 dnl ---------------------------------------------------------------------------
634 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
635 dnl ------------
636 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
637 dnl a monocase filesystem.
638 AC_DEFUN([CF_MAKE_TAGS],[
639 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
640
641 AC_CHECK_PROGS(CTAGS, exctags ctags)
642 AC_CHECK_PROGS(ETAGS, exetags etags)
643
644 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
645
646 if test "$cf_cv_mixedcase" = yes ; then
647         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
648 else
649         MAKE_UPPER_TAGS=no
650 fi
651
652 if test "$MAKE_UPPER_TAGS" = yes ; then
653         MAKE_UPPER_TAGS=
654 else
655         MAKE_UPPER_TAGS="#"
656 fi
657
658 if test "$MAKE_LOWER_TAGS" = yes ; then
659         MAKE_LOWER_TAGS=
660 else
661         MAKE_LOWER_TAGS="#"
662 fi
663
664 AC_SUBST(CTAGS)
665 AC_SUBST(ETAGS)
666
667 AC_SUBST(MAKE_UPPER_TAGS)
668 AC_SUBST(MAKE_LOWER_TAGS)
669 ])dnl
670 dnl ---------------------------------------------------------------------------
671 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
672 dnl ----------------------
673 dnl Check if the file-system supports mixed-case filenames.  If we're able to
674 dnl create a lowercase name and see it as uppercase, it doesn't support that.
675 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
676 [
677 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
678 if test "$cross_compiling" = yes ; then
679         case $target_alias in #(vi
680         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
681                 cf_cv_mixedcase=no
682                 ;;
683         *)
684                 cf_cv_mixedcase=yes
685                 ;;
686         esac
687 else
688         rm -f conftest CONFTEST
689         echo test >conftest
690         if test -f CONFTEST ; then
691                 cf_cv_mixedcase=no
692         else
693                 cf_cv_mixedcase=yes
694         fi
695         rm -f conftest CONFTEST
696 fi
697 ])
698 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
699 ])dnl
700 dnl ---------------------------------------------------------------------------
701 dnl CF_MKSTEMP version: 7 updated: 2010/08/14 18:25:37
702 dnl ----------
703 dnl Check for a working mkstemp.  This creates two files, checks that they are
704 dnl successfully created and distinct (AmigaOS apparently fails on the last).
705 AC_DEFUN([CF_MKSTEMP],[
706 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
707 rm -rf conftest*
708 AC_TRY_RUN([
709 #include <sys/types.h>
710 #include <stdlib.h>
711 #include <stdio.h>
712 #include <string.h>
713 #include <sys/stat.h>
714 int main()
715 {
716         char *tmpl = "conftestXXXXXX";
717         char name[2][80];
718         int n;
719         int result = 0;
720         int fd;
721         struct stat sb;
722
723         umask(077);
724         for (n = 0; n < 2; ++n) {
725                 strcpy(name[n], tmpl);
726                 if ((fd = mkstemp(name[n])) >= 0) {
727                         if (!strcmp(name[n], tmpl)
728                          || stat(name[n], &sb) != 0
729                          || (sb.st_mode & S_IFMT) != S_IFREG
730                          || (sb.st_mode & 077) != 0) {
731                                 result = 1;
732                         }
733                         close(fd);
734                 }
735         }
736         if (result == 0
737          && !strcmp(name[0], name[1]))
738                 result = 1;
739         ${cf_cv_main_return:-return}(result);
740 }
741 ],[cf_cv_func_mkstemp=yes
742 ],[cf_cv_func_mkstemp=no
743 ],[AC_CHECK_FUNC(mkstemp)
744 ])
745 ])
746 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
747         AC_DEFINE(HAVE_MKSTEMP)
748 fi
749 ])dnl
750 dnl ---------------------------------------------------------------------------
751 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
752 dnl ----------
753 dnl Write a debug message to config.log, along with the line number in the
754 dnl configure script.
755 AC_DEFUN([CF_MSG_LOG],[
756 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
757 ])dnl
758 dnl ---------------------------------------------------------------------------
759 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
760 dnl ------------------
761 dnl see CF_WITH_NO_LEAKS
762 AC_DEFUN([CF_NO_LEAKS_OPTION],[
763 AC_MSG_CHECKING(if you want to use $1 for testing)
764 AC_ARG_WITH($1,
765         [$2],
766         [AC_DEFINE($3)ifelse([$4],,[
767          $4
768 ])
769         : ${with_cflags:=-g}
770         : ${with_no_leaks:=yes}
771          with_$1=yes],
772         [with_$1=])
773 AC_MSG_RESULT(${with_$1:-no})
774
775 case .$with_cflags in #(vi
776 .*-g*)
777         case .$CFLAGS in #(vi
778         .*-g*) #(vi
779                 ;;
780         *)
781                 CF_ADD_CFLAGS([-g])
782                 ;;
783         esac
784         ;;
785 esac
786 ])dnl
787 dnl ---------------------------------------------------------------------------
788 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
789 dnl -----------------
790 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
791 dnl
792 dnl     POSIX.1-1990                            _POSIX_SOURCE
793 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
794 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
795 dnl             Bindings Option
796 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
797 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
798 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
799 dnl
800 dnl Parameters:
801 dnl     $1 is the nominal value for _POSIX_C_SOURCE
802 AC_DEFUN([CF_POSIX_C_SOURCE],
803 [
804 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
805
806 cf_save_CFLAGS="$CFLAGS"
807 cf_save_CPPFLAGS="$CPPFLAGS"
808
809 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
810 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
811
812 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
813         CF_MSG_LOG(if the symbol is already defined go no further)
814         AC_TRY_COMPILE([#include <sys/types.h>],[
815 #ifndef _POSIX_C_SOURCE
816 make an error
817 #endif],
818         [cf_cv_posix_c_source=no],
819         [cf_want_posix_source=no
820          case .$cf_POSIX_C_SOURCE in #(vi
821          .[[12]]??*) #(vi
822                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
823                 ;;
824          .2) #(vi
825                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
826                 cf_want_posix_source=yes
827                 ;;
828          .*)
829                 cf_want_posix_source=yes
830                 ;;
831          esac
832          if test "$cf_want_posix_source" = yes ; then
833                 AC_TRY_COMPILE([#include <sys/types.h>],[
834 #ifdef _POSIX_SOURCE
835 make an error
836 #endif],[],
837                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
838          fi
839          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
840          CFLAGS="$cf_trim_CFLAGS"
841          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
842          CF_MSG_LOG(if the second compile does not leave our definition intact error)
843          AC_TRY_COMPILE([#include <sys/types.h>],[
844 #ifndef _POSIX_C_SOURCE
845 make an error
846 #endif],,
847          [cf_cv_posix_c_source=no])
848          CFLAGS="$cf_save_CFLAGS"
849          CPPFLAGS="$cf_save_CPPFLAGS"
850         ])
851 ])
852
853 if test "$cf_cv_posix_c_source" != no ; then
854         CFLAGS="$cf_trim_CFLAGS"
855         CPPFLAGS="$cf_trim_CPPFLAGS"
856         CF_ADD_CFLAGS($cf_cv_posix_c_source)
857 fi
858
859 ])dnl
860 dnl ---------------------------------------------------------------------------
861 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
862 dnl -----------
863 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
864 AC_DEFUN([CF_PROG_EXT],
865 [
866 AC_REQUIRE([CF_CHECK_CACHE])
867 case $cf_cv_system_name in
868 os2*)
869     CFLAGS="$CFLAGS -Zmt"
870     CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
871     CXXFLAGS="$CXXFLAGS -Zmt"
872     # autoconf's macro sets -Zexe and suffix both, which conflict:w
873     LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
874     ac_cv_exeext=.exe
875     ;;
876 esac
877
878 AC_EXEEXT
879 AC_OBJEXT
880
881 PROG_EXT="$EXEEXT"
882 AC_SUBST(PROG_EXT)
883 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
884 ])dnl
885 dnl ---------------------------------------------------------------------------
886 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
887 dnl ------------
888 AC_DEFUN([CF_PROG_LINT],
889 [
890 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
891 AC_SUBST(LINT_OPTS)
892 ])dnl
893 dnl ---------------------------------------------------------------------------
894 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
895 dnl ----------------
896 dnl Remove all -U and -D options that refer to the given symbol from a list
897 dnl of C compiler options.  This works around the problem that not all
898 dnl compilers process -U and -D options from left-to-right, so a -U option
899 dnl cannot be used to cancel the effect of a preceding -D option.
900 dnl
901 dnl $1 = target (which could be the same as the source variable)
902 dnl $2 = source (including '$')
903 dnl $3 = symbol to remove
904 define([CF_REMOVE_DEFINE],
905 [
906 $1=`echo "$2" | \
907         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
908                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
909 ])dnl
910 dnl ---------------------------------------------------------------------------
911 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
912 dnl -------------------
913 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
914 dnl can define it successfully.
915 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
916 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
917         AC_TRY_COMPILE([
918 #include <stdlib.h>
919 #include <string.h>
920 #include <sys/types.h>
921 ],[
922 #ifndef _XOPEN_SOURCE
923 make an error
924 #endif],
925         [cf_cv_xopen_source=no],
926         [cf_save="$CPPFLAGS"
927          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
928          AC_TRY_COMPILE([
929 #include <stdlib.h>
930 #include <string.h>
931 #include <sys/types.h>
932 ],[
933 #ifdef _XOPEN_SOURCE
934 make an error
935 #endif],
936         [cf_cv_xopen_source=no],
937         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
938         CPPFLAGS="$cf_save"
939         ])
940 ])
941
942 if test "$cf_cv_xopen_source" != no ; then
943         CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
944         CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
945         cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
946         CF_ADD_CFLAGS($cf_temp_xopen_source)
947 fi
948 ])
949 dnl ---------------------------------------------------------------------------
950 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
951 dnl --------
952 dnl Make an uppercase version of a variable
953 dnl $1=uppercase($2)
954 AC_DEFUN([CF_UPPER],
955 [
956 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
957 ])dnl
958 dnl ---------------------------------------------------------------------------
959 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
960 dnl ----------
961 dnl Use AC_VERBOSE w/o the warnings
962 AC_DEFUN([CF_VERBOSE],
963 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
964 CF_MSG_LOG([$1])
965 ])dnl
966 dnl ---------------------------------------------------------------------------
967 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
968 dnl ----------------
969 dnl Configure-option for dbmalloc.  The optional parameter is used to override
970 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
971 AC_DEFUN([CF_WITH_DBMALLOC],[
972 CF_NO_LEAKS_OPTION(dbmalloc,
973         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
974         [USE_DBMALLOC])
975
976 if test "$with_dbmalloc" = yes ; then
977         AC_CHECK_HEADER(dbmalloc.h,
978                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
979 fi
980 ])dnl
981 dnl ---------------------------------------------------------------------------
982 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
983 dnl ---------------
984 dnl Configure-option for dmalloc.  The optional parameter is used to override
985 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
986 AC_DEFUN([CF_WITH_DMALLOC],[
987 CF_NO_LEAKS_OPTION(dmalloc,
988         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
989         [USE_DMALLOC])
990
991 if test "$with_dmalloc" = yes ; then
992         AC_CHECK_HEADER(dmalloc.h,
993                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
994 fi
995 ])dnl
996 dnl ---------------------------------------------------------------------------
997 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
998 dnl ----------------
999 AC_DEFUN([CF_WITH_VALGRIND],[
1000 CF_NO_LEAKS_OPTION(valgrind,
1001         [  --with-valgrind         test: use valgrind],
1002         [USE_VALGRIND])
1003 ])dnl
1004 dnl ---------------------------------------------------------------------------
1005 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1006 dnl ----------------
1007 dnl Combine the checks for gcc features into a configure-script option
1008 dnl
1009 dnl Parameters:
1010 dnl     $1 - see CF_GCC_WARNINGS
1011 AC_DEFUN([CF_WITH_WARNINGS],
1012 [
1013 if ( test "$GCC" = yes || test "$GXX" = yes )
1014 then
1015 AC_MSG_CHECKING(if you want to check for gcc warnings)
1016 AC_ARG_WITH(warnings,
1017         [  --with-warnings         test: turn on gcc warnings],
1018         [cf_opt_with_warnings=$withval],
1019         [cf_opt_with_warnings=no])
1020 AC_MSG_RESULT($cf_opt_with_warnings)
1021 if test "$cf_opt_with_warnings" != no ; then
1022         CF_GCC_ATTRIBUTES
1023         CF_GCC_WARNINGS([$1])
1024 fi
1025 fi
1026 ])dnl
1027 dnl ---------------------------------------------------------------------------
1028 dnl CF_XOPEN_SOURCE version: 42 updated: 2012/01/07 08:26:49
1029 dnl ---------------
1030 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1031 dnl or adapt to the vendor's definitions to get equivalent functionality,
1032 dnl without losing the common non-POSIX features.
1033 dnl
1034 dnl Parameters:
1035 dnl     $1 is the nominal value for _XOPEN_SOURCE
1036 dnl     $2 is the nominal value for _POSIX_C_SOURCE
1037 AC_DEFUN([CF_XOPEN_SOURCE],[
1038
1039 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1040 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1041 cf_xopen_source=
1042
1043 case $host_os in #(vi
1044 aix[[4-7]]*) #(vi
1045         cf_xopen_source="-D_ALL_SOURCE"
1046         ;;
1047 cygwin) #(vi
1048         cf_XOPEN_SOURCE=600
1049         ;;
1050 darwin[[0-8]].*) #(vi
1051         cf_xopen_source="-D_APPLE_C_SOURCE"
1052         ;;
1053 darwin*) #(vi
1054         cf_xopen_source="-D_DARWIN_C_SOURCE"
1055         cf_XOPEN_SOURCE=
1056         ;;
1057 freebsd*|dragonfly*) #(vi
1058         # 5.x headers associate
1059         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1060         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1061         cf_POSIX_C_SOURCE=200112L
1062         cf_XOPEN_SOURCE=600
1063         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1064         ;;
1065 hpux11*) #(vi
1066         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1067         ;;
1068 hpux*) #(vi
1069         cf_xopen_source="-D_HPUX_SOURCE"
1070         ;;
1071 irix[[56]].*) #(vi
1072         cf_xopen_source="-D_SGI_SOURCE"
1073         cf_XOPEN_SOURCE=
1074         ;;
1075 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
1076         CF_GNU_SOURCE
1077         ;;
1078 mirbsd*) #(vi
1079         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1080         cf_XOPEN_SOURCE=
1081         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1082         ;;
1083 netbsd*) #(vi
1084         cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1085         ;;
1086 openbsd[[4-9]]*) #(vi
1087         # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1088         cf_xopen_source="-D_BSD_SOURCE"
1089         cf_XOPEN_SOURCE=600
1090         ;;
1091 openbsd*) #(vi
1092         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1093         ;;
1094 osf[[45]]*) #(vi
1095         cf_xopen_source="-D_OSF_SOURCE"
1096         ;;
1097 nto-qnx*) #(vi
1098         cf_xopen_source="-D_QNX_SOURCE"
1099         ;;
1100 sco*) #(vi
1101         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1102         ;;
1103 solaris2.*) #(vi
1104         cf_xopen_source="-D__EXTENSIONS__"
1105         ;;
1106 *)
1107         CF_TRY_XOPEN_SOURCE
1108         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1109         ;;
1110 esac
1111
1112 if test -n "$cf_xopen_source" ; then
1113         CF_ADD_CFLAGS($cf_xopen_source)
1114 fi
1115
1116 dnl In anything but the default case, we may have system-specific setting
1117 dnl which is still not guaranteed to provide all of the entrypoints that
1118 dnl _XOPEN_SOURCE would yield.
1119 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1120         AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1121         AC_TRY_COMPILE([#include <stdlib.h>],[
1122 #ifndef _XOPEN_SOURCE
1123 make an error
1124 #endif],
1125         [cf_XOPEN_SOURCE_set=yes],
1126         [cf_XOPEN_SOURCE_set=no])
1127         AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1128         if test $cf_XOPEN_SOURCE_set = yes
1129         then
1130                 AC_TRY_COMPILE([#include <stdlib.h>],[
1131 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1132 make an error
1133 #endif],
1134                 [cf_XOPEN_SOURCE_set_ok=yes],
1135                 [cf_XOPEN_SOURCE_set_ok=no])
1136                 if test $cf_XOPEN_SOURCE_set_ok = no
1137                 then
1138                         AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1139                 fi
1140         else
1141                 CF_TRY_XOPEN_SOURCE
1142         fi
1143 fi
1144 ])