xref: /src/contrib/ncurses/aclocal.m4 (revision 68ad2b0d7af2a3571c4abac9afa712f9b09b721c) !
1dnl***************************************************************************
2dnl Copyright 2018-2024,2025 Thomas E. Dickey                                *
3dnl Copyright 1998-2017,2018 Free Software Foundation, Inc.                  *
4dnl                                                                          *
5dnl Permission is hereby granted, free of charge, to any person obtaining a  *
6dnl copy of this software and associated documentation files (the            *
7dnl "Software"), to deal in the Software without restriction, including      *
8dnl without limitation the rights to use, copy, modify, merge, publish,      *
9dnl distribute, distribute with modifications, sublicense, and/or sell       *
10dnl copies of the Software, and to permit persons to whom the Software is    *
11dnl furnished to do so, subject to the following conditions:                 *
12dnl                                                                          *
13dnl The above copyright notice and this permission notice shall be included  *
14dnl in all copies or substantial portions of the Software.                   *
15dnl                                                                          *
16dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23dnl                                                                          *
24dnl Except as contained in this notice, the name(s) of the above copyright   *
25dnl holders shall not be used in advertising or otherwise to promote the     *
26dnl sale, use or other dealings in this Software without prior written       *
27dnl authorization.                                                           *
28dnl***************************************************************************
29dnl
30dnl Author: Thomas E. Dickey 1995-on
31dnl
32dnl $Id: aclocal.m4,v 1.1148 2025/12/25 23:44:16 tom Exp $
33dnl Macros used in NCURSES auto-configuration script.
34dnl
35dnl These macros are maintained separately from NCURSES.  The copyright on
36dnl this file applies to the aggregation of macros and does not affect use of
37dnl these macros in other applications.
38dnl
39dnl See these pages for additional information:
40dnl		https://invisible-island.net/autoconf/
41dnl		https://invisible-island.net/autoconf/my-autoconf.html
42dnl
43dnl ---------------------------------------------------------------------------
44dnl ---------------------------------------------------------------------------
45dnl AM_LANGINFO_CODESET version: 8 updated: 2025/12/22 04:16:14
46dnl -------------------
47dnl Inserted as requested by gettext 0.10.40
48dnl File from /usr/share/aclocal
49dnl codeset.m4
50dnl ====================
51dnl serial AM1
52dnl
53dnl From Bruno Haible.
54AC_DEFUN([AM_LANGINFO_CODESET],
55[
56AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
57	[AC_LINK_IFELSE([AC_LANG_PROGRAM([
58$ac_includes_default
59#include <langinfo.h>],
60	[char* cs = nl_langinfo(CODESET); (void)cs])],
61	am_cv_langinfo_codeset=yes,
62	am_cv_langinfo_codeset=no)
63	])
64	if test "$am_cv_langinfo_codeset" = yes; then
65		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
66		[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
67	fi
68])dnl
69dnl ---------------------------------------------------------------------------
70dnl CF_ABI_DEFAULTS version: 6 updated: 2025/05/17 14:54:28
71dnl ---------------
72dnl Provide configure-script defaults for different ncurses ABIs.
73AC_DEFUN([CF_ABI_DEFAULTS],[
74AC_REQUIRE([CF_NCURSES_WITH_ABI_VERSION])
75
76# ABI 5 defaults:
77cf_dft_ccharw_max=5
78cf_dft_chtype=auto
79cf_dft_ext_colors=no
80cf_dft_ext_const=no
81cf_dft_ext_mouse=no
82cf_dft_ext_mouse2=no
83cf_dft_ext_putwin=no
84cf_dft_ext_spfuncs=no
85cf_dft_filter_syms=no
86cf_dft_interop=no
87cf_dft_mmask_t=auto
88cf_dft_opaque_curses=no
89cf_dft_ordinate_type=short
90cf_dft_rgb_color=no
91cf_dft_signed_char=no
92cf_dft_tparm_arg=long
93cf_dft_widec=no
94cf_dft_with_lp64=no
95
96# ABI 6 default differences from ABI 5:
97case x$cf_cv_abi_default in
98(x[[6789]])
99	cf_dft_chtype=uint32_t
100	cf_dft_ext_colors=yes
101	cf_dft_ext_const=yes
102	cf_dft_ext_mouse=yes
103	cf_dft_ext_putwin=yes
104	cf_dft_ext_spfuncs=yes
105	cf_dft_filter_syms=yes
106	cf_dft_interop=yes
107	cf_dft_mmask_t=uint32_t
108	cf_dft_opaque_curses=yes
109	cf_dft_tparm_arg=intptr_t
110	cf_dft_widec=yes
111	cf_dft_with_lp64=yes
112	;;
113esac
114
115# ABI 7 default differences from ABI 6:
116case x$cf_cv_abi_default in
117(x[[789]])
118	cf_dft_ccharw_max=6
119	cf_dft_ext_mouse2=yes
120	cf_dft_mmask_t=uint64_t
121	cf_dft_ordinate_type=int
122	cf_dft_rgb_color=yes
123	cf_dft_signed_char=yes
124	# also: remove the wgetch-events feature in ABI 7
125	;;
126esac
127])dnl
128dnl ---------------------------------------------------------------------------
129dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
130dnl ------------------
131dnl Conditionally generate script according to whether we're using a given autoconf.
132dnl
133dnl $1 = version to compare against
134dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
135dnl $3 = code to use if AC_ACVERSION is older than $1.
136define([CF_ACVERSION_CHECK],
137[
138ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
139ifdef([m4_version_compare],
140[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
141[CF_ACVERSION_COMPARE(
142AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
143AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
144dnl ---------------------------------------------------------------------------
145dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
146dnl --------------------
147dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
148dnl                      MAJOR2, MINOR2, TERNARY2,
149dnl                      PRINTABLE2, not FOUND, FOUND)
150define([CF_ACVERSION_COMPARE],
151[ifelse(builtin([eval], [$2 < $5]), 1,
152[ifelse([$8], , ,[$8])],
153[ifelse([$9], , ,[$9])])])dnl
154dnl ---------------------------------------------------------------------------
155dnl CF_ADA_INCLUDE_DIRS version: 8 updated: 2013/10/14 04:24:07
156dnl -------------------
157dnl Construct the list of include-options for the C programs in the Ada95
158dnl binding.
159AC_DEFUN([CF_ADA_INCLUDE_DIRS],
160[
161ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
162if test "$srcdir" != "."; then
163	ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
164fi
165if test "$GCC" != yes; then
166	ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
167elif test "$includedir" != "/usr/include"; then
168	if test "$includedir" = '${prefix}/include' ; then
169		if test x$prefix != x/usr ; then
170			ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
171		fi
172	else
173		ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
174	fi
175fi
176AC_SUBST(ACPPFLAGS)
177])dnl
178dnl ---------------------------------------------------------------------------
179dnl CF_ADD_ADAFLAGS version: 1 updated: 2010/06/19 15:22:18
180dnl ---------------
181dnl Add to $ADAFLAGS, which is substituted into makefile and scripts.
182AC_DEFUN([CF_ADD_ADAFLAGS],[
183 	ADAFLAGS="$ADAFLAGS $1"
184	AC_SUBST(ADAFLAGS)
185])dnl
186dnl ---------------------------------------------------------------------------
187dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15
188dnl -------------
189dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
190dnl $1 = flags to add
191dnl $2 = if given makes this macro verbose.
192dnl
193dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
194dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
195dnl confused by the quotes (which require backslashes to keep them usable).
196AC_DEFUN([CF_ADD_CFLAGS],
197[
198cf_fix_cppflags=no
199cf_new_cflags=
200cf_new_cppflags=
201cf_new_extra_cppflags=
202
203for cf_add_cflags in $1
204do
205case "$cf_fix_cppflags" in
206(no)
207	case "$cf_add_cflags" in
208	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
209		case "$cf_add_cflags" in
210		(-D*)
211			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
212
213			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
214				&& test -z "${cf_tst_cflags}" \
215				&& cf_fix_cppflags=yes
216
217			if test "$cf_fix_cppflags" = yes ; then
218				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
219				continue
220			elif test "${cf_tst_cflags}" = "\"'" ; then
221				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
222				continue
223			fi
224			;;
225		esac
226		case "$CPPFLAGS" in
227		(*$cf_add_cflags)
228			;;
229		(*)
230			case "$cf_add_cflags" in
231			(-D*)
232				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
233				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
234				;;
235			esac
236			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
237			;;
238		esac
239		;;
240	(*)
241		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
242		;;
243	esac
244	;;
245(yes)
246	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
247
248	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
249
250	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
251		&& test -z "${cf_tst_cflags}" \
252		&& cf_fix_cppflags=no
253	;;
254esac
255done
256
257if test -n "$cf_new_cflags" ; then
258	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
259	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
260fi
261
262if test -n "$cf_new_cppflags" ; then
263	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
264	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
265fi
266
267if test -n "$cf_new_extra_cppflags" ; then
268	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
269	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
270fi
271
272AC_SUBST(EXTRA_CPPFLAGS)
273
274])dnl
275dnl ---------------------------------------------------------------------------
276dnl CF_ADD_CXXFLAGS version: 1 updated: 2020/04/04 16:16:13
277dnl ---------------
278dnl Copy non-preprocessor flags to $CXXFLAGS, preprocessor flags to $CPPFLAGS
279dnl The second parameter if given makes this macro verbose.
280dnl
281dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
282dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
283dnl confused by the quotes (which require backslashes to keep them usable).
284AC_DEFUN([CF_ADD_CXXFLAGS],
285[
286cf_save_CXXFLAGS="$CFLAGS"
287CFLAGS="$CXXFLAGS"
288CF_ADD_CFLAGS($1 ifelse($2,,,[,$2]))
289CXXFLAGS="$CFLAGS"
290CFLAGS="$cf_save_CXXFLAGS"
291])dnl
292dnl ---------------------------------------------------------------------------
293dnl CF_ADD_INCDIR version: 18 updated: 2025/12/22 04:16:14
294dnl -------------
295dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it is
296dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
297dnl but old versions (and some misinstalled ones) need that.  To make things
298dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
299dnl the include-path).
300AC_DEFUN([CF_ADD_INCDIR],
301[
302if test -n "$1" ; then
303  for cf_add_incdir in $1
304  do
305	while test "$cf_add_incdir" != /usr/include
306	do
307	  if test -d "$cf_add_incdir"
308	  then
309		cf_have_incdir=no
310		if test -n "$CFLAGS$CPPFLAGS" ; then
311		  # a loop is needed to ensure we can add subdirs of existing dirs
312		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
313			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
314			  cf_have_incdir=yes; break
315			fi
316		  done
317		fi
318
319		if test "$cf_have_incdir" = no ; then
320		  if test "$cf_add_incdir" = /usr/local/include ; then
321			if test "$GCC" = yes
322			then
323			  cf_save_CPPFLAGS=$CPPFLAGS
324			  CF_APPEND_TEXT(CPPFLAGS,-I$cf_add_incdir)
325			  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],
326				  [printf("Hello")])],
327				  [],
328				  [cf_have_incdir=yes])
329			  CPPFLAGS=$cf_save_CPPFLAGS
330			fi
331		  fi
332		fi
333
334		if test "$cf_have_incdir" = no ; then
335		  CF_VERBOSE(adding $cf_add_incdir to include-path)
336		  ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
337
338		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
339		  test "$cf_top_incdir" = "$cf_add_incdir" && break
340		  cf_add_incdir="$cf_top_incdir"
341		else
342		  break
343		fi
344	  else
345		break
346	  fi
347	done
348  done
349fi
350])dnl
351dnl ---------------------------------------------------------------------------
352dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
353dnl ----------
354dnl Add a library, used to enforce consistency.
355dnl
356dnl $1 = library to add, without the "-l"
357dnl $2 = variable to update (default $LIBS)
358AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
359dnl ---------------------------------------------------------------------------
360dnl CF_ADD_LIBDIR version: 11 updated: 2020/12/31 20:19:42
361dnl -------------
362dnl	Adds to the library-path
363dnl
364dnl	Some machines have trouble with multiple -L options.
365dnl
366dnl $1 is the (list of) directory(s) to add
367dnl $2 is the optional name of the variable to update (default LDFLAGS)
368dnl
369AC_DEFUN([CF_ADD_LIBDIR],
370[
371if test -n "$1" ; then
372	for cf_add_libdir in $1
373	do
374		if test "$cf_add_libdir" = /usr/lib ; then
375			:
376		elif test -d "$cf_add_libdir"
377		then
378			cf_have_libdir=no
379			if test -n "$LDFLAGS$LIBS" ; then
380				# a loop is needed to ensure we can add subdirs of existing dirs
381				for cf_test_libdir in $LDFLAGS $LIBS ; do
382					if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
383						cf_have_libdir=yes; break
384					fi
385				done
386			fi
387			if test "$cf_have_libdir" = no ; then
388				CF_VERBOSE(adding $cf_add_libdir to library-path)
389				ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
390			fi
391		fi
392	done
393fi
394])dnl
395dnl ---------------------------------------------------------------------------
396dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
397dnl -----------
398dnl Add one or more libraries, used to enforce consistency.  Libraries are
399dnl prepended to an existing list, since their dependencies are assumed to
400dnl already exist in the list.
401dnl
402dnl $1 = libraries to add, with the "-l", etc.
403dnl $2 = variable to update (default $LIBS)
404AC_DEFUN([CF_ADD_LIBS],[
405cf_add_libs="[$]ifelse($2,,LIBS,[$2])"
406# reverse order
407cf_add_0lib=
408for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
409# filter duplicates
410for cf_add_1lib in $cf_add_0lib; do
411	for cf_add_2lib in $cf_add_libs; do
412		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
413			cf_add_1lib=
414			break
415		fi
416	done
417	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
418done
419ifelse($2,,LIBS,[$2])="$cf_add_libs"
420])dnl
421dnl ---------------------------------------------------------------------------
422dnl CF_ADD_SUBDIR_PATH version: 5 updated: 2020/12/31 20:19:42
423dnl ------------------
424dnl Append to a search-list for a nonstandard header/lib-file
425dnl	$1 = the variable to return as result
426dnl	$2 = the package name
427dnl	$3 = the subdirectory, e.g., bin, include or lib
428dnl $4 = the directory under which we will test for subdirectories
429dnl $5 = a directory that we do not want $4 to match
430AC_DEFUN([CF_ADD_SUBDIR_PATH],
431[
432test "x$4" != "x$5" && \
433test -d "$4" && \
434ifelse([$5],NONE,,[{ test -z "$5" || test "x$5" = xNONE || test "x$4" != "x$5"; } &&]) {
435	test -n "$verbose" && echo "	... testing for $3-directories under $4"
436	test -d "$4/$3" &&          $1="[$]$1 $4/$3"
437	test -d "$4/$3/$2" &&       $1="[$]$1 $4/$3/$2"
438	test -d "$4/$3/$2/$3" &&    $1="[$]$1 $4/$3/$2/$3"
439	test -d "$4/$2/$3" &&       $1="[$]$1 $4/$2/$3"
440	test -d "$4/$2/$3/$2" &&    $1="[$]$1 $4/$2/$3/$2"
441}
442])dnl
443dnl ---------------------------------------------------------------------------
444dnl CF_APPEND_CFLAGS version: 3 updated: 2021/09/05 17:25:40
445dnl ----------------
446dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
447dnl $1 = flags to add
448dnl $2 = if given makes this macro verbose.
449define([CF_APPEND_CFLAGS],
450[
451for cf_add_cflags in $1
452do
453	case "x$cf_add_cflags" in
454	(x-[[DU]]*)
455		CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
456		CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
457		;;
458	esac
459	CF_ADD_CFLAGS([$cf_add_cflags],[$2])
460done
461])dnl
462dnl ---------------------------------------------------------------------------
463dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
464dnl --------------
465dnl use this macro for appending text without introducing an extra blank at
466dnl the beginning
467define([CF_APPEND_TEXT],
468[
469	test -n "[$]$1" && $1="[$]$1 "
470	$1="[$]{$1}$2"
471])dnl
472dnl ---------------------------------------------------------------------------
473dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
474dnl --------------
475dnl Allow user to disable a normally-on option.
476AC_DEFUN([CF_ARG_DISABLE],
477[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
478dnl ---------------------------------------------------------------------------
479dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
480dnl -------------
481dnl Allow user to enable a normally-off option.
482AC_DEFUN([CF_ARG_ENABLE],
483[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
484dnl ---------------------------------------------------------------------------
485dnl CF_ARG_OPTION version: 6 updated: 2025/08/05 04:09:09
486dnl -------------
487dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
488dnl values.
489dnl
490dnl Parameters:
491dnl $1 = option name
492dnl $2 = help-string
493dnl $3 = action to perform if option is not default
494dnl $4 = action to perform if option is default
495dnl $5 = default option value (either 'yes' or 'no')
496AC_DEFUN([CF_ARG_OPTION],
497[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
498	if test "$enableval" != "$5" ; then
499ifelse([$3],,[    :]dnl
500,[    $3]) ifelse([$4],,,[
501	else
502		$4])
503	fi],[enableval=$5 ifelse([$4],,,[
504	$4
505])dnl
506])])dnl
507dnl ---------------------------------------------------------------------------
508dnl CF_AR_FLAGS version: 10 updated: 2025/12/14 20:07:31
509dnl -----------
510dnl Check for suitable "ar" (archiver) options for updating an archive.
511dnl
512dnl In particular, handle some obsolete cases where the "-" might be omitted,
513dnl as well as a workaround for breakage of make's archive rules by the GNU
514dnl binutils "ar" program.
515AC_DEFUN([CF_AR_FLAGS],[
516AC_REQUIRE([CF_PROG_AR])
517
518AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
519	case "$cf_cv_system_name" in
520	(*-msvc*)
521		cf_cv_ar_flags=''
522		cat >mk_static_lib.sh <<-EOF
523		#!$SHELL
524		MSVC_BIN="[$]AR"
525		out="\[$]1"
526		shift
527		exec \[$]MSVC_BIN -out:"\[$]out" \[$]@
528		EOF
529		chmod +x mk_static_lib.sh
530		AR=`pwd`/mk_static_lib.sh
531		;;
532	(*)
533		cf_cv_ar_flags=unknown
534		for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
535		do
536
537			# check if $ARFLAGS already contains this choice
538			if test "x$ARFLAGS" != "x" ; then
539				cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
540				if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
541					cf_cv_ar_flags=
542					break
543				fi
544			fi
545
546			rm -f "conftest.$ac_cv_objext"
547			rm -f conftest.a
548
549			cat >"conftest.$ac_ext" <<EOF
550#line __oline__ "configure"
551int	testdata[[3]] = { 123, 456, 789 };
552EOF
553			if AC_TRY_EVAL(ac_compile) ; then
554				echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AS_MESSAGE_LOG_FD
555				$AR $ARFLAGS "$cf_ar_flags" conftest.a "conftest.$ac_cv_objext" 2>&AS_MESSAGE_LOG_FD 1>/dev/null
556				if test -f conftest.a ; then
557					cf_cv_ar_flags="$cf_ar_flags"
558					break
559				fi
560			else
561				CF_VERBOSE(cannot compile test-program)
562				break
563			fi
564		done
565		rm -f conftest.a "conftest.$ac_ext" "conftest.$ac_cv_objext"
566		;;
567	esac
568])
569
570if test -n "$ARFLAGS" ; then
571	if test -n "$cf_cv_ar_flags" ; then
572		ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
573	fi
574else
575	ARFLAGS=$cf_cv_ar_flags
576fi
577
578AC_SUBST(ARFLAGS)
579])
580dnl ---------------------------------------------------------------------------
581dnl CF_AWK_BIG_PRINTF version: 5 updated: 2015/04/17 21:13:04
582dnl -----------------
583dnl Check if awk can handle big strings using printf.  Some older versions of
584dnl awk choke on large strings passed via "%s".
585dnl
586dnl $1 = desired string size
587dnl $2 = variable to set with result
588AC_DEFUN([CF_AWK_BIG_PRINTF],
589[
590	case x$AWK in
591	(x)
592		eval $2=no
593		;;
594	(*)
595		if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' 2>/dev/null \
596			| $AWK '{ printf "%d\n", length([$]0); }' 2>/dev/null | $AWK 'BEGIN { eqls=0; recs=0; } { recs++; if ([$]0 == 12000) eqls++; } END { if (recs != 1 || eqls != 1) exit 1; }' 2>/dev/null >/dev/null ) ; then
597			eval $2=yes
598		else
599			eval $2=no
600		fi
601		;;
602	esac
603])dnl
604dnl ---------------------------------------------------------------------------
605dnl CF_BOOL_DECL version: 12 updated: 2025/12/24 12:27:29
606dnl ------------
607dnl Test if 'bool' is a builtin type in the configured C/C++ compiler.  Some
608dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
609dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
610dnl
611dnl $1 is the shell variable to store the result in, if not $cv_cv_builtin_bool
612AC_DEFUN([CF_BOOL_DECL],
613[
614AC_REQUIRE([CF_C99_STDBOOL_H])
615AC_CACHE_CHECK(for builtin bool type, ifelse($1,,cf_cv_builtin_bool,[$1]),[
616	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
617$ac_includes_default
618],[bool x = false; (void)x])],
619		[ifelse($1,,cf_cv_builtin_bool,[$1])=yes],
620		[ifelse($1,,cf_cv_builtin_bool,[$1])=no])])
621])dnl
622dnl ---------------------------------------------------------------------------
623dnl CF_BOOL_SIZE version: 22 updated: 2025/02/22 20:49:45
624dnl ------------
625dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
626dnl Don't bother looking for bool.h, since it has been deprecated.
627dnl
628dnl If the current compiler is C rather than C++, we get the bool definition
629dnl from <stdbool.h>.
630AC_DEFUN([CF_BOOL_SIZE],
631[
632AC_REQUIRE([CF_C99_STDBOOL_H])
633AC_CHECK_SIZEOF(bool,,[
634$ac_includes_default
635
636#if defined(__cplusplus)
637
638#ifdef HAVE_GXX_BUILTIN_H
639#include <g++/builtin.h>
640#elif HAVE_GPP_BUILTIN_H
641#include <gpp/builtin.h>
642#elif HAVE_BUILTIN_H
643#include <builtin.h>
644#endif
645
646#else
647
648#if $USE_STDBOOL_H
649#include <stdbool.h>
650#endif
651
652#endif
653])
654
655AC_CACHE_CHECK(for type of bool, cf_cv_type_of_bool,[
656	rm -f cf_test.out
657	AC_TRY_RUN([
658$ac_includes_default
659
660#if defined(__cplusplus)
661
662#ifdef HAVE_GXX_BUILTIN_H
663#include <g++/builtin.h>
664#elif HAVE_GPP_BUILTIN_H
665#include <gpp/builtin.h>
666#elif HAVE_BUILTIN_H
667#include <builtin.h>
668#endif
669
670#else
671
672#if $USE_STDBOOL_H
673#include <stdbool.h>
674#endif
675
676#endif
677
678int main(void)
679{
680	FILE *fp = fopen("cf_test.out", "w");
681	if (fp != NULL) {
682		bool x = true;
683		if ((bool)(-x) >= 0)
684			fputs("unsigned ", fp);
685		if (sizeof(x) == sizeof(int))       fputs("int",  fp);
686		else if (sizeof(x) == sizeof(char)) fputs("char", fp);
687		else if (sizeof(x) == sizeof(short))fputs("short",fp);
688		else if (sizeof(x) == sizeof(long)) fputs("long", fp);
689		fclose(fp);
690	}
691	${cf_cv_main_return:-return}(0);
692}
693		],
694		[cf_cv_type_of_bool=`cat cf_test.out`
695		 if test -z "$cf_cv_type_of_bool"; then
696		   cf_cv_type_of_bool=unknown
697		 fi],
698		[cf_cv_type_of_bool=unknown],
699		[
700		case x$ac_cv_sizeof_bool in
701		(x1) cf_cv_type_of_bool="unsigned char";;
702		(x2) cf_cv_type_of_bool="unsigned short";;
703		(x4) cf_cv_type_of_bool="unsigned int";;
704		(x8) cf_cv_type_of_bool="unsigned long";;
705		(*)  cf_cv_type_of_bool=unknown;;
706		esac
707		])
708	rm -f cf_test.out
709])
710
711if test "$cf_cv_type_of_bool" = unknown ; then
712	case .$NCURSES_BOOL in
713	(.auto|.) NCURSES_BOOL=unsigned;;
714	esac
715	AC_MSG_WARN(Assuming $NCURSES_BOOL for type of bool)
716	cf_cv_type_of_bool=$NCURSES_BOOL
717fi
718])dnl
719dnl ---------------------------------------------------------------------------
720dnl CF_BUILD_CC version: 14 updated: 2024/12/14 11:58:01
721dnl -----------
722dnl If we're cross-compiling, allow the user to override the tools and their
723dnl options.  The configure script is oriented toward identifying the host
724dnl compiler, etc., but we need a build compiler to generate parts of the
725dnl source.
726dnl
727dnl $1 = default for $CPPFLAGS
728dnl $2 = default for $LIBS
729AC_DEFUN([CF_BUILD_CC],[
730CF_ACVERSION_CHECK(2.52,,
731	[AC_REQUIRE([CF_PROG_EXT])])
732if test "$cross_compiling" = yes ; then
733
734	# defaults that we might want to override
735	: ${BUILD_CFLAGS:=''}
736	: ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
737	: ${BUILD_LDFLAGS:=''}
738	: ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
739	: ${BUILD_EXEEXT:='$x'}
740	: ${BUILD_OBJEXT:='o'}
741
742	AC_ARG_WITH(build-cc,
743		[  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
744		[BUILD_CC="$withval"],
745		[AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none)])
746	AC_MSG_CHECKING(for native build C compiler)
747	AC_MSG_RESULT($BUILD_CC)
748
749	AC_MSG_CHECKING(for native build C preprocessor)
750	AC_ARG_WITH(build-cpp,
751		[  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
752		[BUILD_CPP="$withval"],
753		[BUILD_CPP='${BUILD_CC} -E'])
754	AC_MSG_RESULT($BUILD_CPP)
755
756	AC_MSG_CHECKING(for native build C flags)
757	AC_ARG_WITH(build-cflags,
758		[  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
759		[BUILD_CFLAGS="$withval"])
760	AC_MSG_RESULT($BUILD_CFLAGS)
761
762	AC_MSG_CHECKING(for native build C preprocessor-flags)
763	AC_ARG_WITH(build-cppflags,
764		[  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
765		[BUILD_CPPFLAGS="$withval"])
766	AC_MSG_RESULT($BUILD_CPPFLAGS)
767
768	AC_MSG_CHECKING(for native build linker-flags)
769	AC_ARG_WITH(build-ldflags,
770		[  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
771		[BUILD_LDFLAGS="$withval"])
772	AC_MSG_RESULT($BUILD_LDFLAGS)
773
774	AC_MSG_CHECKING(for native build linker-libraries)
775	AC_ARG_WITH(build-libs,
776		[  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
777		[BUILD_LIBS="$withval"])
778	AC_MSG_RESULT($BUILD_LIBS)
779
780	# this assumes we're on Unix.
781	BUILD_EXEEXT=
782	BUILD_OBJEXT=o
783
784	: ${BUILD_CC:='${CC}'}
785
786	AC_MSG_CHECKING(if the build-compiler "$BUILD_CC" works)
787
788	cf_save_crossed=$cross_compiling
789	cf_save_ac_link=$ac_link
790	cross_compiling=no
791	cf_build_cppflags=$BUILD_CPPFLAGS
792	test "$cf_build_cppflags" = "#" && cf_build_cppflags=
793	ac_link='$BUILD_CC -o "conftest$ac_exeext" $BUILD_CFLAGS $cf_build_cppflags $BUILD_LDFLAGS "conftest.$ac_ext" $BUILD_LIBS >&AS_MESSAGE_LOG_FD'
794
795	AC_TRY_RUN([#include <stdio.h>
796		int main(int argc, char *argv[])
797		{
798			${cf_cv_main_return:-return}(argc < 0 || argv == (void*)0 || argv[0] == (void*)0);
799		}
800	],
801		cf_ok_build_cc=yes,
802		cf_ok_build_cc=no,
803		cf_ok_build_cc=unknown)
804
805	cross_compiling=$cf_save_crossed
806	ac_link=$cf_save_ac_link
807
808	AC_MSG_RESULT($cf_ok_build_cc)
809
810	if test "$cf_ok_build_cc" != yes
811	then
812		AC_MSG_ERROR([Cross-build requires two compilers.
813Use --with-build-cc to specify the native compiler.])
814	fi
815
816else
817	: ${BUILD_CC:='${CC}'}
818	: ${BUILD_CPP:='${CPP}'}
819	: ${BUILD_CFLAGS:='${CFLAGS}'}
820	: ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
821	: ${BUILD_LDFLAGS:='${LDFLAGS}'}
822	: ${BUILD_LIBS:='${LIBS}'}
823	: ${BUILD_EXEEXT:='$x'}
824	: ${BUILD_OBJEXT:='o'}
825fi
826
827AC_SUBST(BUILD_CC)
828AC_SUBST(BUILD_CPP)
829AC_SUBST(BUILD_CFLAGS)
830AC_SUBST(BUILD_CPPFLAGS)
831AC_SUBST(BUILD_LDFLAGS)
832AC_SUBST(BUILD_LIBS)
833AC_SUBST(BUILD_EXEEXT)
834AC_SUBST(BUILD_OBJEXT)
835])dnl
836dnl ---------------------------------------------------------------------------
837dnl CF_C11_NORETURN version: 5 updated: 2025/12/14 17:40:20
838dnl ---------------
839AC_DEFUN([CF_C11_NORETURN],
840[
841AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
842CF_ARG_ENABLE(stdnoreturn,
843	[  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
844	[enable_stdnoreturn=yes],
845	[enable_stdnoreturn=no])
846AC_MSG_RESULT($enable_stdnoreturn)
847
848if test $enable_stdnoreturn = yes; then
849AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
850	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
851$ac_includes_default
852#include <stdnoreturn.h>
853static _Noreturn void giveup(void) { exit(0); }
854	],
855	[if (feof(stdin)) giveup()])],
856	cf_cv_c11_noreturn=yes,
857	cf_cv_c11_noreturn=no)
858	])
859else
860	cf_cv_c11_noreturn=no,
861fi
862
863if test "$cf_cv_c11_noreturn" = yes; then
864	AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
865	AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
866	HAVE_STDNORETURN_H=1
867else
868	HAVE_STDNORETURN_H=0
869fi
870
871AC_SUBST(HAVE_STDNORETURN_H)
872AC_SUBST(STDC_NORETURN)
873])dnl
874dnl ---------------------------------------------------------------------------
875dnl CF_C99_STDBOOL_H version: 2 updated: 2025/12/24 12:27:29
876dnl ----------------
877dnl Check if we can compile using <stdbool.h> and get a valid "bool" type.
878AC_DEFUN([CF_C99_STDBOOL_H],
879[
880AC_CACHE_CHECK(if we can include stdbool.h,cf_cv_header_stdbool_h,[
881	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
882$ac_includes_default
883#include <stdbool.h>
884],[bool foo = false; (void)foo])],
885		[cf_cv_header_stdbool_h=yes],
886		[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[bool foo = false; (void)foo])],
887			[cf_cv_header_stdbool_h=no])])])
888
889if test "$cf_cv_header_stdbool_h" = yes
890then	USE_STDBOOL_H=1
891else	USE_STDBOOL_H=0
892fi
893AC_SUBST(USE_STDBOOL_H)
894])dnl
895dnl ---------------------------------------------------------------------------
896dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46
897dnl ---------------
898dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
899dnl into CC.  This will not help with broken scripts that wrap the compiler
900dnl with options, but eliminates a more common category of user confusion.
901dnl
902dnl In particular, it addresses the problem of being able to run the C
903dnl preprocessor in a consistent manner.
904dnl
905dnl Caveat: this also disallows blanks in the pathname for the compiler, but
906dnl the nuisance of having inconsistent settings for compiler and preprocessor
907dnl outweighs that limitation.
908AC_DEFUN([CF_CC_ENV_FLAGS],
909[
910# This should have been defined by AC_PROG_CC
911: "${CC:=cc}"
912
913AC_MSG_CHECKING(\$CFLAGS variable)
914case "x$CFLAGS" in
915(*-[[IUD]]*)
916	AC_MSG_RESULT(broken)
917	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
918	cf_flags="$CFLAGS"
919	CFLAGS=
920	for cf_arg in $cf_flags
921	do
922		CF_ADD_CFLAGS($cf_arg)
923	done
924	;;
925(*)
926	AC_MSG_RESULT(ok)
927	;;
928esac
929
930AC_MSG_CHECKING(\$CC variable)
931case "$CC" in
932(*[[\ \	]]-*)
933	AC_MSG_RESULT(broken)
934	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
935	# humor him...
936	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
937	cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
938	CC="$cf_prog"
939	for cf_arg in $cf_flags
940	do
941		case "x$cf_arg" in
942		(x-[[IUDfgOW]]*)
943			CF_ADD_CFLAGS($cf_arg)
944			;;
945		(*)
946			CC="$CC $cf_arg"
947			;;
948		esac
949	done
950	CF_VERBOSE(resulting CC: '$CC')
951	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
952	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
953	;;
954(*)
955	AC_MSG_RESULT(ok)
956	;;
957esac
958])dnl
959dnl ---------------------------------------------------------------------------
960dnl CF_CFG_DEFAULTS version: 17 updated: 2025/12/24 12:27:29
961dnl ---------------
962dnl Determine the default configuration into which we'll install ncurses.  This
963dnl can be overridden by the user's command-line options.  There's two items to
964dnl look for:
965dnl	1. the prefix (e.g., /usr)
966dnl	2. the header files (e.g., /usr/include/ncurses)
967dnl We'll look for a previous installation of ncurses and use the same defaults.
968dnl
969dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
970dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
971dnl programs from a vendor's.
972AC_DEFUN([CF_CFG_DEFAULTS],
973[AC_REQUIRE([AC_PROG_FGREP])dnl
974
975AC_MSG_CHECKING(for prefix)
976if test "x$prefix" = "xNONE" ; then
977	case "$cf_cv_system_name" in
978		# non-vendor systems don't have a conflict
979	(openbsd*|freebsd*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
980		prefix=/usr
981		;;
982	(*)	prefix=$ac_default_prefix
983		;;
984	esac
985fi
986AC_MSG_RESULT($prefix)
987
988if test "x$prefix" = "xNONE" ; then
989AC_MSG_CHECKING(for default include-directory)
990test -n "$verbose" && echo 1>&AS_MESSAGE_FD
991for cf_symbol in \
992	"$includedir" \
993	"$includedir/ncurses" \
994	"$prefix/include" \
995	"$prefix/include/ncurses" \
996	/usr/local/include \
997	/usr/local/include/ncurses \
998	/usr/include \
999	/usr/include/ncurses
1000do
1001	cf_dir=`eval echo "$cf_symbol"`
1002	if test -f "$cf_dir/curses.h" ; then
1003	if ( ${FGREP-fgrep} NCURSES_VERSION "$cf_dir/curses.h" >/dev/null 2>&1 ) ; then
1004		includedir="$cf_symbol"
1005		test -n "$verbose"  && echo $ECHO_N "	found " 1>&AS_MESSAGE_FD
1006		break
1007	fi
1008	fi
1009	test -n "$verbose"  && echo "	tested $cf_dir" 1>&AS_MESSAGE_FD
1010done
1011AC_MSG_RESULT($includedir)
1012fi
1013])dnl
1014dnl ---------------------------------------------------------------------------
1015dnl CF_CGETENT version: 8 updated: 2025/12/24 12:27:29
1016dnl ----------
1017dnl Check if the terminal-capability database functions are available.  If not,
1018dnl ncurses has a much-reduced version.
1019AC_DEFUN([CF_CGETENT],[
1020AC_CACHE_CHECK(for terminal-capability database functions,cf_cv_cgetent,[
1021AC_LINK_IFELSE([AC_LANG_PROGRAM([
1022$ac_includes_default],[
1023	char temp[[128]];
1024	char *buf = temp;
1025	char *db_array = temp;
1026	cgetent(&buf, &db_array, "vt100");
1027	cgetcap(buf, "tc", '=');
1028	cgetmatch(buf, "tc");
1029	])],
1030	[cf_cv_cgetent=yes],
1031	[cf_cv_cgetent=no])
1032])
1033
1034if test "$cf_cv_cgetent" = yes
1035then
1036	AC_DEFINE(HAVE_BSD_CGETENT,1,[Define to 1 if we have BSD cgetent])
1037AC_CACHE_CHECK(if cgetent uses const parameter,cf_cv_cgetent_const,[
1038AC_LINK_IFELSE([AC_LANG_PROGRAM([
1039#pragma GCC diagnostic error "-Wincompatible-pointer-types-discards-qualifiers"
1040$ac_includes_default],[
1041	char temp[[128]];
1042	char *buf = temp;
1043#ifndef _NETBSD_SOURCE			/* given, since April 2004 in stdlib.h */
1044	const char *db_array = temp;
1045	cgetent(&buf, &db_array, "vt100");
1046#endif
1047	cgetcap(buf, "tc", '=');
1048	cgetmatch(buf, "tc");
1049	])],
1050	[cf_cv_cgetent_const=yes],
1051	[cf_cv_cgetent_const=no])
1052])
1053	if test "$cf_cv_cgetent_const" = yes
1054	then
1055		AC_DEFINE_UNQUOTED(CGETENT_CONST,const,[Define to const if needed for some BSD cgetent variations])
1056	fi
1057fi
1058])dnl
1059dnl ---------------------------------------------------------------------------
1060dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
1061dnl --------------
1062dnl Check if we're accidentally using a cache from a different machine.
1063dnl Derive the system name, as a check for reusing the autoconf cache.
1064dnl
1065dnl If we've packaged config.guess and config.sub, run that (since it does a
1066dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1067dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1068dnl which is useful in cross-compiles.
1069dnl
1070dnl Note: we would use $ac_config_sub, but that is one of the places where
1071dnl autoconf 2.5x broke compatibility with autoconf 2.13
1072AC_DEFUN([CF_CHECK_CACHE],
1073[
1074if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
1075	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
1076	system_name="$host_os"
1077else
1078	system_name="`(uname -s -r) 2>/dev/null`"
1079	if test -z "$system_name" ; then
1080		system_name="`(hostname) 2>/dev/null`"
1081	fi
1082fi
1083test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
1084AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1085
1086test -z "$system_name" && system_name="$cf_cv_system_name"
1087test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1088
1089if test ".$system_name" != ".$cf_cv_system_name" ; then
1090	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
1091	AC_MSG_ERROR("Please remove config.cache and try again.")
1092fi
1093])dnl
1094dnl ---------------------------------------------------------------------------
1095dnl CF_CHECK_ENVIRON version: 6 updated: 2025/12/24 12:27:29
1096dnl ----------------
1097dnl Check for data that is usually declared in <unistd.h>, e.g., the 'environ'
1098dnl variable.  Define a DECL_xxx symbol if we must declare it ourselves.
1099dnl
1100dnl $1 = the name to check
1101dnl $2 = the assumed type
1102AC_DEFUN([CF_CHECK_ENVIRON],
1103[
1104AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
1105    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1106$ac_includes_default],
1107    [ifelse([$2],,void*,[$2]) x = (ifelse([$2],,void*,[$2])) $1; (void)x])],
1108    [cf_cv_dcl_$1=yes],
1109    [cf_cv_dcl_$1=no])
1110])
1111
1112if test "$cf_cv_dcl_$1" = no ; then
1113    CF_UPPER(cf_result,decl_$1)
1114    AC_DEFINE_UNQUOTED($cf_result)
1115fi
1116
1117# It's possible (for near-UNIX clones) that the data doesn't exist
1118CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
1119])dnl
1120dnl ---------------------------------------------------------------------------
1121dnl CF_CHECK_ERRNO version: 15 updated: 2025/12/23 18:53:34
1122dnl --------------
1123dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
1124dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
1125dnl ourselves.
1126dnl
1127dnl $1 = the name to check
1128dnl $2 = the assumed type
1129AC_DEFUN([CF_CHECK_ERRNO],
1130[
1131AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
1132	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1133$ac_includes_default
1134#include <errno.h> ],
1135	[ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1; (void)x])],
1136	[cf_cv_dcl_$1=yes],
1137	[cf_cv_dcl_$1=no])
1138])
1139
1140if test "$cf_cv_dcl_$1" = no ; then
1141	CF_UPPER(cf_result,decl_$1)
1142	AC_DEFINE_UNQUOTED($cf_result)
1143fi
1144
1145# It's possible (for near-UNIX clones) that the data doesn't exist
1146CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
1147])dnl
1148dnl ---------------------------------------------------------------------------
1149dnl CF_CHECK_EXTERN_DATA version: 6 updated: 2025/12/23 18:53:34
1150dnl --------------------
1151dnl Check for existence of external data in the current set of libraries.  If
1152dnl we can modify it, it is real enough.
1153dnl $1 = the name to check
1154dnl $2 = its type
1155AC_DEFUN([CF_CHECK_EXTERN_DATA],
1156[
1157AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
1158	AC_LINK_IFELSE([AC_LANG_PROGRAM([
1159#undef $1
1160extern $2 $1;
1161],
1162	[$1 = 2])],
1163	[cf_cv_have_$1=yes],
1164	[cf_cv_have_$1=no])
1165])
1166
1167if test "$cf_cv_have_$1" = yes ; then
1168	CF_UPPER(cf_result,have_$1)
1169	AC_DEFINE_UNQUOTED($cf_result)
1170fi
1171
1172])dnl
1173dnl ---------------------------------------------------------------------------
1174dnl CF_CHECK_FVISIBILITY version: 3 updated: 2025/12/24 12:27:29
1175dnl --------------------
1176dnl Check whether the compiler understands -fvisibility=hidden
1177dnl
1178dnl $1 = compiler
1179dnl $2 = compiler-flags variable name
1180dnl $3 = cache variable to set
1181AC_DEFUN([CF_CHECK_FVISIBILITY],[
1182AC_CACHE_CHECK(if $1 -fvisibility=hidden option works,$3,[
1183    cf_save_cflags="[$]$2"
1184    $2="[$]$2 -fvisibility=hidden"
1185    AC_LINK_IFELSE([AC_LANG_PROGRAM([
1186__attribute__ ((visibility("default"))) int somefunc() {return 42;}
1187	],[
1188	if (somefunc()) return 1;
1189])],
1190    [$3=yes],
1191    [$3=no])
1192    $2=$cf_save_cflags
1193])
1194])dnl
1195dnl ---------------------------------------------------------------------------
1196dnl CF_CHECK_GETENV version: 5 updated: 2024/12/14 16:09:34
1197dnl ---------------
1198dnl Check if repeated getenv calls return the same pointer, e.g., it does not
1199dnl discard the previous pointer when returning a new one.
1200AC_DEFUN([CF_CHECK_GETENV],
1201[
1202AC_REQUIRE([CF_CHECK_ENVIRON])
1203AC_CHECK_FUNC( getenv, ,, AC_MSG_ERROR(getenv not found) )
1204AC_CHECK_FUNCS( putenv setenv strdup )
1205AC_CACHE_CHECK(if getenv returns consistent values,cf_cv_consistent_getenv,[
1206AC_TRY_RUN([
1207$ac_includes_default
1208
1209#if defined(HAVE_ENVIRON) && defined(DECL_ENVIRON) && !defined(environ)
1210extern char **environ;	/* POSIX, but some systems are not... */
1211#endif
1212
1213#if defined(HAVE_STRDUP)
1214#define str_alloc(s) strdup(s)
1215#else
1216#define str_alloc(s) strcpy(malloc(strlen(s) + 1, s))
1217#endif
1218
1219static void set_value(const char *name, const char *value)
1220{
1221#if defined(HAVE_SETENV)
1222	setenv(name, value, 1);
1223#elif defined(HAVE_PUTENV)
1224	char buffer[1024];
1225	sprintf(buffer, "%s=%s", name, value);
1226	putenv(str_alloc(buffer));
1227#else
1228#error neither putenv/setenv found
1229#endif
1230}
1231int main(void)
1232{
1233	int pass;
1234	size_t numenv, limit, j;
1235	char **mynames;
1236	char **myvalues;
1237	char **mypointer;
1238	char *equals;
1239	for (numenv = 0; environ[numenv]; ++numenv) ;
1240	limit = numenv + 10;
1241	mynames = (char **) calloc(limit + 1, sizeof(char *));
1242	myvalues = (char **) calloc(limit + 1, sizeof(char *));
1243	mypointer = (char **) calloc(limit + 1, sizeof(char *));
1244#if defined(HAVE_ENVIRON)
1245	for (j = 0; environ[j]; ++j) {
1246		mynames[j] = str_alloc(environ[j]);
1247		equals = strchr(mynames[j], '=');
1248		if (equals != NULL) {
1249			*equals++ = '\\0';
1250			myvalues[j] = str_alloc(equals);
1251		} else {
1252			myvalues[j] = str_alloc("");
1253		}
1254	}
1255#endif
1256	for (j = numenv; j < limit; ++j) {
1257		char name[80];
1258		char value[80];
1259		size_t found;
1260		size_t k = 0;
1261		do {
1262			size_t jk;
1263			found = 0;
1264			sprintf(name, "TERM%lu", (unsigned long) k);
1265			for (jk = 0; jk < j; ++jk) {
1266				if (!strcmp(name, mynames[jk])) {
1267					found = 1;
1268					++k;
1269					break;
1270				}
1271			}
1272		} while (found);
1273		sprintf(value, "%lu:%p", (unsigned long) k, (void*)&mynames[j]);
1274		set_value(name, value);
1275		mynames[j] = str_alloc(name);
1276		myvalues[j] = str_alloc(value);
1277	}
1278	for (pass = 0; pass < 3; ++pass) {
1279		for (j = 0; j < limit; ++j) {
1280			char *value = getenv(mynames[j]);
1281			if (pass) {
1282				if (value == 0) {
1283					fprintf(stderr, "getenv returned null for %s\\n", mynames[j]);
1284					${cf_cv_main_return:-return}(1);
1285				} else if (value != mypointer[j]) {
1286					fprintf(stderr, "getenv returned different pointer for %s\\n", mynames[j]);
1287					${cf_cv_main_return:-return}(1);
1288				} else if (strcmp(value, myvalues[j])) {
1289					fprintf(stderr, "getenv returned different value for %s\\n", mynames[j]);
1290					${cf_cv_main_return:-return}(1);
1291				}
1292			} else {
1293				size_t k;
1294				mypointer[j] = value;
1295				for (k = 0; k < j; ++k) {
1296					if (mypointer[j] == mypointer[k]) {
1297						fprintf(stderr, "getenv returned same pointer for %s and %s\\n", mynames[j], mynames[k]);
1298						${cf_cv_main_return:-return}(1);
1299					}
1300				}
1301			}
1302		}
1303	}
1304	${cf_cv_main_return:-return}(0);
1305}
1306],
1307[cf_cv_consistent_getenv=yes],
1308[cf_cv_consistent_getenv=no],
1309[cf_cv_consistent_getenv=unknown])
1310])
1311
1312if test "x$cf_cv_consistent_getenv" = xno
1313then
1314	AC_DEFINE(HAVE_CONSISTENT_GETENV,1,[Define to 1 if getenv repeatably returns the same value for a given name])
1315fi
1316])dnl
1317dnl ---------------------------------------------------------------------------
1318dnl CF_CHECK_GNAT_VERSION version: 4 updated: 2021/01/01 13:31:04
1319dnl ---------------------
1320AC_DEFUN([CF_CHECK_GNAT_VERSION],
1321[
1322AC_REQUIRE([CF_GNAT_VERSION])
1323case "$cf_cv_gnat_version" in
1324(3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*|[[1-9]][[0-9]].[[0-9]]*|20[[0-9]][[0-9]])
1325	cf_cv_prog_gnat_correct=yes
1326	;;
1327(*)
1328	AC_MSG_WARN(Unsupported GNAT version $cf_cv_gnat_version. We require 3.11 or better. Disabling Ada95 binding.)
1329	cf_cv_prog_gnat_correct=no
1330	;;
1331esac
1332])
1333dnl ---------------------------------------------------------------------------
1334dnl CF_CHECK_GPM_WGETCH version: 6 updated: 2021/01/04 18:48:01
1335dnl -------------------
1336dnl Check if GPM is already linked with curses.  If so - and if the linkage
1337dnl is not "weak" - warn about this because it can create problems linking
1338dnl applications with ncurses.
1339AC_DEFUN([CF_CHECK_GPM_WGETCH],[
1340AC_REQUIRE([AC_PROG_EGREP])dnl
1341
1342AC_CHECK_LIB(gpm,Gpm_Wgetch,[
1343
1344AC_CACHE_CHECK(if GPM is weakly bound to curses library, cf_cv_check_gpm_wgetch,[
1345cf_cv_check_gpm_wgetch=unknown
1346if test "$cross_compiling" != yes ; then
1347
1348cat >conftest.$ac_ext <<CF_EOF
1349#include <gpm.h>
1350int main(void)
1351{
1352	Gpm_Wgetch();
1353	${cf_cv_main_return:-return}(0);
1354}
1355CF_EOF
1356
1357	cf_save_LIBS="$LIBS"
1358	# This only works if we can look at the symbol table.  If a shared
1359	# library is stripped for install, we cannot use that.  So we're forced
1360	# to rely on the static library, noting that some packagers may not
1361	# include it.
1362	LIBS="-static -lgpm -dynamic $LIBS"
1363	if AC_TRY_EVAL(ac_compile) ; then
1364		if AC_TRY_EVAL(ac_link) ; then
1365			cf_cv_check_gpm_wgetch="`nm \"conftest$ac_exeext\" | ${EGREP-egrep} '\<wgetch\>' | ${EGREP-egrep} '\<[[vVwW]]\>'`"
1366			test -n "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=yes
1367			test -z "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=no
1368		fi
1369	fi
1370	rm -rf ./conftest*
1371	LIBS="$cf_save_LIBS"
1372fi
1373])
1374
1375if test "$cf_cv_check_gpm_wgetch" != yes ; then
1376	AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
1377fi
1378])])dnl
1379dnl ---------------------------------------------------------------------------
1380dnl CF_CHECK_LIBSSP version: 2 updated: 2025/12/24 12:27:29
1381dnl ---------------
1382dnl Check if libssp is needed, e.g., to work around misconfigured libraries
1383dnl used in cross-compiling to MinGW.
1384AC_DEFUN([CF_CHECK_LIBSSP],[
1385AC_CACHE_CHECK(if ssp library is needed,cf_cv_need_libssp,[
1386AC_LINK_IFELSE([AC_LANG_PROGRAM([
1387#include <sys/types.h>
1388#include <dirent.h>
1389],[
1390       DIR *dp = opendir(".");
1391])],cf_cv_need_libssp=no,[
1392	cf_save_LIBS="$LIBS"
1393	LIBS="$LIBS -lssp"
1394	AC_LINK_IFELSE([AC_LANG_PROGRAM([
1395#include <sys/types.h>
1396#include <dirent.h>
1397	],[
1398		   DIR *dp = opendir(".");
1399	])],cf_cv_need_libssp=yes,
1400	  cf_cv_need_libssp=maybe)
1401	LIBS="$cf_save_LIBS"
1402])dnl
1403])
1404
1405if test "x$cf_cv_need_libssp" = xyes
1406then
1407	CF_ADD_LIB(ssp)
1408fi
1409])dnl
1410dnl ---------------------------------------------------------------------------
1411dnl CF_CHECK_LIBTOOL_VERSION version: 3 updated: 2024/06/12 04:19:01
1412dnl ------------------------
1413dnl Show the version of libtool
1414dnl
1415dnl Save the version in a cache variable - this is not entirely a good thing,
1416dnl but the version string from libtool is very ugly, and for bug reports it
1417dnl might be useful to have the original string.
1418dnl
1419dnl There is an imitation in OpenBSD, which has no apparent use other than to
1420dnl deny that it is GNU libtool.  Just ignore it.
1421AC_DEFUN([CF_CHECK_LIBTOOL_VERSION],[
1422if test -n "$LIBTOOL" && test "$LIBTOOL" != none
1423then
1424	AC_MSG_CHECKING(version of $LIBTOOL)
1425	CF_LIBTOOL_VERSION
1426	AC_MSG_RESULT($cf_cv_libtool_version)
1427	ifdef([LT_PACKAGE_VERSION],,[
1428	if test -n "$cf_cv_libtool_version"
1429	then
1430		cf_check_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' -e 's,[[()]],...,g' -e 's,[[ ]],-,g' -e '2,$d'`
1431		case "x$cf_check_libtool_version" in
1432		(*...GNU-libtool...*)
1433			;;
1434		(*)
1435			AC_MSG_ERROR(This is not GNU libtool)
1436			;;
1437		esac
1438	else
1439		AC_MSG_ERROR(No version found for $LIBTOOL)
1440	fi
1441	])
1442else
1443	AC_MSG_ERROR(GNU libtool has not been found)
1444fi
1445])dnl
1446dnl ---------------------------------------------------------------------------
1447dnl CF_CHECK_MULTIUSER version: 1 updated: 2025/09/13 11:43:46
1448dnl ------------------
1449dnl Runtime features which check for root permissions apply only to multiuser
1450dnl systems.  Check for single-user systems by inspecting /etc/passwd.
1451AC_DEFUN([CF_CHECK_MULTIUSER],[
1452AC_CACHE_CHECK(for conventional multiuser system,cf_cv_multiuser,[
1453	cf_cv_multiuser=no
1454	if test -f /etc/passwd
1455	then
1456		sed \
1457			-e '/true$/d' \
1458			-e '/false$/d' \
1459			-e '/nologin$/d' \
1460			-e '/^[[^:]]*:[[^:]]*:[[0-9]]:/d' \
1461			-e '/^[[^:]]*:[[^:]]*:[[0-9]][[0-9]]:/d' \
1462			-e '/:$/d' < /etc/passwd >conftest.tmp
1463		test -s conftest.tmp && cf_cv_multiuser=yes
1464		rm -f conftest.tmp
1465	fi
1466])
1467])dnl
1468dnl ---------------------------------------------------------------------------
1469dnl CF_CHECK_NAMED_PIPES version: 2 updated: 2025/12/24 12:27:29
1470dnl --------------------
1471dnl Check for existence of Windows named-pipe functions, set cache variable
1472dnl to reflect the result.
1473AC_DEFUN([CF_CHECK_NAMED_PIPES],[
1474AC_CACHE_CHECK(for named pipe functions,cf_cv_named_pipes,[
1475	cf_save_CPPFLAGS="$CPPFLAGS"
1476	CPPFLAGS="$CPPFLAGS -DWINVER=0x0600 -DWIN32_LEAN_AND_MEAN"
1477	AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <windows.h>],
1478	[
1479		HANDLE handle = 0;
1480		ULONG pPid = 0;
1481		if (GetNamedPipeInfo(handle, NULL, NULL, NULL, NULL)) {
1482			if (GetNamedPipeServerProcessId(handle, &pPid)) {
1483				${cf_cv_main_return:-return} (0);
1484			}
1485		}
1486	])],[cf_cv_named_pipes=yes],[cf_cv_named_pipes=no])
1487	CPPFLAGS="$cf_save_CPPFLAGS"
1488])dnl
1489])dnl
1490dnl ---------------------------------------------------------------------------
1491dnl CF_CHECK_TBL_X_OPTION version: 2 updated: 2025/11/11 20:09:36
1492dnl ---------------------
1493AC_DEFUN([CF_CHECK_TBL_X_OPTION],[
1494AC_REQUIRE([CF_PROG_TBL])
1495
1496AC_CACHE_CHECK(if $NROFF_TBL supports 'x' column modifier,cf_cv_tbl_x_option_okay,[
1497	if test "$cross_compiling" = yes ; then
1498		cf_cv_tbl_x_option_okay=unknown
1499	else
1500		cf_cv_tbl_x_option_okay=no
1501		cat > conftest <<-CF_EOF
1502		.TS
1503		L.
1504		table cell
1505		.TE
1506		CF_EOF
1507		if $NROFF_TBL < conftest > /dev/null 2>&1
1508		then
1509			cat > conftest <<-CF_EOF
1510			.TS
1511			Lx.
1512			table cell
1513			.TE
1514			CF_EOF
1515			if $NROFF_TBL < conftest > /dev/null 2>&1
1516			then
1517				cf_cv_tbl_x_option_okay=yes
1518			fi
1519		else
1520			AC_MSG_ERROR([$NROFF_TBL not available.])
1521		fi
1522		rm -f conftest
1523	fi
1524])
1525
1526TBL_X_OPTION=$cf_cv_tbl_x_option_okay
1527AC_SUBST(TBL_X_OPTION)
1528])dnl
1529dnl ---------------------------------------------------------------------------
1530dnl CF_CHECK_TYPE2 version: 3 updated: 2025/08/08 20:44:18
1531dnl --------------
1532dnl Check if the given type can be declared via the given header.
1533dnl $1 = the type to check
1534dnl $2 = the header (i.e., not one of the default includes)
1535AC_DEFUN([CF_CHECK_TYPE2],[
1536	AC_CHECK_TYPES($1,,,[
1537$ac_includes_default
1538ifelse($2,,,[#include <$2>])])
1539])dnl
1540dnl ---------------------------------------------------------------------------
1541dnl CF_CHECK_WCHAR_H version: 6 updated: 2025/12/24 12:27:29
1542dnl ----------------
1543dnl Check if wchar.h can be used, i.e., without defining _XOPEN_SOURCE_EXTENDED
1544AC_DEFUN([CF_CHECK_WCHAR_H],[
1545AC_CHECK_HEADERS( \
1546wchar.h \
1547wctype.h \
1548)
1549AC_CACHE_CHECK(if wchar.h can be used as is,cf_cv_wchar_h_okay,[
1550AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1551[
1552$ac_includes_default
1553#ifdef HAVE_WCHAR_H
1554#include <wchar.h>
1555#endif
1556#ifdef HAVE_WCTYPE_H
1557#include <wctype.h>
1558#endif
1559],[
1560	wint_t foo = 0;
1561	int bar = iswpunct(foo); (void) bar])],
1562	[cf_cv_wchar_h_okay=yes],
1563	[cf_cv_wchar_h_okay=no])])
1564
1565if test "$cf_cv_wchar_h_okay" = no
1566then
1567	CF_PREDEFINE(_XOPEN_SOURCE_EXTENDED)
1568fi
1569])dnl
1570dnl ---------------------------------------------------------------------------
1571dnl CF_CHECK_WCWIDTH_GRAPHICS version: 5 updated: 2024/12/14 16:09:34
1572dnl -------------------------
1573dnl Most "modern" terminal emulators are based to some degree on VT100, and
1574dnl should support line-drawing.  Even with Unicode.  There is a problem.
1575dnl
1576dnl While most of the VT100 graphics characters were incorporated into Unicode,
1577dnl all of those were combined into a page of useful graphics characters.
1578dnl
1579dnl So far, so good.
1580dnl
1581dnl However, while they are useful, there are other considerations.  CJK
1582dnl is (because of poor device resolution) often rendered as double-width
1583dnl characters.  So... for these generally-useful characters, what should
1584dnl be the width (to make them consistent with adjacent characters)?
1585dnl
1586dnl The obvious choice would have been to make this locale-dependent, and use
1587dnl wcwidth() to tell applications what the actual width is.  That was too
1588dnl obvious.  Instead, we have a slew of "ambiguous-width" characters.
1589dnl See for example
1590dnl		http://www.unicode.org/reports/tr11/tr11-29.html
1591dnl		http://www.cl.cam.ac.uk/~mgk25/ucs/scw-proposal.html
1592dnl
1593dnl The EastAsianWidth-6.2.0.txt file from the Unicode organization lists
1594dnl more than 22,000 characters, with 1281 of those as ambiguous-width.  For
1595dnl instance, it lists half (44/96) of the Latin-1 characters as
1596dnl ambiguous-width.  Also, all of the box-characters at 0x2500 are ambiguous.
1597dnl
1598dnl What this means for the implementor is that on some systems wcwidth() can
1599dnl give bad advice.  On Solaris, some of the ambiguous widths are returned as
1600dnl 1 (the Latin-1 characters), while others are returned as 2 (line-drawing
1601dnl characters).  These do not necessarily match the behavior of the terminal
1602dnl emulator.  xterm, for instance, does an optional startup check to find if
1603dnl this problem (or similar) exists with the system's locale tables, rejecting
1604dnl them if they are too unreliable.
1605AC_DEFUN([CF_CHECK_WCWIDTH_GRAPHICS],[
1606AC_CACHE_CHECK(if wcwidth agrees graphics are single-width, cf_cv_wcwidth_graphics,[
1607cat >conftest.in <<CF_EOF
1608-	VT100 symbols
16090x250c	upper left corner
16100x2514	lower left corner
16110x2510	upper right corner
16120x2518	lower right corner
16130x251c	tee pointing left
16140x2524	tee pointing right
16150x2534	tee pointing up
16160x252c	tee pointing down
16170x2500	horizontal line
16180x2502	vertical line
16190x253c	large plus or crossover
16200x23ba	scan line 1
16210x23bd	scan line 9
16220x25c6	diamond
16230x2592	checker board (stipple)
16240x00b0	degree symbol
16250x00b1	plus/minus
16260x00b7	bullet
1627-	Teletype 5410v1 symbols
16280x2190	arrow pointing left
16290x2192	arrow pointing right
16300x2193	arrow pointing down
16310x2191	arrow pointing up
16320x2592	board of squares
16330x2603	lantern symbol
16340x25ae	solid square block
1635-	these defaults were invented for ncurses
16360x23bb	scan line 3
16370x23bc	scan line 7
16380x2264	less-than-or-equal-to
16390x2265	greater-than-or-equal-to
16400x03c0	greek pi
16410x2260	not-equal
16420x00a3	pound-sterling symbol
1643-	thick-line-drawing
16440x250f	upper left corner
16450x2517	lower left corner
16460x2513	upper right corner
16470x251b	lower right corner
16480x2523	tee pointing left
16490x252b	tee pointing right
16500x253b	tee pointing up
16510x2533	tee pointing down
16520x2501	horizontal line
16530x2503	vertical line
16540x254b	large plus or crossover
1655-	double-line-drawing
16560x2554	upper left corner
16570x255a	lower left corner
16580x2557	upper right corner
16590x255d	lower right corner
16600x2563	tee pointing left
16610x2560	tee pointing right
16620x2569	tee pointing up
16630x2566	tee pointing down
16640x2550	horizontal line
16650x2551	vertical line
16660x256c	large plus or crossover
1667CF_EOF
1668AC_TRY_RUN([
1669$ac_includes_default
1670
1671#include <locale.h>
1672#include <wchar.h>
1673
1674#define MY_LEN 80
1675
1676int
1677main(void)
1678{
1679	FILE *fp;
1680	unsigned value;
1681	char buffer[MY_LEN + 1];
1682	char notes[MY_LEN + 1];
1683	int totals = 0;
1684	int passed = 0;
1685
1686	if (setlocale(LC_ALL, "en_US.UTF8") ||
1687		setlocale(LC_ALL, "en_US.UTF-8") ||
1688		setlocale(LC_ALL, "en_US.utf8") ||
1689		setlocale(LC_ALL, "en_US.utf-8")) {
1690		if ((fp = fopen("conftest.in", "r")) != NULL) {
1691			while (fgets(buffer, MY_LEN, fp) != NULL) {
1692				if (*buffer == '-') {
1693					fprintf(stderr, "\\t%s", buffer);
1694				} else if (sscanf(buffer, "%x %s", &value, notes) == 2) {
1695					++totals;
1696					if (wcwidth((int)value) == 1)
1697						++passed;
1698					fprintf(stderr, "%d\\t%s", wcwidth((int)value), buffer);
1699				} else {
1700					fprintf(stderr, "?\\t%s", buffer);
1701				}
1702			}
1703		}
1704	}
1705	fprintf(stderr, "%d/%d passed wcwidth/graphics check\\n", passed, totals);
1706	return (totals == passed) ? 0 : 1;
1707}
1708],
1709[cf_cv_wcwidth_graphics=yes],
1710[cf_cv_wcwidth_graphics=no],
1711[cf_cv_wcwidth_graphics=unknown])
1712])
1713])dnl
1714dnl ---------------------------------------------------------------------------
1715dnl CF_CLANG_COMPILER version: 11 updated: 2025/12/14 17:46:02
1716dnl -----------------
1717dnl Check if the given compiler is really clang.  clang's C driver defines
1718dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
1719dnl not ignore some gcc options.
1720dnl
1721dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1722dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1723dnl the wrappers for gcc and g++ warnings.
1724dnl
1725dnl $1 = GCC (default) or GXX
1726dnl $2 = CLANG_COMPILER (default)
1727dnl $3 = CFLAGS (default) or CXXFLAGS
1728AC_DEFUN([CF_CLANG_COMPILER],[
1729ifelse([$2],,CLANG_COMPILER,[$2])=no
1730
1731if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1732	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
1733	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1734	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[
1735#ifdef __clang__
1736#else
1737#error __clang__ is not defined
1738#endif
1739])],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
1740],[])
1741	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1742	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
1743fi
1744
1745CLANG_VERSION=none
1746
1747if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
1748	case "$CC" in
1749	(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
1750		AC_MSG_WARN(replacing broken compiler alias $CC)
1751		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
1752		CC=clang
1753		;;
1754	esac
1755
1756	AC_MSG_CHECKING(version of $CC)
1757	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.]].*//'`"
1758	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
1759	AC_MSG_RESULT($CLANG_VERSION)
1760
1761	for cf_clang_opt in \
1762		-Qunused-arguments \
1763		-Wno-error=implicit-function-declaration
1764	do
1765		AC_MSG_CHECKING(if option $cf_clang_opt works)
1766		cf_save_CFLAGS="$CFLAGS"
1767		CFLAGS="$CFLAGS $cf_clang_opt"
1768		AC_LINK_IFELSE([AC_LANG_PROGRAM([
1769			#include <stdio.h>],[
1770			printf("hello!\\n");])],[
1771			cf_clang_optok=yes],[
1772			cf_clang_optok=no])
1773		AC_MSG_RESULT($cf_clang_optok)
1774		CFLAGS="$cf_save_CFLAGS"
1775		if test "$cf_clang_optok" = yes; then
1776			CF_VERBOSE(adding option $cf_clang_opt)
1777			CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
1778		fi
1779	done
1780fi
1781])
1782dnl ---------------------------------------------------------------------------
1783dnl CF_CONST_X_STRING version: 10 updated: 2025/12/14 17:40:20
1784dnl -----------------
1785dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
1786dnl character-strings.
1787dnl
1788dnl It is ambiguous because the specification accommodated the pre-ANSI
1789dnl compilers bundled by more than one vendor in lieu of providing a standard C
1790dnl compiler other than by costly add-ons.  Because of this, the specification
1791dnl did not take into account the use of const for telling the compiler that
1792dnl string literals would be in readonly memory.
1793dnl
1794dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
1795dnl let the compiler decide how to represent Xt's strings which were #define'd.
1796dnl That does not solve the problem of using the block of Xt's strings which
1797dnl are compiled into the library (and is less efficient than one might want).
1798dnl
1799dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
1800dnl when compiling the library and compiling using the library, to tell the
1801dnl compiler that String is const.
1802AC_DEFUN([CF_CONST_X_STRING],
1803[
1804AC_REQUIRE([AC_PATH_XTRA])
1805
1806CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
1807
1808AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1809[
1810$ac_includes_default
1811#include <X11/Intrinsic.h>
1812],
1813[String foo = malloc(1); free((void*)foo)])],[
1814
1815AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
1816	AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1817		[
1818#undef  _CONST_X_STRING
1819#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
1820#undef  XTSTRINGDEFINES	/* X11R5 and later */
1821$ac_includes_default
1822#include <X11/Intrinsic.h>
1823		],[String foo = malloc(1); *foo = 0])],[
1824			cf_cv_const_x_string=no
1825		],[
1826			cf_cv_const_x_string=yes
1827		])
1828])
1829
1830CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
1831
1832case "$cf_cv_const_x_string" in
1833(no)
1834	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
1835	;;
1836(*)
1837	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
1838	;;
1839esac
1840
1841])
1842])dnl
1843dnl ---------------------------------------------------------------------------
1844dnl CF_CPP_OVERRIDE version: 2 updated: 2024/11/09 18:07:29
1845dnl ---------------
1846dnl Check if the C++ compiler accepts the override keyword.  This is a C++-11
1847dnl feature.
1848AC_DEFUN([CF_CPP_OVERRIDE],
1849[
1850if test -n "$CXX"; then
1851AC_CACHE_CHECK(if $CXX accepts override keyword,cf_cv_cpp_override,[
1852	AC_LANG_SAVE
1853	AC_LANG_CPLUSPLUS
1854	AC_TRY_RUN([
1855
1856class base
1857{
1858public:
1859	virtual int foo(float x) = 0;
1860};
1861
1862
1863class derived: public base
1864{
1865public:
1866	int foo(float x) override { return x != 0.0 ? 1 : 0; }
1867};
1868
1869int main(void) { }
1870],
1871	[cf_cv_cpp_override=yes],
1872	[cf_cv_cpp_override=no],
1873	[cf_cv_cpp_override=unknown])
1874	AC_LANG_RESTORE
1875])
1876fi
1877test "$cf_cv_cpp_override" = yes && AC_DEFINE(CPP_HAS_OVERRIDE,1,[Define to 1 if C++ has override keyword])
1878])dnl
1879dnl ---------------------------------------------------------------------------
1880dnl CF_CPP_PARAM_INIT version: 7 updated: 2017/01/21 11:06:25
1881dnl -----------------
1882dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
1883dnl is a late feature for the standard and is not in some recent compilers
1884dnl (1999/9/11).
1885AC_DEFUN([CF_CPP_PARAM_INIT],
1886[
1887if test -n "$CXX"; then
1888AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
1889	AC_LANG_SAVE
1890	AC_LANG_CPLUSPLUS
1891	AC_TRY_RUN([
1892class TEST {
1893private:
1894	int value;
1895public:
1896	TEST(int x = 1);
1897	~TEST();
1898};
1899
1900TEST::TEST(int x = 1)	// some compilers do not like second initializer
1901{
1902	value = x;
1903}
1904int main(void) { }
1905],
1906	[cf_cv_cpp_param_init=yes],
1907	[cf_cv_cpp_param_init=no],
1908	[cf_cv_cpp_param_init=unknown])
1909	AC_LANG_RESTORE
1910])
1911fi
1912test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT,1,[Define to 1 if C++ has parameter initialization])
1913])dnl
1914dnl ---------------------------------------------------------------------------
1915dnl CF_CPP_STATIC_CAST version: 4 updated: 2025/12/24 12:27:29
1916dnl ------------------
1917dnl Check if the C++ compiler accepts static_cast in generics.  This appears to
1918dnl not be supported in g++ before 3.0
1919AC_DEFUN([CF_CPP_STATIC_CAST],
1920[
1921if test -n "$CXX"; then
1922
1923AC_CACHE_CHECK(if $CXX accepts static_cast,cf_cv_cpp_static_cast,[
1924	AC_LANG_SAVE
1925	AC_LANG_CPLUSPLUS
1926
1927	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
1928class NCursesPanel
1929{
1930public:
1931  NCursesPanel(int nlines,
1932	       int ncols,
1933	       int begin_y = 0,
1934	       int begin_x = 0)
1935  {
1936  }
1937  NCursesPanel();
1938  ~NCursesPanel();
1939};
1940
1941template<class T> class NCursesUserPanel : public NCursesPanel
1942{
1943public:
1944  NCursesUserPanel (int nlines,
1945		    int ncols,
1946		    int begin_y = 0,
1947		    int begin_x = 0,
1948		    const T* p_UserData = static_cast<T*>(0))
1949    : NCursesPanel (nlines, ncols, begin_y, begin_x)
1950  {
1951  };
1952  NCursesUserPanel(const T* p_UserData = static_cast<T*>(0)) : NCursesPanel()
1953  {
1954  };
1955
1956  virtual ~NCursesUserPanel() {};
1957};
1958],[
1959	const char* p_UserData = static_cast<char*>(0)])],
1960	[cf_cv_cpp_static_cast=yes],
1961	[cf_cv_cpp_static_cast=no])
1962
1963	AC_LANG_RESTORE
1964])
1965
1966fi
1967
1968test "$cf_cv_cpp_static_cast" = yes && AC_DEFINE(CPP_HAS_STATIC_CAST,1,[Define to 1 if C++ has static_cast])
1969])dnl
1970dnl ---------------------------------------------------------------------------
1971dnl CF_CXX_AR_FLAGS version: 3 updated: 2021/01/01 13:31:04
1972dnl ---------------
1973dnl Setup special archiver flags for given compilers.
1974AC_DEFUN([CF_CXX_AR_FLAGS],[
1975	CXX_AR='$(AR)'
1976	CXX_ARFLAGS='$(ARFLAGS)'
1977	case "$cf_cv_system_name" in
1978	(irix*)
1979	    if test "$GXX" != yes ; then
1980		CXX_AR='$(CXX)'
1981		CXX_ARFLAGS='-ar -o'
1982	    fi
1983	    ;;
1984	(sco3.2v5*)
1985	    CXXLDFLAGS="-u main"
1986	    ;;
1987	(solaris2*)
1988	    if test "$GXX" != yes ; then
1989		CXX_AR='$(CXX)'
1990		CXX_ARFLAGS='-xar -o'
1991	    fi
1992	    ;;
1993	esac
1994	AC_SUBST(CXXLDFLAGS)
1995	AC_SUBST(CXX_AR)
1996	AC_SUBST(CXX_ARFLAGS)
1997])dnl
1998dnl ---------------------------------------------------------------------------
1999dnl CF_CXX_IOSTREAM_NAMESPACE version: 3 updated: 2025/12/24 12:27:29
2000dnl -------------------------
2001dnl For c++, check if iostream uses "std::" namespace.
2002AC_DEFUN([CF_CXX_IOSTREAM_NAMESPACE],[
2003AC_CHECK_HEADERS(iostream)
2004if test x"$ac_cv_header_iostream" = xyes ; then
2005	AC_MSG_CHECKING(if iostream uses std-namespace)
2006	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
2007#include <iostream>
2008using std::endl;
2009using std::cerr;],[
2010cerr << "testing" << endl;
2011])],[cf_iostream_namespace=yes],[cf_iostream_namespace=no])
2012	AC_MSG_RESULT($cf_iostream_namespace)
2013	if test "$cf_iostream_namespace" = yes ; then
2014		AC_DEFINE(IOSTREAM_NAMESPACE,1,[Define to 1 if C++ has namespace iostream])
2015	fi
2016fi
2017])dnl
2018dnl ---------------------------------------------------------------------------
2019dnl CF_C_INLINE version: 7 updated: 2025/12/24 12:27:29
2020dnl -----------
2021dnl Check if the C compiler supports "inline".
2022dnl $1 is the name of a shell variable to set if inline is supported
2023dnl $2 is the threshold for gcc 4.x's option controlling maximum inline size
2024AC_DEFUN([CF_C_INLINE],[
2025AC_REQUIRE([CF_GCC_VERSION])
2026AC_C_INLINE
2027$1=
2028if test "$ac_cv_c_inline" != no ; then
2029	$1=inline
2030	if test "$INTEL_COMPILER" = yes
2031	then
2032		:
2033	elif test "$CLANG_COMPILER" = yes
2034	then
2035		:
2036	elif test "$GCC" = yes
2037	then
2038		AC_CACHE_CHECK(if $CC supports options to tune inlining,cf_cv_gcc_inline,[
2039		cf_save_CFLAGS=$CFLAGS
2040		CFLAGS="$CFLAGS --param max-inline-insns-single=$2"
2041		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([inline int foo(void) { return 1; }],
2042		[${cf_cv_main_return:-return} foo()])],
2043		[cf_cv_gcc_inline=yes],
2044		[cf_cv_gcc_inline=no])
2045		CFLAGS=$cf_save_CFLAGS
2046		])
2047		if test "$cf_cv_gcc_inline" = yes ; then
2048			CF_ADD_CFLAGS([--param max-inline-insns-single=$2])
2049		fi
2050	fi
2051fi
2052AC_SUBST($1)
2053])dnl
2054dnl ---------------------------------------------------------------------------
2055dnl CF_DIRNAME version: 5 updated: 2020/12/31 20:19:42
2056dnl ----------
2057dnl "dirname" is not portable, so we fake it with a shell script.
2058AC_DEFUN([CF_DIRNAME],[$1=`echo "$2" | sed -e 's%/[[^/]]*$%%'`])dnl
2059dnl ---------------------------------------------------------------------------
2060dnl CF_DIRS_TO_MAKE version: 4 updated: 2021/01/01 13:31:04
2061dnl ---------------
2062AC_DEFUN([CF_DIRS_TO_MAKE],
2063[
2064DIRS_TO_MAKE="lib"
2065for cf_item in $cf_list_models
2066do
2067	CF_OBJ_SUBDIR($cf_item,cf_subdir)
2068	for cf_item2 in $DIRS_TO_MAKE
2069	do
2070		test "$cf_item2" = "$cf_subdir" && break
2071	done
2072	test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
2073done
2074for cf_dir in $DIRS_TO_MAKE
2075do
2076	test ! -d "$cf_dir" && mkdir "$cf_dir"
2077done
2078AC_SUBST(DIRS_TO_MAKE)
2079])dnl
2080dnl ---------------------------------------------------------------------------
2081dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
2082dnl ---------------
2083dnl You can always use "make -n" to see the actual options, but it is hard to
2084dnl pick out/analyze warning messages when the compile-line is long.
2085dnl
2086dnl Sets:
2087dnl	ECHO_LT - symbol to control if libtool is verbose
2088dnl	ECHO_LD - symbol to prefix "cc -o" lines
2089dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
2090dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
2091dnl	ECHO_CC - symbol to put before any "cc" line
2092dnl
2093AC_DEFUN([CF_DISABLE_ECHO],[
2094AC_MSG_CHECKING(if you want to see long compiling messages)
2095CF_ARG_DISABLE(echo,
2096	[  --disable-echo          do not display "compiling" commands],
2097	[
2098	ECHO_LT='--silent'
2099	ECHO_LD='@echo linking [$]@;'
2100	RULE_CC='@echo compiling [$]<'
2101	SHOW_CC='@echo compiling [$]@'
2102	ECHO_CC='@'
2103],[
2104	ECHO_LT=''
2105	ECHO_LD=''
2106	RULE_CC=''
2107	SHOW_CC=''
2108	ECHO_CC=''
2109])
2110AC_MSG_RESULT($enableval)
2111AC_SUBST(ECHO_LT)
2112AC_SUBST(ECHO_LD)
2113AC_SUBST(RULE_CC)
2114AC_SUBST(SHOW_CC)
2115AC_SUBST(ECHO_CC)
2116])dnl
2117dnl ---------------------------------------------------------------------------
2118dnl CF_DISABLE_GNAT_PROJECTS version: 1 updated: 2014/06/01 11:34:00
2119dnl ------------------------
2120AC_DEFUN([CF_DISABLE_GNAT_PROJECTS],[
2121AC_MSG_CHECKING(if we want to use GNAT projects)
2122CF_ARG_DISABLE(gnat-projects,
2123	[  --disable-gnat-projects test: disable GNAT projects even if usable],
2124	[enable_gnat_projects=no],
2125	[enable_gnat_projects=yes])
2126AC_MSG_RESULT($enable_gnat_projects)
2127])dnl
2128dnl ---------------------------------------------------------------------------
2129dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
2130dnl ----------------
2131dnl Combine no-leak checks with the libraries or tools that are used for the
2132dnl checks.
2133AC_DEFUN([CF_DISABLE_LEAKS],[
2134
2135AC_REQUIRE([CF_WITH_DMALLOC])
2136AC_REQUIRE([CF_WITH_DBMALLOC])
2137AC_REQUIRE([CF_WITH_VALGRIND])
2138
2139AC_MSG_CHECKING(if you want to perform memory-leak testing)
2140AC_ARG_ENABLE(leaks,
2141	[  --disable-leaks         test: free permanent memory, analyze leaks],
2142	[enable_leaks=$enableval],
2143	[enable_leaks=yes])
2144dnl with_no_leaks is more readable...
2145if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
2146AC_MSG_RESULT($with_no_leaks)
2147
2148if test "$enable_leaks" = no ; then
2149	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
2150	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
2151fi
2152])dnl
2153dnl ---------------------------------------------------------------------------
2154dnl CF_DISABLE_LIBTOOL_VERSION version: 3 updated: 2015/04/17 21:13:04
2155dnl --------------------------
2156dnl Check if we should use the libtool 1.5 feature "-version-number" instead of
2157dnl the older "-version-info" feature.  The newer feature allows us to use
2158dnl version numbering on shared libraries which make them compatible with
2159dnl various systems.
2160AC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
2161[
2162AC_MSG_CHECKING(if libtool -version-number should be used)
2163CF_ARG_DISABLE(libtool-version,
2164	[  --disable-libtool-version  enable to use libtool's incompatible naming scheme],
2165	[cf_libtool_version=no],
2166	[cf_libtool_version=yes])
2167AC_MSG_RESULT($cf_libtool_version)
2168
2169if test "$cf_libtool_version" = yes ; then
2170	LIBTOOL_VERSION="-version-number"
2171else
2172	LIBTOOL_VERSION="-version-info"
2173	case "x$VERSION" in
2174	(x)
2175		AC_MSG_WARN(VERSION was not set)
2176		;;
2177	(x*.*.*)
2178		ABI_VERSION="$VERSION"
2179		CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
2180		;;
2181	(x*:*:*)
2182		ABI_VERSION=`echo "$VERSION" | sed -e 's/:/./g'`
2183		CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
2184		;;
2185	(*)
2186		AC_MSG_WARN(unexpected VERSION value: $VERSION)
2187		;;
2188	esac
2189fi
2190
2191AC_SUBST(ABI_VERSION)
2192AC_SUBST(LIBTOOL_VERSION)
2193])dnl
2194dnl ---------------------------------------------------------------------------
2195dnl CF_DISABLE_RPATH_HACK version: 3 updated: 2021/01/05 20:14:44
2196dnl ---------------------
2197dnl The rpath-hack makes it simpler to build programs, particularly with the
2198dnl *BSD ports which may have essential libraries in unusual places.  But it
2199dnl can interfere with building an executable for the base system.  Use this
2200dnl option in that case.
2201AC_DEFUN([CF_DISABLE_RPATH_HACK],
2202[
2203AC_MSG_CHECKING(if rpath-hack should be disabled)
2204CF_ARG_DISABLE(rpath-hack,
2205	[  --disable-rpath-hack    don't add rpath options for additional libraries],
2206	[enable_rpath_hack=no],
2207	[enable_rpath_hack=yes])
2208dnl TODO - drop cf_disable_rpath_hack
2209if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
2210AC_MSG_RESULT($cf_disable_rpath_hack)
2211
2212if test "$enable_rpath_hack" = yes ; then
2213	CF_RPATH_HACK
2214fi
2215])
2216dnl ---------------------------------------------------------------------------
2217dnl CF_ENABLE_BROKEN_LINKER version: 2 updated: 2021/01/02 17:09:14
2218dnl -----------------------
2219dnl Some linkers cannot reference a data-only object.  Cygwin used to be one.
2220dnl This usually follows CF_LINK_DATAONLY, but is not required in case we need
2221dnl an unconditional feature.
2222AC_DEFUN([CF_ENABLE_BROKEN_LINKER],[
2223
2224AC_MSG_CHECKING(if you want broken-linker support code)
2225AC_ARG_ENABLE(broken_linker,
2226	[  --enable-broken_linker  compile with broken-linker support code],
2227	[with_broken_linker=$enableval],
2228	[with_broken_linker=no])
2229AC_MSG_RESULT($with_broken_linker)
2230
2231: "${BROKEN_LINKER:=0}"
2232if test "x$with_broken_linker" = xyes ; then
2233	AC_DEFINE(BROKEN_LINKER,1,[Define to 1 to work around linkers which cannot link data-only modules])
2234	BROKEN_LINKER=1
2235fi
2236AC_SUBST(BROKEN_LINKER)
2237])dnl
2238dnl ---------------------------------------------------------------------------
2239dnl CF_ENABLE_PC_FILES version: 16 updated: 2021/11/20 12:48:37
2240dnl ------------------
2241dnl This is the "--enable-pc-files" option, which is available if there is a
2242dnl pkg-config configuration on the local machine.
2243AC_DEFUN([CF_ENABLE_PC_FILES],[
2244AC_REQUIRE([CF_PKG_CONFIG])
2245AC_REQUIRE([CF_WITH_PKG_CONFIG_LIBDIR])
2246
2247if test "x$PKG_CONFIG" != xnone
2248then
2249	AC_MSG_CHECKING(if we should install .pc files for $PKG_CONFIG)
2250else
2251	AC_MSG_CHECKING(if we should install .pc files)
2252fi
2253
2254AC_ARG_ENABLE(pc-files,
2255	[  --enable-pc-files       generate and install .pc files for pkg-config],
2256	[enable_pc_files=$enableval],
2257	[enable_pc_files=no])
2258AC_MSG_RESULT($enable_pc_files)
2259
2260if test "x$enable_pc_files" != xno
2261then
2262	MAKE_PC_FILES=
2263	case "x$PKG_CONFIG_LIBDIR" in
2264	(xno|xnone|xyes|x)
2265		AC_MSG_WARN(no PKG_CONFIG_LIBDIR was found)
2266		;;
2267	(*)
2268		cf_pkg_config_libdir="$PKG_CONFIG_LIBDIR"
2269		CF_PATH_SYNTAX(cf_pkg_config_libdir)
2270		;;
2271	esac
2272else
2273	MAKE_PC_FILES="#"
2274fi
2275AC_SUBST(MAKE_PC_FILES)
2276])dnl
2277dnl ---------------------------------------------------------------------------
2278dnl CF_ENABLE_RPATH version: 2 updated: 2010/03/27 18:39:42
2279dnl ---------------
2280dnl Check if the rpath option should be used, setting cache variable
2281dnl cf_cv_enable_rpath if so.
2282AC_DEFUN([CF_ENABLE_RPATH],
2283[
2284AC_MSG_CHECKING(if rpath option should be used)
2285AC_ARG_ENABLE(rpath,
2286[  --enable-rpath          use rpath option when generating shared libraries],
2287[cf_cv_enable_rpath=$enableval],
2288[cf_cv_enable_rpath=no])
2289AC_MSG_RESULT($cf_cv_enable_rpath)
2290])dnl
2291dnl ---------------------------------------------------------------------------
2292dnl CF_ENABLE_STRING_HACKS version: 7 updated: 2025/11/11 20:09:36
2293dnl ----------------------
2294dnl On a few platforms, the compiler and/or loader nags with untruthful
2295dnl comments stating that "most" uses of strcat/strcpy/sprintf are incorrect,
2296dnl and implying that most uses of the recommended alternatives are correct.
2297dnl
2298dnl Factually speaking, no one has actually counted the number of uses of these
2299dnl functions versus the total of incorrect uses.  Samples of a few thousand
2300dnl instances are meaningless compared to the hundreds of millions of lines of
2301dnl existing C code.
2302dnl
2303dnl strlcat/strlcpy are standard as of POSIX.1-2024, and are available on some
2304dnl platforms, in implementations of varying quality.  Likewise, snprintf is
2305dnl standard - but evolved through phases, and older implementations are likely
2306dnl to yield surprising results, as documented in man pages on various systems.
2307AC_DEFUN([CF_ENABLE_STRING_HACKS],
2308[
2309AC_MSG_CHECKING(if you want to work around bogus compiler/loader warnings)
2310AC_ARG_ENABLE(string-hacks,
2311	[  --enable-string-hacks   work around bogus compiler/loader warnings],
2312	[enable_string_hacks=$enableval],
2313	[enable_string_hacks=no])
2314AC_MSG_RESULT($enable_string_hacks)
2315
2316if test "x$enable_string_hacks" = "xyes"; then
2317 	AC_DEFINE(USE_STRING_HACKS,1,[Define to 1 to work around bogus compiler/loader warnings])
2318	AC_MSG_WARN(enabling string-hacks to work around bogus compiler/loader warnings)
2319	AC_CHECK_FUNC(strlcat,[
2320		AC_DEFINE(HAVE_STRLCAT,1,[Define to 1 if we have strlcat function])
2321		],[
2322		AC_CHECK_LIB(bsd,strlcat,[
2323			CF_ADD_LIB(bsd)
2324			AC_CHECK_HEADERS(bsd/string.h)
2325			AC_DEFINE(HAVE_STRLCAT,1,[Define to 1 if we have strlcat function])
2326			])
2327		])
2328	AC_CHECK_FUNCS( strlcpy snprintf )
2329fi
2330])dnl
2331dnl ---------------------------------------------------------------------------
2332dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
2333dnl ------------------
2334dnl Configure-option to enable gcc warnings
2335dnl
2336dnl $1 = extra options to add, if supported
2337dnl $2 = option for checking attributes.  By default, this is done when
2338dnl      warnings are enabled.  For other values:
2339dnl      yes: always do this, e.g., to use in generated library-headers
2340dnl      no: never do this
2341AC_DEFUN([CF_ENABLE_WARNINGS],[
2342if test "$GCC" = yes || test "$GXX" = yes
2343then
2344CF_FIX_WARNINGS(CFLAGS)
2345CF_FIX_WARNINGS(CPPFLAGS)
2346CF_FIX_WARNINGS(LDFLAGS)
2347AC_MSG_CHECKING(if you want to turn on gcc warnings)
2348CF_ARG_ENABLE(warnings,
2349	[  --enable-warnings       test: turn on gcc compiler warnings],
2350	[enable_warnings=yes],
2351	[enable_warnings=no])
2352AC_MSG_RESULT($enable_warnings)
2353if test "$enable_warnings" = "yes"
2354then
2355	ifelse($2,,[CF_GCC_ATTRIBUTES])
2356	CF_GCC_WARNINGS($1)
2357fi
2358ifelse($2,yes,[CF_GCC_ATTRIBUTES])
2359fi
2360])dnl
2361dnl ---------------------------------------------------------------------------
2362dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
2363dnl --------
2364dnl Check if 'errno' is declared in <errno.h>
2365AC_DEFUN([CF_ERRNO],
2366[
2367CF_CHECK_ERRNO(errno)
2368])dnl
2369dnl ---------------------------------------------------------------------------
2370dnl CF_ETIP_DEFINES version: 8 updated: 2025/12/24 12:27:29
2371dnl ---------------
2372dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
2373dnl math.h and builtin.h, only for ncurses
2374AC_DEFUN([CF_ETIP_DEFINES],
2375[
2376AC_MSG_CHECKING(for special defines needed for etip.h)
2377cf_save_CXXFLAGS="$CXXFLAGS"
2378cf_result="none"
2379
2380# etip.h includes ncurses.h which includes ncurses_dll.h
2381# But ncurses_dll.h is generated - fix here.
2382test -d include || mkdir include
2383test -f include/ncurses_dll.h || sed -e 's/@NCURSES_WRAP_PREFIX@/'$NCURSES_WRAP_PREFIX'/g' "${srcdir}/include/ncurses_dll.h.in" >include/ncurses_dll.h
2384
2385for cf_math in "" MATH_H
2386do
2387for cf_excp in "" MATH_EXCEPTION
2388do
2389	CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -Iinclude -I${srcdir}/include"
2390	test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
2391	test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
2392AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
2393#include <etip.h.in>
2394],[])],[
2395	test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
2396	test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
2397	cf_result="$cf_math $cf_excp"
2398	break 2
2399],[])
2400done
2401done
2402AC_MSG_RESULT([${cf_result:-(none)}])
2403CXXFLAGS="$cf_save_CXXFLAGS"
2404])
2405dnl ---------------------------------------------------------------------------
2406dnl CF_FIND_LINKAGE version: 23 updated: 2025/12/22 04:16:14
2407dnl ---------------
2408dnl Find a library (specifically the linkage used in the code fragment),
2409dnl searching for it if it is not already in the library path.
2410dnl See also CF_ADD_SEARCHPATH.
2411dnl
2412dnl Parameters (4-on are optional):
2413dnl     $1 = headers for library entrypoint
2414dnl     $2 = code fragment for library entrypoint
2415dnl     $3 = the library name without the "-l" option or ".so" suffix.
2416dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
2417dnl     $5 = action to perform if not successful
2418dnl     $6 = module name, if not the same as the library name
2419dnl     $7 = extra libraries
2420dnl
2421dnl Sets these variables:
2422dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
2423dnl     $cf_cv_header_path_$3 - include-directory if needed
2424dnl     $cf_cv_library_path_$3 - library-directory if needed
2425dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
2426AC_DEFUN([CF_FIND_LINKAGE],[
2427
2428# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
2429# will be set on completion of the AC_LINK_IFELSE below.
2430cf_cv_header_path_$3=
2431cf_cv_library_path_$3=
2432
2433CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
2434
2435cf_save_LIBS="$LIBS"
2436
2437AC_LINK_IFELSE([AC_LANG_PROGRAM([$1],[$2])],[
2438	cf_cv_find_linkage_$3=yes
2439	cf_cv_header_path_$3=/usr/include
2440	cf_cv_library_path_$3=/usr/lib
2441],[
2442
2443LIBS="-l$3 $7 $cf_save_LIBS"
2444
2445AC_LINK_IFELSE([AC_LANG_PROGRAM([$1],[$2])],[
2446	cf_cv_find_linkage_$3=yes
2447	cf_cv_header_path_$3=/usr/include
2448	cf_cv_library_path_$3=/usr/lib
2449	cf_cv_library_file_$3="-l$3"
2450],[
2451	cf_cv_find_linkage_$3=no
2452	LIBS="$cf_save_LIBS"
2453
2454	CF_VERBOSE(find linkage for $3 library)
2455	CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
2456
2457	cf_save_CPPFLAGS="$CPPFLAGS"
2458	cf_test_CPPFLAGS="$CPPFLAGS"
2459
2460	CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
2461	for cf_cv_header_path_$3 in $cf_search
2462	do
2463		if test -d "$cf_cv_header_path_$3" ; then
2464			CF_VERBOSE(... testing $cf_cv_header_path_$3)
2465			CPPFLAGS="$cf_save_CPPFLAGS"
2466			CF_APPEND_TEXT(CPPFLAGS,-I$cf_cv_header_path_$3)
2467			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$1],[$2])],[
2468				CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
2469				cf_cv_find_linkage_$3=maybe
2470				cf_test_CPPFLAGS="$CPPFLAGS"
2471				break],[
2472				CPPFLAGS="$cf_save_CPPFLAGS"
2473				])
2474		fi
2475	done
2476
2477	if test "$cf_cv_find_linkage_$3" = maybe ; then
2478
2479		CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
2480
2481		cf_save_LIBS="$LIBS"
2482		cf_save_LDFLAGS="$LDFLAGS"
2483
2484		ifelse([$6],,,[
2485		CPPFLAGS="$cf_test_CPPFLAGS"
2486		LIBS="-l$3 $7 $cf_save_LIBS"
2487		AC_LINK_IFELSE([AC_LANG_PROGRAM([$1],[$2])],[
2488			CF_VERBOSE(... found $3 library in system)
2489			cf_cv_find_linkage_$3=yes])
2490			CPPFLAGS="$cf_save_CPPFLAGS"
2491			LIBS="$cf_save_LIBS"
2492			])
2493
2494		if test "$cf_cv_find_linkage_$3" != yes ; then
2495			CF_LIBRARY_PATH(cf_search,$3)
2496			for cf_cv_library_path_$3 in $cf_search
2497			do
2498				if test -d "$cf_cv_library_path_$3" ; then
2499					CF_VERBOSE(... testing $cf_cv_library_path_$3)
2500					CPPFLAGS="$cf_test_CPPFLAGS"
2501					LIBS="-l$3 $7 $cf_save_LIBS"
2502					LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
2503					AC_LINK_IFELSE([AC_LANG_PROGRAM([$1],[$2])],[
2504					CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
2505					cf_cv_find_linkage_$3=yes
2506					cf_cv_library_file_$3="-l$3"
2507					break],[
2508					CPPFLAGS="$cf_save_CPPFLAGS"
2509					LIBS="$cf_save_LIBS"
2510					LDFLAGS="$cf_save_LDFLAGS"
2511					])
2512				fi
2513			done
2514			CPPFLAGS="$cf_save_CPPFLAGS"
2515			LDFLAGS="$cf_save_LDFLAGS"
2516		fi
2517
2518	else
2519		cf_cv_find_linkage_$3=no
2520	fi
2521	],$7)
2522])
2523
2524LIBS="$cf_save_LIBS"
2525
2526if test "$cf_cv_find_linkage_$3" = yes ; then
2527ifelse([$4],,[
2528	CF_ADD_INCDIR($cf_cv_header_path_$3)
2529	CF_ADD_LIBDIR($cf_cv_library_path_$3)
2530	CF_ADD_LIB($3)
2531],[$4])
2532else
2533ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
2534fi
2535])dnl
2536dnl ---------------------------------------------------------------------------
2537dnl CF_FIND_SUB_INCDIR version: 3 updated: 2021/01/01 13:31:04
2538dnl ------------------
2539dnl Find an include-directory with the given leaf-name.  This is useful for
2540dnl example with FreeBSD ports, which use this convention to distinguish
2541dnl different versions of the same port.
2542AC_DEFUN([CF_FIND_SUB_INCDIR],[
2543	CF_SUBDIR_PATH(cf_search,$1,include)
2544	for cf_item in $cf_search
2545	do
2546		case "$cf_item" in
2547		(*/$1)
2548			CF_ADD_INCDIR($cf_item)
2549			;;
2550		esac
2551	done
2552])dnl
2553dnl ---------------------------------------------------------------------------
2554dnl CF_FIND_SUB_LIBDIR version: 3 updated: 2021/01/01 13:31:04
2555dnl ------------------
2556dnl Find a library-directory with the given leaf-name.  This is useful for
2557dnl example with FreeBSD ports, which use this convention to distinguish
2558dnl different versions of the same port.
2559AC_DEFUN([CF_FIND_SUB_LIBDIR],[
2560	CF_SUBDIR_PATH(cf_search,$1,lib)
2561	for cf_item in $cf_search
2562	do
2563		case "$cf_item" in
2564		(*/$1)
2565			CF_ADD_LIBDIR($cf_item)
2566			;;
2567		esac
2568	done
2569])dnl
2570dnl ---------------------------------------------------------------------------
2571dnl CF_FIXUP_ADAFLAGS version: 2 updated: 2015/04/17 21:13:04
2572dnl -----------------
2573dnl make ADAFLAGS consistent with CFLAGS
2574AC_DEFUN([CF_FIXUP_ADAFLAGS],[
2575	AC_MSG_CHECKING(optimization options for ADAFLAGS)
2576	case "$CFLAGS" in
2577	(*-g*)
2578		CF_ADD_ADAFLAGS(-g)
2579		;;
2580	esac
2581	case "$CFLAGS" in
2582	(*-O*)
2583		cf_O_flag=`echo "$CFLAGS" |sed -e 's/^.*-O/-O/' -e 's/[[ 	]].*//'`
2584		CF_ADD_ADAFLAGS($cf_O_flag)
2585		;;
2586	esac
2587	AC_MSG_RESULT($ADAFLAGS)
2588])dnl
2589dnl ---------------------------------------------------------------------------
2590dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31
2591dnl ---------------
2592dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
2593dnl "-Werror" flags can interfere with configure-checks.  Those go into
2594dnl EXTRA_CFLAGS.
2595dnl
2596dnl $1 = variable name to repair
2597define([CF_FIX_WARNINGS],[
2598if test "$GCC" = yes || test "$GXX" = yes
2599then
2600	case [$]$1 in
2601	(*-Werror=*)
2602		cf_temp_flags=
2603		for cf_temp_scan in [$]$1
2604		do
2605			case "x$cf_temp_scan" in
2606			(x-Werror=format*)
2607				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
2608				;;
2609			(x-Werror=*)
2610				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
2611				;;
2612			(*)
2613				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
2614				;;
2615			esac
2616		done
2617		if test "x[$]$1" != "x$cf_temp_flags"
2618		then
2619			CF_VERBOSE(repairing $1: [$]$1)
2620			$1="$cf_temp_flags"
2621			CF_VERBOSE(... fixed [$]$1)
2622			CF_VERBOSE(... extra $EXTRA_CFLAGS)
2623		fi
2624		;;
2625	esac
2626fi
2627AC_SUBST(EXTRA_CFLAGS)
2628])dnl
2629dnl ---------------------------------------------------------------------------
2630dnl CF_FOPEN_BIN_R version: 4 updated: 2024/12/14 16:09:34
2631dnl --------------
2632dnl Check if fopen works when the "b" (binary) flag is added to the mode
2633dnl parameter.  POSIX ignores the "b", which c89 specified.  Some very old
2634dnl systems do not accept it.
2635AC_DEFUN([CF_FOPEN_BIN_R],[
2636AC_CACHE_CHECK(if fopen accepts explicit binary mode,cf_cv_fopen_bin_r,[
2637	AC_TRY_RUN([
2638$ac_includes_default
2639
2640int main(void)
2641{
2642	FILE *fp = fopen("conftest.tmp", "wb");
2643	int rc = 0;
2644	if (fp != NULL) {
2645		int p, q;
2646		for (p = 0; p < 256; ++p) {
2647			fputc(p, fp);
2648		}
2649		fclose(fp);
2650		fp = fopen("conftest.tmp", "rb");
2651		if (fp != NULL) {
2652			for (p = 0; p < 256; ++p) {
2653				q = fgetc(fp);
2654				if (q != p) {
2655					rc = 1;
2656					break;
2657				}
2658			}
2659		} else {
2660			rc = 1;
2661		}
2662	} else {
2663		rc = 1;
2664	}
2665	${cf_cv_main_return:-return} (rc);
2666}
2667],
2668		[cf_cv_fopen_bin_r=yes],
2669		[cf_cv_fopen_bin_r=no],
2670		[cf_cv_fopen_bin_r=unknown])
2671])
2672test "x$cf_cv_fopen_bin_r" != xno && AC_DEFINE(USE_FOPEN_BIN_R,1,[Define to 1 if fopen accepts explicit binary mode])
2673])dnl
2674dnl ---------------------------------------------------------------------------
2675dnl CF_FORGET_TOOL version: 1 updated: 2013/04/06 18:03:09
2676dnl --------------
2677dnl Forget that we saw the given tool.
2678AC_DEFUN([CF_FORGET_TOOL],[
2679unset ac_cv_prog_ac_ct_$1
2680unset ac_ct_$1
2681unset $1
2682])dnl
2683dnl ---------------------------------------------------------------------------
2684dnl CF_FUNC_DLSYM version: 6 updated: 2025/12/24 12:27:29
2685dnl -------------
2686dnl Test for dlsym() and related functions, as well as libdl.
2687dnl
2688dnl Sets
2689dnl	$cf_have_dlsym
2690dnl	$cf_have_libdl
2691AC_DEFUN([CF_FUNC_DLSYM],[
2692cf_have_dlsym=no
2693AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
2694
2695cf_have_libdl=no
2696AC_CHECK_LIB(dl,dlsym,[
2697	cf_have_dlsym=yes
2698	cf_have_libdl=yes])])
2699
2700if test "$cf_have_dlsym" = yes ; then
2701	test "$cf_have_libdl" = yes && { CF_ADD_LIB(dl) }
2702
2703	AC_MSG_CHECKING(whether able to link to dl*() functions)
2704	AC_LINK_IFELSE([AC_LANG_PROGRAM([
2705	#include <stdio.h>
2706	#include <dlfcn.h>
2707	],[
2708		void *obj;
2709		if ((obj = dlopen("filename", 0)) != NULL) {
2710			if (dlsym(obj, "symbolname") == 0) {
2711			dlclose(obj);
2712			}
2713		}])],[
2714		AC_DEFINE(HAVE_LIBDL,1,[Define to 1 if we have dl library])],[
2715		AC_MSG_ERROR(Cannot link test program for libdl)])
2716	AC_MSG_RESULT(ok)
2717else
2718	AC_MSG_ERROR(Cannot find dlsym function)
2719fi
2720])
2721dnl ---------------------------------------------------------------------------
2722dnl CF_FUNC_GETTIME version: 4 updated: 2025/12/23 18:53:34
2723dnl ---------------
2724dnl Check for gettimeofday or clock_gettime.  In 2023, the former is still more
2725dnl widely supported, but "deprecated" (2008), so we will use the latter if it
2726dnl is available, to reduce compiler warnings.
2727AC_DEFUN([CF_FUNC_GETTIME],[
2728cf_save_libs="$LIBS"
2729AC_CHECK_FUNC(clock_gettime,
2730	cf_cv_test_clock_gettime=yes,
2731	AC_CHECK_LIB(rt, clock_gettime,
2732		[LIBS="-lrt $LIBS"
2733		 cf_cv_test_clock_gettime=yes],
2734		 cf_cv_test_clock_gettime=no))
2735
2736if test "$cf_cv_test_clock_gettime" = yes ; then
2737AC_CACHE_CHECK(if clock_gettime links,cf_cv_func_clock_gettime,[
2738		AC_LINK_IFELSE([AC_LANG_PROGRAM([
2739$ac_includes_default
2740#include <time.h>
2741		],
2742		[struct timespec ts;
2743		int rc = clock_gettime(CLOCK_REALTIME, &ts)
2744			   + clock_gettime(CLOCK_MONOTONIC, &ts);
2745		 (void) rc; (void)ts])],
2746		[cf_cv_func_clock_gettime=yes],
2747		[cf_cv_func_clock_gettime=no])
2748])
2749else
2750	cf_cv_func_clock_gettime=no
2751fi
2752
2753if test "$cf_cv_func_clock_gettime" = yes
2754then
2755	AC_DEFINE(HAVE_CLOCK_GETTIME,1,[Define to 1 if we have clock_gettime function])
2756else
2757AC_CHECK_FUNC(gettimeofday,
2758	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function]),[
2759
2760AC_CHECK_LIB(bsd, gettimeofday,
2761	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function])
2762	CF_ADD_LIB(bsd))])dnl CLIX: bzero, select, gettimeofday
2763fi
2764])dnl
2765dnl ---------------------------------------------------------------------------
2766dnl CF_FUNC_GETTTYNAM version: 5 updated: 2025/12/24 12:27:29
2767dnl -----------------
2768dnl Check if the 4.3BSD function getttyname exists, as well as if <ttyent.h>
2769dnl defines the _PATH_TTYS symbol.  If the corresponding file exists, but the
2770dnl other checks fail, just define HAVE_PATH_TTYS.
2771AC_DEFUN([CF_FUNC_GETTTYNAM],[
2772AC_CACHE_CHECK(if _PATH_TTYS is defined in ttyent.h,cf_cv_PATH_TTYS,[
2773AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
2774#include <stdio.h>
2775#include <ttyent.h>],[
2776FILE *fp = fopen(_PATH_TTYS, "r"); (void)fp])],
2777	[cf_cv_PATH_TTYS=yes],
2778	[cf_cv_PATH_TTYS=no])])
2779
2780if test $cf_cv_PATH_TTYS = no
2781then
2782	for cf_ttys in /etc/ttytype /etc/ttys
2783	do
2784		if test -f $cf_ttys
2785		then
2786			cf_cv_PATH_TTYS=maybe
2787			AC_DEFINE(_PATH_TTYS,$cf_ttys,[define to pathname of file containing mapping from tty name to terminal type])
2788			break
2789		fi
2790	done
2791fi
2792
2793if test $cf_cv_PATH_TTYS != no
2794then
2795	AC_CACHE_CHECK(if _PATH_TTYS file exists,cf_cv_have_PATH_TTYS,[
2796		AC_TRY_RUN([
2797$ac_includes_default
2798#include <ttyent.h>
2799
2800int main(void) {
2801	FILE *fp = fopen(_PATH_TTYS, "r");
2802	${cf_cv_main_return:-return} (fp == NULL);
2803}],
2804			[cf_cv_have_PATH_TTYS=yes],
2805			[cf_cv_have_PATH_TTYS=no],
2806			[cf_cv_have_PATH_TTYS=unknown])])
2807	test "$cf_cv_have_PATH_TTYS" = no && cf_cv_PATH_TTYS=no
2808fi
2809
2810if test $cf_cv_PATH_TTYS != no
2811then
2812	AC_DEFINE(HAVE_PATH_TTYS,1,[define to 1 if system can map tty name to terminal type])
2813	AC_CACHE_CHECK(for getttynam,cf_cv_func_getttynam,[
2814		AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <ttyent.h>],
2815		[struct ttyent *fp = getttynam("/dev/tty"); (void)fp])],
2816		[cf_cv_func_getttynam=yes],
2817		[cf_cv_func_getttynam=no])])
2818	test "$cf_cv_func_getttynam" = yes && AC_DEFINE(HAVE_GETTTYNAM,1,[define to 1 if the system has getttynam()])
2819fi
2820])dnl
2821dnl ---------------------------------------------------------------------------
2822dnl CF_FUNC_MEMMOVE version: 10 updated: 2023/01/05 18:51:28
2823dnl ---------------
2824dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
2825dnl is found, add our own version of memmove to the list of objects.
2826AC_DEFUN([CF_FUNC_MEMMOVE],
2827[
2828AC_CHECK_FUNC(memmove,,[
2829AC_CHECK_FUNC(bcopy,[
2830	AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
2831		AC_TRY_RUN([
2832$ac_includes_default
2833
2834int main(void) {
2835	static char data[] = "abcdefghijklmnopqrstuwwxyz";
2836	char temp[40];
2837	bcopy(data, temp, sizeof(data));
2838	bcopy(temp+10, temp, 15);
2839	bcopy(temp+5, temp+15, 10);
2840	${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
2841}
2842		],
2843		[cf_cv_good_bcopy=yes],
2844		[cf_cv_good_bcopy=no],
2845		[cf_cv_good_bcopy=unknown])
2846		])
2847	],[cf_cv_good_bcopy=no])
2848	if test "$cf_cv_good_bcopy" = yes ; then
2849		AC_DEFINE(USE_OK_BCOPY,1,[Define to 1 to use bcopy when memmove is unavailable])
2850	else
2851		AC_DEFINE(USE_MY_MEMMOVE,1,[Define to 1 to use replacement function when memmove is unavailable])
2852	fi
2853])])dnl
2854dnl ---------------------------------------------------------------------------
2855dnl CF_FUNC_NANOSLEEP version: 6 updated: 2023/01/05 18:51:33
2856dnl -----------------
2857dnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
2858dnl AIX 4.x, provide a non-working version.
2859AC_DEFUN([CF_FUNC_NANOSLEEP],[
2860AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
2861AC_TRY_RUN([
2862$ac_includes_default
2863
2864#include <errno.h>
2865#include <time.h>
2866
2867#ifdef HAVE_SYS_TIME_H
2868#include <sys/time.h>
2869#endif
2870
2871int main(void) {
2872	struct timespec ts1, ts2;
2873	int code;
2874	ts1.tv_sec  = 0;
2875	ts1.tv_nsec = 750000000;
2876	ts2.tv_sec  = 0;
2877	ts2.tv_nsec = 0;
2878	errno = 0;
2879	code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */
2880	${cf_cv_main_return:-return}(code != 0);
2881}
2882],
2883	[cf_cv_func_nanosleep=yes],
2884	[cf_cv_func_nanosleep=no],
2885	[cf_cv_func_nanosleep=unknown])])
2886
2887test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP,1,[Define to 1 if we have nanosleep()])
2888])
2889dnl ---------------------------------------------------------------------------
2890dnl CF_FUNC_OPENPTY version: 8 updated: 2025/12/24 12:27:29
2891dnl ---------------
2892dnl Check for openpty() function, along with <pty.h> header.  It may need the
2893dnl "util" library as well.
2894AC_DEFUN([CF_FUNC_OPENPTY],
2895[
2896AC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
2897AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
2898	cf_save_LIBS="$LIBS"
2899	test "$cf_cv_lib_util" = yes && { CF_ADD_LIB(util) }
2900	for cf_header in pty.h libutil.h util.h
2901	do
2902	AC_LINK_IFELSE([AC_LANG_PROGRAM([
2903#include <$cf_header>
2904],[
2905	int x = openpty((int *)0, (int *)0, (char *)0,
2906				   (struct termios *)0, (struct winsize *)0);
2907	(void)x;
2908])],[
2909		cf_cv_func_openpty=$cf_header
2910		break
2911],[
2912		cf_cv_func_openpty=no
2913])
2914	done
2915	LIBS="$cf_save_LIBS"
2916])
2917])dnl
2918dnl ---------------------------------------------------------------------------
2919dnl CF_FUNC_POLL version: 11 updated: 2023/01/05 18:51:40
2920dnl ------------
2921dnl See if the poll function really works.  Some platforms have poll(), but
2922dnl it does not work for terminals or files.
2923AC_DEFUN([CF_FUNC_POLL],[
2924tty >/dev/null 2>&1 || { AC_CHECK_FUNCS(posix_openpt) }
2925AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
2926AC_TRY_RUN([
2927$ac_includes_default
2928
2929#include <fcntl.h>
2930
2931#ifdef HAVE_POLL_H
2932#include <poll.h>
2933#else
2934#include <sys/poll.h>
2935#endif
2936
2937int main(void) {
2938	struct pollfd myfds;
2939	int ret;
2940
2941	/* check for Darwin bug with respect to "devices" */
2942	myfds.fd = open("/dev/null", 1);	/* O_WRONLY */
2943	if (myfds.fd < 0)
2944		myfds.fd = 0;
2945	myfds.events = POLLIN;
2946	myfds.revents = 0;
2947
2948	ret = poll(&myfds, 1, 100);
2949
2950	if (ret < 0 || (myfds.revents & POLLNVAL)) {
2951		ret = -1;
2952	} else {
2953		int fd = 0;
2954		if (!isatty(fd)) {
2955			fd = open("/dev/tty", 2);	/* O_RDWR */
2956		}
2957#ifdef HAVE_POSIX_OPENPT
2958		if (fd < 0) {
2959			fd = posix_openpt(O_RDWR);
2960		}
2961#endif
2962
2963		if (fd >= 0) {
2964			/* also check with standard input */
2965			myfds.fd = fd;
2966			myfds.events = POLLIN;
2967			myfds.revents = 0;
2968			ret = poll(&myfds, 1, 100);
2969		} else {
2970			ret = -1;
2971		}
2972	}
2973	${cf_cv_main_return:-return}(ret < 0);
2974}],
2975	[cf_cv_working_poll=yes],
2976	[cf_cv_working_poll=no],
2977	[cf_cv_working_poll=unknown])])
2978test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL,1,[Define to 1 if the poll function seems to work])
2979])dnl
2980dnl ---------------------------------------------------------------------------
2981dnl CF_FUNC_TERMIOS version: 4 updated: 2025/12/24 12:27:29
2982dnl ---------------
2983dnl Some old/broken variations define tcgetattr() only as a macro in
2984dnl termio(s).h
2985AC_DEFUN([CF_FUNC_TERMIOS],[
2986AC_REQUIRE([CF_STRUCT_TERMIOS])
2987AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
2988AC_LINK_IFELSE([AC_LANG_PROGRAM([
2989#include <sys/types.h>
2990#ifdef HAVE_UNISTD_H
2991#include <unistd.h>
2992#endif
2993#ifdef HAVE_TERMIOS_H
2994#include <termios.h>
2995#define TTY struct termios
2996#else
2997#ifdef HAVE_TERMIO_H
2998#include <termio.h>
2999#define TTY struct termio
3000#endif
3001#endif
3002],[
3003TTY foo;
3004tcgetattr(1, &foo);])],
3005[cf_cv_have_tcgetattr=yes],
3006[cf_cv_have_tcgetattr=no])])
3007test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR,1,[Define to 1 if we have tcgetattr])
3008])dnl
3009dnl ---------------------------------------------------------------------------
3010dnl CF_FUNC_VSSCANF version: 9 updated: 2025/12/24 12:27:29
3011dnl ---------------
3012dnl Check for vsscanf() function, which is in c9x but generally not in earlier
3013dnl versions of C.  It can often be simulated by other functions on older
3014dnl systems (where FILE is not opaque).
3015AC_DEFUN([CF_FUNC_VSSCANF],
3016[
3017AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
3018AC_LINK_IFELSE([AC_LANG_PROGRAM([
3019#include <stdarg.h>
3020#include <stdio.h>
3021
3022static void
3023myfunc(const char *str, const char *fmt, ...)
3024{
3025	va_list ap;
3026	va_start(ap, fmt);
3027	vsscanf(str, fmt, ap);
3028	va_end(ap);
3029}
3030],[
3031	myfunc("55", "%d");
3032])],[cf_cv_func_vsscanf=vsscanf],[
3033AC_LINK_IFELSE([AC_LANG_PROGRAM([
3034#include <stdarg.h>
3035#include <stdio.h>],[
3036	FILE strbuf;
3037	char *str = "from";
3038
3039	strbuf._flag = _IOREAD;
3040	strbuf._ptr = strbuf._base = (unsigned char *) str;
3041	strbuf._cnt = strlen(str);
3042	strbuf._file = _NFILE;
3043	return (vfscanf(&strbuf, "%d", ap))])],[cf_cv_func_vsscanf=vfscanf],[
3044AC_LINK_IFELSE([AC_LANG_PROGRAM([
3045#include <stdarg.h>
3046#include <stdio.h>],[
3047	FILE strbuf;
3048	char *str = "from";
3049
3050	strbuf._flag = _IOREAD;
3051	strbuf._ptr = strbuf._base = (unsigned char *) str;
3052	strbuf._cnt = strlen(str);
3053	strbuf._file = _NFILE;
3054	return (_doscan(&strbuf, "%d", ap))])],[cf_cv_func_vsscanf=_doscan],[
3055cf_cv_func_vsscanf=no])])])])
3056
3057case "$cf_cv_func_vsscanf" in
3058(vsscanf) AC_DEFINE(HAVE_VSSCANF,1,[Define to 1 if we have vsscanf]);;
3059(vfscanf) AC_DEFINE(HAVE_VFSCANF,1,[Define to 1 if we have vfscanf]);;
3060(_doscan) AC_DEFINE(HAVE__DOSCAN,1,[Define to 1 if we have _doscan]);;
3061esac
3062
3063])dnl
3064dnl ---------------------------------------------------------------------------
3065dnl CF_GCC_ATTRIBUTES version: 28 updated: 2025/12/25 18:43:31
3066dnl -----------------
3067dnl Test for availability of useful gcc __attribute__ directives to quiet
3068dnl compiler warnings.  Though useful, not all are supported -- and contrary
3069dnl to documentation, unrecognized directives cause older compilers to barf.
3070AC_DEFUN([CF_GCC_ATTRIBUTES],
3071[AC_REQUIRE([AC_PROG_FGREP])dnl
3072AC_REQUIRE([CF_C11_NORETURN])dnl
3073
3074if test "$GCC" = yes || test "$GXX" = yes
3075then
3076cat > conftest.i <<EOF
3077#ifndef GCC_PRINTF
3078#define GCC_PRINTF 0
3079#endif
3080#ifndef GCC_SCANF
3081#define GCC_SCANF 0
3082#endif
3083#ifndef GCC_NORETURN
3084#define GCC_NORETURN /* nothing */
3085#endif
3086#ifndef GCC_UNUSED
3087#define GCC_UNUSED /* nothing */
3088#endif
3089EOF
3090if test "$GCC" = yes
3091then
3092	AC_MSG_CHECKING([for $CC __attribute__ directives])
3093	test -n "$verbose" && AC_MSG_RESULT()
3094cat > "conftest.$ac_ext" <<EOF
3095#line __oline__ "${as_me:-configure}"
3096#include <stdio.h>
3097#include "confdefs.h"
3098#include "conftest.h"
3099#include "conftest.i"
3100#if	GCC_PRINTF
3101#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
3102#else
3103#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
3104#endif
3105#if	GCC_SCANF
3106#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
3107#else
3108#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
3109#endif
3110extern void wow(char *,...) GCC_SCANFLIKE(1,2);
3111extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
3112extern GCC_NORETURN void foo(void);
3113int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
3114EOF
3115	cf_printf_attribute=no
3116	cf_scanf_attribute=no
3117	for cf_attribute in scanf printf unused noreturn
3118	do
3119		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
3120		cf_directive="__attribute__(($cf_attribute))"
3121		echo "checking for $CC $cf_directive" 1>&AS_MESSAGE_LOG_FD
3122
3123		case "$cf_attribute" in
3124		(printf)
3125			cf_printf_attribute=yes
3126			cat >conftest.h <<EOF
3127#define GCC_$cf_ATTRIBUTE 1
3128EOF
3129			;;
3130		(scanf)
3131			cf_scanf_attribute=yes
3132			cat >conftest.h <<EOF
3133#define GCC_$cf_ATTRIBUTE 1
3134EOF
3135			;;
3136		(*)
3137			cat >conftest.h <<EOF
3138#define GCC_$cf_ATTRIBUTE $cf_directive
3139EOF
3140			;;
3141		esac
3142
3143		if AC_TRY_EVAL(ac_compile); then
3144			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
3145			cat conftest.h >>confdefs.h
3146			case "$cf_attribute" in
3147			(noreturn)
3148				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
3149				;;
3150			(printf)
3151				cf_value='/* nothing */'
3152				if test "$cf_printf_attribute" != no ; then
3153					cf_value='__attribute__((format(printf,fmt,var)))'
3154					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
3155				fi
3156				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
3157				;;
3158			(scanf)
3159				cf_value='/* nothing */'
3160				if test "$cf_scanf_attribute" != no ; then
3161					cf_value='__attribute__((format(scanf,fmt,var)))'
3162					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
3163				fi
3164				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
3165				;;
3166			(unused)
3167				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
3168				;;
3169			esac
3170		fi
3171	done
3172else
3173	${FGREP-fgrep} define conftest.i >>confdefs.h
3174fi
3175rm -rf ./conftest*
3176fi
3177])dnl
3178dnl ---------------------------------------------------------------------------
3179dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
3180dnl --------------
3181dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
3182dnl compatible), attempt to determine if icc/clang is actually used.
3183AC_DEFUN([CF_GCC_VERSION],[
3184AC_REQUIRE([AC_PROG_CC])
3185GCC_VERSION=none
3186if test "$GCC" = yes ; then
3187	AC_MSG_CHECKING(version of $CC)
3188	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
3189	test -z "$GCC_VERSION" && GCC_VERSION=unknown
3190	AC_MSG_RESULT($GCC_VERSION)
3191fi
3192CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
3193CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
3194])dnl
3195dnl ---------------------------------------------------------------------------
3196dnl CF_GCC_WARNINGS version: 45 updated: 2025/12/24 09:07:25
3197dnl ---------------
3198dnl Check if the compiler supports useful warning options.  There's a few that
3199dnl we don't use, simply because they're too noisy:
3200dnl
3201dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
3202dnl	-Winline (usually not worthwhile)
3203dnl	-Wredundant-decls (system headers make this too noisy)
3204dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
3205dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
3206dnl		is enabled for ncurses using "--enable-const".
3207dnl	-pedantic
3208dnl
3209dnl Parameter:
3210dnl	$1 is an optional list of gcc warning flags that a particular
3211dnl		application might want to use, e.g., "no-unused" for
3212dnl		-Wno-unused
3213dnl Special:
3214dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
3215dnl
3216AC_DEFUN([CF_GCC_WARNINGS],
3217[
3218AC_REQUIRE([CF_GCC_VERSION])
3219if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
3220cat > "conftest.$ac_ext" <<EOF
3221#line __oline__ "${as_me:-configure}"
3222int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
3223EOF
3224if test "$INTEL_COMPILER" = yes
3225then
3226# The "-wdXXX" options suppress warnings:
3227# remark #1419: external declaration in primary source file
3228# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
3229# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
3230# remark #193: zero used for undefined preprocessing identifier
3231# remark #593: variable "curs_sb_left_arrow" was set but never used
3232# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
3233# remark #869: parameter "tw" was never referenced
3234# remark #981: operands are evaluated in unspecified order
3235# warning #279: controlling expression is constant
3236
3237	AC_MSG_CHECKING([for $CC warning options])
3238	test -n "$verbose" && AC_MSG_RESULT()
3239	cf_save_CFLAGS="$CFLAGS"
3240	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
3241	for cf_opt in \
3242		wd1419 \
3243		wd1683 \
3244		wd1684 \
3245		wd193 \
3246		wd593 \
3247		wd279 \
3248		wd810 \
3249		wd869 \
3250		wd981
3251	do
3252		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
3253		if AC_TRY_EVAL(ac_compile); then
3254			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3255			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
3256		fi
3257	done
3258	CFLAGS="$cf_save_CFLAGS"
3259elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
3260then
3261	AC_MSG_CHECKING([for $CC warning options])
3262	test -n "$verbose" && AC_MSG_RESULT()
3263	cf_save_CFLAGS="$CFLAGS"
3264	cf_warn_CONST=""
3265	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
3266	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
3267	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
3268	for cf_opt in W Wall \
3269		Wbad-function-cast \
3270		Wcast-align \
3271		Wcast-qual \
3272		Wdeclaration-after-statement \
3273		Wextra \
3274		Winline \
3275		Wmissing-declarations \
3276		Wmissing-prototypes \
3277		Wnested-externs \
3278		Wpointer-arith \
3279		Wshadow \
3280		Wstrict-prototypes \
3281		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
3282	do
3283		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
3284		if AC_TRY_EVAL(ac_compile); then
3285			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3286			case "$cf_opt" in
3287			(Winline)
3288				case "$GCC_VERSION" in
3289				([[34]].*)
3290					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
3291					continue;;
3292				esac
3293				;;
3294			(Wpointer-arith)
3295				case "$GCC_VERSION" in
3296				([[12]].*)
3297					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
3298					continue;;
3299				esac
3300				;;
3301			esac
3302			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
3303		fi
3304	done
3305	CFLAGS="$cf_save_CFLAGS"
3306fi
3307rm -rf ./conftest*
3308
3309AC_SUBST(EXTRA_CFLAGS)
3310])dnl
3311dnl ---------------------------------------------------------------------------
3312dnl CF_GETOPT_HEADER version: 10 updated: 2025/12/14 17:40:20
3313dnl ----------------
3314dnl Check for getopt's variables which are commonly defined in stdlib.h,
3315dnl unistd.h or (nonstandard) in getopt.h
3316AC_DEFUN([CF_GETOPT_HEADER],
3317[AC_REQUIRE([AC_HEADER_STDC])
3318
3319AC_CHECK_HEADERS(getopt.h)
3320AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
3321cf_cv_getopt_header=none
3322for cf_header in stdio.h stdlib.h unistd.h getopt.h
3323do
3324AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
3325#include <$cf_header>],
3326[int x = optind; char *y = optarg; (void)x; (void)y])],
3327[cf_cv_getopt_header=$cf_header
3328 break])
3329done
3330])
3331if test "$cf_cv_getopt_header" != none ; then
3332	AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
3333fi
3334if test "$cf_cv_getopt_header" = getopt.h ; then
3335	AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
3336fi
3337])dnl
3338dnl ---------------------------------------------------------------------------
3339dnl CF_GLOB_FULLPATH version: 2 updated: 2024/08/03 12:34:02
3340dnl ----------------
3341dnl Use this in case-statements to check for pathname syntax, i.e., absolute
3342dnl pathnames.  The "x" is assumed since we provide an alternate form for DOS.
3343AC_DEFUN([CF_GLOB_FULLPATH],[
3344AC_REQUIRE([CF_WITH_SYSTYPE])dnl
3345case "$cf_cv_system_name" in
3346(cygwin*|msys*|mingw32*|mingw64|os2*)
3347	GLOB_FULLPATH_POSIX='/*'
3348	GLOB_FULLPATH_OTHER='[[a-zA-Z]]:[[\\/]]*'
3349	;;
3350(*)
3351	GLOB_FULLPATH_POSIX='/*'
3352	GLOB_FULLPATH_OTHER=$GLOB_FULLPATH_POSIX
3353	;;
3354esac
3355AC_SUBST(GLOB_FULLPATH_POSIX)
3356AC_SUBST(GLOB_FULLPATH_OTHER)
3357])dnl
3358dnl ---------------------------------------------------------------------------
3359dnl CF_GNATPREP_OPT_T version: 1 updated: 2014/08/02 18:37:25
3360dnl -----------------
3361AC_DEFUN([CF_GNATPREP_OPT_T],[
3362AC_CACHE_CHECK(if GNATPREP supports -T option,cf_cv_gnatprep_opt_t,[
3363cf_cv_gnatprep_opt_t=no
3364gnatprep -T 2>/dev/null >/dev/null && cf_cv_gnatprep_opt_t=yes
3365])
3366test "$cf_cv_gnatprep_opt_t" = yes && GNATPREP_OPTS="-T $GNATPREP_OPTS"
3367AC_SUBST(GNATPREP_OPTS)
3368])dnl
3369dnl ---------------------------------------------------------------------------
3370dnl CF_GNAT_GENERICS version: 7 updated: 2021/01/01 13:31:04
3371dnl ----------------
3372AC_DEFUN([CF_GNAT_GENERICS],
3373[
3374AC_REQUIRE([CF_GNAT_VERSION])
3375
3376AC_MSG_CHECKING(if GNAT supports generics)
3377case "$cf_cv_gnat_version" in
3378(3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*|[[1-9]][[0-9]].[[0-9]]*|20[[0-9]][[0-9]])
3379	cf_gnat_generics=yes
3380	;;
3381(*)
3382	cf_gnat_generics=no
3383	;;
3384esac
3385AC_MSG_RESULT($cf_gnat_generics)
3386
3387if test "$cf_gnat_generics" = yes
3388then
3389	cf_compile_generics=generics
3390	cf_generic_objects="\${GENOBJS}"
3391else
3392	cf_compile_generics=
3393	cf_generic_objects=
3394fi
3395
3396AC_SUBST(cf_compile_generics)
3397AC_SUBST(cf_generic_objects)
3398])dnl
3399dnl ---------------------------------------------------------------------------
3400dnl CF_GNAT_PROJECTS version: 14 updated: 2025/12/24 12:27:29
3401dnl ----------------
3402dnl GNAT projects are configured with ".gpr" project files.
3403dnl GNAT libraries are a further development, using the project feature.
3404AC_DEFUN([CF_GNAT_PROJECTS],
3405[
3406AC_REQUIRE([CF_GNAT_VERSION])
3407AC_REQUIRE([CF_DISABLE_GNAT_PROJECTS])
3408
3409cf_gnat_libraries=no
3410cf_gnat_projects=no
3411
3412if test "$enable_gnat_projects" != no ; then
3413AC_MSG_CHECKING(if GNAT supports project files)
3414case "$cf_cv_gnat_version" in
3415(3.[[0-9]]*)
3416	;;
3417(*)
3418	case "$cf_cv_system_name" in
3419	(cygwin*|msys*)
3420		;;
3421	(*)
3422		rm -rf ./conftest* ./*~conftest*
3423		if mkdir conftest.src conftest.bin conftest.lib
3424		then
3425			cd conftest.src
3426			rm -rf ./conftest* ./*~conftest*
3427			cat >>library.gpr <<CF_EOF
3428project Library is
3429  Kind := External ("LIB_KIND");
3430  for Library_Name use "ConfTest";
3431  for Object_Dir use ".";
3432  for Library_ALI_Dir use External("LIBRARY_DIR");
3433  for Library_Version use External ("SONAME");
3434  for Library_Kind use Kind;
3435  for Library_Dir use External("BUILD_DIR");
3436  Source_Dir := External ("SOURCE_DIR");
3437  for Source_Dirs use (Source_Dir);
3438end Library;
3439CF_EOF
3440			cat >>confpackage.ads <<CF_EOF
3441package ConfPackage is
3442   procedure conftest;
3443end ConfPackage;
3444CF_EOF
3445			cat >>confpackage.adb <<CF_EOF
3446with Text_IO;
3447package body ConfPackage is
3448   procedure conftest is
3449   begin
3450      Text_IO.Put ("Hello World");
3451      Text_IO.New_Line;
3452   end conftest;
3453end ConfPackage;
3454CF_EOF
3455			if ( "$cf_ada_make" $ADAFLAGS \
3456					-Plibrary.gpr \
3457					-XBUILD_DIR="`cd ../conftest.bin;pwd`" \
3458					-XLIBRARY_DIR="`cd ../conftest.lib;pwd`" \
3459					-XSOURCE_DIR="`pwd`" \
3460					-XSONAME=libConfTest.so.1 \
3461					-XLIB_KIND=static 1>&AS_MESSAGE_LOG_FD 2>&1 ) ; then
3462				cf_gnat_projects=yes
3463			fi
3464			cd ..
3465		fi
3466		if test -f conftest.lib/confpackage.ali
3467		then
3468			cf_gnat_libraries=yes
3469		fi
3470		rm -rf ./conftest* ./*~conftest*
3471		;;
3472	esac
3473	;;
3474esac
3475AC_MSG_RESULT($cf_gnat_projects)
3476fi # enable_gnat_projects
3477
3478if test "$cf_gnat_projects" = yes
3479then
3480	AC_MSG_CHECKING(if GNAT supports libraries)
3481	AC_MSG_RESULT($cf_gnat_libraries)
3482fi
3483
3484USE_OLD_MAKERULES=""
3485USE_GNAT_PROJECTS="#"
3486USE_GNAT_MAKE_GPR="#"
3487USE_GNAT_GPRBUILD="#"
3488
3489if test "$cf_gnat_projects" = yes
3490then
3491	USE_OLD_MAKERULES="#"
3492	USE_GNAT_PROJECTS=""
3493	if test "$cf_cv_VERSION_GPRBUILD" != no
3494	then
3495		USE_GNAT_GPRBUILD=""
3496	elif test "$cf_cv_VERSION_GNATMAKE" != no
3497	then
3498		USE_GNAT_MAKE_GPR=""
3499	else
3500		AC_MSG_WARN(use old makefile rules since tools are missing)
3501	fi
3502fi
3503
3504if test "$cf_gnat_libraries" = yes
3505then
3506	USE_GNAT_LIBRARIES=""
3507else
3508	USE_GNAT_LIBRARIES="#"
3509fi
3510
3511AC_SUBST(USE_OLD_MAKERULES)
3512AC_SUBST(USE_GNAT_PROJECTS)
3513AC_SUBST(USE_GNAT_LIBRARIES)
3514AC_SUBST(USE_GNAT_MAKE_GPR)
3515AC_SUBST(USE_GNAT_GPRBUILD)
3516])dnl
3517dnl ---------------------------------------------------------------------------
3518dnl CF_GNAT_SIGINT version: 2 updated: 2021/01/01 13:31:04
3519dnl --------------
3520dnl Check if gnat supports SIGINT, and presumably tasking.  For the latter, it
3521dnl is noted that gnat may compile a tasking unit even for configurations which
3522dnl fail at runtime.
3523AC_DEFUN([CF_GNAT_SIGINT],[
3524AC_CACHE_CHECK(if GNAT supports SIGINT,cf_cv_gnat_sigint,[
3525CF_GNAT_TRY_LINK([with Ada.Interrupts.Names;
3526
3527package ConfTest is
3528
3529   pragma Warnings (Off);  --  the next pragma exists since 3.11p
3530   pragma Unreserve_All_Interrupts;
3531   pragma Warnings (On);
3532
3533   protected Process is
3534      procedure Stop;
3535      function Continue return Boolean;
3536      pragma Attach_Handler (Stop, Ada.Interrupts.Names.SIGINT);
3537   private
3538      Done : Boolean := False;
3539   end Process;
3540
3541end ConfTest;],
3542[package body ConfTest is
3543   protected body Process is
3544      procedure Stop is
3545      begin
3546         Done := True;
3547      end Stop;
3548      function Continue return Boolean is
3549      begin
3550         return not Done;
3551      end Continue;
3552   end Process;
3553end ConfTest;],
3554	[cf_cv_gnat_sigint=yes],
3555	[cf_cv_gnat_sigint=no])])
3556
3557if test "$cf_cv_gnat_sigint" = yes ; then
3558	USE_GNAT_SIGINT=""
3559else
3560	USE_GNAT_SIGINT="#"
3561fi
3562AC_SUBST(USE_GNAT_SIGINT)
3563])dnl
3564dnl ---------------------------------------------------------------------------
3565dnl CF_GNAT_TRY_LINK version: 5 updated: 2025/12/24 12:27:29
3566dnl ----------------
3567dnl Verify that a test program compiles/links with GNAT.
3568dnl $cf_ada_make is set to the program that compiles/links
3569dnl $ADAFLAGS may be set to the GNAT flags.
3570dnl
3571dnl $1 is the text of the spec
3572dnl $2 is the text of the body
3573dnl $3 is the shell command to execute if successful
3574dnl $4 is the shell command to execute if not successful
3575AC_DEFUN([CF_GNAT_TRY_LINK],
3576[
3577rm -rf ./conftest* ./*~conftest*
3578cat >>conftest.ads <<CF_EOF
3579$1
3580CF_EOF
3581cat >>conftest.adb <<CF_EOF
3582$2
3583CF_EOF
3584if ( "$cf_ada_make" $ADAFLAGS conftest 1>&AS_MESSAGE_LOG_FD 2>&1 ) ; then
3585ifelse($3,,      :,[      $3])
3586ifelse($4,,,[else
3587   $4])
3588fi
3589rm -rf ./conftest* ./*~conftest*
3590])dnl
3591dnl ---------------------------------------------------------------------------
3592dnl CF_GNAT_TRY_RUN version: 7 updated: 2025/12/24 12:27:29
3593dnl ---------------
3594dnl Verify that a test program compiles and runs with GNAT
3595dnl $cf_ada_make is set to the program that compiles/links
3596dnl $ADAFLAGS may be set to the GNAT flags.
3597dnl
3598dnl $1 is the text of the spec
3599dnl $2 is the text of the body
3600dnl $3 is the shell command to execute if successful
3601dnl $4 is the shell command to execute if not successful
3602AC_DEFUN([CF_GNAT_TRY_RUN],
3603[
3604rm -rf ./conftest* ./*~conftest*
3605cat >>conftest.ads <<CF_EOF
3606$1
3607CF_EOF
3608cat >>conftest.adb <<CF_EOF
3609$2
3610CF_EOF
3611if ( "$cf_ada_make" $ADAFLAGS conftest 1>&AS_MESSAGE_LOG_FD 2>&1 ) ; then
3612   if ( ./conftest 1>&AS_MESSAGE_LOG_FD 2>&1 ) ; then
3613ifelse($3,,      :,[      $3])
3614ifelse($4,,,[   else
3615      $4])
3616   fi
3617ifelse($4,,,[else
3618   $4])
3619fi
3620rm -rf ./conftest* ./*~conftest*
3621])dnl
3622dnl ---------------------------------------------------------------------------
3623dnl CF_GNAT_VERSION version: 22 updated: 2019/12/31 08:53:54
3624dnl ---------------
3625dnl $1 = cache variable to update
3626dnl $2 = program name
3627dnl Verify version of GNAT or related tool
3628AC_DEFUN([CF_GNAT_VERSION],
3629[
3630AC_CACHE_CHECK(for ifelse($2,,gnat,$2) version, cf_cv_gnat_version,[
3631cf_cv_gnat_version=`ifelse($2,,${cf_ada_make:-gnatmake},$2) --version 2>&1 | \
3632	grep '[[0-9]].[[0-9]][[0-9]]*' |\
3633	sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
3634])
3635test -z "$cf_cv_gnat_version" && cf_cv_gnat_version=no
3636ifelse($1,,,[eval $1=$cf_cv_gnat_version; unset cf_cv_gnat_version])
3637])dnl
3638dnl ---------------------------------------------------------------------------
3639dnl CF_GNU_SOURCE version: 11 updated: 2025/12/14 17:40:20
3640dnl -------------
3641dnl Check if we must define _GNU_SOURCE to get a reasonable value for
3642dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
3643dnl (or misfeature) of glibc2, which breaks portability of many applications,
3644dnl since it is interwoven with GNU extensions.
3645dnl
3646dnl Well, yes we could work around it...
3647dnl
3648dnl Parameters:
3649dnl	$1 is the nominal value for _XOPEN_SOURCE
3650AC_DEFUN([CF_GNU_SOURCE],
3651[
3652cf_gnu_xopen_source=ifelse($1,,500,$1)
3653
3654AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
3655AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
3656	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
3657		return 0;
3658	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
3659		return 0;
3660	#else
3661	#	error not GNU C library
3662	#endif])],
3663	[cf_cv_gnu_library=yes],
3664	[cf_cv_gnu_library=no])
3665])
3666
3667if test x$cf_cv_gnu_library = xyes; then
3668
3669	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
3670	# was changed to help a little.  newlib incorporated the change about 4
3671	# years later.
3672	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
3673		cf_save="$CPPFLAGS"
3674		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
3675		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
3676			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
3677				return 0;
3678			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
3679				return 0;
3680			#else
3681			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
3682			#endif])],
3683			[cf_cv_gnu_library_219=yes],
3684			[cf_cv_gnu_library_219=no])
3685		CPPFLAGS="$cf_save"
3686	])
3687
3688	if test "x$cf_cv_gnu_library_219" = xyes; then
3689		cf_save="$CPPFLAGS"
3690		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
3691			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
3692			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
3693				#include <limits.h>
3694				#include <sys/types.h>
3695				],[
3696				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
3697					return 0;
3698				#else
3699				#	error GNU C library is too old
3700				#endif])],
3701				[cf_cv_gnu_dftsrc_219=yes],
3702				[cf_cv_gnu_dftsrc_219=no])
3703			])
3704		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
3705	else
3706		cf_cv_gnu_dftsrc_219=maybe
3707	fi
3708
3709	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
3710
3711		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
3712		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
3713			#ifndef _XOPEN_SOURCE
3714			#error	expected _XOPEN_SOURCE to be defined
3715			#endif])],
3716			[cf_cv_gnu_source=no],
3717			[cf_save="$CPPFLAGS"
3718			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
3719			 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
3720				#ifdef _XOPEN_SOURCE
3721				#error	expected _XOPEN_SOURCE to be undefined
3722				#endif])],
3723				[cf_cv_gnu_source=no],
3724				[cf_cv_gnu_source=yes])
3725			CPPFLAGS="$cf_save"
3726			])
3727		])
3728
3729		if test "$cf_cv_gnu_source" = yes
3730		then
3731		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
3732			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
3733			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
3734				#ifdef _DEFAULT_SOURCE
3735				#error	expected _DEFAULT_SOURCE to be undefined
3736				#endif])],
3737				[cf_cv_default_source=no],
3738				[cf_cv_default_source=yes])
3739			])
3740			if test "$cf_cv_default_source" = yes
3741			then
3742				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
3743			fi
3744		fi
3745	fi
3746
3747fi
3748])dnl
3749dnl ---------------------------------------------------------------------------
3750dnl CF_GPP_LIBRARY version: 14 updated: 2025/12/24 12:27:29
3751dnl --------------
3752dnl If we're trying to use g++, test if libg++ is installed (a rather common
3753dnl problem :-).  If we have the compiler but no library, we'll be able to
3754dnl configure, but won't be able to build the c++ demo program.
3755AC_DEFUN([CF_GPP_LIBRARY],
3756[
3757cf_cxx_library=unknown
3758case "$cf_cv_system_name" in
3759(os2*)
3760	cf_gpp_libname=gpp
3761	;;
3762(*)
3763	cf_gpp_libname=g++
3764	;;
3765esac
3766if test "$GXX" = yes; then
3767	AC_MSG_CHECKING([for lib$cf_gpp_libname])
3768	cf_save="$LIBS"
3769	CF_ADD_LIB($cf_gpp_libname)
3770	AC_LINK_IFELSE([AC_LANG_PROGRAM([
3771#include <$cf_gpp_libname/builtin.h>
3772	],
3773	[two_arg_error_handler_t foo2 = lib_error_handler])],
3774	[cf_cxx_library=yes
3775	 CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
3776	 if test "$cf_gpp_libname" = cpp ; then
3777	    AC_DEFINE(HAVE_GPP_BUILTIN_H,1,[Define to 1 if we have gpp builtin.h])
3778	 else
3779	    AC_DEFINE(HAVE_GXX_BUILTIN_H,1,[Define to 1 if we have g++ builtin.h])
3780	 fi],
3781	[AC_LINK_IFELSE([AC_LANG_PROGRAM([
3782#include <builtin.h>
3783	],
3784	[two_arg_error_handler_t foo2 = lib_error_handler])],
3785	[cf_cxx_library=yes
3786	 CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
3787	 AC_DEFINE(HAVE_BUILTIN_H,1,[Define to 1 if we have builtin.h])],
3788	[cf_cxx_library=no])])
3789	LIBS="$cf_save"
3790	AC_MSG_RESULT($cf_cxx_library)
3791fi
3792])dnl
3793dnl ---------------------------------------------------------------------------
3794dnl CF_GXX_VERSION version: 9 updated: 2023/03/05 14:30:13
3795dnl --------------
3796dnl Check for version of g++
3797AC_DEFUN([CF_GXX_VERSION],[
3798AC_REQUIRE([AC_PROG_CPP])
3799GXX_VERSION=none
3800if test "$GXX" = yes; then
3801	AC_MSG_CHECKING(version of ${CXX:-g++})
3802	GXX_VERSION="`${CXX:-g++} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
3803	if test -z "$GXX_VERSION"
3804	then
3805		GXX_VERSION=unknown
3806		GXX=no
3807	fi
3808	AC_MSG_RESULT($GXX_VERSION)
3809fi
3810])dnl
3811dnl ---------------------------------------------------------------------------
3812dnl CF_GXX_WARNINGS version: 14 updated: 2025/12/24 09:07:25
3813dnl ---------------
3814dnl Check if the compiler supports useful warning options.
3815dnl
3816dnl Most of gcc's options apply to g++, except:
3817dnl	-Wbad-function-cast
3818dnl	-Wmissing-declarations
3819dnl	-Wnested-externs
3820dnl
3821dnl Omit a few (for now):
3822dnl	-Winline
3823dnl
3824dnl Parameter:
3825dnl	$1 is an optional list of g++ warning flags that a particular
3826dnl		application might want to use, e.g., "no-unused" for
3827dnl		-Wno-unused
3828dnl Special:
3829dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
3830dnl
3831AC_DEFUN([CF_GXX_WARNINGS],
3832[
3833
3834CF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS)
3835CF_CLANG_COMPILER(GXX,CLANG_CPLUSPLUS,CXXFLAGS)
3836
3837AC_REQUIRE([CF_GXX_VERSION])
3838
3839AC_LANG_SAVE
3840AC_LANG_CPLUSPLUS
3841
3842cat > conftest.$ac_ext <<EOF
3843#line __oline__ "configure"
3844int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
3845EOF
3846
3847if test "$INTEL_CPLUSPLUS" = yes
3848then
3849# The "-wdXXX" options suppress warnings:
3850# remark #1419: external declaration in primary source file
3851# remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
3852# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
3853# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
3854# remark #193: zero used for undefined preprocessing identifier
3855# remark #593: variable "curs_sb_left_arrow" was set but never used
3856# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
3857# remark #869: parameter "tw" was never referenced
3858# remark #981: operands are evaluated in unspecified order
3859# warning #269: invalid format string conversion
3860
3861	AC_MSG_CHECKING([for $CC warning options])
3862	test -n "$verbose" && AC_MSG_RESULT()
3863	cf_save_CXXFLAGS="$CXXFLAGS"
3864	EXTRA_CXXFLAGS="-Wall"
3865	for cf_opt in \
3866		wd1419 \
3867		wd1682 \
3868		wd1683 \
3869		wd1684 \
3870		wd193 \
3871		wd279 \
3872		wd593 \
3873		wd810 \
3874		wd869 \
3875		wd981
3876	do
3877		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
3878		if AC_TRY_EVAL(ac_compile); then
3879			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3880			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
3881		fi
3882	done
3883	CXXFLAGS="$cf_save_CXXFLAGS"
3884
3885elif test "$GXX" = yes
3886then
3887	AC_MSG_CHECKING([for $CXX warning options])
3888	test -n "$verbose" && AC_MSG_RESULT()
3889	cf_save_CXXFLAGS="$CXXFLAGS"
3890	EXTRA_CXXFLAGS="-W -Wall"
3891	cf_gxx_extra_warnings=""
3892	test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings"
3893	case "$GXX_VERSION" in
3894	([[1-2]].*)
3895		;;
3896	(*)
3897		cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++"
3898		;;
3899	esac
3900	for cf_opt in \
3901		Wabi \
3902		fabi-version=0 \
3903		Wextra \
3904		Wignored-qualifiers \
3905		Wlogical-op \
3906		Woverloaded-virtual \
3907		Wsign-promo \
3908		Wsynth \
3909		Wold-style-cast \
3910		Wcast-align \
3911		Wcast-qual \
3912		Wpointer-arith \
3913		Wshadow \
3914		Wundef $cf_gxx_extra_warnings $1
3915	do
3916		CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
3917		if AC_TRY_EVAL(ac_compile); then
3918			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3919			EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
3920		else
3921			test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
3922		fi
3923	done
3924	CXXFLAGS="$cf_save_CXXFLAGS"
3925fi
3926
3927rm -rf ./conftest*
3928AC_LANG_RESTORE
3929AC_SUBST(EXTRA_CXXFLAGS)
3930])dnl
3931dnl ---------------------------------------------------------------------------
3932dnl CF_HASHED_DB version: 7 updated: 2015/04/18 08:56:57
3933dnl ------------
3934dnl Look for an instance of the Berkeley hashed database.
3935dnl
3936dnl $1 = optional parameter, to specify install-prefix for the database.
3937AC_DEFUN([CF_HASHED_DB],
3938[
3939ifelse([$1],,,[
3940case $1 in
3941(yes|*able*)
3942	;;
3943(*)
3944	if test -d "$1" ; then
3945		CF_ADD_INCDIR($1/include)
3946		CF_ADD_LIBDIR($1/lib)
3947	else
3948		case "$1" in
3949		(./*|../*|/*)
3950			AC_MSG_WARN(no such directory $1)
3951			;;
3952		(*)
3953			CF_FIND_SUB_INCDIR($1)
3954			CF_FIND_SUB_LIBDIR($1)
3955			;;
3956		esac
3957	fi
3958esac
3959])
3960AC_CHECK_HEADER(db.h,[
3961CF_HASHED_DB_VERSION
3962if test "$cf_cv_hashed_db_version" = unknown ; then
3963	AC_MSG_ERROR(Cannot determine version of db)
3964else
3965	CF_HASHED_DB_LIBS
3966	if test "$cf_cv_hashed_db_libs" = unknown ; then
3967		AC_MSG_ERROR(Cannot determine library for db)
3968	elif test "$cf_cv_hashed_db_libs" != default ; then
3969		CF_ADD_LIB($cf_cv_hashed_db_libs)
3970	fi
3971fi
3972],[
3973	AC_MSG_ERROR(Cannot find db.h)
3974])
3975])dnl
3976dnl ---------------------------------------------------------------------------
3977dnl CF_HASHED_DB_LIBS version: 12 updated: 2025/12/24 12:27:29
3978dnl -----------------
3979dnl Given that we have the header and version for hashed database, find the
3980dnl library information.
3981AC_DEFUN([CF_HASHED_DB_LIBS],
3982[
3983AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
3984cf_cv_hashed_db_libs=unknown
3985for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
3986do
3987	cf_save_libs="$LIBS"
3988	if test -n "$cf_db_libs"; then
3989		CF_ADD_LIB($cf_db_libs)
3990	fi
3991	CF_MSG_LOG(checking for library $cf_db_libs)
3992	AC_LINK_IFELSE([AC_LANG_PROGRAM([
3993$ac_includes_default
3994#include <db.h>
3995],[
3996	char *path = "/tmp/foo";
3997#ifdef DB_VERSION_MAJOR
3998#if DB_VERSION_MAJOR >= 4
3999	DB *result = NULL;
4000	db_create(&result, NULL, 0);
4001	result->open(result,
4002		NULL,
4003		path,
4004		path,
4005		DB_HASH,
4006		DB_CREATE,
4007		0644);
4008#elif DB_VERSION_MAJOR >= 3
4009	DB *result = NULL;
4010	db_create(&result, NULL, 0);
4011	result->open(result,
4012		path,
4013		path,
4014		DB_HASH,
4015		DB_CREATE,
4016		0644);
4017#elif DB_VERSION_MAJOR >= 2
4018	DB *result = NULL;
4019	db_open(path,
4020		DB_HASH,
4021		DB_CREATE,
4022		0644,
4023		(DB_ENV *) 0,
4024		(DB_INFO *) 0,
4025		&result);
4026#endif /* DB_VERSION_MAJOR */
4027#else
4028	DB *result = dbopen(path,
4029		     2,
4030		     0644,
4031		     DB_HASH,
4032		     0);
4033#endif
4034	${cf_cv_main_return:-return}(result != NULL)
4035])],[
4036	if test -n "$cf_db_libs" ; then
4037		cf_cv_hashed_db_libs=$cf_db_libs
4038	else
4039		cf_cv_hashed_db_libs=default
4040	fi
4041	LIBS="$cf_save_libs"
4042	break
4043])
4044	LIBS="$cf_save_libs"
4045done
4046])
4047])dnl
4048dnl ---------------------------------------------------------------------------
4049dnl CF_HASHED_DB_VERSION version: 6 updated: 2025/12/24 12:27:29
4050dnl --------------------
4051dnl Given that we have the header file for hashed database, find the version
4052dnl information.
4053AC_DEFUN([CF_HASHED_DB_VERSION],
4054[
4055AC_CACHE_CHECK(for version of db, cf_cv_hashed_db_version,[
4056cf_cv_hashed_db_version=unknown
4057
4058for cf_db_version in 1 2 3 4 5 6
4059do
4060	CF_MSG_LOG(checking for db version $cf_db_version)
4061	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
4062$ac_includes_default
4063#include <db.h>
4064
4065#ifdef DB_VERSION_MAJOR
4066	/* db2 (DB_VERSION_MAJOR=2) has also DB_VERSION_MINOR, tested with 7 */
4067#if $cf_db_version == DB_VERSION_MAJOR
4068	/* ok */
4069#else
4070	#error $cf_db_version is not DB_VERSION_MAJOR
4071#endif
4072#else
4073#if $cf_db_version == 1
4074	/* ok: assuming this is DB 1.8.5 */
4075#else
4076	#error $cf_db_version is not 1
4077#endif
4078#endif
4079],[DBT *foo = 0])],[
4080	cf_cv_hashed_db_version=$cf_db_version
4081	break
4082	])
4083done
4084])
4085])dnl
4086dnl ---------------------------------------------------------------------------
4087dnl CF_HEADER_PATH version: 15 updated: 2021/01/01 13:31:04
4088dnl --------------
4089dnl Construct a search-list of directories for a nonstandard header-file
4090dnl
4091dnl Parameters
4092dnl	$1 = the variable to return as result
4093dnl	$2 = the package name
4094AC_DEFUN([CF_HEADER_PATH],
4095[
4096$1=
4097
4098# collect the current set of include-directories from compiler flags
4099cf_header_path_list=""
4100if test -n "${CFLAGS}${CPPFLAGS}" ; then
4101	for cf_header_path in $CPPFLAGS $CFLAGS
4102	do
4103		case "$cf_header_path" in
4104		(-I*)
4105			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
4106			CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
4107			cf_header_path_list="$cf_header_path_list [$]$1"
4108			;;
4109		esac
4110	done
4111fi
4112
4113# add the variations for the package we are looking for
4114CF_SUBDIR_PATH($1,$2,include)
4115
4116test "$includedir" != NONE && \
4117test "$includedir" != "/usr/include" && \
4118test -d "$includedir" && {
4119	test -d "$includedir" &&    $1="[$]$1 $includedir"
4120	test -d "$includedir/$2" && $1="[$]$1 $includedir/$2"
4121}
4122
4123test "$oldincludedir" != NONE && \
4124test "$oldincludedir" != "/usr/include" && \
4125test -d "$oldincludedir" && {
4126	test -d "$oldincludedir"    && $1="[$]$1 $oldincludedir"
4127	test -d "$oldincludedir/$2" && $1="[$]$1 $oldincludedir/$2"
4128}
4129
4130$1="[$]$1 $cf_header_path_list"
4131])dnl
4132dnl ---------------------------------------------------------------------------
4133dnl CF_HELP_MESSAGE version: 4 updated: 2019/12/31 08:53:54
4134dnl ---------------
4135dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
4136AC_DEFUN([CF_HELP_MESSAGE],
4137[CF_ACVERSION_CHECK(2.53,[],[
4138AC_DIVERT_HELP($1)])dnl
4139])dnl
4140dnl ---------------------------------------------------------------------------
4141dnl CF_INCLUDE_DIRS version: 10 updated: 2014/09/19 20:58:42
4142dnl ---------------
4143dnl Construct the list of include-options according to whether we're building
4144dnl in the source directory or using '--srcdir=DIR' option.
4145AC_DEFUN([CF_INCLUDE_DIRS],
4146[
4147if test "$srcdir" != "."; then
4148	CPPFLAGS="-I\${srcdir}/../include $CPPFLAGS"
4149fi
4150CPPFLAGS="-I../include $CPPFLAGS"
4151if test "$srcdir" != "."; then
4152	CPPFLAGS="-I\${srcdir} $CPPFLAGS"
4153fi
4154CPPFLAGS="-I. $CPPFLAGS"
4155AC_SUBST(CPPFLAGS)
4156])dnl
4157dnl ---------------------------------------------------------------------------
4158dnl CF_INSTALL_OPTS version: 3 updated: 2023/06/03 15:17:30
4159dnl ---------------
4160dnl prompt for/fill-in useful install-program options
4161AC_DEFUN([CF_INSTALL_OPTS],
4162[
4163CF_INSTALL_OPT_S
4164CF_INSTALL_OPT_P
4165CF_INSTALL_OPT_O
4166CF_INSTALL_OPT_STRIP_PROG
4167])dnl
4168dnl ---------------------------------------------------------------------------
4169dnl CF_INSTALL_OPT_O version: 3 updated: 2020/12/31 20:19:42
4170dnl ----------------
4171dnl Almost all "install" programs default to the current user's ownership.
4172dnl Almost - MINIX is an exception.
4173AC_DEFUN([CF_INSTALL_OPT_O],
4174[
4175AC_MSG_CHECKING(if install needs to be told about ownership)
4176case `$ac_config_guess` in
4177(*minix)
4178	with_install_o=yes
4179	;;
4180(*)
4181	with_install_o=no
4182	;;
4183esac
4184
4185AC_MSG_RESULT($with_install_o)
4186if test "x$with_install_o" = xyes
4187then
4188	INSTALL_OPT_O="`id root|sed -e 's/uid=[[0-9]]*(/ -o /' -e 's/gid=[[0-9]]*(/ -g /' -e 's/ [[^=[:space:]]][[^=[:space:]]]*=.*/ /' -e 's/)//g'`"
4189else
4190	INSTALL_OPT_O=
4191fi
4192
4193AC_SUBST(INSTALL_OPT_O)
4194])dnl
4195dnl ---------------------------------------------------------------------------
4196dnl CF_INSTALL_OPT_P version: 3 updated: 2021/01/01 13:31:04
4197dnl ----------------
4198dnl Some install-programs accept a "-p" option to preserve file modification
4199dnl timestamps.  That can be useful as an install option, as well as a way to
4200dnl avoid the need for ranlib after copying a static archive.
4201AC_DEFUN([CF_INSTALL_OPT_P],
4202[
4203: "${INSTALL:=install}"
4204AC_CACHE_CHECK(if install accepts -p option, cf_cv_install_p,[
4205	rm -rf ./conftest*
4206	date >conftest.in
4207	mkdir conftest.out
4208	sleep 3
4209	if $INSTALL -p conftest.in conftest.out 2>/dev/null
4210	then
4211		if test -f conftest.out/conftest.in
4212		then
4213			test conftest.in -nt conftest.out/conftest.in 2>conftest.err && \
4214			test conftest.out/conftest.in -nt conftest.in 2>conftest.err
4215			if test -s conftest.err
4216			then
4217				cf_cv_install_p=no
4218			else
4219				cf_cv_install_p=yes
4220			fi
4221		else
4222			cf_cv_install_p=no
4223		fi
4224	else
4225		cf_cv_install_p=no
4226	fi
4227	rm -rf ./conftest*
4228])
4229])dnl
4230dnl ---------------------------------------------------------------------------
4231dnl CF_INSTALL_OPT_S version: 3 updated: 2021/01/05 19:23:48
4232dnl ----------------
4233dnl By default, we should strip executables which are installed, but leave the
4234dnl ability to suppress that for unit-testing.
4235AC_DEFUN([CF_INSTALL_OPT_S],
4236[
4237AC_MSG_CHECKING(if you want to install stripped executables)
4238CF_ARG_DISABLE(stripping,
4239	[  --disable-stripping     do not strip (debug info) installed executables],
4240	[enable_stripping=no],
4241	[enable_stripping=yes])
4242AC_MSG_RESULT($enable_stripping)
4243
4244if test "$enable_stripping" = yes
4245then
4246	INSTALL_OPT_S="-s"
4247else
4248	INSTALL_OPT_S=
4249fi
4250AC_SUBST(INSTALL_OPT_S)
4251])dnl
4252dnl ---------------------------------------------------------------------------
4253dnl CF_INSTALL_OPT_STRIP_PROG version: 1 updated: 2023/06/03 15:17:30
4254dnl -------------------------
4255dnl Provide an option for overriding the strip program used in install "-s"
4256dnl
4257dnl coreutils install provides a --strip-program option
4258dnl FreeBSD uses STRIPBIN environment variable, while NetBSD and OpenBSD use
4259dnl STRIP environment variable.  Other versions of install do not support this.
4260AC_DEFUN([CF_INSTALL_OPT_STRIP_PROG],
4261[
4262AC_REQUIRE([CF_INSTALL_OPT_S])
4263if test -n "$INSTALL_OPT_S"
4264then
4265	AC_MSG_CHECKING(if you want to specify strip-program)
4266	AC_ARG_WITH(strip-program,
4267		[  --with-strip-program=XX specify program to use when stripping in install],
4268		[with_strip_program=$withval],
4269		[with_strip_program=no])
4270	AC_MSG_RESULT($with_strip_program)
4271	if test "$with_strip_program" != no
4272	then
4273		AC_MSG_CHECKING(if strip-program is supported with this installer)
4274		cf_install_program=`echo "$INSTALL" | sed -e 's%[[ ]]*[[ ]]-.%%'`
4275		check_install_strip=no
4276		if test -f "$cf_install_program"
4277		then
4278			check_install_version=`"$cf_install_program" --version 2>/dev/null | head -n 1 | grep coreutils`
4279			if test -n "$check_install_version"
4280			then
4281				check_install_strip="option"
4282			else
4283				for check_strip_variable in STRIPBIN STRIP
4284				do
4285					if strings "$cf_install_program" | grep "^$check_strip_variable[$]" >/dev/null
4286					then
4287						check_install_strip="environ"
4288						break
4289					fi
4290				done
4291			fi
4292		fi
4293		AC_MSG_RESULT($check_install_strip)
4294		case "$check_install_strip" in
4295		(no)
4296			AC_MSG_WARN($cf_install_program does not support strip program option)
4297			with_strip_program=no
4298			;;
4299		(environ)
4300			cat >install.tmp <<-CF_EOF
4301			#! $SHELL
4302			STRIPBIN="$with_strip_program" \\
4303			STRIP="$with_strip_program" \\
4304			$INSTALL "[$]@"
4305			CF_EOF
4306			INSTALL="`pwd`/install.tmp"
4307			chmod +x "$INSTALL"
4308			CF_VERBOSE(created $INSTALL)
4309			;;
4310		(option)
4311			INSTALL_OPT_S="$INSTALL_OPT_S --strip-program=\"$with_strip_program\""
4312			;;
4313		esac
4314	fi
4315fi
4316AC_SUBST(INSTALL_OPT_S)
4317])dnl
4318dnl ---------------------------------------------------------------------------
4319dnl CF_INSTALL_PREFIX version: 2 updated: 2025/10/18 11:14:21
4320dnl -----------------
4321dnl Special option for use by system-builders: the install-prefix is used to
4322dnl adjust the location into which the actual install is done, so that an
4323dnl archive can be built without modifying the host system's configuration.
4324AC_DEFUN([CF_INSTALL_PREFIX],[
4325AC_MSG_CHECKING(for an installation directory prefix)
4326AC_ARG_WITH(install-prefix,
4327	[  --with-install-prefix=DESTDIR use DESTDIR as installation directory prefix],
4328	[case "x$withval" in
4329	(xyes|xno)
4330		;;
4331	(*)	DESTDIR="$withval"
4332		;;
4333	esac])
4334AC_MSG_RESULT([${DESTDIR:-(none)}])
4335AC_SUBST(DESTDIR)
4336
4337SET_DESTDIR=
4338test -n "$DESTDIR" && SET_DESTDIR="DESTDIR=$DESTDIR"
4339AC_SUBST(SET_DESTDIR)
4340
4341AC_MSG_CHECKING(if installation directory prefix should be merged)
4342CF_ARG_ENABLE(install-prefix,
4343	[  --enable-install-prefix merge DESTDIR with installation prefix],
4344	cf_install_prefix=yes,
4345	cf_install_prefix=no)
4346AC_MSG_RESULT($cf_install_prefix)
4347
4348if test "$cf_install_prefix" = yes ; then
4349	MERGE_PREFIX=':$(prefix)%=%'
4350else
4351	MERGE_PREFIX=''
4352fi
4353
4354AC_SUBST(MERGE_PREFIX)
4355])dnl
4356dnl ---------------------------------------------------------------------------
4357dnl CF_INTEL_COMPILER version: 10 updated: 2025/12/14 17:40:20
4358dnl -----------------
4359dnl Check if the given compiler is really the Intel compiler for Linux.  It
4360dnl tries to imitate gcc, but does not return an error when it finds a mismatch
4361dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
4362dnl
4363dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
4364dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
4365dnl the wrappers for gcc and g++ warnings.
4366dnl
4367dnl $1 = GCC (default) or GXX
4368dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
4369dnl $3 = CFLAGS (default) or CXXFLAGS
4370AC_DEFUN([CF_INTEL_COMPILER],[
4371AC_REQUIRE([AC_CANONICAL_HOST])
4372ifelse([$2],,INTEL_COMPILER,[$2])=no
4373
4374if test "$ifelse([$1],,[$1],GCC)" = yes ; then
4375	case "$host_os" in
4376	(linux*|gnu*)
4377		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
4378		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
4379		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
4380		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[
4381#ifdef __INTEL_COMPILER
4382#else
4383#error __INTEL_COMPILER is not defined
4384#endif
4385])],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
4386cf_save_CFLAGS="$cf_save_CFLAGS -we147"
4387],[])
4388		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
4389		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
4390		;;
4391	esac
4392fi
4393])dnl
4394dnl ---------------------------------------------------------------------------
4395dnl CF_ISASCII version: 6 updated: 2025/12/24 12:27:29
4396dnl ----------
4397dnl Check if we have either a function or macro for 'isascii()'.
4398AC_DEFUN([CF_ISASCII],
4399[
4400AC_MSG_CHECKING(for isascii)
4401AC_CACHE_VAL(cf_cv_have_isascii,[
4402	AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <ctype.h>],[int x = isascii(' '); (void)x])],
4403	[cf_cv_have_isascii=yes],
4404	[cf_cv_have_isascii=no])
4405])dnl
4406AC_MSG_RESULT($cf_cv_have_isascii)
4407test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII,1,[Define to 1 if we have isascii()])
4408])dnl
4409dnl ---------------------------------------------------------------------------
4410dnl CF_LARGEFILE version: 14 updated: 2025/12/22 04:16:14
4411dnl ------------
4412dnl Add checks for large file support.
4413AC_DEFUN([CF_LARGEFILE],[
4414ifdef([AC_FUNC_FSEEKO],[
4415	AC_SYS_LARGEFILE
4416	if test "$enable_largefile" != no ; then
4417	AC_FUNC_FSEEKO
4418
4419	# Normally we would collect these definitions in the config.h,
4420	# but (like _XOPEN_SOURCE), some environments rely on having these
4421	# defined before any of the system headers are included.  Another
4422	# case comes up with C++, e.g., on AIX the compiler compiles the
4423	# header files by themselves before looking at the body files it is
4424	# told to compile.  For ncurses, those header files do not include
4425	# the config.h
4426	if test "$ac_cv_sys_large_files" != no
4427	then
4428		CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES)
4429	fi
4430	if test "$ac_cv_sys_largefile_source" != no
4431	then
4432		CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE)
4433	fi
4434	if test "$ac_cv_sys_file_offset_bits" != no
4435	then
4436		CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits)
4437	fi
4438
4439	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
4440		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
4441#pragma GCC diagnostic error "-Wincompatible-pointer-types"
4442#include <sys/types.h>
4443#include <dirent.h>
4444
4445#ifndef __REDIRECT
4446/* if transitional largefile support is setup, this is true */
4447extern struct dirent64 * readdir(DIR *);
4448#endif
4449		],[
4450		DIR *dp = opendir(".");
4451		struct dirent64 *x = readdir(dp);
4452		struct dirent *y = readdir(dp);
4453		int z = x - y;
4454		(void)z;
4455		])],
4456		[cf_cv_struct_dirent64=yes],
4457		[cf_cv_struct_dirent64=no])
4458	])
4459	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64])
4460	fi
4461])
4462])
4463dnl ---------------------------------------------------------------------------
4464dnl CF_LDFLAGS_STATIC version: 17 updated: 2025/12/24 12:27:29
4465dnl -----------------
4466dnl Check for compiler/linker flags used to temporarily force usage of static
4467dnl libraries.  This depends on the compiler and platform.  Use this to help
4468dnl ensure that the linker picks up a given library based on its position in
4469dnl the list of linker options and libraries.
4470AC_DEFUN([CF_LDFLAGS_STATIC],[
4471
4472if test "$GCC" = yes ; then
4473	case "$cf_cv_system_name" in
4474	(OS/2*|os2*|aix[[4]]*|solaris2.1[[0-9]]|darwin*)
4475		LDFLAGS_STATIC=
4476		LDFLAGS_SHARED=
4477		;;
4478	(*) 	# normally, except when broken
4479		LDFLAGS_STATIC=-static
4480		LDFLAGS_SHARED=-dynamic
4481		;;
4482	esac
4483else
4484	case "$cf_cv_system_name" in
4485	(aix[[4-7]]*) 	# from ld man page
4486		LDFLAGS_STATIC=-bstatic
4487		LDFLAGS_SHARED=-bdynamic
4488		;;
4489	(hpux*)		# from ld man page for hpux10.20, hpux11.11
4490		# We could also use just "archive" and "shared".
4491		LDFLAGS_STATIC=-Wl,-a,archive_shared
4492		LDFLAGS_SHARED=-Wl,-a,shared_archive
4493		;;
4494	(irix*)		# from ld man page IRIX64
4495		LDFLAGS_STATIC=-Bstatic
4496		LDFLAGS_SHARED=-Bdynamic
4497		;;
4498	(osf[[45]]*)	# from ld man page osf4.0d, osf5.1
4499		# alternative "-oldstyle_liblookup" (not in cc man page)
4500		LDFLAGS_STATIC=-noso
4501		LDFLAGS_SHARED=-so_archive
4502		;;
4503	(solaris2*)
4504		LDFLAGS_STATIC=-Bstatic
4505		LDFLAGS_SHARED=-Bdynamic
4506		;;
4507	esac
4508fi
4509
4510if test -n "$LDFLAGS_STATIC" && test -n "$LDFLAGS_SHARED"
4511then
4512	AC_MSG_CHECKING(if linker supports switching between static/dynamic)
4513
4514	rm -f libconftest.a
4515	cat >conftest.$ac_ext <<EOF
4516#line __oline__ "configure"
4517#include <stdio.h>
4518int cf_ldflags_static(FILE *fp) { return fflush(fp); }
4519EOF
4520	if AC_TRY_EVAL(ac_compile) ; then
4521		( $AR $ARFLAGS libconftest.a conftest.$OBJEXT ) 2>&AS_MESSAGE_LOG_FD 1>/dev/null
4522		( eval $RANLIB libconftest.a ) 2>&AS_MESSAGE_LOG_FD >/dev/null
4523	fi
4524	rm -f conftest.*
4525
4526	cf_save_LIBS="$LIBS"
4527
4528	LIBS="$LDFLAGS_STATIC -L`pwd` -lconftest $LDFLAGS_DYNAMIC $LIBS"
4529	AC_LINK_IFELSE([AC_LANG_PROGRAM([
4530#line __oline__ "configure"
4531#include <stdio.h>
4532int cf_ldflags_static(FILE *fp);
4533],[
4534	return cf_ldflags_static(stdin);
4535])],[
4536	# some linkers simply ignore the -dynamic
4537	case x`file "conftest$ac_exeext" 2>/dev/null` in
4538	(*static*)
4539		cf_ldflags_static=no
4540		;;
4541	(*)
4542		cf_ldflags_static=yes
4543		;;
4544	esac
4545],[cf_ldflags_static=no])
4546
4547	rm -f libconftest.*
4548	LIBS="$cf_save_LIBS"
4549
4550	AC_MSG_RESULT($cf_ldflags_static)
4551
4552	if test "$cf_ldflags_static" != yes
4553	then
4554		LDFLAGS_STATIC=
4555		LDFLAGS_SHARED=
4556	fi
4557else
4558	LDFLAGS_STATIC=
4559	LDFLAGS_SHARED=
4560fi
4561
4562AC_SUBST(LDFLAGS_STATIC)
4563AC_SUBST(LDFLAGS_SHARED)
4564])
4565dnl ---------------------------------------------------------------------------
4566dnl CF_LD_RPATH_OPT version: 10 updated: 2025/12/15 04:04:20
4567dnl ---------------
4568dnl For the given system and compiler, find the compiler flags to pass to the
4569dnl loader to use the "rpath" feature.
4570AC_DEFUN([CF_LD_RPATH_OPT],
4571[
4572AC_REQUIRE([CF_CHECK_CACHE])
4573
4574LD_RPATH_OPT=
4575if test "x$cf_cv_enable_rpath" != xno
4576then
4577	AC_MSG_CHECKING(for an rpath option)
4578	case "$cf_cv_system_name" in
4579	(irix*)
4580		if test "$GCC" = yes; then
4581			LD_RPATH_OPT="-Wl,-rpath,"
4582		else
4583			LD_RPATH_OPT="-rpath "
4584		fi
4585		;;
4586	(linux*|gnu*|k*bsd*-gnu|freebsd*)
4587		LD_RPATH_OPT="-Wl,-rpath,"
4588		;;
4589	(openbsd[[2-9]].*|mirbsd*)
4590		LD_RPATH_OPT="-Wl,-rpath,"
4591		;;
4592	(dragonfly*)
4593		LD_RPATH_OPT="-rpath "
4594		;;
4595	(netbsd*)
4596		LD_RPATH_OPT="-Wl,-rpath,"
4597		;;
4598	(osf*|mls+*)
4599		LD_RPATH_OPT="-rpath "
4600		;;
4601	(solaris2*)
4602		LD_RPATH_OPT="-R"
4603		;;
4604	(*)
4605		;;
4606	esac
4607	AC_MSG_RESULT($LD_RPATH_OPT)
4608
4609	case "x$LD_RPATH_OPT" in
4610	(x-R*)
4611		AC_MSG_CHECKING(if we need a space after rpath option)
4612		cf_save_LIBS="$LIBS"
4613		CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
4614		AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], cf_rpath_space=no, cf_rpath_space=yes)
4615		LIBS="$cf_save_LIBS"
4616		AC_MSG_RESULT($cf_rpath_space)
4617		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
4618		;;
4619	esac
4620fi
4621])dnl
4622dnl ---------------------------------------------------------------------------
4623dnl CF_LD_SEARCHPATH version: 4 updated: 2022/08/27 15:43:08
4624dnl ----------------
4625dnl Try to obtain the linker's search-path, for use in scripts.
4626dnl
4627dnl Ignore LD_LIBRARY_PATH, etc.
4628AC_DEFUN([CF_LD_SEARCHPATH],[
4629AC_CACHE_CHECK(for linker search path,cf_cv_ld_searchpath,[
4630
4631if test "$cross_compiling" != yes ; then
4632
4633# GNU binutils' ld does not involve permissions which may stop ldconfig.
4634cf_pathlist=`${LD:-ld} --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[[("=]][[("=]]*,,g' -e 's/"[[)]];//gp' | sort -u`
4635
4636# The -NX options tell newer versions of Linux ldconfig to not attempt to
4637# update the cache, which makes it run faster.
4638test -z "$cf_pathlist" && \
4639	cf_pathlist=`(ldconfig -NX -v) 2>/dev/null | sed -e '/^[[ 	]]/d' -e 's/:$//' | sort -u`
4640
4641test -z "$cf_pathlist" &&
4642	cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e '/^[[ 	]]/d' -e 's/:$//p' | sort -u`
4643
4644# This works with OpenBSD 6.5, which lists only filenames
4645test -z "$cf_pathlist" &&
4646	cf_pathlist=`(ldconfig -v) 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*[$],\1,p' | sort -u`
4647
4648if test -z "$cf_pathlist"
4649then
4650	# dyld default path with MacOS
4651	if test -f /usr/bin/otool && test "x`uname -s`" = xDarwin
4652	then
4653		# do this to bypass check
4654		cf_cv_ld_searchpath='$HOME/lib'
4655		cf_pathlist="/usr/local/lib /lib /usr/lib"
4656	fi
4657fi
4658
4659if test -z "$cf_pathlist"
4660then
4661	# Solaris is "SunOS"
4662	if test -f /usr/bin/isainfo && test "x`uname -s`" = xSunOS
4663	then
4664		case x`(isainfo -b)` in
4665		(x64)
4666			cf_pathlist="$cf_pathlist /lib/64 /usr/lib/64"
4667			;;
4668		(x32)
4669			test -d /usr/ccs/lib && cf_pathlist="$cf_pathlist /usr/ccs/lib"
4670			cf_pathlist="$cf_pathlist /lib /usr/lib"
4671			;;
4672		(*)
4673			AC_MSG_WARN(problem with Solaris architecture)
4674			;;
4675		esac
4676	fi
4677fi
4678
4679if test -z "$cf_pathlist"
4680then
4681	# HP-UX
4682	if test x"`uname -s`" = xHP-UX
4683	then
4684		case x`getconf LONG_BIT` in
4685		(x64)
4686			cf_pathlist="/usr/lib/hpux64"
4687			;;
4688		(x*)
4689			cf_pathlist="/usr/lib/hpux32"
4690			;;
4691		esac
4692	fi
4693fi
4694
4695fi
4696
4697# If nothing else, assume it is conventional
4698test -z "$cf_pathlist" && cf_pathlist="/usr/lib /lib"
4699
4700# Finally, check that this is only directories
4701for cf_path in [$]0 $cf_pathlist
4702do
4703	if test -d "$cf_path"; then
4704		test -n "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath="${cf_cv_ld_searchpath} "
4705		cf_cv_ld_searchpath="${cf_cv_ld_searchpath}${cf_path}"
4706	fi
4707done
4708
4709# Ensure that it is nonempty
4710test -z "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath=/usr/lib
4711])
4712
4713LD_SEARCHPATH=`echo "$cf_cv_ld_searchpath"|sed -e 's/ /|/g'`
4714AC_SUBST(LD_SEARCHPATH)
4715])dnl
4716dnl ---------------------------------------------------------------------------
4717dnl CF_LIBRARY_PATH version: 11 updated: 2021/01/01 13:31:04
4718dnl ---------------
4719dnl Construct a search-list of directories for a nonstandard library-file
4720dnl
4721dnl Parameters
4722dnl	$1 = the variable to return as result
4723dnl	$2 = the package name
4724AC_DEFUN([CF_LIBRARY_PATH],
4725[
4726$1=
4727cf_library_path_list=""
4728if test -n "${LDFLAGS}${LIBS}" ; then
4729	for cf_library_path in $LDFLAGS $LIBS
4730	do
4731		case "$cf_library_path" in
4732		(-L*)
4733			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
4734			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
4735			cf_library_path_list="$cf_library_path_list [$]$1"
4736			;;
4737		esac
4738	done
4739fi
4740
4741CF_SUBDIR_PATH($1,$2,lib)
4742
4743$1="$cf_library_path_list [$]$1"
4744])dnl
4745dnl ---------------------------------------------------------------------------
4746dnl CF_LIBTOOL_VERSION version: 2 updated: 2024/06/12 04:19:01
4747dnl ------------------
4748AC_DEFUN([CF_LIBTOOL_VERSION],[
4749ifdef([LT_PACKAGE_VERSION],[
4750	cf_cv_libtool_version=LT_PACKAGE_VERSION
4751],[
4752if test -n "$LIBTOOL" && test "$LIBTOOL" != none
4753then
4754	cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' |sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
4755else
4756	cf_cv_libtool_version=
4757fi
4758test -z "$cf_cv_libtool_version" && unset cf_cv_libtool_version
4759])dnl
4760])dnl
4761dnl ---------------------------------------------------------------------------
4762dnl CF_LIB_PREFIX version: 14 updated: 2021/01/01 13:31:04
4763dnl -------------
4764dnl Compute the library-prefix for the given host system
4765dnl $1 = variable to set
4766define([CF_LIB_PREFIX],
4767[
4768	case "$cf_cv_system_name" in
4769	(OS/2*|os2*)
4770		if test "$DFT_LWR_MODEL" = libtool; then
4771			LIB_PREFIX='lib'
4772		else
4773			LIB_PREFIX=''
4774		fi
4775		;;
4776	(*-msvc*)
4777		LIB_PREFIX=''
4778		;;
4779	(*)	LIB_PREFIX='lib'
4780		;;
4781	esac
4782ifelse($1,,,[$1=$LIB_PREFIX])
4783	AC_SUBST(LIB_PREFIX)
4784])dnl
4785dnl ---------------------------------------------------------------------------
4786dnl CF_LIB_RULES version: 103 updated: 2025/11/11 20:09:36
4787dnl ------------
4788dnl Append definitions and rules for the given models to the subdirectory
4789dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
4790dnl subdirectory is a library-source directory, modify the Libs_To_Make list in
4791dnl the corresponding makefile to list the models that we'll generate.
4792dnl
4793dnl For shared libraries, make a list of symbolic links to construct when
4794dnl generating each library.  The convention used for Linux is the simplest
4795dnl one:
4796dnl	lib<name>.so	->
4797dnl	lib<name>.so.<major>	->
4798dnl	lib<name>.so.<maj>.<minor>
4799dnl
4800dnl Note: Libs_To_Make is mixed case, since it is not a pure autoconf variable.
4801AC_DEFUN([CF_LIB_RULES],
4802[AC_REQUIRE([AC_PROG_FGREP])dnl
4803AC_REQUIRE([CF_MAKE_PHONY])dnl
4804AC_REQUIRE([CF_GLOB_FULLPATH])dnl
4805
4806cf_prefix=$LIB_PREFIX
4807AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
4808
4809case "$cf_cv_shlib_version" in
4810(cygdll|msysdll|mingw|msvcdll)
4811	TINFO_NAME=$TINFO_ARG_SUFFIX
4812	TINFO_SUFFIX=.dll
4813	;;
4814esac
4815
4816if test -n "$TINFO_SUFFIX" ; then
4817	case "$TINFO_SUFFIX" in
4818	(tw*)
4819		TINFO_NAME="${TINFO_NAME}tw${EXTRA_SUFFIX}"
4820		TINFO_SUFFIX=`echo "$TINFO_SUFFIX" | sed 's/^tw'$EXTRA_SUFFIX'//'`
4821		;;
4822	(t*)
4823		TINFO_NAME="${TINFO_NAME}t${EXTRA_SUFFIX}"
4824		TINFO_SUFFIX=`echo "$TINFO_SUFFIX" | sed 's/^t'$EXTRA_SUFFIX'//'`
4825		;;
4826	(w*)
4827		TINFO_NAME="${TINFO_NAME}w${EXTRA_SUFFIX}"
4828		TINFO_SUFFIX=`echo "$TINFO_SUFFIX" | sed 's/^w'$EXTRA_SUFFIX'//'`
4829		;;
4830	esac
4831fi
4832
4833for cf_dir in $SRC_SUBDIRS
4834do
4835	if test ! -d "$srcdir/$cf_dir" ; then
4836		continue
4837	elif test -f "$srcdir/$cf_dir/modules" ; then
4838
4839		SHARED_LIB=
4840		Libs_To_Make=
4841		cf_awk_program=
4842		if test -n "${cf_cv_abi_default}" && test "x${cf_cv_abi_default}" != "x5"
4843		then
4844			cf_awk_program="$cf_awk_program\
4845/deprecated in ABI${cf_cv_abi_default}/ { next; }\
4846{ sub(\"NCURSES([[WT]]+)?\", \"&${cf_cv_abi_default}\"); }\
4847"
4848		fi
4849
4850		if test "x$WILDCARD_SYMS" = xno
4851		then
4852			cf_awk_program="$cf_awk_program\
4853/[[ 	]]_\\*;/ { skip=1; next; }\
4854"
4855		fi
4856
4857		if test "x$cf_awk_program" != "x"
4858		then
4859			cat >>$cf_dir/Makefile <<CF_EOF
4860
4861# Generated by CF_LIB_RULES
4862resulting.map: $UNALTERED_SYMS
4863	$AWK 'BEGIN { skip = 1; last=""; } \
4864$cf_awk_program \
4865{ if ( last != "" && ( skip == 0 || \[$]\[$]0 !~ /}/ ) ) { print last; }\
4866 skip = 0; last = \[$]\[$]0; } \
4867END { print last; }' < "$UNALTERED_SYMS" >\[$]@
4868
4869distclean::
4870	rm -f resulting.map
4871CF_EOF
4872		fi
4873
4874		for cf_item in $cf_LIST_MODELS
4875		do
4876			CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
4877			if test "$cf_dir" = "c++"
4878			then
4879				CF_MAP_LIB_BASENAME(cf_libname,cxx)
4880			else
4881				CF_MAP_LIB_BASENAME(cf_libname,$cf_dir)
4882			fi
4883			test -z "$cf_libname" && cf_libname="$cf_dir"
4884			if test "$cf_item" = shared ; then
4885				if test -n "${LIB_SUFFIX}"
4886				then
4887					cf_shared_suffix=`echo "$cf_suffix" | sed 's/^'"${ABI_SUFFIX}"'//'`
4888				else
4889					cf_shared_suffix="$cf_suffix"
4890				fi
4891				if test "$cf_cv_do_symlinks" = yes ; then
4892					cf_version_name=
4893
4894					case "$cf_cv_shlib_version" in
4895					(rel)
4896						cf_version_name=REL_VERSION
4897						;;
4898					(abi)
4899						cf_version_name=ABI_VERSION
4900						;;
4901					esac
4902
4903					if test -n "$cf_version_name"
4904					then
4905						case "$cf_cv_system_name" in
4906						(darwin*)
4907							# "w", etc?
4908							cf_suffix="${ABI_SUFFIX}"'.${'$cf_version_name'}'"$cf_shared_suffix"
4909							;;
4910						(*)
4911							cf_suffix="$cf_suffix"'.${'$cf_version_name'}'
4912							;;
4913						esac
4914					fi
4915					if test -n "${ABI_SUFFIX}"
4916					then
4917						cf_shared_suffix=`echo "$cf_suffix" | sed 's/^'"${ABI_SUFFIX}"'//'`
4918					else
4919						cf_shared_suffix="$cf_suffix"
4920					fi
4921				fi
4922				# cygwin needs import library, and has unique naming convention
4923				# use autodetected ${cf_prefix} for import lib and static lib, but
4924				# use 'cyg' prefix for shared lib.
4925				case "$cf_cv_shlib_version" in
4926				(cygdll)
4927					cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4928					cf_add_lib="../lib/cyg${cf_libname}${cf_cygsuf}"
4929					;;
4930				(msysdll)
4931					cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4932					cf_add_lib="../lib/msys-${cf_libname}${cf_cygsuf}"
4933					;;
4934				(mingw)
4935					cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4936					cf_add_lib="../lib/lib${cf_libname}${cf_cygsuf}"
4937					;;
4938				(msvcdll)
4939					cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
4940					cf_add_lib="../lib/${cf_libname}${cf_cygsuf}"
4941					;;
4942				(*)
4943					cf_add_lib=
4944					;;
4945				esac
4946				if test -n "$cf_add_lib"
4947				then
4948					Libs_To_Make="$Libs_To_Make $cf_add_lib"
4949					continue
4950				fi
4951			fi
4952			cf_add_lib="../lib/${cf_prefix}${cf_libname}${cf_suffix}"
4953			Libs_To_Make="$Libs_To_Make $cf_add_lib"
4954		done
4955
4956		if test "$cf_dir" = ncurses ; then
4957			cf_subsets="$LIB_SUBSETS"
4958			cf_r_parts="$cf_subsets"
4959			cf_liblist="$Libs_To_Make"
4960
4961			while test -n "$cf_r_parts"
4962			do
4963				cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'`
4964				cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'`
4965				if test "$cf_l_parts" != "$cf_r_parts" ; then
4966					cf_add_lib=
4967					case "$cf_l_parts" in
4968					(*termlib*)
4969						cf_add_lib=`echo "$cf_liblist" |sed -e s%${LIB_NAME}${ABI_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
4970						;;
4971					(*ticlib*)
4972						cf_add_lib=`echo "$cf_liblist" |sed -e s%${LIB_NAME}${ABI_SUFFIX}%${TICS_LIB_SUFFIX}%g`
4973						;;
4974					(*)
4975						break
4976						;;
4977					esac
4978					if test -n "$cf_add_lib"; then
4979						Libs_To_Make="$cf_add_lib $Libs_To_Make"
4980					fi
4981				else
4982					break
4983				fi
4984			done
4985		else
4986			cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
4987		fi
4988
4989		if test "$cf_dir" = c++; then
4990			if test "x$with_shared_cxx" != xyes && test -n "$cf_shared_suffix"; then
4991				cf_list=
4992				for cf_item in $Libs_To_Make
4993				do
4994					case "$cf_item" in
4995					(*.a)
4996						;;
4997					(*)
4998						cf_item=`echo "$cf_item" | sed -e "s,"$cf_shared_suffix",.a,"`
4999						;;
5000					esac
5001					for cf_test in $cf_list
5002					do
5003						if test "$cf_test" = "$cf_item"
5004						then
5005							cf_LIST_MODELS=`echo "$cf_LIST_MODELS" | sed -e 's/normal//'`
5006							cf_item=
5007							break
5008						fi
5009					done
5010					test -n "$cf_item" && cf_list="$cf_list $cf_item"
5011				done
5012				Libs_To_Make="$cf_list"
5013			fi
5014		fi
5015
5016		sed -e "s%@Libs_To_Make@%$Libs_To_Make%" \
5017		    -e "s%@SHARED_LIB@%$SHARED_LIB%" \
5018			"$cf_dir/Makefile" >$cf_dir/Makefile.out
5019		mv "$cf_dir/Makefile.out" "$cf_dir/Makefile"
5020
5021		$AWK -f "$srcdir/mk-0th.awk" \
5022			libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" ticlib="$TICS_LIB_SUFFIX" termlib="$TINFO_LIB_SUFFIX" \
5023			"$srcdir/$cf_dir/modules" >>$cf_dir/Makefile
5024
5025		for cf_subset in $cf_subsets
5026		do
5027			cf_subdirs=
5028			for cf_item in $cf_LIST_MODELS
5029			do
5030
5031			echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
5032			CF_UPPER(cf_ITEM,$cf_item)
5033
5034			CXX_MODEL=$cf_ITEM
5035			if test "$CXX_MODEL" = SHARED; then
5036				case "$cf_cv_shlib_version" in
5037				(cygdll|msysdll|mingw|msvcdll)
5038					test "x$with_shared_cxx" = xno && CF_VERBOSE(overriding CXX_MODEL to SHARED)
5039					with_shared_cxx=yes
5040					;;
5041				(*)
5042					test "x$with_shared_cxx" = xno && CXX_MODEL=NORMAL
5043					;;
5044				esac
5045			fi
5046
5047			CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
5048			CF_OBJ_SUBDIR($cf_item,cf_subdir)
5049
5050			# Test for case where we build libtinfo with a different name.
5051			cf_libname=$cf_dir
5052			if test "$cf_dir" = ncurses ; then
5053				case "$cf_subset" in
5054				(*base*)
5055					cf_libname=${cf_libname}$ABI_SUFFIX
5056					;;
5057				(*termlib*)
5058					cf_libname=$TINFO_LIB_SUFFIX
5059					;;
5060				(ticlib*)
5061					cf_libname=$TICS_LIB_SUFFIX
5062					;;
5063				esac
5064			elif test "$cf_dir" = c++ ; then
5065				CF_MAP_LIB_BASENAME(cf_libname,cxx)
5066				cf_libname=${cf_libname}$ABI_SUFFIX
5067			else
5068				CF_MAP_LIB_BASENAME(cf_libname,$cf_dir)
5069				cf_libname=${cf_libname}$ABI_SUFFIX
5070			fi
5071			if test -n "${USE_ARG_SUFFIX}" ; then
5072				# undo $ABI_SUFFIX add-on in CF_LIB_SUFFIX
5073				cf_suffix=`echo "$cf_suffix" |sed -e "s%^${ABI_SUFFIX}%%"`
5074			fi
5075
5076			# These dependencies really are for development, not
5077			# builds, but they are useful in porting, too.
5078			cf_depend="../include/ncurses_cfg.h"
5079			if test "$srcdir" = "."; then
5080				cf_reldir="."
5081			else
5082				cf_reldir="\${srcdir}"
5083			fi
5084
5085			if test -f "$srcdir/$cf_dir/$cf_dir.priv.h" ; then
5086				cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
5087			elif test -f "$srcdir/$cf_dir/curses.priv.h" ; then
5088				cf_depend="$cf_depend $cf_reldir/curses.priv.h"
5089			fi
5090
5091 			cf_dir_suffix=
5092 			old_cf_suffix="$cf_suffix"
5093 			if test "$cf_cv_shlib_version_infix" = yes ; then
5094			if test -n "$ABI_SUFFIX" ; then
5095				case "$ABI_SUFFIX" in
5096				(tw*)
5097					cf_libname=`echo "$cf_libname" | sed 's/tw'$EXTRA_SUFFIX'$//'`
5098					cf_suffix=`echo "$cf_suffix" | sed 's/^tw'$EXTRA_SUFFIX'//'`
5099					cf_dir_suffix=tw$EXTRA_SUFFIX
5100					;;
5101				(t*)
5102					cf_libname=`echo "$cf_libname" | sed 's/t'$EXTRA_SUFFIX'$//'`
5103					cf_suffix=`echo "$cf_suffix" | sed 's/^t'$EXTRA_SUFFIX'//'`
5104					cf_dir_suffix=t$EXTRA_SUFFIX
5105					;;
5106				(w*)
5107					cf_libname=`echo "$cf_libname" | sed 's/w'$EXTRA_SUFFIX'$//'`
5108					cf_suffix=`echo "$cf_suffix" | sed 's/^w'$EXTRA_SUFFIX'//'`
5109					cf_dir_suffix=w$EXTRA_SUFFIX
5110					;;
5111				(*)
5112					cf_libname=`echo "$cf_libname" | sed 's/'$EXTRA_SUFFIX'$//'`
5113					cf_suffix=`echo "$cf_suffix" | sed 's/^'$EXTRA_SUFFIX'//'`
5114					cf_dir_suffix=$EXTRA_SUFFIX
5115					;;
5116				esac
5117			fi
5118 			fi
5119
5120			$AWK -f "$srcdir/mk-1st.awk" \
5121				name=${cf_libname}${cf_dir_suffix} \
5122				traces=$LIB_TRACING \
5123				MODEL=$cf_ITEM \
5124				CXX_MODEL=$CXX_MODEL \
5125				ABI_SUFFIX=$ABI_SUFFIX \
5126				LIB_SUFFIX=$LIB_SUFFIX \
5127				make_phony="${cf_cv_make_PHONY:-no}" \
5128				model=$cf_subdir \
5129				prefix=$cf_prefix \
5130				suffix=$cf_suffix \
5131				subset=$cf_subset \
5132				driver=$cf_cv_term_driver \
5133				SymLink="$LN_S" \
5134				TermlibRoot=$TINFO_NAME \
5135				TermlibSuffix=$TINFO_SUFFIX \
5136				ShlibVer=$cf_cv_shlib_version \
5137				ShlibVerInfix=$cf_cv_shlib_version_infix \
5138				ReLink=${cf_cv_do_relink:-no} \
5139				ReRanlib=${cf_cv_do_reranlib:-yes} \
5140				DoLinks=$cf_cv_do_symlinks \
5141				rmSoLocs=$cf_cv_rm_so_locs \
5142				ldconfig="$LDCONFIG" \
5143				overwrite=$WITH_OVERWRITE \
5144				depend="$cf_depend" \
5145				host="$host" \
5146				libtool_version="$LIBTOOL_VERSION" \
5147				"$srcdir/$cf_dir/modules" >>$cf_dir/Makefile
5148
5149			cf_suffix="$old_cf_suffix"
5150
5151			for cf_subdir2 in $cf_subdirs lib
5152			do
5153				test "$cf_subdir" = "$cf_subdir2" && break
5154			done
5155			test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
5156			$AWK -f "$srcdir/mk-2nd.awk" \
5157				name=$cf_dir \
5158				traces=$LIB_TRACING \
5159				MODEL=$cf_ITEM \
5160				model=$cf_subdir \
5161				subset=$cf_subset \
5162				srcdir=$srcdir \
5163				echo=$WITH_ECHO \
5164				crenames=$cf_cv_prog_CC_c_o \
5165				cxxrenames=$cf_cv_prog_CXX_c_o \
5166				"$srcdir/$cf_dir/modules" >>$cf_dir/Makefile
5167			cf_subdirs="$cf_subdirs $cf_subdir"
5168			done
5169		done
5170	fi
5171
5172	echo '	( cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} [$]@ )' >>Makefile
5173done
5174
5175echo >> Makefile
5176echo '# generated by CF_LIB_RULES' >> Makefile
5177
5178if test "x$cf_cv_make_PHONY" = xyes ; then
5179	cat >> Makefile <<-CF_EOF
5180
5181	.PHONY :	libs
5182	.PHONY :	lintlib
5183	.PHONY :	install.includes
5184	.PHONY :	uninstall.includes
5185	.PHONY :	install.libs
5186	.PHONY :	uninstall.libs
5187CF_EOF
5188fi
5189
5190for cf_dir in $SRC_SUBDIRS
5191do
5192	if test ! -d "$srcdir/$cf_dir" ; then
5193		continue
5194	fi
5195
5196	if test -f "$cf_dir/Makefile" ; then
5197		case "$cf_dir" in
5198		(Ada95)
5199			echo 'libs \' >> Makefile
5200			echo 'install.libs \' >> Makefile
5201			echo 'uninstall.libs ::' >> Makefile
5202			echo '	( cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} [$]@ )' >> Makefile
5203			;;
5204		esac
5205	fi
5206
5207	if test -f "$srcdir/$cf_dir/modules" ; then
5208
5209		if test "x$cf_cv_make_PHONY" = xyes ; then
5210			cat >> Makefile <<-CF_EOF
5211
5212			.PHONY :	install.$cf_dir
5213			.PHONY :	uninstall.$cf_dir
5214CF_EOF
5215		fi
5216
5217		echo >> Makefile
5218		if test -f "$srcdir/$cf_dir/headers" ; then
5219cat >> Makefile <<CF_EOF
5220install.includes \\
5221uninstall.includes \\
5222CF_EOF
5223		fi
5224
5225cat >> Makefile <<CF_EOF
5226lint \\
5227libs \\
5228lintlib \\
5229install.libs \\
5230uninstall.libs \\
5231install.$cf_dir \\
5232uninstall.$cf_dir ::
5233	( cd "$cf_dir" && \${MAKE} \${TOP_MFLAGS} \[$]@ )
5234CF_EOF
5235	elif test -f "$srcdir/$cf_dir/headers" ; then
5236cat >> Makefile <<CF_EOF
5237
5238libs \\
5239install.libs \\
5240uninstall.libs \\
5241install.includes \\
5242uninstall.includes ::
5243	( cd "$cf_dir" && \${MAKE} \${TOP_MFLAGS} \[$]@ )
5244CF_EOF
5245fi
5246done
5247
5248if test "x$cf_cv_make_PHONY" = xyes ; then
5249	cat >> Makefile <<-CF_EOF
5250
5251	.PHONY :	install.data
5252	.PHONY :	uninstall.data
5253CF_EOF
5254fi
5255
5256if test "x$cf_with_db_install" = xyes; then
5257cat >> Makefile <<CF_EOF
5258
5259install.libs uninstall.libs \\
5260install.data uninstall.data ::
5261$MAKE_TERMINFO	( cd misc && \${MAKE} \${TOP_MFLAGS} \[$]@ )
5262CF_EOF
5263else
5264cat >> Makefile <<CF_EOF
5265
5266install.libs uninstall.libs ::
5267	( cd misc && \${MAKE} \${TOP_MFLAGS} \[$]@ )
5268CF_EOF
5269fi
5270
5271if test "x$cf_with_manpages" = xyes; then
5272
5273if test "x$cf_cv_make_PHONY" = xyes ; then
5274	cat >> Makefile <<-CF_EOF
5275
5276	.PHONY :	install.man
5277	.PHONY :	uninstall.man
5278CF_EOF
5279fi
5280
5281cat >> Makefile <<CF_EOF
5282
5283install.man \\
5284uninstall.man ::
5285	( cd man && \${MAKE} \${TOP_MFLAGS} \[$]@ )
5286CF_EOF
5287fi
5288
5289cat >> Makefile <<CF_EOF
5290
5291distclean ::
5292	rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
5293	rm -f headers.sh headers.sed mk_shared_lib.sh
5294	rm -f edit_man.* man_alias.* *.tmp
5295	rm -rf \${DIRS_TO_MAKE}
5296CF_EOF
5297
5298dnl If we're installing into a subdirectory of /usr/include, etc., we should
5299dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
5300dnl anything, and will make it more standardized.  It's awkward to decide this
5301dnl at configuration because of quoting, so we'll simply make all headers
5302dnl installed via a script that can do the right thing.
5303
5304rm -f headers.sed headers.sh
5305
5306dnl ( generating this script makes the makefiles a little tidier :-)
5307echo creating headers.sh
5308cat >headers.sh <<CF_EOF
5309#! $SHELL
5310# This shell script is generated by the 'configure' script.  It is invoked in a
5311# subdirectory of the build tree.  It generates a sed script in the parent
5312# directory that is used to adjust includes for header files that reside in a
5313# subdirectory of /usr/include, etc.
5314PRG=""
5315while test \[$]# != 3
5316do
5317PRG="\$PRG \[$]1"; shift
5318done
5319DST=\[$]1
5320REF=\[$]2
5321SRC=\[$]3
5322TMPSRC=\${TMPDIR:-/tmp}/\`basename \$SRC\`\$\$
5323TMPSED=\${TMPDIR:-/tmp}/headers.sed\$\$
5324echo installing \$SRC in \$DST
5325CF_EOF
5326
5327if test "$WITH_CURSES_H" = yes; then
5328	cat >>headers.sh <<CF_EOF
5329case \$DST in
5330($GLOB_FULLPATH_POSIX/include/*)
5331	END=\`basename \$DST\`
5332	for i in \`cat \$REF/../*/headers |${FGREP-fgrep} -v "#"\`
5333	do
5334		NAME=\`basename \$i\`
5335		echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
5336	done
5337	;;
5338(*)
5339	echo "" >> \$TMPSED
5340	;;
5341esac
5342CF_EOF
5343
5344else
5345	cat >>headers.sh <<CF_EOF
5346case \$DST in
5347($GLOB_FULLPATH_POSIX/include/*)
5348	END=\`basename \$DST\`
5349	for i in \`cat \$REF/../*/headers |${FGREP-fgrep} -v "#"\`
5350	do
5351		NAME=\`basename \$i\`
5352		if test "\$NAME" = "curses.h"
5353		then
5354			echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
5355			NAME=ncurses.h
5356		fi
5357		echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
5358	done
5359	;;
5360(*)
5361	echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
5362	;;
5363esac
5364CF_EOF
5365fi
5366cat >>headers.sh <<CF_EOF
5367rm -f \$TMPSRC
5368sed -f \$TMPSED \$SRC > \$TMPSRC
5369NAME=\`basename \$SRC\`
5370CF_EOF
5371if test "$WITH_CURSES_H" != yes; then
5372	cat >>headers.sh <<CF_EOF
5373test "\$NAME" = "curses.h" && NAME=ncurses.h
5374CF_EOF
5375fi
5376cat >>headers.sh <<CF_EOF
5377# Just in case someone gzip'd man pages, remove the conflicting copy.
5378test -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
5379
5380eval \$PRG \$TMPSRC \$DST/\$NAME
5381rm -f \$TMPSRC \$TMPSED
5382CF_EOF
5383
5384chmod 0755 headers.sh
5385
5386for cf_dir in $SRC_SUBDIRS
5387do
5388	if test ! -d "$srcdir/$cf_dir" ; then
5389		continue
5390	fi
5391
5392	if test -f "$srcdir/$cf_dir/headers" ; then
5393		$AWK -f "$srcdir/mk-hdr.awk" \
5394			subset="$LIB_SUBSETS" \
5395			compat="$WITH_CURSES_H" \
5396			"$srcdir/$cf_dir/headers" >>$cf_dir/Makefile
5397	fi
5398
5399	if test -f "$srcdir/$cf_dir/modules" ; then
5400		if test "$cf_dir" != "c++" ; then
5401			if test "x$cf_cv_make_PHONY" = xyes ; then
5402				cat >> $cf_dir/Makefile <<-CF_EOF
5403
5404				.PHONY :	depend
5405CF_EOF
5406			fi
5407
5408			cat >>$cf_dir/Makefile <<"CF_EOF"
5409depend : ${AUTO_SRC}
5410	makedepend -- ${CPPFLAGS} -- ${C_SRC}
5411
5412# DO NOT DELETE THIS LINE -- make depend depends on it.
5413CF_EOF
5414		fi
5415	fi
5416done
5417AC_SUBST(Libs_To_Make)
5418])dnl
5419dnl ---------------------------------------------------------------------------
5420dnl CF_LIB_SONAME version: 9 updated: 2021/01/04 18:48:01
5421dnl -------------
5422dnl Find the and soname for the given shared library.  Set the cache variable
5423dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
5424dnl variable to "unknown".
5425dnl
5426dnl $1 = headers
5427dnl $2 = code
5428dnl $3 = library name
5429AC_DEFUN([CF_LIB_SONAME],
5430[AC_REQUIRE([AC_PROG_FGREP])dnl
5431
5432AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
5433
5434cf_cv_$3_soname=unknown
5435if test "$cross_compiling" != yes ; then
5436cat >conftest.$ac_ext <<CF_EOF
5437$1
5438int main(void)
5439{
5440$2
5441	${cf_cv_main_return:-return}(0);
5442}
5443CF_EOF
5444cf_save_LIBS="$LIBS"
5445	CF_ADD_LIB($3)
5446	if AC_TRY_EVAL(ac_compile) ; then
5447		if AC_TRY_EVAL(ac_link) ; then
5448			cf_cv_$3_soname="`ldd \"conftest$ac_exeext\" 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | ${FGREP-fgrep} lib$3.`"
5449			test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
5450		fi
5451	fi
5452rm -rf ./conftest*
5453LIBS="$cf_save_LIBS"
5454fi
5455])
5456])
5457dnl ---------------------------------------------------------------------------
5458dnl CF_LIB_SUFFIX version: 28 updated: 2021/01/01 16:53:59
5459dnl -------------
5460dnl Compute the library file-suffix from the given model name
5461dnl $1 = model name
5462dnl $2 = variable to set (the nominal library suffix)
5463dnl $3 = dependency variable to set (actual filename)
5464dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
5465AC_DEFUN([CF_LIB_SUFFIX],
5466[
5467	case X$1 in
5468	(Xlibtool)
5469		$2='.la'
5470		$3=[$]$2
5471		;;
5472	(Xdebug)
5473		case "$cf_cv_system_name" in
5474		(*-msvc*)
5475			$2='_g.lib'
5476			;;
5477		(*)
5478			$2='_g.a'
5479			;;
5480		esac
5481		$3=[$]$2
5482		;;
5483	(Xprofile)
5484		case "$cf_cv_system_name" in
5485		(*-msvc*)
5486			$2='_p.lib'
5487			;;
5488		(*)
5489			$2='_p.a'
5490			;;
5491		esac
5492		$3=[$]$2
5493		;;
5494	(Xshared)
5495		case "$cf_cv_system_name" in
5496		(aix[[5-7]]*)
5497			$2='.so'
5498			$3=[$]$2
5499			;;
5500		(*-msvc*)
5501			$2='.dll'
5502			$3='.dll.lib'
5503			;;
5504		(cygwin*|msys*|mingw*)
5505			$2='.dll'
5506			$3='.dll.a'
5507			;;
5508		(darwin*)
5509			$2='.dylib'
5510			$3=[$]$2
5511			;;
5512		(hpux*)
5513			case "$target" in
5514			(ia64*)
5515				$2='.so'
5516				$3=[$]$2
5517				;;
5518			(*)
5519				$2='.sl'
5520				$3=[$]$2
5521				;;
5522			esac
5523			;;
5524		(*)
5525			$2='.so'
5526			$3=[$]$2
5527			;;
5528		esac
5529		;;
5530	(*)
5531		case "$target" in
5532		(*-msvc*)
5533			$2='.lib'
5534			;;
5535		(*)
5536			$2='.a'
5537			;;
5538		esac
5539		$3=[$]$2
5540		;;
5541	esac
5542	if test -n "${LIB_SUFFIX}${EXTRA_SUFFIX}"
5543	then
5544		$2="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$2}"
5545		$3="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$3}"
5546	fi
5547])dnl
5548dnl ---------------------------------------------------------------------------
5549dnl CF_LIB_TYPE version: 5 updated: 2015/04/17 21:13:04
5550dnl -----------
5551dnl Compute the string to append to -library from the given model name
5552dnl $1 = model name
5553dnl $2 = variable to set
5554dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
5555AC_DEFUN([CF_LIB_TYPE],
5556[
5557	case $1 in
5558	(libtool) $2=''   ;;
5559	(normal)  $2=''   ;;
5560	(debug)   $2='_g' ;;
5561	(profile) $2='_p' ;;
5562	(shared)  $2=''   ;;
5563	esac
5564	test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
5565])dnl
5566dnl ---------------------------------------------------------------------------
5567dnl CF_LINK_DATAONLY version: 17 updated: 2025/12/24 12:27:29
5568dnl ----------------
5569dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
5570dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
5571dnl have to provide wrappers for global tables to ensure they're linked
5572dnl properly.
5573AC_DEFUN([CF_LINK_DATAONLY],
5574[
5575AC_MSG_CHECKING([if data-only library module links])
5576AC_CACHE_VAL(cf_cv_link_dataonly,[
5577	rm -f conftest.a
5578	cat >conftest.$ac_ext <<EOF
5579#line __oline__ "configure"
5580int	testdata[[3]] = { 123, 456, 789 };
5581EOF
5582	if AC_TRY_EVAL(ac_compile) ; then
5583		mv conftest.$OBJEXT data.$OBJEXT && \
5584		( $AR $ARFLAGS conftest.a data.$OBJEXT ) 2>&AS_MESSAGE_LOG_FD 1>/dev/null
5585	fi
5586	rm -f conftest.$ac_ext data.$OBJEXT
5587	cat >conftest.$ac_ext <<EOF
5588#line __oline__ "configure"
5589extern int testfunc(void);
5590#if defined(NeXT)
5591int	testfunc(void)
5592{
5593	${cf_cv_main_return:-return}(1);	/* I'm told this linker is broken */
5594}
5595#else
5596extern int testdata[[3]];
5597int	testfunc(void)
5598{
5599	return testdata[[0]] == 123
5600	   &&  testdata[[1]] == 456
5601	   &&  testdata[[2]] == 789;
5602}
5603#endif
5604EOF
5605	if AC_TRY_EVAL(ac_compile); then
5606		mv conftest.$OBJEXT func.$OBJEXT && \
5607		( $AR $ARFLAGS conftest.a func.$OBJEXT ) 2>&AS_MESSAGE_LOG_FD 1>/dev/null
5608	fi
5609	rm -f conftest.$ac_ext func.$OBJEXT
5610	( eval $RANLIB conftest.a ) 2>&AS_MESSAGE_LOG_FD >/dev/null
5611	cf_saveLIBS="$LIBS"
5612	LIBS="conftest.a $LIBS"
5613	AC_TRY_RUN([
5614	extern int testfunc(void);
5615	int main(void)
5616	{
5617		${cf_cv_main_return:-return} (!testfunc());
5618	}
5619	],
5620	[cf_cv_link_dataonly=yes],
5621	[cf_cv_link_dataonly=no],
5622	[cf_cv_link_dataonly=unknown])
5623	LIBS="$cf_saveLIBS"
5624	])
5625AC_MSG_RESULT($cf_cv_link_dataonly)
5626
5627if test "$cf_cv_link_dataonly" = no ; then
5628	AC_DEFINE(BROKEN_LINKER,1,[if data-only library module does not link])
5629	BROKEN_LINKER=1
5630fi
5631AC_SUBST(BROKEN_LINKER)
5632
5633])dnl
5634dnl ---------------------------------------------------------------------------
5635dnl CF_LINK_FUNCS version: 14 updated: 2024/12/14 16:09:34
5636dnl -------------
5637dnl Most Unix systems have both link and symlink, a few don't have symlink.
5638dnl A few non-Unix systems implement symlink, but not link.
5639dnl A few non-systems implement neither (or have nonfunctional versions).
5640dnl
5641dnl This allows for a 2-second difference in modification times to allow for
5642dnl some marginal NFS implementations.
5643AC_DEFUN([CF_LINK_FUNCS],
5644[
5645AC_CHECK_HEADERS( \
5646unistd.h \
5647)
5648AC_CHECK_FUNCS( \
5649	remove \
5650	unlink )
5651
5652if test "$cross_compiling" = yes ; then
5653	AC_CHECK_FUNCS( \
5654		link \
5655		symlink )
5656else
5657	AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
5658		cf_cv_link_funcs=
5659		for cf_func in link symlink ; do
5660			AC_TRY_RUN([
5661$ac_includes_default
5662
5663int main(void)
5664{
5665	int fail = 0;
5666	char src[] = "conftest.tmp";
5667	char dst[] = "conftest.chk";
5668	struct stat src_sb, dst_sb;
5669	FILE *fp = fopen(src, "w");
5670	if (fp == NULL) { fail = 3; } else {
5671		fclose(fp); stat(src, &src_sb);
5672		if ($cf_func(src, dst) < 0) {
5673			fail = 1;
5674		} else if (stat(dst, &dst_sb) < 0) {
5675			fail = 2;
5676		} else {
5677			long diff = (dst_sb.st_mtime - src_sb.st_mtime);
5678			if (diff < 0) diff = -diff;
5679			if (diff > 2) fail = 3;
5680		}
5681	}
5682#ifdef HAVE_UNLINK
5683	unlink(dst); unlink(src);
5684#else
5685	remove(dst); remove(src);
5686#endif
5687	${cf_cv_main_return:-return} (fail);
5688}
5689			],[
5690			cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
5691			eval 'ac_cv_func_'$cf_func'=yes'],[
5692			eval 'ac_cv_func_'$cf_func'=no'],[
5693			eval 'ac_cv_func_'$cf_func'=error'])
5694		done
5695		test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
5696	])
5697	test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK,1,[Define to 1 if we have link() function])
5698	test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK,1,[Define to 1 if we have symlink() function])
5699fi
5700])dnl
5701dnl ---------------------------------------------------------------------------
5702dnl CF_MAKE_PHONY version: 4 updated: 2025/12/24 12:27:29
5703dnl -------------
5704dnl Check if the make-program handles a ".PHONY" target, e.g,. a target which
5705dnl acts as a placeholder.
5706dnl
5707dnl The ".PHONY" feature was proposed in 2011 here
5708dnl     https://www.austingroupbugs.net/view.php?id=523
5709dnl and is scheduled for release in P1003.1 Issue 8 (late 2022).
5710dnl
5711dnl This is not supported by SVr4 make (or SunOS 4, 4.3SD, etc), but works with
5712dnl a few others (i.e., GNU make and the non-POSIX "BSD" make):
5713dnl
5714dnl + This is a GNU make feature (since April 1988, but in turn from binutils,
5715dnl   date unspecified).
5716dnl
5717dnl + It was adopted in NetBSD make in June 1995.
5718dnl
5719dnl + The other BSD make programs are derived from the NetBSD make (and for
5720dnl   that reason are not actually different "implementations").
5721dnl
5722dnl + Some features of NetBSD make were actually adapted from pmake, which
5723dnl   began as a modified GNU make starting in 1993.
5724dnl
5725dnl + Version 3.8 of the dmake program in January 1992 also implemented this
5726dnl   GNU make extension, but is less well known than the BSD make.
5727AC_DEFUN([CF_MAKE_PHONY],[
5728AC_CACHE_CHECK(for \".PHONY\" make-support, cf_cv_make_PHONY,[
5729	rm -rf conftest*
5730	(
5731		mkdir conftest || exit 1
5732		cd conftest
5733		cat >makefile <<'CF_EOF'
5734.PHONY: always
5735DATA=0
5736always:	always.out
5737	@echo "** making [$]@ [$](DATA)"
5738once: once.out
5739	@echo "** making [$]@ [$](DATA)"
5740always.out:
5741	@echo "** making [$]@ [$](DATA)"
5742	echo [$](DATA) > [$]@
5743once.out:
5744	@echo "** making [$]@ [$](DATA)"
5745	echo [$](DATA) > [$]@
5746CF_EOF
5747		for cf_data in 1 2 3
5748		do
5749			${MAKE:-make} always DATA=$cf_data
5750			${MAKE:-make} once   DATA=$cf_data
5751			${MAKE:-make} -t always once
5752			if test -f always ; then
5753				echo "no (case 1)" > ../conftest.tmp
5754			elif test ! -f always.out ; then
5755				echo "no (case 2)" > ../conftest.tmp
5756			elif test ! -f once.out ; then
5757				echo "no (case 3)" > ../conftest.tmp
5758			elif ! cmp -s always.out once.out ; then
5759				echo "no (case 4)" > ../conftest.tmp
5760				diff always.out once.out
5761			else
5762				cf_check="`cat always.out`"
5763				if test "x$cf_check" != "x$cf_data" ; then
5764					echo "no (case 5)" > ../conftest.tmp
5765				else
5766					echo yes > ../conftest.tmp
5767					rm -f ./*.out
5768					continue
5769				fi
5770			fi
5771			break
5772		done
5773	) >&AS_MESSAGE_LOG_FD 2>&1
5774	cf_cv_make_PHONY="`cat conftest.tmp`"
5775	rm -rf conftest*
5776])
5777MAKE_NO_PHONY="#"
5778MAKE_PHONY="#"
5779test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY=
5780test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY=
5781AC_SUBST(MAKE_NO_PHONY)
5782AC_SUBST(MAKE_PHONY)
5783])dnl
5784dnl ---------------------------------------------------------------------------
5785dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
5786dnl ------------
5787dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
5788dnl a monocase filesystem.
5789AC_DEFUN([CF_MAKE_TAGS],[
5790AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
5791
5792AC_CHECK_PROGS(CTAGS, exctags ctags)
5793AC_CHECK_PROGS(ETAGS, exetags etags)
5794
5795AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
5796
5797if test "$cf_cv_mixedcase" = yes ; then
5798	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
5799else
5800	MAKE_UPPER_TAGS=no
5801fi
5802
5803if test "$MAKE_UPPER_TAGS" = yes ; then
5804	MAKE_UPPER_TAGS=
5805else
5806	MAKE_UPPER_TAGS="#"
5807fi
5808
5809if test "$MAKE_LOWER_TAGS" = yes ; then
5810	MAKE_LOWER_TAGS=
5811else
5812	MAKE_LOWER_TAGS="#"
5813fi
5814
5815AC_SUBST(CTAGS)
5816AC_SUBST(ETAGS)
5817
5818AC_SUBST(MAKE_UPPER_TAGS)
5819AC_SUBST(MAKE_LOWER_TAGS)
5820])dnl
5821dnl ---------------------------------------------------------------------------
5822dnl CF_MANPAGE_FORMAT version: 20 updated: 2025/11/11 20:09:36
5823dnl -----------------
5824dnl Option to allow user to override automatic configuration of man page format.
5825dnl There are several special cases:
5826dnl
5827dnl	compress - man checks for, can display compressed files
5828dnl	bzip2 - man checks for, can display bzip2'd files
5829dnl	gzip - man checks for, can display gzip'd files
5830dnl	xz - man checks for, can display xz'd files
5831dnl
5832dnl	BSDI - files in the cat-directories are suffixed ".0"
5833dnl	formatted - installer should format (put files in cat-directory)
5834dnl	catonly - installer should only format, e.g., for a turnkey system.
5835dnl
5836dnl There are other configurations which this macro does not test, e.g., HPUX's
5837dnl compressed man pages (but uncompressed man pages are fine, and HPUX's naming
5838dnl convention would not match our use).
5839AC_DEFUN([CF_MANPAGE_FORMAT],
5840[
5841AC_REQUIRE([CF_PATHSEP])
5842AC_MSG_CHECKING(format of man pages)
5843
5844AC_ARG_WITH(manpage-format,
5845	[  --with-manpage-format   specify man page format: gzip/compress/bzip2/xz,
5846                          BSDI/normal and optionally formatted/catonly,
5847                          e.g., gzip,formatted],
5848	[MANPAGE_FORMAT=$withval],
5849	[MANPAGE_FORMAT=unknown])
5850
5851test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
5852MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
5853
5854cf_unknown=
5855
5856case "$MANPAGE_FORMAT" in
5857(unknown)
5858	if test -z "$MANPATH" ; then
5859		MANPATH="/usr/man:/usr/share/man"
5860	fi
5861
5862	# look for the 'date' man page (it is most likely to be installed!)
5863	MANPAGE_FORMAT=
5864	cf_preform="no"
5865	cf_catonly="yes"
5866	cf_example="date"
5867
5868	IFS="${IFS:- 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
5869	for cf_dir in $MANPATH; do
5870		test -z "$cf_dir" && cf_dir=/usr/man
5871		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
5872		do
5873			cf_test=`echo "$cf_name" | sed -e 's/*//'`
5874			if test "x$cf_test" = "x$cf_name" ; then
5875
5876				case "$cf_name" in
5877				(*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";;
5878				(*.xz)  MANPAGE_FORMAT="$MANPAGE_FORMAT xz";;
5879				(*.gz)  MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
5880				(*.Z)   MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
5881				(*.0)   MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
5882				(*)     MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
5883				esac
5884
5885				case "$cf_name" in
5886				($cf_dir/man*)
5887					cf_catonly=no
5888					;;
5889				($cf_dir/cat*)
5890					cf_preform=yes
5891					;;
5892				esac
5893				break
5894			fi
5895
5896			# if we found a match in either man* or cat*, stop looking
5897			if test -n "$MANPAGE_FORMAT" ; then
5898				cf_found=no
5899				test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
5900				test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
5901				case "$cf_name" in
5902				($cf_dir/cat*)
5903					cf_found=yes
5904					;;
5905				esac
5906				test "$cf_found" = yes && break
5907			fi
5908		done
5909		# only check the first directory in $MANPATH where we find man pages
5910		if test -n "$MANPAGE_FORMAT" ; then
5911			break
5912		fi
5913	done
5914	# if we did not find the example, just assume it is normal
5915	test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
5916	IFS="$ac_save_ifs"
5917	;;
5918(*)
5919	for cf_option in $MANPAGE_FORMAT; do
5920	case "$cf_option" in
5921	(xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly)
5922		;;
5923	(*)
5924		cf_unknown="$cf_unknown $cf_option"
5925		;;
5926	esac
5927	done
5928	;;
5929esac
5930
5931AC_MSG_RESULT($MANPAGE_FORMAT)
5932if test -n "$cf_unknown" ; then
5933	AC_MSG_WARN(Unexpected man page format $cf_unknown)
5934fi
5935
5936cf_manpage_format=no
5937cf_manpage_inboth=no
5938cf_manpage_so_strip=
5939cf_manpage_compress=
5940cf_manpage_coptions=
5941
5942for cf_item in $MANPAGE_FORMAT
5943do
5944case "$cf_item" in
5945(catonly)
5946	cf_manpage_format=yes
5947	cf_manpage_inboth=no
5948	;;
5949(formatted)
5950	cf_manpage_format=yes
5951	cf_manpage_inboth=yes
5952	;;
5953(compress)
5954	cf_manpage_so_strip="Z"
5955	cf_manpage_compress=compress
5956	;;
5957(gzip)
5958	cf_manpage_so_strip="gz"
5959	cf_manpage_compress=gzip
5960	cf_manpage_coptions=-n
5961	;;
5962(bzip2)
5963	cf_manpage_so_strip="bz2"
5964	cf_manpage_compress=bzip2
5965	;;
5966(xz)
5967	cf_manpage_so_strip="xz"
5968	cf_manpage_compress=xz
5969	;;
5970esac
5971done
5972
5973AC_SUBST(cf_manpage_format)
5974AC_SUBST(cf_manpage_inboth)
5975AC_SUBST(cf_manpage_so_strip)
5976AC_SUBST(cf_manpage_compress)
5977AC_SUBST(cf_manpage_coptions)
5978
5979])dnl
5980dnl ---------------------------------------------------------------------------
5981dnl CF_MANPAGE_RENAMES version: 18 updated: 2025/11/11 20:09:36
5982dnl ------------------
5983dnl The Debian people have their own naming convention for man pages.  This
5984dnl option lets us override the name of the file containing renaming, or
5985dnl disable it altogether.
5986AC_DEFUN([CF_MANPAGE_RENAMES],
5987[
5988AC_MSG_CHECKING(for man page renaming)
5989
5990AC_ARG_WITH(manpage-renames,
5991	[  --with-manpage-renames  specify man page renaming],
5992	[MANPAGE_RENAMES=$withval],
5993	[MANPAGE_RENAMES=yes])
5994
5995case ".$MANPAGE_RENAMES" in
5996(.no)
5997	;;
5998(.|.yes)
5999	# Debian 'man' program?
6000	if test -f /etc/debian_version ; then
6001		MANPAGE_RENAMES=man/man_db.renames
6002	else
6003		MANPAGE_RENAMES=no
6004	fi
6005	;;
6006esac
6007
6008if test "$MANPAGE_RENAMES" = man/man_db.renames ; then
6009	MANPAGE_RENAMES=`pwd`/$MANPAGE_RENAMES
6010elif test "$MANPAGE_RENAMES" = no ; then
6011	:
6012elif test ! -f "$MANPAGE_RENAMES" ; then
6013	AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
6014fi
6015
6016AC_MSG_RESULT($MANPAGE_RENAMES)
6017AC_SUBST(MANPAGE_RENAMES)
6018])dnl
6019dnl ---------------------------------------------------------------------------
6020dnl CF_MANPAGE_SYMLINKS version: 8 updated: 2025/11/11 20:09:36
6021dnl -------------------
6022dnl Some people expect each tool to make all aliases for man pages in the
6023dnl man-directory.  This accommodates the older, less-capable implementations
6024dnl of 'man', and is optional.
6025AC_DEFUN([CF_MANPAGE_SYMLINKS],
6026[
6027AC_MSG_CHECKING(if man page aliases will be installed)
6028
6029AC_ARG_WITH(manpage-aliases,
6030	[  --with-manpage-aliases  specify man page aliases using .so],
6031	[MANPAGE_ALIASES=$withval],
6032	[MANPAGE_ALIASES=yes])
6033
6034AC_MSG_RESULT($MANPAGE_ALIASES)
6035
6036case "x$LN_S" in
6037(xln*)
6038	cf_use_symlinks=yes
6039	;;
6040(*)
6041	cf_use_symlinks=no
6042	;;
6043esac
6044
6045MANPAGE_SYMLINKS=no
6046if test "$MANPAGE_ALIASES" = yes ; then
6047AC_MSG_CHECKING(if man page symlinks should be used)
6048
6049AC_ARG_WITH(manpage-symlinks,
6050	[  --with-manpage-symlinks specify man page aliases using symlinks],
6051	[MANPAGE_SYMLINKS=$withval],
6052	[MANPAGE_SYMLINKS=$cf_use_symlinks])
6053
6054if test "$cf_use_symlinks" = no; then
6055if test "$MANPAGE_SYMLINKS" = yes ; then
6056	AC_MSG_WARN(cannot make symlinks, will use .so files)
6057	MANPAGE_SYMLINKS=no
6058fi
6059fi
6060
6061AC_MSG_RESULT($MANPAGE_SYMLINKS)
6062fi
6063
6064])dnl
6065dnl ---------------------------------------------------------------------------
6066dnl CF_MANPAGE_TBL version: 4 updated: 2025/11/11 20:09:36
6067dnl --------------
6068dnl This option causes man pages to be run through tbl(1) to generate tables
6069dnl correctly.
6070AC_DEFUN([CF_MANPAGE_TBL],
6071[
6072AC_MSG_CHECKING(for man page tbl)
6073
6074AC_ARG_WITH(manpage-tbl,
6075	[  --with-manpage-tbl      specify man page processing with tbl],
6076	[MANPAGE_TBL=$withval],
6077	[MANPAGE_TBL=no])
6078
6079AC_MSG_RESULT($MANPAGE_TBL)
6080])dnl
6081dnl ---------------------------------------------------------------------------
6082dnl CF_MAN_PAGES version: 64 updated: 2025/11/11 20:09:36
6083dnl ------------
6084dnl Try to determine if the man pages on the system are compressed, and if
6085dnl so, what format is used.  Use this information to construct a script that
6086dnl will install man pages.
6087AC_DEFUN([CF_MAN_PAGES],
6088[
6089AC_REQUIRE([CF_CHECK_TBL_X_OPTION])
6090CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
6091CF_MANPAGE_FORMAT
6092CF_MANPAGE_RENAMES
6093CF_MANPAGE_SYMLINKS
6094CF_MANPAGE_TBL
6095
6096if test "$prefix" = "NONE" ; then
6097	cf_prefix="$ac_default_prefix"
6098else
6099	cf_prefix="$prefix"
6100fi
6101
6102test ! -d man && mkdir man
6103
6104cf_edit_man=./edit_man.sh
6105cf_man_alias=`pwd`/man_alias.sed
6106
6107cat >$cf_edit_man <<CF_EOF
6108#!$SHELL
6109# generated by "configure" from the CF_MAN_PAGES macro in "aclocal.m4"
6110
6111prefix="$cf_prefix"
6112datarootdir="$datarootdir"
6113datadir="$datadir"
6114
6115NCURSES_MAJOR="$NCURSES_MAJOR"
6116NCURSES_MINOR="$NCURSES_MINOR"
6117NCURSES_PATCH="$NCURSES_PATCH"
6118
6119NCURSES_OSPEED="$NCURSES_OSPEED"
6120TERMINFO="$TERMINFO"
6121TERMINFO_DIRS="$TERMINFO_DIRS"
6122
6123INSTALL="$INSTALL"
6124INSTALL_DATA="$INSTALL_DATA"
6125
6126transform="$program_transform_name"
6127
6128TMP=\${TMPDIR:=/tmp}/man\$\$
6129trap "rm -f \$TMP; exit 1" 1 2 3 15
6130trap "rm -f \$TMP" 0
6131
6132form=\[$]1
6133shift || exit 1
6134
6135verb=\[$]1
6136shift || exit 1
6137
6138mandir=\[$]1
6139shift || exit 1
6140
6141srcdir=\[$]1
6142top_srcdir=\[$]srcdir/..
6143shift || exit 1
6144
6145if test "\$form" = normal ; then
6146	if test "$cf_manpage_format" = yes ; then
6147	if test "$cf_manpage_inboth" = no ; then
6148		$SHELL "\[$]0" format "\$verb" "\$mandir" "\$srcdir" "\[$]@"
6149		exit $?
6150	fi
6151	fi
6152	cf_subdir=\$mandir/man
6153	cf_tables=$MANPAGE_TBL
6154else
6155	cf_subdir=\$mandir/cat
6156	cf_tables=yes
6157fi
6158
6159# process the list of source-files
6160for i in "\[$]@" ; do
6161case \$i in
6162(*.orig|*.rej) ;;
6163(*.[[0-9]]*)
6164	section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
6165	if test "\$verb" = installing ; then
6166	if test ! -d "\$cf_subdir\${section}" ; then
6167		mkdir -p "\$cf_subdir\$section"
6168	fi
6169	fi
6170
6171	# replace variables in man page
6172	if test ! -f "$cf_man_alias" ; then
6173cat >>$cf_man_alias <<-CF_EOF2
6174		s,@DATADIR@,\$datadir,g
6175		s,@TERMINFO@,\${TERMINFO:="no default value"},g
6176		s,@TERMINFO_DIRS@,\${TERMINFO_DIRS:="no default value"},g
6177		s,@NCURSES_MAJOR@,\${NCURSES_MAJOR:="no default value"},g
6178		s,@NCURSES_MINOR@,\${NCURSES_MINOR:="no default value"},g
6179		s,@NCURSES_PATCH@,\${NCURSES_PATCH:="no default value"},g
6180		s,@NCURSES_OSPEED@,\${NCURSES_OSPEED:="no default value"},g
6181CF_EOF
6182	ifelse($1,,,[
6183	for cf_name in $1
6184	do
6185		cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
6186		cf_name=`echo "$cf_name" | sed "$program_transform_name"`
6187cat >>$cf_edit_man <<-CF_EOF
6188		s,@$cf_NAME@,$cf_name,g
6189CF_EOF
6190	done
6191	])
6192cat >>$cf_edit_man <<CF_EOF
6193CF_EOF2
6194		echo "...made $cf_man_alias"
6195	fi
6196
6197	aliases=
6198	cf_source=\`basename "\$i"\`
6199	cf_full_alias=\$cf_source
6200	test ! -f "\$cf_full_alias" && cf_full_alias="\$srcdir/\$cf_full_alias"
6201	if test ! -f "\$cf_full_alias" ; then
6202		echo ".. skipped \$cf_source"
6203		continue
6204	fi
6205CF_EOF
6206
6207if test "$MANPAGE_ALIASES" != no ; then
6208cat >>$cf_edit_man <<CF_EOF
6209	nCurses=ignore.3x
6210	cf_part_alias=\`echo \$cf_full_alias| sed -e 's,^.*/,,'\`
6211	test "$with_curses_h" = yes && nCurses=ncurses.3x
6212	aliases=\`sed -f "\$top_srcdir/man/manlinks.sed" "\$cf_full_alias" |sed -f "$cf_man_alias" | sort -u; test "\$cf_part_alias" = "\$nCurses" && echo curses\`
6213CF_EOF
6214fi
6215
6216if test "$MANPAGE_RENAMES" = no ; then
6217cat >>$cf_edit_man <<CF_EOF
6218	# perform program transformations for section 1 man pages
6219	if test \$section = 1 ; then
6220		cf_target=\$cf_subdir\${section}/\`echo \$cf_source|sed "\${transform}"\`
6221	else
6222		cf_target=\$cf_subdir\${section}/\$cf_source
6223	fi
6224CF_EOF
6225else
6226cat >>$cf_edit_man <<CF_EOF
6227	cf_target=\`grep "^\$cf_source" $MANPAGE_RENAMES | $AWK '{print \[$]2}'\`
6228	if test -z "\$cf_target" ; then
6229		echo "? missing rename for \$cf_source"
6230		cf_target="\$cf_source"
6231	fi
6232	cf_target="\$cf_subdir\${section}/\${cf_target}"
6233
6234CF_EOF
6235fi
6236
6237cat >>$cf_edit_man <<CF_EOF
6238	sed	-f "$cf_man_alias" \\
6239CF_EOF
6240
6241if test "$MANPAGE_RENAMES" != no ; then
6242cat >>$cf_edit_man <<CF_EOF
6243		< "\$i" | sed -f `pwd`/edit_man.sed >\$TMP
6244CF_EOF
6245else
6246cat >>$cf_edit_man <<CF_EOF
6247		< "\$i" >\$TMP
6248CF_EOF
6249fi
6250
6251cat >>$cf_edit_man <<CF_EOF
6252if test $cf_cv_tbl_x_option_okay != yes ; then
6253	# Remove column modifier 'x' from table descriptions if the
6254	# system's tbl(1) doesn't support it.
6255	sed -e '/^\.TS/,/\.$/s@x[[.]]@.@' \$TMP >\$TMP.unx
6256	mv \$TMP.unx \$TMP
6257fi
6258CF_EOF
6259
6260cat >>$cf_edit_man <<CF_EOF
6261if test \$cf_tables = yes ; then
6262	tbl \$TMP >\$TMP.out
6263	mv \$TMP.out \$TMP
6264fi
6265CF_EOF
6266
6267if test "$with_overwrite" != yes ; then
6268cat >>$cf_edit_man <<CF_EOF
6269	sed -e "/\\#[    ]*include/s,<curses.h,<ncurses$ABI_SUFFIX/curses.h," \
6270	    -e "/\\#[    ]*include/s,<term.h,<ncurses$ABI_SUFFIX/term.h," \
6271	    -e "/\\#[    ]*include/s,<form.h,<ncurses$ABI_SUFFIX/form.h," \
6272	    -e "/\\#[    ]*include/s,<menu.h,<ncurses$ABI_SUFFIX/menu.h," \
6273	    -e "/\\#[    ]*include/s,<panel.h,<ncurses$ABI_SUFFIX/panel.h," \
6274	    -e "/\\#[    ]*include/s,<unctrl.h,<ncurses$ABI_SUFFIX/unctrl.h," \
6275	  < \$TMP >\$TMP.out
6276	mv \$TMP.out \$TMP
6277CF_EOF
6278fi
6279
6280if test "$with_curses_h" != yes ; then
6281cat >>$cf_edit_man <<CF_EOF
6282	sed -e "/\\#[    ]*include/s,curses.h,ncurses.h," \
6283	  < \$TMP >\$TMP.out
6284	mv \$TMP.out \$TMP
6285CF_EOF
6286fi
6287
6288cat >>$cf_edit_man <<CF_EOF
6289	if test "\$form" = format ; then
6290		nroff -man \$TMP >\$TMP.out
6291		mv \$TMP.out \$TMP
6292	fi
6293CF_EOF
6294
6295if test -n "$cf_manpage_compress" ; then
6296cat >>$cf_edit_man <<CF_EOF
6297	if test "\$verb" = installing ; then
6298	if ( "$cf_manpage_compress" $cf_manpage_coptions -f \$TMP )
6299	then
6300		mv \$TMP.$cf_manpage_so_strip \$TMP
6301	fi
6302	fi
6303	cf_target="\$cf_target.$cf_manpage_so_strip"
6304CF_EOF
6305fi
6306
6307case "$MANPAGE_FORMAT" in
6308(*BSDI*)
6309cat >>$cf_edit_man <<CF_EOF
6310	if test "\$form" = format ; then
6311		# BSDI installs only .0 suffixes in the cat directories
6312		cf_target="\`echo \$cf_target|sed -e 's/\\.[[1-9]]\\+[[a-z]]*/.0/'\`"
6313	fi
6314CF_EOF
6315  ;;
6316esac
6317
6318cat >>$cf_edit_man <<CF_EOF
6319	suffix=\`basename "\$cf_target" | sed -e 's%^[[^.]]*%%'\`
6320	extra_suffix=
6321	if test -n "$EXTRA_SUFFIX" ; then
6322		case \$cf_target in
6323		(*${EXTRA_SUFFIX}\$suffix)
6324			extra_suffix="$EXTRA_SUFFIX"
6325			;;
6326		esac
6327	fi
6328	if test "\$verb" = installing ; then
6329		echo "\$verb \$cf_target"
6330		\$INSTALL_DATA \$TMP "\$cf_target"
6331		test -d "\$cf_subdir\${section}" &&
6332		test -n "\$aliases" && (
6333			cd "\$cf_subdir\${section}" && (
6334				cf_source=\`echo "\$cf_target" |sed -e 's%^.*/\\([[^/]][[^/]]*/[[^/]][[^/]]*$\\)%\\1%'\`
6335				test -n "$cf_manpage_so_strip" && cf_source=\`echo "\$cf_source" |sed -e 's%\\.$cf_manpage_so_strip\$%%'\`
6336				cf_target=\`basename "\$cf_target"\`
6337				for cf_alias in \$aliases
6338				do
6339					if test "\$section" = 1 ; then
6340						cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
6341					fi
6342					cf_alias="\${cf_alias}\${extra_suffix}"
6343
6344					if test "$MANPAGE_SYMLINKS" = yes ; then
6345						if test -f "\$cf_alias\${suffix}" ; then
6346							if ( cmp -s "\$cf_target" "\$cf_alias\${suffix}" )
6347							then
6348								continue
6349							fi
6350						fi
6351						echo ".. \$verb alias \$cf_alias\${suffix}"
6352CF_EOF
6353case "x$LN_S" in
6354(*-f)
6355cat >>$cf_edit_man <<CF_EOF
6356						$LN_S "\$cf_target" "\$cf_alias\${suffix}"
6357CF_EOF
6358	;;
6359(*)
6360cat >>$cf_edit_man <<CF_EOF
6361						rm -f "\$cf_alias\${suffix}"
6362						$LN_S "\$cf_target" "\$cf_alias\${suffix}"
6363CF_EOF
6364	;;
6365esac
6366cat >>$cf_edit_man <<CF_EOF
6367					elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
6368						echo ".so \$cf_source" >\$TMP
6369CF_EOF
6370if test -n "$cf_manpage_compress" ; then
6371cat >>$cf_edit_man <<CF_EOF
6372						if test -n "$cf_manpage_so_strip" ; then
6373							"$cf_manpage_compress" $cf_manpage_coptions -f \$TMP
6374							mv \$TMP.$cf_manpage_so_strip \$TMP
6375						fi
6376CF_EOF
6377fi
6378cat >>$cf_edit_man <<CF_EOF
6379						echo ".. \$verb alias \$cf_alias\${suffix}"
6380						rm -f "\$cf_alias\${suffix}"
6381						\$INSTALL_DATA \$TMP "\$cf_alias\${suffix}"
6382					fi
6383				done
6384			)
6385		)
6386	elif test "\$verb" = removing ; then
6387		test -f "\$cf_target" && (
6388			echo "\$verb \$cf_target"
6389			rm -f "\$cf_target"
6390		)
6391		test -d "\$cf_subdir\${section}" &&
6392		test -n "\$aliases" && (
6393			cd "\$cf_subdir\${section}" && (
6394				for cf_alias in \$aliases
6395				do
6396					if test "\$section" = 1 ; then
6397						cf_alias=\`echo "\$cf_alias" |sed "\${transform}"\`
6398					fi
6399					cf_alias="\${cf_alias}\${extra_suffix}"
6400
6401					echo ".. \$verb alias \$cf_alias\${suffix}"
6402					rm -f "\$cf_alias\${suffix}"
6403				done
6404			)
6405		)
6406	else
6407#		echo ".hy 0"
6408		cat \$TMP
6409	fi
6410	;;
6411esac
6412done
6413
6414if test "$cf_manpage_inboth" = yes ; then
6415if test "\$form" != format ; then
6416	$SHELL "\[$]0" format "\$verb" "\$mandir" "\$srcdir" "\[$]@"
6417fi
6418fi
6419
6420exit 0
6421CF_EOF
6422chmod 755 "$cf_edit_man"
6423
6424])dnl
6425dnl ---------------------------------------------------------------------------
6426dnl CF_MAP_LIB_BASENAME version: 2 updated: 2021/01/02 17:09:14
6427dnl -------------------
6428dnl Convert a default-libname to the actual one used via CF_WITH_LIB_BASENAME.
6429dnl
6430dnl $1 = variable to set
6431dnl $2 = default-libname
6432AC_DEFUN([CF_MAP_LIB_BASENAME],[
6433CF_UPPER(cf_map_lib_basename,$2)
6434eval $1="\$${cf_map_lib_basename}_NAME"
6435])dnl
6436dnl ---------------------------------------------------------------------------
6437dnl CF_MATH_LIB version: 12 updated: 2025/12/22 04:16:14
6438dnl -----------
6439dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
6440dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
6441dnl AC_CHECK_LIB(m,sin), because that fails for C++.
6442AC_DEFUN([CF_MATH_LIB],
6443[
6444AC_CACHE_CHECK(if -lm needed for math functions,
6445	cf_cv_need_libm,[
6446	AC_LINK_IFELSE([AC_LANG_PROGRAM([
6447		#include <stdio.h>
6448		#include <stdlib.h>
6449		#include <math.h>
6450	],
6451	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)])],
6452	[cf_cv_need_libm=no],
6453	[cf_cv_need_libm=yes])])
6454
6455if test "$cf_cv_need_libm" = yes
6456then
6457
6458	cf_save_LIBS="$LIBS"
6459	LIBS="$LIBS -lm"
6460	AC_CACHE_CHECK(if -lm is available for math functions,
6461	cf_cv_have_libm,[
6462	AC_LINK_IFELSE([AC_LANG_PROGRAM([
6463		#include <stdio.h>
6464		#include <stdlib.h>
6465		#include <math.h>
6466	],
6467	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)])],
6468	[cf_cv_have_libm=yes],
6469	[cf_cv_have_libm=no])])
6470	LIBS="$cf_save_LIBS"
6471
6472	if test "$cf_cv_have_libm" = yes
6473	then
6474		ifelse($1,,[CF_ADD_LIB(m)],[$1=-lm])
6475	fi
6476else
6477	cf_cv_have_libm=yes
6478fi
6479
6480if test "$cf_cv_have_libm" = yes
6481then
6482	AC_DEFINE(HAVE_MATH_FUNCS,1,[Define to 1 if math functions are available])
6483fi
6484])
6485dnl ---------------------------------------------------------------------------
6486dnl CF_MB_LEN_MAX version: 2 updated: 2025/12/24 12:27:29
6487dnl -------------
6488dnl Check if <limits.h> defines a usable MB_LEN_MAX.  That may be because it is
6489dnl not defined, or it may be a bogus value.
6490AC_DEFUN([CF_MB_LEN_MAX],[
6491AC_CACHE_CHECK(if MB_LEN_MAX is usable,cf_cv_mb_len_max,[
6492AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
6493$ac_includes_default
6494#include <limits.h>],
6495[
6496#if defined(MB_LEN_MAX) && MB_LEN_MAX >= 6
6497	${cf_cv_main_return:-return}(0);
6498#else
6499#error MB_LEN_MAX is not usable
6500#endif
6501])],	[cf_cv_mb_len_max=yes],
6502	[cf_cv_mb_len_max=no])])
6503if test "$cf_cv_mb_len_max" = yes
6504then
6505	AC_DEFINE(HAVE_CONSISTENT_MB_LEN_MAX,1,[Define to 1 if MB_LEN_MAX is usable])
6506else
6507	AC_MSG_WARN(MB_LEN_MAX is missing/inconsistent in system headers)
6508fi
6509])dnl
6510dnl ---------------------------------------------------------------------------
6511dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
6512dnl ----------------------
6513dnl Check if the file-system supports mixed-case filenames.  If we're able to
6514dnl create a lowercase name and see it as uppercase, it doesn't support that.
6515AC_DEFUN([CF_MIXEDCASE_FILENAMES],
6516[
6517AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
6518if test "$cross_compiling" = yes ; then
6519	case "$target_alias" in
6520	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
6521		cf_cv_mixedcase=no
6522		;;
6523	(*)
6524		cf_cv_mixedcase=yes
6525		;;
6526	esac
6527else
6528	rm -f conftest CONFTEST
6529	echo test >conftest
6530	if test -f CONFTEST ; then
6531		cf_cv_mixedcase=no
6532	else
6533		cf_cv_mixedcase=yes
6534	fi
6535	rm -f conftest CONFTEST
6536fi
6537])
6538test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
6539])dnl
6540dnl ---------------------------------------------------------------------------
6541dnl CF_MKSTEMP version: 14 updated: 2025/12/14 18:08:20
6542dnl ----------
6543dnl Check for a working mkstemp.  This creates two files, checks that they are
6544dnl successfully created and distinct (AmigaOS apparently fails on the last).
6545AC_DEFUN([CF_MKSTEMP],[
6546AC_CHECK_HEADERS( \
6547unistd.h \
6548)
6549AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
6550rm -rf ./conftest*
6551AC_RUN_IFELSE([AC_LANG_SOURCE([[
6552$ac_includes_default
6553
6554int main(void)
6555{
6556	static char tmpl[] = "conftestXXXXXX";
6557	char name[2][80];
6558	int n;
6559	int result = 0;
6560	int fd;
6561	struct stat sb;
6562
6563	umask(077);
6564	for (n = 0; n < 2; ++n) {
6565		strcpy(name[n], tmpl);
6566		if ((fd = mkstemp(name[n])) >= 0) {
6567			if (!strcmp(name[n], tmpl)
6568			 || stat(name[n], &sb) != 0
6569			 || (sb.st_mode & S_IFMT) != S_IFREG
6570			 || (sb.st_mode & 077) != 0) {
6571				result = 1;
6572			}
6573			close(fd);
6574		}
6575	}
6576	if (result == 0
6577	 && !strcmp(name[0], name[1]))
6578		result = 1;
6579	${cf_cv_main_return:-return}(result);
6580}
6581]])],[cf_cv_func_mkstemp=yes
6582],[cf_cv_func_mkstemp=no
6583],[cf_cv_func_mkstemp=maybe])
6584])
6585if test "x$cf_cv_func_mkstemp" = xmaybe ; then
6586	AC_CHECK_FUNC(mkstemp)
6587fi
6588if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
6589	AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
6590fi
6591])dnl
6592dnl ---------------------------------------------------------------------------
6593dnl CF_MSG_LOG version: 6 updated: 2025/12/14 17:51:46
6594dnl ----------
6595dnl Write a debug message to config.log, along with the line number in the
6596dnl configure script.
6597AC_DEFUN([CF_MSG_LOG],[
6598echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AS_MESSAGE_LOG_FD
6599])dnl
6600dnl ---------------------------------------------------------------------------
6601dnl CF_NCURSES_ABI_6 version: 5 updated: 2023/01/07 16:32:06
6602dnl ----------------
6603dnl Set ncurses' ABI to 6 unless overridden by explicit configure option, and
6604dnl warn about this.
6605AC_DEFUN([CF_NCURSES_ABI_6],[
6606if test "${with_abi_version+set}" != set; then
6607	case "$cf_cv_rel_version" in
6608	(5.*)
6609		cf_cv_rel_version=6.0
6610		cf_cv_abi_version=6
6611		cf_cv_abi_default=6
6612		AC_MSG_WARN(overriding ABI version to $cf_cv_abi_default)
6613		;;
6614	esac
6615fi
6616])dnl
6617dnl ---------------------------------------------------------------------------
6618dnl CF_NCURSES_WITH_ABI_VERSION version: 3 updated: 2021/01/01 13:31:04
6619dnl ---------------------------
6620dnl Allow ncurses's ABI to be overridden.  Generally this happens when a
6621dnl packager has incremented the ABI past that used in the original package,
6622dnl and wishes to keep doing this.
6623dnl
6624dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
6625dnl symbol.
6626AC_DEFUN([CF_NCURSES_WITH_ABI_VERSION],[
6627CF_WITH_ABI_VERSION($1)
6628if test "x$cf_cv_abi_version" != "x$with_abi_version"
6629then
6630	case "$cf_cv_rel_version" in
6631	(5.*)
6632		cf_cv_rel_version=$with_abi_version.0
6633		;;
6634	esac
6635fi
6636])dnl
6637dnl ---------------------------------------------------------------------------
6638dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
6639dnl ------------------
6640dnl see CF_WITH_NO_LEAKS
6641dnl
6642dnl $1 = option/name
6643dnl $2 = help-text
6644dnl $3 = symbol to define if the option is set
6645dnl $4 = additional actions to take if the option is set
6646AC_DEFUN([CF_NO_LEAKS_OPTION],[
6647AC_MSG_CHECKING(if you want to use $1 for testing)
6648AC_ARG_WITH($1,
6649	[$2],
6650	[case "x$withval" in
6651	(x|xno) ;;
6652	(*)
6653		: "${with_cflags:=-g}"
6654		: "${enable_leaks:=no}"
6655		with_$1=yes
6656		AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
6657	 $4
6658])
6659		;;
6660	esac],
6661	[with_$1=])
6662AC_MSG_RESULT(${with_$1:-no})
6663
6664case ".$with_cflags" in
6665(.*-g*)
6666	case .$CFLAGS in
6667	(.*-g*)
6668		;;
6669	(*)
6670		CF_ADD_CFLAGS([-g])
6671		;;
6672	esac
6673	;;
6674esac
6675])dnl
6676dnl ---------------------------------------------------------------------------
6677dnl CF_NUMBER_SYNTAX version: 3 updated: 2023/05/06 16:14:29
6678dnl ----------------
6679dnl Check if the given variable is a positive integer.  Report an error if not.
6680dnl $1 is the variable
6681dnl $2 is the message
6682AC_DEFUN([CF_NUMBER_SYNTAX],[
6683if test -n "$1" ; then
6684  case `echo "$1" | sed -e 's/^[[0-9]]*$/0/g'` in
6685  (0)
6686 	;;
6687  (*)
6688	AC_MSG_ERROR($2 is not a number: $1)
6689 	;;
6690  esac
6691else
6692  AC_MSG_ERROR($2 value is empty)
6693fi
6694])dnl
6695dnl ---------------------------------------------------------------------------
6696dnl CF_OBJ_SUBDIR version: 8 updated: 2021/01/01 13:31:04
6697dnl -------------
6698dnl Compute the object-directory name from the given model name
6699AC_DEFUN([CF_OBJ_SUBDIR],
6700[
6701	case $1 in
6702	(libtool) $2='obj_lo'  ;;
6703	(normal)  $2='objects' ;;
6704	(debug)   $2='obj_g' ;;
6705	(profile) $2='obj_p' ;;
6706	(shared)
6707		case "$cf_cv_system_name" in
6708		(cygwin|msys)
6709			$2='objects' ;;
6710		(*)
6711			$2='obj_s' ;;
6712		esac
6713	esac
6714])dnl
6715dnl ---------------------------------------------------------------------------
6716dnl CF_OUTPUT_MANPAGE_RENAMES version: 3 updated: 2025/11/11 20:09:36
6717dnl -------------------------
6718dnl This runs in the output step to config.status, after man_db.renames has
6719dnl been generated.
6720AC_DEFUN([CF_OUTPUT_MANPAGE_RENAMES],
6721[
6722AC_REQUIRE([CF_MANPAGE_RENAMES])
6723if test "$MANPAGE_RENAMES" != no ; then
6724	# Construct a sed script to perform renaming within man pages
6725	test -n "$verbose" && echo "creating edit_man.sed"
6726	test ! -d man && mkdir man
6727	FGREP="${FGREP-grep -F}" $SHELL "$srcdir/man/make_sed.sh" "$MANPAGE_RENAMES" >./edit_man.sed
6728fi
6729])dnl
6730dnl ---------------------------------------------------------------------------
6731dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
6732dnl ----------
6733dnl Provide a value for the $PATH and similar separator (or amend the value
6734dnl as provided in autoconf 2.5x).
6735AC_DEFUN([CF_PATHSEP],
6736[
6737	AC_MSG_CHECKING(for PATH separator)
6738	case "$cf_cv_system_name" in
6739	(os2*)	PATH_SEPARATOR=';'  ;;
6740	(*)	${PATH_SEPARATOR:=':'}  ;;
6741	esac
6742ifelse([$1],,,[$1=$PATH_SEPARATOR])
6743	AC_SUBST(PATH_SEPARATOR)
6744	AC_MSG_RESULT($PATH_SEPARATOR)
6745])dnl
6746dnl ---------------------------------------------------------------------------
6747dnl CF_PATH_PROG version: 12 updated: 2021/01/02 09:31:20
6748dnl ------------
6749dnl Check for a given program, defining corresponding symbol.
6750dnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
6751dnl	$2 = program name to find.
6752dnl	$3 = optional list of additional program names to test.
6753dnl $4 = $PATH
6754dnl
6755dnl If there is more than one token in the result, #define the remaining tokens
6756dnl to $1_ARGS.  We need this for 'install' in particular.
6757dnl
6758dnl FIXME: we should allow this to be overridden by environment variables
6759dnl
6760AC_DEFUN([CF_PATH_PROG],[
6761AC_REQUIRE([CF_PATHSEP])
6762test -z "[$]$1" && $1="$2"
6763AC_PATH_PROGS($1,[$]$1 $2 ifelse($3,,,$3),[$]$1, ifelse($4,,,$4))
6764
6765cf_path_prog=""
6766cf_path_args=""
6767IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
6768for cf_temp in $ac_cv_path_$1
6769do
6770	if test -z "$cf_path_prog" ; then
6771		if test "$with_full_paths" = yes ; then
6772			CF_PATH_SYNTAX(cf_temp,break)
6773			cf_path_prog="$cf_temp"
6774		else
6775			cf_path_prog="`basename "$cf_temp"`"
6776		fi
6777	elif test -z "$cf_path_args" ; then
6778		cf_path_args="$cf_temp"
6779	else
6780		cf_path_args="$cf_path_args $cf_temp"
6781	fi
6782done
6783IFS="$cf_save_ifs"
6784
6785if test -n "$cf_path_prog" ; then
6786	CF_MSG_LOG(defining path for ${cf_path_prog})
6787	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
6788	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
6789fi
6790])dnl
6791dnl ---------------------------------------------------------------------------
6792dnl CF_PATH_SYNTAX version: 20 updated: 2025/12/16 04:09:03
6793dnl --------------
6794dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
6795dnl begins with one of the prefix/exec_prefix variables, and then again if the
6796dnl result begins with 'NONE'.  This is necessary to work around autoconf's
6797dnl delayed evaluation of those symbols.
6798AC_DEFUN([CF_PATH_SYNTAX],[
6799AC_REQUIRE([CF_GLOB_FULLPATH])dnl
6800
6801if test "x$prefix" != xNONE; then
6802	cf_path_syntax="$prefix"
6803else
6804	cf_path_syntax="$ac_default_prefix"
6805fi
6806
6807case "x[$]$1" in
6808(x\[$]\(*\)*|x\'*\'*)
6809	;;
6810(x.|x$GLOB_FULLPATH_POSIX|x$GLOB_FULLPATH_OTHER)
6811	;;
6812(x\[$]\{*prefix\}*|x\[$]\{*dir\}*)
6813	eval $1="[$]$1"
6814	case "x[$]$1" in
6815	(xNONE/*)
6816		$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
6817		;;
6818	esac
6819	;;
6820(xno|xNONE/*)
6821	$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
6822	;;
6823(*)
6824	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not "[$]$1"])],$2)
6825	;;
6826esac
6827])dnl
6828dnl ---------------------------------------------------------------------------
6829dnl CF_PKG_CONFIG version: 13 updated: 2023/10/28 11:59:01
6830dnl -------------
6831dnl Check for the package-config program, unless disabled by command-line.
6832dnl
6833dnl Sets $PKG_CONFIG to the pathname of the pkg-config program.
6834AC_DEFUN([CF_PKG_CONFIG],
6835[
6836AC_MSG_CHECKING(if you want to use pkg-config)
6837AC_ARG_WITH(pkg-config,
6838	[[  --with-pkg-config[=CMD] enable/disable use of pkg-config and its name CMD]],
6839	[cf_pkg_config=$withval],
6840	[cf_pkg_config=yes])
6841AC_MSG_RESULT($cf_pkg_config)
6842
6843case "$cf_pkg_config" in
6844(no)
6845	PKG_CONFIG=none
6846	;;
6847(yes)
6848	CF_ACVERSION_CHECK(2.52,
6849		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
6850		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
6851	;;
6852(*)
6853	PKG_CONFIG=$withval
6854	;;
6855esac
6856
6857test -z "$PKG_CONFIG" && PKG_CONFIG=none
6858if test "$PKG_CONFIG" != none ; then
6859	CF_PATH_SYNTAX(PKG_CONFIG)
6860elif test "x$cf_pkg_config" != xno ; then
6861	AC_MSG_WARN(pkg-config is not installed)
6862fi
6863
6864AC_SUBST(PKG_CONFIG)
6865])dnl
6866dnl ---------------------------------------------------------------------------
6867dnl CF_POSIX_C_SOURCE version: 13 updated: 2025/12/14 17:40:20
6868dnl -----------------
6869dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
6870dnl
6871dnl	POSIX.1-1990				_POSIX_SOURCE
6872dnl	POSIX.1-1990 and			_POSIX_SOURCE and
6873dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
6874dnl		Bindings Option
6875dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
6876dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
6877dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
6878dnl
6879dnl Parameters:
6880dnl	$1 is the nominal value for _POSIX_C_SOURCE
6881AC_DEFUN([CF_POSIX_C_SOURCE],
6882[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
6883
6884if test "$cf_cv_posix_visible" = no; then
6885
6886cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
6887
6888cf_save_CFLAGS="$CFLAGS"
6889cf_save_CPPFLAGS="$CPPFLAGS"
6890
6891CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
6892CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
6893
6894AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
6895	CF_MSG_LOG(if the symbol is already defined go no further)
6896	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
6897#ifndef _POSIX_C_SOURCE
6898#error _POSIX_C_SOURCE is not defined
6899#endif])],
6900	[cf_cv_posix_c_source=no],
6901	[cf_want_posix_source=no
6902	 case .$cf_POSIX_C_SOURCE in
6903	 (.[[12]]??*)
6904		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
6905		;;
6906	 (.2)
6907		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
6908		cf_want_posix_source=yes
6909		;;
6910	 (.*)
6911		cf_want_posix_source=yes
6912		;;
6913	 esac
6914	 if test "$cf_want_posix_source" = yes ; then
6915		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
6916#ifdef _POSIX_SOURCE
6917#error _POSIX_SOURCE is defined
6918#endif])],[],
6919		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
6920	 fi
6921	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
6922	 CFLAGS="$cf_trim_CFLAGS"
6923	 CPPFLAGS="$cf_trim_CPPFLAGS"
6924	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
6925	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
6926	 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>],[
6927#ifndef _POSIX_C_SOURCE
6928#error _POSIX_C_SOURCE is not defined
6929#endif])],,
6930	 [cf_cv_posix_c_source=no])
6931	 CFLAGS="$cf_save_CFLAGS"
6932	 CPPFLAGS="$cf_save_CPPFLAGS"
6933	])
6934])
6935
6936if test "$cf_cv_posix_c_source" != no ; then
6937	CFLAGS="$cf_trim_CFLAGS"
6938	CPPFLAGS="$cf_trim_CPPFLAGS"
6939	CF_ADD_CFLAGS($cf_cv_posix_c_source)
6940fi
6941
6942fi # cf_cv_posix_visible
6943
6944])dnl
6945dnl ---------------------------------------------------------------------------
6946dnl CF_POSIX_VISIBLE version: 2 updated: 2025/12/14 17:40:20
6947dnl ----------------
6948dnl POSIX documents test-macros which an application may set before any system
6949dnl headers are included to make features available.
6950dnl
6951dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
6952dnl diverged from POSIX in 2002 by setting symbols which make all of the most
6953dnl recent features visible in the system header files unless the application
6954dnl overrides the corresponding test-macros.  Doing that introduces portability
6955dnl problems.
6956dnl
6957dnl This macro makes a special check for the symbols used for this, to avoid a
6958dnl conflicting definition.
6959AC_DEFUN([CF_POSIX_VISIBLE],
6960[
6961AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
6962AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],[
6963#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
6964	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
6965	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
6966	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
6967#error conflicting symbols found
6968#endif
6969])],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
6970])
6971])dnl
6972dnl ---------------------------------------------------------------------------
6973dnl CF_PREDEFINE version: 4 updated: 2025/12/24 12:27:29
6974dnl ------------
6975dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
6976dnl
6977dnl $1 = symbol to test
6978dnl $2 = value (if any) to use for a predefinition
6979AC_DEFUN([CF_PREDEFINE],
6980[
6981AC_MSG_CHECKING(if we must define $1)
6982AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
6983],[
6984#ifndef $1
6985#error $1 is not defined
6986#endif])],[cf_result=no],[cf_result=yes])
6987AC_MSG_RESULT($cf_result)
6988
6989if test "$cf_result" = yes ; then
6990	CPPFLAGS="$CPPFLAGS ifelse([$2],,-D$1,[-D$1=$2])"
6991elif test "x$2" != "x" ; then
6992	AC_MSG_CHECKING(checking for compatible value versus $2)
6993	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
6994],[
6995#if $1-$2 < 0
6996#error $1-$2 is negative
6997#endif])],[cf_result=yes],[cf_result=no])
6998	AC_MSG_RESULT($cf_result)
6999	if test "$cf_result" = no ; then
7000		# perhaps we can override it - try...
7001		CPPFLAGS="$CPPFLAGS -D$1=$2"
7002	fi
7003fi
7004])dnl
7005dnl ---------------------------------------------------------------------------
7006dnl CF_PRG_RULES version: 2 updated: 2021/01/01 13:31:04
7007dnl ------------
7008dnl Append definitions and rules for the given programs to the subdirectory
7009dnl Makefiles, and the recursion rule for the top-level Makefile.
7010dnl
7011dnl parameters
7012dnl	$1 = script to run
7013dnl	$2 = list of subdirectories
7014dnl
7015dnl variables
7016dnl	$AWK
7017AC_DEFUN([CF_PRG_RULES],
7018[
7019for cf_dir in $2
7020do
7021	if test ! -d "$srcdir/$cf_dir" ; then
7022		continue
7023	elif test -f "$srcdir/$cf_dir/programs" ; then
7024		$AWK -f $1 "$srcdir/$cf_dir/programs" >>$cf_dir/Makefile
7025	fi
7026done
7027
7028])dnl
7029dnl ---------------------------------------------------------------------------
7030dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
7031dnl ----------
7032dnl Check for archiver "ar".
7033AC_DEFUN([CF_PROG_AR],[
7034AC_CHECK_TOOL(AR, ar, ar)
7035])
7036dnl ---------------------------------------------------------------------------
7037dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
7038dnl -----------
7039dnl Check for awk, ensure that the check found something.
7040AC_DEFUN([CF_PROG_AWK],
7041[
7042AC_PROG_AWK
7043test -z "$AWK" && AC_MSG_ERROR(No awk program found)
7044])dnl
7045dnl ---------------------------------------------------------------------------
7046dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
7047dnl ----------
7048dnl standard check for CC, plus followup sanity checks
7049dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
7050AC_DEFUN([CF_PROG_CC],[
7051CF_ACVERSION_CHECK(2.53,
7052	[AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
7053	 AC_REQUIRE([AC_PROG_CC])],
7054	[])
7055ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
7056CF_GCC_VERSION
7057CF_ACVERSION_CHECK(2.52,
7058	[AC_PROG_CC_STDC],
7059	[CF_ANSI_CC_REQD])
7060CF_CC_ENV_FLAGS
7061])dnl
7062dnl ---------------------------------------------------------------------------
7063dnl CF_PROG_CC_C_O version: 7 updated: 2025/12/24 12:27:29
7064dnl --------------
7065dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
7066dnl the output file can be renamed, and allows for a shell variable that can
7067dnl be used later.  The parameter is either CC or CXX.  The result is the
7068dnl cache variable:
7069dnl	$cf_cv_prog_CC_c_o
7070dnl	$cf_cv_prog_CXX_c_o
7071dnl
7072dnl $1 = compiler
7073dnl $2 = compiler options, if any
7074AC_DEFUN([CF_PROG_CC_C_O],
7075[AC_REQUIRE([AC_PROG_CC])dnl
7076AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
7077AC_CACHE_VAL(cf_cv_prog_$1_c_o,
7078[
7079cat > conftest.$ac_ext <<CF_EOF
7080int main(void)
7081{
7082	${cf_cv_main_return:-return}(0);
7083}
7084CF_EOF
7085# We do the test twice because some compilers refuse to overwrite an
7086# existing .o file with -o, though they will create one.
7087ac_try='[$]$1 $2 -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
7088if AC_TRY_EVAL(ac_try) &&
7089  test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
7090then
7091  eval cf_cv_prog_$1_c_o=yes
7092else
7093  eval cf_cv_prog_$1_c_o=no
7094fi
7095rm -rf ./conftest*
7096])dnl
7097if test "$cf_cv_prog_$1_c_o" = yes; then
7098  AC_MSG_RESULT([yes])
7099else
7100  AC_MSG_RESULT([no])
7101fi
7102])dnl
7103dnl ---------------------------------------------------------------------------
7104dnl CF_PROG_GNAT version: 13 updated: 2025/12/24 12:27:29
7105dnl ------------
7106dnl Check for gnat/gnatmake/etc, ensure that the toolset is complete.
7107AC_DEFUN([CF_PROG_GNAT],[
7108for cf_prog_gnat in gnat gnatmake gprconfig gprbuild
7109do
7110	CF_UPPER(cf_upper_prog_gnat,${cf_prog_gnat})
7111
7112	unset ac_cv_path_cf_TEMP_gnat
7113	unset cf_TEMP_gnat
7114	AC_PATH_PROG(cf_TEMP_gnat,$cf_prog_gnat,no)
7115	eval "cf_cv_PATH_$cf_upper_prog_gnat=[$]ac_cv_path_cf_TEMP_gnat"
7116
7117	if test "x$cf_TEMP_gnat" != xno; then
7118		unset cf_cv_gnat_version
7119		unset cf_TEMP_gnat
7120		CF_GNAT_VERSION(cf_TEMP_gnat,$cf_prog_gnat)
7121	fi
7122	eval "cf_cv_VERSION_$cf_upper_prog_gnat=[$]cf_TEMP_gnat"
7123
7124	unset cf_TEMP_gnat
7125	unset cf_cv_gnat_version
7126	unset ac_cv_path_cf_TEMP_gnat
7127done
7128
7129if test "x$cf_cv_VERSION_GNATMAKE" = "xno"; then
7130	cf_ada_make=
7131	cf_cv_prog_gnat_correct=no
7132else
7133	cf_ada_make=gnatmake
7134	if test "x$cf_cv_VERSION_GPRCONFIG" = "xno"; then
7135		# gprconfig is newer than gnatmake; we can continue...
7136		cf_ada_config="##"
7137	else
7138		rm -rf ./conftest* ./*~conftest*
7139		if mkdir conftest.src
7140		then
7141			cf_ada_config=""
7142			cd conftest.src
7143			for cf_gprconfig in Ada C
7144			do
7145				AC_MSG_CHECKING(for gprconfig name for $cf_gprconfig)
7146				if test "$cf_gprconfig" = C
7147				then
7148					for cf_gprconfig_param in \
7149						"$cf_gprconfig,,,,GNATGCC" \
7150						"$cf_gprconfig,,,,GCC" \
7151						"$cf_gprconfig"
7152					do
7153						cf_gprconfig_value=`echo s| gprconfig --config=$cf_gprconfig_param 2>&AS_MESSAGE_LOG_FD | ${AWK:-awk} '/^\*/{print [$]3;}' | head -n 1`
7154						test -n "$cf_gprconfig_value" && break
7155					done
7156				else
7157					cf_gprconfig_param=$cf_gprconfig
7158					cf_gprconfig_value=`echo s| gprconfig --config=$cf_gprconfig_param 2>&AS_MESSAGE_LOG_FD | ${AWK:-awk} '/^\*/{print [$]3;}' | head -n 1`
7159				fi
7160				if test -n "$cf_gprconfig_value"
7161				then
7162					eval "cf_ada_config_[$]cf_gprconfig=[$]cf_gprconfig_value"
7163					AC_MSG_RESULT($cf_gprconfig_value)
7164				else
7165					AC_MSG_RESULT(missing)
7166					cf_ada_config="#"
7167					break
7168				fi
7169			done
7170			cd ..
7171			rm -rf ./conftest* ./*~conftest*
7172		fi
7173	fi
7174	if test "x$cf_ada_config" != "x#"
7175	then
7176		CF_GNAT_VERSION
7177		CF_CHECK_GNAT_VERSION
7178		AC_CHECK_PROG(M4_exists, m4, yes, no)
7179		if test "$ac_cv_prog_M4_exists" = no; then
7180			cf_cv_prog_gnat_correct=no
7181			AC_MSG_WARN(Ada95 binding required program m4 not found. Ada95 binding disabled)
7182		fi
7183		if test "$cf_cv_prog_gnat_correct" = yes; then
7184			AC_MSG_CHECKING(if GNAT works)
7185			CF_GNAT_TRY_RUN([procedure conftest;],
7186[with Text_IO;
7187with GNAT.OS_Lib;
7188procedure conftest is
7189begin
7190   Text_IO.Put ("Hello World");
7191   Text_IO.New_Line;
7192   GNAT.OS_Lib.OS_Exit (0);
7193end conftest;],
7194[cf_cv_prog_gnat_correct=yes],
7195[cf_cv_prog_gnat_correct=no])
7196			AC_MSG_RESULT($cf_cv_prog_gnat_correct)
7197		fi
7198	else
7199		cf_cv_prog_gnat_correct=no
7200	fi
7201fi
7202
7203AC_SUBST(cf_ada_make)
7204AC_SUBST(cf_ada_config)
7205AC_SUBST(cf_ada_config_Ada)
7206AC_SUBST(cf_ada_config_C)
7207])dnl
7208dnl ---------------------------------------------------------------------------
7209dnl CF_PROG_INSTALL version: 13 updated: 2025/10/21 16:28:49
7210dnl ---------------
7211dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
7212dnl misc/tabset install won't work properly.  Usually this happens only when
7213dnl using the fallback mkinstalldirs script
7214AC_DEFUN([CF_PROG_INSTALL],
7215[AC_PROG_INSTALL
7216AC_REQUIRE([CF_GLOB_FULLPATH])dnl
7217if test "x$INSTALL" = "x./install-sh -c"; then
7218	if test -f /usr/sbin/install ; then
7219		case "$host_os" in
7220		(linux*gnu*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
7221			INSTALL=/usr/sbin/install
7222			;;
7223		esac
7224	fi
7225fi
7226case x$INSTALL in
7227(x$GLOB_FULLPATH_POSIX|x$GLOB_FULLPATH_OTHER)
7228	;;
7229(*)
7230	CF_DIRNAME(cf_dir,$INSTALL)
7231	test -z "$cf_dir" && cf_dir=.
7232	INSTALL="`cd \"$cf_dir\" && pwd`"/"`echo "$INSTALL" | sed -e 's%^.*/%%'`"
7233	;;
7234esac
7235])dnl
7236dnl ---------------------------------------------------------------------------
7237dnl CF_PROG_LDCONFIG version: 5 updated: 2015/04/18 08:56:57
7238dnl ----------------
7239dnl Check for ldconfig, needed to fixup shared libraries that would be built
7240dnl and then used in the install.
7241AC_DEFUN([CF_PROG_LDCONFIG],[
7242if test "$cross_compiling" = yes ; then
7243	LDCONFIG=:
7244else
7245	case "$cf_cv_system_name" in
7246	(dragonfly*|mirbsd*|freebsd*)
7247		test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
7248		;;
7249	(*) LDPATH=$PATH:/sbin:/usr/sbin
7250		AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
7251		;;
7252	esac
7253fi
7254AC_SUBST(LDCONFIG)
7255])dnl
7256dnl ---------------------------------------------------------------------------
7257dnl CF_PROG_LINT version: 7 updated: 2024/11/30 14:37:45
7258dnl ------------
7259AC_DEFUN([CF_PROG_LINT],
7260[
7261AC_CHECK_PROGS(LINT, lint cppcheck splint)
7262case "x$LINT" in
7263(xlint|x*/lint) # NetBSD 10
7264	test -z "$LINT_OPTS" && LINT_OPTS="-chapbrxzgFS -v -Ac11"
7265	;;
7266(xcppcheck|x*/cppcheck)
7267	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all -D__CPPCHECK__"
7268	;;
7269esac
7270AC_SUBST(LINT_OPTS)
7271AC_SUBST(LINT_LIBS)
7272])dnl
7273dnl ---------------------------------------------------------------------------
7274dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
7275dnl ------------
7276dnl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
7277dnl option if it is supported.
7278AC_DEFUN([CF_PROG_LN_S],[
7279AC_PROG_LN_S
7280AC_MSG_CHECKING(if $LN_S -f options work)
7281
7282rm -f conf$$.src conf$$dst
7283echo >conf$$.dst
7284echo first >conf$$.src
7285if $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
7286	cf_prog_ln_sf=yes
7287else
7288	cf_prog_ln_sf=no
7289fi
7290rm -f conf$$.dst conf$$src
7291AC_MSG_RESULT($cf_prog_ln_sf)
7292
7293test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
7294])dnl
7295dnl ---------------------------------------------------------------------------
7296dnl CF_PROG_TBL version: 1 updated: 2025/11/01 18:43:38
7297dnl -----------
7298dnl Allow the "tbl" program to be configured.
7299dnl "TBL" is too short, and likely to conflict.
7300AC_DEFUN([CF_PROG_TBL],[
7301AC_PATH_PROG(NROFF_TBL,tbl)
7302])dnl
7303dnl ---------------------------------------------------------------------------
7304dnl CF_REGEX version: 20 updated: 2025/12/24 12:27:29
7305dnl --------
7306dnl Attempt to determine if we've got one of the flavors of regular-expression
7307dnl code that we can support.
7308AC_DEFUN([CF_REGEX],
7309[
7310
7311cf_regex_func=no
7312cf_regex_libs=
7313case "$host_os" in
7314(mingw*)
7315	# -lsystre -ltre -lintl -liconv
7316	AC_CHECK_LIB(systre,regcomp,[
7317		AC_CHECK_LIB(iconv,libiconv_open,[CF_ADD_LIB(iconv)])
7318		AC_CHECK_LIB(intl,libintl_gettext,[CF_ADD_LIB(intl)])
7319		AC_CHECK_LIB(tre,tre_regcomp,[CF_ADD_LIB(tre)])
7320		CF_ADD_LIB(systre)
7321		cf_regex_func=regcomp
7322	],[
7323		AC_CHECK_LIB(gnurx,regcomp,[
7324			CF_ADD_LIB(gnurx)
7325			cf_regex_func=regcomp])
7326	])
7327	;;
7328(*)
7329	cf_regex_libs="regex re"
7330	AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
7331		for cf_regex_lib in $cf_regex_libs
7332		do
7333			AC_CHECK_LIB($cf_regex_lib,regcomp,[
7334					CF_ADD_LIB($cf_regex_lib)
7335					cf_regex_func=regcomp
7336					break])
7337		done
7338	])
7339	;;
7340esac
7341
7342if test "$cf_regex_func" = no ; then
7343	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
7344		AC_CHECK_LIB(gen,compile,[
7345				CF_ADD_LIB(gen)
7346				cf_regex_func=compile])])
7347fi
7348
7349if test "$cf_regex_func" = no ; then
7350	AC_MSG_WARN(cannot find regular expression library)
7351fi
7352
7353AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
7354
7355cf_cv_regex_hdrs=no
7356case "$cf_regex_func" in
7357(compile)
7358	for cf_regex_hdr in regexp.h regexpr.h
7359	do
7360		AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <$cf_regex_hdr>],[
7361			char *p = compile("", "", "", 0);
7362			int x = step("", "");
7363			(void)p;
7364			(void)x;
7365		])],[
7366			cf_cv_regex_hdrs=$cf_regex_hdr
7367			break
7368		])
7369	done
7370	;;
7371(*)
7372	for cf_regex_hdr in regex.h
7373	do
7374		AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
7375#include <stdio.h>
7376#include <$cf_regex_hdr>],[
7377			regex_t *p = NULL;
7378			int x = regcomp(p, "", 0);
7379			int y = regexec(p, "", 0, 0, 0);
7380			(void)x;
7381			(void)y;
7382			regfree(p);
7383		])],[
7384			cf_cv_regex_hdrs=$cf_regex_hdr
7385			break
7386		])
7387	done
7388	;;
7389esac
7390
7391])
7392
7393case "$cf_cv_regex_hdrs" in
7394	(no)		AC_MSG_WARN(no regular expression header found) ;;
7395	(regex.h)	AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;;
7396	(regexp.h)	AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;;
7397	(regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
7398esac
7399])dnl
7400dnl ---------------------------------------------------------------------------
7401dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40
7402dnl ----------------
7403dnl Remove a given option from CFLAGS/CPPFLAGS
7404dnl $1 = option to remove
7405dnl $2 = variable to update
7406dnl $3 = nonempty to allow verbose message
7407define([CF_REMOVE_CFLAGS],
7408[
7409cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
7410while true
7411do
7412	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'`
7413	test "[$]$2" != "$cf_old_cflag" || break
7414	ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
7415	$2="$cf_old_cflag"
7416done
7417])dnl
7418dnl ---------------------------------------------------------------------------
7419dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
7420dnl ----------------
7421dnl Remove all -U and -D options that refer to the given symbol from a list
7422dnl of C compiler options.  This works around the problem that not all
7423dnl compilers process -U and -D options from left-to-right, so a -U option
7424dnl cannot be used to cancel the effect of a preceding -D option.
7425dnl
7426dnl $1 = target (which could be the same as the source variable)
7427dnl $2 = source (including '$')
7428dnl $3 = symbol to remove
7429define([CF_REMOVE_DEFINE],
7430[
7431$1=`echo "$2" | \
7432	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
7433		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
7434])dnl
7435dnl ---------------------------------------------------------------------------
7436dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
7437dnl -------------
7438dnl Remove the given library from the symbol
7439dnl
7440dnl $1 = target (which could be the same as the source variable)
7441dnl $2 = source (including '$')
7442dnl $3 = library to remove
7443define([CF_REMOVE_LIB],
7444[
7445# remove $3 library from $2
7446$1=`echo "$2" | sed -e 's/-l$3[[ 	]]//g' -e 's/-l$3[$]//'`
7447])dnl
7448dnl ---------------------------------------------------------------------------
7449dnl CF_REQUIRE_PKG version: 1 updated: 2025/01/10 19:55:54
7450dnl --------------
7451dnl Update $REQUIRE_PKG, which lists the known required packages for this
7452dnl program.
7453dnl
7454dnl $1 = package(s) to require, e.g., in the generated ".pc" file
7455define([CF_REQUIRE_PKG],
7456[
7457for cf_required in $1
7458do
7459	# check for duplicates
7460	for cf_require_pkg in $REQUIRE_PKG
7461	do
7462		if test "$cf_required" = "$cf_require_pkg"
7463		then
7464			cf_required=
7465			break
7466		fi
7467	done
7468	test -n "$cf_required" && REQUIRE_PKG="$REQUIRE_PKG $cf_required"
7469done
7470AC_SUBST(REQUIRE_PKG)
7471])dnl
7472dnl ---------------------------------------------------------------------------
7473dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
7474dnl ---------------------
7475dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
7476dnl $1 = name of current macro
7477define([CF_RESTORE_XTRA_FLAGS],
7478[
7479LIBS="$cf_save_LIBS_$1"
7480CFLAGS="$cf_save_CFLAGS_$1"
7481CPPFLAGS="$cf_save_CPPFLAGS_$1"
7482])dnl
7483dnl ---------------------------------------------------------------------------
7484dnl CF_RPATH_HACK version: 14 updated: 2025/12/15 04:04:20
7485dnl -------------
7486AC_DEFUN([CF_RPATH_HACK],
7487[AC_REQUIRE([AC_PROG_FGREP])dnl
7488AC_REQUIRE([CF_LD_RPATH_OPT])dnl
7489
7490AC_MSG_CHECKING(for updated LDFLAGS)
7491if test -n "$LD_RPATH_OPT" ; then
7492	AC_MSG_RESULT(maybe)
7493
7494	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
7495	cf_rpath_list="/usr/lib /lib"
7496	if test "$cf_ldd_prog" != no
7497	then
7498		cf_rpath_oops=
7499
7500AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],
7501		[printf("Hello");])],
7502		[cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
7503		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
7504
7505		# If we passed the link-test, but get a "not found" on a given library,
7506		# this could be due to inept reconfiguration of gcc to make it only
7507		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
7508		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
7509		# /usr/local libraries.
7510		if test -n "$cf_rpath_oops"
7511		then
7512			for cf_rpath_src in $cf_rpath_oops
7513			do
7514				for cf_rpath_dir in \
7515					/usr/local \
7516					/usr/pkg \
7517					/opt/sfw
7518				do
7519					if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
7520					then
7521						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
7522						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
7523						break
7524					fi
7525				done
7526			done
7527		fi
7528	fi
7529
7530	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
7531
7532	CF_RPATH_HACK_2(LDFLAGS)
7533	CF_RPATH_HACK_2(LIBS)
7534
7535	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
7536else
7537	AC_MSG_RESULT(no)
7538fi
7539AC_SUBST(EXTRA_LDFLAGS)
7540])dnl
7541dnl ---------------------------------------------------------------------------
7542dnl CF_RPATH_HACK_2 version: 8 updated: 2021/01/01 13:31:04
7543dnl ---------------
7544dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
7545dnl EXTRA_LDFLAGS for each -L option found.
7546dnl
7547dnl $cf_rpath_list contains a list of directories to ignore.
7548dnl
7549dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
7550dnl      but LIBS often has misplaced -L options.
7551AC_DEFUN([CF_RPATH_HACK_2],
7552[
7553CF_VERBOSE(...checking $1 [$]$1)
7554
7555cf_rpath_dst=
7556for cf_rpath_src in [$]$1
7557do
7558	case "$cf_rpath_src" in
7559	(-L*)
7560
7561		# check if this refers to a directory which we will ignore
7562		cf_rpath_skip=no
7563		if test -n "$cf_rpath_list"
7564		then
7565			for cf_rpath_item in $cf_rpath_list
7566			do
7567				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
7568				then
7569					cf_rpath_skip=yes
7570					break
7571				fi
7572			done
7573		fi
7574
7575		if test "$cf_rpath_skip" = no
7576		then
7577			# transform the option
7578			if test "$LD_RPATH_OPT" = "-R " ; then
7579				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
7580			else
7581				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
7582			fi
7583
7584			# if we have not already added this, add it now
7585			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
7586			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
7587			then
7588				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
7589				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
7590			fi
7591		fi
7592		;;
7593	esac
7594	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
7595done
7596$1=$cf_rpath_dst
7597
7598CF_VERBOSE(...checked $1 [$]$1)
7599AC_SUBST(EXTRA_LDFLAGS)
7600])dnl
7601dnl ---------------------------------------------------------------------------
7602dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
7603dnl ------------------
7604dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
7605dnl and libraries which do not update those variables.
7606dnl
7607dnl $1 = name of current macro
7608define([CF_SAVE_XTRA_FLAGS],
7609[
7610cf_save_LIBS_$1="$LIBS"
7611cf_save_CFLAGS_$1="$CFLAGS"
7612cf_save_CPPFLAGS_$1="$CPPFLAGS"
7613LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
7614for cf_X_CFLAGS in $X_CFLAGS
7615do
7616	case "x$cf_X_CFLAGS" in
7617	x-[[IUD]]*)
7618		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
7619		;;
7620	*)
7621		CFLAGS="$CFLAGS $cf_X_CFLAGS"
7622		;;
7623	esac
7624done
7625])dnl
7626dnl ---------------------------------------------------------------------------
7627dnl CF_SHARED_OPTS version: 114 updated: 2025/12/15 04:04:20
7628dnl --------------
7629dnl --------------
7630dnl Attempt to determine the appropriate CC/LD options for creating a shared
7631dnl library.
7632dnl
7633dnl Notes:
7634dnl a) ${LOCAL_LDFLAGS} is used to link executables that will run within
7635dnl the build-tree, i.e., by making use of the libraries that are compiled in
7636dnl $rel_builddir/lib We avoid compiling-in a $rel_builddir/lib path for the
7637dnl shared library since that can lead to unexpected results at runtime.
7638dnl b) ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared
7639dnl libraries are compiled in ../../lib
7640dnl
7641dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
7642dnl to install symbolic links to the rel/abi versions of shared libraries.
7643dnl
7644dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
7645dnl version when making symbolic links.
7646dnl
7647dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
7648dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
7649dnl (ex: libncurses.so.<ver>).
7650dnl
7651dnl Some loaders leave 'so_locations' lying around.  It is nice to clean up.
7652AC_DEFUN([CF_SHARED_OPTS],
7653[
7654	AC_REQUIRE([CF_LD_RPATH_OPT])
7655
7656	RM_SHARED_OPTS=
7657	LOCAL_LDFLAGS=
7658	LOCAL_LDFLAGS2=
7659	LD_SHARED_OPTS=
7660	INSTALL_LIB="-m 644"
7661	: ${rel_builddir:=.}
7662
7663	shlibdir=$libdir
7664	AC_SUBST(shlibdir)
7665
7666	MAKE_DLLS="#"
7667	AC_SUBST(MAKE_DLLS)
7668
7669	cf_cv_do_symlinks=no
7670	cf_ld_rpath_opt=
7671	test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
7672
7673	AC_MSG_CHECKING(whether to use release or ABI version in shared library file names)
7674	AC_ARG_WITH(shlib-version,
7675	[[  --with-shlib-version[={rel|abi}] use release or ABI version in shared library file names]],
7676	[test -z "$withval" && withval=auto
7677	case "$withval" in
7678	(yes)
7679		cf_cv_shlib_version=auto
7680		;;
7681	(rel|abi|auto)
7682		cf_cv_shlib_version=$withval
7683		;;
7684	(*)
7685		AC_MSG_RESULT($withval)
7686		AC_MSG_ERROR([option value must be one of: rel, abi, or auto])
7687		;;
7688	esac
7689	],[cf_cv_shlib_version=auto])
7690	AC_MSG_RESULT($cf_cv_shlib_version)
7691
7692	cf_cv_rm_so_locs=no
7693	cf_try_cflags=
7694
7695	# Some less-capable ports of gcc support only -fpic
7696	CC_SHARED_OPTS=
7697
7698	cf_try_fPIC=no
7699	if test "$GCC" = yes
7700	then
7701		cf_try_fPIC=yes
7702	else
7703		case "$cf_cv_system_name" in
7704		(*linux*)	# e.g., PGI compiler
7705			cf_try_fPIC=yes
7706			;;
7707		esac
7708	fi
7709
7710	if test "$cf_try_fPIC" = yes
7711	then
7712		AC_MSG_CHECKING(which $CC option to use)
7713		cf_save_CFLAGS="$CFLAGS"
7714		for CC_SHARED_OPTS in -fPIC -fpic ''
7715		do
7716			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
7717			AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],[int x = 1; (void)x])],[break],[])
7718		done
7719		AC_MSG_RESULT($CC_SHARED_OPTS)
7720		CFLAGS="$cf_save_CFLAGS"
7721	fi
7722
7723	cf_cv_shlib_version_infix=no
7724
7725	case "$cf_cv_system_name" in
7726	(aix4.[3-9]*|aix[[5-7]]*)
7727		if test "$GCC" = yes; then
7728			CC_SHARED_OPTS='-Wl,-brtl'
7729			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
7730		else
7731			CC_SHARED_OPTS='-brtl'
7732			# as well as '-qpic=large -G' or perhaps "-bM:SRE -bnoentry -bexpall"
7733			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -G -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
7734		fi
7735		;;
7736	(beos*)
7737		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
7738		;;
7739	(cygwin*)
7740		CC_SHARED_OPTS=
7741		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
7742		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
7743		cf_cv_shlib_version=cygdll
7744		cf_cv_shlib_version_infix=cygdll
7745		shlibdir=$bindir
7746		MAKE_DLLS=
7747		cat >mk_shared_lib.sh <<-CF_EOF
7748		#!$SHELL
7749		SHARED_LIB=\[$]1
7750		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
7751		shift
7752		cat <<-EOF
7753		Linking shared library
7754		** SHARED_LIB \[$]SHARED_LIB
7755		** IMPORT_LIB \[$]IMPORT_LIB
7756EOF
7757		exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
7758CF_EOF
7759		chmod +x mk_shared_lib.sh
7760		;;
7761	(msys*)
7762		CC_SHARED_OPTS=
7763		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
7764		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
7765		cf_cv_shlib_version=msysdll
7766		cf_cv_shlib_version_infix=msysdll
7767		shlibdir=$bindir
7768		MAKE_DLLS=
7769		cat >mk_shared_lib.sh <<-CF_EOF
7770		#!$SHELL
7771		SHARED_LIB=\[$]1
7772		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/msys-/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
7773		shift
7774		cat <<-EOF
7775		Linking shared library
7776		** SHARED_LIB \[$]SHARED_LIB
7777		** IMPORT_LIB \[$]IMPORT_LIB
7778EOF
7779		exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
7780CF_EOF
7781		chmod +x mk_shared_lib.sh
7782		;;
7783	(darwin*)
7784		cf_try_cflags="no-cpp-precomp"
7785		CC_SHARED_OPTS="-dynamic"
7786		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
7787		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
7788		cf_cv_shlib_version_infix=yes
7789		AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
7790			cf_save_LDFLAGS=$LDFLAGS
7791			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
7792			AC_LINK_IFELSE([AC_LANG_PROGRAM([], [int i;])], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
7793				LDFLAGS=$cf_save_LDFLAGS])
7794		if test "$cf_cv_ldflags_search_paths_first" = yes; then
7795			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
7796		fi
7797		;;
7798	(haiku*)
7799		CF_SHARED_SONAME
7800		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
7801		;;
7802	(hpux[[7-8]]*)
7803		# HP-UX 8.07 ld lacks "+b" option used for libdir search-list
7804		if test "$GCC" != yes; then
7805			CC_SHARED_OPTS='+Z'
7806		fi
7807		MK_SHARED_LIB='${LD} ${LDFLAGS} -b -o $[@]'
7808		INSTALL_LIB="-m 555"
7809		;;
7810	(hpux*)
7811		# (tested with gcc 2.7.2 -- I don't have c89)
7812		if test "$GCC" = yes; then
7813			LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
7814		else
7815			CC_SHARED_OPTS='+Z'
7816			LD_SHARED_OPTS='-Wl,+b,${libdir}'
7817		fi
7818		MK_SHARED_LIB='${LD} ${LDFLAGS} +b ${libdir} -b -o $[@]'
7819		# HP-UX shared libraries must be executable, and should be
7820		# readonly to exploit a quirk in the memory manager.
7821		INSTALL_LIB="-m 555"
7822		;;
7823	(interix*)
7824		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
7825		if test "$cf_cv_shlib_version" = rel; then
7826			cf_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
7827		else
7828			cf_shared_soname='`basename $[@]`'
7829		fi
7830		CC_SHARED_OPTS=
7831		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-rpath,${RPATH_LIST} -Wl,-h,'$cf_shared_soname' -o $[@]'
7832		;;
7833	(irix*)
7834		if test "$cf_cv_enable_rpath" = yes ; then
7835			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7836		fi
7837		# tested with IRIX 5.2 and 'cc'.
7838		if test "$GCC" != yes; then
7839			CC_SHARED_OPTS='-KPIC'
7840			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
7841		else
7842			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,`basename $[@]` -o $[@]'
7843		fi
7844		cf_cv_rm_so_locs=yes
7845		;;
7846	(linux*|gnu*|k*bsd*-gnu)
7847		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
7848			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
7849			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7850		fi
7851		if test "$cf_cv_enable_rpath" = yes ; then
7852			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7853		fi
7854		CF_SHARED_SONAME
7855		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
7856		;;
7857	(mingw*msvc*)
7858		cf_cv_shlib_version=msvcdll
7859		cf_cv_shlib_version_infix=msvcdll
7860		shlibdir=$bindir
7861		MAKE_DLLS=
7862		if test "$DFT_LWR_MODEL" = "shared" ; then
7863			LOCAL_LDFLAGS="-link -dll"
7864			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7865			EXTRA_LDFLAGS="-link -dll $EXTRA_LDFLAGS"
7866		fi
7867		CC_SHARED_OPTS=
7868		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ ${LD} [$]{CFLAGS}'
7869		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.lib"
7870		cat >mk_shared_lib.sh <<-CF_EOF
7871		#!$SHELL
7872		SHARED_LIB=\[$]1
7873		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.lib/'\`
7874		shift
7875		my_ld=\[$]1
7876		shift
7877		cat <<-EOF
7878		Linking shared library
7879		** SHARED LIB \$SHARED_LIB
7880		** IMPORT_LIB \$IMPORT_LIB
7881EOF
7882		args=\$(echo \[$]* | sed -E "s#-l(\w*)#\1.dll.lib#g" | sed -E "s#-L(\w*)#-LIBPATH:\1#g")
7883		exec \$my_ld -DLL -IMPLIB:"\${IMPORT_LIB}" -OUT:"\${SHARED_LIB}" ${LDFLAGS} \$args
7884		mv "\${IMPORT_LIB}" "\${IMPORT_LIB}"
7885CF_EOF
7886		chmod +x mk_shared_lib.sh
7887		cat >mk_prog.sh <<-CF_EOF
7888		#!$SHELL
7889		shift
7890		# Ignore first argument (compiler) and use LD (link.exe) unconditionally
7891		LD="[$]LD"
7892		clopts=()
7893		ldopts=("/subsystem:console")
7894		libs=()
7895		isdll=0
7896		while test \[$]# -gt 0; do
7897			case "\[$]1" in
7898				-link)
7899					# ignore -link argument
7900					;;
7901				-M[[TD]] | -M[[TD]]d)
7902					# ignore runtime-library option
7903					;;
7904				-dll)
7905					isdll=1
7906					;;
7907				-W* | -w*)
7908					# ignore warnings
7909					;;
7910				-D*)
7911					clopts+=("\[$]1")
7912					;;
7913				-I*)
7914					clopts+=("\[$]1")
7915					;;
7916				-l*)
7917					libs+=("\`echo \"\[$]1\" | sed \"s/^-l//\"\`")
7918					;;
7919				-L*)
7920					ldopts+=("\`echo \"\[$]1\" | sed \"s/^-L/-LIBPATH:/\"\`")
7921					;;
7922				*.obj | *.$OBJEXT)
7923					ldopts+=("\[$]1")
7924					;;
7925				-Wl,*)
7926					for linkarg in \`echo '\[$]1' | sed -e 's/-Wl,//' -e 's/,/ /'\`; do
7927						ldopts+=("\[$]{linkarg}")
7928					done
7929					;;
7930				*.lib)
7931					ldopts+=("\[$]1")
7932					;;
7933				-o)
7934					shift
7935					ldopts+=("-out:\[$]1")
7936					;;
7937				*)
7938					clopts+=("\[$]1")
7939					ldopts+=("\[$]1")
7940					;;
7941			esac
7942			shift
7943		done
7944		if [[ "\$isdll" -ne 0 ]]; then
7945			for lib in \[$]{libs[[*]]}; do
7946				ldopts+=("\[$]lib.dll.lib")
7947			done
7948		else
7949			for lib in \[$]{libs[[*]]}; do
7950				ldopts+=("\[$]lib.lib")
7951			done
7952		fi
7953		cat <<-EOF
7954		Creating program
7955		** ld options:   "\[$]{ldopts[[@]]}"
7956EOF
7957		exec \[$]LD \[$]{ldopts[[@]]}
7958CF_EOF
7959		chmod +x mk_prog.sh
7960		LINK_PROGS="$SHELL ${rel_builddir}/mk_prog.sh"
7961		LINK_TESTS="$SHELL ${rel_builddir}/mk_prog.sh"
7962		;;
7963	(mingw*)
7964		cf_cv_shlib_version=mingw
7965		cf_cv_shlib_version_infix=mingw
7966		shlibdir=$bindir
7967		MAKE_DLLS=
7968		if test "$DFT_LWR_MODEL" = "shared" ; then
7969			LOCAL_LDFLAGS="-Wl,--enable-auto-import"
7970			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7971			EXTRA_LDFLAGS="-Wl,--enable-auto-import $EXTRA_LDFLAGS"
7972		fi
7973		CC_SHARED_OPTS=
7974		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
7975		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
7976		cat >mk_shared_lib.sh <<-CF_EOF
7977		#!$SHELL
7978		SHARED_LIB=\[$]1
7979		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
7980		shift
7981		cat <<-EOF
7982		Linking shared library
7983		** SHARED_LIB \[$]SHARED_LIB
7984		** IMPORT_LIB \[$]IMPORT_LIB
7985EOF
7986		exec \[$]* ${LDFLAGS} -shared -Wl,--enable-auto-import,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
7987CF_EOF
7988		chmod +x mk_shared_lib.sh
7989		;;
7990	(openbsd[[2-9]].*|mirbsd*)
7991		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
7992			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
7993			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
7994		fi
7995		if test "$cf_cv_enable_rpath" = yes ; then
7996			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
7997		fi
7998		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
7999		CF_SHARED_SONAME
8000		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
8001		;;
8002	(nskJ*)
8003		CC_SHARED_OPTS=
8004		MK_SHARED_LIB='${LD} -Wshared -Weld=-export_all -o $[@]'
8005		;;
8006	(nskL*)
8007		CC_SHARED_OPTS=
8008		MK_SHARED_LIB='${LD} -Wshared -Wxld=-export_all -o $[@]'
8009		;;
8010	(nto-qnx*|openbsd*|freebsd[[12]].*)
8011		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
8012		MK_SHARED_LIB='${LD} ${LDFLAGS} -Bshareable -o $[@]'
8013		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
8014		;;
8015	(dragonfly*|freebsd*)
8016		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
8017		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
8018			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
8019			LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${RPATH_LIST} $LOCAL_LDFLAGS"
8020			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
8021		fi
8022		CF_SHARED_SONAME
8023		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
8024		;;
8025	(netbsd*)
8026		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
8027		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
8028			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
8029			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
8030			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
8031			if test "$cf_cv_shlib_version" = auto; then
8032			if test -f /usr/libexec/ld.elf_so; then
8033				cf_cv_shlib_version=abi
8034			else
8035				cf_cv_shlib_version=rel
8036			fi
8037			fi
8038			CF_SHARED_SONAME
8039			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
8040		else
8041			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -o $[@]'
8042		fi
8043		;;
8044	(osf*|mls+*)
8045		# tested with OSF/1 V3.2 and 'cc'
8046		# tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
8047		# link with shared libs).
8048		MK_SHARED_LIB='${LD} ${LDFLAGS} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
8049		case "$host_os" in
8050		(osf4*)
8051			MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
8052			;;
8053		esac
8054		MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
8055		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
8056			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
8057			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
8058		fi
8059		cf_cv_rm_so_locs=yes
8060		;;
8061	(sco3.2v5*)  # also uw2* and UW7: hops 13-Apr-98
8062		# tested with osr5.0.5
8063		if test "$GCC" != yes; then
8064			CC_SHARED_OPTS='-belf -KPIC'
8065		fi
8066		MK_SHARED_LIB='${LD} ${LDFLAGS} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
8067		if test "$cf_cv_enable_rpath" = yes ; then
8068			# only way is to set LD_RUN_PATH but no switch for it
8069			RUN_PATH=$libdir
8070		fi
8071		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
8072		LINK_PROGS='LD_RUN_PATH=${libdir}'
8073		LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
8074		;;
8075	(sunos4*)
8076		# tested with SunOS 4.1.1 and gcc 2.7.0
8077		if test "$GCC" != yes; then
8078			CC_SHARED_OPTS='-KPIC'
8079		fi
8080		MK_SHARED_LIB='${LD} ${LDFLAGS} -assert pure-text -o $[@]'
8081		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
8082		;;
8083	(solaris2*)
8084		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
8085		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
8086		if test "$DFT_LWR_MODEL" = "shared" ; then
8087			LOCAL_LDFLAGS="-R\$(LOCAL_LIBDIR):\${libdir}"
8088			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
8089		fi
8090		if test "$cf_cv_enable_rpath" = yes ; then
8091			EXTRA_LDFLAGS="-R\${libdir} $EXTRA_LDFLAGS"
8092		fi
8093		CF_SHARED_SONAME
8094		if test "$GCC" != yes; then
8095			cf_save_CFLAGS="$CFLAGS"
8096			for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
8097			do
8098				CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
8099				AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],[printf("Hello\\n");])],[break])
8100			done
8101			CFLAGS="$cf_save_CFLAGS"
8102			CC_SHARED_OPTS=$cf_shared_opts
8103			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -Wl,-h,'$cf_cv_shared_soname' -o $[@]'
8104		else
8105			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -Wl,-h,'$cf_cv_shared_soname' -o $[@]'
8106		fi
8107		;;
8108	(sysv5uw7*|unix_sv*)
8109		# tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
8110		if test "$GCC" != yes; then
8111			CC_SHARED_OPTS='-KPIC'
8112		fi
8113		MK_SHARED_LIB='${LD} ${LDFLAGS} -d y -G -o [$]@'
8114		;;
8115	(*)
8116		CC_SHARED_OPTS='unknown'
8117		MK_SHARED_LIB='echo unknown'
8118		;;
8119	esac
8120
8121	# This works if the last tokens in $MK_SHARED_LIB are the -o target.
8122	case "$cf_cv_shlib_version" in
8123	(rel|abi)
8124		case "$MK_SHARED_LIB" in
8125		(*'-o $[@]')
8126			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
8127			;;
8128		(*)
8129			AC_MSG_WARN(ignored --with-shlib-version)
8130			;;
8131		esac
8132		;;
8133	esac
8134
8135	if test -n "$cf_try_cflags"
8136	then
8137cat > conftest.$ac_ext <<EOF
8138#line __oline__ "${as_me:-configure}"
8139#include <stdio.h>
8140int main(int argc, char *argv[[]])
8141{
8142	printf("hello\\n");
8143	return (argv[[argc-1]] == NULL) ;
8144}
8145EOF
8146		cf_save_CFLAGS="$CFLAGS"
8147		for cf_opt in $cf_try_cflags
8148		do
8149			CFLAGS="$cf_save_CFLAGS -$cf_opt"
8150			AC_MSG_CHECKING(if CFLAGS option -$cf_opt works)
8151			if AC_TRY_EVAL(ac_compile); then
8152				AC_MSG_RESULT(yes)
8153				cf_save_CFLAGS="$CFLAGS"
8154			else
8155				AC_MSG_RESULT(no)
8156			fi
8157		done
8158		CFLAGS="$cf_save_CFLAGS"
8159	fi
8160
8161
8162	# RPATH_LIST is a colon-separated list of directories
8163	test -n "$cf_ld_rpath_opt" && MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${RPATH_LIST}"
8164	test -z "$RPATH_LIST" && RPATH_LIST="\${libdir}"
8165
8166	test "$cf_cv_rm_so_locs" = yes && RM_SHARED_OPTS="$RM_SHARED_OPTS so_locations"
8167
8168	CF_VERBOSE(CC_SHARED_OPTS: $CC_SHARED_OPTS)
8169	CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
8170
8171	AC_SUBST(CC_SHARED_OPTS)
8172	AC_SUBST(LD_RPATH_OPT)
8173	AC_SUBST(LD_SHARED_OPTS)
8174	AC_SUBST(MK_SHARED_LIB)
8175	AC_SUBST(RM_SHARED_OPTS)
8176
8177	AC_SUBST(LINK_PROGS)
8178	AC_SUBST(LINK_TESTS)
8179
8180	AC_SUBST(EXTRA_LDFLAGS)
8181	AC_SUBST(LOCAL_LDFLAGS)
8182	AC_SUBST(LOCAL_LDFLAGS2)
8183
8184	AC_SUBST(INSTALL_LIB)
8185	AC_SUBST(RPATH_LIST)
8186])dnl
8187dnl ---------------------------------------------------------------------------
8188dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
8189dnl ----------------
8190dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
8191dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
8192dnl option.
8193dnl
8194dnl $1 is the default that should be used for "$cf_cv_shlib_version".
8195dnl If missing, use "rel".
8196define([CF_SHARED_SONAME],
8197[
8198	test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
8199	if test "$cf_cv_shlib_version" = rel; then
8200		cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
8201	else
8202		cf_cv_shared_soname='`basename $[@]`'
8203	fi
8204])
8205dnl ---------------------------------------------------------------------------
8206dnl CF_SIGWINCH version: 8 updated: 2025/12/23 18:53:34
8207dnl -----------
8208dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
8209dnl programs need this test).
8210dnl
8211dnl This is really a Mac OS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
8212dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
8213dnl winsize declaration is left alone - we may revisit this if Apple choose to
8214dnl break that part of the interface as well.
8215AC_DEFUN([CF_SIGWINCH],
8216[
8217AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
8218	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8219#include <sys/types.h>
8220#include <sys/signal.h>
8221],[int x = SIGWINCH; (void)x])],
8222	[cf_cv_define_sigwinch=yes],
8223	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8224#undef _XOPEN_SOURCE
8225#undef _POSIX_SOURCE
8226#undef _POSIX_C_SOURCE
8227#include <sys/types.h>
8228#include <sys/signal.h>
8229],[int x = SIGWINCH; (void)x])],
8230	[cf_cv_define_sigwinch=maybe],
8231	[cf_cv_define_sigwinch=no])
8232])
8233])
8234
8235if test "$cf_cv_define_sigwinch" = maybe ; then
8236AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
8237cf_cv_fixup_sigwinch=unknown
8238cf_sigwinch=32
8239while test "$cf_sigwinch" != 1
8240do
8241	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8242#undef _XOPEN_SOURCE
8243#undef _POSIX_SOURCE
8244#undef _POSIX_C_SOURCE
8245#include <sys/types.h>
8246#include <sys/signal.h>
8247],[
8248#if SIGWINCH != $cf_sigwinch
8249#error SIGWINCH is not $cf_sigwinch
8250#endif
8251int x = SIGWINCH; (void)x])],
8252	[cf_cv_fixup_sigwinch=$cf_sigwinch
8253	 break])
8254
8255cf_sigwinch="`expr "$cf_sigwinch" - 1`"
8256done
8257])
8258
8259	if test "$cf_cv_fixup_sigwinch" != unknown ; then
8260		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
8261	fi
8262fi
8263])dnl
8264dnl ---------------------------------------------------------------------------
8265dnl CF_SIG_ATOMIC_T version: 6 updated: 2025/12/24 12:27:29
8266dnl ---------------
8267dnl signal handler, but there are some gcc dependencies in that recommendation.
8268dnl Try anyway.
8269AC_DEFUN([CF_SIG_ATOMIC_T],
8270[
8271AC_MSG_CHECKING(for signal global datatype)
8272AC_CACHE_VAL(cf_cv_sig_atomic_t,[
8273	for cf_type in \
8274		"volatile sig_atomic_t" \
8275		"sig_atomic_t" \
8276		"int"
8277	do
8278	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8279#include <sys/types.h>
8280#include <signal.h>
8281#include <stdio.h>
8282
8283extern $cf_type x;
8284$cf_type x;
8285static void handler(int sig)
8286{
8287	(void)sig;
8288	x = 5;
8289}],
8290		[signal(SIGINT, handler);
8291		 x = 1])],
8292		[cf_cv_sig_atomic_t=$cf_type],
8293		[cf_cv_sig_atomic_t=no])
8294		test "$cf_cv_sig_atomic_t" != no && break
8295	done
8296	])
8297AC_MSG_RESULT($cf_cv_sig_atomic_t)
8298test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
8299])dnl
8300dnl ---------------------------------------------------------------------------
8301dnl CF_SIZECHANGE version: 19 updated: 2025/12/22 04:16:14
8302dnl -------------
8303dnl Check for definitions & structures needed for window size-changing
8304dnl
8305dnl https://stackoverflow.com/questions/18878141/difference-between-structures-ttysize-and-winsize/50769952#50769952
8306AC_DEFUN([CF_SIZECHANGE],
8307[
8308AC_REQUIRE([CF_STRUCT_TERMIOS])
8309AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
8310	cf_cv_sizechange=unknown
8311	cf_save_CPPFLAGS="$CPPFLAGS"
8312
8313for cf_opts in "" "NEED_PTEM_H"
8314do
8315
8316	CPPFLAGS="$cf_save_CPPFLAGS"
8317	if test -n "$cf_opts"
8318	then
8319		CF_APPEND_TEXT(CPPFLAGS,-D$cf_opts)
8320	fi
8321	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
8322#ifdef HAVE_TERMIOS_H
8323#include <termios.h>
8324#else
8325#ifdef HAVE_TERMIO_H
8326#include <termio.h>
8327#endif
8328#endif
8329
8330#ifdef NEED_PTEM_H
8331/* This is a workaround for SCO:  they neglected to define struct winsize in
8332 * termios.h -- it is only in termio.h and ptem.h
8333 */
8334#include <sys/stream.h>
8335#include <sys/ptem.h>
8336#endif
8337
8338#ifdef HAVE_SYS_IOCTL_H
8339#include <sys/ioctl.h>
8340#endif
8341],[
8342#ifdef TIOCGSIZE
8343	struct ttysize win;	/* SunOS 3.0... */
8344	int y = win.ts_lines = 2;
8345	int x = win.ts_cols = 1;
8346	(void)y;
8347	(void)x;
8348#else
8349#ifdef TIOCGWINSZ
8350	struct winsize win;	/* everything else */
8351	int y = win.ws_row = 2;
8352	int x = win.ws_col = 1;
8353	(void)y;
8354	(void)x;
8355#else
8356	no TIOCGSIZE or TIOCGWINSZ
8357#endif /* TIOCGWINSZ */
8358#endif /* TIOCGSIZE */
8359	])],
8360	[cf_cv_sizechange=yes],
8361	[cf_cv_sizechange=no])
8362
8363	CPPFLAGS="$cf_save_CPPFLAGS"
8364	if test "$cf_cv_sizechange" = yes ; then
8365		echo "size-change succeeded ($cf_opts)" >&AS_MESSAGE_LOG_FD
8366		test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
8367		break
8368	fi
8369done
8370])
8371if test "$cf_cv_sizechange" != no ; then
8372	AC_DEFINE(HAVE_SIZECHANGE,1,[Define to 1 if sizechange declarations are provided])
8373	case "$cf_cv_sizechange" in
8374	(NEED*)
8375		AC_DEFINE_UNQUOTED($cf_cv_sizechange )
8376		;;
8377	esac
8378fi
8379])dnl
8380dnl ---------------------------------------------------------------------------
8381dnl CF_SRC_MODULES version: 34 updated: 2023/04/22 11:51:06
8382dnl --------------
8383dnl For each parameter, test if the source-directory exists, and if it contains
8384dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
8385dnl use in CF_LIB_RULES.
8386dnl
8387dnl This uses the configured value to make the lists SRC_SUBDIRS and
8388dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
8389AC_DEFUN([CF_SRC_MODULES],
8390[
8391AC_REQUIRE([CF_CHECK_GNAT_VERSION])
8392AC_MSG_CHECKING(for src modules)
8393
8394# dependencies and linker-arguments for test-programs
8395TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
8396TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEP2"
8397if test "$DFT_LWR_MODEL" = "libtool"; then
8398	TEST_ARGS="${TEST_DEPS}"
8399	TEST_ARG2="${TEST_DEP2}"
8400else
8401	TEST_ARGS="-l${LIB_NAME}${USE_ARG_SUFFIX} $TEST_ARGS"
8402	TEST_ARG2="-l${LIB_NAME}${USE_ARG_SUFFIX} $TEST_ARG2"
8403fi
8404
8405PC_MODULES_TO_MAKE="ncurses${USE_ARG_SUFFIX}"
8406cf_cv_src_modules=
8407for cf_dir in $1
8408do
8409	if test -f "$srcdir/$cf_dir/modules" ; then
8410
8411		if test -z "$cf_cv_src_modules"; then
8412			cf_cv_src_modules=$cf_dir
8413		else
8414			cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
8415		fi
8416
8417		# Make the ncurses_cfg.h file record the library interface files as
8418		# well.  These are header files that are the same name as their
8419		# directory.  Ncurses is the only library that does not follow
8420		# that pattern.
8421		if test -f "$srcdir/${cf_dir}/${cf_dir}.h" ; then
8422			CF_UPPER(cf_have_include,$cf_dir)
8423			AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
8424			AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
8425			CF_MAP_LIB_BASENAME(TEST_ROOT,$cf_dir)
8426			TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${TEST_ROOT}${DFT_DEP_SUFFIX} $TEST_DEPS"
8427			TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${TEST_ROOT}${DFT_DEP_SUFFIX} $TEST_DEP2"
8428			if test "$DFT_LWR_MODEL" = "libtool"; then
8429				TEST_ARGS="${TEST_DEPS}"
8430				TEST_ARG2="${TEST_DEP2}"
8431			else
8432				TEST_ARGS="-l${TEST_ROOT}${USE_ARG_SUFFIX} $TEST_ARGS"
8433				TEST_ARG2="-l${TEST_ROOT}${USE_ARG_SUFFIX} $TEST_ARG2"
8434			fi
8435			PC_MODULES_TO_MAKE="${PC_MODULES_TO_MAKE} ${cf_dir}${USE_ARG_SUFFIX}"
8436		fi
8437	fi
8438done
8439AC_MSG_RESULT($cf_cv_src_modules)
8440
8441TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
8442TEST_ARG2="-L${LIB_2ND} $TEST_ARG2"
8443
8444AC_SUBST(TEST_ARGS)
8445AC_SUBST(TEST_DEPS)
8446
8447AC_SUBST(TEST_ARG2)
8448AC_SUBST(TEST_DEP2)
8449
8450SRC_SUBDIRS=
8451if test "x$cf_with_manpages" != xno ; then
8452	SRC_SUBDIRS="$SRC_SUBDIRS man"
8453fi
8454SRC_SUBDIRS="$SRC_SUBDIRS include"
8455for cf_dir in $cf_cv_src_modules
8456do
8457	SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
8458done
8459if test "x$cf_with_tests" != "xno" ; then
8460	SRC_SUBDIRS="$SRC_SUBDIRS test"
8461fi
8462# always make this, to install the ncurses-config script
8463SRC_SUBDIRS="$SRC_SUBDIRS misc"
8464if test "$cf_with_cxx_binding" != no; then
8465	PC_MODULES_TO_MAKE="${PC_MODULES_TO_MAKE} ncurses++${USE_ARG_SUFFIX}"
8466	SRC_SUBDIRS="$SRC_SUBDIRS c++"
8467fi
8468
8469test "x$with_termlib" != xno && PC_MODULES_TO_MAKE="$PC_MODULES_TO_MAKE $TINFO_ARG_SUFFIX"
8470test "x$with_ticlib" != xno && PC_MODULES_TO_MAKE="$PC_MODULES_TO_MAKE $TICS_ARG_SUFFIX"
8471
8472AC_SUBST(PC_MODULES_TO_MAKE)
8473
8474ADA_SUBDIRS=
8475if test "x$cf_with_ada" = "xyes" && test "x$cf_cv_prog_gnat_correct" = xyes && test -f "$srcdir/Ada95/Makefile.in" ; then
8476	SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
8477	ADA_SUBDIRS="gen src"
8478	if test "x$cf_with_tests" != "xno" ; then
8479		ADA_SUBDIRS="$ADA_SUBDIRS samples"
8480	fi
8481fi
8482
8483SUB_MAKEFILES=
8484for cf_dir in $SRC_SUBDIRS
8485do
8486	SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
8487done
8488
8489if test -n "$ADA_SUBDIRS"; then
8490	for cf_dir in $ADA_SUBDIRS
8491	do
8492		SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
8493	done
8494	AC_SUBST(ADA_SUBDIRS)
8495fi
8496])dnl
8497dnl ---------------------------------------------------------------------------
8498dnl CF_STDCPP_LIBRARY version: 13 updated: 2025/12/24 12:27:29
8499dnl -----------------
8500dnl Check for -lstdc++, which is GNU's standard C++ library.
8501dnl If $CXXLIBS is set, add that to the libraries used for test-linking.
8502dnl If -lstdc++ was not already added to $LIBS or $CXXLIBS, and is needed,
8503dnl add it to $CXXLIBS.
8504AC_DEFUN([CF_STDCPP_LIBRARY],
8505[
8506if test -n "$GXX" ; then
8507
8508	cf_save="$LIBS"
8509	LIBS="$LIBS $CXXLIBS"
8510	AC_MSG_CHECKING(if we already have C++ library)
8511	AC_LINK_IFELSE([AC_LANG_PROGRAM([
8512			#include <iostream>],[
8513			std::cout << "Hello World!" << std::endl;])],
8514		[cf_have_libstdcpp=yes],
8515		[cf_have_libstdcpp=no])
8516	AC_MSG_RESULT($cf_have_libstdcpp)
8517	LIBS="$cf_save"
8518
8519	if test "$cf_have_libstdcpp" != yes
8520	then
8521		case "$cf_cv_system_name" in
8522		(os2*)
8523			if test -z "`g++ -dM -E - < /dev/null | grep __KLIBC__`"; then
8524				cf_stdcpp_libname=stdcpp
8525			else
8526				cf_stdcpp_libname=stdc++
8527			fi
8528			;;
8529		(*)
8530			cf_stdcpp_libname=stdc++
8531			;;
8532		esac
8533
8534		AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
8535			cf_save="$LIBS"
8536			LIBS="$LIBS $CXXLIBS"
8537			CF_ADD_LIB($cf_stdcpp_libname)
8538		AC_LINK_IFELSE([AC_LANG_PROGRAM([
8539				#include <iostream>],[
8540				std::cout << "Hello World!" << std::endl;])],
8541			[cf_cv_libstdcpp=yes],
8542			[cf_cv_libstdcpp=no])
8543			LIBS="$cf_save"
8544		])
8545		test "$cf_cv_libstdcpp" = yes && { CF_ADD_LIB($cf_stdcpp_libname,CXXLIBS) }
8546	fi
8547fi
8548])dnl
8549dnl ---------------------------------------------------------------------------
8550dnl CF_STRIP_G_OPT version: 4 updated: 2021/01/02 09:31:20
8551dnl --------------
8552dnl	Remove "-g" option from the compiler options
8553AC_DEFUN([CF_STRIP_G_OPT],
8554[$1=`echo "${$1}" | CF__SED_TRIMBLANKS(-e 's%-g %%' -e 's%-g$%%')`])dnl
8555dnl ---------------------------------------------------------------------------
8556dnl CF_STRUCT_SIGACTION version: 7 updated: 2025/12/24 12:27:29
8557dnl -------------------
8558dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
8559dnl do this if we've found the sigaction function.
8560AC_DEFUN([CF_STRUCT_SIGACTION],[
8561AC_REQUIRE([CF_XOPEN_SOURCE])
8562
8563if test "$ac_cv_func_sigaction" = yes; then
8564AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
8565AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8566#include <sys/types.h>
8567#include <signal.h>],
8568	[struct sigaction act; (void)act])],
8569	[sigact_bad=no],
8570	[
8571AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8572#define _POSIX_SOURCE
8573#include <sys/types.h>
8574#include <signal.h>],
8575	[struct sigaction act; (void)act])],
8576	[sigact_bad=yes
8577	 AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE])],
8578	 [sigact_bad=unknown])])
8579AC_MSG_RESULT($sigact_bad)
8580fi
8581])dnl
8582dnl ---------------------------------------------------------------------------
8583dnl CF_STRUCT_TERMIOS version: 15 updated: 2025/12/22 04:16:14
8584dnl -----------------
8585dnl Some machines require _POSIX_SOURCE to completely define struct termios.
8586AC_DEFUN([CF_STRUCT_TERMIOS],[
8587AC_REQUIRE([CF_XOPEN_SOURCE])
8588
8589AC_CHECK_HEADERS( sgtty.h \
8590termio.h \
8591termios.h \
8592unistd.h \
8593sys/ioctl.h \
8594sys/termio.h \
8595)
8596
8597if test "$ac_cv_header_termios_h" = yes ; then
8598	case "$CFLAGS $CPPFLAGS" in
8599	(*-D_POSIX_SOURCE*)
8600		termios_bad=dunno ;;
8601	(*)	termios_bad=maybe ;;
8602	esac
8603	if test "$termios_bad" = maybe ; then
8604	AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
8605	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <termios.h>],
8606		[struct termios foo; int x = (int)(foo.c_iflag = 1); (void)x])],
8607		termios_bad=no, [
8608		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8609#define _POSIX_SOURCE
8610#include <termios.h>],
8611			[struct termios foo; int x = (int)(foo.c_iflag = 2); (void)x])],
8612			termios_bad=unknown,
8613			termios_bad=yes AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE]))
8614			])
8615	AC_MSG_RESULT($termios_bad)
8616	fi
8617fi
8618])dnl
8619dnl ---------------------------------------------------------------------------
8620dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
8621dnl --------------
8622dnl Construct a search-list for a nonstandard header/lib-file
8623dnl	$1 = the variable to return as result
8624dnl	$2 = the package name
8625dnl	$3 = the subdirectory, e.g., bin, include or lib
8626AC_DEFUN([CF_SUBDIR_PATH],
8627[
8628$1=
8629
8630CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
8631
8632for cf_subdir_prefix in \
8633	/usr \
8634	/usr/local \
8635	/usr/pkg \
8636	/opt \
8637	/opt/local \
8638	[$]HOME
8639do
8640	CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
8641done
8642])dnl
8643dnl ---------------------------------------------------------------------------
8644dnl CF_SUBST_IF version: 2 updated: 2006/06/17 12:33:03
8645dnl -----------
8646dnl	Shorthand macro for substituting things that the user may override
8647dnl	with an environment variable.
8648dnl
8649dnl	$1 = condition to pass to "test"
8650dnl	$2 = environment variable
8651dnl	$3 = value if the test succeeds
8652dnl	$4 = value if the test fails
8653AC_DEFUN([CF_SUBST_IF],
8654[
8655if test $1 ; then
8656	$2=$3
8657ifelse($4,,,[else
8658	$2=$4])
8659fi
8660AC_SUBST($2)
8661])dnl
8662dnl ---------------------------------------------------------------------------
8663dnl CF_SUBST_NCURSES_VERSION version: 11 updated: 2023/01/07 16:32:06
8664dnl ------------------------
8665dnl Get the version-number for use in shared-library naming, etc.
8666AC_DEFUN([CF_SUBST_NCURSES_VERSION],
8667[AC_REQUIRE([AC_PROG_EGREP])dnl
8668
8669NCURSES_MAJOR="`${EGREP-egrep} '^NCURSES_MAJOR[[ 	]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
8670NCURSES_MINOR="`${EGREP-egrep} '^NCURSES_MINOR[[ 	]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
8671NCURSES_PATCH="`${EGREP-egrep} '^NCURSES_PATCH[[ 	]]*=' "$srcdir/dist.mk" | sed -e 's/^[[^0-9]]*//'`"
8672cf_cv_abi_version=${NCURSES_MAJOR}
8673cf_cv_abi_default=${NCURSES_MAJOR}
8674cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
8675dnl Show the computed version, for logging
8676cf_cv_timestamp=`date`
8677AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_default ($cf_cv_timestamp))
8678dnl We need these values in the generated headers
8679AC_SUBST(NCURSES_MAJOR)
8680AC_SUBST(NCURSES_MINOR)
8681AC_SUBST(NCURSES_PATCH)
8682dnl We need these values in the generated makefiles
8683AC_SUBST(cf_cv_rel_version)
8684AC_SUBST(cf_cv_abi_version)
8685AC_SUBST(cf_cv_abi_default)
8686AC_SUBST(cf_cv_builtin_bool)
8687AC_SUBST(cf_cv_header_stdbool_h)
8688AC_SUBST(cf_cv_type_of_bool)dnl
8689])dnl
8690dnl ---------------------------------------------------------------------------
8691dnl CF_SYS_TIME_SELECT version: 7 updated: 2025/12/24 12:27:29
8692dnl ------------------
8693dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
8694dnl older SCO configurations.
8695AC_DEFUN([CF_SYS_TIME_SELECT],
8696[
8697AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
8698AC_CACHE_VAL(cf_cv_sys_time_select,[
8699AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8700#include <sys/types.h>
8701#ifdef HAVE_SYS_TIME_H
8702#include <sys/time.h>
8703#endif
8704#ifdef HAVE_SYS_SELECT_H
8705#include <sys/select.h>
8706#endif
8707],[])],[cf_cv_sys_time_select=yes],
8708	 [cf_cv_sys_time_select=no])
8709	 ])
8710AC_MSG_RESULT($cf_cv_sys_time_select)
8711test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT,1,[Define to 1 if we can include <sys/time.h> with <sys/select.h>])
8712])dnl
8713dnl ---------------------------------------------------------------------------
8714dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
8715dnl ---------------
8716dnl Define a top_builddir symbol, for applications that need an absolute path.
8717AC_DEFUN([CF_TOP_BUILDDIR],
8718[
8719top_builddir=ifelse($1,,`pwd`,$1)
8720AC_SUBST(top_builddir)
8721])dnl
8722dnl ---------------------------------------------------------------------------
8723dnl CF_TRY_PKG_CONFIG version: 7 updated: 2025/01/10 19:55:54
8724dnl -----------------
8725dnl This is a simple wrapper to use for pkg-config, for libraries which may be
8726dnl available in that form.
8727dnl
8728dnl $1 = package name, which may be a shell variable
8729dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
8730dnl $3 = logic to use if pkg-config does not have the package
8731AC_DEFUN([CF_TRY_PKG_CONFIG],[
8732AC_REQUIRE([CF_PKG_CONFIG])
8733
8734if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$1"; then
8735	CF_VERBOSE(found package $1)
8736	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$1" 2>/dev/null`"
8737	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$1" 2>/dev/null`"
8738	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
8739	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
8740	CF_REQUIRE_PKG($1)
8741	CF_ADD_CFLAGS($cf_pkgconfig_incs)
8742	CF_ADD_LIBS($cf_pkgconfig_libs)
8743	ifelse([$2],,:,[$2])
8744else
8745	cf_pkgconfig_incs=
8746	cf_pkgconfig_libs=
8747	ifelse([$3],,:,[$3])
8748fi
8749])
8750dnl ---------------------------------------------------------------------------
8751dnl CF_TRY_XOPEN_SOURCE version: 5 updated: 2025/12/14 17:40:20
8752dnl -------------------
8753dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
8754dnl can define it successfully.
8755AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
8756AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
8757	AC_COMPILE_IFELSE([AC_LANG_PROGRAM(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY)],
8758	[cf_cv_xopen_source=no],
8759	[cf_save="$CPPFLAGS"
8760	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
8761	 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY)],
8762		[cf_cv_xopen_source=no],
8763		[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
8764		CPPFLAGS="$cf_save"
8765	])
8766])
8767
8768if test "$cf_cv_xopen_source" != no ; then
8769	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
8770	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
8771	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
8772	CF_APPEND_CFLAGS($cf_temp_xopen_source)
8773fi
8774])
8775dnl ---------------------------------------------------------------------------
8776dnl CF_TYPEOF_CHTYPE version: 12 updated: 2024/12/14 16:09:34
8777dnl ----------------
8778dnl Determine the type we should use for chtype (and attr_t, which is treated
8779dnl as the same thing).  We want around 32 bits, so on most machines want a
8780dnl long, but on newer 64-bit machines, probably want an int.  If we're using
8781dnl wide characters, we have to have a type compatible with that, as well.
8782AC_DEFUN([CF_TYPEOF_CHTYPE],
8783[
8784AC_MSG_CHECKING([for type of chtype])
8785AC_CACHE_VAL(cf_cv_typeof_chtype,[
8786		AC_TRY_RUN([
8787$ac_includes_default
8788#define WANT_BITS 31
8789int main(void)
8790{
8791	FILE *fp = fopen("cf_test.out", "w");
8792	if (fp != NULL) {
8793		char *result = "long";
8794		if (sizeof(unsigned long) > sizeof(unsigned int)) {
8795			int n;
8796			unsigned int x, y;
8797			for (n = 0; n < WANT_BITS; n++) {
8798				x = (1 << n);
8799				y = (x >> n);
8800				if (y != 1 || x == 0) {
8801					x = 0;
8802					break;
8803				}
8804			}
8805			/*
8806			 * If x is nonzero, an int is big enough for the bits
8807			 * that we want.
8808			 */
8809			result = (x != 0) ? "int" : "long";
8810		}
8811		fputs(result, fp);
8812		fclose(fp);
8813	}
8814	${cf_cv_main_return:-return}(0);
8815}
8816		],
8817		[cf_cv_typeof_chtype=`cat cf_test.out`],
8818		[cf_cv_typeof_chtype=long],
8819		[cf_cv_typeof_chtype=long])
8820		rm -f cf_test.out
8821	])
8822AC_MSG_RESULT($cf_cv_typeof_chtype)
8823
8824AC_SUBST(cf_cv_typeof_chtype)
8825AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype,[Define to actual type if needed for chtype])
8826])dnl
8827dnl ---------------------------------------------------------------------------
8828dnl CF_TYPE_SIGACTION version: 6 updated: 2025/12/24 12:27:29
8829dnl -----------------
8830dnl
8831AC_DEFUN([CF_TYPE_SIGACTION],
8832[
8833AC_MSG_CHECKING([for type sigaction_t])
8834AC_CACHE_VAL(cf_cv_type_sigaction,[
8835	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
8836#include <signal.h>],
8837		[sigaction_t x; (void)x])],
8838		[cf_cv_type_sigaction=yes],
8839		[cf_cv_type_sigaction=no])])
8840AC_MSG_RESULT($cf_cv_type_sigaction)
8841test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION,1,[Define to 1 if we have the sigaction_t type])
8842])dnl
8843dnl ---------------------------------------------------------------------------
8844dnl CF_UNSIGNED_LITERALS version: 4 updated: 2025/12/24 12:27:29
8845dnl --------------------
8846dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
8847dnl won't, but they're still there.
8848AC_DEFUN([CF_UNSIGNED_LITERALS],
8849[
8850AC_MSG_CHECKING([if unsigned literals are legal])
8851AC_CACHE_VAL(cf_cv_unsigned_literals,[
8852	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[long x = 1L + 1UL + 1U + 1; (void)x])],
8853		[cf_cv_unsigned_literals=yes],
8854		[cf_cv_unsigned_literals=no])
8855	])
8856AC_MSG_RESULT($cf_cv_unsigned_literals)
8857])dnl
8858dnl ---------------------------------------------------------------------------
8859dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
8860dnl --------
8861dnl Make an uppercase version of a variable
8862dnl $1=uppercase($2)
8863AC_DEFUN([CF_UPPER],
8864[
8865$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
8866])dnl
8867dnl ---------------------------------------------------------------------------
8868dnl CF_UTF8_LIB version: 12 updated: 2025/12/22 04:16:14
8869dnl -----------
8870dnl Check for multibyte support, and if not found, utf8 compatibility library
8871AC_DEFUN([CF_UTF8_LIB],
8872[
8873AC_CHECK_HEADERS(wchar.h)
8874AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
8875	cf_save_LIBS="$LIBS"
8876	AC_LINK_IFELSE([AC_LANG_PROGRAM([
8877$ac_includes_default
8878#ifdef HAVE_WCHAR_H
8879#include <wchar.h>
8880#endif
8881],[putwc(0,0);])],
8882	[cf_cv_utf8_lib=yes],
8883	[CF_FIND_LINKAGE([
8884#include <libutf8.h>],[putwc(0,0);],utf8,
8885		[cf_cv_utf8_lib=add-on],
8886		[cf_cv_utf8_lib=no])
8887])])
8888
8889# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
8890# ncurses/ncursesw:
8891if test "$cf_cv_utf8_lib" = "add-on" ; then
8892	AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
8893	CF_ADD_INCDIR($cf_cv_header_path_utf8)
8894	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
8895	CF_ADD_LIBS($cf_cv_library_file_utf8)
8896fi
8897])dnl
8898dnl ---------------------------------------------------------------------------
8899dnl CF_VA_COPY version: 7 updated: 2025/12/24 12:27:29
8900dnl ----------
8901dnl check for va_copy, part of stdarg.h starting with ISO C 1999.
8902dnl Also, workaround for glibc's __va_copy, by checking for both.
8903dnl Finally, try to accommodate pre-ISO C 1999 headers.
8904AC_DEFUN([CF_VA_COPY],[
8905AC_CACHE_CHECK(for va_copy, cf_cv_have_va_copy,[
8906AC_LINK_IFELSE([AC_LANG_PROGRAM([
8907#include <stdarg.h>
8908],[
8909	static va_list dst;
8910	static va_list src;
8911	va_copy(dst, src)])],
8912	cf_cv_have_va_copy=yes,
8913	cf_cv_have_va_copy=no)])
8914
8915if test "$cf_cv_have_va_copy" = yes;
8916then
8917	AC_DEFINE(HAVE_VA_COPY,1,[Define to 1 if we have va_copy])
8918else # !cf_cv_have_va_copy
8919
8920AC_CACHE_CHECK(for __va_copy, cf_cv_have___va_copy,[
8921AC_LINK_IFELSE([AC_LANG_PROGRAM([
8922#include <stdarg.h>
8923],[
8924	static va_list dst;
8925	static va_list src;
8926	__va_copy(dst, src)])],
8927	cf_cv_have___va_copy=yes,
8928	cf_cv_have___va_copy=no)])
8929
8930if test "$cf_cv_have___va_copy" = yes
8931then
8932	AC_DEFINE(HAVE___VA_COPY,1,[Define to 1 if we have __va_copy])
8933else # !cf_cv_have___va_copy
8934
8935AC_CACHE_CHECK(for __builtin_va_copy, cf_cv_have___builtin_va_copy,[
8936AC_LINK_IFELSE([AC_LANG_PROGRAM([
8937#include <stdarg.h>
8938],[
8939	static va_list dst;
8940	static va_list src;
8941	__builtin_va_copy(dst, src)])],
8942	cf_cv_have___builtin_va_copy=yes,
8943	cf_cv_have___builtin_va_copy=no)])
8944
8945test "$cf_cv_have___builtin_va_copy" = yes &&
8946	AC_DEFINE(HAVE___BUILTIN_VA_COPY,1,[Define to 1 if we have __builtin_va_copy])
8947
8948fi # cf_cv_have___va_copy
8949
8950fi # cf_cv_have_va_copy
8951
8952case "${cf_cv_have_va_copy}${cf_cv_have___va_copy}${cf_cv_have___builtin_va_copy}" in
8953(*yes*)
8954	;;
8955
8956(*)
8957	AC_CACHE_CHECK(if we can simply copy va_list, cf_cv_pointer_va_list,[
8958AC_LINK_IFELSE([AC_LANG_PROGRAM([
8959#include <stdarg.h>
8960],[
8961	va_list dst;
8962	va_list src;
8963	dst = src])],
8964	cf_cv_pointer_va_list=yes,
8965	cf_cv_pointer_va_list=no)])
8966
8967	if test "$cf_cv_pointer_va_list" = no
8968	then
8969		AC_CACHE_CHECK(if we can copy va_list indirectly, cf_cv_array_va_list,[
8970AC_LINK_IFELSE([AC_LANG_PROGRAM([
8971#include <stdarg.h>
8972],[
8973	va_list dst;
8974	va_list src;
8975	*dst = *src])],
8976			cf_cv_array_va_list=yes,
8977			cf_cv_array_va_list=no)])
8978		test "$cf_cv_array_va_list" = yes && AC_DEFINE(ARRAY_VA_LIST,1,[Define to 1 if we can copy va_list indirectly])
8979	fi
8980	;;
8981esac
8982])
8983dnl ---------------------------------------------------------------------------
8984dnl CF_VERBOSE version: 4 updated: 2025/12/14 17:51:46
8985dnl ----------
8986dnl Use AC_VERBOSE w/o the warnings
8987AC_DEFUN([CF_VERBOSE],
8988[test -n "$verbose" && echo "	$1" 1>&AS_MESSAGE_FD
8989CF_MSG_LOG([$1])
8990])dnl
8991dnl ---------------------------------------------------------------------------
8992dnl CF_VERSION_INFO version: 11 updated: 2025/09/20 13:27:11
8993dnl ---------------
8994dnl Define several useful symbols derived from the VERSION file.  A separate
8995dnl file is preferred to embedding the version numbers in various scripts.
8996dnl (automake is a textbook-example of why the latter is a bad idea, but there
8997dnl are others).
8998dnl
8999dnl The file contents are:
9000dnl	libtool-version	release-version	patch-version
9001dnl or
9002dnl	release-version
9003dnl where
9004dnl	libtool-version (see ?) consists of 3 integers separated by '.'
9005dnl	release-version consists of a major version and minor version
9006dnl		separated by '.', optionally followed by a patch-version
9007dnl		separated by '-'.  The minor version need not be an
9008dnl		integer (but it is preferred).
9009dnl	patch-version is an integer in the form yyyymmdd, so ifdef's and
9010dnl		scripts can easily compare versions.
9011dnl
9012dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
9013dnl simply extracts the first field using 'cut -f1'.
9014dnl
9015dnl Optional parameters:
9016dnl $1 = internal name for package
9017dnl $2 = external name for package
9018AC_DEFUN([CF_VERSION_INFO],
9019[
9020if test -f "$srcdir/VERSION" ; then
9021	AC_MSG_CHECKING(for package version)
9022
9023	# if there are not enough fields, cut returns the last one...
9024	cf_field1=`sed -e '2,$d' "$srcdir/VERSION" |cut -f1`
9025	cf_field2=`sed -e '2,$d' "$srcdir/VERSION" |cut -f2`
9026	cf_field3=`sed -e '2,$d' "$srcdir/VERSION" |cut -f3`
9027
9028	# this is how CF_BUNDLED_INTL uses $VERSION:
9029	VERSION="$cf_field1"
9030
9031	VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
9032	test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
9033
9034	VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
9035	test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
9036
9037	AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
9038
9039	AC_MSG_CHECKING(for package patch date)
9040	VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
9041	case .$VERSION_PATCH in
9042	(.)
9043		AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
9044		;;
9045	(.[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
9046		;;
9047	(*)
9048		AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
9049		;;
9050	esac
9051	AC_MSG_RESULT($VERSION_PATCH)
9052else
9053	AC_MSG_ERROR(did not find $srcdir/VERSION)
9054fi
9055
9056# show the actual data that we have for versions:
9057CF_VERBOSE(ABI VERSION $VERSION)
9058CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
9059CF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
9060CF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
9061
9062AC_SUBST(VERSION)
9063AC_SUBST(VERSION_MAJOR)
9064AC_SUBST(VERSION_MINOR)
9065AC_SUBST(VERSION_PATCH)
9066
9067dnl if a package name is given, define its corresponding version info.  We
9068dnl need the package name to ensure that the defined symbols are unique.
9069ifelse($1,,,[
9070	PROGRAM=$1
9071	PACKAGE=ifelse($2,,$1,$2)
9072	AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",[Define to the package-name])
9073	AC_SUBST(PROGRAM)
9074	AC_SUBST(PACKAGE)
9075	AH_TEMPLATE([AS_TR_CPP($1[_VERSION])],[version of package])
9076	AC_DEFINE_UNQUOTED(AS_TR_CPP($1[_VERSION]),"${VERSION_MAJOR}.${VERSION_MINOR}",[define to version of $1])
9077	AH_TEMPLATE([AS_TR_CPP($1[_PATCHDATE])],[patchdate of package])
9078	AC_DEFINE_UNQUOTED(AS_TR_CPP($1[_PATCHDATE]),${VERSION_PATCH},[define to patchdate of $1])
9079])
9080])dnl
9081dnl ---------------------------------------------------------------------------
9082dnl CF_WCHAR_TYPE version: 6 updated: 2025/12/24 12:27:29
9083dnl -------------
9084dnl Check if type wide-character type $1 is declared, and if so, which header
9085dnl file is needed.  The second parameter is used to set a shell variable when
9086dnl the type is not found.  The first parameter sets a shell variable for the
9087dnl opposite sense.
9088AC_DEFUN([CF_WCHAR_TYPE],
9089[
9090# This is needed on Tru64 5.0 to declare $1
9091AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
9092AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
9093#include <stdlib.h>
9094#include <stdarg.h>
9095#include <stdio.h>
9096#ifdef HAVE_LIBUTF8_H
9097#include <libutf8.h>
9098#endif],
9099	[$1 state; (void)state])],
9100	[cf_cv_$1=no],
9101	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
9102#include <stdlib.h>
9103#include <stdarg.h>
9104#include <stdio.h>
9105#include <wchar.h>
9106#ifdef HAVE_LIBUTF8_H
9107#include <libutf8.h>
9108#endif],
9109	[$1 value; (void) value])],
9110	[cf_cv_$1=yes],
9111	[cf_cv_$1=unknown])])])
9112
9113if test "$cf_cv_$1" = yes ; then
9114	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
9115	NEED_WCHAR_H=1
9116fi
9117
9118ifelse([$2],,,[
9119# if we do not find $1 in either place, use substitution to provide a fallback.
9120if test "$cf_cv_$1" = unknown ; then
9121	$2=1
9122fi
9123])
9124ifelse($3,,,[
9125# if we find $1 in either place, use substitution to provide a fallback.
9126if test "$cf_cv_$1" != unknown ; then
9127	$3=1
9128fi
9129])
9130])dnl
9131dnl ---------------------------------------------------------------------------
9132dnl CF_WEAK_SYMBOLS version: 2 updated: 2025/12/24 12:27:29
9133dnl ---------------
9134dnl Check for compiler-support for weak symbols.
9135dnl This works with "recent" gcc.
9136AC_DEFUN([CF_WEAK_SYMBOLS],[
9137AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
9138
9139AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
9140#include <stdio.h>],
9141[
9142#if defined(__GNUC__)
9143#  if defined __USE_ISOC99
9144#    define _cat_pragma(exp)	_Pragma(#exp)
9145#    define _weak_pragma(exp)	_cat_pragma(weak name)
9146#  else
9147#    define _weak_pragma(exp)
9148#  endif
9149#  define _declare(name)	__extension__ extern __typeof__(name) name
9150#  define weak_symbol(name)	_weak_pragma(name) _declare(name) __attribute__((weak))
9151#endif
9152
9153weak_symbol(fopen);
9154])],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
9155])
9156])dnl
9157dnl ---------------------------------------------------------------------------
9158dnl CF_WITH_ABI_ALTERED version: 1 updated: 2023/01/07 16:32:06
9159dnl -------------------
9160dnl Provide a way to override the displayed ABI version, e.g., in filenames.
9161dnl Check this option after using the ABI version in configuration decisions.
9162AC_DEFUN([CF_WITH_ABI_ALTERED],[
9163AC_REQUIRE([CF_WITH_ABI_VERSION])
9164AC_REQUIRE([CF_ABI_DEFAULTS])
9165AC_ARG_WITH(abi-altered,
9166[  --with-abi-altered=XXX  override visible ABI version, for packaging],[
9167	CF_NUMBER_SYNTAX($withval,ABI altered)
9168	if test "$cf_cv_abi_version" != "$withval"
9169	then
9170		AC_MSG_WARN(altering visible ABI from $cf_cv_abi_version to $withval)
9171		cf_cv_abi_version=$withval
9172	fi
9173])dnl
9174])dnl
9175dnl ---------------------------------------------------------------------------
9176dnl CF_WITH_ABI_VERSION version: 5 updated: 2023/01/07 16:32:06
9177dnl -------------------
9178dnl Allow library's ABI to be overridden.  Generally this happens when a
9179dnl packager has incremented the ABI past that used in the original package,
9180dnl and wishes to keep doing this.
9181dnl
9182dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
9183dnl symbol.
9184AC_DEFUN([CF_WITH_ABI_VERSION],[
9185test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
9186AC_ARG_WITH(abi-version,
9187[  --with-abi-version=XXX  override derived ABI version],[
9188	if test "x$cf_cv_abi_version" != "x$withval"
9189	then
9190		AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
9191		case "$cf_cv_rel_version" in
9192		(5.*)
9193			cf_cv_rel_version=$withval.0
9194			;;
9195		(6.*)
9196			cf_cv_rel_version=$withval.9	# FIXME: should be 10 as of 6.0 release
9197			;;
9198		esac
9199	fi
9200	cf_cv_abi_version=$withval])
9201	CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
9202ifelse($1,,,[
9203$1_ABI=$cf_cv_abi_version
9204])
9205cf_cv_abi_default=$cf_cv_abi_version
9206])dnl
9207dnl ---------------------------------------------------------------------------
9208dnl CF_WITH_ADA version: 2 updated: 2024/11/09 18:07:29
9209dnl -----------
9210dnl Check for the Ada compiler (unless requested to not do this), which causes
9211dnl a further check for a C compiler which can work with the Ada compiler.
9212AC_DEFUN([CF_WITH_ADA],[
9213AC_ARG_WITH(ada,
9214	[  --without-ada           suppress check for Ada compiler],
9215	[cf_with_ada=$withval],
9216	[cf_with_ada=yes])
9217
9218cf_prog_cc="gcc cc"
9219if test "x$cf_with_ada" = xyes
9220then
9221	CF_PROG_GNAT
9222	if test	"x$cf_cv_prog_gnat_correct" = xyes; then
9223		# gcc's developers chose to deprecate gnatgcc before making gprconfig
9224		# work.  They replaced gnatgcc in gcc 13 with a script which spits out
9225		# a warning offering advice which could never work.
9226		#
9227		# Here is a workaround.
9228		AC_PATH_PROG(cf_cv_path_gnatgcc,gnatgcc,no)
9229		if test "$cf_cv_path_gnatgcc" != no
9230		then
9231			AC_MSG_CHECKING(for improvement)
9232			cf_file_gnatgcc=`file -L "$cf_cv_path_gnatgcc" 2>/dev/null`
9233			case "x$cf_file_gnatgcc" in
9234			(*script*)
9235				cf_cv_path_gnatgcc=`sh -x "$cf_cv_path_gnatgcc" --version 2>&1 | grep -w exec | sed -e 's/^[[ 	]]*+[[ 	]]*//' -e 's/exec[[ 	]]//' -e 's/ .*//'`
9236				;;
9237			(*)
9238				cf_cv_path_gnatgcc=no
9239				;;
9240			esac
9241			AC_MSG_RESULT($cf_cv_path_gnatgcc)
9242			test "$cf_cv_path_gnatgcc" = no && cf_cv_path_gnatgcc=gnatgcc
9243			cf_prog_cc="$cf_cv_path_gnatgcc $cf_prog_cc"
9244		fi
9245	fi
9246fi
9247case "$cf_prog_cc" in
9248(*/*)
9249	CC="$cf_prog_cc"
9250	AC_SUBST(CC)
9251	;;
9252(*)
9253	CF_PROG_CC($cf_prog_cc)
9254	;;
9255esac
9256])dnl
9257dnl ---------------------------------------------------------------------------
9258dnl CF_WITH_ADA_COMPILER version: 3 updated: 2023/10/28 11:59:01
9259dnl --------------------
9260dnl Command-line option to specify the Ada95 compiler.
9261AC_DEFUN([CF_WITH_ADA_COMPILER],[
9262AC_MSG_CHECKING(for Ada95 compiler)
9263AC_ARG_WITH(ada-compiler,
9264	[[  --with-ada-compiler[=CMD] use CMD as Ada95 compiler (default: gnatmake)]],
9265	[cf_ada_compiler=$withval],
9266	[cf_ada_compiler=gnatmake])
9267AC_SUBST(cf_ada_compiler)
9268AC_MSG_RESULT($cf_ada_compiler)
9269])dnl
9270dnl ---------------------------------------------------------------------------
9271dnl CF_WITH_ADA_INCLUDE version: 3 updated: 2023/10/28 11:59:01
9272dnl -------------------
9273dnl Command-line option to specify where Ada includes will install.
9274AC_DEFUN([CF_WITH_ADA_INCLUDE],[
9275AC_MSG_CHECKING(for Ada95 include directory)
9276CF_WITH_PATH(ada-include,
9277   [  --with-ada-include=DIR  find Ada95 includes in DIR],
9278   ADA_INCLUDE,
9279   PREFIX/share/ada/adainclude,
9280   [$]prefix/share/ada/adainclude)
9281AC_SUBST(ADA_INCLUDE)
9282AC_MSG_RESULT($ADA_INCLUDE)
9283])dnl
9284dnl ---------------------------------------------------------------------------
9285dnl CF_WITH_ADA_LIBNAME version: 3 updated: 2023/11/22 20:48:30
9286dnl -------------------
9287dnl CF_WITH_ADA_LIBNAME
9288dnl -------------------
9289dnl Command-line option to specify how to name the resulting Ada library.
9290dnl $1 = default value
9291AC_DEFUN([CF_WITH_ADA_LIBNAME],[
9292AC_MSG_CHECKING(for Ada95 curses library name)
9293AC_ARG_WITH(ada-libname,
9294   [[  --with-ada-libname[=XXX]  use XXX as Ada95 library name]],
9295   ADA_LIBNAME=[$]withval,
9296   ADA_LIBNAME=$1)
9297case "x$ADA_LIBNAME" in
9298(x|xyes|xno)
9299	ADA_LIBNAME=$1
9300	;;
9301esac
9302AC_SUBST(ADA_LIBNAME)
9303AC_MSG_RESULT($ADA_LIBNAME)
9304])dnl
9305dnl ---------------------------------------------------------------------------
9306dnl CF_WITH_ADA_OBJECTS version: 3 updated: 2023/10/28 11:59:01
9307dnl -------------------
9308dnl Command-line option to specify where Ada objects will install.
9309AC_DEFUN([CF_WITH_ADA_OBJECTS],[
9310AC_MSG_CHECKING(for Ada95 object directory)
9311CF_WITH_PATH(ada-objects,
9312   [  --with-ada-objects=DIR  find Ada95 objects in DIR],
9313   ADA_OBJECTS,
9314   PREFIX/lib/ada/adalib,
9315   [$]prefix/lib/ada/adalib)
9316AC_SUBST(ADA_OBJECTS)
9317AC_MSG_RESULT($ADA_OBJECTS)
9318])dnl
9319dnl ---------------------------------------------------------------------------
9320dnl CF_WITH_ADA_SHAREDLIB version: 6 updated: 2023/10/28 11:59:01
9321dnl ---------------------
9322dnl Command-line option to specify if an Ada95 shared library should be built,
9323dnl and optionally what its soname should be.
9324AC_DEFUN([CF_WITH_ADA_SHAREDLIB],[
9325AC_REQUIRE([CF_GNAT_PROJECTS])
9326AC_MSG_CHECKING(whether to build an Ada95 shared library)
9327AC_ARG_WITH(ada-sharedlib,
9328	[  --with-ada-sharedlib    build Ada95 shared library; requires GNAT project support],
9329	[with_ada_sharedlib=$withval],
9330	[with_ada_sharedlib=no])
9331cf_ada_sharedlib_warn=no
9332
9333if test "x$with_ada_sharedlib" != xno
9334then
9335	if test "x$cf_gnat_projects" != xyes
9336	then
9337		with_ada_sharedlib=no
9338		cf_ada_sharedlib_warn=yes
9339	fi
9340fi
9341
9342AC_MSG_RESULT($with_ada_sharedlib)
9343if test "x$cf_ada_sharedlib_warn" != xno
9344then
9345	AC_MSG_WARN(disabling Ada95 shared library since GNAT projects are not supported)
9346fi
9347
9348ADA_SHAREDLIB='lib$(LIB_NAME).so.1'
9349MAKE_ADA_SHAREDLIB="#"
9350
9351if test "x$with_ada_sharedlib" != xno
9352then
9353	MAKE_ADA_SHAREDLIB=
9354	if test "x$with_ada_sharedlib" != xyes
9355	then
9356		ADA_SHAREDLIB="$with_ada_sharedlib"
9357	fi
9358fi
9359
9360AC_SUBST(ADA_SHAREDLIB)
9361AC_SUBST(MAKE_ADA_SHAREDLIB)
9362])dnl
9363dnl ---------------------------------------------------------------------------
9364dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
9365dnl ----------------
9366dnl Configure-option for dbmalloc.  The optional parameter is used to override
9367dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
9368AC_DEFUN([CF_WITH_DBMALLOC],[
9369CF_NO_LEAKS_OPTION(dbmalloc,
9370	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
9371	[USE_DBMALLOC])
9372
9373if test "$with_dbmalloc" = yes ; then
9374	AC_CHECK_HEADER(dbmalloc.h,
9375		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
9376fi
9377])dnl
9378dnl ---------------------------------------------------------------------------
9379dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
9380dnl ---------------
9381dnl Configure-option for dmalloc.  The optional parameter is used to override
9382dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
9383AC_DEFUN([CF_WITH_DMALLOC],[
9384CF_NO_LEAKS_OPTION(dmalloc,
9385	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
9386	[USE_DMALLOC])
9387
9388if test "$with_dmalloc" = yes ; then
9389	AC_CHECK_HEADER(dmalloc.h,
9390		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
9391fi
9392])dnl
9393dnl ---------------------------------------------------------------------------
9394dnl CF_WITH_EXPORT_SYMS version: 5 updated: 2023/11/22 20:48:30
9395dnl -------------------
9396dnl Use this with libtool to specify the list of symbols that may be exported.
9397dnl The input file contains one symbol per line; comments work with "#".
9398dnl
9399dnl $1 = basename of the ".sym" file (default $PACKAGE)
9400AC_DEFUN([CF_WITH_EXPORT_SYMS],
9401[
9402AC_MSG_CHECKING(if exported-symbols file should be used)
9403AC_ARG_WITH(export-syms,
9404	[[  --with-export-syms[=SYM-FILE] limit symbols exported by libtool to those listed in SYM-FILE]],
9405	[with_export_syms=$withval],
9406	[with_export_syms=no])
9407if test "x$with_export_syms" = xyes
9408then
9409	with_export_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).sym'
9410	AC_SUBST(PACKAGE)
9411fi
9412AC_MSG_RESULT($with_export_syms)
9413if test "x$with_export_syms" != xno
9414then
9415	EXPORT_SYMS="-export-symbols $with_export_syms"
9416	AC_SUBST(EXPORT_SYMS)
9417fi
9418])dnl
9419dnl ---------------------------------------------------------------------------
9420dnl CF_WITH_GPM version: 10 updated: 2017/04/29 18:32:18
9421dnl -----------
9422dnl
9423dnl The option parameter (if neither yes/no) is assumed to be the name of
9424dnl the gpm library, e.g., for dynamic loading.
9425AC_DEFUN([CF_WITH_GPM],
9426[
9427AC_MSG_CHECKING(if you want to link with the GPM mouse library)
9428AC_ARG_WITH(gpm,
9429	[  --with-gpm              use Alessandro Rubini's GPM library],
9430	[with_gpm=$withval],
9431	[with_gpm=maybe])
9432AC_MSG_RESULT($with_gpm)
9433
9434if test "$with_gpm" != no ; then
9435	AC_CHECK_HEADER(gpm.h,[
9436		AC_DEFINE(HAVE_GPM_H,1,[Define to 1 if we have gpm.h header])
9437		if test "$with_gpm" != yes && test "$with_gpm" != maybe ; then
9438			CF_VERBOSE(assuming we really have GPM library)
9439			AC_DEFINE(HAVE_LIBGPM,1,[Define to 1 if we have the gpm library])
9440			with_gpm=yes
9441		else
9442			AC_CHECK_LIB(gpm,Gpm_Open,[with_gpm=yes],[
9443				if test "$with_gpm" = maybe; then
9444					AC_MSG_WARN(Cannot link with GPM library)
9445					with_gpm=no
9446				else
9447					AC_MSG_ERROR(Cannot link with GPM library)
9448				fi
9449			])
9450		fi
9451	],[
9452		test "$with_gpm" != maybe && AC_MSG_WARN(Cannot find GPM header)
9453		with_gpm=no
9454	])
9455fi
9456])
9457dnl ---------------------------------------------------------------------------
9458dnl CF_WITH_LIBTOOL version: 38 updated: 2025/10/01 18:05:23
9459dnl ---------------
9460dnl Provide a configure option to incorporate libtool.  Define several useful
9461dnl symbols for the makefile rules.
9462dnl
9463dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
9464dnl macros from libtool.m4 which is in the aclocal directory of automake.
9465dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
9466dnl But that still does not work properly since the macro is expanded outside
9467dnl the CF_WITH_LIBTOOL macro:
9468dnl
9469dnl	#!/bin/sh
9470dnl	ACLOCAL=`aclocal --print-ac-dir`
9471dnl	if test -z "$ACLOCAL" ; then
9472dnl		echo cannot find aclocal directory
9473dnl		exit 1
9474dnl	elif test ! -f $ACLOCAL/libtool.m4 ; then
9475dnl		echo cannot find libtool.m4 file
9476dnl		exit 1
9477dnl	fi
9478dnl
9479dnl	LOCAL=aclocal.m4
9480dnl	ORIG=aclocal.m4.orig
9481dnl
9482dnl	trap "mv $ORIG $LOCAL" 0 1 2 3 15
9483dnl	rm -f $ORIG
9484dnl	mv $LOCAL $ORIG
9485dnl
9486dnl	# sed the LIBTOOL= assignment to omit the current directory?
9487dnl	sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL:-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
9488dnl	cat $ORIG >>$LOCAL
9489dnl
9490dnl	autoconf-257 $*
9491dnl
9492AC_DEFUN([CF_WITH_LIBTOOL],
9493[
9494AC_REQUIRE([CF_DISABLE_LIBTOOL_VERSION])
9495ifdef([AC_PROG_LIBTOOL],,[
9496LIBTOOL=
9497])
9498# common library maintenance symbols that are convenient for libtool scripts:
9499LIB_CREATE='${AR} -cr'
9500LIB_OBJECT='${OBJECTS}'
9501LIB_SUFFIX=.a
9502LIB_PREP="$RANLIB"
9503
9504# symbols used to prop libtool up to enable it to determine what it should be
9505# doing:
9506LIB_CLEAN=
9507LIB_COMPILE=
9508LIB_LINK='${CC}'
9509LIB_INSTALL=
9510LIB_UNINSTALL=
9511
9512AC_MSG_CHECKING(if you want to build libraries with libtool)
9513AC_ARG_WITH(libtool,
9514	[  --with-libtool          generate libraries with libtool],
9515	[with_libtool=$withval],
9516	[with_libtool=no])
9517AC_MSG_RESULT($with_libtool)
9518if test "$with_libtool" != "no"; then
9519ifdef([AC_PROG_LIBTOOL],[
9520	# missing_content_AC_PROG_LIBTOOL{{
9521	AC_PROG_LIBTOOL
9522	# missing_content_AC_PROG_LIBTOOL}}
9523],[
9524	if test "$with_libtool" != "yes" ; then
9525		CF_PATH_SYNTAX(with_libtool)
9526		LIBTOOL=$with_libtool
9527	else
9528		AC_CHECK_TOOLS(LIBTOOL,[libtool glibtool],none)
9529		CF_LIBTOOL_VERSION
9530		if test -z "$cf_cv_libtool_version" && test "$LIBTOOL" = libtool
9531		then
9532			CF_FORGET_TOOL(LIBTOOL)
9533			AC_CHECK_TOOLS(LIBTOOL,[glibtool],none)
9534			CF_LIBTOOL_VERSION
9535		fi
9536	fi
9537	if test -z "$LIBTOOL" ; then
9538		AC_MSG_ERROR(Cannot find libtool)
9539	fi
9540])dnl
9541	LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${libdir} ${LIBTOOL_VERSION} `cut -f1 ${top_srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} $(LIBS) -o'
9542	LIB_OBJECT='${OBJECTS:.${OBJEXT}=.lo}'
9543	LIB_SUFFIX=.la
9544	LIB_CLEAN='${LIBTOOL} --mode=clean'
9545	LIB_COMPILE='${LIBTOOL} --mode=compile'
9546	LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
9547	LIB_INSTALL='${LIBTOOL} --mode=install'
9548	LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
9549	LIB_PREP=:
9550
9551	CF_CHECK_LIBTOOL_VERSION
9552
9553	# special hack to add -no-undefined (which libtool should do for itself)
9554	LT_UNDEF=
9555	case "$cf_cv_system_name" in
9556	(cygwin*|msys*|mingw32*|os2*|uwin*|aix[[4-7]])
9557		LT_UNDEF=-no-undefined
9558		;;
9559	esac
9560	AC_SUBST([LT_UNDEF])
9561
9562	# special hack to add --tag option for C++ compiler
9563	case "$cf_cv_libtool_version" in
9564	(1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*)
9565		LIBTOOL_CXX="$LIBTOOL --tag=CXX"
9566		LIBTOOL="$LIBTOOL --tag=CC"
9567		;;
9568	(*)
9569		LIBTOOL_CXX="$LIBTOOL"
9570		;;
9571	esac
9572else
9573	LIBTOOL=""
9574	LIBTOOL_CXX=""
9575fi
9576
9577test -z "$LIBTOOL" && ECHO_LT=
9578
9579AC_SUBST(LIBTOOL)
9580AC_SUBST(LIBTOOL_CXX)
9581AC_SUBST(LIBTOOL_OPTS)
9582
9583AC_SUBST(LIB_CREATE)
9584AC_SUBST(LIB_OBJECT)
9585AC_SUBST(LIB_SUFFIX)
9586AC_SUBST(LIB_PREP)
9587
9588AC_SUBST(LIB_CLEAN)
9589AC_SUBST(LIB_COMPILE)
9590AC_SUBST(LIB_LINK)
9591AC_SUBST(LIB_INSTALL)
9592AC_SUBST(LIB_UNINSTALL)
9593
9594])dnl
9595dnl ---------------------------------------------------------------------------
9596dnl CF_WITH_LIBTOOL_OPTS version: 6 updated: 2023/11/22 20:48:30
9597dnl --------------------
9598dnl Allow user to pass additional libtool options into the library creation
9599dnl and link steps.  The main use for this is to do something like
9600dnl	./configure --with-libtool-opts=-static
9601dnl to get the same behavior as automake-flavored
9602dnl	./configure --enable-static
9603AC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
9604AC_MSG_CHECKING(for additional libtool options)
9605AC_ARG_WITH(libtool-opts,
9606	[[  --with-libtool-opts[=XXX] give libtool additional options XXX]],
9607	[with_libtool_opts=$withval],
9608	[with_libtool_opts=no])
9609AC_MSG_RESULT($with_libtool_opts)
9610
9611case .$with_libtool_opts in
9612(.yes|.no|.)
9613	;;
9614(*)
9615	LIBTOOL_OPTS="$LIBTOOL_OPTS $with_libtool_opts"
9616	;;
9617esac
9618
9619AC_SUBST(LIBTOOL_OPTS)
9620])dnl
9621dnl ---------------------------------------------------------------------------
9622dnl CF_WITH_LIB_BASENAME version: 2 updated: 2023/11/22 20:48:30
9623dnl --------------------
9624dnl Allow for overriding the basename of a library, i.e., the part to which
9625dnl prefixes/suffixes are attached.
9626dnl
9627dnl $1 = variable to set
9628dnl $2 = option name
9629dnl $3 = default basename for library, if omitted use $2
9630AC_DEFUN([CF_WITH_LIB_BASENAME],
9631[
9632AC_MSG_CHECKING(for desired basename for $2 library)
9633AC_ARG_WITH($2-libname,
9634	[[  --with-$2-libname[=XXX] override ifelse($3,,$2,$3) basename of library]],
9635	[with_lib_basename=$withval],
9636	[with_lib_basename=ifelse($3,,$2,$3)])
9637$1="$with_lib_basename"
9638
9639case "x[$]$1" in
9640(x|xno|xnone|xyes)
9641	$1=ifelse($3,,$2,$3)
9642	;;
9643(*)
9644	;;
9645esac
9646
9647AC_MSG_RESULT([$]$1)
9648AC_SUBST($1)
9649])dnl
9650dnl ---------------------------------------------------------------------------
9651dnl CF_WITH_LIB_PREFIX version: 2 updated: 2021/01/01 16:53:59
9652dnl ------------------
9653dnl Allow the library-prefix to be overridden.  OS/2 EMX originally had no
9654dnl "lib" prefix, e.g., because it used the dll naming convention.
9655dnl
9656dnl $1 = variable to set
9657AC_DEFUN([CF_WITH_LIB_PREFIX],
9658[
9659AC_MSG_CHECKING(if you want to have a library-prefix)
9660AC_ARG_WITH(lib-prefix,
9661	[  --with-lib-prefix       override library-prefix],
9662	[with_lib_prefix=$withval],
9663	[with_lib_prefix=auto])
9664AC_MSG_RESULT($with_lib_prefix)
9665
9666if test "$with_lib_prefix" = auto
9667then
9668	CF_LIB_PREFIX($1)
9669elif test "$with_lib_prefix" = no
9670then
9671	LIB_PREFIX=
9672else
9673	LIB_PREFIX=$with_lib_prefix
9674fi
9675])dnl
9676dnl ---------------------------------------------------------------------------
9677dnl CF_WITH_PATH version: 12 updated: 2021/09/04 06:35:04
9678dnl ------------
9679dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
9680dnl defaulting to yes/no.
9681dnl
9682dnl $1 = option name
9683dnl $2 = help-text
9684dnl $3 = environment variable to set
9685dnl $4 = default value, shown in the help-message, must be a constant
9686dnl $5 = default value, if it is an expression & cannot be in the help-message
9687dnl
9688AC_DEFUN([CF_WITH_PATH],
9689[AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
9690ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
9691if ifelse([$5],,true,[test -n "$5"]) ; then
9692CF_PATH_SYNTAX(withval)
9693fi
9694eval $3="$withval"
9695AC_SUBST($3)dnl
9696])dnl
9697dnl ---------------------------------------------------------------------------
9698dnl CF_WITH_PATHLIST version: 13 updated: 2021/09/04 06:35:04
9699dnl ----------------
9700dnl Process an option specifying a list of colon-separated paths.
9701dnl
9702dnl $1 = option name
9703dnl $2 = help-text
9704dnl $3 = environment variable to set
9705dnl $4 = default value, shown in the help-message, must be a constant
9706dnl $5 = default value, if it is an expression & cannot be in the help-message
9707dnl $6 = flag to tell if we want to define or substitute
9708dnl
9709AC_DEFUN([CF_WITH_PATHLIST],[
9710AC_REQUIRE([CF_PATHSEP])
9711AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
9712ifelse($4,,[withval=${$3}],[withval=${$3:-ifelse($5,,$4,$5)}]))dnl
9713
9714IFS="${IFS:- 	}"; ac_save_ifs="$IFS"; IFS="${PATH_SEPARATOR}"
9715cf_dst_path=
9716for cf_src_path in $withval
9717do
9718  CF_PATH_SYNTAX(cf_src_path)
9719  test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}$PATH_SEPARATOR"
9720  cf_dst_path="${cf_dst_path}${cf_src_path}"
9721done
9722IFS="$ac_save_ifs"
9723
9724ifelse($6,define,[
9725# Strip single quotes from the value, e.g., when it was supplied as a literal
9726# for $4 or $5.
9727case "$cf_dst_path" in
9728(\'*)
9729  cf_dst_path="`echo "$cf_dst_path" |sed -e s/\'// -e s/\'\$//`"
9730  ;;
9731esac
9732cf_dst_path=`echo "$cf_dst_path" | sed -e 's/\\\\/\\\\\\\\/g'`
9733])
9734
9735# This may use the prefix/exec_prefix symbols which will only yield "NONE"
9736# so we have to check/work around.  We do prefer the result of "eval"...
9737eval cf_dst_eval="$cf_dst_path"
9738case "x$cf_dst_eval" in
9739(xNONE*)
9740	$3=$cf_dst_path
9741	;;
9742(*)
9743	$3="$cf_dst_eval"
9744	;;
9745esac
9746AC_SUBST($3)dnl
9747
9748])dnl
9749dnl ---------------------------------------------------------------------------
9750dnl CF_WITH_PATH_PROG version: 1 updated: 2019/06/30 19:44:43
9751dnl -----------------
9752dnl Check for a given program, like CF_PATH_PROG, but allow override using a
9753dnl "--with-xxx" option.
9754dnl
9755dnl Parameters:
9756dnl		$1 = environment variable to set/update
9757dnl		$2 = program name
9758dnl		$3 = help-text
9759dnl		$4 = $PATH
9760AC_DEFUN([CF_WITH_PATH_PROG],[
9761AC_ARG_WITH($2-path,
9762	[  --with-$2-path=XXX     specify path of $2 ifelse($3,,,$3)],
9763	[AC_MSG_CHECKING(for $2 program ifelse($3,,,$3))
9764		$1=$withval
9765		AC_MSG_RESULT([$]$1)
9766		CF_PATH_SYNTAX($1)
9767	],
9768	[CF_PATH_PROG($1,$2,,ifelse($4,,,$4))
9769		if test -z "[$]$1"
9770		then
9771			AC_MSG_WARN(no $2 program found ifelse($3,,,$3))
9772		fi
9773	])
9774])
9775dnl ---------------------------------------------------------------------------
9776dnl CF_WITH_PCRE2 version: 6 updated: 2021/08/11 20:35:34
9777dnl -------------
9778dnl Add PCRE2 (Perl-compatible regular expressions v2) to the build if it is
9779dnl available and the user requests it.  Assume the application will otherwise
9780dnl use the POSIX interface.
9781dnl
9782dnl TODO allow $withval to specify package location
9783AC_DEFUN([CF_WITH_PCRE2],
9784[
9785AC_REQUIRE([CF_PKG_CONFIG])
9786
9787AC_MSG_CHECKING(if you want to use PCRE2 for regular-expressions)
9788AC_ARG_WITH(pcre2,
9789	[  --with-pcre2            use PCRE2 for regular-expressions])
9790test -z "$with_pcre2" && with_pcre2=no
9791AC_MSG_RESULT($with_pcre2)
9792
9793if test "x$with_pcre2" != xno ; then
9794	cf_with_pcre2_ok=no
9795	for cf_with_pcre2 in libpcre2 libpcre2-posix libpcre
9796	do
9797		CF_TRY_PKG_CONFIG($cf_with_pcre2,[cf_with_pcre2_ok=yes; break])
9798	done
9799	cf_with_pcre2_ok=yes || AC_MSG_ERROR(Cannot find PCRE2 library)
9800
9801	AC_DEFINE(HAVE_LIB_PCRE2,1,[Define to 1 if we can/should compile with the PCRE2 library])
9802
9803	# if pkgconfig gave no results, look for the libraries directly
9804	case "$LIBS" in
9805	(*pcre2-posix*|*pcreposix*)
9806		;;
9807	(*)
9808		AC_CHECK_LIB(pcre2-posix,regcomp,[
9809			CF_ADD_LIB(pcre2-posix)],
9810			[AC_CHECK_LIB(pcreposix,regcomp,[
9811			 CF_ADD_LIB(pcreposix)
9812			],[AC_MSG_ERROR(Cannot find PCRE2 POSIX library)])])
9813		;;
9814	esac
9815
9816	# either way, check for the library header files
9817	AC_CHECK_HEADERS(pcre2posix.h pcreposix.h)
9818	AC_CHECK_FUNCS(PCRE2regcomp)
9819fi
9820])dnl
9821dnl ---------------------------------------------------------------------------
9822dnl CF_WITH_PKG_CONFIG_LIBDIR version: 25 updated: 2024/08/03 13:34:29
9823dnl -------------------------
9824dnl Allow the choice of the pkg-config library directory to be overridden.
9825dnl
9826dnl pkg-config uses a search-list built from these colon-separated lists of
9827dnl directories:
9828dnl a) $PKG_CONFIG_PATH (tested first, added if set)
9829dnl b) $PKG_CONFIG_LIBDIR (tested second, added if set)
9830dnl c) builtin-list (added if $PKG_CONFIG_LIBDIR is not set)
9831dnl
9832dnl pkgconf (used with some systems such as FreeBSD in place of pkg-config)
9833dnl optionally ignores $PKG_CONFIG_LIBDIR.  Very old versions of pkg-config,
9834dnl e.g., Solaris 10 also do not recognize $PKG_CONFIG_LIBDIR.
9835AC_DEFUN([CF_WITH_PKG_CONFIG_LIBDIR],[
9836AC_REQUIRE([CF_GLOB_FULLPATH])dnl
9837
9838case "$PKG_CONFIG" in
9839(no|none|yes)
9840	AC_MSG_CHECKING(for pkg-config library directory)
9841	;;
9842(*)
9843	AC_MSG_CHECKING(for $PKG_CONFIG library directory)
9844	;;
9845esac
9846
9847# if $PKG_CONFIG_LIBDIR is set, try to use that
9848if test -n "$PKG_CONFIG_PATH"; then
9849	cf_search_path=`echo "$PKG_CONFIG_PATH" | sed -e 's/:/ /g' -e 's,^[[ 	]]*,,' -e 's,[[ 	]]*$,,'`
9850elif test -n "$PKG_CONFIG_LIBDIR"; then
9851	cf_search_path=`echo "$PKG_CONFIG_LIBDIR" | sed -e 's/:/ /g' -e 's,^[[ 	]]*,,' -e 's,[[ 	]]*$,,'`
9852else
9853	cf_search_path=auto
9854fi
9855
9856# if the option is used, let that override.  otherwise default to "libdir"
9857AC_ARG_WITH(pkg-config-libdir,
9858	[[  --with-pkg-config-libdir[=XXX] use given directory for installing pc-files]],
9859	[cf_search_path=$withval],
9860	[test "x$PKG_CONFIG" != xnone && test -z "$cf_search_path" && cf_search_path=libdir])
9861
9862case "x$cf_search_path" in
9863(xlibdir)
9864	PKG_CONFIG_LIBDIR='${libdir}/pkgconfig'
9865	AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
9866	cf_search_path=
9867	;;
9868(x)
9869	;;
9870(x$GLOB_FULLPATH_POSIX\ *|x$GLOB_FULLPATH_OTHER\ *)
9871	PKG_CONFIG_LIBDIR=
9872	;;
9873(x$GLOB_FULLPATH_POSIX|x$GLOB_FULLPATH_OTHER)
9874	PKG_CONFIG_LIBDIR="$cf_search_path"
9875	AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
9876	cf_search_path=
9877	;;
9878(xyes|xauto)
9879	AC_MSG_RESULT(auto)
9880	cf_search_path=
9881	# Look for the library directory using the same prefix as the executable
9882	AC_MSG_CHECKING(for search-list)
9883	if test "x$PKG_CONFIG" != xnone
9884	then
9885		# works for pkg-config since version 0.24 (2009)
9886		# works for pkgconf since version 0.8.3 (2012)
9887		for cf_pkg_program in \
9888			`echo "$PKG_CONFIG" | sed -e 's,^.*/,,'` \
9889			pkg-config \
9890			pkgconf
9891		do
9892			cf_raw_search_path=`"$PKG_CONFIG" --variable=pc_path "$cf_pkg_program" 2>/dev/null`
9893			case "$cf_raw_search_path" in
9894			(*\\*)
9895				cf_search_path=`echo "$cf_raw_search_path" | tr ';' ' ' | tr '\' '/'`
9896				;;
9897			(*/*)
9898				cf_search_path=`echo "$cf_raw_search_path" | tr : ' '`
9899				;;
9900			esac
9901			test -n "$cf_search_path" && break
9902		done
9903
9904		# works for pkg-config since import in 2005 of original 2001 HP code.
9905		test -z "$cf_search_path" && \
9906		cf_search_path=`
9907		"$PKG_CONFIG" --debug --exists no-such-package 2>&1 | $AWK "\
9908/^Scanning directory (#[1-9][0-9]* )?'.*'$/{ \
9909	sub(\"^[[^']]*'\",\"\"); \
9910	sub(\"'.*\",\"\"); \
9911	printf \" %s\", \\[$]0; } \
9912{ next; } \
9913"`
9914	fi
9915
9916	AC_MSG_RESULT($cf_search_path)
9917	;;
9918(*)
9919	AC_MSG_ERROR(Unexpected option value: $cf_search_path)
9920	;;
9921esac
9922
9923if test -n "$cf_search_path"
9924then
9925	AC_MSG_CHECKING(for first directory)
9926	cf_pkg_config_path=none
9927	for cf_config in $cf_search_path
9928	do
9929		if test -d "$cf_config"
9930		then
9931			cf_pkg_config_path=$cf_config
9932			break
9933		fi
9934	done
9935	AC_MSG_RESULT($cf_pkg_config_path)
9936
9937	if test "x$cf_pkg_config_path" != xnone ; then
9938		# limit this to the first directory found
9939		PKG_CONFIG_LIBDIR="$cf_pkg_config_path"
9940	fi
9941
9942	if test -z "$PKG_CONFIG_LIBDIR" && test -n "$cf_search_path"
9943	then
9944		AC_MSG_CHECKING(for workaround)
9945		if test "$prefix" = "NONE" ; then
9946			cf_prefix="$ac_default_prefix"
9947		else
9948			cf_prefix="$prefix"
9949		fi
9950		eval cf_libdir=$libdir
9951		cf_libdir=`echo "$cf_libdir" | sed -e "s,^NONE,$cf_prefix,"`
9952		cf_backup=
9953		for cf_config in $cf_search_path
9954		do
9955			case $cf_config in
9956			$cf_libdir/pkgconfig)
9957				PKG_CONFIG_LIBDIR=$cf_libdir/pkgconfig
9958				break
9959				;;
9960			*)
9961				test -z "$cf_backup" && cf_backup=$cf_config
9962				;;
9963			esac
9964		done
9965		test -z "$PKG_CONFIG_LIBDIR" && PKG_CONFIG_LIBDIR=$cf_backup
9966		AC_MSG_RESULT($PKG_CONFIG_LIBDIR)
9967	fi
9968fi
9969
9970AC_SUBST(PKG_CONFIG_LIBDIR)
9971])dnl
9972dnl ---------------------------------------------------------------------------
9973dnl CF_WITH_PTHREAD version: 8 updated: 2025/12/24 12:27:29
9974dnl ---------------
9975dnl Check for POSIX thread library.
9976AC_DEFUN([CF_WITH_PTHREAD],
9977[
9978AC_MSG_CHECKING(if you want to link with the pthread library)
9979AC_ARG_WITH(pthread,
9980	[  --with-pthread          use POSIX thread library],
9981	[with_pthread=$withval],
9982	[with_pthread=no])
9983AC_MSG_RESULT($with_pthread)
9984
9985if test "$with_pthread" != no ; then
9986	AC_CHECK_HEADER(pthread.h,[
9987	AC_DEFINE(HAVE_PTHREADS_H,1,[Define to 1 if we have pthreads.h header])
9988
9989	for cf_lib_pthread in pthread c_r
9990	do
9991	    AC_MSG_CHECKING(if we can link with the $cf_lib_pthread library)
9992	    cf_save_LIBS="$LIBS"
9993	    CF_ADD_LIB($cf_lib_pthread)
9994	    AC_LINK_IFELSE([AC_LANG_PROGRAM([
9995#include <pthread.h>
9996],[
9997		int rc = pthread_create(0,0,0,0);
9998		int r2 = pthread_mutexattr_settype(0, 0);
9999])],[with_pthread=yes],[with_pthread=no])
10000	    LIBS="$cf_save_LIBS"
10001	    AC_MSG_RESULT($with_pthread)
10002	    test "$with_pthread" = yes && break
10003	done
10004
10005	if test "$with_pthread" = yes ; then
10006	    CF_ADD_LIB($cf_lib_pthread)
10007	    AC_DEFINE(HAVE_LIBPTHREADS,1,[Define to 1 if we have pthreads library])
10008	else
10009	    AC_MSG_ERROR(Cannot link with pthread library)
10010	fi
10011	])
10012fi
10013])
10014dnl ---------------------------------------------------------------------------
10015dnl CF_WITH_REL_VERSION version: 2 updated: 2023/05/06 18:18:18
10016dnl -------------------
10017dnl Allow library's release-version to be overridden.  Generally this happens when a
10018dnl packager has incremented the release-version past that used in the original package,
10019dnl and wishes to keep doing this.
10020dnl
10021dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
10022dnl and {package}_MINOR symbols
10023dnl symbol.
10024AC_DEFUN([CF_WITH_REL_VERSION],[
10025test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
10026AC_ARG_WITH(rel-version,
10027[  --with-rel-version=XXX  override derived release version],
10028[AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
10029 cf_cv_rel_version=$withval])
10030ifelse($1,,[
10031 CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
10032],[
10033 $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
10034 $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
10035 test -n "$1_MINOR" || $1_MINOR=0
10036 CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
10037 CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
10038])
10039])dnl
10040dnl ---------------------------------------------------------------------------
10041dnl CF_WITH_SYSMOUSE version: 4 updated: 2025/12/24 12:27:29
10042dnl ----------------
10043dnl If we can compile with sysmouse, make it available unless it is not wanted.
10044AC_DEFUN([CF_WITH_SYSMOUSE],[
10045# not everyone has "test -c"
10046if test -c /dev/sysmouse 2>/dev/null ; then
10047AC_MSG_CHECKING(if you want to use sysmouse)
10048AC_ARG_WITH(sysmouse,
10049	[  --with-sysmouse         use sysmouse (FreeBSD console)],
10050	[cf_with_sysmouse=$withval],
10051	[cf_with_sysmouse=maybe])
10052	if test "$cf_with_sysmouse" != no ; then
10053	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
10054#include <osreldate.h>
10055#if (__FreeBSD_version >= 400017)
10056#include <sys/consio.h>
10057#include <sys/fbio.h>
10058#else
10059#include <machine/console.h>
10060#endif
10061],[
10062	struct mouse_info the_mouse;
10063	ioctl(0, CONS_MOUSECTL, &the_mouse);
10064])],[cf_with_sysmouse=yes],[cf_with_sysmouse=no])
10065	fi
10066AC_MSG_RESULT($cf_with_sysmouse)
10067test "$cf_with_sysmouse" = yes && AC_DEFINE(USE_SYSMOUSE,1,[Define to 1 if we can/should use the sysmouse interface])
10068fi
10069])dnl
10070dnl ---------------------------------------------------------------------------
10071dnl CF_WITH_SYSTYPE version: 2 updated: 2025/12/14 18:08:20
10072dnl ---------------
10073dnl For testing, override the derived host system-type which is used to decide
10074dnl things such as the linker commands used to build shared libraries.  This is
10075dnl normally chosen automatically based on the type of system which you are
10076dnl building on.  We use it for testing the configure script.
10077dnl
10078dnl This is different from the --host option: it is used only for testing parts
10079dnl of the configure script which would not be reachable with --host since that
10080dnl relies on the build environment being real, rather than mocked up.
10081AC_DEFUN([CF_WITH_SYSTYPE],[
10082CF_CHECK_CACHE([AC_CANONICAL_TARGET])
10083AC_ARG_WITH(system-type,
10084	[  --with-system-type=XXX  test: override derived host system-type],
10085[AC_MSG_WARN(overriding system type to $withval)
10086	cf_cv_system_name=$withval
10087	host_os=$withval
10088])
10089])dnl
10090dnl ---------------------------------------------------------------------------
10091dnl CF_WITH_TYPE version: 2 updated: 2023/11/25 16:11:47
10092dnl ------------
10093dnl Accept a TYPE for substitution:
10094dnl $1 = name of type
10095dnl $2 = help/usage message
10096dnl $3 = symbol to set
10097dnl $4 = default value
10098AC_DEFUN([CF_WITH_TYPE],[
10099AC_MSG_CHECKING(for type of $1)
10100AC_ARG_WITH([$1], [$2],
10101	[$3="$withval"],
10102	[$3=$4])
10103AC_MSG_RESULT([$]$3)
10104case x[$]$3 in
10105(x|xyes|xno)
10106	AC_MSG_ERROR(expected a type name for $1)
10107	;;
10108esac
10109AC_SUBST($3)
10110])dnl
10111dnl ---------------------------------------------------------------------------
10112dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
10113dnl ----------------
10114AC_DEFUN([CF_WITH_VALGRIND],[
10115CF_NO_LEAKS_OPTION(valgrind,
10116	[  --with-valgrind         test: use valgrind],
10117	[USE_VALGRIND])
10118])dnl
10119dnl ---------------------------------------------------------------------------
10120dnl CF_WITH_VERSIONED_SYMS version: 17 updated: 2025/12/16 04:01:46
10121dnl ----------------------
10122dnl Use this when building shared library with ELF, to markup symbols with the
10123dnl version identifier from the given input file.  Generally that identifier is
10124dnl the same as the SONAME at which the symbol was first introduced.
10125dnl
10126dnl $1 = basename of the ".map" file (default $PACKAGE)
10127AC_DEFUN([CF_WITH_VERSIONED_SYMS],
10128[AC_REQUIRE([AC_PROG_FGREP])dnl
10129AC_REQUIRE([AC_PROG_EGREP])dnl
10130AC_REQUIRE([CF_GLOB_FULLPATH])dnl
10131
10132if test "$with_libtool" = "yes" ; then
10133	:
10134elif test "$with_shared" = "yes" ; then
10135AC_MSG_CHECKING(if versioned-symbols file should be used)
10136AC_ARG_WITH(versioned-syms,
10137	[[  --with-versioned-syms[=MAP-FILE] version ELF shared library symbols per MAP-FILE]],
10138	[with_versioned_syms=$withval],
10139	[with_versioned_syms=no])
10140case "x$with_versioned_syms" in
10141(xyes)
10142	with_versioned_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).map'
10143	AC_SUBST(PACKAGE)
10144	;;
10145(xno)
10146	;;
10147(x$GLOB_FULLPATH_POSIX|x$GLOB_FULLPATH_OTHER)
10148	test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
10149	;;
10150(*)
10151	test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
10152	with_versioned_syms=`pwd`/"$with_versioned_syms"
10153	;;
10154esac
10155AC_MSG_RESULT($with_versioned_syms)
10156
10157RESULTING_SYMS=
10158VERSIONED_SYMS=
10159WILDCARD_SYMS=
10160
10161if test "x$with_versioned_syms" != xno
10162then
10163	RESULTING_SYMS=$with_versioned_syms
10164	case "x$MK_SHARED_LIB" in
10165	(*-Wl,*)
10166		VERSIONED_SYMS="-Wl,--version-script,\${RESULTING_SYMS}"
10167		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-Wl,%\\[$]{VERSIONED_SYMS} -Wl,%"`
10168		CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
10169		LIB_CREATE="[$]MK_SHARED_LIB"
10170		;;
10171	(*-dy\ *)
10172		VERSIONED_SYMS="-Wl,-M,\${RESULTING_SYMS}"
10173		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-dy%\\[$]{VERSIONED_SYMS} -dy%"`
10174		CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
10175		LIB_CREATE="[$]MK_SHARED_LIB"
10176		;;
10177	(*)
10178		AC_MSG_WARN(this system does not support versioned-symbols)
10179		;;
10180	esac
10181
10182	# Linux ld can selectively override scope, e.g., of symbols beginning with
10183	# "_" by first declaring some as global, and then using a wildcard to
10184	# declare the others as local.  Some other loaders cannot do this.  Check
10185	# by constructing a (very) simple shared library and inspecting its
10186	# symbols.
10187	if test "x$VERSIONED_SYMS" != "x"
10188	then
10189		AC_MSG_CHECKING(if wildcards can be used to selectively omit symbols)
10190		WILDCARD_SYMS=no
10191
10192		# make sources
10193		rm -f conftest.*
10194
10195		cat >conftest.ver <<EOF
10196module_1.0 {
10197global:
10198	globalf1;
10199local:
10200	localf1;
10201};
10202module_2.0 {
10203global:
10204	globalf2;
10205local:
10206	localf2;
10207	_*;
10208} module_1.0;
10209submodule_1.0 {
10210global:
10211	subglobalf1;
10212	_ismissing;
10213local:
10214	sublocalf1;
10215};
10216submodule_2.0 {
10217global:
10218	subglobalf2;
10219local:
10220	sublocalf2;
10221	_*;
10222} submodule_1.0;
10223EOF
10224		cat >conftest.$ac_ext <<EOF
10225#line __oline__ "configure"
10226extern int _ismissing(void);    int _ismissing(void)  { return 1; }
10227extern int _localf1(void);      int _localf1(void)    { return 1; }
10228extern int _localf2(void);      int _localf2(void)    { return 2; }
10229extern int globalf1(void);      int globalf1(void)    { return 1; }
10230extern int globalf2(void);      int globalf2(void)    { return 2; }
10231extern int _sublocalf1(void);   int _sublocalf1(void) { return 1; }
10232extern int _sublocalf2(void);   int _sublocalf2(void) { return 2; }
10233extern int subglobalf1(void);   int subglobalf1(void) { return 1; }
10234extern int subglobalf2(void);   int subglobalf2(void) { return 2; }
10235EOF
10236		cat >conftest.mk <<EOF
10237CC=${CC}
10238CFLAGS=${CFLAGS}
10239CPPFLAGS=${CPPFLAGS}
10240LDFLAGS=${LDFLAGS}
10241LIBS=${LIBS}
10242VERSIONED_SYMS=${VERSIONED_SYMS}
10243RESULTING_SYMS=conftest.ver
10244MK_SHARED_LIB=${MK_SHARED_LIB}
10245conftest.so: conftest.$ac_cv_objext
10246		\$(MK_SHARED_LIB) conftest.$ac_cv_objext
10247EOF
10248
10249		# compile source, make library
10250		if make -f conftest.mk 2>&AS_MESSAGE_LOG_FD >/dev/null
10251		then
10252			# test for missing symbol in either Data or Text section
10253			cf_missing="`nm -P conftest.so 2>&AS_MESSAGE_LOG_FD |${FGREP-fgrep} _ismissing | ${EGREP-egrep} '[[ 	]][[DT]][[ 	]]'`"
10254			test -n "$cf_missing" && WILDCARD_SYMS=yes
10255		fi
10256		AC_MSG_RESULT($WILDCARD_SYMS)
10257		rm -f conftest.*
10258	fi
10259fi
10260
10261fi
10262AC_SUBST(RESULTING_SYMS)
10263AC_SUBST(VERSIONED_SYMS)
10264AC_SUBST(WILDCARD_SYMS)
10265])dnl
10266dnl ---------------------------------------------------------------------------
10267dnl CF_WITH_X11_RGB version: 3 updated: 2023/10/28 11:59:01
10268dnl ---------------
10269dnl Handle configure option "--with-x11-rgb", setting these shell
10270dnl variables:
10271dnl
10272dnl $RGB_PATH is the option value, used for finding the X11 rgb file.
10273dnl $no_x11_rgb is a "#" (comment) if "--without-x11-rgb" is given.
10274dnl
10275dnl Most Linux's use this:
10276dnl 	/usr/share/X11/rgb.txt
10277dnl Debian uses this:
10278dnl 	/etc/X11/rgb.txt
10279dnl DragonFlyBSD ports uses this:
10280dnl 	/usr/pkg/lib/X11/rgb.txt
10281dnl FreeBSD ports use these:
10282dnl 	/usr/local/lib/X11/rgb.txt
10283dnl 	/usr/local/share/X11/rgb.txt
10284dnl Mandriva has these:
10285dnl 	/usr/lib/X11/rgb.txt
10286dnl 	/usr/lib64/X11/rgb.txt
10287dnl NetBSD has these
10288dnl 	/usr/X11R7/lib/X11/rgb.txt
10289dnl OpenSolaris uses
10290dnl 	32-bit:
10291dnl 	/usr/X11/etc/X11/rgb.txt
10292dnl 	/usr/X11/share/X11/rgb.txt
10293dnl 	/usr/X11/lib/X11/rgb.txt
10294dnl OSX uses
10295dnl		/opt/local/share/X11/rgb.txt (MacPorts)
10296dnl		/opt/X11/share/X11/rgb.txt (non-ports)
10297dnl	64-bit:
10298dnl 	/usr/X11/etc/X11/rgb.txt
10299dnl 	/usr/X11/share/X11/rgb.txt (perhaps)
10300dnl 	/usr/X11/lib/amd64/X11/rgb.txt
10301dnl Solaris10 uses (in this order):
10302dnl 	/usr/openwin/lib/X11/rgb.txt
10303dnl 	/usr/X11/lib/X11/rgb.txt
10304AC_DEFUN([CF_WITH_X11_RGB],[
10305AC_MSG_CHECKING(for X11 rgb file)
10306AC_ARG_WITH(x11-rgb,
10307	[  --with-x11-rgb=FILE     obtain X11 color definitions from FILE (default: EPREFIX/lib/X11/rgb.txt)],
10308	[RGB_PATH=$withval],
10309	[RGB_PATH=auto])
10310
10311if test "x[$]RGB_PATH" = xauto
10312then
10313	RGB_PATH='${exec_prefix}/lib/X11/rgb.txt'
10314	for cf_path in \
10315		/opt/local/share/X11/rgb.txt \
10316		/opt/X11/share/X11/rgb.txt \
10317		/usr/share/X11/rgb.txt \
10318		/usr/X11/share/X11/rgb.txt \
10319		/usr/X11/lib/X11/rgb.txt \
10320		/usr/lib/X11/rgb.txt \
10321		/etc/X11/rgb.txt \
10322		/usr/pkg/lib/X11/rgb.txt \
10323		/usr/X11R7/lib/X11/rgb.txt \
10324		/usr/X11R6/lib/X11/rgb.txt \
10325		/usr/X11R5/lib/X11/rgb.txt \
10326		/usr/X11R4/lib/X11/rgb.txt \
10327		/usr/local/lib/X11/rgb.txt \
10328		/usr/local/share/X11/rgb.txt \
10329		/usr/lib64/X11/rgb.txt
10330	do
10331		if test -f "$cf_path" ; then
10332			RGB_PATH="$cf_path"
10333			break
10334		fi
10335	done
10336else
10337	cf_path=$RGB_PATH
10338	CF_PATH_SYNTAX(cf_path)
10339fi
10340
10341AC_MSG_RESULT($RGB_PATH)
10342AC_SUBST(RGB_PATH)
10343AC_DEFINE_UNQUOTED(RGB_PATH,"$cf_path",[Define to the full pathname of rgb.txt])
10344
10345no_x11_rgb=
10346if test "$RGB_PATH" = no
10347then
10348	no_x11_rgb="#"
10349fi
10350AC_SUBST(no_x11_rgb)
10351])dnl
10352dnl ---------------------------------------------------------------------------
10353dnl CF_WITH_XTERM_KBS version: 3 updated: 2025/10/21 03:55:54
10354dnl -----------------
10355dnl Configure-option with platform-defaults for the "xterm+kbs" building block
10356dnl in the terminfo file.
10357dnl
10358dnl The terminfo "kbs" value corresponds to "stty erase", and is conventionally
10359dnl assigned to the key which has
10360dnl
10361dnl		a "Backspace" label and/or
10362dnl		a backarrow symbol.
10363dnl
10364dnl See XTerm FAQ "Why doesn't my delete key work?"
10365dnl		https://invisible-island.net/xterm/xterm.faq.html#xterm_erase
10366AC_DEFUN([CF_WITH_XTERM_KBS],[
10367case $host_os in
10368(linux*gnu*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc|linux*musl|openbsd*|darwin*)
10369	want_xterm_kbs=DEL
10370	;;
10371(*)
10372	want_xterm_kbs=BS
10373	;;
10374esac
10375
10376AC_MSG_CHECKING(if xterm backspace-key sends BS or DEL)
10377AC_ARG_WITH(xterm-kbs,
10378	[[  --with-xterm-kbs[=XXX]  specify if xterm backspace-key sends BS or DEL]],
10379	[with_xterm_kbs=$withval],
10380	[with_xterm_kbs=auto])
10381case x$with_xterm_kbs in
10382(xyes|xno|xBS|xbs|x8)
10383	with_xterm_kbs=BS
10384	;;
10385(xDEL|xdel|x127)
10386	with_xterm_kbs=DEL
10387	;;
10388(xauto)
10389	with_xterm_kbs=$want_xterm_kbs
10390	;;
10391(*)
10392	with_xterm_kbs=$withval
10393	;;
10394esac
10395AC_MSG_RESULT($with_xterm_kbs)
10396XTERM_KBS=$with_xterm_kbs
10397AC_SUBST(XTERM_KBS)
10398
10399if test "x$with_xterm_kbs" != "x$want_xterm_kbs"
10400then
10401	AC_MSG_WARN([expected --with-xterm-kbs=$want_xterm_kbs for $host_os, have $with_xterm_kbs])
10402fi
10403])dnl
10404dnl ---------------------------------------------------------------------------
10405dnl CF_XOPEN_SOURCE version: 71 updated: 2025/12/14 17:40:20
10406dnl ---------------
10407dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
10408dnl or adapt to the vendor's definitions to get equivalent functionality,
10409dnl without losing the common non-POSIX features.
10410dnl
10411dnl Parameters:
10412dnl	$1 is the nominal value for _XOPEN_SOURCE
10413dnl	$2 is the nominal value for _POSIX_C_SOURCE
10414dnl
10415dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
10416dnl implementation predefines it, because X/Open and most implementations agree
10417dnl that the latter is a legacy or "aligned" value.
10418dnl
10419dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
10420dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
10421dnl
10422dnl References:
10423dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
10424dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
10425dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
10426AC_DEFUN([CF_XOPEN_SOURCE],[
10427AC_REQUIRE([AC_CANONICAL_HOST])
10428AC_REQUIRE([CF_POSIX_VISIBLE])
10429
10430if test "$cf_cv_posix_visible" = no; then
10431
10432cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
10433cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
10434cf_xopen_source=
10435
10436case "$host_os" in
10437(aix[[4-7]]*)
10438	cf_xopen_source="-D_ALL_SOURCE"
10439	;;
10440(darwin[[0-8]].*)
10441	cf_xopen_source="-D_APPLE_C_SOURCE"
10442	;;
10443(darwin*)
10444	cf_xopen_source="-D_DARWIN_C_SOURCE"
10445	cf_XOPEN_SOURCE=
10446	;;
10447(freebsd*|dragonfly*|midnightbsd*)
10448	# 5.x headers associate
10449	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
10450	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
10451	cf_POSIX_C_SOURCE=200112L
10452	cf_XOPEN_SOURCE=600
10453	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
10454	;;
10455(hpux11*)
10456	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
10457	;;
10458(hpux*)
10459	cf_xopen_source="-D_HPUX_SOURCE"
10460	;;
10461(irix[[56]].*)
10462	cf_xopen_source="-D_SGI_SOURCE"
10463	cf_XOPEN_SOURCE=
10464	;;
10465(linux*gnu*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
10466	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
10467	;;
10468linux*musl)
10469	cf_xopen_source="-D_BSD_SOURCE"
10470	;;
10471(minix*)
10472	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
10473	;;
10474(mirbsd*)
10475	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
10476	cf_XOPEN_SOURCE=
10477	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
10478	;;
10479(netbsd*)
10480	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
10481	;;
10482(openbsd[[6-9]]*)
10483	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
10484	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
10485	# Abusing the conformance level is a workaround.
10486	AC_MSG_WARN(this system does not provide usable locale support)
10487	cf_xopen_source="-D_BSD_SOURCE"
10488	cf_XOPEN_SOURCE=700
10489	;;
10490(openbsd[[4-5]]*)
10491	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
10492	cf_xopen_source="-D_BSD_SOURCE"
10493	cf_XOPEN_SOURCE=600
10494	;;
10495(openbsd*)
10496	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
10497	;;
10498(osf[[45]]*)
10499	cf_xopen_source="-D_OSF_SOURCE"
10500	;;
10501(nto-qnx*)
10502	cf_xopen_source="-D_QNX_SOURCE"
10503	;;
10504(sco*)
10505	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
10506	;;
10507(solaris2.*)
10508	cf_xopen_source="-D__EXTENSIONS__"
10509	cf_cv_xopen_source=broken
10510	;;
10511(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
10512	cf_XOPEN_SOURCE=
10513	cf_POSIX_C_SOURCE=
10514	;;
10515(*)
10516	CF_TRY_XOPEN_SOURCE
10517	cf_save_xopen_cppflags="$CPPFLAGS"
10518	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
10519	# Some of these niche implementations use copy/paste, double-check...
10520	if test "$cf_cv_xopen_source" = no ; then
10521		CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
10522		AC_COMPILE_IFELSE([AC_LANG_PROGRAM(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY)],,[
10523			AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
10524			CPPFLAGS="$cf_save_xopen_cppflags"])
10525	fi
10526	;;
10527esac
10528
10529if test -n "$cf_xopen_source" ; then
10530	CF_APPEND_CFLAGS($cf_xopen_source,true)
10531fi
10532
10533dnl In anything but the default case, we may have system-specific setting
10534dnl which is still not guaranteed to provide all of the entrypoints that
10535dnl _XOPEN_SOURCE would yield.
10536if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
10537	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
10538	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h>],[
10539#ifndef _XOPEN_SOURCE
10540#error _XOPEN_SOURCE is not defined
10541#endif])],
10542	[cf_XOPEN_SOURCE_set=yes],
10543	[cf_XOPEN_SOURCE_set=no])
10544	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
10545	if test "$cf_XOPEN_SOURCE_set" = yes
10546	then
10547		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h>],[
10548#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
10549#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
10550#endif])],
10551		[cf_XOPEN_SOURCE_set_ok=yes],
10552		[cf_XOPEN_SOURCE_set_ok=no])
10553		if test "$cf_XOPEN_SOURCE_set_ok" = no
10554		then
10555			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
10556		fi
10557	else
10558		CF_TRY_XOPEN_SOURCE
10559	fi
10560fi
10561fi # cf_cv_posix_visible
10562])
10563dnl ---------------------------------------------------------------------------
10564dnl CF__SED_TRIMBLANKS version: 1 updated: 2021/01/02 09:31:20
10565dnl ------------------
10566dnl Trim something using sed, then trim extra whitespace
10567dnl $1 = extra parameters, e.g., in CF_STRIP_G_OPT
10568define([CF__SED_TRIMBLANKS],[sed ifelse($1,,,[$1] )-e 's%[[	]]% %g' -e 's% [[ ]]*% %g' -e 's%^ %%' -e 's% [$]%%'])dnl
10569dnl ---------------------------------------------------------------------------
10570dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25
10571dnl ---------------------
10572dnl body of test when test-compiling for _XOPEN_SOURCE check
10573define([CF__XOPEN_SOURCE_BODY],
10574[
10575#ifndef _XOPEN_SOURCE
10576#error _XOPEN_SOURCE is not defined
10577#endif
10578])
10579dnl ---------------------------------------------------------------------------
10580dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25
10581dnl ---------------------
10582dnl headers to include when test-compiling for _XOPEN_SOURCE check
10583define([CF__XOPEN_SOURCE_HEAD],
10584[
10585$ac_includes_default
10586])
10587