xref: /netbsd-src/external/bsd/byacc/dist/aclocal.m4 (revision e6c7e151de239c49d2e38720a061ed9d1fa99309)
1dnl Id: aclocal.m4,v 1.46 2019/06/16 13:58:05 tom Exp
2dnl Macros for byacc configure script (Thomas E. Dickey)
3dnl ---------------------------------------------------------------------------
4dnl Copyright 2004-2018,2019 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_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
32dnl ------------------
33dnl Conditionally generate script according to whether we're using a given autoconf.
34dnl
35dnl $1 = version to compare against
36dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
37dnl $3 = code to use if AC_ACVERSION is older than $1.
38define([CF_ACVERSION_CHECK],
39[
40ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
41ifdef([m4_version_compare],
42[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
43[CF_ACVERSION_COMPARE(
44AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
45AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
46dnl ---------------------------------------------------------------------------
47dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
48dnl --------------------
49dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
50dnl                      MAJOR2, MINOR2, TERNARY2,
51dnl                      PRINTABLE2, not FOUND, FOUND)
52define([CF_ACVERSION_COMPARE],
53[ifelse(builtin([eval], [$2 < $5]), 1,
54[ifelse([$8], , ,[$8])],
55[ifelse([$9], , ,[$9])])])dnl
56dnl ---------------------------------------------------------------------------
57dnl CF_ADD_CFLAGS version: 13 updated: 2017/02/25 18:57:40
58dnl -------------
59dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
60dnl The second parameter if given makes this macro verbose.
61dnl
62dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
63dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
64dnl confused by the quotes (which require backslashes to keep them usable).
65AC_DEFUN([CF_ADD_CFLAGS],
66[
67cf_fix_cppflags=no
68cf_new_cflags=
69cf_new_cppflags=
70cf_new_extra_cppflags=
71
72for cf_add_cflags in $1
73do
74case $cf_fix_cppflags in
75(no)
76	case $cf_add_cflags in
77	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
78		case $cf_add_cflags in
79		(-D*)
80			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
81
82			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
83				&& test -z "${cf_tst_cflags}" \
84				&& cf_fix_cppflags=yes
85
86			if test $cf_fix_cppflags = yes ; then
87				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
88				continue
89			elif test "${cf_tst_cflags}" = "\"'" ; then
90				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
91				continue
92			fi
93			;;
94		esac
95		case "$CPPFLAGS" in
96		(*$cf_add_cflags)
97			;;
98		(*)
99			case $cf_add_cflags in
100			(-D*)
101				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
102				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
103				;;
104			esac
105			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
106			;;
107		esac
108		;;
109	(*)
110		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
111		;;
112	esac
113	;;
114(yes)
115	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
116
117	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
118
119	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
120		&& test -z "${cf_tst_cflags}" \
121		&& cf_fix_cppflags=no
122	;;
123esac
124done
125
126if test -n "$cf_new_cflags" ; then
127	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
128	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
129fi
130
131if test -n "$cf_new_cppflags" ; then
132	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
133	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
134fi
135
136if test -n "$cf_new_extra_cppflags" ; then
137	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
138	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
139fi
140
141AC_SUBST(EXTRA_CPPFLAGS)
142
143])dnl
144dnl ---------------------------------------------------------------------------
145dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
146dnl --------------
147dnl use this macro for appending text without introducing an extra blank at
148dnl the beginning
149define([CF_APPEND_TEXT],
150[
151	test -n "[$]$1" && $1="[$]$1 "
152	$1="[$]{$1}$2"
153])dnl
154dnl ---------------------------------------------------------------------------
155dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
156dnl --------------
157dnl Allow user to disable a normally-on option.
158AC_DEFUN([CF_ARG_DISABLE],
159[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
160dnl ---------------------------------------------------------------------------
161dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
162dnl -------------
163dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
164dnl values.
165dnl
166dnl Parameters:
167dnl $1 = option name
168dnl $2 = help-string
169dnl $3 = action to perform if option is not default
170dnl $4 = action if perform if option is default
171dnl $5 = default option value (either 'yes' or 'no')
172AC_DEFUN([CF_ARG_OPTION],
173[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
174	if test "$enableval" != "$5" ; then
175ifelse([$3],,[    :]dnl
176,[    $3]) ifelse([$4],,,[
177	else
178		$4])
179	fi],[enableval=$5 ifelse([$4],,,[
180	$4
181])dnl
182])])dnl
183dnl ---------------------------------------------------------------------------
184dnl CF_CC_ENV_FLAGS version: 9 updated: 2018/07/29 18:03:26
185dnl ---------------
186dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
187dnl into CC.  This will not help with broken scripts that wrap the compiler
188dnl with options, but eliminates a more common category of user confusion.
189dnl
190dnl In particular, it addresses the problem of being able to run the C
191dnl preprocessor in a consistent manner.
192dnl
193dnl Caveat: this also disallows blanks in the pathname for the compiler, but
194dnl the nuisance of having inconsistent settings for compiler and preprocessor
195dnl outweighs that limitation.
196AC_DEFUN([CF_CC_ENV_FLAGS],
197[
198# This should have been defined by AC_PROG_CC
199: ${CC:=cc}
200
201AC_MSG_CHECKING(\$CFLAGS variable)
202case "x$CFLAGS" in
203(*-[[IUD]]*)
204	AC_MSG_RESULT(broken)
205	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
206	cf_flags="$CFLAGS"
207	CFLAGS=
208	for cf_arg in $cf_flags
209	do
210		CF_ADD_CFLAGS($cf_arg)
211	done
212	;;
213(*)
214	AC_MSG_RESULT(ok)
215	;;
216esac
217
218AC_MSG_CHECKING(\$CC variable)
219case "$CC" in
220(*[[\ \	]]-*)
221	AC_MSG_RESULT(broken)
222	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
223	# humor him...
224	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
225	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
226	CC="$cf_prog"
227	for cf_arg in $cf_flags
228	do
229		case "x$cf_arg" in
230		(x-[[IUDfgOW]]*)
231			CF_ADD_CFLAGS($cf_arg)
232			;;
233		(*)
234			CC="$CC $cf_arg"
235			;;
236		esac
237	done
238	CF_VERBOSE(resulting CC: '$CC')
239	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
240	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
241	;;
242(*)
243	AC_MSG_RESULT(ok)
244	;;
245esac
246])dnl
247dnl ---------------------------------------------------------------------------
248dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
249dnl --------------
250dnl Check if we're accidentally using a cache from a different machine.
251dnl Derive the system name, as a check for reusing the autoconf cache.
252dnl
253dnl If we've packaged config.guess and config.sub, run that (since it does a
254dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
255dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
256dnl which is useful in cross-compiles.
257dnl
258dnl Note: we would use $ac_config_sub, but that is one of the places where
259dnl autoconf 2.5x broke compatibility with autoconf 2.13
260AC_DEFUN([CF_CHECK_CACHE],
261[
262if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
263	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
264	system_name="$host_os"
265else
266	system_name="`(uname -s -r) 2>/dev/null`"
267	if test -z "$system_name" ; then
268		system_name="`(hostname) 2>/dev/null`"
269	fi
270fi
271test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
272AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
273
274test -z "$system_name" && system_name="$cf_cv_system_name"
275test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
276
277if test ".$system_name" != ".$cf_cv_system_name" ; then
278	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
279	AC_MSG_ERROR("Please remove config.cache and try again.")
280fi
281])dnl
282dnl ---------------------------------------------------------------------------
283dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
284dnl -----------------
285dnl Check if the given compiler is really clang.  clang's C driver defines
286dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
287dnl not ignore some gcc options.
288dnl
289dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
290dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
291dnl the wrappers for gcc and g++ warnings.
292dnl
293dnl $1 = GCC (default) or GXX
294dnl $2 = CLANG_COMPILER (default)
295dnl $3 = CFLAGS (default) or CXXFLAGS
296AC_DEFUN([CF_CLANG_COMPILER],[
297ifelse([$2],,CLANG_COMPILER,[$2])=no
298
299if test "$ifelse([$1],,[$1],GCC)" = yes ; then
300	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
301	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
302	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
303	AC_TRY_COMPILE([],[
304#ifdef __clang__
305#else
306make an error
307#endif
308],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
309cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
310],[])
311	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
312	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
313fi
314])
315dnl ---------------------------------------------------------------------------
316dnl CF_CONST_X_STRING version: 1 updated: 2019/04/08 17:50:29
317dnl -----------------
318dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
319dnl character-strings.
320dnl
321dnl It is ambiguous because the specification accommodated the pre-ANSI
322dnl compilers bundled by more than one vendor in lieu of providing a standard C
323dnl compiler other than by costly add-ons.  Because of this, the specification
324dnl did not take into account the use of const for telling the compiler that
325dnl string literals would be in readonly memory.
326dnl
327dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
328dnl let the compiler decide how to represent Xt's strings which were #define'd.
329dnl That does not solve the problem of using the block of Xt's strings which
330dnl are compiled into the library (and is less efficient than one might want).
331dnl
332dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
333dnl when compiling the library and compiling using the library, to tell the
334dnl compiler that String is const.
335AC_DEFUN([CF_CONST_X_STRING],
336[
337AC_TRY_COMPILE(
338[
339#include <stdlib.h>
340#include <X11/Intrinsic.h>
341],
342[String foo = malloc(1)],[
343
344AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
345	AC_TRY_COMPILE(
346		[
347#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
348#undef  XTSTRINGDEFINES	/* X11R5 and later */
349#include <stdlib.h>
350#include <X11/Intrinsic.h>
351		],[String foo = malloc(1); *foo = 0],[
352			cf_cv_const_x_string=no
353		],[
354			cf_cv_const_x_string=yes
355		])
356])
357
358case $cf_cv_const_x_string in
359(no)
360	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
361	;;
362(*)
363	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
364	;;
365esac
366
367])
368])dnl
369dnl ---------------------------------------------------------------------------
370dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
371dnl ---------------
372dnl You can always use "make -n" to see the actual options, but it's hard to
373dnl pick out/analyze warning messages when the compile-line is long.
374dnl
375dnl Sets:
376dnl	ECHO_LT - symbol to control if libtool is verbose
377dnl	ECHO_LD - symbol to prefix "cc -o" lines
378dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
379dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
380dnl	ECHO_CC - symbol to put before any "cc" line
381dnl
382AC_DEFUN([CF_DISABLE_ECHO],[
383AC_MSG_CHECKING(if you want to see long compiling messages)
384CF_ARG_DISABLE(echo,
385	[  --disable-echo          do not display "compiling" commands],
386	[
387	ECHO_LT='--silent'
388	ECHO_LD='@echo linking [$]@;'
389	RULE_CC='@echo compiling [$]<'
390	SHOW_CC='@echo compiling [$]@'
391	ECHO_CC='@'
392],[
393	ECHO_LT=''
394	ECHO_LD=''
395	RULE_CC=''
396	SHOW_CC=''
397	ECHO_CC=''
398])
399AC_MSG_RESULT($enableval)
400AC_SUBST(ECHO_LT)
401AC_SUBST(ECHO_LD)
402AC_SUBST(RULE_CC)
403AC_SUBST(SHOW_CC)
404AC_SUBST(ECHO_CC)
405])dnl
406dnl ---------------------------------------------------------------------------
407dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
408dnl ----------------
409dnl Combine no-leak checks with the libraries or tools that are used for the
410dnl checks.
411AC_DEFUN([CF_DISABLE_LEAKS],[
412
413AC_REQUIRE([CF_WITH_DMALLOC])
414AC_REQUIRE([CF_WITH_DBMALLOC])
415AC_REQUIRE([CF_WITH_VALGRIND])
416
417AC_MSG_CHECKING(if you want to perform memory-leak testing)
418AC_ARG_ENABLE(leaks,
419	[  --disable-leaks         test: free permanent memory, analyze leaks],
420	[if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
421	: ${with_no_leaks:=no})
422AC_MSG_RESULT($with_no_leaks)
423
424if test "$with_no_leaks" = yes ; then
425	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
426	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
427fi
428])dnl
429dnl ---------------------------------------------------------------------------
430dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
431dnl -----------------
432dnl Test for availability of useful gcc __attribute__ directives to quiet
433dnl compiler warnings.  Though useful, not all are supported -- and contrary
434dnl to documentation, unrecognized directives cause older compilers to barf.
435AC_DEFUN([CF_GCC_ATTRIBUTES],
436[
437if test "$GCC" = yes
438then
439cat > conftest.i <<EOF
440#ifndef GCC_PRINTF
441#define GCC_PRINTF 0
442#endif
443#ifndef GCC_SCANF
444#define GCC_SCANF 0
445#endif
446#ifndef GCC_NORETURN
447#define GCC_NORETURN /* nothing */
448#endif
449#ifndef GCC_UNUSED
450#define GCC_UNUSED /* nothing */
451#endif
452EOF
453if test "$GCC" = yes
454then
455	AC_CHECKING([for $CC __attribute__ directives])
456cat > conftest.$ac_ext <<EOF
457#line __oline__ "${as_me:-configure}"
458#include "confdefs.h"
459#include "conftest.h"
460#include "conftest.i"
461#if	GCC_PRINTF
462#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
463#else
464#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
465#endif
466#if	GCC_SCANF
467#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
468#else
469#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
470#endif
471extern void wow(char *,...) GCC_SCANFLIKE(1,2);
472extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
473extern void foo(void) GCC_NORETURN;
474int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
475EOF
476	cf_printf_attribute=no
477	cf_scanf_attribute=no
478	for cf_attribute in scanf printf unused noreturn
479	do
480		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
481		cf_directive="__attribute__(($cf_attribute))"
482		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
483
484		case $cf_attribute in
485		(printf)
486			cf_printf_attribute=yes
487			cat >conftest.h <<EOF
488#define GCC_$cf_ATTRIBUTE 1
489EOF
490			;;
491		(scanf)
492			cf_scanf_attribute=yes
493			cat >conftest.h <<EOF
494#define GCC_$cf_ATTRIBUTE 1
495EOF
496			;;
497		(*)
498			cat >conftest.h <<EOF
499#define GCC_$cf_ATTRIBUTE $cf_directive
500EOF
501			;;
502		esac
503
504		if AC_TRY_EVAL(ac_compile); then
505			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
506			cat conftest.h >>confdefs.h
507			case $cf_attribute in
508			(noreturn)
509				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
510				;;
511			(printf)
512				cf_value='/* nothing */'
513				if test "$cf_printf_attribute" != no ; then
514					cf_value='__attribute__((format(printf,fmt,var)))'
515					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
516				fi
517				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
518				;;
519			(scanf)
520				cf_value='/* nothing */'
521				if test "$cf_scanf_attribute" != no ; then
522					cf_value='__attribute__((format(scanf,fmt,var)))'
523					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
524				fi
525				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
526				;;
527			(unused)
528				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
529				;;
530			esac
531		fi
532	done
533else
534	fgrep define conftest.i >>confdefs.h
535fi
536rm -rf conftest*
537fi
538])dnl
539dnl ---------------------------------------------------------------------------
540dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
541dnl --------------
542dnl Find version of gcc
543AC_DEFUN([CF_GCC_VERSION],[
544AC_REQUIRE([AC_PROG_CC])
545GCC_VERSION=none
546if test "$GCC" = yes ; then
547	AC_MSG_CHECKING(version of $CC)
548	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
549	test -z "$GCC_VERSION" && GCC_VERSION=unknown
550	AC_MSG_RESULT($GCC_VERSION)
551fi
552])dnl
553dnl ---------------------------------------------------------------------------
554dnl CF_GCC_WARNINGS version: 35 updated: 2019/06/16 09:45:01
555dnl ---------------
556dnl Check if the compiler supports useful warning options.  There's a few that
557dnl we don't use, simply because they're too noisy:
558dnl
559dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
560dnl	-Wredundant-decls (system headers make this too noisy)
561dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
562dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
563dnl		is enabled for ncurses using "--enable-const".
564dnl	-pedantic
565dnl
566dnl Parameter:
567dnl	$1 is an optional list of gcc warning flags that a particular
568dnl		application might want to use, e.g., "no-unused" for
569dnl		-Wno-unused
570dnl Special:
571dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
572dnl
573AC_DEFUN([CF_GCC_WARNINGS],
574[
575AC_REQUIRE([CF_GCC_VERSION])
576CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
577CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
578if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
579cat > conftest.$ac_ext <<EOF
580#line __oline__ "${as_me:-configure}"
581int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
582EOF
583if test "$INTEL_COMPILER" = yes
584then
585# The "-wdXXX" options suppress warnings:
586# remark #1419: external declaration in primary source file
587# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
588# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
589# remark #193: zero used for undefined preprocessing identifier
590# remark #593: variable "curs_sb_left_arrow" was set but never used
591# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
592# remark #869: parameter "tw" was never referenced
593# remark #981: operands are evaluated in unspecified order
594# warning #279: controlling expression is constant
595
596	AC_CHECKING([for $CC warning options])
597	cf_save_CFLAGS="$CFLAGS"
598	EXTRA_CFLAGS="-Wall"
599	for cf_opt in \
600		wd1419 \
601		wd1683 \
602		wd1684 \
603		wd193 \
604		wd593 \
605		wd279 \
606		wd810 \
607		wd869 \
608		wd981
609	do
610		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
611		if AC_TRY_EVAL(ac_compile); then
612			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
613			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
614		fi
615	done
616	CFLAGS="$cf_save_CFLAGS"
617elif test "$GCC" = yes
618then
619	AC_CHECKING([for $CC warning options])
620	cf_save_CFLAGS="$CFLAGS"
621	EXTRA_CFLAGS=
622	cf_warn_CONST=""
623	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
624	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
625	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
626	for cf_opt in W Wall \
627		Wbad-function-cast \
628		Wcast-align \
629		Wcast-qual \
630		Wdeclaration-after-statement \
631		Wextra \
632		Winline \
633		Wmissing-declarations \
634		Wmissing-prototypes \
635		Wnested-externs \
636		Wpointer-arith \
637		Wshadow \
638		Wstrict-prototypes \
639		Wundef $cf_gcc_warnings $cf_warn_CONST $1
640	do
641		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
642		if AC_TRY_EVAL(ac_compile); then
643			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
644			case $cf_opt in
645			(Winline)
646				case $GCC_VERSION in
647				([[34]].*)
648					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
649					continue;;
650				esac
651				;;
652			(Wpointer-arith)
653				case $GCC_VERSION in
654				([[12]].*)
655					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
656					continue;;
657				esac
658				;;
659			esac
660			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
661		fi
662	done
663	CFLAGS="$cf_save_CFLAGS"
664fi
665rm -rf conftest*
666
667AC_SUBST(EXTRA_CFLAGS)
668])dnl
669dnl ---------------------------------------------------------------------------
670dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
671dnl ----------------
672dnl Check for getopt's variables which are commonly defined in stdlib.h,
673dnl unistd.h or (nonstandard) in getopt.h
674AC_DEFUN([CF_GETOPT_HEADER],
675[
676AC_HAVE_HEADERS(unistd.h getopt.h)
677AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
678cf_cv_getopt_header=none
679for cf_header in stdio.h stdlib.h unistd.h getopt.h
680do
681AC_TRY_COMPILE([
682#include <$cf_header>],
683[int x = optind; char *y = optarg],
684[cf_cv_getopt_header=$cf_header
685 break])
686done
687])
688if test $cf_cv_getopt_header != none ; then
689	AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
690fi
691if test $cf_cv_getopt_header = getopt.h ; then
692	AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
693fi
694])dnl
695dnl ---------------------------------------------------------------------------
696dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
697dnl -------------
698dnl Check if we must define _GNU_SOURCE to get a reasonable value for
699dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
700dnl (or misfeature) of glibc2, which breaks portability of many applications,
701dnl since it is interwoven with GNU extensions.
702dnl
703dnl Well, yes we could work around it...
704dnl
705dnl Parameters:
706dnl	$1 is the nominal value for _XOPEN_SOURCE
707AC_DEFUN([CF_GNU_SOURCE],
708[
709cf_gnu_xopen_source=ifelse($1,,500,$1)
710
711AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
712AC_TRY_COMPILE([#include <sys/types.h>],[
713	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
714		return 0;
715	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
716		return 0;
717	#else
718	#	error not GNU C library
719	#endif],
720	[cf_cv_gnu_library=yes],
721	[cf_cv_gnu_library=no])
722])
723
724if test x$cf_cv_gnu_library = xyes; then
725
726	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
727	# was changed to help a little.  newlib incorporated the change about 4
728	# years later.
729	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
730		cf_save="$CPPFLAGS"
731		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
732		AC_TRY_COMPILE([#include <sys/types.h>],[
733			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
734				return 0;
735			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
736				return 0;
737			#else
738			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
739			#endif],
740			[cf_cv_gnu_library_219=yes],
741			[cf_cv_gnu_library_219=no])
742		CPPFLAGS="$cf_save"
743	])
744
745	if test "x$cf_cv_gnu_library_219" = xyes; then
746		cf_save="$CPPFLAGS"
747		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
748			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
749			AC_TRY_COMPILE([
750				#include <limits.h>
751				#include <sys/types.h>
752				],[
753				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
754					return 0;
755				#else
756				#	error GNU C library is too old
757				#endif],
758				[cf_cv_gnu_dftsrc_219=yes],
759				[cf_cv_gnu_dftsrc_219=no])
760			])
761		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
762	else
763		cf_cv_gnu_dftsrc_219=maybe
764	fi
765
766	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
767
768		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
769		AC_TRY_COMPILE([#include <sys/types.h>],[
770			#ifndef _XOPEN_SOURCE
771			#error	expected _XOPEN_SOURCE to be defined
772			#endif],
773			[cf_cv_gnu_source=no],
774			[cf_save="$CPPFLAGS"
775			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
776			 AC_TRY_COMPILE([#include <sys/types.h>],[
777				#ifdef _XOPEN_SOURCE
778				#error	expected _XOPEN_SOURCE to be undefined
779				#endif],
780				[cf_cv_gnu_source=no],
781				[cf_cv_gnu_source=yes])
782			CPPFLAGS="$cf_save"
783			])
784		])
785
786		if test "$cf_cv_gnu_source" = yes
787		then
788		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
789			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
790			AC_TRY_COMPILE([#include <sys/types.h>],[
791				#ifdef _DEFAULT_SOURCE
792				#error	expected _DEFAULT_SOURCE to be undefined
793				#endif],
794				[cf_cv_default_source=no],
795				[cf_cv_default_source=yes])
796			])
797			if test "$cf_cv_default_source" = yes
798			then
799				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
800			fi
801		fi
802	fi
803
804fi
805])dnl
806dnl ---------------------------------------------------------------------------
807dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
808dnl -----------------
809dnl Check if the given compiler is really the Intel compiler for Linux.  It
810dnl tries to imitate gcc, but does not return an error when it finds a mismatch
811dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
812dnl
813dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
814dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
815dnl the wrappers for gcc and g++ warnings.
816dnl
817dnl $1 = GCC (default) or GXX
818dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
819dnl $3 = CFLAGS (default) or CXXFLAGS
820AC_DEFUN([CF_INTEL_COMPILER],[
821AC_REQUIRE([AC_CANONICAL_HOST])
822ifelse([$2],,INTEL_COMPILER,[$2])=no
823
824if test "$ifelse([$1],,[$1],GCC)" = yes ; then
825	case $host_os in
826	(linux*|gnu*)
827		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
828		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
829		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
830		AC_TRY_COMPILE([],[
831#ifdef __INTEL_COMPILER
832#else
833make an error
834#endif
835],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
836cf_save_CFLAGS="$cf_save_CFLAGS -we147"
837],[])
838		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
839		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
840		;;
841	esac
842fi
843])dnl
844dnl ---------------------------------------------------------------------------
845dnl CF_MAKE_DOCS version: 4 updated: 2015/07/04 21:43:03
846dnl ------------
847dnl $1 = name(s) to generate rules for
848dnl $2 = suffix of corresponding manpages used as input.
849dnl
850dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
851define([CF_MAKE_DOCS],[
852test -z "$cf_make_docs" && cf_make_docs=0
853
854cf_output=makefile
855test -f "$cf_output" || cf_output=Makefile
856
857if test "$cf_make_docs" = 0
858then
859cat >>$cf_output <<CF_EOF
860################################################################################
861## generated by $0
862.SUFFIXES : .html .$2 .man .ps .pdf .txt
863
864${NROFF_NOTE}.$2.txt :
865${NROFF_NOTE}	[\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
866
867${GROFF_NOTE}.ps.pdf :
868${GROFF_NOTE}	ps2pdf [\$]*.ps
869${GROFF_NOTE}
870${GROFF_NOTE}.$2.ps :
871${GROFF_NOTE}	[\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
872${GROFF_NOTE}
873${GROFF_NOTE}.$2.txt :
874${GROFF_NOTE}	GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -Tascii -man | col -bx" >[\$]@
875
876${MAN2HTML_NOTE}.$2.html :
877${MAN2HTML_NOTE}	./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
878
879CF_EOF
880	cf_make_docs=1
881fi
882
883for cf_name in $1
884do
885cat >>$cf_output <<CF_EOF
886################################################################################
887${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
888${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
889${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
890${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
891${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
892
893clean \\
894docs-clean ::
895${NROFF_NOTE}	rm -f $cf_name.txt
896${MAN2HTML_NOTE}	rm -f $cf_name.html
897${GROFF_NOTE}	rm -f $cf_name.pdf
898${GROFF_NOTE}	rm -f $cf_name.ps
899${GROFF_NOTE}	rm -f $cf_name.txt
900
901${NROFF_NOTE}$cf_name.txt  : $cf_name.$2
902${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
903${GROFF_NOTE}$cf_name.pdf  : $cf_name.ps
904${GROFF_NOTE}$cf_name.ps   : $cf_name.$2
905${GROFF_NOTE}$cf_name.txt  : $cf_name.$2
906CF_EOF
907done
908])dnl
909dnl ---------------------------------------------------------------------------
910dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
911dnl ------------
912dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
913dnl a monocase filesystem.
914AC_DEFUN([CF_MAKE_TAGS],[
915AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
916
917AC_CHECK_PROGS(CTAGS, exctags ctags)
918AC_CHECK_PROGS(ETAGS, exetags etags)
919
920AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
921
922if test "$cf_cv_mixedcase" = yes ; then
923	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
924else
925	MAKE_UPPER_TAGS=no
926fi
927
928if test "$MAKE_UPPER_TAGS" = yes ; then
929	MAKE_UPPER_TAGS=
930else
931	MAKE_UPPER_TAGS="#"
932fi
933
934if test "$MAKE_LOWER_TAGS" = yes ; then
935	MAKE_LOWER_TAGS=
936else
937	MAKE_LOWER_TAGS="#"
938fi
939
940AC_SUBST(CTAGS)
941AC_SUBST(ETAGS)
942
943AC_SUBST(MAKE_UPPER_TAGS)
944AC_SUBST(MAKE_LOWER_TAGS)
945])dnl
946dnl ---------------------------------------------------------------------------
947dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
948dnl ----------------------
949dnl Check if the file-system supports mixed-case filenames.  If we're able to
950dnl create a lowercase name and see it as uppercase, it doesn't support that.
951AC_DEFUN([CF_MIXEDCASE_FILENAMES],
952[
953AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
954if test "$cross_compiling" = yes ; then
955	case $target_alias in
956	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
957		cf_cv_mixedcase=no
958		;;
959	(*)
960		cf_cv_mixedcase=yes
961		;;
962	esac
963else
964	rm -f conftest CONFTEST
965	echo test >conftest
966	if test -f CONFTEST ; then
967		cf_cv_mixedcase=no
968	else
969		cf_cv_mixedcase=yes
970	fi
971	rm -f conftest CONFTEST
972fi
973])
974test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
975])dnl
976dnl ---------------------------------------------------------------------------
977dnl CF_MKSTEMP version: 10 updated: 2017/01/21 11:12:16
978dnl ----------
979dnl Check for a working mkstemp.  This creates two files, checks that they are
980dnl successfully created and distinct (AmigaOS apparently fails on the last).
981AC_DEFUN([CF_MKSTEMP],[
982AC_CHECK_HEADERS( \
983unistd.h \
984)
985AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
986rm -rf conftest*
987AC_TRY_RUN([
988#include <sys/types.h>
989#ifdef HAVE_UNISTD_H
990#include <unistd.h>
991#endif
992#include <stdlib.h>
993#include <stdio.h>
994#include <string.h>
995#include <sys/stat.h>
996int main(void)
997{
998	char *tmpl = "conftestXXXXXX";
999	char name[2][80];
1000	int n;
1001	int result = 0;
1002	int fd;
1003	struct stat sb;
1004
1005	umask(077);
1006	for (n = 0; n < 2; ++n) {
1007		strcpy(name[n], tmpl);
1008		if ((fd = mkstemp(name[n])) >= 0) {
1009			if (!strcmp(name[n], tmpl)
1010			 || stat(name[n], &sb) != 0
1011			 || (sb.st_mode & S_IFMT) != S_IFREG
1012			 || (sb.st_mode & 077) != 0) {
1013				result = 1;
1014			}
1015			close(fd);
1016		}
1017	}
1018	if (result == 0
1019	 && !strcmp(name[0], name[1]))
1020		result = 1;
1021	${cf_cv_main_return:-return}(result);
1022}
1023],[cf_cv_func_mkstemp=yes
1024],[cf_cv_func_mkstemp=no
1025],[cf_cv_func_mkstemp=maybe])
1026])
1027if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1028	AC_CHECK_FUNC(mkstemp)
1029fi
1030if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1031	AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
1032fi
1033])dnl
1034dnl ---------------------------------------------------------------------------
1035dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1036dnl ----------
1037dnl Write a debug message to config.log, along with the line number in the
1038dnl configure script.
1039AC_DEFUN([CF_MSG_LOG],[
1040echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1041])dnl
1042dnl ---------------------------------------------------------------------------
1043dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
1044dnl ------------------
1045dnl see CF_WITH_NO_LEAKS
1046AC_DEFUN([CF_NO_LEAKS_OPTION],[
1047AC_MSG_CHECKING(if you want to use $1 for testing)
1048AC_ARG_WITH($1,
1049	[$2],
1050	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1051	 $4
1052])
1053	: ${with_cflags:=-g}
1054	: ${with_no_leaks:=yes}
1055	 with_$1=yes],
1056	[with_$1=])
1057AC_MSG_RESULT(${with_$1:-no})
1058
1059case .$with_cflags in
1060(.*-g*)
1061	case .$CFLAGS in
1062	(.*-g*)
1063		;;
1064	(*)
1065		CF_ADD_CFLAGS([-g])
1066		;;
1067	esac
1068	;;
1069esac
1070])dnl
1071dnl ---------------------------------------------------------------------------
1072dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
1073dnl --------------
1074dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1075dnl begins with one of the prefix/exec_prefix variables, and then again if the
1076dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1077dnl delayed evaluation of those symbols.
1078AC_DEFUN([CF_PATH_SYNTAX],[
1079if test "x$prefix" != xNONE; then
1080	cf_path_syntax="$prefix"
1081else
1082	cf_path_syntax="$ac_default_prefix"
1083fi
1084
1085case ".[$]$1" in
1086(.\[$]\(*\)*|.\'*\'*)
1087	;;
1088(..|./*|.\\*)
1089	;;
1090(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1091	;;
1092(.\[$]{*prefix}*|.\[$]{*dir}*)
1093	eval $1="[$]$1"
1094	case ".[$]$1" in
1095	(.NONE/*)
1096		$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1097		;;
1098	esac
1099	;;
1100(.no|.NONE/*)
1101	$1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1102	;;
1103(*)
1104	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1105	;;
1106esac
1107])dnl
1108dnl ---------------------------------------------------------------------------
1109dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
1110dnl -----------------
1111dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1112dnl
1113dnl	POSIX.1-1990				_POSIX_SOURCE
1114dnl	POSIX.1-1990 and			_POSIX_SOURCE and
1115dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1116dnl		Bindings Option
1117dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1118dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1119dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1120dnl
1121dnl Parameters:
1122dnl	$1 is the nominal value for _POSIX_C_SOURCE
1123AC_DEFUN([CF_POSIX_C_SOURCE],
1124[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
1125
1126if test "$cf_cv_posix_visible" = no; then
1127
1128cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1129
1130cf_save_CFLAGS="$CFLAGS"
1131cf_save_CPPFLAGS="$CPPFLAGS"
1132
1133CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1134CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1135
1136AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1137	CF_MSG_LOG(if the symbol is already defined go no further)
1138	AC_TRY_COMPILE([#include <sys/types.h>],[
1139#ifndef _POSIX_C_SOURCE
1140make an error
1141#endif],
1142	[cf_cv_posix_c_source=no],
1143	[cf_want_posix_source=no
1144	 case .$cf_POSIX_C_SOURCE in
1145	 (.[[12]]??*)
1146		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1147		;;
1148	 (.2)
1149		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1150		cf_want_posix_source=yes
1151		;;
1152	 (.*)
1153		cf_want_posix_source=yes
1154		;;
1155	 esac
1156	 if test "$cf_want_posix_source" = yes ; then
1157		AC_TRY_COMPILE([#include <sys/types.h>],[
1158#ifdef _POSIX_SOURCE
1159make an error
1160#endif],[],
1161		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1162	 fi
1163	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1164	 CFLAGS="$cf_trim_CFLAGS"
1165	 CPPFLAGS="$cf_trim_CPPFLAGS"
1166	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
1167	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1168	 AC_TRY_COMPILE([#include <sys/types.h>],[
1169#ifndef _POSIX_C_SOURCE
1170make an error
1171#endif],,
1172	 [cf_cv_posix_c_source=no])
1173	 CFLAGS="$cf_save_CFLAGS"
1174	 CPPFLAGS="$cf_save_CPPFLAGS"
1175	])
1176])
1177
1178if test "$cf_cv_posix_c_source" != no ; then
1179	CFLAGS="$cf_trim_CFLAGS"
1180	CPPFLAGS="$cf_trim_CPPFLAGS"
1181	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1182fi
1183
1184fi # cf_cv_posix_visible
1185
1186])dnl
1187dnl ---------------------------------------------------------------------------
1188dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
1189dnl ----------------
1190dnl POSIX documents test-macros which an application may set before any system
1191dnl headers are included to make features available.
1192dnl
1193dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
1194dnl diverged from POSIX in 2002 by setting symbols which make all of the most
1195dnl recent features visible in the system header files unless the application
1196dnl overrides the corresponding test-macros.  Doing that introduces portability
1197dnl problems.
1198dnl
1199dnl This macro makes a special check for the symbols used for this, to avoid a
1200dnl conflicting definition.
1201AC_DEFUN([CF_POSIX_VISIBLE],
1202[
1203AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
1204AC_TRY_COMPILE([#include <stdio.h>],[
1205#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
1206	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
1207	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
1208	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
1209#error conflicting symbols found
1210#endif
1211],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1212])
1213])dnl
1214dnl ---------------------------------------------------------------------------
1215dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1216dnl -----------
1217dnl Check for awk, ensure that the check found something.
1218AC_DEFUN([CF_PROG_AWK],
1219[
1220AC_PROG_AWK
1221test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1222])dnl
1223dnl ---------------------------------------------------------------------------
1224dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
1225dnl ----------
1226dnl standard check for CC, plus followup sanity checks
1227dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1228AC_DEFUN([CF_PROG_CC],[
1229ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1230CF_GCC_VERSION
1231CF_ACVERSION_CHECK(2.52,
1232	[AC_PROG_CC_STDC],
1233	[CF_ANSI_CC_REQD])
1234CF_CC_ENV_FLAGS
1235])dnl
1236dnl ---------------------------------------------------------------------------
1237dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1238dnl -------------
1239dnl Check if groff is available, for cases (such as html output) where nroff
1240dnl is not enough.
1241AC_DEFUN([CF_PROG_GROFF],[
1242AC_PATH_PROG(GROFF_PATH,groff,no)
1243AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
1244AC_PATH_PROG(TBL_PATH,tbl,cat)
1245if test "x$GROFF_PATH" = xno
1246then
1247	NROFF_NOTE=
1248	GROFF_NOTE="#"
1249else
1250	NROFF_NOTE="#"
1251	GROFF_NOTE=
1252fi
1253AC_SUBST(GROFF_NOTE)
1254AC_SUBST(NROFF_NOTE)
1255])dnl
1256dnl ---------------------------------------------------------------------------
1257dnl CF_PROG_LINT version: 3 updated: 2016/05/22 15:25:54
1258dnl ------------
1259AC_DEFUN([CF_PROG_LINT],
1260[
1261AC_CHECK_PROGS(LINT, lint cppcheck splint)
1262AC_SUBST(LINT_OPTS)
1263])dnl
1264dnl ---------------------------------------------------------------------------
1265dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1266dnl ----------------
1267dnl Remove all -U and -D options that refer to the given symbol from a list
1268dnl of C compiler options.  This works around the problem that not all
1269dnl compilers process -U and -D options from left-to-right, so a -U option
1270dnl cannot be used to cancel the effect of a preceding -D option.
1271dnl
1272dnl $1 = target (which could be the same as the source variable)
1273dnl $2 = source (including '$')
1274dnl $3 = symbol to remove
1275define([CF_REMOVE_DEFINE],
1276[
1277$1=`echo "$2" | \
1278	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
1279		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
1280])dnl
1281dnl ---------------------------------------------------------------------------
1282dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
1283dnl -------------------
1284dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1285dnl can define it successfully.
1286AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1287AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1288	AC_TRY_COMPILE([
1289#include <stdlib.h>
1290#include <string.h>
1291#include <sys/types.h>
1292],[
1293#ifndef _XOPEN_SOURCE
1294make an error
1295#endif],
1296	[cf_cv_xopen_source=no],
1297	[cf_save="$CPPFLAGS"
1298	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1299	 AC_TRY_COMPILE([
1300#include <stdlib.h>
1301#include <string.h>
1302#include <sys/types.h>
1303],[
1304#ifdef _XOPEN_SOURCE
1305make an error
1306#endif],
1307	[cf_cv_xopen_source=no],
1308	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1309	CPPFLAGS="$cf_save"
1310	])
1311])
1312
1313if test "$cf_cv_xopen_source" != no ; then
1314	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1315	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1316	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1317	CF_ADD_CFLAGS($cf_temp_xopen_source)
1318fi
1319])
1320dnl ---------------------------------------------------------------------------
1321dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1322dnl --------
1323dnl Make an uppercase version of a variable
1324dnl $1=uppercase($2)
1325AC_DEFUN([CF_UPPER],
1326[
1327$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1328])dnl
1329dnl ---------------------------------------------------------------------------
1330dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1331dnl ----------
1332dnl Use AC_VERBOSE w/o the warnings
1333AC_DEFUN([CF_VERBOSE],
1334[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
1335CF_MSG_LOG([$1])
1336])dnl
1337dnl ---------------------------------------------------------------------------
1338dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1339dnl ----------------
1340dnl Configure-option for dbmalloc.  The optional parameter is used to override
1341dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1342AC_DEFUN([CF_WITH_DBMALLOC],[
1343CF_NO_LEAKS_OPTION(dbmalloc,
1344	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
1345	[USE_DBMALLOC])
1346
1347if test "$with_dbmalloc" = yes ; then
1348	AC_CHECK_HEADER(dbmalloc.h,
1349		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1350fi
1351])dnl
1352dnl ---------------------------------------------------------------------------
1353dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1354dnl ---------------
1355dnl Configure-option for dmalloc.  The optional parameter is used to override
1356dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1357AC_DEFUN([CF_WITH_DMALLOC],[
1358CF_NO_LEAKS_OPTION(dmalloc,
1359	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
1360	[USE_DMALLOC])
1361
1362if test "$with_dmalloc" = yes ; then
1363	AC_CHECK_HEADER(dmalloc.h,
1364		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1365fi
1366])dnl
1367dnl ---------------------------------------------------------------------------
1368dnl CF_WITH_MAN2HTML version: 8 updated: 2018/06/27 18:44:03
1369dnl ----------------
1370dnl Check for man2html and groff.  Prefer man2html over groff, but use groff
1371dnl as a fallback.  See
1372dnl
1373dnl		http://invisible-island.net/scripts/man2html.html
1374dnl
1375dnl Generate a shell script which hides the differences between the two.
1376dnl
1377dnl We name that "man2html.tmp".
1378dnl
1379dnl The shell script can be removed later, e.g., using "make distclean".
1380AC_DEFUN([CF_WITH_MAN2HTML],[
1381AC_REQUIRE([CF_PROG_GROFF])
1382
1383case "x${with_man2html}" in
1384(xno)
1385	cf_man2html=no
1386	;;
1387(x|xyes)
1388	AC_PATH_PROG(cf_man2html,man2html,no)
1389	case "x$cf_man2html" in
1390	(x/*)
1391		AC_MSG_CHECKING(for the modified Earl Hood script)
1392		if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
1393		then
1394			cf_man2html_ok=yes
1395		else
1396			cf_man2html=no
1397			cf_man2html_ok=no
1398		fi
1399		AC_MSG_RESULT($cf_man2html_ok)
1400		;;
1401	(*)
1402		cf_man2html=no
1403		;;
1404	esac
1405esac
1406
1407AC_MSG_CHECKING(for program to convert manpage to html)
1408AC_ARG_WITH(man2html,
1409	[  --with-man2html=XXX     use XXX rather than groff],
1410	[cf_man2html=$withval],
1411	[cf_man2html=$cf_man2html])
1412
1413cf_with_groff=no
1414
1415case $cf_man2html in
1416(yes)
1417	AC_MSG_RESULT(man2html)
1418	AC_PATH_PROG(cf_man2html,man2html,no)
1419	;;
1420(no|groff|*/groff*)
1421	cf_with_groff=yes
1422	cf_man2html=$GROFF_PATH
1423	AC_MSG_RESULT($cf_man2html)
1424	;;
1425(*)
1426	AC_MSG_RESULT($cf_man2html)
1427	;;
1428esac
1429
1430MAN2HTML_TEMP="man2html.tmp"
1431	cat >$MAN2HTML_TEMP <<CF_EOF
1432#!$SHELL
1433# Temporary script generated by CF_WITH_MAN2HTML
1434# Convert inputs to html, sending result to standard output.
1435#
1436# Parameters:
1437# \${1} = rootname of file to convert
1438# \${2} = suffix of file to convert, e.g., "1"
1439# \${3} = macros to use, e.g., "man"
1440#
1441ROOT=\[$]1
1442TYPE=\[$]2
1443MACS=\[$]3
1444
1445unset LANG
1446unset LC_ALL
1447unset LC_CTYPE
1448unset LANGUAGE
1449GROFF_NO_SGR=stupid
1450export GROFF_NO_SGR
1451
1452CF_EOF
1453
1454if test "x$cf_with_groff" = xyes
1455then
1456	MAN2HTML_NOTE="$GROFF_NOTE"
1457	MAN2HTML_PATH="$GROFF_PATH"
1458	cat >>$MAN2HTML_TEMP <<CF_EOF
1459$SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1460CF_EOF
1461else
1462	MAN2HTML_NOTE=""
1463	CF_PATH_SYNTAX(cf_man2html)
1464	MAN2HTML_PATH="$cf_man2html"
1465	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
1466
1467	# for this example, expect 3 lines of content, the remainder is head/foot
1468	cat >conftest.in <<CF_EOF
1469.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
1470.SH SECTION
1471MARKER
1472CF_EOF
1473
1474	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1475
1476	cf_man2html_1st=`fgrep -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1477	cf_man2html_top=`expr $cf_man2html_1st - 2`
1478	cf_man2html_bot=`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`
1479	cf_man2html_bot=`expr $cf_man2html_bot - 2 - $cf_man2html_top`
1480	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
1481
1482	AC_MSG_RESULT($cf_man2html_top_bot)
1483
1484	AC_MSG_CHECKING(for pagesize to use)
1485	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1486	do
1487	cat >>conftest.in <<CF_EOF
1488.nf
14890
14901
14912
14923
14934
14945
14956
14967
14978
14989
1499CF_EOF
1500	done
1501
1502	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
1503	cf_man2html_page=`fgrep -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`
1504	test -z "$cf_man2html_page" && cf_man2html_page=99999
1505	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
1506
1507	rm -rf conftest*
1508	AC_MSG_RESULT($cf_man2html_page)
1509
1510	cat >>$MAN2HTML_TEMP <<CF_EOF
1511: \${MAN2HTML_PATH=$MAN2HTML_PATH}
1512MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title="\$ROOT\(\$TYPE\)" -compress -pgsize $cf_man2html_page"
1513case \${TYPE} in
1514(ms)
1515	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
1516	;;
1517(*)
1518	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
1519	;;
1520esac
1521CF_EOF
1522fi
1523
1524chmod 700 $MAN2HTML_TEMP
1525
1526AC_SUBST(MAN2HTML_NOTE)
1527AC_SUBST(MAN2HTML_PATH)
1528AC_SUBST(MAN2HTML_TEMP)
1529])dnl
1530dnl ---------------------------------------------------------------------------
1531dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
1532dnl ----------------
1533AC_DEFUN([CF_WITH_VALGRIND],[
1534CF_NO_LEAKS_OPTION(valgrind,
1535	[  --with-valgrind         test: use valgrind],
1536	[USE_VALGRIND])
1537])dnl
1538dnl ---------------------------------------------------------------------------
1539dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
1540dnl ----------------
1541dnl Combine the checks for gcc features into a configure-script option
1542dnl
1543dnl Parameters:
1544dnl	$1 - see CF_GCC_WARNINGS
1545AC_DEFUN([CF_WITH_WARNINGS],
1546[
1547if ( test "$GCC" = yes || test "$GXX" = yes )
1548then
1549AC_MSG_CHECKING(if you want to check for gcc warnings)
1550AC_ARG_WITH(warnings,
1551	[  --with-warnings         test: turn on gcc warnings],
1552	[cf_opt_with_warnings=$withval],
1553	[cf_opt_with_warnings=no])
1554AC_MSG_RESULT($cf_opt_with_warnings)
1555if test "$cf_opt_with_warnings" != no ; then
1556	CF_GCC_ATTRIBUTES
1557	CF_GCC_WARNINGS([$1])
1558fi
1559fi
1560])dnl
1561dnl ---------------------------------------------------------------------------
1562dnl CF_XOPEN_SOURCE version: 55 updated: 2018/12/31 20:46:17
1563dnl ---------------
1564dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1565dnl or adapt to the vendor's definitions to get equivalent functionality,
1566dnl without losing the common non-POSIX features.
1567dnl
1568dnl Parameters:
1569dnl	$1 is the nominal value for _XOPEN_SOURCE
1570dnl	$2 is the nominal value for _POSIX_C_SOURCE
1571AC_DEFUN([CF_XOPEN_SOURCE],[
1572AC_REQUIRE([AC_CANONICAL_HOST])
1573AC_REQUIRE([CF_POSIX_VISIBLE])
1574
1575if test "$cf_cv_posix_visible" = no; then
1576
1577cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
1578cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
1579cf_xopen_source=
1580
1581case $host_os in
1582(aix[[4-7]]*)
1583	cf_xopen_source="-D_ALL_SOURCE"
1584	;;
1585(msys)
1586	cf_XOPEN_SOURCE=600
1587	;;
1588(darwin[[0-8]].*)
1589	cf_xopen_source="-D_APPLE_C_SOURCE"
1590	;;
1591(darwin*)
1592	cf_xopen_source="-D_DARWIN_C_SOURCE"
1593	cf_XOPEN_SOURCE=
1594	;;
1595(freebsd*|dragonfly*|midnightbsd*)
1596	# 5.x headers associate
1597	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1598	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1599	cf_POSIX_C_SOURCE=200112L
1600	cf_XOPEN_SOURCE=600
1601	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1602	;;
1603(hpux11*)
1604	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
1605	;;
1606(hpux*)
1607	cf_xopen_source="-D_HPUX_SOURCE"
1608	;;
1609(irix[[56]].*)
1610	cf_xopen_source="-D_SGI_SOURCE"
1611	cf_XOPEN_SOURCE=
1612	;;
1613(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
1614	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
1615	;;
1616(minix*)
1617	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
1618	;;
1619(mirbsd*)
1620	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
1621	cf_XOPEN_SOURCE=
1622	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1623	;;
1624(netbsd*)
1625	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1626	;;
1627(openbsd[[4-9]]*)
1628	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
1629	cf_xopen_source="-D_BSD_SOURCE"
1630	cf_XOPEN_SOURCE=600
1631	;;
1632(openbsd*)
1633	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1634	;;
1635(osf[[45]]*)
1636	cf_xopen_source="-D_OSF_SOURCE"
1637	;;
1638(nto-qnx*)
1639	cf_xopen_source="-D_QNX_SOURCE"
1640	;;
1641(sco*)
1642	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1643	;;
1644(solaris2.*)
1645	cf_xopen_source="-D__EXTENSIONS__"
1646	cf_cv_xopen_source=broken
1647	;;
1648(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
1649	cf_XOPEN_SOURCE=
1650	cf_POSIX_C_SOURCE=
1651	;;
1652(*)
1653	CF_TRY_XOPEN_SOURCE
1654	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
1655	;;
1656esac
1657
1658if test -n "$cf_xopen_source" ; then
1659	CF_ADD_CFLAGS($cf_xopen_source,true)
1660fi
1661
1662dnl In anything but the default case, we may have system-specific setting
1663dnl which is still not guaranteed to provide all of the entrypoints that
1664dnl _XOPEN_SOURCE would yield.
1665if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
1666	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
1667	AC_TRY_COMPILE([#include <stdlib.h>],[
1668#ifndef _XOPEN_SOURCE
1669make an error
1670#endif],
1671	[cf_XOPEN_SOURCE_set=yes],
1672	[cf_XOPEN_SOURCE_set=no])
1673	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
1674	if test $cf_XOPEN_SOURCE_set = yes
1675	then
1676		AC_TRY_COMPILE([#include <stdlib.h>],[
1677#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
1678make an error
1679#endif],
1680		[cf_XOPEN_SOURCE_set_ok=yes],
1681		[cf_XOPEN_SOURCE_set_ok=no])
1682		if test $cf_XOPEN_SOURCE_set_ok = no
1683		then
1684			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
1685		fi
1686	else
1687		CF_TRY_XOPEN_SOURCE
1688	fi
1689fi
1690fi # cf_cv_posix_visible
1691])
1692