xref: /freebsd/contrib/byacc/aclocal.m4 (revision 641a6cfb86023499caafe26a4d821a0b885cf00b)
1dnl $Id: aclocal.m4,v 1.19 2012/01/13 14:10:56 tom Exp $
2dnl Macros for byacc configure script (Thomas E. Dickey)
3dnl ---------------------------------------------------------------------------
4dnl Copyright 2004-2011,2012 Thomas E. Dickey
5dnl
6dnl Permission is hereby granted, free of charge, to any person obtaining a
7dnl copy of this software and associated documentation files (the
8dnl "Software"), to deal in the Software without restriction, including
9dnl without limitation the rights to use, copy, modify, merge, publish,
10dnl distribute, distribute with modifications, sublicense, and/or sell
11dnl copies of the Software, and to permit persons to whom the Software is
12dnl furnished to do so, subject to the following conditions:
13dnl
14dnl The above copyright notice and this permission notice shall be included
15dnl in all copies or portions of the Software.
16dnl
17dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24dnl
25dnl Except as contained in this notice, the name(s) of the above copyright
26dnl holders shall not be used in advertising or otherwise to promote the
27dnl sale, use or other dealings in this Software without prior written
28dnl authorization.
29dnl ---------------------------------------------------------------------------
30dnl ---------------------------------------------------------------------------
31dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
32dnl -------------
33dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
34dnl The second parameter if given makes this macro verbose.
35dnl
36dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
37dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
38dnl confused by the quotes (which require backslashes to keep them usable).
39AC_DEFUN([CF_ADD_CFLAGS],
40[
41cf_fix_cppflags=no
42cf_new_cflags=
43cf_new_cppflags=
44cf_new_extra_cppflags=
45
46for cf_add_cflags in $1
47do
48case $cf_fix_cppflags in
49no)
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	;;
88yes)
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	;;
97esac
98done
99
100if test -n "$cf_new_cflags" ; then
101	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
102	CFLAGS="$CFLAGS $cf_new_cflags"
103fi
104
105if test -n "$cf_new_cppflags" ; then
106	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
107	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
108fi
109
110if 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"
113fi
114
115AC_SUBST(EXTRA_CPPFLAGS)
116
117])dnl
118dnl ---------------------------------------------------------------------------
119dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
120dnl ----------------
121dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
122dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
123AC_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.
131AC_MSG_CHECKING(\$CC variable)
132case "$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	;;
144esac
145
146AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
147cf_cv_ansi_cc=no
148cf_save_CFLAGS="$CFLAGS"
149cf_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)
157for cf_arg in "-DCC_HAS_PROTOS" \
158	"" \
159	-qlanglvl=ansi \
160	-std1 \
161	-Ae \
162	"-Aa -D_HPUX_SOURCE" \
163	-Xc
164do
165	CF_ADD_CFLAGS($cf_arg)
166	AC_TRY_COMPILE(
167[
168#ifndef CC_HAS_PROTOS
169#if !defined(__STDC__) || (__STDC__ != 1)
170choke 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])
178done
179CFLAGS="$cf_save_CFLAGS"
180CPPFLAGS="$cf_save_CPPFLAGS"
181])
182
183if test "$cf_cv_ansi_cc" != "no"; then
184if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
185	CF_ADD_CFLAGS($cf_cv_ansi_cc)
186else
187	AC_DEFINE(CC_HAS_PROTOS)
188fi
189fi
190])dnl
191dnl ---------------------------------------------------------------------------
192dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
193dnl ---------------
194dnl For programs that must use an ANSI compiler, obtain compiler options that
195dnl will make it recognize prototypes.  We'll do preprocessor checks in other
196dnl macros, since tools such as unproto can fake prototypes, but only part of
197dnl the preprocessor.
198AC_DEFUN([CF_ANSI_CC_REQD],
199[AC_REQUIRE([CF_ANSI_CC_CHECK])
200if test "$cf_cv_ansi_cc" = "no"; then
201	AC_MSG_ERROR(
202[Your compiler does not appear to recognize prototypes.
203You 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])
207fi
208])dnl
209dnl ---------------------------------------------------------------------------
210dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
211dnl --------------
212dnl Allow user to disable a normally-on option.
213AC_DEFUN([CF_ARG_DISABLE],
214[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
215dnl ---------------------------------------------------------------------------
216dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
217dnl -------------
218dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
219dnl values.
220dnl
221dnl Parameters:
222dnl $1 = option name
223dnl $2 = help-string
224dnl $3 = action to perform if option is not default
225dnl $4 = action if perform if option is default
226dnl $5 = default option value (either 'yes' or 'no')
227AC_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
230ifelse([$3],,[    :]dnl
231,[    $3]) ifelse([$4],,,[
232  else
233    $4])
234  fi],[enableval=$5 ifelse([$4],,,[
235  $4
236])dnl
237  ])])dnl
238dnl ---------------------------------------------------------------------------
239dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
240dnl --------------
241dnl Check if we're accidentally using a cache from a different machine.
242dnl Derive the system name, as a check for reusing the autoconf cache.
243dnl
244dnl If we've packaged config.guess and config.sub, run that (since it does a
245dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
246dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
247dnl which is useful in cross-compiles.
248dnl
249dnl Note: we would use $ac_config_sub, but that is one of the places where
250dnl autoconf 2.5x broke compatibility with autoconf 2.13
251AC_DEFUN([CF_CHECK_CACHE],
252[
253if 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"
256else
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
261fi
262test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
263AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
264
265test -z "$system_name" && system_name="$cf_cv_system_name"
266test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
267
268if 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.")
271fi
272])dnl
273dnl ---------------------------------------------------------------------------
274dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
275dnl ---------------
276dnl You can always use "make -n" to see the actual options, but it's hard to
277dnl pick out/analyze warning messages when the compile-line is long.
278dnl
279dnl Sets:
280dnl	ECHO_LT - symbol to control if libtool is verbose
281dnl	ECHO_LD - symbol to prefix "cc -o" lines
282dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
283dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
284dnl	ECHO_CC - symbol to put before any "cc" line
285dnl
286AC_DEFUN([CF_DISABLE_ECHO],[
287AC_MSG_CHECKING(if you want to see long compiling messages)
288CF_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])
303AC_MSG_RESULT($enableval)
304AC_SUBST(ECHO_LT)
305AC_SUBST(ECHO_LD)
306AC_SUBST(RULE_CC)
307AC_SUBST(SHOW_CC)
308AC_SUBST(ECHO_CC)
309])dnl
310dnl ---------------------------------------------------------------------------
311dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
312dnl ----------------
313dnl Combine no-leak checks with the libraries or tools that are used for the
314dnl checks.
315AC_DEFUN([CF_DISABLE_LEAKS],[
316
317AC_REQUIRE([CF_WITH_DMALLOC])
318AC_REQUIRE([CF_WITH_DBMALLOC])
319AC_REQUIRE([CF_WITH_VALGRIND])
320
321AC_MSG_CHECKING(if you want to perform memory-leak testing)
322AC_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})
326AC_MSG_RESULT($with_no_leaks)
327
328if test "$with_no_leaks" = yes ; then
329	AC_DEFINE(NO_LEAKS)
330	AC_DEFINE(YY_NO_LEAKS)
331fi
332])dnl
333dnl ---------------------------------------------------------------------------
334dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
335dnl -----------------
336dnl Test for availability of useful gcc __attribute__ directives to quiet
337dnl compiler warnings.  Though useful, not all are supported -- and contrary
338dnl to documentation, unrecognized directives cause older compilers to barf.
339AC_DEFUN([CF_GCC_ATTRIBUTES],
340[
341if test "$GCC" = yes
342then
343cat > 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
356EOF
357if test "$GCC" = yes
358then
359	AC_CHECKING([for $CC __attribute__ directives])
360cat > 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
375extern void wow(char *,...) GCC_SCANFLIKE(1,2);
376extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
377extern void foo(void) GCC_NORETURN;
378int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
379EOF
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
393EOF
394			;;
395		scanf) #(vi
396			cf_scanf_attribute=yes
397			cat >conftest.h <<EOF
398#define GCC_$cf_ATTRIBUTE 1
399EOF
400			;;
401		*) #(vi
402			cat >conftest.h <<EOF
403#define GCC_$cf_ATTRIBUTE $cf_directive
404EOF
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 */
416EOF
417				else
418					cat >>confdefs.h <<EOF
419#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
420EOF
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 */
427EOF
428				else
429					cat >>confdefs.h <<EOF
430#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
431EOF
432				fi
433				;;
434			esac
435		fi
436	done
437else
438	fgrep define conftest.i >>confdefs.h
439fi
440rm -rf conftest*
441fi
442])dnl
443dnl ---------------------------------------------------------------------------
444dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
445dnl --------------
446dnl Find version of gcc
447AC_DEFUN([CF_GCC_VERSION],[
448AC_REQUIRE([AC_PROG_CC])
449GCC_VERSION=none
450if 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)
455fi
456])dnl
457dnl ---------------------------------------------------------------------------
458dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
459dnl ---------------
460dnl Check if the compiler supports useful warning options.  There's a few that
461dnl we don't use, simply because they're too noisy:
462dnl
463dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
464dnl	-Wredundant-decls (system headers make this too noisy)
465dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
466dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
467dnl		is enabled for ncurses using "--enable-const".
468dnl	-pedantic
469dnl
470dnl Parameter:
471dnl	$1 is an optional list of gcc warning flags that a particular
472dnl		application might want to use, e.g., "no-unused" for
473dnl		-Wno-unused
474dnl Special:
475dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
476dnl
477AC_DEFUN([CF_GCC_WARNINGS],
478[
479AC_REQUIRE([CF_GCC_VERSION])
480CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
481
482cat > conftest.$ac_ext <<EOF
483#line __oline__ "${as_me:-configure}"
484int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
485EOF
486
487if test "$INTEL_COMPILER" = yes
488then
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
522elif test "$GCC" = yes
523then
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"
561fi
562rm -rf conftest*
563
564AC_SUBST(EXTRA_CFLAGS)
565])dnl
566dnl ---------------------------------------------------------------------------
567dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
568dnl -------------
569dnl Check if we must define _GNU_SOURCE to get a reasonable value for
570dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
571dnl (or misfeature) of glibc2, which breaks portability of many applications,
572dnl since it is interwoven with GNU extensions.
573dnl
574dnl Well, yes we could work around it...
575AC_DEFUN([CF_GNU_SOURCE],
576[
577AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
578AC_TRY_COMPILE([#include <sys/types.h>],[
579#ifndef _XOPEN_SOURCE
580make 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
587make an error
588#endif],
589	[cf_cv_gnu_source=no],
590	[cf_cv_gnu_source=yes])
591	CPPFLAGS="$cf_save"
592	])
593])
594test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
595])dnl
596dnl ---------------------------------------------------------------------------
597dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
598dnl -----------------
599dnl Check if the given compiler is really the Intel compiler for Linux.  It
600dnl tries to imitate gcc, but does not return an error when it finds a mismatch
601dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
602dnl
603dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
604dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
605dnl the wrappers for gcc and g++ warnings.
606dnl
607dnl $1 = GCC (default) or GXX
608dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
609dnl $3 = CFLAGS (default) or CXXFLAGS
610AC_DEFUN([CF_INTEL_COMPILER],[
611ifelse([$2],,INTEL_COMPILER,[$2])=no
612
613if 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
622make an error
623#endif
624],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
625cf_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
631fi
632])dnl
633dnl ---------------------------------------------------------------------------
634dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
635dnl ------------
636dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
637dnl a monocase filesystem.
638AC_DEFUN([CF_MAKE_TAGS],[
639AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
640
641AC_CHECK_PROGS(CTAGS, exctags ctags)
642AC_CHECK_PROGS(ETAGS, exetags etags)
643
644AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
645
646if test "$cf_cv_mixedcase" = yes ; then
647	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
648else
649	MAKE_UPPER_TAGS=no
650fi
651
652if test "$MAKE_UPPER_TAGS" = yes ; then
653	MAKE_UPPER_TAGS=
654else
655	MAKE_UPPER_TAGS="#"
656fi
657
658if test "$MAKE_LOWER_TAGS" = yes ; then
659	MAKE_LOWER_TAGS=
660else
661	MAKE_LOWER_TAGS="#"
662fi
663
664AC_SUBST(CTAGS)
665AC_SUBST(ETAGS)
666
667AC_SUBST(MAKE_UPPER_TAGS)
668AC_SUBST(MAKE_LOWER_TAGS)
669])dnl
670dnl ---------------------------------------------------------------------------
671dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
672dnl ----------------------
673dnl Check if the file-system supports mixed-case filenames.  If we're able to
674dnl create a lowercase name and see it as uppercase, it doesn't support that.
675AC_DEFUN([CF_MIXEDCASE_FILENAMES],
676[
677AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
678if 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
687else
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
696fi
697])
698test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
699])dnl
700dnl ---------------------------------------------------------------------------
701dnl CF_MKSTEMP version: 7 updated: 2010/08/14 18:25:37
702dnl ----------
703dnl Check for a working mkstemp.  This creates two files, checks that they are
704dnl successfully created and distinct (AmigaOS apparently fails on the last).
705AC_DEFUN([CF_MKSTEMP],[
706AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
707rm -rf conftest*
708AC_TRY_RUN([
709#include <sys/types.h>
710#include <stdlib.h>
711#include <stdio.h>
712#include <string.h>
713#include <sys/stat.h>
714int 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])
746if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
747	AC_DEFINE(HAVE_MKSTEMP)
748fi
749])dnl
750dnl ---------------------------------------------------------------------------
751dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
752dnl ----------
753dnl Write a debug message to config.log, along with the line number in the
754dnl configure script.
755AC_DEFUN([CF_MSG_LOG],[
756echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
757])dnl
758dnl ---------------------------------------------------------------------------
759dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
760dnl ------------------
761dnl see CF_WITH_NO_LEAKS
762AC_DEFUN([CF_NO_LEAKS_OPTION],[
763AC_MSG_CHECKING(if you want to use $1 for testing)
764AC_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=])
773AC_MSG_RESULT(${with_$1:-no})
774
775case .$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	;;
785esac
786])dnl
787dnl ---------------------------------------------------------------------------
788dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
789dnl -----------------
790dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
791dnl
792dnl	POSIX.1-1990				_POSIX_SOURCE
793dnl	POSIX.1-1990 and			_POSIX_SOURCE and
794dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
795dnl		Bindings Option
796dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
797dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
798dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
799dnl
800dnl Parameters:
801dnl	$1 is the nominal value for _POSIX_C_SOURCE
802AC_DEFUN([CF_POSIX_C_SOURCE],
803[
804cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
805
806cf_save_CFLAGS="$CFLAGS"
807cf_save_CPPFLAGS="$CPPFLAGS"
808
809CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
810CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
811
812AC_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
816make 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
835make 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
845make an error
846#endif],,
847	 [cf_cv_posix_c_source=no])
848	 CFLAGS="$cf_save_CFLAGS"
849	 CPPFLAGS="$cf_save_CPPFLAGS"
850	])
851])
852
853if 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)
857fi
858
859])dnl
860dnl ---------------------------------------------------------------------------
861dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
862dnl -----------
863dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
864AC_DEFUN([CF_PROG_EXT],
865[
866AC_REQUIRE([CF_CHECK_CACHE])
867case $cf_cv_system_name in
868os2*)
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    ;;
876esac
877
878AC_EXEEXT
879AC_OBJEXT
880
881PROG_EXT="$EXEEXT"
882AC_SUBST(PROG_EXT)
883test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
884])dnl
885dnl ---------------------------------------------------------------------------
886dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
887dnl ------------
888AC_DEFUN([CF_PROG_LINT],
889[
890AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
891AC_SUBST(LINT_OPTS)
892])dnl
893dnl ---------------------------------------------------------------------------
894dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
895dnl ----------------
896dnl Remove all -U and -D options that refer to the given symbol from a list
897dnl of C compiler options.  This works around the problem that not all
898dnl compilers process -U and -D options from left-to-right, so a -U option
899dnl cannot be used to cancel the effect of a preceding -D option.
900dnl
901dnl $1 = target (which could be the same as the source variable)
902dnl $2 = source (including '$')
903dnl $3 = symbol to remove
904define([CF_REMOVE_DEFINE],
905[
906$1=`echo "$2" | \
907	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
908		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
909])dnl
910dnl ---------------------------------------------------------------------------
911dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
912dnl -------------------
913dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
914dnl can define it successfully.
915AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
916AC_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
923make 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
934make 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
942if 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)
947fi
948])
949dnl ---------------------------------------------------------------------------
950dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
951dnl --------
952dnl Make an uppercase version of a variable
953dnl $1=uppercase($2)
954AC_DEFUN([CF_UPPER],
955[
956$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
957])dnl
958dnl ---------------------------------------------------------------------------
959dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
960dnl ----------
961dnl Use AC_VERBOSE w/o the warnings
962AC_DEFUN([CF_VERBOSE],
963[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
964CF_MSG_LOG([$1])
965])dnl
966dnl ---------------------------------------------------------------------------
967dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
968dnl ----------------
969dnl Configure-option for dbmalloc.  The optional parameter is used to override
970dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
971AC_DEFUN([CF_WITH_DBMALLOC],[
972CF_NO_LEAKS_OPTION(dbmalloc,
973	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
974	[USE_DBMALLOC])
975
976if test "$with_dbmalloc" = yes ; then
977	AC_CHECK_HEADER(dbmalloc.h,
978		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
979fi
980])dnl
981dnl ---------------------------------------------------------------------------
982dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
983dnl ---------------
984dnl Configure-option for dmalloc.  The optional parameter is used to override
985dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
986AC_DEFUN([CF_WITH_DMALLOC],[
987CF_NO_LEAKS_OPTION(dmalloc,
988	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
989	[USE_DMALLOC])
990
991if test "$with_dmalloc" = yes ; then
992	AC_CHECK_HEADER(dmalloc.h,
993		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
994fi
995])dnl
996dnl ---------------------------------------------------------------------------
997dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
998dnl ----------------
999AC_DEFUN([CF_WITH_VALGRIND],[
1000CF_NO_LEAKS_OPTION(valgrind,
1001	[  --with-valgrind         test: use valgrind],
1002	[USE_VALGRIND])
1003])dnl
1004dnl ---------------------------------------------------------------------------
1005dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1006dnl ----------------
1007dnl Combine the checks for gcc features into a configure-script option
1008dnl
1009dnl Parameters:
1010dnl	$1 - see CF_GCC_WARNINGS
1011AC_DEFUN([CF_WITH_WARNINGS],
1012[
1013if ( test "$GCC" = yes || test "$GXX" = yes )
1014then
1015AC_MSG_CHECKING(if you want to check for gcc warnings)
1016AC_ARG_WITH(warnings,
1017	[  --with-warnings         test: turn on gcc warnings],
1018	[cf_opt_with_warnings=$withval],
1019	[cf_opt_with_warnings=no])
1020AC_MSG_RESULT($cf_opt_with_warnings)
1021if test "$cf_opt_with_warnings" != no ; then
1022	CF_GCC_ATTRIBUTES
1023	CF_GCC_WARNINGS([$1])
1024fi
1025fi
1026])dnl
1027dnl ---------------------------------------------------------------------------
1028dnl CF_XOPEN_SOURCE version: 42 updated: 2012/01/07 08:26:49
1029dnl ---------------
1030dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1031dnl or adapt to the vendor's definitions to get equivalent functionality,
1032dnl without losing the common non-POSIX features.
1033dnl
1034dnl Parameters:
1035dnl	$1 is the nominal value for _XOPEN_SOURCE
1036dnl	$2 is the nominal value for _POSIX_C_SOURCE
1037AC_DEFUN([CF_XOPEN_SOURCE],[
1038
1039cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1040cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1041cf_xopen_source=
1042
1043case $host_os in #(vi
1044aix[[4-7]]*) #(vi
1045	cf_xopen_source="-D_ALL_SOURCE"
1046	;;
1047cygwin) #(vi
1048	cf_XOPEN_SOURCE=600
1049	;;
1050darwin[[0-8]].*) #(vi
1051	cf_xopen_source="-D_APPLE_C_SOURCE"
1052	;;
1053darwin*) #(vi
1054	cf_xopen_source="-D_DARWIN_C_SOURCE"
1055	cf_XOPEN_SOURCE=
1056	;;
1057freebsd*|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	;;
1065hpux11*) #(vi
1066	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1067	;;
1068hpux*) #(vi
1069	cf_xopen_source="-D_HPUX_SOURCE"
1070	;;
1071irix[[56]].*) #(vi
1072	cf_xopen_source="-D_SGI_SOURCE"
1073	cf_XOPEN_SOURCE=
1074	;;
1075linux*|gnu*|mint*|k*bsd*-gnu) #(vi
1076	CF_GNU_SOURCE
1077	;;
1078mirbsd*) #(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	;;
1083netbsd*) #(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	;;
1086openbsd[[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	;;
1091openbsd*) #(vi
1092	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1093	;;
1094osf[[45]]*) #(vi
1095	cf_xopen_source="-D_OSF_SOURCE"
1096	;;
1097nto-qnx*) #(vi
1098	cf_xopen_source="-D_QNX_SOURCE"
1099	;;
1100sco*) #(vi
1101	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1102	;;
1103solaris2.*) #(vi
1104	cf_xopen_source="-D__EXTENSIONS__"
1105	;;
1106*)
1107	CF_TRY_XOPEN_SOURCE
1108	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1109	;;
1110esac
1111
1112if test -n "$cf_xopen_source" ; then
1113	CF_ADD_CFLAGS($cf_xopen_source)
1114fi
1115
1116dnl In anything but the default case, we may have system-specific setting
1117dnl which is still not guaranteed to provide all of the entrypoints that
1118dnl _XOPEN_SOURCE would yield.
1119if 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
1123make 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
1132make 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
1143fi
1144])
1145