xref: /freebsd/contrib/byacc/aclocal.m4 (revision 822ca3276345b4a67ccbc9b54616d8b205fd37f2)
1dnl $Id: aclocal.m4,v 1.65 2023/12/01 22:22:50 tom Exp $
2dnl Macros for byacc configure script (Thomas E. Dickey)
3dnl ---------------------------------------------------------------------------
4dnl Copyright 2004-2022,2023 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: 15 updated: 2020/12/31 10:54:15
58dnl -------------
59dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
60dnl $1 = flags to add
61dnl $2 = if given makes this macro verbose.
62dnl
63dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
64dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
65dnl confused by the quotes (which require backslashes to keep them usable).
66AC_DEFUN([CF_ADD_CFLAGS],
67[
68cf_fix_cppflags=no
69cf_new_cflags=
70cf_new_cppflags=
71cf_new_extra_cppflags=
72
73for cf_add_cflags in $1
74do
75case "$cf_fix_cppflags" in
76(no)
77	case "$cf_add_cflags" in
78	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
79		case "$cf_add_cflags" in
80		(-D*)
81			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
82
83			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
84				&& test -z "${cf_tst_cflags}" \
85				&& cf_fix_cppflags=yes
86
87			if test "$cf_fix_cppflags" = yes ; then
88				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
89				continue
90			elif test "${cf_tst_cflags}" = "\"'" ; then
91				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
92				continue
93			fi
94			;;
95		esac
96		case "$CPPFLAGS" in
97		(*$cf_add_cflags)
98			;;
99		(*)
100			case "$cf_add_cflags" in
101			(-D*)
102				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
103				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
104				;;
105			esac
106			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
107			;;
108		esac
109		;;
110	(*)
111		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
112		;;
113	esac
114	;;
115(yes)
116	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
117
118	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
119
120	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
121		&& test -z "${cf_tst_cflags}" \
122		&& cf_fix_cppflags=no
123	;;
124esac
125done
126
127if test -n "$cf_new_cflags" ; then
128	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
129	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
130fi
131
132if test -n "$cf_new_cppflags" ; then
133	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
134	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
135fi
136
137if test -n "$cf_new_extra_cppflags" ; then
138	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
139	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
140fi
141
142AC_SUBST(EXTRA_CPPFLAGS)
143
144])dnl
145dnl ---------------------------------------------------------------------------
146dnl CF_APPEND_CFLAGS version: 3 updated: 2021/09/05 17:25:40
147dnl ----------------
148dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
149dnl $1 = flags to add
150dnl $2 = if given makes this macro verbose.
151define([CF_APPEND_CFLAGS],
152[
153for cf_add_cflags in $1
154do
155	case "x$cf_add_cflags" in
156	(x-[[DU]]*)
157		CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
158		CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
159		;;
160	esac
161	CF_ADD_CFLAGS([$cf_add_cflags],[$2])
162done
163])dnl
164dnl ---------------------------------------------------------------------------
165dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
166dnl --------------
167dnl use this macro for appending text without introducing an extra blank at
168dnl the beginning
169define([CF_APPEND_TEXT],
170[
171	test -n "[$]$1" && $1="[$]$1 "
172	$1="[$]{$1}$2"
173])dnl
174dnl ---------------------------------------------------------------------------
175dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
176dnl --------------
177dnl Allow user to disable a normally-on option.
178AC_DEFUN([CF_ARG_DISABLE],
179[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
180dnl ---------------------------------------------------------------------------
181dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
182dnl -------------
183dnl Allow user to enable a normally-off option.
184AC_DEFUN([CF_ARG_ENABLE],
185[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
186dnl ---------------------------------------------------------------------------
187dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
188dnl -------------
189dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
190dnl values.
191dnl
192dnl Parameters:
193dnl $1 = option name
194dnl $2 = help-string
195dnl $3 = action to perform if option is not default
196dnl $4 = action if perform if option is default
197dnl $5 = default option value (either 'yes' or 'no')
198AC_DEFUN([CF_ARG_OPTION],
199[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
200	if test "$enableval" != "$5" ; then
201ifelse([$3],,[    :]dnl
202,[    $3]) ifelse([$4],,,[
203	else
204		$4])
205	fi],[enableval=$5 ifelse([$4],,,[
206	$4
207])dnl
208])])dnl
209dnl ---------------------------------------------------------------------------
210dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25
211dnl ---------------
212AC_DEFUN([CF_C11_NORETURN],
213[
214AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
215CF_ARG_ENABLE(stdnoreturn,
216	[  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
217	[enable_stdnoreturn=yes],
218	[enable_stdnoreturn=no])
219AC_MSG_RESULT($enable_stdnoreturn)
220
221if test $enable_stdnoreturn = yes; then
222AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
223	[AC_TRY_COMPILE([
224$ac_includes_default
225#include <stdnoreturn.h>
226static _Noreturn void giveup(void) { exit(0); }
227	],
228	[if (feof(stdin)) giveup()],
229	cf_cv_c11_noreturn=yes,
230	cf_cv_c11_noreturn=no)
231	])
232else
233	cf_cv_c11_noreturn=no,
234fi
235
236if test "$cf_cv_c11_noreturn" = yes; then
237	AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
238	AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
239	HAVE_STDNORETURN_H=1
240else
241	HAVE_STDNORETURN_H=0
242fi
243
244AC_SUBST(HAVE_STDNORETURN_H)
245AC_SUBST(STDC_NORETURN)
246])dnl
247dnl ---------------------------------------------------------------------------
248dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46
249dnl ---------------
250dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
251dnl into CC.  This will not help with broken scripts that wrap the compiler
252dnl with options, but eliminates a more common category of user confusion.
253dnl
254dnl In particular, it addresses the problem of being able to run the C
255dnl preprocessor in a consistent manner.
256dnl
257dnl Caveat: this also disallows blanks in the pathname for the compiler, but
258dnl the nuisance of having inconsistent settings for compiler and preprocessor
259dnl outweighs that limitation.
260AC_DEFUN([CF_CC_ENV_FLAGS],
261[
262# This should have been defined by AC_PROG_CC
263: "${CC:=cc}"
264
265AC_MSG_CHECKING(\$CFLAGS variable)
266case "x$CFLAGS" in
267(*-[[IUD]]*)
268	AC_MSG_RESULT(broken)
269	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
270	cf_flags="$CFLAGS"
271	CFLAGS=
272	for cf_arg in $cf_flags
273	do
274		CF_ADD_CFLAGS($cf_arg)
275	done
276	;;
277(*)
278	AC_MSG_RESULT(ok)
279	;;
280esac
281
282AC_MSG_CHECKING(\$CC variable)
283case "$CC" in
284(*[[\ \	]]-*)
285	AC_MSG_RESULT(broken)
286	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
287	# humor him...
288	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
289	cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
290	CC="$cf_prog"
291	for cf_arg in $cf_flags
292	do
293		case "x$cf_arg" in
294		(x-[[IUDfgOW]]*)
295			CF_ADD_CFLAGS($cf_arg)
296			;;
297		(*)
298			CC="$CC $cf_arg"
299			;;
300		esac
301	done
302	CF_VERBOSE(resulting CC: '$CC')
303	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
304	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
305	;;
306(*)
307	AC_MSG_RESULT(ok)
308	;;
309esac
310])dnl
311dnl ---------------------------------------------------------------------------
312dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
313dnl --------------
314dnl Check if we're accidentally using a cache from a different machine.
315dnl Derive the system name, as a check for reusing the autoconf cache.
316dnl
317dnl If we've packaged config.guess and config.sub, run that (since it does a
318dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
319dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
320dnl which is useful in cross-compiles.
321dnl
322dnl Note: we would use $ac_config_sub, but that is one of the places where
323dnl autoconf 2.5x broke compatibility with autoconf 2.13
324AC_DEFUN([CF_CHECK_CACHE],
325[
326if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
327	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
328	system_name="$host_os"
329else
330	system_name="`(uname -s -r) 2>/dev/null`"
331	if test -z "$system_name" ; then
332		system_name="`(hostname) 2>/dev/null`"
333	fi
334fi
335test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
336AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
337
338test -z "$system_name" && system_name="$cf_cv_system_name"
339test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
340
341if test ".$system_name" != ".$cf_cv_system_name" ; then
342	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
343	AC_MSG_ERROR("Please remove config.cache and try again.")
344fi
345])dnl
346dnl ---------------------------------------------------------------------------
347dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25
348dnl -----------------
349dnl Check if the given compiler is really clang.  clang's C driver defines
350dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
351dnl not ignore some gcc options.
352dnl
353dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
354dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
355dnl the wrappers for gcc and g++ warnings.
356dnl
357dnl $1 = GCC (default) or GXX
358dnl $2 = CLANG_COMPILER (default)
359dnl $3 = CFLAGS (default) or CXXFLAGS
360AC_DEFUN([CF_CLANG_COMPILER],[
361ifelse([$2],,CLANG_COMPILER,[$2])=no
362
363if test "$ifelse([$1],,[$1],GCC)" = yes ; then
364	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
365	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
366	AC_TRY_COMPILE([],[
367#ifdef __clang__
368#else
369#error __clang__ is not defined
370#endif
371],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
372],[])
373	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
374	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
375fi
376
377CLANG_VERSION=none
378
379if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
380	case "$CC" in
381	(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
382		AC_MSG_WARN(replacing broken compiler alias $CC)
383		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
384		CC=clang
385		;;
386	esac
387
388	AC_MSG_CHECKING(version of $CC)
389	CLANG_VERSION="`$CC --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(CLANG[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
390	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
391	AC_MSG_RESULT($CLANG_VERSION)
392
393	for cf_clang_opt in \
394		-Qunused-arguments \
395		-Wno-error=implicit-function-declaration
396	do
397		AC_MSG_CHECKING(if option $cf_clang_opt works)
398		cf_save_CFLAGS="$CFLAGS"
399		CFLAGS="$CFLAGS $cf_clang_opt"
400		AC_TRY_LINK([
401			#include <stdio.h>],[
402			printf("hello!\\n");],[
403			cf_clang_optok=yes],[
404			cf_clang_optok=no])
405		AC_MSG_RESULT($cf_clang_optok)
406		CFLAGS="$cf_save_CFLAGS"
407		if test "$cf_clang_optok" = yes; then
408			CF_VERBOSE(adding option $cf_clang_opt)
409			CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
410		fi
411	done
412fi
413])
414dnl ---------------------------------------------------------------------------
415dnl CF_CONST_X_STRING version: 8 updated: 2023/12/01 17:22:50
416dnl -----------------
417dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
418dnl character-strings.
419dnl
420dnl It is ambiguous because the specification accommodated the pre-ANSI
421dnl compilers bundled by more than one vendor in lieu of providing a standard C
422dnl compiler other than by costly add-ons.  Because of this, the specification
423dnl did not take into account the use of const for telling the compiler that
424dnl string literals would be in readonly memory.
425dnl
426dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
427dnl let the compiler decide how to represent Xt's strings which were #define'd.
428dnl That does not solve the problem of using the block of Xt's strings which
429dnl are compiled into the library (and is less efficient than one might want).
430dnl
431dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
432dnl when compiling the library and compiling using the library, to tell the
433dnl compiler that String is const.
434AC_DEFUN([CF_CONST_X_STRING],
435[
436AC_REQUIRE([AC_PATH_XTRA])
437
438CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
439
440AC_TRY_COMPILE(
441[
442#include <stdlib.h>
443#include <X11/Intrinsic.h>
444],
445[String foo = malloc(1); free((void*)foo)],[
446
447AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
448	AC_TRY_COMPILE(
449		[
450#undef  _CONST_X_STRING
451#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
452#undef  XTSTRINGDEFINES	/* X11R5 and later */
453#include <stdlib.h>
454#include <X11/Intrinsic.h>
455		],[String foo = malloc(1); *foo = 0],[
456			cf_cv_const_x_string=no
457		],[
458			cf_cv_const_x_string=yes
459		])
460])
461
462CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
463
464case "$cf_cv_const_x_string" in
465(no)
466	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
467	;;
468(*)
469	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
470	;;
471esac
472
473])
474])dnl
475dnl ---------------------------------------------------------------------------
476dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
477dnl ---------------
478dnl You can always use "make -n" to see the actual options, but it is hard to
479dnl pick out/analyze warning messages when the compile-line is long.
480dnl
481dnl Sets:
482dnl	ECHO_LT - symbol to control if libtool is verbose
483dnl	ECHO_LD - symbol to prefix "cc -o" lines
484dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
485dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
486dnl	ECHO_CC - symbol to put before any "cc" line
487dnl
488AC_DEFUN([CF_DISABLE_ECHO],[
489AC_MSG_CHECKING(if you want to see long compiling messages)
490CF_ARG_DISABLE(echo,
491	[  --disable-echo          do not display "compiling" commands],
492	[
493	ECHO_LT='--silent'
494	ECHO_LD='@echo linking [$]@;'
495	RULE_CC='@echo compiling [$]<'
496	SHOW_CC='@echo compiling [$]@'
497	ECHO_CC='@'
498],[
499	ECHO_LT=''
500	ECHO_LD=''
501	RULE_CC=''
502	SHOW_CC=''
503	ECHO_CC=''
504])
505AC_MSG_RESULT($enableval)
506AC_SUBST(ECHO_LT)
507AC_SUBST(ECHO_LD)
508AC_SUBST(RULE_CC)
509AC_SUBST(SHOW_CC)
510AC_SUBST(ECHO_CC)
511])dnl
512dnl ---------------------------------------------------------------------------
513dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
514dnl ----------------
515dnl Combine no-leak checks with the libraries or tools that are used for the
516dnl checks.
517AC_DEFUN([CF_DISABLE_LEAKS],[
518
519AC_REQUIRE([CF_WITH_DMALLOC])
520AC_REQUIRE([CF_WITH_DBMALLOC])
521AC_REQUIRE([CF_WITH_VALGRIND])
522
523AC_MSG_CHECKING(if you want to perform memory-leak testing)
524AC_ARG_ENABLE(leaks,
525	[  --disable-leaks         test: free permanent memory, analyze leaks],
526	[enable_leaks=$enableval],
527	[enable_leaks=yes])
528dnl with_no_leaks is more readable...
529if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
530AC_MSG_RESULT($with_no_leaks)
531
532if test "$enable_leaks" = no ; then
533	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
534	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
535fi
536])dnl
537dnl ---------------------------------------------------------------------------
538dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
539dnl ------------------
540dnl Configure-option to enable gcc warnings
541dnl
542dnl $1 = extra options to add, if supported
543dnl $2 = option for checking attributes.  By default, this is done when
544dnl      warnings are enabled.  For other values:
545dnl      yes: always do this, e.g., to use in generated library-headers
546dnl      no: never do this
547AC_DEFUN([CF_ENABLE_WARNINGS],[
548if test "$GCC" = yes || test "$GXX" = yes
549then
550CF_FIX_WARNINGS(CFLAGS)
551CF_FIX_WARNINGS(CPPFLAGS)
552CF_FIX_WARNINGS(LDFLAGS)
553AC_MSG_CHECKING(if you want to turn on gcc warnings)
554CF_ARG_ENABLE(warnings,
555	[  --enable-warnings       test: turn on gcc compiler warnings],
556	[enable_warnings=yes],
557	[enable_warnings=no])
558AC_MSG_RESULT($enable_warnings)
559if test "$enable_warnings" = "yes"
560then
561	ifelse($2,,[CF_GCC_ATTRIBUTES])
562	CF_GCC_WARNINGS($1)
563fi
564ifelse($2,yes,[CF_GCC_ATTRIBUTES])
565fi
566])dnl
567dnl ---------------------------------------------------------------------------
568dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31
569dnl ---------------
570dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
571dnl "-Werror" flags can interfere with configure-checks.  Those go into
572dnl EXTRA_CFLAGS.
573dnl
574dnl $1 = variable name to repair
575define([CF_FIX_WARNINGS],[
576if test "$GCC" = yes || test "$GXX" = yes
577then
578	case [$]$1 in
579	(*-Werror=*)
580		cf_temp_flags=
581		for cf_temp_scan in [$]$1
582		do
583			case "x$cf_temp_scan" in
584			(x-Werror=format*)
585				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
586				;;
587			(x-Werror=*)
588				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
589				;;
590			(*)
591				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
592				;;
593			esac
594		done
595		if test "x[$]$1" != "x$cf_temp_flags"
596		then
597			CF_VERBOSE(repairing $1: [$]$1)
598			$1="$cf_temp_flags"
599			CF_VERBOSE(... fixed [$]$1)
600			CF_VERBOSE(... extra $EXTRA_CFLAGS)
601		fi
602		;;
603	esac
604fi
605AC_SUBST(EXTRA_CFLAGS)
606])dnl
607dnl ---------------------------------------------------------------------------
608dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
609dnl -----------------
610dnl Test for availability of useful gcc __attribute__ directives to quiet
611dnl compiler warnings.  Though useful, not all are supported -- and contrary
612dnl to documentation, unrecognized directives cause older compilers to barf.
613AC_DEFUN([CF_GCC_ATTRIBUTES],
614[AC_REQUIRE([AC_PROG_FGREP])dnl
615AC_REQUIRE([CF_C11_NORETURN])dnl
616
617if test "$GCC" = yes || test "$GXX" = yes
618then
619cat > conftest.i <<EOF
620#ifndef GCC_PRINTF
621#define GCC_PRINTF 0
622#endif
623#ifndef GCC_SCANF
624#define GCC_SCANF 0
625#endif
626#ifndef GCC_NORETURN
627#define GCC_NORETURN /* nothing */
628#endif
629#ifndef GCC_UNUSED
630#define GCC_UNUSED /* nothing */
631#endif
632EOF
633if test "$GCC" = yes
634then
635	AC_CHECKING([for $CC __attribute__ directives])
636cat > "conftest.$ac_ext" <<EOF
637#line __oline__ "${as_me:-configure}"
638#include <stdio.h>
639#include "confdefs.h"
640#include "conftest.h"
641#include "conftest.i"
642#if	GCC_PRINTF
643#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
644#else
645#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
646#endif
647#if	GCC_SCANF
648#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
649#else
650#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
651#endif
652extern void wow(char *,...) GCC_SCANFLIKE(1,2);
653extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
654extern GCC_NORETURN void foo(void);
655int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
656EOF
657	cf_printf_attribute=no
658	cf_scanf_attribute=no
659	for cf_attribute in scanf printf unused noreturn
660	do
661		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
662		cf_directive="__attribute__(($cf_attribute))"
663		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
664
665		case "$cf_attribute" in
666		(printf)
667			cf_printf_attribute=yes
668			cat >conftest.h <<EOF
669#define GCC_$cf_ATTRIBUTE 1
670EOF
671			;;
672		(scanf)
673			cf_scanf_attribute=yes
674			cat >conftest.h <<EOF
675#define GCC_$cf_ATTRIBUTE 1
676EOF
677			;;
678		(*)
679			cat >conftest.h <<EOF
680#define GCC_$cf_ATTRIBUTE $cf_directive
681EOF
682			;;
683		esac
684
685		if AC_TRY_EVAL(ac_compile); then
686			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
687			cat conftest.h >>confdefs.h
688			case "$cf_attribute" in
689			(noreturn)
690				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
691				;;
692			(printf)
693				cf_value='/* nothing */'
694				if test "$cf_printf_attribute" != no ; then
695					cf_value='__attribute__((format(printf,fmt,var)))'
696					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
697				fi
698				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
699				;;
700			(scanf)
701				cf_value='/* nothing */'
702				if test "$cf_scanf_attribute" != no ; then
703					cf_value='__attribute__((format(scanf,fmt,var)))'
704					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
705				fi
706				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
707				;;
708			(unused)
709				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
710				;;
711			esac
712		fi
713	done
714else
715	${FGREP-fgrep} define conftest.i >>confdefs.h
716fi
717rm -rf ./conftest*
718fi
719])dnl
720dnl ---------------------------------------------------------------------------
721dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
722dnl --------------
723dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
724dnl compatible), attempt to determine if icc/clang is actually used.
725AC_DEFUN([CF_GCC_VERSION],[
726AC_REQUIRE([AC_PROG_CC])
727GCC_VERSION=none
728if test "$GCC" = yes ; then
729	AC_MSG_CHECKING(version of $CC)
730	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
731	test -z "$GCC_VERSION" && GCC_VERSION=unknown
732	AC_MSG_RESULT($GCC_VERSION)
733fi
734CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
735CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
736])dnl
737dnl ---------------------------------------------------------------------------
738dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
739dnl ---------------
740dnl Check if the compiler supports useful warning options.  There's a few that
741dnl we don't use, simply because they're too noisy:
742dnl
743dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
744dnl	-Winline (usually not worthwhile)
745dnl	-Wredundant-decls (system headers make this too noisy)
746dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
747dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
748dnl		is enabled for ncurses using "--enable-const".
749dnl	-pedantic
750dnl
751dnl Parameter:
752dnl	$1 is an optional list of gcc warning flags that a particular
753dnl		application might want to use, e.g., "no-unused" for
754dnl		-Wno-unused
755dnl Special:
756dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
757dnl
758AC_DEFUN([CF_GCC_WARNINGS],
759[
760AC_REQUIRE([CF_GCC_VERSION])
761if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
762cat > "conftest.$ac_ext" <<EOF
763#line __oline__ "${as_me:-configure}"
764int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
765EOF
766if test "$INTEL_COMPILER" = yes
767then
768# The "-wdXXX" options suppress warnings:
769# remark #1419: external declaration in primary source file
770# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
771# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
772# remark #193: zero used for undefined preprocessing identifier
773# remark #593: variable "curs_sb_left_arrow" was set but never used
774# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
775# remark #869: parameter "tw" was never referenced
776# remark #981: operands are evaluated in unspecified order
777# warning #279: controlling expression is constant
778
779	AC_CHECKING([for $CC warning options])
780	cf_save_CFLAGS="$CFLAGS"
781	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
782	for cf_opt in \
783		wd1419 \
784		wd1683 \
785		wd1684 \
786		wd193 \
787		wd593 \
788		wd279 \
789		wd810 \
790		wd869 \
791		wd981
792	do
793		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
794		if AC_TRY_EVAL(ac_compile); then
795			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
796			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
797		fi
798	done
799	CFLAGS="$cf_save_CFLAGS"
800elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
801then
802	AC_CHECKING([for $CC warning options])
803	cf_save_CFLAGS="$CFLAGS"
804	cf_warn_CONST=""
805	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
806	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
807	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
808	for cf_opt in W Wall \
809		Wbad-function-cast \
810		Wcast-align \
811		Wcast-qual \
812		Wdeclaration-after-statement \
813		Wextra \
814		Winline \
815		Wmissing-declarations \
816		Wmissing-prototypes \
817		Wnested-externs \
818		Wpointer-arith \
819		Wshadow \
820		Wstrict-prototypes \
821		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
822	do
823		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
824		if AC_TRY_EVAL(ac_compile); then
825			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
826			case "$cf_opt" in
827			(Winline)
828				case "$GCC_VERSION" in
829				([[34]].*)
830					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
831					continue;;
832				esac
833				;;
834			(Wpointer-arith)
835				case "$GCC_VERSION" in
836				([[12]].*)
837					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
838					continue;;
839				esac
840				;;
841			esac
842			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
843		fi
844	done
845	CFLAGS="$cf_save_CFLAGS"
846fi
847rm -rf ./conftest*
848
849AC_SUBST(EXTRA_CFLAGS)
850])dnl
851dnl ---------------------------------------------------------------------------
852dnl CF_GETOPT_HEADER version: 8 updated: 2021/06/19 19:16:16
853dnl ----------------
854dnl Check for getopt's variables which are commonly defined in stdlib.h,
855dnl unistd.h or (nonstandard) in getopt.h
856AC_DEFUN([CF_GETOPT_HEADER],
857[
858AC_HAVE_HEADERS(unistd.h getopt.h)
859AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
860cf_cv_getopt_header=none
861for cf_header in stdio.h stdlib.h unistd.h getopt.h
862do
863AC_TRY_COMPILE([
864#include <$cf_header>],
865[int x = optind; char *y = optarg; (void)x; (void)y],
866[cf_cv_getopt_header=$cf_header
867 break])
868done
869])
870if test "$cf_cv_getopt_header" != none ; then
871	AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
872fi
873if test "$cf_cv_getopt_header" = getopt.h ; then
874	AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
875fi
876])dnl
877dnl ---------------------------------------------------------------------------
878dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
879dnl -------------
880dnl Check if we must define _GNU_SOURCE to get a reasonable value for
881dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
882dnl (or misfeature) of glibc2, which breaks portability of many applications,
883dnl since it is interwoven with GNU extensions.
884dnl
885dnl Well, yes we could work around it...
886dnl
887dnl Parameters:
888dnl	$1 is the nominal value for _XOPEN_SOURCE
889AC_DEFUN([CF_GNU_SOURCE],
890[
891cf_gnu_xopen_source=ifelse($1,,500,$1)
892
893AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
894AC_TRY_COMPILE([#include <sys/types.h>],[
895	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
896		return 0;
897	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
898		return 0;
899	#else
900	#	error not GNU C library
901	#endif],
902	[cf_cv_gnu_library=yes],
903	[cf_cv_gnu_library=no])
904])
905
906if test x$cf_cv_gnu_library = xyes; then
907
908	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
909	# was changed to help a little.  newlib incorporated the change about 4
910	# years later.
911	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
912		cf_save="$CPPFLAGS"
913		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
914		AC_TRY_COMPILE([#include <sys/types.h>],[
915			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
916				return 0;
917			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
918				return 0;
919			#else
920			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
921			#endif],
922			[cf_cv_gnu_library_219=yes],
923			[cf_cv_gnu_library_219=no])
924		CPPFLAGS="$cf_save"
925	])
926
927	if test "x$cf_cv_gnu_library_219" = xyes; then
928		cf_save="$CPPFLAGS"
929		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
930			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
931			AC_TRY_COMPILE([
932				#include <limits.h>
933				#include <sys/types.h>
934				],[
935				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
936					return 0;
937				#else
938				#	error GNU C library is too old
939				#endif],
940				[cf_cv_gnu_dftsrc_219=yes],
941				[cf_cv_gnu_dftsrc_219=no])
942			])
943		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
944	else
945		cf_cv_gnu_dftsrc_219=maybe
946	fi
947
948	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
949
950		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
951		AC_TRY_COMPILE([#include <sys/types.h>],[
952			#ifndef _XOPEN_SOURCE
953			#error	expected _XOPEN_SOURCE to be defined
954			#endif],
955			[cf_cv_gnu_source=no],
956			[cf_save="$CPPFLAGS"
957			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
958			 AC_TRY_COMPILE([#include <sys/types.h>],[
959				#ifdef _XOPEN_SOURCE
960				#error	expected _XOPEN_SOURCE to be undefined
961				#endif],
962				[cf_cv_gnu_source=no],
963				[cf_cv_gnu_source=yes])
964			CPPFLAGS="$cf_save"
965			])
966		])
967
968		if test "$cf_cv_gnu_source" = yes
969		then
970		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
971			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
972			AC_TRY_COMPILE([#include <sys/types.h>],[
973				#ifdef _DEFAULT_SOURCE
974				#error	expected _DEFAULT_SOURCE to be undefined
975				#endif],
976				[cf_cv_default_source=no],
977				[cf_cv_default_source=yes])
978			])
979			if test "$cf_cv_default_source" = yes
980			then
981				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
982			fi
983		fi
984	fi
985
986fi
987])dnl
988dnl ---------------------------------------------------------------------------
989dnl CF_INSTALL_MAN version: 5 updated: 2023/05/21 15:53:07
990dnl --------------
991dnl Call this to generate a script "install-man" which uses the detected
992dnl manpage-format to compress the resulting manpage.  Providing this as a
993dnl macro simplifies including the script in different programs.
994dnl
995dnl The generated script assumes that the program can be renamed, using two
996dnl symbols in the manpage, e.g.,
997dnl		.ds N Yacc
998dnl     .ds n yacc
999dnl which are later used as \*N and \*n, as well as a special case in the
1000dnl synopsis to work around limitations of makewhatis.
1001dnl
1002dnl Script parameters:
1003dnl	$1 = input file
1004dnl	$2 = output filename
1005dnl
1006dnl or (uninstall):
1007dnl	$1 = output filename
1008AC_DEFUN([CF_INSTALL_MAN],
1009[
1010AC_REQUIRE([AC_ARG_PROGRAM])
1011AC_REQUIRE([AC_PROG_INSTALL])
1012AC_REQUIRE([AC_LN_S])
1013AC_REQUIRE([CF_MANPAGE_FORMAT])
1014cf_install_man=install-man
1015ac_config_files="$ac_config_files $cf_install_man"
1016cf_install_man=$cf_install_man.in
1017echo [$]as_me: creating $cf_install_man
1018cat >[$]cf_install_man <<"CF_EOF"
1019#!/bin/sh
1020# generated by CF_INSTALL_MAN
1021
1022LANG=C;     export LANG
1023LC_ALL=C;   export LC_ALL
1024LC_CTYPE=C; export LC_CTYPE
1025LANGUAGE=C; export LANGUAGE
1026
1027INSTALL="@INSTALL@"
1028INSTALL_DATA="@INSTALL_DATA@"
1029
1030usage() {
1031	cat <<EOF
1032Usage: install-man [[-l]] [[source]] target
1033EOF
1034	exit 1
1035}
1036
1037failed() {
1038	echo "?? [$]*" >&2
1039	exit 1
1040}
1041
1042test [$]# != 0 || usage
1043OPTS=
1044case "x[$]1" in
1045(x-l)
1046	OPTS="link"
1047	shift
1048	;;
1049(x-*)
1050	usage
1051	;;
1052esac
1053
1054source=
1055if test [$]# = 2 ; then
1056	source=[$]1; shift
1057	target=[$]1
1058elif test [$]# = 1 ; then
1059	test -n "$OPTS" && usage
1060	target=[$]1
1061else
1062	usage
1063fi
1064
1065origin_name=`echo "$source" |sed -e 's%^.*/%%' -e 's%\..*%%'`
1066actual_name=`echo "$origin_name" |sed '@program_transform_name@'`
1067leading_cap=`echo "$actual_name" | sed -e 's%^\(.\).*$%\1%' | tr a-z A-Z``echo "$actual_name" | sed -e 's%^.%%'`
1068capitalized=`echo "$actual_name" | tr a-z A-Z`
1069
1070cf_tmpdir=`mktemp -d`
1071trap 'rm -rf "$cf_tmpdir"; exit 1' 1 2 3 15
1072trap 'rm -rf "$cf_tmpdir"; exit 0' 0
1073
1074if test -n "$source" ; then
1075	suffix=
1076	test -n "@cf_manpage_so_strip" && suffix=".@cf_manpage_so_strip@"
1077	if test "x$OPTS" = xlink ; then
1078		source_dir=`echo "$source" | sed -e "s%/[[^/]]*$%%"`
1079		target_dir=`echo "$target" | sed -e "s%/[[^/]]*$%%"`
1080		sourcelink="${source}${suffix}"
1081		targetfile="${target}${suffix}"
1082		targetlink="${target_dir}/${sourcelink}"
1083		if test ! -d "$target_dir" ; then
1084			failed "target directory does not exist: $target_dir"
1085		elif test ! -f "$targetfile" ; then
1086			failed "target file does not exist: $targetfile"
1087		elif test "$source" != "$source_dir" ; then
1088			failed "unexpected directory for source-link: $source_dir"
1089		fi
1090		test -f "$targetlink" && failed "already exists $targetlink"
1091		( cd "$target_dir" && @LN_S@ "`echo "$targetfile" | sed -e 's%^.*/%%'`" "$sourcelink" )
1092		test -f "$targetlink" || failed "cannot create $targetlink"
1093		target="$targetlink"
1094	else
1095		echo "** installing $source to $target"
1096		interim="$cf_tmpdir"/"`basename $source`"
1097		if test "x$origin_name" != "x$actual_name" ; then
1098			sed \
1099				-e "/^.ds N/s%N.*%N $leading_cap%" \
1100				-e "/^.ds n/s%n.*%n $actual_name%" \
1101				-e "/^\.TH/s%[[ ]][[ ]]*[[^ ]][[^ ]]*% $capitalized%" \
1102				-e "/^\.SH[[ ]][[ ]]*NAME/,/[[ ]]\\\\-[[ ]]/s%^\\\\\\*[[Nn]]%$actual_name%" \
1103				"$source" >"$interim" || exit 1
1104			diff -c "$source" "$interim"
1105		else
1106			cp "$source" "$interim" || exit 1
1107		fi
1108		if test -n "@cf_manpage_compress@" ; then
1109			@cf_manpage_compress@ "$interim"
1110			source="${interim}${suffix}"
1111		fi
1112		if test -d "$target" ; then
1113			target="$target"/"$source"
1114		else
1115			test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
1116		fi
1117		$INSTALL_DATA "$source" "$target" || exit 1
1118	fi
1119	echo "...installed $target"
1120else
1121	echo "** removing $target"
1122	test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
1123	if test -f "$target" ; then
1124		rm -f "$target"
1125		echo "...removed $target"
1126	else
1127		echo "...not found"
1128	fi
1129fi
1130exit 0
1131CF_EOF
1132])dnl
1133dnl ---------------------------------------------------------------------------
1134dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25
1135dnl -----------------
1136dnl Check if the given compiler is really the Intel compiler for Linux.  It
1137dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1138dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1139dnl
1140dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1141dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1142dnl the wrappers for gcc and g++ warnings.
1143dnl
1144dnl $1 = GCC (default) or GXX
1145dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1146dnl $3 = CFLAGS (default) or CXXFLAGS
1147AC_DEFUN([CF_INTEL_COMPILER],[
1148AC_REQUIRE([AC_CANONICAL_HOST])
1149ifelse([$2],,INTEL_COMPILER,[$2])=no
1150
1151if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1152	case "$host_os" in
1153	(linux*|gnu*)
1154		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1155		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1156		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1157		AC_TRY_COMPILE([],[
1158#ifdef __INTEL_COMPILER
1159#else
1160#error __INTEL_COMPILER is not defined
1161#endif
1162],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1163cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1164],[])
1165		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1166		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1167		;;
1168	esac
1169fi
1170])dnl
1171dnl ---------------------------------------------------------------------------
1172dnl CF_MAKE_DOCS version: 5 updated: 2021/01/10 16:05:11
1173dnl ------------
1174dnl $1 = name(s) to generate rules for
1175dnl $2 = suffix of corresponding manpages used as input.
1176dnl
1177dnl This works best if called at the end of configure.in, following CF_WITH_MAN2HTML
1178define([CF_MAKE_DOCS],[
1179test -z "$cf_make_docs" && cf_make_docs=0
1180
1181cf_output=makefile
1182test -f "$cf_output" || cf_output=Makefile
1183
1184if test "$cf_make_docs" = 0
1185then
1186cat >>$cf_output <<CF_EOF
1187################################################################################
1188## generated by $0
1189.SUFFIXES : .html .$2 .man .ps .pdf .txt
1190
1191${NROFF_NOTE}.$2.txt :
1192${NROFF_NOTE}	[\$](SHELL) -c "tbl [\$]*.$2 | nroff -man | col -bx" >[\$]@
1193
1194${GROFF_NOTE}.ps.pdf :
1195${GROFF_NOTE}	ps2pdf [\$]*.ps
1196${GROFF_NOTE}
1197${GROFF_NOTE}.$2.ps :
1198${GROFF_NOTE}	[\$](SHELL) -c "tbl [\$]*.$2 | groff -man" >[\$]@
1199${GROFF_NOTE}
1200${GROFF_NOTE}.$2.txt :
1201${GROFF_NOTE}	GROFF_NO_SGR=stupid [\$](SHELL) -c "tbl [\$]*.$2 | nroff -rHY=0 -Tascii -man | col -bx" >[\$]@
1202
1203${MAN2HTML_NOTE}.$2.html :
1204${MAN2HTML_NOTE}	./${MAN2HTML_TEMP} [\$]* $2 man >[\$]@
1205
1206CF_EOF
1207	cf_make_docs=1
1208fi
1209
1210for cf_name in $1
1211do
1212cat >>$cf_output <<CF_EOF
1213################################################################################
1214${NROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
1215${MAN2HTML_NOTE}docs docs-$cf_name :: $cf_name.html
1216${GROFF_NOTE}docs docs-$cf_name :: $cf_name.pdf
1217${GROFF_NOTE}docs docs-$cf_name :: $cf_name.ps
1218${GROFF_NOTE}docs docs-$cf_name :: $cf_name.txt
1219
1220clean \\
1221docs-clean ::
1222${NROFF_NOTE}	rm -f $cf_name.txt
1223${MAN2HTML_NOTE}	rm -f $cf_name.html
1224${GROFF_NOTE}	rm -f $cf_name.pdf
1225${GROFF_NOTE}	rm -f $cf_name.ps
1226${GROFF_NOTE}	rm -f $cf_name.txt
1227
1228${NROFF_NOTE}$cf_name.txt  : $cf_name.$2
1229${MAN2HTML_NOTE}$cf_name.html : $cf_name.$2
1230${GROFF_NOTE}$cf_name.pdf  : $cf_name.ps
1231${GROFF_NOTE}$cf_name.ps   : $cf_name.$2
1232${GROFF_NOTE}$cf_name.txt  : $cf_name.$2
1233CF_EOF
1234done
1235])dnl
1236dnl ---------------------------------------------------------------------------
1237dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1238dnl ------------
1239dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1240dnl a monocase filesystem.
1241AC_DEFUN([CF_MAKE_TAGS],[
1242AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1243
1244AC_CHECK_PROGS(CTAGS, exctags ctags)
1245AC_CHECK_PROGS(ETAGS, exetags etags)
1246
1247AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1248
1249if test "$cf_cv_mixedcase" = yes ; then
1250	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1251else
1252	MAKE_UPPER_TAGS=no
1253fi
1254
1255if test "$MAKE_UPPER_TAGS" = yes ; then
1256	MAKE_UPPER_TAGS=
1257else
1258	MAKE_UPPER_TAGS="#"
1259fi
1260
1261if test "$MAKE_LOWER_TAGS" = yes ; then
1262	MAKE_LOWER_TAGS=
1263else
1264	MAKE_LOWER_TAGS="#"
1265fi
1266
1267AC_SUBST(CTAGS)
1268AC_SUBST(ETAGS)
1269
1270AC_SUBST(MAKE_UPPER_TAGS)
1271AC_SUBST(MAKE_LOWER_TAGS)
1272])dnl
1273dnl ---------------------------------------------------------------------------
1274dnl CF_MANPAGE_FORMAT version: 18 updated: 2023/05/19 18:35:02
1275dnl -----------------
1276dnl Option to allow user to override automatic configuration of manpage format.
1277dnl There are several special cases:
1278dnl
1279dnl	compress - man checks for, can display compressed files
1280dnl	bzip2 - man checks for, can display bzip2'd files
1281dnl	gzip - man checks for, can display gzip'd files
1282dnl	xz - man checks for, can display xz'd files
1283dnl
1284dnl	BSDI - files in the cat-directories are suffixed ".0"
1285dnl	formatted - installer should format (put files in cat-directory)
1286dnl	catonly - installer should only format, e.g., for a turnkey system.
1287dnl
1288dnl There are other configurations which this macro does not test, e.g., HPUX's
1289dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
1290dnl convention would not match our use).
1291AC_DEFUN([CF_MANPAGE_FORMAT],
1292[
1293AC_REQUIRE([CF_PATHSEP])
1294AC_MSG_CHECKING(format of man-pages)
1295
1296AC_ARG_WITH(manpage-format,
1297	[  --with-manpage-format   specify manpage-format: gzip/compress/bzip2/xz,
1298                          BSDI/normal and optionally formatted/catonly,
1299                          e.g., gzip,formatted],
1300	[MANPAGE_FORMAT=$withval],
1301	[MANPAGE_FORMAT=unknown])
1302
1303test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
1304MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
1305
1306cf_unknown=
1307
1308case "$MANPAGE_FORMAT" in
1309(unknown)
1310	if test -z "$MANPATH" ; then
1311		MANPATH="/usr/man:/usr/share/man"
1312	fi
1313
1314	# look for the 'date' man-page (it is most likely to be installed!)
1315	MANPAGE_FORMAT=
1316	cf_preform="no"
1317	cf_catonly="yes"
1318	cf_example="date"
1319
1320	IFS="${IFS:- 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
1321	for cf_dir in $MANPATH; do
1322		test -z "$cf_dir" && cf_dir=/usr/man
1323		for cf_name in $cf_dir/man*/$cf_example.[[01]]* $cf_dir/cat*/$cf_example.[[01]]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
1324		do
1325			cf_test=`echo "$cf_name" | sed -e 's/*//'`
1326			if test "x$cf_test" = "x$cf_name" ; then
1327
1328				case "$cf_name" in
1329				(*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";;
1330				(*.xz)  MANPAGE_FORMAT="$MANPAGE_FORMAT xz";;
1331				(*.gz)  MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
1332				(*.Z)   MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
1333				(*.0)   MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
1334				(*)     MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
1335				esac
1336
1337				case "$cf_name" in
1338				($cf_dir/man*)
1339					cf_catonly=no
1340					;;
1341				($cf_dir/cat*)
1342					cf_preform=yes
1343					;;
1344				esac
1345				break
1346			fi
1347
1348			# if we found a match in either man* or cat*, stop looking
1349			if test -n "$MANPAGE_FORMAT" ; then
1350				cf_found=no
1351				test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
1352				test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
1353				case "$cf_name" in
1354				($cf_dir/cat*)
1355					cf_found=yes
1356					;;
1357				esac
1358				test "$cf_found" = yes && break
1359			fi
1360		done
1361		# only check the first directory in $MANPATH where we find manpages
1362		if test -n "$MANPAGE_FORMAT" ; then
1363			break
1364		fi
1365	done
1366	# if we did not find the example, just assume it is normal
1367	test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
1368	IFS="$ac_save_ifs"
1369	;;
1370(*)
1371	for cf_option in $MANPAGE_FORMAT; do
1372	case "$cf_option" in
1373	(xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly)
1374		;;
1375	(*)
1376		cf_unknown="$cf_unknown $cf_option"
1377		;;
1378	esac
1379	done
1380	;;
1381esac
1382
1383AC_MSG_RESULT($MANPAGE_FORMAT)
1384if test -n "$cf_unknown" ; then
1385	AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
1386fi
1387
1388cf_manpage_format=no
1389cf_manpage_inboth=no
1390cf_manpage_so_strip=
1391cf_manpage_compress=
1392
1393for cf_item in $MANPAGE_FORMAT
1394do
1395case "$cf_item" in
1396(catonly)
1397	cf_manpage_format=yes
1398	cf_manpage_inboth=no
1399	;;
1400(formatted)
1401	cf_manpage_format=yes
1402	cf_manpage_inboth=yes
1403	;;
1404(compress)
1405	cf_manpage_so_strip="Z"
1406	cf_manpage_compress=compress
1407	;;
1408(gzip)
1409	cf_manpage_so_strip="gz"
1410	cf_manpage_compress=gzip
1411	;;
1412(bzip2)
1413	cf_manpage_so_strip="bz2"
1414	cf_manpage_compress=bzip2
1415	;;
1416(xz)
1417	cf_manpage_so_strip="xz"
1418	cf_manpage_compress=xz
1419	;;
1420esac
1421done
1422
1423AC_SUBST(cf_manpage_format)
1424AC_SUBST(cf_manpage_inboth)
1425AC_SUBST(cf_manpage_so_strip)
1426AC_SUBST(cf_manpage_compress)
1427
1428])dnl
1429dnl ---------------------------------------------------------------------------
1430dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
1431dnl ----------------------
1432dnl Check if the file-system supports mixed-case filenames.  If we're able to
1433dnl create a lowercase name and see it as uppercase, it doesn't support that.
1434AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1435[
1436AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1437if test "$cross_compiling" = yes ; then
1438	case "$target_alias" in
1439	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
1440		cf_cv_mixedcase=no
1441		;;
1442	(*)
1443		cf_cv_mixedcase=yes
1444		;;
1445	esac
1446else
1447	rm -f conftest CONFTEST
1448	echo test >conftest
1449	if test -f CONFTEST ; then
1450		cf_cv_mixedcase=no
1451	else
1452		cf_cv_mixedcase=yes
1453	fi
1454	rm -f conftest CONFTEST
1455fi
1456])
1457test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1458])dnl
1459dnl ---------------------------------------------------------------------------
1460dnl CF_MKSTEMP version: 13 updated: 2023/12/01 17:22:50
1461dnl ----------
1462dnl Check for a working mkstemp.  This creates two files, checks that they are
1463dnl successfully created and distinct (AmigaOS apparently fails on the last).
1464AC_DEFUN([CF_MKSTEMP],[
1465AC_CHECK_HEADERS( \
1466unistd.h \
1467)
1468AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
1469rm -rf ./conftest*
1470AC_TRY_RUN([
1471$ac_includes_default
1472
1473int main(void)
1474{
1475	static char tmpl[] = "conftestXXXXXX";
1476	char name[2][80];
1477	int n;
1478	int result = 0;
1479	int fd;
1480	struct stat sb;
1481
1482	umask(077);
1483	for (n = 0; n < 2; ++n) {
1484		strcpy(name[n], tmpl);
1485		if ((fd = mkstemp(name[n])) >= 0) {
1486			if (!strcmp(name[n], tmpl)
1487			 || stat(name[n], &sb) != 0
1488			 || (sb.st_mode & S_IFMT) != S_IFREG
1489			 || (sb.st_mode & 077) != 0) {
1490				result = 1;
1491			}
1492			close(fd);
1493		}
1494	}
1495	if (result == 0
1496	 && !strcmp(name[0], name[1]))
1497		result = 1;
1498	${cf_cv_main_return:-return}(result);
1499}
1500],[cf_cv_func_mkstemp=yes
1501],[cf_cv_func_mkstemp=no
1502],[cf_cv_func_mkstemp=maybe])
1503])
1504if test "x$cf_cv_func_mkstemp" = xmaybe ; then
1505	AC_CHECK_FUNC(mkstemp)
1506fi
1507if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1508	AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
1509fi
1510])dnl
1511dnl ---------------------------------------------------------------------------
1512dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1513dnl ----------
1514dnl Write a debug message to config.log, along with the line number in the
1515dnl configure script.
1516AC_DEFUN([CF_MSG_LOG],[
1517echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1518])dnl
1519dnl ---------------------------------------------------------------------------
1520dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
1521dnl ------------------
1522dnl see CF_WITH_NO_LEAKS
1523dnl
1524dnl $1 = option/name
1525dnl $2 = help-text
1526dnl $3 = symbol to define if the option is set
1527dnl $4 = additional actions to take if the option is set
1528AC_DEFUN([CF_NO_LEAKS_OPTION],[
1529AC_MSG_CHECKING(if you want to use $1 for testing)
1530AC_ARG_WITH($1,
1531	[$2],
1532	[case "x$withval" in
1533	(x|xno) ;;
1534	(*)
1535		: "${with_cflags:=-g}"
1536		: "${enable_leaks:=no}"
1537		with_$1=yes
1538		AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
1539	 $4
1540])
1541		;;
1542	esac],
1543	[with_$1=])
1544AC_MSG_RESULT(${with_$1:-no})
1545
1546case ".$with_cflags" in
1547(.*-g*)
1548	case .$CFLAGS in
1549	(.*-g*)
1550		;;
1551	(*)
1552		CF_ADD_CFLAGS([-g])
1553		;;
1554	esac
1555	;;
1556esac
1557])dnl
1558dnl ---------------------------------------------------------------------------
1559dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
1560dnl ----------
1561dnl Provide a value for the $PATH and similar separator (or amend the value
1562dnl as provided in autoconf 2.5x).
1563AC_DEFUN([CF_PATHSEP],
1564[
1565	AC_MSG_CHECKING(for PATH separator)
1566	case "$cf_cv_system_name" in
1567	(os2*)	PATH_SEPARATOR=';'  ;;
1568	(*)	${PATH_SEPARATOR:=':'}  ;;
1569	esac
1570ifelse([$1],,,[$1=$PATH_SEPARATOR])
1571	AC_SUBST(PATH_SEPARATOR)
1572	AC_MSG_RESULT($PATH_SEPARATOR)
1573])dnl
1574dnl ---------------------------------------------------------------------------
1575dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
1576dnl --------------
1577dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1578dnl begins with one of the prefix/exec_prefix variables, and then again if the
1579dnl result begins with 'NONE'.  This is necessary to work around autoconf's
1580dnl delayed evaluation of those symbols.
1581AC_DEFUN([CF_PATH_SYNTAX],[
1582if test "x$prefix" != xNONE; then
1583	cf_path_syntax="$prefix"
1584else
1585	cf_path_syntax="$ac_default_prefix"
1586fi
1587
1588case ".[$]$1" in
1589(.\[$]\(*\)*|.\'*\'*)
1590	;;
1591(..|./*|.\\*)
1592	;;
1593(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
1594	;;
1595(.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
1596	eval $1="[$]$1"
1597	case ".[$]$1" in
1598	(.NONE/*)
1599		$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
1600		;;
1601	esac
1602	;;
1603(.no|.NONE/*)
1604	$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
1605	;;
1606(*)
1607	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1608	;;
1609esac
1610])dnl
1611dnl ---------------------------------------------------------------------------
1612dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25
1613dnl -----------------
1614dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1615dnl
1616dnl	POSIX.1-1990				_POSIX_SOURCE
1617dnl	POSIX.1-1990 and			_POSIX_SOURCE and
1618dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
1619dnl		Bindings Option
1620dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
1621dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
1622dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
1623dnl
1624dnl Parameters:
1625dnl	$1 is the nominal value for _POSIX_C_SOURCE
1626AC_DEFUN([CF_POSIX_C_SOURCE],
1627[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
1628
1629if test "$cf_cv_posix_visible" = no; then
1630
1631cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
1632
1633cf_save_CFLAGS="$CFLAGS"
1634cf_save_CPPFLAGS="$CPPFLAGS"
1635
1636CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1637CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1638
1639AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1640	CF_MSG_LOG(if the symbol is already defined go no further)
1641	AC_TRY_COMPILE([#include <sys/types.h>],[
1642#ifndef _POSIX_C_SOURCE
1643#error _POSIX_C_SOURCE is not defined
1644#endif],
1645	[cf_cv_posix_c_source=no],
1646	[cf_want_posix_source=no
1647	 case .$cf_POSIX_C_SOURCE in
1648	 (.[[12]]??*)
1649		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1650		;;
1651	 (.2)
1652		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1653		cf_want_posix_source=yes
1654		;;
1655	 (.*)
1656		cf_want_posix_source=yes
1657		;;
1658	 esac
1659	 if test "$cf_want_posix_source" = yes ; then
1660		AC_TRY_COMPILE([#include <sys/types.h>],[
1661#ifdef _POSIX_SOURCE
1662#error _POSIX_SOURCE is defined
1663#endif],[],
1664		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1665	 fi
1666	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1667	 CFLAGS="$cf_trim_CFLAGS"
1668	 CPPFLAGS="$cf_trim_CPPFLAGS"
1669	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
1670	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1671	 AC_TRY_COMPILE([#include <sys/types.h>],[
1672#ifndef _POSIX_C_SOURCE
1673#error _POSIX_C_SOURCE is not defined
1674#endif],,
1675	 [cf_cv_posix_c_source=no])
1676	 CFLAGS="$cf_save_CFLAGS"
1677	 CPPFLAGS="$cf_save_CPPFLAGS"
1678	])
1679])
1680
1681if test "$cf_cv_posix_c_source" != no ; then
1682	CFLAGS="$cf_trim_CFLAGS"
1683	CPPFLAGS="$cf_trim_CPPFLAGS"
1684	CF_ADD_CFLAGS($cf_cv_posix_c_source)
1685fi
1686
1687fi # cf_cv_posix_visible
1688
1689])dnl
1690dnl ---------------------------------------------------------------------------
1691dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
1692dnl ----------------
1693dnl POSIX documents test-macros which an application may set before any system
1694dnl headers are included to make features available.
1695dnl
1696dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
1697dnl diverged from POSIX in 2002 by setting symbols which make all of the most
1698dnl recent features visible in the system header files unless the application
1699dnl overrides the corresponding test-macros.  Doing that introduces portability
1700dnl problems.
1701dnl
1702dnl This macro makes a special check for the symbols used for this, to avoid a
1703dnl conflicting definition.
1704AC_DEFUN([CF_POSIX_VISIBLE],
1705[
1706AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
1707AC_TRY_COMPILE([#include <stdio.h>],[
1708#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
1709	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
1710	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
1711	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
1712#error conflicting symbols found
1713#endif
1714],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
1715])
1716])dnl
1717dnl ---------------------------------------------------------------------------
1718dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
1719dnl -----------
1720dnl Check for awk, ensure that the check found something.
1721AC_DEFUN([CF_PROG_AWK],
1722[
1723AC_PROG_AWK
1724test -z "$AWK" && AC_MSG_ERROR(No awk program found)
1725])dnl
1726dnl ---------------------------------------------------------------------------
1727dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
1728dnl ----------
1729dnl standard check for CC, plus followup sanity checks
1730dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
1731AC_DEFUN([CF_PROG_CC],[
1732CF_ACVERSION_CHECK(2.53,
1733	[AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
1734	 AC_REQUIRE([AC_PROG_CC])],
1735	[])
1736ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
1737CF_GCC_VERSION
1738CF_ACVERSION_CHECK(2.52,
1739	[AC_PROG_CC_STDC],
1740	[CF_ANSI_CC_REQD])
1741CF_CC_ENV_FLAGS
1742])dnl
1743dnl ---------------------------------------------------------------------------
1744dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
1745dnl -------------
1746dnl Check if groff is available, for cases (such as html output) where nroff
1747dnl is not enough.
1748AC_DEFUN([CF_PROG_GROFF],[
1749AC_PATH_PROG(GROFF_PATH,groff,no)
1750AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
1751AC_PATH_PROG(TBL_PATH,tbl,cat)
1752if test "x$GROFF_PATH" = xno
1753then
1754	NROFF_NOTE=
1755	GROFF_NOTE="#"
1756else
1757	NROFF_NOTE="#"
1758	GROFF_NOTE=
1759fi
1760AC_SUBST(GROFF_NOTE)
1761AC_SUBST(NROFF_NOTE)
1762])dnl
1763dnl ---------------------------------------------------------------------------
1764dnl CF_PROG_LINT version: 5 updated: 2022/08/20 15:44:13
1765dnl ------------
1766AC_DEFUN([CF_PROG_LINT],
1767[
1768AC_CHECK_PROGS(LINT, lint cppcheck splint)
1769case "x$LINT" in
1770(xcppcheck|x*/cppcheck)
1771	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
1772	;;
1773esac
1774AC_SUBST(LINT_OPTS)
1775AC_SUBST(LINT_LIBS)
1776])dnl
1777dnl ---------------------------------------------------------------------------
1778dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40
1779dnl ----------------
1780dnl Remove a given option from CFLAGS/CPPFLAGS
1781dnl $1 = option to remove
1782dnl $2 = variable to update
1783dnl $3 = nonempty to allow verbose message
1784define([CF_REMOVE_CFLAGS],
1785[
1786cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
1787while true
1788do
1789	cf_old_cflag=`echo "x[$]$2" | sed -e 's/^.//' -e 's/[[ 	]][[ 	]]*-/ -/g' -e "s%$cf_tmp_cflag\\(=[[^ 	]][[^ 	]]*\\)\?%%" -e 's/^[[ 	]]*//' -e 's%[[ ]][[ ]]*-D% -D%g' -e 's%[[ ]][[ ]]*-I% -I%g'`
1790	test "[$]$2" != "$cf_old_cflag" || break
1791	ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
1792	$2="$cf_old_cflag"
1793done
1794])dnl
1795dnl ---------------------------------------------------------------------------
1796dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
1797dnl ----------------
1798dnl Remove all -U and -D options that refer to the given symbol from a list
1799dnl of C compiler options.  This works around the problem that not all
1800dnl compilers process -U and -D options from left-to-right, so a -U option
1801dnl cannot be used to cancel the effect of a preceding -D option.
1802dnl
1803dnl $1 = target (which could be the same as the source variable)
1804dnl $2 = source (including '$')
1805dnl $3 = symbol to remove
1806define([CF_REMOVE_DEFINE],
1807[
1808$1=`echo "$2" | \
1809	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
1810		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
1811])dnl
1812dnl ---------------------------------------------------------------------------
1813dnl CF_TRY_XOPEN_SOURCE version: 4 updated: 2022/09/10 15:16:16
1814dnl -------------------
1815dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
1816dnl can define it successfully.
1817AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
1818AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1819	AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
1820	[cf_cv_xopen_source=no],
1821	[cf_save="$CPPFLAGS"
1822	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
1823	 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
1824		[cf_cv_xopen_source=no],
1825		[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1826		CPPFLAGS="$cf_save"
1827	])
1828])
1829
1830if test "$cf_cv_xopen_source" != no ; then
1831	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1832	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1833	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
1834	CF_APPEND_CFLAGS($cf_temp_xopen_source)
1835fi
1836])
1837dnl ---------------------------------------------------------------------------
1838dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1839dnl --------
1840dnl Make an uppercase version of a variable
1841dnl $1=uppercase($2)
1842AC_DEFUN([CF_UPPER],
1843[
1844$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1845])dnl
1846dnl ---------------------------------------------------------------------------
1847dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
1848dnl ----------
1849dnl Use AC_VERBOSE w/o the warnings
1850AC_DEFUN([CF_VERBOSE],
1851[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
1852CF_MSG_LOG([$1])
1853])dnl
1854dnl ---------------------------------------------------------------------------
1855dnl CF_WITHOUT_X version: 3 updated: 2021/01/13 16:51:52
1856dnl ------------
1857dnl Use this to cancel the check for X headers/libraries which would be pulled
1858dnl in via CF_GCC_WARNINGS.
1859define([CF_WITHOUT_X],
1860AC_DEFUN([AC_PATH_XTRA],[])
1861AC_DEFUN([CF_SAVE_XTRA_FLAGS],[])
1862AC_DEFUN([CF_RESTORE_XTRA_FLAGS],[])
1863AC_DEFUN([CF_CONST_X_STRING],[echo "skipping X-const check";])dnl
1864AC_SUBST(X_CFLAGS)
1865AC_SUBST(X_LIBS)
1866[])dnl
1867dnl ---------------------------------------------------------------------------
1868dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
1869dnl ----------------
1870dnl Configure-option for dbmalloc.  The optional parameter is used to override
1871dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1872AC_DEFUN([CF_WITH_DBMALLOC],[
1873CF_NO_LEAKS_OPTION(dbmalloc,
1874	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
1875	[USE_DBMALLOC])
1876
1877if test "$with_dbmalloc" = yes ; then
1878	AC_CHECK_HEADER(dbmalloc.h,
1879		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
1880fi
1881])dnl
1882dnl ---------------------------------------------------------------------------
1883dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
1884dnl ---------------
1885dnl Configure-option for dmalloc.  The optional parameter is used to override
1886dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
1887AC_DEFUN([CF_WITH_DMALLOC],[
1888CF_NO_LEAKS_OPTION(dmalloc,
1889	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
1890	[USE_DMALLOC])
1891
1892if test "$with_dmalloc" = yes ; then
1893	AC_CHECK_HEADER(dmalloc.h,
1894		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
1895fi
1896])dnl
1897dnl ---------------------------------------------------------------------------
1898dnl CF_WITH_MAN2HTML version: 13 updated: 2023/11/23 06:40:35
1899dnl ----------------
1900dnl Check for man2html and groff.  Prefer man2html over groff, but use groff
1901dnl as a fallback.  See
1902dnl
1903dnl		http://invisible-island.net/scripts/man2html.html
1904dnl
1905dnl Generate a shell script which hides the differences between the two.
1906dnl
1907dnl We name that "man2html.tmp".
1908dnl
1909dnl The shell script can be removed later, e.g., using "make distclean".
1910AC_DEFUN([CF_WITH_MAN2HTML],[
1911AC_REQUIRE([CF_PROG_GROFF])dnl
1912AC_REQUIRE([AC_PROG_FGREP])dnl
1913
1914case "x${with_man2html}" in
1915(xno)
1916	cf_man2html=no
1917	;;
1918(x|xyes)
1919	AC_PATH_PROG(cf_man2html,man2html,no)
1920	case "x$cf_man2html" in
1921	(x/*)
1922		AC_MSG_CHECKING(for the modified Earl Hood script)
1923		if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
1924		then
1925			cf_man2html_ok=yes
1926		else
1927			cf_man2html=no
1928			cf_man2html_ok=no
1929		fi
1930		AC_MSG_RESULT($cf_man2html_ok)
1931		;;
1932	(*)
1933		cf_man2html=no
1934		;;
1935	esac
1936esac
1937
1938AC_MSG_CHECKING(for program to convert manpage to html)
1939AC_ARG_WITH(man2html,
1940	[[  --with-man2html[=XXX]   use XXX rather than groff]],
1941	[cf_man2html=$withval],
1942	[cf_man2html=$cf_man2html])
1943
1944cf_with_groff=no
1945
1946case $cf_man2html in
1947(yes)
1948	AC_MSG_RESULT(man2html)
1949	AC_PATH_PROG(cf_man2html,man2html,no)
1950	;;
1951(no|groff|*/groff*)
1952	cf_with_groff=yes
1953	cf_man2html=$GROFF_PATH
1954	AC_MSG_RESULT($cf_man2html)
1955	;;
1956(*)
1957	AC_MSG_RESULT($cf_man2html)
1958	;;
1959esac
1960
1961MAN2HTML_TEMP="man2html.tmp"
1962	cat >$MAN2HTML_TEMP <<CF_EOF
1963#!$SHELL
1964# Temporary script generated by CF_WITH_MAN2HTML
1965# Convert inputs to html, sending result to standard output.
1966#
1967# Parameters:
1968# \${1} = rootname of file to convert
1969# \${2} = suffix of file to convert, e.g., "1"
1970# \${3} = macros to use, e.g., "man"
1971#
1972ROOT=\[$]1
1973TYPE=\[$]2
1974MACS=\[$]3
1975
1976unset LANG
1977unset LC_ALL
1978unset LC_CTYPE
1979unset LANGUAGE
1980GROFF_NO_SGR=stupid
1981export GROFF_NO_SGR
1982
1983CF_EOF
1984
1985NROFF_OPTS=
1986if test "x$cf_with_groff" = xyes
1987then
1988	MAN2HTML_NOTE="$GROFF_NOTE"
1989	MAN2HTML_PATH="$GROFF_PATH"
1990	cat >>$MAN2HTML_TEMP <<CF_EOF
1991$SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
1992CF_EOF
1993else
1994	# disable hyphenation if this is groff
1995	if test "x$GROFF_PATH" != xno
1996	then
1997		AC_MSG_CHECKING(if nroff is really groff)
1998		cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`"
1999		test -n "$cf_check_groff" && cf_check_groff=yes
2000		test -n "$cf_check_groff" || cf_check_groff=no
2001		AC_MSG_RESULT($cf_check_groff)
2002		test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0"
2003	fi
2004	MAN2HTML_NOTE=""
2005	CF_PATH_SYNTAX(cf_man2html)
2006	MAN2HTML_PATH="$cf_man2html"
2007	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
2008
2009	# for this example, expect 3 lines of content, the remainder is head/foot
2010	cat >conftest.in <<CF_EOF
2011.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
2012.SH SECTION
2013MARKER
2014CF_EOF
2015
2016	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
2017
2018	cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
2019	cf_man2html_top=`expr "$cf_man2html_1st" - 2`
2020	cf_man2html_bot="`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`"
2021	cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"`
2022	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
2023
2024	AC_MSG_RESULT($cf_man2html_top_bot)
2025
2026	AC_MSG_CHECKING(for pagesize to use)
2027	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
2028	do
2029	cat >>conftest.in <<CF_EOF
2030.nf
20310
20321
20332
20343
20354
20365
20376
20387
20398
20409
2041CF_EOF
2042	done
2043
2044	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
2045	cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
2046	test -z "$cf_man2html_page" && cf_man2html_page=99999
2047	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
2048
2049	rm -rf conftest*
2050	AC_MSG_RESULT($cf_man2html_page)
2051
2052	cat >>$MAN2HTML_TEMP <<CF_EOF
2053: \${MAN2HTML_PATH=$MAN2HTML_PATH}
2054MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title=\"\$ROOT(\$TYPE)\" -compress -pgsize $cf_man2html_page"
2055case \${TYPE} in
2056(ms)
2057	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
2058	;;
2059(*)
2060	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
2061	;;
2062esac
2063CF_EOF
2064fi
2065
2066chmod 700 $MAN2HTML_TEMP
2067
2068AC_SUBST(MAN2HTML_NOTE)
2069AC_SUBST(MAN2HTML_PATH)
2070AC_SUBST(MAN2HTML_TEMP)
2071])dnl
2072dnl ---------------------------------------------------------------------------
2073dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
2074dnl ----------------
2075AC_DEFUN([CF_WITH_VALGRIND],[
2076CF_NO_LEAKS_OPTION(valgrind,
2077	[  --with-valgrind         test: use valgrind],
2078	[USE_VALGRIND])
2079])dnl
2080dnl ---------------------------------------------------------------------------
2081dnl CF_XOPEN_SOURCE version: 67 updated: 2023/09/06 18:55:27
2082dnl ---------------
2083dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2084dnl or adapt to the vendor's definitions to get equivalent functionality,
2085dnl without losing the common non-POSIX features.
2086dnl
2087dnl Parameters:
2088dnl	$1 is the nominal value for _XOPEN_SOURCE
2089dnl	$2 is the nominal value for _POSIX_C_SOURCE
2090dnl
2091dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
2092dnl implementation predefines it, because X/Open and most implementations agree
2093dnl that the latter is a legacy or "aligned" value.
2094dnl
2095dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
2096dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
2097dnl
2098dnl References:
2099dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
2100dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
2101dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
2102AC_DEFUN([CF_XOPEN_SOURCE],[
2103AC_REQUIRE([AC_CANONICAL_HOST])
2104AC_REQUIRE([CF_POSIX_VISIBLE])
2105
2106if test "$cf_cv_posix_visible" = no; then
2107
2108cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
2109cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
2110cf_xopen_source=
2111
2112case "$host_os" in
2113(aix[[4-7]]*)
2114	cf_xopen_source="-D_ALL_SOURCE"
2115	;;
2116(darwin[[0-8]].*)
2117	cf_xopen_source="-D_APPLE_C_SOURCE"
2118	;;
2119(darwin*)
2120	cf_xopen_source="-D_DARWIN_C_SOURCE"
2121	cf_XOPEN_SOURCE=
2122	;;
2123(freebsd*|dragonfly*|midnightbsd*)
2124	# 5.x headers associate
2125	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2126	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2127	cf_POSIX_C_SOURCE=200112L
2128	cf_XOPEN_SOURCE=600
2129	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2130	;;
2131(hpux11*)
2132	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
2133	;;
2134(hpux*)
2135	cf_xopen_source="-D_HPUX_SOURCE"
2136	;;
2137(irix[[56]].*)
2138	cf_xopen_source="-D_SGI_SOURCE"
2139	cf_XOPEN_SOURCE=
2140	;;
2141(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
2142	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
2143	;;
2144(minix*)
2145	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
2146	;;
2147(mirbsd*)
2148	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
2149	cf_XOPEN_SOURCE=
2150	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2151	;;
2152(netbsd*)
2153	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2154	;;
2155(openbsd[[6-9]]*)
2156	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
2157	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
2158	# Abusing the conformance level is a workaround.
2159	AC_MSG_WARN(this system does not provide usable locale support)
2160	cf_xopen_source="-D_BSD_SOURCE"
2161	cf_XOPEN_SOURCE=700
2162	;;
2163(openbsd[[4-5]]*)
2164	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
2165	cf_xopen_source="-D_BSD_SOURCE"
2166	cf_XOPEN_SOURCE=600
2167	;;
2168(openbsd*)
2169	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2170	;;
2171(osf[[45]]*)
2172	cf_xopen_source="-D_OSF_SOURCE"
2173	;;
2174(nto-qnx*)
2175	cf_xopen_source="-D_QNX_SOURCE"
2176	;;
2177(sco*)
2178	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2179	;;
2180(solaris2.*)
2181	cf_xopen_source="-D__EXTENSIONS__"
2182	cf_cv_xopen_source=broken
2183	;;
2184(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
2185	cf_XOPEN_SOURCE=
2186	cf_POSIX_C_SOURCE=
2187	;;
2188(*)
2189	CF_TRY_XOPEN_SOURCE
2190	cf_save_xopen_cppflags="$CPPFLAGS"
2191	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2192	# Some of these niche implementations use copy/paste, double-check...
2193	if test "$cf_cv_xopen_source" = no ; then
2194		CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
2195		AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[
2196			AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
2197			CPPFLAGS="$cf_save_xopen_cppflags"])
2198	fi
2199	;;
2200esac
2201
2202if test -n "$cf_xopen_source" ; then
2203	CF_APPEND_CFLAGS($cf_xopen_source,true)
2204fi
2205
2206dnl In anything but the default case, we may have system-specific setting
2207dnl which is still not guaranteed to provide all of the entrypoints that
2208dnl _XOPEN_SOURCE would yield.
2209if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
2210	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
2211	AC_TRY_COMPILE([#include <stdlib.h>],[
2212#ifndef _XOPEN_SOURCE
2213#error _XOPEN_SOURCE is not defined
2214#endif],
2215	[cf_XOPEN_SOURCE_set=yes],
2216	[cf_XOPEN_SOURCE_set=no])
2217	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
2218	if test "$cf_XOPEN_SOURCE_set" = yes
2219	then
2220		AC_TRY_COMPILE([#include <stdlib.h>],[
2221#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
2222#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
2223#endif],
2224		[cf_XOPEN_SOURCE_set_ok=yes],
2225		[cf_XOPEN_SOURCE_set_ok=no])
2226		if test "$cf_XOPEN_SOURCE_set_ok" = no
2227		then
2228			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
2229		fi
2230	else
2231		CF_TRY_XOPEN_SOURCE
2232	fi
2233fi
2234fi # cf_cv_posix_visible
2235])
2236dnl ---------------------------------------------------------------------------
2237dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25
2238dnl ---------------------
2239dnl body of test when test-compiling for _XOPEN_SOURCE check
2240define([CF__XOPEN_SOURCE_BODY],
2241[
2242#ifndef _XOPEN_SOURCE
2243#error _XOPEN_SOURCE is not defined
2244#endif
2245])
2246dnl ---------------------------------------------------------------------------
2247dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25
2248dnl ---------------------
2249dnl headers to include when test-compiling for _XOPEN_SOURCE check
2250define([CF__XOPEN_SOURCE_HEAD],
2251[
2252$ac_includes_default
2253])
2254