1dnl $XTermId: aclocal.m4,v 1.533 2024/12/21 13:44:12 tom Exp $
2dnl
3dnl ---------------------------------------------------------------------------
4dnl
5dnl Copyright 1997-2023,2024 by Thomas E. Dickey
6dnl
7dnl                         All Rights Reserved
8dnl
9dnl Permission is hereby granted, free of charge, to any person obtaining a
10dnl copy of this software and associated documentation files (the
11dnl "Software"), to deal in the Software without restriction, including
12dnl without limitation the rights to use, copy, modify, merge, publish,
13dnl distribute, sublicense, and/or sell copies of the Software, and to
14dnl permit persons to whom the Software is furnished to do so, subject to
15dnl the following conditions:
16dnl
17dnl The above copyright notice and this permission notice shall be included
18dnl in all copies or substantial portions of the Software.
19dnl
20dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23dnl IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
24dnl CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25dnl TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26dnl SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27dnl
28dnl Except as contained in this notice, the name(s) of the above copyright
29dnl holders shall not be used in advertising or otherwise to promote the
30dnl sale, use or other dealings in this Software without prior written
31dnl authorization.
32dnl
33dnl ---------------------------------------------------------------------------
34dnl See
35dnl     https://invisible-island.net/autoconf/autoconf.html
36dnl     https://invisible-island.net/autoconf/my-autoconf.html
37dnl ---------------------------------------------------------------------------
38dnl ---------------------------------------------------------------------------
39dnl AM_LANGINFO_CODESET version: 7 updated: 2023/01/11 04:05:23
40dnl -------------------
41dnl Inserted as requested by gettext 0.10.40
42dnl File from /usr/share/aclocal
43dnl codeset.m4
44dnl ====================
45dnl serial AM1
46dnl
47dnl From Bruno Haible.
48AC_DEFUN([AM_LANGINFO_CODESET],
49[
50AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
51	[AC_TRY_LINK([
52$ac_includes_default
53#include <langinfo.h>],
54	[char* cs = nl_langinfo(CODESET); (void)cs],
55	am_cv_langinfo_codeset=yes,
56	am_cv_langinfo_codeset=no)
57	])
58	if test "$am_cv_langinfo_codeset" = yes; then
59		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
60		[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
61	fi
62])dnl
63dnl ---------------------------------------------------------------------------
64dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
65dnl ------------------
66dnl Conditionally generate script according to whether we're using a given autoconf.
67dnl
68dnl $1 = version to compare against
69dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
70dnl $3 = code to use if AC_ACVERSION is older than $1.
71define([CF_ACVERSION_CHECK],
72[
73ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
74ifdef([m4_version_compare],
75[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
76[CF_ACVERSION_COMPARE(
77AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
78AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
79dnl ---------------------------------------------------------------------------
80dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
81dnl --------------------
82dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
83dnl                      MAJOR2, MINOR2, TERNARY2,
84dnl                      PRINTABLE2, not FOUND, FOUND)
85define([CF_ACVERSION_COMPARE],
86[ifelse(builtin([eval], [$2 < $5]), 1,
87[ifelse([$8], , ,[$8])],
88[ifelse([$9], , ,[$9])])])dnl
89dnl ---------------------------------------------------------------------------
90dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15
91dnl -------------
92dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
93dnl $1 = flags to add
94dnl $2 = if given makes this macro verbose.
95dnl
96dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
97dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
98dnl confused by the quotes (which require backslashes to keep them usable).
99AC_DEFUN([CF_ADD_CFLAGS],
100[
101cf_fix_cppflags=no
102cf_new_cflags=
103cf_new_cppflags=
104cf_new_extra_cppflags=
105
106for cf_add_cflags in $1
107do
108case "$cf_fix_cppflags" in
109(no)
110	case "$cf_add_cflags" in
111	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
112		case "$cf_add_cflags" in
113		(-D*)
114			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
115
116			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
117				&& test -z "${cf_tst_cflags}" \
118				&& cf_fix_cppflags=yes
119
120			if test "$cf_fix_cppflags" = yes ; then
121				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
122				continue
123			elif test "${cf_tst_cflags}" = "\"'" ; then
124				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
125				continue
126			fi
127			;;
128		esac
129		case "$CPPFLAGS" in
130		(*$cf_add_cflags)
131			;;
132		(*)
133			case "$cf_add_cflags" in
134			(-D*)
135				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
136				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
137				;;
138			esac
139			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
140			;;
141		esac
142		;;
143	(*)
144		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
145		;;
146	esac
147	;;
148(yes)
149	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
150
151	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
152
153	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
154		&& test -z "${cf_tst_cflags}" \
155		&& cf_fix_cppflags=no
156	;;
157esac
158done
159
160if test -n "$cf_new_cflags" ; then
161	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
162	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
163fi
164
165if test -n "$cf_new_cppflags" ; then
166	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
167	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
168fi
169
170if test -n "$cf_new_extra_cppflags" ; then
171	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
172	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
173fi
174
175AC_SUBST(EXTRA_CPPFLAGS)
176
177])dnl
178dnl ---------------------------------------------------------------------------
179dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
180dnl ----------
181dnl Add a library, used to enforce consistency.
182dnl
183dnl $1 = library to add, without the "-l"
184dnl $2 = variable to update (default $LIBS)
185AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
186dnl ---------------------------------------------------------------------------
187dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
188dnl -----------
189dnl Add one or more libraries, used to enforce consistency.  Libraries are
190dnl prepended to an existing list, since their dependencies are assumed to
191dnl already exist in the list.
192dnl
193dnl $1 = libraries to add, with the "-l", etc.
194dnl $2 = variable to update (default $LIBS)
195AC_DEFUN([CF_ADD_LIBS],[
196cf_add_libs="[$]ifelse($2,,LIBS,[$2])"
197# reverse order
198cf_add_0lib=
199for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
200# filter duplicates
201for cf_add_1lib in $cf_add_0lib; do
202	for cf_add_2lib in $cf_add_libs; do
203		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
204			cf_add_1lib=
205			break
206		fi
207	done
208	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
209done
210ifelse($2,,LIBS,[$2])="$cf_add_libs"
211])dnl
212dnl ---------------------------------------------------------------------------
213dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
214dnl ----------------
215dnl Add a given library after another, e.g., following the one it satisfies a
216dnl dependency for.
217dnl
218dnl $1 = the first library
219dnl $2 = its dependency
220AC_DEFUN([CF_ADD_LIB_AFTER],[
221CF_VERBOSE(...before $LIBS)
222LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
223CF_VERBOSE(...after  $LIBS)
224])dnl
225dnl ---------------------------------------------------------------------------
226dnl CF_APPEND_CFLAGS version: 3 updated: 2021/09/05 17:25:40
227dnl ----------------
228dnl Use CF_ADD_CFLAGS after first checking for potential redefinitions.
229dnl $1 = flags to add
230dnl $2 = if given makes this macro verbose.
231define([CF_APPEND_CFLAGS],
232[
233for cf_add_cflags in $1
234do
235	case "x$cf_add_cflags" in
236	(x-[[DU]]*)
237		CF_REMOVE_CFLAGS($cf_add_cflags,CFLAGS,[$2])
238		CF_REMOVE_CFLAGS($cf_add_cflags,CPPFLAGS,[$2])
239		;;
240	esac
241	CF_ADD_CFLAGS([$cf_add_cflags],[$2])
242done
243])dnl
244dnl ---------------------------------------------------------------------------
245dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
246dnl --------------
247dnl use this macro for appending text without introducing an extra blank at
248dnl the beginning
249define([CF_APPEND_TEXT],
250[
251	test -n "[$]$1" && $1="[$]$1 "
252	$1="[$]{$1}$2"
253])dnl
254dnl ---------------------------------------------------------------------------
255dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
256dnl --------------
257dnl Allow user to disable a normally-on option.
258AC_DEFUN([CF_ARG_DISABLE],
259[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
260dnl ---------------------------------------------------------------------------
261dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
262dnl -------------
263dnl Allow user to enable a normally-off option.
264AC_DEFUN([CF_ARG_ENABLE],
265[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
266dnl ---------------------------------------------------------------------------
267dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
268dnl -------------
269dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
270dnl values.
271dnl
272dnl Parameters:
273dnl $1 = option name
274dnl $2 = help-string
275dnl $3 = action to perform if option is not default
276dnl $4 = action if perform if option is default
277dnl $5 = default option value (either 'yes' or 'no')
278AC_DEFUN([CF_ARG_OPTION],
279[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
280	if test "$enableval" != "$5" ; then
281ifelse([$3],,[    :]dnl
282,[    $3]) ifelse([$4],,,[
283	else
284		$4])
285	fi],[enableval=$5 ifelse([$4],,,[
286	$4
287])dnl
288])])dnl
289dnl ---------------------------------------------------------------------------
290dnl CF_C11_NORETURN version: 4 updated: 2023/02/18 17:41:25
291dnl ---------------
292AC_DEFUN([CF_C11_NORETURN],
293[
294AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
295CF_ARG_ENABLE(stdnoreturn,
296	[  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
297	[enable_stdnoreturn=yes],
298	[enable_stdnoreturn=no])
299AC_MSG_RESULT($enable_stdnoreturn)
300
301if test $enable_stdnoreturn = yes; then
302AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
303	[AC_TRY_COMPILE([
304$ac_includes_default
305#include <stdnoreturn.h>
306static _Noreturn void giveup(void) { exit(0); }
307	],
308	[if (feof(stdin)) giveup()],
309	cf_cv_c11_noreturn=yes,
310	cf_cv_c11_noreturn=no)
311	])
312else
313	cf_cv_c11_noreturn=no,
314fi
315
316if test "$cf_cv_c11_noreturn" = yes; then
317	AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
318	AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
319	HAVE_STDNORETURN_H=1
320else
321	HAVE_STDNORETURN_H=0
322fi
323
324AC_SUBST(HAVE_STDNORETURN_H)
325AC_SUBST(STDC_NORETURN)
326])dnl
327dnl ---------------------------------------------------------------------------
328dnl CF_CC_ENV_FLAGS version: 11 updated: 2023/02/20 11:15:46
329dnl ---------------
330dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
331dnl into CC.  This will not help with broken scripts that wrap the compiler
332dnl with options, but eliminates a more common category of user confusion.
333dnl
334dnl In particular, it addresses the problem of being able to run the C
335dnl preprocessor in a consistent manner.
336dnl
337dnl Caveat: this also disallows blanks in the pathname for the compiler, but
338dnl the nuisance of having inconsistent settings for compiler and preprocessor
339dnl outweighs that limitation.
340AC_DEFUN([CF_CC_ENV_FLAGS],
341[
342# This should have been defined by AC_PROG_CC
343: "${CC:=cc}"
344
345AC_MSG_CHECKING(\$CFLAGS variable)
346case "x$CFLAGS" in
347(*-[[IUD]]*)
348	AC_MSG_RESULT(broken)
349	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
350	cf_flags="$CFLAGS"
351	CFLAGS=
352	for cf_arg in $cf_flags
353	do
354		CF_ADD_CFLAGS($cf_arg)
355	done
356	;;
357(*)
358	AC_MSG_RESULT(ok)
359	;;
360esac
361
362AC_MSG_CHECKING(\$CC variable)
363case "$CC" in
364(*[[\ \	]]-*)
365	AC_MSG_RESULT(broken)
366	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
367	# humor him...
368	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
369	cf_flags=`echo "$CC" | sed -e "s%^$cf_prog%%"`
370	CC="$cf_prog"
371	for cf_arg in $cf_flags
372	do
373		case "x$cf_arg" in
374		(x-[[IUDfgOW]]*)
375			CF_ADD_CFLAGS($cf_arg)
376			;;
377		(*)
378			CC="$CC $cf_arg"
379			;;
380		esac
381	done
382	CF_VERBOSE(resulting CC: '$CC')
383	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
384	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
385	;;
386(*)
387	AC_MSG_RESULT(ok)
388	;;
389esac
390])dnl
391dnl ---------------------------------------------------------------------------
392dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
393dnl --------------
394dnl Check if we're accidentally using a cache from a different machine.
395dnl Derive the system name, as a check for reusing the autoconf cache.
396dnl
397dnl If we've packaged config.guess and config.sub, run that (since it does a
398dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
399dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
400dnl which is useful in cross-compiles.
401dnl
402dnl Note: we would use $ac_config_sub, but that is one of the places where
403dnl autoconf 2.5x broke compatibility with autoconf 2.13
404AC_DEFUN([CF_CHECK_CACHE],
405[
406if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
407	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
408	system_name="$host_os"
409else
410	system_name="`(uname -s -r) 2>/dev/null`"
411	if test -z "$system_name" ; then
412		system_name="`(hostname) 2>/dev/null`"
413	fi
414fi
415test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
416AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
417
418test -z "$system_name" && system_name="$cf_cv_system_name"
419test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
420
421if test ".$system_name" != ".$cf_cv_system_name" ; then
422	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
423	AC_MSG_ERROR("Please remove config.cache and try again.")
424fi
425])dnl
426dnl ---------------------------------------------------------------------------
427dnl CF_CHECK_CFLAGS version: 4 updated: 2021/01/02 19:22:58
428dnl ---------------
429dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
430dnl a build-configuration such as imake.  These have the pitfall that they
431dnl often contain compiler-specific options which we cannot use, mixed with
432dnl preprocessor options that we usually can.
433AC_DEFUN([CF_CHECK_CFLAGS],
434[
435CF_VERBOSE(checking additions to CFLAGS)
436cf_check_cflags="$CFLAGS"
437cf_check_cppflags="$CPPFLAGS"
438CF_ADD_CFLAGS($1,yes)
439if test "x$cf_check_cflags" != "x$CFLAGS" ; then
440AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
441	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
442	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
443		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
444	 fi
445	 CFLAGS="$cf_check_cflags"])
446fi
447])dnl
448dnl ---------------------------------------------------------------------------
449dnl CF_CHECK_ERRNO version: 14 updated: 2023/02/18 17:41:25
450dnl --------------
451dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
452dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
453dnl ourselves.
454dnl
455dnl $1 = the name to check
456dnl $2 = the assumed type
457AC_DEFUN([CF_CHECK_ERRNO],
458[
459AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
460	AC_TRY_COMPILE([
461$ac_includes_default
462#include <errno.h> ],
463	ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1; (void)x,
464	[cf_cv_dcl_$1=yes],
465	[cf_cv_dcl_$1=no])
466])
467
468if test "$cf_cv_dcl_$1" = no ; then
469	CF_UPPER(cf_result,decl_$1)
470	AC_DEFINE_UNQUOTED($cf_result)
471fi
472
473# It's possible (for near-UNIX clones) that the data doesn't exist
474CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
475])dnl
476dnl ---------------------------------------------------------------------------
477dnl CF_CHECK_EXTERN_DATA version: 5 updated: 2021/09/04 06:35:04
478dnl --------------------
479dnl Check for existence of external data in the current set of libraries.  If
480dnl we can modify it, it is real enough.
481dnl $1 = the name to check
482dnl $2 = its type
483AC_DEFUN([CF_CHECK_EXTERN_DATA],
484[
485AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
486	AC_TRY_LINK([
487#undef $1
488extern $2 $1;
489],
490	[$1 = 2],
491	[cf_cv_have_$1=yes],
492	[cf_cv_have_$1=no])
493])
494
495if test "$cf_cv_have_$1" = yes ; then
496	CF_UPPER(cf_result,have_$1)
497	AC_DEFINE_UNQUOTED($cf_result)
498fi
499
500])dnl
501dnl ---------------------------------------------------------------------------
502dnl CF_CLANG_COMPILER version: 9 updated: 2023/02/18 17:41:25
503dnl -----------------
504dnl Check if the given compiler is really clang.  clang's C driver defines
505dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
506dnl not ignore some gcc options.
507dnl
508dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
509dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
510dnl the wrappers for gcc and g++ warnings.
511dnl
512dnl $1 = GCC (default) or GXX
513dnl $2 = CLANG_COMPILER (default)
514dnl $3 = CFLAGS (default) or CXXFLAGS
515AC_DEFUN([CF_CLANG_COMPILER],[
516ifelse([$2],,CLANG_COMPILER,[$2])=no
517
518if test "$ifelse([$1],,[$1],GCC)" = yes ; then
519	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
520	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
521	AC_TRY_COMPILE([],[
522#ifdef __clang__
523#else
524#error __clang__ is not defined
525#endif
526],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
527],[])
528	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
529	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
530fi
531
532CLANG_VERSION=none
533
534if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
535	case "$CC" in
536	(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
537		AC_MSG_WARN(replacing broken compiler alias $CC)
538		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
539		CC=clang
540		;;
541	esac
542
543	AC_MSG_CHECKING(version of $CC)
544	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.]].*//'`"
545	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
546	AC_MSG_RESULT($CLANG_VERSION)
547
548	for cf_clang_opt in \
549		-Qunused-arguments \
550		-Wno-error=implicit-function-declaration
551	do
552		AC_MSG_CHECKING(if option $cf_clang_opt works)
553		cf_save_CFLAGS="$CFLAGS"
554		CFLAGS="$CFLAGS $cf_clang_opt"
555		AC_TRY_LINK([
556			#include <stdio.h>],[
557			printf("hello!\\n");],[
558			cf_clang_optok=yes],[
559			cf_clang_optok=no])
560		AC_MSG_RESULT($cf_clang_optok)
561		CFLAGS="$cf_save_CFLAGS"
562		if test "$cf_clang_optok" = yes; then
563			CF_VERBOSE(adding option $cf_clang_opt)
564			CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
565		fi
566	done
567fi
568])
569dnl ---------------------------------------------------------------------------
570dnl CF_CONST_X_STRING version: 9 updated: 2024/12/04 03:49:57
571dnl -----------------
572dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
573dnl character-strings.
574dnl
575dnl It is ambiguous because the specification accommodated the pre-ANSI
576dnl compilers bundled by more than one vendor in lieu of providing a standard C
577dnl compiler other than by costly add-ons.  Because of this, the specification
578dnl did not take into account the use of const for telling the compiler that
579dnl string literals would be in readonly memory.
580dnl
581dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
582dnl let the compiler decide how to represent Xt's strings which were #define'd.
583dnl That does not solve the problem of using the block of Xt's strings which
584dnl are compiled into the library (and is less efficient than one might want).
585dnl
586dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
587dnl when compiling the library and compiling using the library, to tell the
588dnl compiler that String is const.
589AC_DEFUN([CF_CONST_X_STRING],
590[
591AC_REQUIRE([AC_PATH_XTRA])
592
593CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
594
595AC_TRY_COMPILE(
596[
597$ac_includes_default
598#include <X11/Intrinsic.h>
599],
600[String foo = malloc(1); free((void*)foo)],[
601
602AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
603	AC_TRY_COMPILE(
604		[
605#undef  _CONST_X_STRING
606#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
607#undef  XTSTRINGDEFINES	/* X11R5 and later */
608$ac_includes_default
609#include <X11/Intrinsic.h>
610		],[String foo = malloc(1); *foo = 0],[
611			cf_cv_const_x_string=no
612		],[
613			cf_cv_const_x_string=yes
614		])
615])
616
617CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
618
619case "$cf_cv_const_x_string" in
620(no)
621	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
622	;;
623(*)
624	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
625	;;
626esac
627
628])
629])dnl
630dnl ---------------------------------------------------------------------------
631dnl CF_DISABLE_DESKTOP version: 2 updated: 2011/04/22 05:17:37
632dnl ------------------
633dnl Handle a configure option "--disable-desktop", which sets a shell
634dnl variable $desktop_utils to a "#" if the feature is not wanted, or to an
635dnl empty string if enabled.  The variable is used to substitute in front of
636dnl corresponding makefile-rules.
637dnl
638dnl It also tells the configure script to substitute the environment variable
639dnl $DESKTOP_FLAGS, which can be used by external scripts to customize the
640dnl invocation of desktop-file-util.
641dnl
642dnl $1 = program name
643AC_DEFUN([CF_DISABLE_DESKTOP],[
644# Comment-out the install-desktop rule if the desktop-utils are not found.
645AC_MSG_CHECKING(if you want to install desktop files)
646CF_ARG_OPTION(desktop,
647	[  --disable-desktop       disable install of $1 desktop files],
648	[enable_desktop=$enableval],
649	[enable_desktop=$enableval],yes)
650AC_MSG_RESULT($enable_desktop)
651
652desktop_utils=
653if test "$enable_desktop" = yes ; then
654AC_CHECK_PROG(desktop_utils,desktop-file-install,yes,no)
655fi
656
657test "$desktop_utils" = yes && desktop_utils= || desktop_utils="#"
658AC_SUBST(DESKTOP_FLAGS)
659])
660dnl ---------------------------------------------------------------------------
661dnl CF_DISABLE_ECHO version: 14 updated: 2021/09/04 06:35:04
662dnl ---------------
663dnl You can always use "make -n" to see the actual options, but it is hard to
664dnl pick out/analyze warning messages when the compile-line is long.
665dnl
666dnl Sets:
667dnl	ECHO_LT - symbol to control if libtool is verbose
668dnl	ECHO_LD - symbol to prefix "cc -o" lines
669dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
670dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
671dnl	ECHO_CC - symbol to put before any "cc" line
672dnl
673AC_DEFUN([CF_DISABLE_ECHO],[
674AC_MSG_CHECKING(if you want to see long compiling messages)
675CF_ARG_DISABLE(echo,
676	[  --disable-echo          do not display "compiling" commands],
677	[
678	ECHO_LT='--silent'
679	ECHO_LD='@echo linking [$]@;'
680	RULE_CC='@echo compiling [$]<'
681	SHOW_CC='@echo compiling [$]@'
682	ECHO_CC='@'
683],[
684	ECHO_LT=''
685	ECHO_LD=''
686	RULE_CC=''
687	SHOW_CC=''
688	ECHO_CC=''
689])
690AC_MSG_RESULT($enableval)
691AC_SUBST(ECHO_LT)
692AC_SUBST(ECHO_LD)
693AC_SUBST(RULE_CC)
694AC_SUBST(SHOW_CC)
695AC_SUBST(ECHO_CC)
696])dnl
697dnl ---------------------------------------------------------------------------
698dnl CF_DISABLE_LEAKS version: 9 updated: 2021/04/03 16:41:50
699dnl ----------------
700dnl Combine no-leak checks with the libraries or tools that are used for the
701dnl checks.
702AC_DEFUN([CF_DISABLE_LEAKS],[
703
704AC_REQUIRE([CF_WITH_DMALLOC])
705AC_REQUIRE([CF_WITH_DBMALLOC])
706AC_REQUIRE([CF_WITH_VALGRIND])
707
708AC_MSG_CHECKING(if you want to perform memory-leak testing)
709AC_ARG_ENABLE(leaks,
710	[  --disable-leaks         test: free permanent memory, analyze leaks],
711	[enable_leaks=$enableval],
712	[enable_leaks=yes])
713dnl with_no_leaks is more readable...
714if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
715AC_MSG_RESULT($with_no_leaks)
716
717if test "$enable_leaks" = no ; then
718	AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
719	AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
720fi
721])dnl
722dnl ---------------------------------------------------------------------------
723dnl CF_DISABLE_RPATH_HACK version: 3 updated: 2021/01/05 20:14:44
724dnl ---------------------
725dnl The rpath-hack makes it simpler to build programs, particularly with the
726dnl *BSD ports which may have essential libraries in unusual places.  But it
727dnl can interfere with building an executable for the base system.  Use this
728dnl option in that case.
729AC_DEFUN([CF_DISABLE_RPATH_HACK],
730[
731AC_MSG_CHECKING(if rpath-hack should be disabled)
732CF_ARG_DISABLE(rpath-hack,
733	[  --disable-rpath-hack    don't add rpath options for additional libraries],
734	[enable_rpath_hack=no],
735	[enable_rpath_hack=yes])
736dnl TODO - drop cf_disable_rpath_hack
737if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
738AC_MSG_RESULT($cf_disable_rpath_hack)
739
740if test "$enable_rpath_hack" = yes ; then
741	CF_RPATH_HACK
742fi
743])
744dnl ---------------------------------------------------------------------------
745dnl CF_ENABLE_NARROWPROTO version: 6 updated: 2020/12/31 18:40:20
746dnl ---------------------
747dnl If this is not set properly, Xaw's scrollbars will not work.
748dnl The so-called "modular" configuration for X.org omits most of the
749dnl configure checks that would be needed to provide compatibility with
750dnl older X builds.  This one breaks things noticeably.
751AC_DEFUN([CF_ENABLE_NARROWPROTO],
752[
753AC_MSG_CHECKING(if you want narrow prototypes for X libraries)
754
755case `$ac_config_guess` in
756(*freebsd*|*gnu*|*irix5*|*irix6*|*netbsd*|*openbsd*|*qnx*|*sco*|*sgi*)
757	cf_default_narrowproto=yes
758	;;
759(*)
760	cf_default_narrowproto=no
761	;;
762esac
763
764CF_ARG_OPTION(narrowproto,
765	[  --enable-narrowproto    enable narrow prototypes for X libraries],
766	[enable_narrowproto=$enableval],
767	[enable_narrowproto=$cf_default_narrowproto],
768	[$cf_default_narrowproto])
769AC_MSG_RESULT($enable_narrowproto)
770])
771dnl ---------------------------------------------------------------------------
772dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
773dnl ------------------
774dnl Configure-option to enable gcc warnings
775dnl
776dnl $1 = extra options to add, if supported
777dnl $2 = option for checking attributes.  By default, this is done when
778dnl      warnings are enabled.  For other values:
779dnl      yes: always do this, e.g., to use in generated library-headers
780dnl      no: never do this
781AC_DEFUN([CF_ENABLE_WARNINGS],[
782if test "$GCC" = yes || test "$GXX" = yes
783then
784CF_FIX_WARNINGS(CFLAGS)
785CF_FIX_WARNINGS(CPPFLAGS)
786CF_FIX_WARNINGS(LDFLAGS)
787AC_MSG_CHECKING(if you want to turn on gcc warnings)
788CF_ARG_ENABLE(warnings,
789	[  --enable-warnings       test: turn on gcc compiler warnings],
790	[enable_warnings=yes],
791	[enable_warnings=no])
792AC_MSG_RESULT($enable_warnings)
793if test "$enable_warnings" = "yes"
794then
795	ifelse($2,,[CF_GCC_ATTRIBUTES])
796	CF_GCC_WARNINGS($1)
797fi
798ifelse($2,yes,[CF_GCC_ATTRIBUTES])
799fi
800])dnl
801dnl ---------------------------------------------------------------------------
802dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
803dnl --------
804dnl Check if 'errno' is declared in <errno.h>
805AC_DEFUN([CF_ERRNO],
806[
807CF_CHECK_ERRNO(errno)
808])dnl
809dnl ---------------------------------------------------------------------------
810dnl CF_FIX_WARNINGS version: 4 updated: 2021/12/16 18:22:31
811dnl ---------------
812dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
813dnl "-Werror" flags can interfere with configure-checks.  Those go into
814dnl EXTRA_CFLAGS.
815dnl
816dnl $1 = variable name to repair
817define([CF_FIX_WARNINGS],[
818if test "$GCC" = yes || test "$GXX" = yes
819then
820	case [$]$1 in
821	(*-Werror=*)
822		cf_temp_flags=
823		for cf_temp_scan in [$]$1
824		do
825			case "x$cf_temp_scan" in
826			(x-Werror=format*)
827				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
828				;;
829			(x-Werror=*)
830				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
831				;;
832			(*)
833				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
834				;;
835			esac
836		done
837		if test "x[$]$1" != "x$cf_temp_flags"
838		then
839			CF_VERBOSE(repairing $1: [$]$1)
840			$1="$cf_temp_flags"
841			CF_VERBOSE(... fixed [$]$1)
842			CF_VERBOSE(... extra $EXTRA_CFLAGS)
843		fi
844		;;
845	esac
846fi
847AC_SUBST(EXTRA_CFLAGS)
848])dnl
849dnl ---------------------------------------------------------------------------
850dnl CF_FUNC_GETTIME version: 3 updated: 2024/05/11 13:40:02
851dnl ---------------
852dnl Check for gettimeofday or clock_gettime.  In 2023, the former is still more
853dnl widely supported, but "deprecated" (2008), so we will use the latter if it
854dnl is available, to reduce compiler warnings.
855AC_DEFUN([CF_FUNC_GETTIME],[
856cf_save_libs="$LIBS"
857AC_CHECK_FUNC(clock_gettime,
858	cf_cv_test_clock_gettime=yes,
859	AC_CHECK_LIB(rt, clock_gettime,
860		[LIBS="-lrt $LIBS"
861		 cf_cv_test_clock_gettime=yes],
862		 cf_cv_test_clock_gettime=no))
863
864if test "$cf_cv_test_clock_gettime" = yes ; then
865AC_CACHE_CHECK(if clock_gettime links,cf_cv_func_clock_gettime,[
866		AC_TRY_LINK([
867$ac_includes_default
868#include <time.h>
869		],
870		[struct timespec ts;
871		int rc = clock_gettime(CLOCK_REALTIME, &ts)
872			   + clock_gettime(CLOCK_MONOTONIC, &ts);
873		 (void) rc; (void)ts],
874		[cf_cv_func_clock_gettime=yes],
875		[cf_cv_func_clock_gettime=no])
876])
877else
878	cf_cv_func_clock_gettime=no
879fi
880
881if test "$cf_cv_func_clock_gettime" = yes
882then
883	AC_DEFINE(HAVE_CLOCK_GETTIME,1,[Define to 1 if we have clock_gettime function])
884else
885AC_CHECK_FUNC(gettimeofday,
886	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function]),[
887
888AC_CHECK_LIB(bsd, gettimeofday,
889	AC_DEFINE(HAVE_GETTIMEOFDAY,1,[Define to 1 if we have gettimeofday function])
890	CF_ADD_LIB(bsd))])dnl CLIX: bzero, select, gettimeofday
891fi
892])dnl
893dnl ---------------------------------------------------------------------------
894dnl CF_FUNC_GRANTPT version: 15 updated: 2020/12/31 18:40:20
895dnl ---------------
896dnl Check for grantpt versus openpty, as well as functions that "should" be
897dnl available if grantpt is available.
898AC_DEFUN([CF_FUNC_GRANTPT],[
899
900AC_CHECK_HEADERS( \
901stropts.h \
902)
903
904cf_func_grantpt="grantpt ptsname"
905cf_prefer_openpt=no
906case $host_os in
907(darwin[[0-9]].*)
908	;;
909(openbsd[[0-9]].*)
910	# The POSIX entrypoints exist, but have never worked.
911	;;
912(linux*)
913	cf_func_grantpt="$cf_func_grantpt posix_openpt"
914	cf_prefer_openpt=yes
915	;;
916(*)
917	cf_func_grantpt="$cf_func_grantpt posix_openpt"
918	;;
919esac
920
921AC_CHECK_FUNCS($cf_func_grantpt)
922
923cf_grantpt_opts=
924if test "x$ac_cv_func_grantpt" = "xyes" ; then
925	AC_MSG_CHECKING(if grantpt really works)
926	AC_TRY_LINK(CF__GRANTPT_HEAD,CF__GRANTPT_BODY,[
927	AC_TRY_RUN(CF__GRANTPT_HEAD
928int main(void)
929{
930CF__GRANTPT_BODY
931}
932,
933,ac_cv_func_grantpt=no
934,ac_cv_func_grantpt=maybe)
935	],ac_cv_func_grantpt=no)
936	AC_MSG_RESULT($ac_cv_func_grantpt)
937
938	if test "x$ac_cv_func_grantpt" != "xno" ; then
939
940		if test "x$ac_cv_func_grantpt" = "xyes" ; then
941			AC_MSG_CHECKING(for pty features)
942dnl if we have no stropts.h, skip the checks for streams modules
943			if test "x$ac_cv_header_stropts_h" = xyes
944			then
945				cf_pty_this=0
946			else
947				cf_pty_this=3
948			fi
949
950			cf_pty_defines=
951			while test $cf_pty_this != 6
952			do
953
954				cf_pty_feature=
955				cf_pty_next="`expr $cf_pty_this + 1`"
956				CF_MSG_LOG(pty feature test $cf_pty_next:5)
957				AC_TRY_RUN(#define CONFTEST $cf_pty_this
958$cf_pty_defines
959CF__GRANTPT_HEAD
960int main(void)
961{
962CF__GRANTPT_BODY
963}
964,
965[
966				case $cf_pty_next in
967				(1) # - streams
968					cf_pty_feature=ptem
969					;;
970				(2) # - streams
971					cf_pty_feature=ldterm
972					;;
973				(3) # - streams
974					cf_pty_feature=ttcompat
975					;;
976				(4)
977					cf_pty_feature=pty_isatty
978					;;
979				(5)
980					cf_pty_feature=pty_tcsetattr
981					;;
982				(6)
983					cf_pty_feature=tty_tcsetattr
984					;;
985				esac
986],[
987				case $cf_pty_next in
988				(1|2|3)
989					CF_MSG_LOG(skipping remaining streams features $cf_pty_this..2)
990					cf_pty_next=3
991					;;
992				esac
993])
994				if test -n "$cf_pty_feature"
995				then
996					cf_pty_defines="$cf_pty_defines
997#define CONFTEST_$cf_pty_feature 1
998"
999					cf_grantpt_opts="$cf_grantpt_opts $cf_pty_feature"
1000				fi
1001
1002				cf_pty_this=$cf_pty_next
1003			done
1004			AC_MSG_RESULT($cf_grantpt_opts)
1005			cf_grantpt_opts=`echo "$cf_grantpt_opts" | sed -e 's/ isatty//'`
1006		fi
1007	fi
1008fi
1009
1010dnl If we found grantpt, but no features, e.g., for streams or if we are not
1011dnl able to use tcsetattr, then give openpty a try.  In particular, Darwin 10.7
1012dnl has a more functional openpty than posix_openpt.
1013dnl
1014dnl There is no configure run-test for openpty, since older implementations do
1015dnl not always run properly as a non-root user.  For that reason, we also allow
1016dnl the configure script to suppress this check entirely with $disable_openpty.
1017if test "x$cf_prefer_posix_openpt" = "xyes" && test "x$ac_cv_func_posix_openpt" = "xyes" ; then
1018	CF_VERBOSE(prefer posix_openpt over openpty)
1019elif test "x$disable_openpty" != "xyes" || test -z "$cf_grantpt_opts" ; then
1020	AC_CHECK_LIB(util, openpty, [cf_have_openpty=yes],[cf_have_openpty=no])
1021	if test "$cf_have_openpty" = yes ; then
1022		ac_cv_func_grantpt=no
1023		LIBS="-lutil $LIBS"
1024		AC_DEFINE(HAVE_OPENPTY,1,[Define to 1 if you have the openpty function])
1025		AC_CHECK_HEADERS( \
1026			util.h \
1027			libutil.h \
1028			pty.h \
1029		)
1030	fi
1031fi
1032
1033dnl If we did not settle on using openpty, fill in the definitions for grantpt.
1034if test "x$ac_cv_func_grantpt" != xno
1035then
1036	CF_VERBOSE(will rely upon grantpt)
1037	AC_DEFINE(HAVE_WORKING_GRANTPT,1,[Define to 1 if the grantpt function seems to work])
1038	for cf_feature in $cf_grantpt_opts
1039	do
1040		cf_feature=`echo "$cf_feature" | sed -e 's/ //g'`
1041		CF_UPPER(cf_FEATURE,$cf_feature)
1042		AC_DEFINE_UNQUOTED(HAVE_GRANTPT_$cf_FEATURE)
1043	done
1044elif test "x$cf_have_openpty" = xno
1045then
1046	CF_VERBOSE(will rely upon BSD-pseudoterminals)
1047else
1048	CF_VERBOSE(will rely upon openpty)
1049fi
1050])dnl
1051dnl ---------------------------------------------------------------------------
1052dnl CF_FUNC_STRFTIME version: 2 updated: 2023/12/01 20:44:51
1053dnl ----------------
1054AC_DEFUN([CF_FUNC_STRFTIME],
1055[
1056AC_CACHE_CHECK(for strftime function,cf_cv_func_strftime,[
1057AC_TRY_LINK([
1058$ac_includes_default
1059#include <time.h>
1060],[
1061	time_t now = time((time_t*)0);
1062	struct tm *tm = localtime(&now);
1063	char buffer[80];
1064	size_t result = strftime(buffer, sizeof(buffer), "%c", tm);
1065
1066	(void)result;
1067	(void)buffer;
1068],[cf_cv_func_strftime=yes],[cf_cv_func_strftime=no])
1069])
1070
1071test "$cf_cv_func_strftime" = yes && AC_DEFINE(HAVE_STRFTIME,1,[Define to 1 to indicate that strftime function is present])
1072])dnl
1073dnl ---------------------------------------------------------------------------
1074dnl CF_FUNC_TGETENT version: 27 updated: 2023/12/01 17:22:50
1075dnl ---------------
1076dnl Check for tgetent function in termcap library.  If we cannot find this,
1077dnl we'll use the $LINES and $COLUMNS environment variables to pass screen
1078dnl size information to subprocesses.  (We cannot use terminfo's compatibility
1079dnl function, since it cannot provide the termcap-format data).
1080dnl
1081dnl If the --disable-full-tgetent option is given, we'll settle for the first
1082dnl tgetent function we find.  Since the search list in that case does not
1083dnl include the termcap library, that allows us to default to terminfo.
1084AC_DEFUN([CF_FUNC_TGETENT],
1085[
1086# compute a reasonable value for $TERM to give tgetent(), since we may be
1087# running in 'screen', which sets $TERMCAP to a specific entry that is not
1088# necessarily in /etc/termcap - unsetenv is not portable, so we cannot simply
1089# discard $TERMCAP.
1090cf_TERMVAR=vt100
1091if test -n "$TERMCAP"
1092then
1093	cf_TERMCAP=`echo "$TERMCAP" | tr '\n' ' ' | sed -e 's/^..|//' -e 's/|.*//'`
1094	case "$cf_TERMCAP" in
1095	(screen*.*)
1096		;;
1097	(*)
1098		cf_TERMVAR="$cf_TERMCAP"
1099		;;
1100	esac
1101fi
1102test -z "$cf_TERMVAR" && cf_TERMVAR=vt100
1103
1104# BSD termcap used no header file
1105# SVr4 provided termcap prototypes as a legacy feature in term.h
1106# GNU termcap provided termcap prototypes in termcap.h
1107# ncurses provides termcap prototypes in both term.h and termcap.h
1108#
1109# The terminfo-based termcap interfaces do not provide a full tgetent (i.e., do
1110# not return the text of the termcap entry in the buffer), but as a special
1111# case, FreeBSD provides ncurses' termcap.h with a modified termcap reader that
1112# returns the termcap text.
1113AC_CHECK_HEADERS(termcap.h)
1114
1115cf_termcap_h="\
1116#ifdef HAVE_TERMCAP_H
1117#include <termcap.h>
1118#else
1119extern int tgetent(char *, const char *);
1120#endif"
1121
1122AC_MSG_CHECKING(if we want full tgetent function)
1123CF_ARG_DISABLE(full-tgetent,
1124	[  --disable-full-tgetent  disable check for full tgetent function],
1125	cf_full_tgetent=no,
1126	cf_full_tgetent=yes,yes)
1127AC_MSG_RESULT($cf_full_tgetent)
1128
1129if test "$cf_full_tgetent" = yes ; then
1130	cf_test_message="full tgetent"
1131else
1132	cf_test_message="tgetent"
1133fi
1134
1135AC_CACHE_CHECK(for $cf_test_message function,cf_cv_lib_tgetent,[
1136cf_save_LIBS="$LIBS"
1137cf_cv_lib_tgetent=no
1138cf_TERMLIB="termlib ncursesw ncurses curses"
1139if test "$cf_full_tgetent" = yes ; then
1140	cf_TERMLIB="otermcap termcap $cf_TERMLIB"
1141	cf_TERMTST="buffer[[0]] == 0"
1142else
1143	cf_TERMLIB="tinfow tinfo $cf_TERMLIB"
1144	cf_TERMTST="0"
1145fi
1146for cf_termlib in '' $cf_TERMLIB ; do
1147	LIBS="$cf_save_LIBS"
1148	test -n "$cf_termlib" && { CF_ADD_LIB($cf_termlib) }
1149	AC_TRY_RUN([
1150$cf_termcap_h
1151
1152/* terminfo implementations ignore the buffer argument, making it useless for
1153 * the xterm application, which uses this information to make a new TERMCAP
1154 * environment variable.
1155 */
1156int main(void)
1157{
1158	char buffer[1024];
1159	buffer[0] = 0;
1160	tgetent(buffer, "$cf_TERMVAR");
1161	${cf_cv_main_return:-return} ($cf_TERMTST); }],
1162	[echo "yes, there is a termcap/tgetent in $cf_termlib" 1>&AC_FD_CC
1163	 if test -n "$cf_termlib" ; then
1164	 	cf_cv_lib_tgetent="-l$cf_termlib"
1165	 else
1166	 	cf_cv_lib_tgetent=yes
1167	 fi
1168	 break],
1169	[echo "no, there is no termcap/tgetent in $cf_termlib" 1>&AC_FD_CC],
1170	[echo "cross-compiling, cannot verify if a termcap/tgetent is present in $cf_termlib" 1>&AC_FD_CC])
1171done
1172LIBS="$cf_save_LIBS"
1173])
1174
1175# If we found a working tgetent(), set LIBS and check for termcap.h.
1176# (LIBS cannot be set inside AC_CACHE_CHECK; the commands there should
1177# not have side effects other than setting the cache variable, because
1178# they are not executed when a cached value exists.)
1179if test "x$cf_cv_lib_tgetent" != xno ; then
1180	test "x$cf_cv_lib_tgetent" != xyes && { CF_ADD_LIBS($cf_cv_lib_tgetent) }
1181	AC_DEFINE(USE_TERMCAP,1,[Define 1 to indicate that working tgetent is found])
1182	if test "$cf_full_tgetent" = no ; then
1183		AC_TRY_COMPILE([
1184#include <termcap.h>],[
1185#ifdef NCURSES_VERSION
1186#error do not use ncurses termcap.h
1187#endif],[AC_DEFINE(HAVE_TERMCAP_H)])
1188	fi
1189else
1190        # If we didn't find a tgetent() that supports the buffer
1191        # argument, look again to see whether we can find even
1192        # a crippled one.  A crippled tgetent() is still useful to
1193        # validate values for the TERM environment variable given to
1194        # child processes.
1195	AC_CACHE_CHECK(for partial tgetent function,cf_cv_lib_part_tgetent,[
1196	cf_cv_lib_part_tgetent=no
1197	for cf_termlib in $cf_TERMLIB ; do
1198		LIBS="$cf_save_LIBS -l$cf_termlib"
1199		AC_TRY_LINK([$cf_termcap_h],[tgetent(0, "$cf_TERMVAR")],
1200			[echo "there is a terminfo/tgetent in $cf_termlib" 1>&AC_FD_CC
1201			 cf_cv_lib_part_tgetent="-l$cf_termlib"
1202			 break])
1203	done
1204	LIBS="$cf_save_LIBS"
1205	])
1206
1207	if test "$cf_cv_lib_part_tgetent" != no ; then
1208		CF_ADD_LIBS($cf_cv_lib_part_tgetent)
1209                # If this is linking against ncurses, we'll trigger the
1210                # ifdef in resize.c that turns the termcap stuff back off.
1211		AC_DEFINE(USE_TERMINFO,1,[Define to 1 to indicate that terminfo provides the tgetent interface])
1212	fi
1213fi
1214])dnl
1215dnl ---------------------------------------------------------------------------
1216dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
1217dnl -----------------
1218dnl Test for availability of useful gcc __attribute__ directives to quiet
1219dnl compiler warnings.  Though useful, not all are supported -- and contrary
1220dnl to documentation, unrecognized directives cause older compilers to barf.
1221AC_DEFUN([CF_GCC_ATTRIBUTES],
1222[AC_REQUIRE([AC_PROG_FGREP])dnl
1223AC_REQUIRE([CF_C11_NORETURN])dnl
1224
1225if test "$GCC" = yes || test "$GXX" = yes
1226then
1227cat > conftest.i <<EOF
1228#ifndef GCC_PRINTF
1229#define GCC_PRINTF 0
1230#endif
1231#ifndef GCC_SCANF
1232#define GCC_SCANF 0
1233#endif
1234#ifndef GCC_NORETURN
1235#define GCC_NORETURN /* nothing */
1236#endif
1237#ifndef GCC_UNUSED
1238#define GCC_UNUSED /* nothing */
1239#endif
1240EOF
1241if test "$GCC" = yes
1242then
1243	AC_CHECKING([for $CC __attribute__ directives])
1244cat > "conftest.$ac_ext" <<EOF
1245#line __oline__ "${as_me:-configure}"
1246#include <stdio.h>
1247#include "confdefs.h"
1248#include "conftest.h"
1249#include "conftest.i"
1250#if	GCC_PRINTF
1251#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1252#else
1253#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1254#endif
1255#if	GCC_SCANF
1256#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1257#else
1258#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1259#endif
1260extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1261extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
1262extern GCC_NORETURN void foo(void);
1263int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
1264EOF
1265	cf_printf_attribute=no
1266	cf_scanf_attribute=no
1267	for cf_attribute in scanf printf unused noreturn
1268	do
1269		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1270		cf_directive="__attribute__(($cf_attribute))"
1271		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1272
1273		case "$cf_attribute" in
1274		(printf)
1275			cf_printf_attribute=yes
1276			cat >conftest.h <<EOF
1277#define GCC_$cf_ATTRIBUTE 1
1278EOF
1279			;;
1280		(scanf)
1281			cf_scanf_attribute=yes
1282			cat >conftest.h <<EOF
1283#define GCC_$cf_ATTRIBUTE 1
1284EOF
1285			;;
1286		(*)
1287			cat >conftest.h <<EOF
1288#define GCC_$cf_ATTRIBUTE $cf_directive
1289EOF
1290			;;
1291		esac
1292
1293		if AC_TRY_EVAL(ac_compile); then
1294			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1295			cat conftest.h >>confdefs.h
1296			case "$cf_attribute" in
1297			(noreturn)
1298				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
1299				;;
1300			(printf)
1301				cf_value='/* nothing */'
1302				if test "$cf_printf_attribute" != no ; then
1303					cf_value='__attribute__((format(printf,fmt,var)))'
1304					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
1305				fi
1306				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
1307				;;
1308			(scanf)
1309				cf_value='/* nothing */'
1310				if test "$cf_scanf_attribute" != no ; then
1311					cf_value='__attribute__((format(scanf,fmt,var)))'
1312					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
1313				fi
1314				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
1315				;;
1316			(unused)
1317				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
1318				;;
1319			esac
1320		fi
1321	done
1322else
1323	${FGREP-fgrep} define conftest.i >>confdefs.h
1324fi
1325rm -rf ./conftest*
1326fi
1327])dnl
1328dnl ---------------------------------------------------------------------------
1329dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
1330dnl --------------
1331dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
1332dnl compatible), attempt to determine if icc/clang is actually used.
1333AC_DEFUN([CF_GCC_VERSION],[
1334AC_REQUIRE([AC_PROG_CC])
1335GCC_VERSION=none
1336if test "$GCC" = yes ; then
1337	AC_MSG_CHECKING(version of $CC)
1338	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1339	test -z "$GCC_VERSION" && GCC_VERSION=unknown
1340	AC_MSG_RESULT($GCC_VERSION)
1341fi
1342CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1343CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
1344])dnl
1345dnl ---------------------------------------------------------------------------
1346dnl CF_GCC_WARNINGS version: 43 updated: 2024/12/21 08:44:12
1347dnl ---------------
1348dnl Check if the compiler supports useful warning options.  There's a few that
1349dnl we don't use, simply because they're too noisy:
1350dnl
1351dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1352dnl	-Winline (usually not worthwhile)
1353dnl	-Wredundant-decls (system headers make this too noisy)
1354dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
1355dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
1356dnl		is enabled for ncurses using "--enable-const".
1357dnl	-pedantic
1358dnl
1359dnl Parameter:
1360dnl	$1 is an optional list of gcc warning flags that a particular
1361dnl		application might want to use, e.g., "no-unused" for
1362dnl		-Wno-unused
1363dnl Special:
1364dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
1365dnl
1366AC_DEFUN([CF_GCC_WARNINGS],
1367[
1368AC_REQUIRE([CF_GCC_VERSION])
1369if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
1370cat > "conftest.$ac_ext" <<EOF
1371#line __oline__ "${as_me:-configure}"
1372int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1373EOF
1374if test "$INTEL_COMPILER" = yes
1375then
1376# The "-wdXXX" options suppress warnings:
1377# remark #1419: external declaration in primary source file
1378# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1379# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1380# remark #193: zero used for undefined preprocessing identifier
1381# remark #593: variable "curs_sb_left_arrow" was set but never used
1382# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1383# remark #869: parameter "tw" was never referenced
1384# remark #981: operands are evaluated in unspecified order
1385# warning #279: controlling expression is constant
1386
1387	AC_CHECKING([for $CC warning options])
1388	cf_save_CFLAGS="$CFLAGS"
1389	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
1390	for cf_opt in \
1391		wd1419 \
1392		wd1683 \
1393		wd1684 \
1394		wd193 \
1395		wd593 \
1396		wd279 \
1397		wd810 \
1398		wd869 \
1399		wd981
1400	do
1401		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1402		if AC_TRY_EVAL(ac_compile); then
1403			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1404			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1405		fi
1406	done
1407	CFLAGS="$cf_save_CFLAGS"
1408elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
1409then
1410	AC_CHECKING([for $CC warning options])
1411	cf_save_CFLAGS="$CFLAGS"
1412	cf_warn_CONST=""
1413	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1414	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1415	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
1416	for cf_opt in W Wall \
1417		Wbad-function-cast \
1418		Wcast-align \
1419		Wcast-qual \
1420		Wdeclaration-after-statement \
1421		Wextra \
1422		Winline \
1423		Wmissing-declarations \
1424		Wmissing-prototypes \
1425		Wnested-externs \
1426		Wpointer-arith \
1427		Wshadow \
1428		Wstrict-prototypes \
1429		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
1430	do
1431		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1432		if AC_TRY_EVAL(ac_compile); then
1433			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1434			case "$cf_opt" in
1435			(Winline)
1436				case "$GCC_VERSION" in
1437				([[34]].*)
1438					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1439					continue;;
1440				esac
1441				;;
1442			(Wpointer-arith)
1443				case "$GCC_VERSION" in
1444				([[12]].*)
1445					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1446					continue;;
1447				esac
1448				;;
1449			esac
1450			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1451		fi
1452	done
1453	CFLAGS="$cf_save_CFLAGS"
1454fi
1455rm -rf ./conftest*
1456
1457AC_SUBST(EXTRA_CFLAGS)
1458])dnl
1459dnl ---------------------------------------------------------------------------
1460dnl CF_GLOB_FULLPATH version: 2 updated: 2024/08/03 12:34:02
1461dnl ----------------
1462dnl Use this in case-statements to check for pathname syntax, i.e., absolute
1463dnl pathnames.  The "x" is assumed since we provide an alternate form for DOS.
1464AC_DEFUN([CF_GLOB_FULLPATH],[
1465AC_REQUIRE([CF_WITH_SYSTYPE])dnl
1466case "$cf_cv_system_name" in
1467(cygwin*|msys*|mingw32*|mingw64|os2*)
1468	GLOB_FULLPATH_POSIX='/*'
1469	GLOB_FULLPATH_OTHER='[[a-zA-Z]]:[[\\/]]*'
1470	;;
1471(*)
1472	GLOB_FULLPATH_POSIX='/*'
1473	GLOB_FULLPATH_OTHER=$GLOB_FULLPATH_POSIX
1474	;;
1475esac
1476AC_SUBST(GLOB_FULLPATH_POSIX)
1477AC_SUBST(GLOB_FULLPATH_OTHER)
1478])dnl
1479dnl ---------------------------------------------------------------------------
1480dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
1481dnl -------------
1482dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1483dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1484dnl (or misfeature) of glibc2, which breaks portability of many applications,
1485dnl since it is interwoven with GNU extensions.
1486dnl
1487dnl Well, yes we could work around it...
1488dnl
1489dnl Parameters:
1490dnl	$1 is the nominal value for _XOPEN_SOURCE
1491AC_DEFUN([CF_GNU_SOURCE],
1492[
1493cf_gnu_xopen_source=ifelse($1,,500,$1)
1494
1495AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
1496AC_TRY_COMPILE([#include <sys/types.h>],[
1497	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
1498		return 0;
1499	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
1500		return 0;
1501	#else
1502	#	error not GNU C library
1503	#endif],
1504	[cf_cv_gnu_library=yes],
1505	[cf_cv_gnu_library=no])
1506])
1507
1508if test x$cf_cv_gnu_library = xyes; then
1509
1510	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
1511	# was changed to help a little.  newlib incorporated the change about 4
1512	# years later.
1513	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
1514		cf_save="$CPPFLAGS"
1515		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
1516		AC_TRY_COMPILE([#include <sys/types.h>],[
1517			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
1518				return 0;
1519			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
1520				return 0;
1521			#else
1522			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
1523			#endif],
1524			[cf_cv_gnu_library_219=yes],
1525			[cf_cv_gnu_library_219=no])
1526		CPPFLAGS="$cf_save"
1527	])
1528
1529	if test "x$cf_cv_gnu_library_219" = xyes; then
1530		cf_save="$CPPFLAGS"
1531		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
1532			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
1533			AC_TRY_COMPILE([
1534				#include <limits.h>
1535				#include <sys/types.h>
1536				],[
1537				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
1538					return 0;
1539				#else
1540				#	error GNU C library is too old
1541				#endif],
1542				[cf_cv_gnu_dftsrc_219=yes],
1543				[cf_cv_gnu_dftsrc_219=no])
1544			])
1545		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
1546	else
1547		cf_cv_gnu_dftsrc_219=maybe
1548	fi
1549
1550	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
1551
1552		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1553		AC_TRY_COMPILE([#include <sys/types.h>],[
1554			#ifndef _XOPEN_SOURCE
1555			#error	expected _XOPEN_SOURCE to be defined
1556			#endif],
1557			[cf_cv_gnu_source=no],
1558			[cf_save="$CPPFLAGS"
1559			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
1560			 AC_TRY_COMPILE([#include <sys/types.h>],[
1561				#ifdef _XOPEN_SOURCE
1562				#error	expected _XOPEN_SOURCE to be undefined
1563				#endif],
1564				[cf_cv_gnu_source=no],
1565				[cf_cv_gnu_source=yes])
1566			CPPFLAGS="$cf_save"
1567			])
1568		])
1569
1570		if test "$cf_cv_gnu_source" = yes
1571		then
1572		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
1573			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
1574			AC_TRY_COMPILE([#include <sys/types.h>],[
1575				#ifdef _DEFAULT_SOURCE
1576				#error	expected _DEFAULT_SOURCE to be undefined
1577				#endif],
1578				[cf_cv_default_source=no],
1579				[cf_cv_default_source=yes])
1580			])
1581			if test "$cf_cv_default_source" = yes
1582			then
1583				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
1584			fi
1585		fi
1586	fi
1587
1588fi
1589])dnl
1590dnl ---------------------------------------------------------------------------
1591dnl CF_HELP_MESSAGE version: 4 updated: 2019/12/31 08:53:54
1592dnl ---------------
1593dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1594AC_DEFUN([CF_HELP_MESSAGE],
1595[CF_ACVERSION_CHECK(2.53,[],[
1596AC_DIVERT_HELP($1)])dnl
1597])dnl
1598dnl ---------------------------------------------------------------------------
1599dnl CF_IMAKE_CFLAGS version: 34 updated: 2020/12/31 18:40:20
1600dnl ---------------
1601dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
1602dnl get these, but if imake is properly configured there is no point in doing
1603dnl this.
1604dnl
1605dnl Parameters (used in constructing a sample Imakefile):
1606dnl	$1 = optional value to append to $IMAKE_CFLAGS
1607dnl	$2 = optional value to append to $IMAKE_LOADFLAGS
1608AC_DEFUN([CF_IMAKE_CFLAGS],
1609[
1610AC_PATH_PROGS(IMAKE,xmkmf imake)
1611
1612if test -n "$IMAKE" ; then
1613
1614case $IMAKE in
1615(*/imake)
1616	cf_imake_opts="-DUseInstalled=YES"
1617	;;
1618(*/util/xmkmf)
1619	# A single parameter tells xmkmf where the config-files are:
1620	cf_imake_opts="`echo "$IMAKE"|sed -e s,/config/util/xmkmf,,`"
1621	;;
1622(*)
1623	cf_imake_opts=
1624	;;
1625esac
1626
1627# If it's installed properly, imake (or its wrapper, xmkmf) will point to the
1628# config directory.
1629if mkdir conftestdir; then
1630	CDPATH=; export CDPATH
1631	cf_makefile=`cd "$srcdir" || exit;pwd`/Imakefile
1632	cd conftestdir
1633
1634	cat >fix_cflags.sed <<'CF_EOF'
1635s/\\//g
1636s/[[ 	]][[ 	]]*/ /g
1637s/"//g
1638:pack
1639s/\(=[[^ ]][[^ ]]*\) \([[^-]]\)/\1	\2/g
1640t pack
1641s/\(-D[[a-zA-Z0-9_]][[a-zA-Z0-9_]]*\)=\([[^\'0-9 ]][[^ ]]*\)/\1='\\"\2\\"'/g
1642s/^IMAKE[[ ]]/IMAKE_CFLAGS="/
1643s/	/ /g
1644s/$/"/
1645CF_EOF
1646
1647	cat >fix_lflags.sed <<'CF_EOF'
1648s/^IMAKE[[ 	]]*/IMAKE_LOADFLAGS="/
1649s/$/"/
1650CF_EOF
1651
1652	echo >./Imakefile
1653	test -f "$cf_makefile" && cat "$cf_makefile" >>./Imakefile
1654
1655	cat >> ./Imakefile <<'CF_EOF'
1656findstddefs:
1657	@echo IMAKE ${ALLDEFINES}ifelse([$1],,,[ $1])       | sed -f fix_cflags.sed
1658	@echo IMAKE ${EXTRA_LOAD_FLAGS}ifelse([$2],,,[ $2]) | sed -f fix_lflags.sed
1659CF_EOF
1660
1661	if ( $IMAKE "$cf_imake_opts" 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
1662	then
1663		CF_VERBOSE(Using $IMAKE $cf_imake_opts)
1664	else
1665		# sometimes imake doesn't have the config path compiled in.  Find it.
1666		cf_config=
1667		for cf_libpath in $X_LIBS $LIBS ; do
1668			case "$cf_libpath" in
1669			(-L*)
1670				cf_libpath=`echo ".$cf_libpath" | sed -e 's/^...//'`
1671				cf_libpath="$cf_libpath/X11/config"
1672				if test -d "$cf_libpath" ; then
1673					cf_config="$cf_libpath"
1674					break
1675				fi
1676				;;
1677			esac
1678		done
1679		if test -z "$cf_config" ; then
1680			AC_MSG_WARN(Could not find imake config-directory)
1681		else
1682			cf_imake_opts="$cf_imake_opts -I$cf_config"
1683			if ( "$IMAKE" -v "$cf_imake_opts" 2>&AC_FD_CC)
1684			then
1685				CF_VERBOSE(Using $IMAKE $cf_config)
1686			else
1687				AC_MSG_WARN(Cannot run $IMAKE)
1688			fi
1689		fi
1690	fi
1691
1692	# GNU make sometimes prints "make[1]: Entering...", which
1693	# would confuse us.
1694	eval "`make findstddefs 2>/dev/null | grep -v make`"
1695
1696	cd ..
1697	rm -rf conftestdir
1698
1699	# We use ${ALLDEFINES} rather than ${STD_DEFINES} because the former
1700	# declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
1701	# modified it to support site.cf, adding a kludge for the /usr/include
1702	# directory.  Try to filter that out, otherwise gcc won't find its
1703	# headers.
1704	if test -n "$GCC" ; then
1705	    if test -n "$IMAKE_CFLAGS" ; then
1706		cf_nostdinc=""
1707		cf_std_incl=""
1708		cf_cpp_opts=""
1709		for cf_opt in $IMAKE_CFLAGS
1710		do
1711		    case "$cf_opt" in
1712		    (-nostdinc)
1713			cf_nostdinc="$cf_opt"
1714			;;
1715		    (-I/usr/include)
1716			cf_std_incl="$cf_opt"
1717			;;
1718		    (*)
1719			cf_cpp_opts="$cf_cpp_opts $cf_opt"
1720			;;
1721		    esac
1722		done
1723		if test -z "$cf_nostdinc" ; then
1724		    IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
1725		elif test -z "$cf_std_incl" ; then
1726		    IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
1727		else
1728		    CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
1729		    IMAKE_CFLAGS="$cf_cpp_opts"
1730		fi
1731	    fi
1732	fi
1733fi
1734
1735# Some imake configurations define PROJECTROOT with an empty value.  Remove
1736# the empty definition.
1737case $IMAKE_CFLAGS in
1738(*-DPROJECTROOT=/*)
1739	;;
1740(*)
1741	IMAKE_CFLAGS=`echo "$IMAKE_CFLAGS" |sed -e "s,-DPROJECTROOT=[[ 	]], ,"`
1742	;;
1743esac
1744
1745fi
1746
1747CF_VERBOSE(IMAKE_CFLAGS $IMAKE_CFLAGS)
1748CF_VERBOSE(IMAKE_LOADFLAGS $IMAKE_LOADFLAGS)
1749
1750AC_SUBST(IMAKE_CFLAGS)
1751AC_SUBST(IMAKE_LOADFLAGS)
1752])dnl
1753dnl ---------------------------------------------------------------------------
1754dnl CF_INPUT_METHOD version: 5 updated: 2021/06/07 17:39:17
1755dnl ---------------
1756dnl Check if the X libraries support input-method
1757AC_DEFUN([CF_INPUT_METHOD],
1758[
1759AC_CACHE_CHECK([if X libraries support input-method],cf_cv_input_method,[
1760AC_TRY_LINK([
1761#include <X11/IntrinsicP.h>
1762#include <X11/Xatom.h>
1763#include <X11/Xutil.h>
1764#include <X11/Xmu/Atoms.h>
1765#include <X11/Xmu/Converters.h>
1766#include <X11/Xaw/XawImP.h>
1767],[
1768{
1769	XIM xim;
1770	XIMStyles *xim_styles = 0;
1771	XIMStyle input_style;
1772	Widget w = XtCreateWidget("none", (WidgetClass)0, None, (ArgList)0, 0);
1773
1774	XSetLocaleModifiers("@im=none");
1775	xim = XOpenIM(XtDisplay(w), NULL, NULL, NULL);
1776	XGetIMValues(xim, XNQueryInputStyle, &xim_styles, NULL);
1777	XCloseIM(xim);
1778	input_style = (XIMPreeditNothing | XIMStatusNothing);
1779	(void)xim_styles;
1780	(void)input_style;
1781}
1782],
1783[cf_cv_input_method=yes],
1784[cf_cv_input_method=no])])
1785])dnl
1786dnl ---------------------------------------------------------------------------
1787dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25
1788dnl -----------------
1789dnl Check if the given compiler is really the Intel compiler for Linux.  It
1790dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1791dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1792dnl
1793dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1794dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1795dnl the wrappers for gcc and g++ warnings.
1796dnl
1797dnl $1 = GCC (default) or GXX
1798dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1799dnl $3 = CFLAGS (default) or CXXFLAGS
1800AC_DEFUN([CF_INTEL_COMPILER],[
1801AC_REQUIRE([AC_CANONICAL_HOST])
1802ifelse([$2],,INTEL_COMPILER,[$2])=no
1803
1804if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1805	case "$host_os" in
1806	(linux*|gnu*)
1807		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1808		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1809		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1810		AC_TRY_COMPILE([],[
1811#ifdef __INTEL_COMPILER
1812#else
1813#error __INTEL_COMPILER is not defined
1814#endif
1815],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1816cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1817],[])
1818		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1819		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1820		;;
1821	esac
1822fi
1823])dnl
1824dnl ---------------------------------------------------------------------------
1825dnl CF_LASTLOG version: 8 updated: 2023/12/01 17:22:50
1826dnl ----------
1827dnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
1828dnl file exists.
1829AC_DEFUN([CF_LASTLOG],
1830[
1831AC_CHECK_HEADERS(lastlog.h paths.h)
1832AC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
1833AC_TRY_COMPILE([
1834#include <sys/types.h>
1835#ifdef HAVE_LASTLOG_H
1836#include <lastlog.h>
1837#else
1838#ifdef HAVE_PATHS_H
1839#include <paths.h>
1840#endif
1841#endif],[static char path[] = _PATH_LASTLOG; (void)path],
1842	[cf_cv_path_lastlog="_PATH_LASTLOG"],
1843	[if test -f /usr/adm/lastlog ; then
1844	 	cf_cv_path_lastlog=/usr/adm/lastlog
1845	else
1846		cf_cv_path_lastlog=no
1847	fi])
1848])
1849test "$cf_cv_path_lastlog" != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
1850])dnl
1851dnl ---------------------------------------------------------------------------
1852dnl CF_LD_RPATH_OPT version: 9 updated: 2021/01/01 13:31:04
1853dnl ---------------
1854dnl For the given system and compiler, find the compiler flags to pass to the
1855dnl loader to use the "rpath" feature.
1856AC_DEFUN([CF_LD_RPATH_OPT],
1857[
1858AC_REQUIRE([CF_CHECK_CACHE])
1859
1860LD_RPATH_OPT=
1861if test "x$cf_cv_enable_rpath" != xno
1862then
1863	AC_MSG_CHECKING(for an rpath option)
1864	case "$cf_cv_system_name" in
1865	(irix*)
1866		if test "$GCC" = yes; then
1867			LD_RPATH_OPT="-Wl,-rpath,"
1868		else
1869			LD_RPATH_OPT="-rpath "
1870		fi
1871		;;
1872	(linux*|gnu*|k*bsd*-gnu|freebsd*)
1873		LD_RPATH_OPT="-Wl,-rpath,"
1874		;;
1875	(openbsd[[2-9]].*|mirbsd*)
1876		LD_RPATH_OPT="-Wl,-rpath,"
1877		;;
1878	(dragonfly*)
1879		LD_RPATH_OPT="-rpath "
1880		;;
1881	(netbsd*)
1882		LD_RPATH_OPT="-Wl,-rpath,"
1883		;;
1884	(osf*|mls+*)
1885		LD_RPATH_OPT="-rpath "
1886		;;
1887	(solaris2*)
1888		LD_RPATH_OPT="-R"
1889		;;
1890	(*)
1891		;;
1892	esac
1893	AC_MSG_RESULT($LD_RPATH_OPT)
1894
1895	case "x$LD_RPATH_OPT" in
1896	(x-R*)
1897		AC_MSG_CHECKING(if we need a space after rpath option)
1898		cf_save_LIBS="$LIBS"
1899		CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1900		AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1901		LIBS="$cf_save_LIBS"
1902		AC_MSG_RESULT($cf_rpath_space)
1903		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1904		;;
1905	esac
1906fi
1907])dnl
1908dnl ---------------------------------------------------------------------------
1909dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1910dnl ------------
1911dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1912dnl a monocase filesystem.
1913AC_DEFUN([CF_MAKE_TAGS],[
1914AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1915
1916AC_CHECK_PROGS(CTAGS, exctags ctags)
1917AC_CHECK_PROGS(ETAGS, exetags etags)
1918
1919AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1920
1921if test "$cf_cv_mixedcase" = yes ; then
1922	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1923else
1924	MAKE_UPPER_TAGS=no
1925fi
1926
1927if test "$MAKE_UPPER_TAGS" = yes ; then
1928	MAKE_UPPER_TAGS=
1929else
1930	MAKE_UPPER_TAGS="#"
1931fi
1932
1933if test "$MAKE_LOWER_TAGS" = yes ; then
1934	MAKE_LOWER_TAGS=
1935else
1936	MAKE_LOWER_TAGS="#"
1937fi
1938
1939AC_SUBST(CTAGS)
1940AC_SUBST(ETAGS)
1941
1942AC_SUBST(MAKE_UPPER_TAGS)
1943AC_SUBST(MAKE_LOWER_TAGS)
1944])dnl
1945dnl ---------------------------------------------------------------------------
1946dnl CF_MATH_LIB version: 11 updated: 2022/07/27 19:01:48
1947dnl -----------
1948dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
1949dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
1950dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1951AC_DEFUN([CF_MATH_LIB],
1952[
1953AC_CACHE_CHECK(if -lm needed for math functions,
1954	cf_cv_need_libm,[
1955	AC_TRY_LINK([
1956		#include <stdio.h>
1957		#include <stdlib.h>
1958		#include <math.h>
1959	],
1960	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
1961	[cf_cv_need_libm=no],
1962	[cf_cv_need_libm=yes])])
1963
1964if test "$cf_cv_need_libm" = yes
1965then
1966
1967	cf_save_LIBS="$LIBS"
1968	LIBS="$LIBS -lm"
1969	AC_CACHE_CHECK(if -lm is available for math functions,
1970	cf_cv_have_libm,[
1971	AC_TRY_LINK([
1972		#include <stdio.h>
1973		#include <stdlib.h>
1974		#include <math.h>
1975	],
1976	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
1977	[cf_cv_have_libm=yes],
1978	[cf_cv_have_libm=no])])
1979	LIBS="$cf_save_LIBS"
1980
1981	if test "$cf_cv_have_libm" = yes
1982	then
1983		ifelse($1,,[CF_ADD_LIB(m)],[$1=-lm])
1984	fi
1985else
1986	cf_cv_have_libm=yes
1987fi
1988
1989if test "$cf_cv_have_libm" = yes
1990then
1991	AC_DEFINE(HAVE_MATH_FUNCS,1,[Define to 1 if math functions are available])
1992fi
1993])
1994dnl ---------------------------------------------------------------------------
1995dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
1996dnl ----------------------
1997dnl Check if the file-system supports mixed-case filenames.  If we're able to
1998dnl create a lowercase name and see it as uppercase, it doesn't support that.
1999AC_DEFUN([CF_MIXEDCASE_FILENAMES],
2000[
2001AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
2002if test "$cross_compiling" = yes ; then
2003	case "$target_alias" in
2004	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
2005		cf_cv_mixedcase=no
2006		;;
2007	(*)
2008		cf_cv_mixedcase=yes
2009		;;
2010	esac
2011else
2012	rm -f conftest CONFTEST
2013	echo test >conftest
2014	if test -f CONFTEST ; then
2015		cf_cv_mixedcase=no
2016	else
2017		cf_cv_mixedcase=yes
2018	fi
2019	rm -f conftest CONFTEST
2020fi
2021])
2022test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
2023])dnl
2024dnl ---------------------------------------------------------------------------
2025dnl CF_MKSTEMP version: 13 updated: 2023/12/01 17:22:50
2026dnl ----------
2027dnl Check for a working mkstemp.  This creates two files, checks that they are
2028dnl successfully created and distinct (AmigaOS apparently fails on the last).
2029AC_DEFUN([CF_MKSTEMP],[
2030AC_CHECK_HEADERS( \
2031unistd.h \
2032)
2033AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
2034rm -rf ./conftest*
2035AC_TRY_RUN([
2036$ac_includes_default
2037
2038int main(void)
2039{
2040	static char tmpl[] = "conftestXXXXXX";
2041	char name[2][80];
2042	int n;
2043	int result = 0;
2044	int fd;
2045	struct stat sb;
2046
2047	umask(077);
2048	for (n = 0; n < 2; ++n) {
2049		strcpy(name[n], tmpl);
2050		if ((fd = mkstemp(name[n])) >= 0) {
2051			if (!strcmp(name[n], tmpl)
2052			 || stat(name[n], &sb) != 0
2053			 || (sb.st_mode & S_IFMT) != S_IFREG
2054			 || (sb.st_mode & 077) != 0) {
2055				result = 1;
2056			}
2057			close(fd);
2058		}
2059	}
2060	if (result == 0
2061	 && !strcmp(name[0], name[1]))
2062		result = 1;
2063	${cf_cv_main_return:-return}(result);
2064}
2065],[cf_cv_func_mkstemp=yes
2066],[cf_cv_func_mkstemp=no
2067],[cf_cv_func_mkstemp=maybe])
2068])
2069if test "x$cf_cv_func_mkstemp" = xmaybe ; then
2070	AC_CHECK_FUNC(mkstemp)
2071fi
2072if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
2073	AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
2074fi
2075])dnl
2076dnl ---------------------------------------------------------------------------
2077dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
2078dnl ----------
2079dnl Write a debug message to config.log, along with the line number in the
2080dnl configure script.
2081AC_DEFUN([CF_MSG_LOG],[
2082echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
2083])dnl
2084dnl ---------------------------------------------------------------------------
2085dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
2086dnl ------------------
2087dnl see CF_WITH_NO_LEAKS
2088dnl
2089dnl $1 = option/name
2090dnl $2 = help-text
2091dnl $3 = symbol to define if the option is set
2092dnl $4 = additional actions to take if the option is set
2093AC_DEFUN([CF_NO_LEAKS_OPTION],[
2094AC_MSG_CHECKING(if you want to use $1 for testing)
2095AC_ARG_WITH($1,
2096	[$2],
2097	[case "x$withval" in
2098	(x|xno) ;;
2099	(*)
2100		: "${with_cflags:=-g}"
2101		: "${enable_leaks:=no}"
2102		with_$1=yes
2103		AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
2104	 $4
2105])
2106		;;
2107	esac],
2108	[with_$1=])
2109AC_MSG_RESULT(${with_$1:-no})
2110
2111case ".$with_cflags" in
2112(.*-g*)
2113	case .$CFLAGS in
2114	(.*-g*)
2115		;;
2116	(*)
2117		CF_ADD_CFLAGS([-g])
2118		;;
2119	esac
2120	;;
2121esac
2122])dnl
2123dnl ---------------------------------------------------------------------------
2124dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
2125dnl ----------
2126dnl Provide a value for the $PATH and similar separator (or amend the value
2127dnl as provided in autoconf 2.5x).
2128AC_DEFUN([CF_PATHSEP],
2129[
2130	AC_MSG_CHECKING(for PATH separator)
2131	case "$cf_cv_system_name" in
2132	(os2*)	PATH_SEPARATOR=';'  ;;
2133	(*)	${PATH_SEPARATOR:=':'}  ;;
2134	esac
2135ifelse([$1],,,[$1=$PATH_SEPARATOR])
2136	AC_SUBST(PATH_SEPARATOR)
2137	AC_MSG_RESULT($PATH_SEPARATOR)
2138])dnl
2139dnl ---------------------------------------------------------------------------
2140dnl CF_PATH_PROG version: 12 updated: 2021/01/02 09:31:20
2141dnl ------------
2142dnl Check for a given program, defining corresponding symbol.
2143dnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
2144dnl	$2 = program name to find.
2145dnl	$3 = optional list of additional program names to test.
2146dnl $4 = $PATH
2147dnl
2148dnl If there is more than one token in the result, #define the remaining tokens
2149dnl to $1_ARGS.  We need this for 'install' in particular.
2150dnl
2151dnl FIXME: we should allow this to be overridden by environment variables
2152dnl
2153AC_DEFUN([CF_PATH_PROG],[
2154AC_REQUIRE([CF_PATHSEP])
2155test -z "[$]$1" && $1="$2"
2156AC_PATH_PROGS($1,[$]$1 $2 ifelse($3,,,$3),[$]$1, ifelse($4,,,$4))
2157
2158cf_path_prog=""
2159cf_path_args=""
2160IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
2161for cf_temp in $ac_cv_path_$1
2162do
2163	if test -z "$cf_path_prog" ; then
2164		if test "$with_full_paths" = yes ; then
2165			CF_PATH_SYNTAX(cf_temp,break)
2166			cf_path_prog="$cf_temp"
2167		else
2168			cf_path_prog="`basename "$cf_temp"`"
2169		fi
2170	elif test -z "$cf_path_args" ; then
2171		cf_path_args="$cf_temp"
2172	else
2173		cf_path_args="$cf_path_args $cf_temp"
2174	fi
2175done
2176IFS="$cf_save_ifs"
2177
2178if test -n "$cf_path_prog" ; then
2179	CF_MSG_LOG(defining path for ${cf_path_prog})
2180	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
2181	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
2182fi
2183])dnl
2184dnl ---------------------------------------------------------------------------
2185dnl CF_PATH_SYNTAX version: 19 updated: 2024/08/03 13:08:58
2186dnl --------------
2187dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2188dnl begins with one of the prefix/exec_prefix variables, and then again if the
2189dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2190dnl delayed evaluation of those symbols.
2191AC_DEFUN([CF_PATH_SYNTAX],[
2192AC_REQUIRE([CF_GLOB_FULLPATH])dnl
2193
2194if test "x$prefix" != xNONE; then
2195	cf_path_syntax="$prefix"
2196else
2197	cf_path_syntax="$ac_default_prefix"
2198fi
2199
2200case "x[$]$1" in
2201(x\[$]\(*\)*|x\'*\'*)
2202	;;
2203(x.|x$GLOB_FULLPATH_POSIX|x$GLOB_FULLPATH_OTHER)
2204	;;
2205(x\[$]\{*prefix\}*|x\[$]\{*dir\}*)
2206	eval $1="[$]$1"
2207	case "x[$]$1" in
2208	(xNONE/*)
2209		$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
2210		;;
2211	esac
2212	;;
2213(xno|xNONE/*)
2214	$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
2215	;;
2216(*)
2217	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2218	;;
2219esac
2220])dnl
2221dnl ---------------------------------------------------------------------------
2222dnl CF_PKG_CONFIG version: 13 updated: 2023/10/28 11:59:01
2223dnl -------------
2224dnl Check for the package-config program, unless disabled by command-line.
2225dnl
2226dnl Sets $PKG_CONFIG to the pathname of the pkg-config program.
2227AC_DEFUN([CF_PKG_CONFIG],
2228[
2229AC_MSG_CHECKING(if you want to use pkg-config)
2230AC_ARG_WITH(pkg-config,
2231	[[  --with-pkg-config[=CMD] enable/disable use of pkg-config and its name CMD]],
2232	[cf_pkg_config=$withval],
2233	[cf_pkg_config=yes])
2234AC_MSG_RESULT($cf_pkg_config)
2235
2236case "$cf_pkg_config" in
2237(no)
2238	PKG_CONFIG=none
2239	;;
2240(yes)
2241	CF_ACVERSION_CHECK(2.52,
2242		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
2243		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
2244	;;
2245(*)
2246	PKG_CONFIG=$withval
2247	;;
2248esac
2249
2250test -z "$PKG_CONFIG" && PKG_CONFIG=none
2251if test "$PKG_CONFIG" != none ; then
2252	CF_PATH_SYNTAX(PKG_CONFIG)
2253elif test "x$cf_pkg_config" != xno ; then
2254	AC_MSG_WARN(pkg-config is not installed)
2255fi
2256
2257AC_SUBST(PKG_CONFIG)
2258])dnl
2259dnl ---------------------------------------------------------------------------
2260dnl CF_POSIX_C_SOURCE version: 12 updated: 2023/02/18 17:41:25
2261dnl -----------------
2262dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2263dnl
2264dnl	POSIX.1-1990				_POSIX_SOURCE
2265dnl	POSIX.1-1990 and			_POSIX_SOURCE and
2266dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
2267dnl		Bindings Option
2268dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
2269dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
2270dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
2271dnl
2272dnl Parameters:
2273dnl	$1 is the nominal value for _POSIX_C_SOURCE
2274AC_DEFUN([CF_POSIX_C_SOURCE],
2275[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
2276
2277if test "$cf_cv_posix_visible" = no; then
2278
2279cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2280
2281cf_save_CFLAGS="$CFLAGS"
2282cf_save_CPPFLAGS="$CPPFLAGS"
2283
2284CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2285CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2286
2287AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2288	CF_MSG_LOG(if the symbol is already defined go no further)
2289	AC_TRY_COMPILE([#include <sys/types.h>],[
2290#ifndef _POSIX_C_SOURCE
2291#error _POSIX_C_SOURCE is not defined
2292#endif],
2293	[cf_cv_posix_c_source=no],
2294	[cf_want_posix_source=no
2295	 case .$cf_POSIX_C_SOURCE in
2296	 (.[[12]]??*)
2297		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2298		;;
2299	 (.2)
2300		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2301		cf_want_posix_source=yes
2302		;;
2303	 (.*)
2304		cf_want_posix_source=yes
2305		;;
2306	 esac
2307	 if test "$cf_want_posix_source" = yes ; then
2308		AC_TRY_COMPILE([#include <sys/types.h>],[
2309#ifdef _POSIX_SOURCE
2310#error _POSIX_SOURCE is defined
2311#endif],[],
2312		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2313	 fi
2314	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2315	 CFLAGS="$cf_trim_CFLAGS"
2316	 CPPFLAGS="$cf_trim_CPPFLAGS"
2317	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
2318	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
2319	 AC_TRY_COMPILE([#include <sys/types.h>],[
2320#ifndef _POSIX_C_SOURCE
2321#error _POSIX_C_SOURCE is not defined
2322#endif],,
2323	 [cf_cv_posix_c_source=no])
2324	 CFLAGS="$cf_save_CFLAGS"
2325	 CPPFLAGS="$cf_save_CPPFLAGS"
2326	])
2327])
2328
2329if test "$cf_cv_posix_c_source" != no ; then
2330	CFLAGS="$cf_trim_CFLAGS"
2331	CPPFLAGS="$cf_trim_CPPFLAGS"
2332	CF_ADD_CFLAGS($cf_cv_posix_c_source)
2333fi
2334
2335fi # cf_cv_posix_visible
2336
2337])dnl
2338dnl ---------------------------------------------------------------------------
2339dnl CF_POSIX_SAVED_IDS version: 12 updated: 2023/12/03 19:55:51
2340dnl ------------------
2341dnl
2342dnl Check first if saved-ids are always supported.  Some systems
2343dnl may require runtime checks.
2344AC_DEFUN([CF_POSIX_SAVED_IDS],
2345[
2346AC_CHECK_HEADERS( \
2347sys/param.h \
2348)
2349
2350AC_CACHE_CHECK(if POSIX saved-ids are supported,cf_cv_posix_saved_ids,[
2351AC_TRY_LINK(
2352[
2353#include <unistd.h>
2354#ifdef HAVE_SYS_PARAM_H
2355#include <sys/param.h>		/* this may define "BSD" */
2356#endif
2357],[
2358#if defined(_POSIX_SAVED_IDS) && (_POSIX_SAVED_IDS > 0)
2359	int (*my_seteuid)(uid_t) = seteuid;
2360	int x = my_seteuid(geteuid());
2361	(void)x;
2362#elif defined(BSD) && (BSD >= 199103)
2363/* The BSD's may implement the runtime check - and it fails.
2364 * However, saved-ids work almost like POSIX (close enough for most uses).
2365 */
2366#else
2367#error no saved-ids found
2368#endif
2369],[cf_cv_posix_saved_ids=yes
2370],[
2371AC_TRY_RUN([
2372$ac_includes_default
2373
2374int main(void)
2375{
2376	void *p = (void *) seteuid;
2377	long code = sysconf(_SC_SAVED_IDS);
2378	(void)p;
2379	${cf_cv_main_return:-return}  ((code > 0) ? 0 : 1);
2380}],
2381	cf_cv_posix_saved_ids=yes,
2382	cf_cv_posix_saved_ids=no,
2383	cf_cv_posix_saved_ids=unknown)
2384])
2385])
2386
2387test "$cf_cv_posix_saved_ids" = yes && AC_DEFINE(HAVE_POSIX_SAVED_IDS,1,[Define to 1 if POSIX saved-ids are supported])
2388])
2389dnl ---------------------------------------------------------------------------
2390dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
2391dnl ----------------
2392dnl POSIX documents test-macros which an application may set before any system
2393dnl headers are included to make features available.
2394dnl
2395dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
2396dnl diverged from POSIX in 2002 by setting symbols which make all of the most
2397dnl recent features visible in the system header files unless the application
2398dnl overrides the corresponding test-macros.  Doing that introduces portability
2399dnl problems.
2400dnl
2401dnl This macro makes a special check for the symbols used for this, to avoid a
2402dnl conflicting definition.
2403AC_DEFUN([CF_POSIX_VISIBLE],
2404[
2405AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
2406AC_TRY_COMPILE([#include <stdio.h>],[
2407#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
2408	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
2409	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
2410	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
2411#error conflicting symbols found
2412#endif
2413],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
2414])
2415])dnl
2416dnl ---------------------------------------------------------------------------
2417dnl CF_POSIX_WAIT version: 5 updated: 2023/01/05 19:26:07
2418dnl -------------
2419dnl Check for POSIX wait support
2420AC_DEFUN([CF_POSIX_WAIT],
2421[
2422AC_REQUIRE([AC_HEADER_SYS_WAIT])
2423AC_CACHE_CHECK(for POSIX wait functions,cf_cv_posix_wait,[
2424AC_TRY_LINK([
2425$ac_includes_default
2426
2427#ifdef HAVE_SYS_WAIT_H
2428#include <sys/wait.h>
2429#endif
2430],[
2431	int stat_loc;
2432	pid_t pid = waitpid(-1, &stat_loc, WNOHANG|WUNTRACED);
2433	pid_t pid2 = wait(&stat_loc);
2434	(void)pid;
2435	(void)pid2;
2436],
2437[cf_cv_posix_wait=yes],
2438[cf_cv_posix_wait=no])
2439])
2440test "$cf_cv_posix_wait" = yes && AC_DEFINE(USE_POSIX_WAIT,1,[Define to 1 if we have POSIX wait functions])
2441])dnl
2442dnl ---------------------------------------------------------------------------
2443dnl CF_PROCFS_CWD version: 4 updated: 2020/12/31 18:40:20
2444dnl -------------
2445dnl Find /proc tree (may be in a different place) which implements the "cwd"
2446dnl link.
2447AC_DEFUN([CF_PROCFS_CWD],[
2448AC_CACHE_CHECK(for proc tree with cwd-support,cf_cv_procfs_cwd,[
2449cf_cv_procfs_cwd=no
2450for cf_path in /proc /compat/linux/proc /usr/compat/linux/proc
2451do
2452	if test -d "$cf_path" && \
2453	   test -d "$cf_path"/$$ && \
2454	   { test -d "$cf_path"/$$/cwd || \
2455	     test -L "$cf_path"/$$/cwd; }; then
2456		cf_cv_procfs_cwd="$cf_path"
2457		break
2458	fi
2459done
2460])
2461])dnl
2462dnl ---------------------------------------------------------------------------
2463dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
2464dnl ----------
2465dnl standard check for CC, plus followup sanity checks
2466dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
2467AC_DEFUN([CF_PROG_CC],[
2468CF_ACVERSION_CHECK(2.53,
2469	[AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
2470	 AC_REQUIRE([AC_PROG_CC])],
2471	[])
2472ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
2473CF_GCC_VERSION
2474CF_ACVERSION_CHECK(2.52,
2475	[AC_PROG_CC_STDC],
2476	[CF_ANSI_CC_REQD])
2477CF_CC_ENV_FLAGS
2478])dnl
2479dnl ---------------------------------------------------------------------------
2480dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
2481dnl -------------
2482dnl Check if groff is available, for cases (such as html output) where nroff
2483dnl is not enough.
2484AC_DEFUN([CF_PROG_GROFF],[
2485AC_PATH_PROG(GROFF_PATH,groff,no)
2486AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
2487AC_PATH_PROG(TBL_PATH,tbl,cat)
2488if test "x$GROFF_PATH" = xno
2489then
2490	NROFF_NOTE=
2491	GROFF_NOTE="#"
2492else
2493	NROFF_NOTE="#"
2494	GROFF_NOTE=
2495fi
2496AC_SUBST(GROFF_NOTE)
2497AC_SUBST(NROFF_NOTE)
2498])dnl
2499dnl ---------------------------------------------------------------------------
2500dnl CF_PROG_LINT version: 7 updated: 2024/11/30 14:37:45
2501dnl ------------
2502AC_DEFUN([CF_PROG_LINT],
2503[
2504AC_CHECK_PROGS(LINT, lint cppcheck splint)
2505case "x$LINT" in
2506(xlint|x*/lint) # NetBSD 10
2507	test -z "$LINT_OPTS" && LINT_OPTS="-chapbrxzgFS -v -Ac11"
2508	;;
2509(xcppcheck|x*/cppcheck)
2510	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all -D__CPPCHECK__"
2511	;;
2512esac
2513AC_SUBST(LINT_OPTS)
2514AC_SUBST(LINT_LIBS)
2515])dnl
2516dnl ---------------------------------------------------------------------------
2517dnl CF_REGEX version: 19 updated: 2024/12/14 16:09:34
2518dnl --------
2519dnl Attempt to determine if we've got one of the flavors of regular-expression
2520dnl code that we can support.
2521AC_DEFUN([CF_REGEX],
2522[
2523
2524cf_regex_func=no
2525cf_regex_libs=
2526case "$host_os" in
2527(mingw*)
2528	# -lsystre -ltre -lintl -liconv
2529	AC_CHECK_LIB(systre,regcomp,[
2530		AC_CHECK_LIB(iconv,libiconv_open,[CF_ADD_LIB(iconv)])
2531		AC_CHECK_LIB(intl,libintl_gettext,[CF_ADD_LIB(intl)])
2532		AC_CHECK_LIB(tre,tre_regcomp,[CF_ADD_LIB(tre)])
2533		CF_ADD_LIB(systre)
2534		cf_regex_func=regcomp
2535	],[
2536		AC_CHECK_LIB(gnurx,regcomp,[
2537			CF_ADD_LIB(gnurx)
2538			cf_regex_func=regcomp])
2539	])
2540	;;
2541(*)
2542	cf_regex_libs="regex re"
2543	AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
2544		for cf_regex_lib in $cf_regex_libs
2545		do
2546			AC_CHECK_LIB($cf_regex_lib,regcomp,[
2547					CF_ADD_LIB($cf_regex_lib)
2548					cf_regex_func=regcomp
2549					break])
2550		done
2551	])
2552	;;
2553esac
2554
2555if test "$cf_regex_func" = no ; then
2556	AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
2557		AC_CHECK_LIB(gen,compile,[
2558				CF_ADD_LIB(gen)
2559				cf_regex_func=compile])])
2560fi
2561
2562if test "$cf_regex_func" = no ; then
2563	AC_MSG_WARN(cannot find regular expression library)
2564fi
2565
2566AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
2567
2568cf_cv_regex_hdrs=no
2569case "$cf_regex_func" in
2570(compile)
2571	for cf_regex_hdr in regexp.h regexpr.h
2572	do
2573		AC_TRY_LINK([#include <$cf_regex_hdr>],[
2574			char *p = compile("", "", "", 0);
2575			int x = step("", "");
2576			(void)p;
2577			(void)x;
2578		],[
2579			cf_cv_regex_hdrs=$cf_regex_hdr
2580			break
2581		])
2582	done
2583	;;
2584(*)
2585	for cf_regex_hdr in regex.h
2586	do
2587		AC_TRY_LINK([#include <sys/types.h>
2588#include <stdio.h>
2589#include <$cf_regex_hdr>],[
2590			regex_t *p = NULL;
2591			int x = regcomp(p, "", 0);
2592			int y = regexec(p, "", 0, 0, 0);
2593			(void)x;
2594			(void)y;
2595			regfree(p);
2596		],[
2597			cf_cv_regex_hdrs=$cf_regex_hdr
2598			break
2599		])
2600	done
2601	;;
2602esac
2603
2604])
2605
2606case "$cf_cv_regex_hdrs" in
2607	(no)		AC_MSG_WARN(no regular expression header found) ;;
2608	(regex.h)	AC_DEFINE(HAVE_REGEX_H_FUNCS,1,[Define to 1 to include regex.h for regular expressions]) ;;
2609	(regexp.h)	AC_DEFINE(HAVE_REGEXP_H_FUNCS,1,[Define to 1 to include regexp.h for regular expressions]) ;;
2610	(regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,1,[Define to 1 to include regexpr.h for regular expressions]) ;;
2611esac
2612])dnl
2613dnl ---------------------------------------------------------------------------
2614dnl CF_REMOVE_CFLAGS version: 3 updated: 2021/09/05 17:25:40
2615dnl ----------------
2616dnl Remove a given option from CFLAGS/CPPFLAGS
2617dnl $1 = option to remove
2618dnl $2 = variable to update
2619dnl $3 = nonempty to allow verbose message
2620define([CF_REMOVE_CFLAGS],
2621[
2622cf_tmp_cflag=`echo "x$1" | sed -e 's/^.//' -e 's/=.*//'`
2623while true
2624do
2625	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'`
2626	test "[$]$2" != "$cf_old_cflag" || break
2627	ifelse([$3],,,[CF_VERBOSE(removing old option $1 from $2)])
2628	$2="$cf_old_cflag"
2629done
2630])dnl
2631dnl ---------------------------------------------------------------------------
2632dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2633dnl ----------------
2634dnl Remove all -U and -D options that refer to the given symbol from a list
2635dnl of C compiler options.  This works around the problem that not all
2636dnl compilers process -U and -D options from left-to-right, so a -U option
2637dnl cannot be used to cancel the effect of a preceding -D option.
2638dnl
2639dnl $1 = target (which could be the same as the source variable)
2640dnl $2 = source (including '$')
2641dnl $3 = symbol to remove
2642define([CF_REMOVE_DEFINE],
2643[
2644$1=`echo "$2" | \
2645	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
2646		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
2647])dnl
2648dnl ---------------------------------------------------------------------------
2649dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
2650dnl ---------------------
2651dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
2652dnl $1 = name of current macro
2653define([CF_RESTORE_XTRA_FLAGS],
2654[
2655LIBS="$cf_save_LIBS_$1"
2656CFLAGS="$cf_save_CFLAGS_$1"
2657CPPFLAGS="$cf_save_CPPFLAGS_$1"
2658])dnl
2659dnl ---------------------------------------------------------------------------
2660dnl CF_RPATH_HACK version: 13 updated: 2021/01/03 18:30:50
2661dnl -------------
2662AC_DEFUN([CF_RPATH_HACK],
2663[AC_REQUIRE([AC_PROG_FGREP])dnl
2664AC_REQUIRE([CF_LD_RPATH_OPT])dnl
2665
2666AC_MSG_CHECKING(for updated LDFLAGS)
2667if test -n "$LD_RPATH_OPT" ; then
2668	AC_MSG_RESULT(maybe)
2669
2670	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2671	cf_rpath_list="/usr/lib /lib"
2672	if test "$cf_ldd_prog" != no
2673	then
2674		cf_rpath_oops=
2675
2676AC_TRY_LINK([#include <stdio.h>],
2677		[printf("Hello");],
2678		[cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2679		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2680
2681		# If we passed the link-test, but get a "not found" on a given library,
2682		# this could be due to inept reconfiguration of gcc to make it only
2683		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
2684		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
2685		# /usr/local libraries.
2686		if test -n "$cf_rpath_oops"
2687		then
2688			for cf_rpath_src in $cf_rpath_oops
2689			do
2690				for cf_rpath_dir in \
2691					/usr/local \
2692					/usr/pkg \
2693					/opt/sfw
2694				do
2695					if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
2696					then
2697						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2698						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2699						break
2700					fi
2701				done
2702			done
2703		fi
2704	fi
2705
2706	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2707
2708	CF_RPATH_HACK_2(LDFLAGS)
2709	CF_RPATH_HACK_2(LIBS)
2710
2711	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2712else
2713	AC_MSG_RESULT(no)
2714fi
2715AC_SUBST(EXTRA_LDFLAGS)
2716])dnl
2717dnl ---------------------------------------------------------------------------
2718dnl CF_RPATH_HACK_2 version: 8 updated: 2021/01/01 13:31:04
2719dnl ---------------
2720dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
2721dnl EXTRA_LDFLAGS for each -L option found.
2722dnl
2723dnl $cf_rpath_list contains a list of directories to ignore.
2724dnl
2725dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
2726dnl      but LIBS often has misplaced -L options.
2727AC_DEFUN([CF_RPATH_HACK_2],
2728[
2729CF_VERBOSE(...checking $1 [$]$1)
2730
2731cf_rpath_dst=
2732for cf_rpath_src in [$]$1
2733do
2734	case "$cf_rpath_src" in
2735	(-L*)
2736
2737		# check if this refers to a directory which we will ignore
2738		cf_rpath_skip=no
2739		if test -n "$cf_rpath_list"
2740		then
2741			for cf_rpath_item in $cf_rpath_list
2742			do
2743				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2744				then
2745					cf_rpath_skip=yes
2746					break
2747				fi
2748			done
2749		fi
2750
2751		if test "$cf_rpath_skip" = no
2752		then
2753			# transform the option
2754			if test "$LD_RPATH_OPT" = "-R " ; then
2755				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
2756			else
2757				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2758			fi
2759
2760			# if we have not already added this, add it now
2761			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
2762			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
2763			then
2764				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2765				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2766			fi
2767		fi
2768		;;
2769	esac
2770	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2771done
2772$1=$cf_rpath_dst
2773
2774CF_VERBOSE(...checked $1 [$]$1)
2775AC_SUBST(EXTRA_LDFLAGS)
2776])dnl
2777dnl ---------------------------------------------------------------------------
2778dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
2779dnl ------------------
2780dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
2781dnl and libraries which do not update those variables.
2782dnl
2783dnl $1 = name of current macro
2784define([CF_SAVE_XTRA_FLAGS],
2785[
2786cf_save_LIBS_$1="$LIBS"
2787cf_save_CFLAGS_$1="$CFLAGS"
2788cf_save_CPPFLAGS_$1="$CPPFLAGS"
2789LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
2790for cf_X_CFLAGS in $X_CFLAGS
2791do
2792	case "x$cf_X_CFLAGS" in
2793	x-[[IUD]]*)
2794		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
2795		;;
2796	*)
2797		CFLAGS="$CFLAGS $cf_X_CFLAGS"
2798		;;
2799	esac
2800done
2801])dnl
2802dnl ---------------------------------------------------------------------------
2803dnl CF_SETITIMER version: 1 updated: 2023/01/25 19:55:24
2804dnl ------------
2805AC_DEFUN([CF_SETITIMER],
2806[
2807AC_CACHE_CHECK(if setitimer is available,cf_cv_func_setitimer,[
2808AC_TRY_COMPILE([
2809$ac_includes_default
2810#include <sys/time.h>
2811],[
2812    struct itimerval it;
2813    memset(&it, 0, sizeof(struct itimerval));
2814    it.it_value.tv_sec = 1;
2815    setitimer(ITIMER_REAL, &it, NULL);
2816],
2817[cf_cv_func_setitimer=yes],
2818[cf_cv_func_setitimer=no])
2819])
2820test "$cf_cv_func_setitimer" != no && AC_DEFINE(HAVE_SETITIMER,1,[Define to 1 if setitimer is available])
2821])dnl
2822dnl ---------------------------------------------------------------------------
2823dnl CF_SIGWINCH version: 7 updated: 2023/02/18 17:41:25
2824dnl -----------
2825dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
2826dnl programs need this test).
2827dnl
2828dnl This is really a Mac OS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
2829dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
2830dnl winsize declaration is left alone - we may revisit this if Apple choose to
2831dnl break that part of the interface as well.
2832AC_DEFUN([CF_SIGWINCH],
2833[
2834AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
2835	AC_TRY_COMPILE([
2836#include <sys/types.h>
2837#include <sys/signal.h>
2838],[int x = SIGWINCH; (void)x],
2839	[cf_cv_define_sigwinch=yes],
2840	[AC_TRY_COMPILE([
2841#undef _XOPEN_SOURCE
2842#undef _POSIX_SOURCE
2843#undef _POSIX_C_SOURCE
2844#include <sys/types.h>
2845#include <sys/signal.h>
2846],[int x = SIGWINCH; (void)x],
2847	[cf_cv_define_sigwinch=maybe],
2848	[cf_cv_define_sigwinch=no])
2849])
2850])
2851
2852if test "$cf_cv_define_sigwinch" = maybe ; then
2853AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
2854cf_cv_fixup_sigwinch=unknown
2855cf_sigwinch=32
2856while test "$cf_sigwinch" != 1
2857do
2858	AC_TRY_COMPILE([
2859#undef _XOPEN_SOURCE
2860#undef _POSIX_SOURCE
2861#undef _POSIX_C_SOURCE
2862#include <sys/types.h>
2863#include <sys/signal.h>
2864],[
2865#if SIGWINCH != $cf_sigwinch
2866#error SIGWINCH is not $cf_sigwinch
2867#endif
2868int x = SIGWINCH; (void)x],
2869	[cf_cv_fixup_sigwinch=$cf_sigwinch
2870	 break])
2871
2872cf_sigwinch="`expr "$cf_sigwinch" - 1`"
2873done
2874])
2875
2876	if test "$cf_cv_fixup_sigwinch" != unknown ; then
2877		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
2878	fi
2879fi
2880])dnl
2881dnl ---------------------------------------------------------------------------
2882dnl CF_SIG_ATOMIC_T version: 5 updated: 2020/03/10 18:53:47
2883dnl ---------------
2884dnl signal handler, but there are some gcc dependencies in that recommendation.
2885dnl Try anyway.
2886AC_DEFUN([CF_SIG_ATOMIC_T],
2887[
2888AC_MSG_CHECKING(for signal global datatype)
2889AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2890	for cf_type in \
2891		"volatile sig_atomic_t" \
2892		"sig_atomic_t" \
2893		"int"
2894	do
2895	AC_TRY_COMPILE([
2896#include <sys/types.h>
2897#include <signal.h>
2898#include <stdio.h>
2899
2900extern $cf_type x;
2901$cf_type x;
2902static void handler(int sig)
2903{
2904	(void)sig;
2905	x = 5;
2906}],
2907		[signal(SIGINT, handler);
2908		 x = 1],
2909		[cf_cv_sig_atomic_t=$cf_type],
2910		[cf_cv_sig_atomic_t=no])
2911		test "$cf_cv_sig_atomic_t" != no && break
2912	done
2913	])
2914AC_MSG_RESULT($cf_cv_sig_atomic_t)
2915test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2916])dnl
2917dnl ---------------------------------------------------------------------------
2918dnl CF_STRUCT_LASTLOG version: 4 updated: 2023/01/05 17:56:31
2919dnl -----------------
2920dnl Check for header defining struct lastlog, ensure that its .ll_time member
2921dnl is compatible with time().
2922AC_DEFUN([CF_STRUCT_LASTLOG],
2923[
2924AC_CHECK_HEADERS(lastlog.h)
2925AC_CACHE_CHECK(for struct lastlog,cf_cv_struct_lastlog,[
2926AC_TRY_RUN([
2927$ac_includes_default
2928
2929#include <time.h>
2930#include <lastlog.h>
2931
2932int main(void)
2933{
2934	struct lastlog data;
2935	return (sizeof(data.ll_time) != sizeof(time_t));
2936}],[
2937cf_cv_struct_lastlog=yes],[
2938cf_cv_struct_lastlog=no],[
2939cf_cv_struct_lastlog=unknown])])
2940
2941test $cf_cv_struct_lastlog != no && AC_DEFINE(USE_STRUCT_LASTLOG,1,[Define to 1 if we have struct lastlog])
2942])dnl
2943dnl ---------------------------------------------------------------------------
2944dnl CF_SVR4 version: 6 updated: 2023/12/01 17:22:50
2945dnl -------
2946dnl Check if this is an SVR4 system.  We need the definition for xterm
2947AC_DEFUN([CF_SVR4],
2948[
2949AC_CHECK_LIB(elf, elf_begin,[
2950AC_CACHE_CHECK(if this is an SVR4 system, cf_cv_svr4,[
2951AC_TRY_COMPILE([
2952#if defined(__CYGWIN__)
2953#error Cygwin is not SVr4
2954#endif
2955#include <elf.h>
2956#include <sys/termio.h>
2957],[
2958static struct termio d_tio;
2959	d_tio.c_cc[VINTR] = 0;
2960	d_tio.c_cc[VQUIT] = 0;
2961	d_tio.c_cc[VERASE] = 0;
2962	d_tio.c_cc[VKILL] = 0;
2963	d_tio.c_cc[VEOF] = 0;
2964	d_tio.c_cc[VEOL] = 0;
2965	d_tio.c_cc[VMIN] = 0;
2966	d_tio.c_cc[VTIME] = 0;
2967	d_tio.c_cc[VLNEXT] = 0;
2968],
2969[cf_cv_svr4=yes],
2970[cf_cv_svr4=no])
2971])
2972])
2973test "$cf_cv_svr4" = yes && AC_DEFINE(SVR4,1,[Define to 1 if this is an SVR4 system])
2974])dnl
2975dnl ---------------------------------------------------------------------------
2976dnl CF_SYSV version: 16 updated: 2020/01/11 16:46:44
2977dnl -------
2978dnl Check if this is a SYSV platform, e.g., as used in <X11/Xos.h>, and whether
2979dnl defining it will be helpful.  The following features are used to check:
2980dnl
2981dnl a) bona-fide SVSV doesn't use const for sys_errlist[].  Since this is a
2982dnl legacy (pre-ANSI) feature, const should not apply.  Modern systems only
2983dnl declare strerror().  Xos.h declares the legacy form of str_errlist[], and
2984dnl a compile-time error will result from trying to assign to a const array.
2985dnl
2986dnl b) compile with headers that exist on SYSV hosts.
2987dnl
2988dnl c) compile with type definitions that differ on SYSV hosts from standard C.
2989AC_DEFUN([CF_SYSV],
2990[
2991AC_REQUIRE([AC_PATH_XTRA])
2992
2993CF_SAVE_XTRA_FLAGS([CF_SYSV])
2994
2995AC_CHECK_HEADERS( \
2996termios.h \
2997stdlib.h \
2998X11/Intrinsic.h \
2999)
3000
3001AC_REQUIRE([CF_SYS_ERRLIST])
3002
3003AC_CACHE_CHECK(if we should define SYSV,cf_cv_sysv,[
3004AC_TRY_COMPILE([
3005#undef  SYSV
3006#define SYSV 1			/* get Xos.h to declare sys_errlist[] */
3007#ifdef HAVE_STDLIB_H
3008#include <stdlib.h>		/* look for wchar_t */
3009#endif
3010#ifdef HAVE_X11_INTRINSIC_H
3011#include <X11/Intrinsic.h>	/* Intrinsic.h has other traps... */
3012#endif
3013#ifdef HAVE_TERMIOS_H		/* needed for HPUX 10.20 */
3014#include <termios.h>
3015#define STRUCT_TERMIOS struct termios
3016#else
3017#define STRUCT_TERMIOS struct termio
3018#endif
3019#include <curses.h>
3020#include <term.h>		/* eliminate most BSD hacks */
3021#include <errno.h>		/* declare sys_errlist on older systems */
3022#include <sys/termio.h>		/* eliminate most of the remaining ones */
3023],[
3024static STRUCT_TERMIOS d_tio;
3025	d_tio.c_cc[VINTR] = 0;
3026	d_tio.c_cc[VQUIT] = 0;
3027	d_tio.c_cc[VERASE] = 0;
3028	d_tio.c_cc[VKILL] = 0;
3029	d_tio.c_cc[VEOF] = 0;
3030	d_tio.c_cc[VEOL] = 0;
3031	d_tio.c_cc[VMIN] = 0;
3032	d_tio.c_cc[VTIME] = 0;
3033#if defined(HAVE_SYS_ERRLIST) && !defined(DECL_SYS_ERRLIST)
3034sys_errlist[0] = "";		/* Cygwin mis-declares this */
3035#endif
3036],
3037[cf_cv_sysv=yes],
3038[cf_cv_sysv=no])
3039])
3040test "$cf_cv_sysv" = yes && AC_DEFINE(SYSV,1,[Define to 1 if this is an SYSV system])
3041
3042CF_RESTORE_XTRA_FLAGS([CF_SYSV])
3043])dnl
3044dnl ---------------------------------------------------------------------------
3045dnl CF_SYSV_UTMP version: 7 updated: 2021/01/02 09:31:20
3046dnl ------------
3047dnl Check if this is a SYSV flavor of UTMP
3048AC_DEFUN([CF_SYSV_UTMP],
3049[
3050AC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
3051test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
3052AC_TRY_LINK([
3053#include <sys/types.h>
3054#include <${cf_cv_have_utmp}.h>],[
3055struct $cf_cv_have_utmp x;
3056	set${cf_prefix}ent ();
3057	get${cf_prefix}id(&x);
3058	put${cf_prefix}line(&x);
3059	end${cf_prefix}ent();],
3060	[cf_cv_sysv_utmp=yes],
3061	[cf_cv_sysv_utmp=no])
3062])
3063test "$cf_cv_sysv_utmp" = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
3064])dnl
3065dnl ---------------------------------------------------------------------------
3066dnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
3067dnl --------------
3068dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
3069dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
3070dnl declaration.  Reported by Keith Bostic.
3071AC_DEFUN([CF_SYS_ERRLIST],
3072[
3073    CF_CHECK_ERRNO(sys_nerr)
3074    CF_CHECK_ERRNO(sys_errlist)
3075])dnl
3076dnl ---------------------------------------------------------------------------
3077dnl CF_TERMIOS_TYPES version: 2 updated: 2020/03/10 18:53:47
3078dnl ----------------
3079dnl https://pubs.opengroup.org/onlinepubs/009695399/basedefs/termios.h.html
3080dnl says that tcflag_t, speed_t and cc_t are typedef'd.  If they are not,
3081dnl fallback to historical values.
3082AC_DEFUN([CF_TERMIOS_TYPES],[
3083
3084AC_CACHE_CHECK(for termios type tcflag_t, cf_cv_havetype_tcflag_t,[
3085	AC_TRY_COMPILE([#include <termios.h>],[
3086		tcflag_t x = 0; (void)x],
3087		[cf_cv_havetype_tcflag_t=yes],
3088		[cf_cv_havetype_tcflag_t=no])
3089])
3090test "$cf_cv_havetype_tcflag_t" = no && AC_DEFINE(tcflag_t,unsigned long,[Define usable value of tcflag_t if not declared])
3091
3092AC_CACHE_CHECK(for termios type speed_t, cf_cv_havetype_speed_t,[
3093	AC_TRY_COMPILE([#include <termios.h>],[
3094		speed_t x = 0; (void)x],
3095		[cf_cv_havetype_speed_t=yes],
3096		[cf_cv_havetype_speed_t=no])
3097])
3098test "$cf_cv_havetype_speed_t" = no && AC_DEFINE(speed_t,unsigned short,[Define usable value of speed_t if not declared])
3099
3100AC_CACHE_CHECK(for termios type cc_t, cf_cv_havetype_cc_t,[
3101	AC_TRY_COMPILE([#include <termios.h>],[
3102		cc_t x = 0; (void)x],
3103		[cf_cv_havetype_cc_t=yes],
3104		[cf_cv_havetype_cc_t=no])
3105])
3106test "$cf_cv_havetype_cc_t" = no && AC_DEFINE(cc_t,unsigned char,[Define usable value of cc_t if not declared])
3107])dnl
3108dnl ---------------------------------------------------------------------------
3109dnl CF_TERMIO_C_ISPEED version: 4 updated: 2020/03/10 18:53:47
3110dnl ------------------
3111dnl Check for SGI's broken redefinition of baud rates introduced in IRIX 6.5
3112dnl (there doesn't appear to be a useful predefined symbol).
3113AC_DEFUN([CF_TERMIO_C_ISPEED],
3114[
3115AC_CACHE_CHECK(for IRIX 6.5 baud-rate redefinitions,cf_cv_termio_c_ispeed,[
3116AC_TRY_COMPILE([
3117#include <sys/types.h>
3118#include <sys/termio.h>],[
3119struct termio foo;
3120foo.c_ispeed = B38400;
3121foo.c_ospeed = B9600;
3122(void)foo;
3123],[cf_cv_termio_c_ispeed=yes
3124],[cf_cv_termio_c_ispeed=no])
3125])
3126test "$cf_cv_termio_c_ispeed" = yes && AC_DEFINE(HAVE_TERMIO_C_ISPEED,1,[define 1 if we have IRIX 6.5 baud-rate redefinitions])
3127])dnl
3128dnl ---------------------------------------------------------------------------
3129dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
3130dnl --------------
3131dnl Trim extra base X libraries added as a workaround for inconsistent library
3132dnl dependencies returned by "new" pkg-config files.
3133AC_DEFUN([CF_TRIM_X_LIBS],[
3134	for cf_trim_lib in Xmu Xt X11
3135	do
3136		case "$LIBS" in
3137		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
3138			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
3139			CF_VERBOSE(..trimmed $LIBS)
3140			;;
3141		esac
3142	done
3143])
3144dnl ---------------------------------------------------------------------------
3145dnl CF_TRY_PKG_CONFIG version: 6 updated: 2020/12/31 10:54:15
3146dnl -----------------
3147dnl This is a simple wrapper to use for pkg-config, for libraries which may be
3148dnl available in that form.
3149dnl
3150dnl $1 = package name, which may be a shell variable
3151dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
3152dnl $3 = logic to use if pkg-config does not have the package
3153AC_DEFUN([CF_TRY_PKG_CONFIG],[
3154AC_REQUIRE([CF_PKG_CONFIG])
3155
3156if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$1"; then
3157	CF_VERBOSE(found package $1)
3158	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$1" 2>/dev/null`"
3159	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$1" 2>/dev/null`"
3160	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
3161	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
3162	CF_ADD_CFLAGS($cf_pkgconfig_incs)
3163	CF_ADD_LIBS($cf_pkgconfig_libs)
3164	ifelse([$2],,:,[$2])
3165else
3166	cf_pkgconfig_incs=
3167	cf_pkgconfig_libs=
3168	ifelse([$3],,:,[$3])
3169fi
3170])
3171dnl ---------------------------------------------------------------------------
3172dnl CF_TRY_XOPEN_SOURCE version: 4 updated: 2022/09/10 15:16:16
3173dnl -------------------
3174dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
3175dnl can define it successfully.
3176AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
3177AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3178	AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
3179	[cf_cv_xopen_source=no],
3180	[cf_save="$CPPFLAGS"
3181	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
3182	 AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,
3183		[cf_cv_xopen_source=no],
3184		[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3185		CPPFLAGS="$cf_save"
3186	])
3187])
3188
3189if test "$cf_cv_xopen_source" != no ; then
3190	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3191	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3192	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3193	CF_APPEND_CFLAGS($cf_temp_xopen_source)
3194fi
3195])
3196dnl ---------------------------------------------------------------------------
3197dnl CF_TTY_GROUP version: 17 updated: 2023/12/01 17:22:50
3198dnl ------------
3199dnl Check if the system has a tty-group defined.  This is used in xterm when
3200dnl setting pty ownership.
3201dnl
3202dnl The check relies upon running a test-program, which calls ttyname.  If this
3203dnl is run in batch mode, or if autoconf uses shell functions, the extra layer
3204dnl of eval/call may close stdin, making calls to ttyname fail.  To work around
3205dnl that, fall back to "/dev/tty".
3206AC_DEFUN([CF_TTY_GROUP],
3207[AC_REQUIRE([AC_PROG_EGREP])dnl
3208AC_MSG_CHECKING(for explicit tty group name)
3209AC_ARG_WITH(tty-group,
3210	[[  --with-tty-group[=XXX]  use XXX for the tty-group]],
3211	[cf_tty_group=$withval],
3212	[cf_tty_group=auto...])
3213test -z "$cf_tty_group"    && cf_tty_group=auto...
3214test "$cf_tty_group" = yes && cf_tty_group=auto...
3215AC_MSG_RESULT($cf_tty_group)
3216
3217if test "$cf_tty_group" = "auto..." ; then
3218AC_CACHE_CHECK(for tty group name,cf_cv_tty_group_name,[
3219
3220# If we are configuring as root, it is hard to get a clue about the tty group.
3221# But we'll guess based on how our connection is set up - assuming it is done
3222# properly.
3223
3224cf_uid="`id | sed -e 's/^[^=]*=//' -e 's/(.*$//'`"
3225# )vi
3226if test "$cf_uid" != 0 ; then
3227cf_cv_tty_group_name=
3228cf_tty_name="`tty`"
3229test "$cf_tty_name" = "not a tty" && cf_tty_name=/dev/tty
3230test -z "$cf_tty_name" && cf_tty_name=/dev/tty
3231if test -c "$cf_tty_name"
3232then
3233	cf_option="-lL"
3234
3235	# Expect listing to have fields like this:
3236	#-rwxrwxrwx   1 user      group       34293 Jul 18 16:29 pathname
3237	ls $cf_option "$cf_tty_name" >conftest.out
3238	read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
3239	if test -z "$cf_rest" ; then
3240		cf_option="${cf_option}g"
3241		ls "$cf_option" "$cf_tty_name" >conftest.out
3242		read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest.out
3243	fi
3244	rm -f conftest.out
3245	cf_cv_tty_group_name=$cf_grp
3246fi
3247fi
3248
3249# If we cannot deduce the tty group, fall back on hardcoded cases
3250
3251if test -z "$cf_cv_tty_group_name"
3252then
3253case $host_os in
3254(osf*)
3255	cf_cv_tty_group_name="terminal"
3256	;;
3257(*)
3258	cf_cv_tty_group_name="unknown"
3259	if ( ${EGREP-egrep} '^tty:' /etc/group 2>/dev/null 1>/dev/null ) then
3260		cf_cv_tty_group_name="tty"
3261	fi
3262	;;
3263esac
3264fi
3265])
3266cf_tty_group="$cf_cv_tty_group_name"
3267else
3268	# if configure option, always do this
3269	AC_DEFINE(USE_TTY_GROUP,1,[Define to 1 if we have a tty groupname])
3270fi
3271
3272AC_DEFINE_UNQUOTED(TTY_GROUP_NAME,"$cf_tty_group",[Define to the name use for tty group])
3273
3274# This is only a double-check that the group-name we obtained above really
3275# does apply to the device.  We cannot perform this test if we are in batch
3276# mode, or if we are cross-compiling.
3277
3278AC_CACHE_CHECK(if we may use the $cf_tty_group group,cf_cv_tty_group,[
3279cf_tty_name="`tty`"
3280if test "$cf_tty_name" != "not a tty"
3281then
3282AC_TRY_RUN([
3283$ac_includes_default
3284
3285#include <grp.h>
3286
3287int main(void)
3288{
3289	static char default_tty[] = "/dev/tty";
3290	struct stat sb;
3291	struct group *ttygrp;
3292	int fd;
3293	char *name;
3294
3295	for (fd = 0; fd < 3; ++fd) {
3296		if ((name = ttyname(fd)) != 0)
3297			break;
3298	}
3299	if (name == 0)
3300		name = default_tty;
3301
3302	ttygrp = getgrnam(TTY_GROUP_NAME);
3303	endgrent();
3304
3305	if (ttygrp != 0
3306	 && name != 0
3307	 && stat(name, &sb) == 0
3308	 && sb.st_gid != getgid()
3309	 && sb.st_gid == ttygrp->gr_gid) {
3310		${cf_cv_main_return:-return} (0);
3311	}
3312	${cf_cv_main_return:-return} (1);
3313}
3314	],
3315	[cf_cv_tty_group=yes],
3316	[cf_cv_tty_group=no],
3317	[cf_cv_tty_group=unknown])
3318elif test "$cross_compiling" = yes; then
3319	cf_cv_tty_group=unknown
3320else
3321	cf_cv_tty_group=yes
3322fi
3323])
3324
3325if test $cf_cv_tty_group = no ; then
3326	AC_MSG_WARN(Cannot use $cf_tty_group group)
3327else
3328	AC_DEFINE(USE_TTY_GROUP)
3329fi
3330])dnl
3331dnl ---------------------------------------------------------------------------
3332dnl CF_TYPE_CC_T version: 3 updated: 2020/03/10 18:53:47
3333dnl ------------
3334dnl	Check for cc_t type, used in termio.
3335AC_DEFUN([CF_TYPE_CC_T],
3336[
3337AC_MSG_CHECKING(for cc_t in <termios.h> or <termio.h>)
3338AC_CACHE_VAL(cf_cv_type_cc_t,[
3339	AC_TRY_COMPILE([
3340#include <sys/types.h>
3341#if defined(HAVE_TERMIOS_H)
3342#include <termios.h>
3343#else
3344#include <termio.h>
3345#include <sys/ioctl.h>
3346#endif
3347],
3348		[cc_t x; (void)x],
3349		[cf_cv_type_cc_t=yes],
3350		[cf_cv_type_cc_t=no])
3351	])
3352AC_MSG_RESULT($cf_cv_type_cc_t)
3353test $cf_cv_type_cc_t = no && AC_DEFINE(cc_t, unsigned char,[Define to cc_t type used in termio])
3354])dnl
3355dnl ---------------------------------------------------------------------------
3356dnl CF_TYPE_FD_MASK version: 3 updated: 2012/10/04 06:57:36
3357dnl ---------------
3358dnl Check for the declaration of fd_mask, which is like fd_set, associated
3359dnl with select().  The check for fd_set should have pulled in this as well,
3360dnl but there is a special case for Mac OS X, possibly other BSD-derived
3361dnl platforms.
3362AC_DEFUN([CF_TYPE_FD_MASK],
3363[
3364AC_REQUIRE([CF_TYPE_FD_SET])
3365
3366AC_CACHE_CHECK(for declaration of fd_mask,cf_cv_type_fd_mask,[
3367    if test x$cf_cv_type_fd_set = xX11/Xpoll.h ; then
3368        AC_TRY_COMPILE([
3369#include <X11/Xpoll.h>],[fd_mask x],,
3370        [CF_MSG_LOG(if we must define CSRG_BASED)
3371# Xosdefs.h on Mac OS X may not define this (but it should).
3372            AC_TRY_COMPILE([
3373#define CSRG_BASED
3374#include <X11/Xpoll.h>],[fd_mask x],
3375        cf_cv_type_fd_mask=CSRG_BASED)])
3376    else
3377        cf_cv_type_fd_mask=$cf_cv_type_fd_set
3378    fi
3379])
3380if test x$cf_cv_type_fd_mask = xCSRG_BASED ; then
3381    AC_DEFINE(CSRG_BASED,1,[Define to 1 if needed for declaring fd_mask()])
3382fi
3383])dnl
3384dnl ---------------------------------------------------------------------------
3385dnl CF_TYPE_FD_SET version: 6 updated: 2020/03/10 18:53:47
3386dnl --------------
3387dnl Check for the declaration of fd_set.  Some platforms declare it in
3388dnl <sys/types.h>, and some in <sys/select.h>, which requires <sys/types.h>.
3389dnl Finally, if we are using this for an X application, Xpoll.h may include
3390dnl <sys/select.h>, so we don't want to do it twice.
3391AC_DEFUN([CF_TYPE_FD_SET],
3392[
3393AC_CHECK_HEADERS(X11/Xpoll.h)
3394
3395AC_CACHE_CHECK(for declaration of fd_set,cf_cv_type_fd_set,
3396	[CF_MSG_LOG(sys/types alone)
3397AC_TRY_COMPILE([
3398#include <sys/types.h>],
3399	[fd_set x; (void)x],
3400	[cf_cv_type_fd_set=sys/types.h],
3401	[CF_MSG_LOG(X11/Xpoll.h)
3402AC_TRY_COMPILE([
3403#ifdef HAVE_X11_XPOLL_H
3404#include <X11/Xpoll.h>
3405#endif],
3406	[fd_set x; (void)x],
3407	[cf_cv_type_fd_set=X11/Xpoll.h],
3408	[CF_MSG_LOG(sys/select.h)
3409AC_TRY_COMPILE([
3410#include <sys/types.h>
3411#include <sys/select.h>],
3412	[fd_set x; (void)x],
3413	[cf_cv_type_fd_set=sys/select.h],
3414	[cf_cv_type_fd_set=unknown])])])])
3415if test $cf_cv_type_fd_set = sys/select.h ; then
3416	AC_DEFINE(USE_SYS_SELECT_H,1,[Define to 1 to include sys/select.h to declare fd_set])
3417fi
3418])
3419dnl ---------------------------------------------------------------------------
3420dnl CF_TYPE_NFDS_T version: 1 updated: 2023/02/26 20:20:10
3421dnl --------------
3422dnl Check for nfds_t type, used in poll.
3423AC_DEFUN([CF_TYPE_NFDS_T],
3424[
3425AC_MSG_CHECKING(for nfds_t in <poll.h>)
3426AC_CACHE_VAL(cf_cv_type_nfds_t,[
3427	AC_TRY_COMPILE([
3428$ac_includes_default
3429#include <poll.h>
3430],
3431		[nfds_t x; (void)x],
3432		[cf_cv_type_nfds_t=yes],
3433		[cf_cv_type_nfds_t=no])
3434	])
3435AC_MSG_RESULT($cf_cv_type_nfds_t)
3436test $cf_cv_type_nfds_t = no && AC_DEFINE(nfds_t, unsigned,[Define to nfds_t type used in poll])
3437])dnl
3438dnl ---------------------------------------------------------------------------
3439dnl CF_UNDO_CFLAGS version: 1 updated: 2011/07/02 09:27:51
3440dnl --------------
3441dnl Remove flags from $CFLAGS or similar shell variable using sed.
3442dnl $1 = variable
3443dnl $2 = message
3444dnl $3 = pattern to remove
3445AC_DEFUN([CF_UNDO_CFLAGS],
3446[
3447	CF_VERBOSE(removing $2 flags from $1)
3448	$1=`echo "[$]$1" | sed -e 's/$3//'`
3449	CF_VERBOSE(...result [$]$1)
3450])dnl
3451dnl ---------------------------------------------------------------------------
3452dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3453dnl --------
3454dnl Make an uppercase version of a variable
3455dnl $1=uppercase($2)
3456AC_DEFUN([CF_UPPER],
3457[
3458$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3459])dnl
3460dnl ---------------------------------------------------------------------------
3461dnl CF_UTEMPTER version: 4 updated: 2012/10/04 20:12:20
3462dnl -----------
3463dnl Try to link with utempter library
3464AC_DEFUN([CF_UTEMPTER],
3465[
3466AC_CACHE_CHECK(if we can link with utempter library,cf_cv_have_utempter,[
3467cf_save_LIBS="$LIBS"
3468CF_ADD_LIB(utempter)
3469AC_TRY_LINK([
3470#include <utempter.h>
3471],[
3472	addToUtmp("/dev/tty", 0, 1);
3473	removeFromUtmp();
3474],[
3475	cf_cv_have_utempter=yes],[
3476	cf_cv_have_utempter=no])
3477LIBS="$cf_save_LIBS"
3478])
3479if test "$cf_cv_have_utempter" = yes ; then
3480	AC_DEFINE(USE_UTEMPTER,1,[Define to 1 if we can/should link with utempter])
3481	CF_ADD_LIB(utempter)
3482fi
3483])dnl
3484dnl ---------------------------------------------------------------------------
3485dnl CF_UTMP version: 12 updated: 2021/01/02 09:31:20
3486dnl -------
3487dnl Check for UTMP/UTMPX headers
3488AC_DEFUN([CF_UTMP],
3489[
3490AC_REQUIRE([CF_LASTLOG])
3491
3492AC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
3493	cf_cv_have_utmp=no
3494for cf_header in utmpx utmp ; do
3495cf_utmp_includes="
3496#include <sys/types.h>
3497#include <${cf_header}.h>
3498#define getutent getutxent
3499#ifdef USE_LASTLOG
3500#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
3501#endif
3502"
3503	AC_TRY_COMPILE([$cf_utmp_includes],
3504	[struct $cf_header x;
3505	 char *name = x.ut_name; /* utmp.h and compatible definitions */
3506	 (void)x;
3507	 (void)name;
3508	],
3509	[cf_cv_have_utmp=$cf_header
3510	 break],
3511	[
3512	AC_TRY_COMPILE([$cf_utmp_includes],
3513	[struct $cf_header x;
3514	 char *name = x.ut_user; /* utmpx.h must declare this */
3515	 (void)x;
3516	 (void)name;
3517	],
3518	[cf_cv_have_utmp=$cf_header
3519	 break
3520	])])
3521done
3522])
3523
3524if test "$cf_cv_have_utmp" != no ; then
3525	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
3526	test "$cf_cv_have_utmp" = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
3527	CF_UTMP_UT_HOST
3528	CF_UTMP_UT_SYSLEN
3529	CF_UTMP_UT_NAME
3530	CF_UTMP_UT_XSTATUS
3531	CF_UTMP_UT_XTIME
3532	CF_UTMP_UT_SESSION
3533	CF_SYSV_UTMP
3534fi
3535])dnl
3536dnl ---------------------------------------------------------------------------
3537dnl CF_UTMP_GROUP version: 2 updated: 2020/12/31 10:54:15
3538dnl -------------
3539dnl Find the utmp/utmpx file and determine its group to allow setgid programs
3540dnl to manipulate it, e.g., when there is no intermediary.
3541AC_DEFUN([CF_UTMP_GROUP],[
3542AC_REQUIRE([CF_UTMP])
3543if test $cf_cv_have_utmp != no ; then
3544AC_CACHE_CHECK(for utmp/utmpx group,cf_cv_utmp_group,[
3545for cf_utmp_path in /var/adm /var/run
3546do
3547	for cf_utmp_file in utmpx utmp
3548	do
3549		if test -f $cf_utmp_path/$cf_utmp_file
3550		then
3551			cf_cv_utmp_group=root
3552
3553			cf_option="-lL"
3554
3555			# Expect listing to have fields like this:
3556			#-r--r--r--   1 user      group       34293 Jul 18 16:29 pathname
3557			ls "$cf_option" "$cf_utmp_path/$cf_utmp_file" >conftest
3558			read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
3559			if test -z "$cf_rest" ; then
3560				cf_option="${cf_option}g"
3561				ls "$cf_option" "$cf_utmp_path/$cf_utmp_file" >conftest
3562				read cf_mode cf_links cf_usr cf_grp cf_size cf_date1 cf_date2 cf_date3 cf_rest <conftest
3563			fi
3564			rm -f conftest
3565
3566			# If we have a pathname, and the date fields look right, assume we've
3567			# captured the group as well.
3568			if test -n "$cf_rest" ; then
3569				cf_test=`echo "${cf_date2}${cf_date3}" | sed -e 's/[[0-9:]]//g'`
3570				if test -z "$cf_test" ; then
3571					cf_cv_utmp_group=$cf_grp;
3572				fi
3573			fi
3574			break
3575		fi
3576	done
3577	test -n "$cf_cv_utmp_group" && break
3578done
3579])
3580else
3581	AC_MSG_ERROR(cannot find utmp group)
3582fi
3583])dnl
3584dnl ---------------------------------------------------------------------------
3585dnl CF_UTMP_UT_HOST version: 10 updated: 2021/01/02 09:31:20
3586dnl ---------------
3587dnl Check if UTMP/UTMPX struct defines ut_host member
3588AC_DEFUN([CF_UTMP_UT_HOST],
3589[
3590if test "$cf_cv_have_utmp" != no ; then
3591AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
3592AC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
3593	AC_TRY_COMPILE([
3594#include <sys/types.h>
3595#include <${cf_cv_have_utmp}.h>],
3596	[struct $cf_cv_have_utmp x;
3597	 char *y = &x.ut_host[0];
3598	 (void)x;
3599	 (void)y],
3600	[cf_cv_have_utmp_ut_host=yes],
3601	[cf_cv_have_utmp_ut_host=no])
3602	])
3603AC_MSG_RESULT($cf_cv_have_utmp_ut_host)
3604test "$cf_cv_have_utmp_ut_host" != no && AC_DEFINE(HAVE_UTMP_UT_HOST,1,[Define to 1 if UTMP/UTMPX struct defines ut_host member])
3605fi
3606])dnl
3607dnl ---------------------------------------------------------------------------
3608dnl CF_UTMP_UT_NAME version: 8 updated: 2021/01/02 09:31:20
3609dnl ---------------
3610dnl Check if UTMP/UTMPX struct defines ut_name member
3611AC_DEFUN([CF_UTMP_UT_NAME],
3612[
3613if test "$cf_cv_have_utmp" != no ; then
3614AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
3615	cf_cv_have_utmp_ut_name=no
3616cf_utmp_includes="
3617#include <sys/types.h>
3618#include <${cf_cv_have_utmp}.h>
3619#define getutent getutxent
3620#ifdef USE_LASTLOG
3621#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
3622#endif
3623"
3624for cf_header in ut_name ut_user ; do
3625	AC_TRY_COMPILE([$cf_utmp_includes],
3626	[struct $cf_cv_have_utmp x;
3627	 char *name = x.$cf_header;
3628	 (void)x;
3629	 (void)name;
3630	],
3631	[cf_cv_have_utmp_ut_name=$cf_header
3632	 break])
3633done
3634])
3635
3636case "$cf_cv_have_utmp_ut_name" in
3637(no)
3638	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
3639	;;
3640(ut_user)
3641	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
3642	;;
3643esac
3644fi
3645])dnl
3646dnl ---------------------------------------------------------------------------
3647dnl CF_UTMP_UT_SESSION version: 9 updated: 2021/06/07 17:39:17
3648dnl ------------------
3649dnl Check if UTMP/UTMPX struct defines ut_session member
3650AC_DEFUN([CF_UTMP_UT_SESSION],
3651[
3652if test "$cf_cv_have_utmp" != no ; then
3653AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
3654	AC_TRY_COMPILE([
3655#include <sys/types.h>
3656#include <${cf_cv_have_utmp}.h>],
3657	[static struct $cf_cv_have_utmp x;
3658	 long y = x.ut_session;
3659	 (void)x;
3660	 (void)y],
3661	[cf_cv_have_utmp_ut_session=yes],
3662	[cf_cv_have_utmp_ut_session=no])
3663])
3664if test "$cf_cv_have_utmp_ut_session" != no ; then
3665	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
3666fi
3667fi
3668])dnl
3669dnl ---------------------------------------------------------------------------
3670dnl CF_UTMP_UT_SYSLEN version: 4 updated: 2021/01/02 09:31:20
3671dnl -----------------
3672dnl Check if UTMP/UTMPX struct defines ut_syslen member
3673AC_DEFUN([CF_UTMP_UT_SYSLEN],
3674[
3675if test "$cf_cv_have_utmp" != no ; then
3676AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
3677AC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
3678	AC_TRY_COMPILE([
3679#include <sys/types.h>
3680#include <${cf_cv_have_utmp}.h>],
3681	[struct $cf_cv_have_utmp x;
3682	 int y = x.ut_syslen;
3683	 (void)x;
3684	 (void)y],
3685	[cf_cv_have_utmp_ut_syslen=yes],
3686	[cf_cv_have_utmp_ut_syslen=no])
3687	])
3688AC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
3689test "$cf_cv_have_utmp_ut_syslen" != no && AC_DEFINE(HAVE_UTMP_UT_SYSLEN,1,[Define to 1 if UTMP/UTMPX struct defines ut_syslen member])
3690fi
3691])dnl
3692dnl ---------------------------------------------------------------------------
3693dnl CF_UTMP_UT_XSTATUS version: 6 updated: 2021/01/02 09:31:20
3694dnl ------------------
3695dnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
3696dnl by various people:
3697dnl
3698dnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
3699dnl	ut_exit.e_exit (SVR4)
3700dnl	ut_exit.ut_e_exit (os390 - Greg Smith)
3701dnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
3702dnl
3703dnl Note: utmp_xstatus is not a conventional compatibility definition in the
3704dnl system header files.
3705AC_DEFUN([CF_UTMP_UT_XSTATUS],
3706[
3707if test "$cf_cv_have_utmp" != no ; then
3708AC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
3709for cf_result in \
3710	ut_exit.__e_exit \
3711	ut_exit.e_exit \
3712	ut_exit.ut_e_exit \
3713	ut_exit.ut_exit
3714do
3715AC_TRY_COMPILE([
3716#include <sys/types.h>
3717#include <${cf_cv_have_utmp}.h>],
3718	[struct $cf_cv_have_utmp x;
3719	 long y = x.$cf_result = 0;
3720	 (void)x;
3721	 (void)y],
3722	[cf_cv_have_utmp_ut_xstatus=$cf_result
3723	 break],
3724	[cf_cv_have_utmp_ut_xstatus=no])
3725done
3726])
3727if test "$cf_cv_have_utmp_ut_xstatus" != no ; then
3728	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
3729	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
3730fi
3731fi
3732])dnl
3733dnl ---------------------------------------------------------------------------
3734dnl CF_UTMP_UT_XTIME version: 11 updated: 2021/01/02 09:31:20
3735dnl ----------------
3736dnl Check if UTMP/UTMPX struct defines ut_xtime member
3737AC_DEFUN([CF_UTMP_UT_XTIME],
3738[
3739if test "$cf_cv_have_utmp" != no ; then
3740AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
3741	AC_TRY_COMPILE([
3742#include <sys/types.h>
3743#include <${cf_cv_have_utmp}.h>],
3744	[struct $cf_cv_have_utmp x;
3745	 long y = x.ut_xtime = 0;
3746	 (void)x;
3747	 (void)y],
3748	[cf_cv_have_utmp_ut_xtime=yes],
3749	[AC_TRY_COMPILE([
3750#include <sys/types.h>
3751#include <${cf_cv_have_utmp}.h>],
3752	[struct $cf_cv_have_utmp x;
3753	 long y = x.ut_tv.tv_sec;
3754	 (void)x;
3755	 (void)y],
3756	[cf_cv_have_utmp_ut_xtime=define],
3757	[cf_cv_have_utmp_ut_xtime=no])
3758	])
3759])
3760if test "$cf_cv_have_utmp_ut_xtime" != no ; then
3761	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
3762	if test "$cf_cv_have_utmp_ut_xtime" = define ; then
3763		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
3764	fi
3765fi
3766fi
3767])dnl
3768dnl ---------------------------------------------------------------------------
3769dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3770dnl ----------
3771dnl Use AC_VERBOSE w/o the warnings
3772AC_DEFUN([CF_VERBOSE],
3773[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
3774CF_MSG_LOG([$1])
3775])dnl
3776dnl ---------------------------------------------------------------------------
3777dnl CF_WITH_APP_CLASS version: 3 updated: 2015/04/12 15:39:00
3778dnl -----------------
3779dnl Handle configure option "--with-app-class", setting the $APP_CLASS
3780dnl variable, used for X resources.
3781dnl
3782dnl $1 = default value.
3783AC_DEFUN([CF_WITH_APP_CLASS],[
3784AC_MSG_CHECKING(for X applications class)
3785AC_ARG_WITH(app-class,
3786	[  --with-app-class=XXX    override X applications class (default $1)],
3787	[APP_CLASS=$withval],
3788	[APP_CLASS=$1])
3789
3790case x$APP_CLASS in
3791(*[[/@,%]]*)
3792	AC_MSG_WARN(X applications class cannot contain punctuation)
3793	APP_CLASS=$1
3794	;;
3795(x[[A-Z]]*)
3796	;;
3797(*)
3798	AC_MSG_WARN([X applications class must start with capital, ignoring $APP_CLASS])
3799	APP_CLASS=$1
3800	;;
3801esac
3802
3803AC_MSG_RESULT($APP_CLASS)
3804
3805AC_SUBST(APP_CLASS)
3806])dnl
3807dnl ---------------------------------------------------------------------------
3808dnl CF_WITH_APP_DEFAULTS version: 6 updated: 2015/01/02 09:05:50
3809dnl --------------------
3810dnl Handle configure option "--with-app-defaults", setting these shell
3811dnl variables:
3812dnl
3813dnl $APPSDIR is the option value, used for installing app-defaults files.
3814dnl $no_appsdir is a "#" (comment) if "--without-app-defaults" is given.
3815dnl
3816dnl Most Linux's use this:
3817dnl 	/usr/share/X11/app-defaults
3818dnl Debian uses this:
3819dnl 	/etc/X11/app-defaults
3820dnl DragonFlyBSD ports uses this:
3821dnl 	/usr/pkg/lib/X11/app-defaults
3822dnl FreeBSD ports use these:
3823dnl 	/usr/local/lib/X11/app-defaults
3824dnl 	/usr/local/share/X11/app-defaults
3825dnl Mandriva has these:
3826dnl 	/usr/lib/X11/app-defaults
3827dnl 	/usr/lib64/X11/app-defaults
3828dnl NetBSD has these
3829dnl 	/usr/X11R7/lib/X11/app-defaults
3830dnl OpenSolaris uses
3831dnl 	32-bit:
3832dnl 	/usr/X11/etc/X11/app-defaults
3833dnl 	/usr/X11/share/X11/app-defaults
3834dnl 	/usr/X11/lib/X11/app-defaults
3835dnl OSX uses
3836dnl		/opt/local/share/X11/app-defaults (MacPorts)
3837dnl		/opt/X11/share/X11/app-defaults (non-ports)
3838dnl	64-bit:
3839dnl 	/usr/X11/etc/X11/app-defaults
3840dnl 	/usr/X11/share/X11/app-defaults (I mkdir'd this)
3841dnl 	/usr/X11/lib/amd64/X11/app-defaults
3842dnl Solaris10 uses (in this order):
3843dnl 	/usr/openwin/lib/X11/app-defaults
3844dnl 	/usr/X11/lib/X11/app-defaults
3845AC_DEFUN([CF_WITH_APP_DEFAULTS],[
3846AC_MSG_CHECKING(for directory to install resource files)
3847AC_ARG_WITH(app-defaults,
3848	[  --with-app-defaults=DIR directory in which to install resource files (EPREFIX/lib/X11/app-defaults)],
3849	[APPSDIR=$withval],
3850	[APPSDIR='${exec_prefix}/lib/X11/app-defaults'])
3851
3852if test "x[$]APPSDIR" = xauto
3853then
3854	APPSDIR='${exec_prefix}/lib/X11/app-defaults'
3855	for cf_path in \
3856		/opt/local/share/X11/app-defaults \
3857		/opt/X11/share/X11/app-defaults \
3858		/usr/share/X11/app-defaults \
3859		/usr/X11/share/X11/app-defaults \
3860		/usr/X11/lib/X11/app-defaults \
3861		/usr/lib/X11/app-defaults \
3862		/etc/X11/app-defaults \
3863		/usr/pkg/lib/X11/app-defaults \
3864		/usr/X11R7/lib/X11/app-defaults \
3865		/usr/X11R6/lib/X11/app-defaults \
3866		/usr/X11R5/lib/X11/app-defaults \
3867		/usr/X11R4/lib/X11/app-defaults \
3868		/usr/local/lib/X11/app-defaults \
3869		/usr/local/share/X11/app-defaults \
3870		/usr/lib64/X11/app-defaults
3871	do
3872		if test -d "$cf_path" ; then
3873			APPSDIR="$cf_path"
3874			break
3875		fi
3876	done
3877else
3878	cf_path=$APPSDIR
3879	CF_PATH_SYNTAX(cf_path)
3880fi
3881
3882AC_MSG_RESULT($APPSDIR)
3883AC_SUBST(APPSDIR)
3884
3885no_appsdir=
3886if test "$APPSDIR" = no
3887then
3888	no_appsdir="#"
3889else
3890	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(APPSDIR)"
3891fi
3892AC_SUBST(no_appsdir)
3893])dnl
3894dnl ---------------------------------------------------------------------------
3895dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3896dnl ----------------
3897dnl Configure-option for dbmalloc.  The optional parameter is used to override
3898dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3899AC_DEFUN([CF_WITH_DBMALLOC],[
3900CF_NO_LEAKS_OPTION(dbmalloc,
3901	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3902	[USE_DBMALLOC])
3903
3904if test "$with_dbmalloc" = yes ; then
3905	AC_CHECK_HEADER(dbmalloc.h,
3906		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3907fi
3908])dnl
3909dnl ---------------------------------------------------------------------------
3910dnl CF_WITH_DESKTOP_CATEGORY version: 10 updated: 2023/12/02 06:55:40
3911dnl ------------------------
3912dnl Taking into account the absence of standardization of desktop categories
3913dnl take a look to see whether other applications on the current system are
3914dnl assigned any/all of a set of suggested categories.
3915dnl
3916dnl $1 = program name
3917dnl $2 = case-pattern to match comparable desktop files to obtain category
3918dnl      This pattern may contain wildcards.
3919dnl $3 = suggested categories, also a case-pattern but without wildcards,
3920dnl      since it doubles as a default value for a shell case-statement.
3921dnl $4 = categories to use if no match is found on the build-machine for the
3922dnl      --with-desktop-category "auto" setting.
3923dnl
3924dnl The macro tells the configure script to substitute the $DESKTOP_CATEGORY
3925dnl value.
3926AC_DEFUN([CF_WITH_DESKTOP_CATEGORY],[
3927AC_REQUIRE([AC_PROG_EGREP])dnl
3928AC_REQUIRE([CF_DISABLE_DESKTOP])dnl
3929if test -z "$desktop_utils"
3930then
3931	AC_MSG_CHECKING(for requested desktop-category)
3932	AC_ARG_WITH(desktop-category,
3933		[  --with-desktop-category=XXX  one or more desktop categories or auto],
3934		[cf_desktop_want=$withval],
3935		[cf_desktop_want=auto])
3936	AC_MSG_RESULT($cf_desktop_want)
3937
3938	if test "$cf_desktop_want" = auto
3939	then
3940		rm -rf conftest*
3941		cf_desktop_also=
3942		for cf_desktop_dir in  \
3943			/usr/share/app-install \
3944			/usr/share/applications
3945		do
3946			if test -d $cf_desktop_dir
3947			then
3948				find $cf_desktop_dir -name '*.desktop' | \
3949				while true
3950				do
3951					read cf_desktop_path
3952					test -z "$cf_desktop_path" && break
3953					cf_desktop_name=`basename "$cf_desktop_path" .desktop`
3954					case $cf_desktop_name in
3955					($1|*-$1|$2)
3956						CF_VERBOSE(inspect $cf_desktop_path)
3957						${EGREP-egrep} '^Categories=' "$cf_desktop_path" | \
3958							tr ';' '\n' | \
3959							sed -e 's%^.*=%%' -e '/^$/d' >>conftest.1
3960						;;
3961					esac
3962				done
3963			fi
3964		done
3965		if test -s conftest.1
3966		then
3967			cf_desktop_last=
3968			sort conftest.1 | \
3969			while true
3970			do
3971				read cf_desktop_this
3972				test -z "$cf_desktop_this" && break
3973				if test -s conftest.2
3974				then
3975					grep -w "$cf_desktop_this" conftest.2 >/dev/null && continue
3976				elif test -s conftest.3
3977				then
3978					grep -w "$cf_desktop_this" conftest.3 >/dev/null && continue
3979				fi
3980				case "$cf_desktop_this" in
3981				(-*)
3982					;;
3983				(Qt*|*Xfce*|*[[ABCDEFGHIJKLMNOPQRSTUVWXYZ]][[ABCDEFGHIJKLMNOPQRSTUVWXYZ]]*)
3984					CF_VERBOSE(ignored $cf_desktop_this)
3985					echo "$cf_desktop_this" >> conftest.3
3986					;;
3987				($3)
3988					CF_VERBOSE(applied $cf_desktop_this)
3989					test "x$cf_desktop_last" != "x$cf_desktop_this" && echo "$cf_desktop_this" >>conftest.2
3990					;;
3991				esac
3992				cf_desktop_last=$cf_desktop_this
3993			done
3994			cf_desktop_want="`tr '\n' ';' < conftest.2`"
3995		fi
3996		if test -n "$cf_desktop_want"
3997		then
3998			if test "$cf_desktop_want" = auto
3999			then
4000				cf_desktop_want=
4001			else
4002				# do a sanity check on the semicolon-separated list, ignore on failure
4003				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/[[^;]]//g'`
4004				test -z "$cf_desktop_test" && cf_desktop_want=
4005				cf_desktop_test=`echo "$cf_desktop_want" | sed -e 's/^.*;$/./g'`
4006				test -z "$cf_desktop_test" && cf_desktop_want=
4007			fi
4008		fi
4009		if test -z "$cf_desktop_want"
4010		then
4011			cf_desktop_want="ifelse([$4],,ifelse([$3],,[Application;],[`echo "$3" | sed -e 's/\*//g' -e 's/|/;/g' -e 's/[[;]]*$/;/g'`]),[$4])"
4012			CF_VERBOSE(no usable value found for desktop category, using $cf_desktop_want)
4013		fi
4014	fi
4015	DESKTOP_CATEGORY=`echo "$cf_desktop_want" | sed -e 's/[[ ,]]/;/g'`
4016	CF_VERBOSE(will use Categories=$DESKTOP_CATEGORY)
4017	AC_SUBST(DESKTOP_CATEGORY)
4018fi
4019])
4020dnl ---------------------------------------------------------------------------
4021dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
4022dnl ---------------
4023dnl Configure-option for dmalloc.  The optional parameter is used to override
4024dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
4025AC_DEFUN([CF_WITH_DMALLOC],[
4026CF_NO_LEAKS_OPTION(dmalloc,
4027	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
4028	[USE_DMALLOC])
4029
4030if test "$with_dmalloc" = yes ; then
4031	AC_CHECK_HEADER(dmalloc.h,
4032		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
4033fi
4034])dnl
4035dnl ---------------------------------------------------------------------------
4036dnl CF_WITH_ICONDIR version: 5 updated: 2012/07/22 09:18:02
4037dnl ---------------
4038dnl Handle configure option "--with-icondir", setting these shell variables:
4039dnl
4040dnl $ICONDIR is the option value, used for installing icon files.
4041dnl $no_icondir is a "#" (comment) if "--without-icondir" is given.
4042AC_DEFUN([CF_WITH_ICONDIR],[
4043AC_MSG_CHECKING(for directory to install icons)
4044AC_ARG_WITH(icondir,
4045	[  --with-icondir=DIR      directory in which to install icons for desktop],
4046	[ICONDIR=$withval],
4047	[test -z "$ICONDIR" && ICONDIR=no])
4048
4049if test "x[$]ICONDIR" = xauto
4050then
4051	ICONDIR='${datadir}/icons'
4052	for cf_path in \
4053		/usr/share/icons \
4054		/usr/X11R6/share/icons
4055	do
4056		if test -d "$cf_path" ; then
4057			ICONDIR="$cf_path"
4058			break
4059		fi
4060	done
4061else
4062	cf_path=$ICONDIR
4063	CF_PATH_SYNTAX(cf_path)
4064fi
4065AC_MSG_RESULT($ICONDIR)
4066AC_SUBST(ICONDIR)
4067
4068no_icondir=
4069if test "$ICONDIR" = no
4070then
4071	no_icondir="#"
4072else
4073	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(ICONDIR)"
4074fi
4075AC_SUBST(no_icondir)
4076])dnl
4077dnl ---------------------------------------------------------------------------
4078dnl CF_WITH_ICON_NAME version: 4 updated: 2023/11/23 06:40:35
4079dnl -----------------
4080dnl Allow a default icon-name to be overridden.
4081dnl $1 = default icon name
4082AC_DEFUN([CF_WITH_ICON_NAME],[
4083AC_MSG_CHECKING(for the icon name)
4084AC_ARG_WITH(icon-name,
4085	[[  --with-icon-name[=XXX]  override icon name (default: $1)]],
4086	[ICON_NAME="$withval"],
4087	[ICON_NAME=$1])
4088case "x$ICON_NAME" in
4089(xyes|xno|x)
4090	ICON_NAME=$1
4091	;;
4092esac
4093AC_SUBST(ICON_NAME)
4094AC_MSG_RESULT($ICON_NAME)
4095])dnl
4096dnl ---------------------------------------------------------------------------
4097dnl CF_WITH_ICON_SYMLINK version: 3 updated: 2023/11/23 06:40:35
4098dnl --------------------
4099dnl Workaround for systems which are (mis)configured to map all icon references
4100dnl for xterm into "xterm" name.  For instance, recent (2013) KDE ignores both
4101dnl the name given in the .desktop file (xterm-color) and the application name
4102dnl (xterm-dev).
4103dnl
4104dnl $1 = default icon name to use if symlink is wanted
4105AC_DEFUN([CF_WITH_ICON_SYMLINK],[
4106AC_MSG_CHECKING(for icon symlink to use)
4107AC_ARG_WITH(icon-symlink,
4108	[[  --with-icon-symlink[=XXX] make symbolic link for icon name (default: $1)]],
4109	[ICON_SYMLINK="$withval"],
4110	[ICON_SYMLINK=NONE])
4111case "x$ICON_SYMLINK" in
4112(xyes)
4113	ICON_SYMLINK=$1
4114	;;
4115(xno|x)
4116	ICON_SYMLINK=NONE
4117	;;
4118esac
4119AC_SUBST(ICON_SYMLINK)
4120AC_MSG_RESULT($ICON_SYMLINK)
4121])dnl
4122dnl ---------------------------------------------------------------------------
4123dnl CF_WITH_ICON_THEME version: 14 updated: 2023/11/23 06:40:35
4124dnl ------------------
4125dnl If asked, check for prerequisites and setup symbols to permit installing
4126dnl one or more application icons in the Red Hat icon-theme directory
4127dnl hierarchy.
4128dnl
4129dnl If the prerequisites are missing, give a warning and revert to the long-
4130dnl standing pixmaps directory.
4131dnl
4132dnl Parameters:
4133dnl
4134dnl $1 = application icon.  This can be a list, and is not optional.
4135dnl $2 = default theme (defaults to hicolor)
4136dnl $3 = formats (defaults to list [.svg .png .xpm])
4137dnl $4 = alternate icon if no theme is used (defaults to $1).
4138dnl
4139dnl Result:
4140dnl ICON_NAME = basename of first item in $1, unless already set
4141dnl ICON_LIST = reprocessed $1
4142dnl ICON_THEME = reprocessed $2
4143dnl ICON_FORMAT = reprocessed $3
4144AC_DEFUN([CF_WITH_ICON_THEME],
4145[
4146ifelse([$1],,[
4147	AC_MSG_ERROR([macro [CF_WITH_ICON_THEME] requires application-icon name])
4148],[
4149
4150CF_WITH_PIXMAPDIR
4151CF_WITH_ICONDIR
4152
4153AC_MSG_CHECKING(if icon theme should be used)
4154AC_ARG_WITH(icon-theme,
4155	[[  --with-icon-theme[=XXX] install icons into desktop theme (hicolor)]],
4156	[ICON_THEME=$withval],
4157	[ICON_THEME=no])
4158
4159case "x$ICON_THEME" in
4160(xno)
4161	;;
4162(x|xyes)
4163	ICON_THEME=ifelse([$2],,hicolor,$2)
4164	;;
4165esac
4166AC_MSG_RESULT($ICON_THEME)
4167
4168if test "x$ICON_THEME" = xno
4169then
4170	if test "x$ICONDIR" != xno
4171	then
4172		CF_VERBOSE(ignoring icondir without theme)
4173		no_icondir="#"
4174	fi
4175else
4176	if test "x$ICONDIR" = xno
4177	then
4178		AC_MSG_ERROR(icondir must be set for icon theme)
4179	fi
4180fi
4181
4182: ${ICON_FORMAT:=ifelse([$3],,[".svg .png .xpm"],[$3])}
4183
4184ICON_LIST=
4185
4186ifelse([$4],,[cf_icon_list=$1],[
4187if test "x$ICON_THEME" != xno
4188then
4189	cf_icon_list="$1"
4190else
4191	cf_icon_list="$4"
4192fi
4193])
4194
4195AC_MSG_CHECKING([for icon(s) to install])
4196for cf_name in $cf_icon_list
4197do
4198	CF_VERBOSE(using $ICON_FORMAT)
4199	for cf_suffix in $ICON_FORMAT
4200	do
4201		cf_icon="${cf_name}${cf_suffix}"
4202		cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
4203		if test ! -f "${cf_left}"
4204		then
4205			if test "x$srcdir" != "x."
4206			then
4207				cf_icon="${srcdir}/${cf_left}"
4208				cf_left=`echo "$cf_icon" | sed -e 's/:.*//'`
4209				if test ! -f "${cf_left}"
4210				then
4211					continue
4212				fi
4213			else
4214				continue
4215			fi
4216		fi
4217		if test "x$ICON_THEME" != xno
4218		then
4219			cf_base=`basename "$cf_left"`
4220			cf_trim=`echo "$cf_base" | sed -e 's/_[[0-9]][[0-9]]x[[0-9]][[0-9]]\././'`
4221			case "x${cf_base}" in
4222			(*:*)
4223				cf_next=$cf_base
4224				# user-defined mapping
4225				;;
4226			(*.png)
4227				cf_size=`file "$cf_left"|sed -e 's/^[[^:]]*://' -e 's/^.*[[^0-9]]\([[0-9]][[0-9]]* x [[0-9]][[0-9]]*\)[[^0-9]].*$/\1/' -e 's/ //g'`
4228				if test -z "$cf_size"
4229				then
4230					AC_MSG_WARN(cannot determine size of $cf_left)
4231					continue
4232				fi
4233				cf_next="$cf_size/apps/$cf_trim"
4234				;;
4235			(*.svg)
4236				cf_next="scalable/apps/$cf_trim"
4237				;;
4238			(*.xpm)
4239				CF_VERBOSE(ignored XPM file in icon theme)
4240				continue
4241				;;
4242			(*_[[0-9]][[0-9]]*x[[0-9]][[0-9]]*.*)
4243				cf_size=`echo "$cf_left"|sed -e 's/^.*_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\..*$/\1/'`
4244				cf_left=`echo "$cf_left"|sed -e 's/^\(.*\)_\([[0-9]][[0-9]]*x[[0-9]][[0-9]]*\)\(\..*\)$/\1\3/'`
4245				cf_next="$cf_size/apps/$cf_base"
4246				;;
4247			esac
4248			CF_VERBOSE(adding $cf_next)
4249			cf_icon="${cf_icon}:${cf_next}"
4250		fi
4251		test -n "$ICON_LIST" && ICON_LIST="$ICON_LIST "
4252		ICON_LIST="$ICON_LIST${cf_icon}"
4253		if test -z "$ICON_NAME"
4254		then
4255			ICON_NAME=`basename "$cf_icon" | sed -e 's/[[.:]].*//'`
4256		fi
4257	done
4258done
4259
4260if test -n "$verbose"
4261then
4262	AC_MSG_CHECKING(result)
4263fi
4264AC_MSG_RESULT($ICON_LIST)
4265
4266if test -z "$ICON_LIST"
4267then
4268	AC_MSG_ERROR(no icons found)
4269fi
4270])
4271
4272AC_MSG_CHECKING(for icon name)
4273AC_MSG_RESULT($ICON_NAME)
4274
4275AC_SUBST(ICON_FORMAT)
4276AC_SUBST(ICON_THEME)
4277AC_SUBST(ICON_LIST)
4278AC_SUBST(ICON_NAME)
4279])dnl
4280dnl ---------------------------------------------------------------------------
4281dnl CF_WITH_IMAKE_CFLAGS version: 13 updated: 2024/07/05 19:34:53
4282dnl --------------------
4283dnl xterm and similar programs build more readily when propped up with imake's
4284dnl hand-tuned definitions.  If we do not use imake, provide fallbacks for the
4285dnl most common definitions that we're not likely to do by autoconf tests.
4286AC_DEFUN([CF_WITH_IMAKE_CFLAGS],[
4287AC_REQUIRE([CF_ENABLE_NARROWPROTO])
4288
4289AC_MSG_CHECKING(if we should use imake to help)
4290CF_ARG_ENABLE(imake,
4291	[  --enable-imake          enable use of imake for definitions],
4292	[enable_imake=yes],
4293	[enable_imake=no])
4294AC_MSG_RESULT($enable_imake)
4295
4296if test "$enable_imake" = yes ; then
4297	CF_IMAKE_CFLAGS(ifelse([$1],,,[$1]))
4298fi
4299
4300if test -n "$IMAKE" && test -n "$IMAKE_CFLAGS" ; then
4301	CF_ADD_CFLAGS($IMAKE_CFLAGS)
4302else
4303	IMAKE_CFLAGS=
4304	IMAKE_LOADFLAGS=
4305	CF_VERBOSE(make fallback definitions)
4306
4307	# We prefer config.guess' values when we can get them, to avoid
4308	# inconsistent results with uname (AIX for instance).  However,
4309	# config.guess is not always consistent either.
4310	case $host_os in
4311	(*[[0-9]].[[0-9]]*)
4312		UNAME_RELEASE="$host_os"
4313		;;
4314	(*)
4315		UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
4316		;;
4317	esac
4318
4319	case .$UNAME_RELEASE in
4320	(*[[0-9]].[[0-9]]*)
4321		OSMAJORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/\..*//'`
4322		OSMINORVERSION=`echo "$UNAME_RELEASE" |sed -e 's/^[[^0-9]]*//' -e 's/^[[^.]]*\.//' -e 's/\..*//' -e 's/[[^0-9]].*//' `
4323		test -z "$OSMAJORVERSION" && OSMAJORVERSION=1
4324		test -z "$OSMINORVERSION" && OSMINORVERSION=0
4325		IMAKE_CFLAGS="-DOSMAJORVERSION=$OSMAJORVERSION -DOSMINORVERSION=$OSMINORVERSION $IMAKE_CFLAGS"
4326		;;
4327	esac
4328
4329	# FUNCPROTO is standard with X11R6, but XFree86 drops it, leaving some
4330	# fallback/fragments for NeedPrototypes, etc.
4331	IMAKE_CFLAGS="-DFUNCPROTO=15 $IMAKE_CFLAGS"
4332
4333	# If this is not set properly, Xaw's scrollbars will not work
4334	if test "$enable_narrowproto" = yes ; then
4335		IMAKE_CFLAGS="-DNARROWPROTO=1 $IMAKE_CFLAGS"
4336	fi
4337
4338	# Other special definitions:
4339	case $host_os in
4340	(aix*)
4341		# imake on AIX 5.1 defines AIXV3.  really.
4342		IMAKE_CFLAGS="-DAIXV3 -DAIXV4 $IMAKE_CFLAGS"
4343		;;
4344	(irix[[56]].*)
4345		# these are needed to make SIGWINCH work in xterm
4346		IMAKE_CFLAGS="-DSYSV -DSVR4 $IMAKE_CFLAGS"
4347		;;
4348	esac
4349
4350	# "modern" systems install X applications in /usr/bin.  Other systems may
4351	# use one of the X release-based directories.
4352	case "$CFLAGS $CPPFLAGS $IMAKE_CFLAGS" in
4353	(*-DPROJECTROOT*)
4354		;;
4355	(*)
4356		for cf_dir in /usr/X11R7 /usr/X11R6 /usr/X11R5
4357		do
4358			if test -d "$cf_dir/bin"
4359			then
4360				IMAKE_CFLAGS="$IMAKE_CFLAGS -DPROJECTROOT=\\\"$cf_dir\\\""
4361				break
4362			fi
4363		done
4364		;;
4365	esac
4366
4367	CF_ADD_CFLAGS($IMAKE_CFLAGS)
4368
4369	AC_SUBST(IMAKE_CFLAGS)
4370	AC_SUBST(IMAKE_LOADFLAGS)
4371fi
4372])dnl
4373dnl ---------------------------------------------------------------------------
4374dnl CF_WITH_MAN2HTML version: 14 updated: 2024/09/09 17:17:46
4375dnl ----------------
4376dnl Check for man2html and groff.  Prefer man2html over groff, but use groff
4377dnl as a fallback.  See
4378dnl
4379dnl		https://invisible-island.net/scripts/man2html.html
4380dnl
4381dnl Generate a shell script which hides the differences between the two.
4382dnl
4383dnl We name that "man2html.tmp".
4384dnl
4385dnl The shell script can be removed later, e.g., using "make distclean".
4386AC_DEFUN([CF_WITH_MAN2HTML],[
4387AC_REQUIRE([CF_PROG_GROFF])dnl
4388AC_REQUIRE([AC_PROG_FGREP])dnl
4389
4390case "x${with_man2html}" in
4391(xno)
4392	cf_man2html=no
4393	;;
4394(x|xyes)
4395	AC_PATH_PROG(cf_man2html,man2html,no)
4396	case "x$cf_man2html" in
4397	(x/*)
4398		AC_MSG_CHECKING(for the modified Earl Hood script)
4399		if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
4400		then
4401			cf_man2html_ok=yes
4402		else
4403			cf_man2html=no
4404			cf_man2html_ok=no
4405		fi
4406		AC_MSG_RESULT($cf_man2html_ok)
4407		;;
4408	(*)
4409		cf_man2html=no
4410		;;
4411	esac
4412esac
4413
4414AC_MSG_CHECKING(for program to convert manpage to html)
4415AC_ARG_WITH(man2html,
4416	[[  --with-man2html[=XXX]   use XXX rather than groff]],
4417	[cf_man2html=$withval],
4418	[cf_man2html=$cf_man2html])
4419
4420cf_with_groff=no
4421
4422case $cf_man2html in
4423(yes)
4424	AC_MSG_RESULT(man2html)
4425	AC_PATH_PROG(cf_man2html,man2html,no)
4426	;;
4427(no|groff|*/groff*)
4428	cf_with_groff=yes
4429	cf_man2html=$GROFF_PATH
4430	AC_MSG_RESULT($cf_man2html)
4431	;;
4432(*)
4433	AC_MSG_RESULT($cf_man2html)
4434	;;
4435esac
4436
4437MAN2HTML_TEMP="man2html.tmp"
4438	cat >$MAN2HTML_TEMP <<CF_EOF
4439#!$SHELL
4440# Temporary script generated by CF_WITH_MAN2HTML
4441# Convert inputs to html, sending result to standard output.
4442#
4443# Parameters:
4444# \${1} = rootname of file to convert
4445# \${2} = suffix of file to convert, e.g., "1"
4446# \${3} = macros to use, e.g., "man"
4447#
4448ROOT=\[$]1
4449TYPE=\[$]2
4450MACS=\[$]3
4451
4452unset LANG
4453unset LC_ALL
4454unset LC_CTYPE
4455unset LANGUAGE
4456GROFF_NO_SGR=stupid
4457export GROFF_NO_SGR
4458
4459CF_EOF
4460
4461NROFF_OPTS=
4462if test "x$cf_with_groff" = xyes
4463then
4464	MAN2HTML_NOTE="$GROFF_NOTE"
4465	MAN2HTML_PATH="$GROFF_PATH"
4466	cat >>$MAN2HTML_TEMP <<CF_EOF
4467$SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
4468CF_EOF
4469else
4470	# disable hyphenation if this is groff
4471	if test "x$GROFF_PATH" != xno
4472	then
4473		AC_MSG_CHECKING(if nroff is really groff)
4474		cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`"
4475		test -n "$cf_check_groff" && cf_check_groff=yes
4476		test -n "$cf_check_groff" || cf_check_groff=no
4477		AC_MSG_RESULT($cf_check_groff)
4478		test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0"
4479	fi
4480	MAN2HTML_NOTE=""
4481	CF_PATH_SYNTAX(cf_man2html)
4482	MAN2HTML_PATH="$cf_man2html"
4483	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
4484
4485	# for this example, expect 3 lines of content, the remainder is head/foot
4486	cat >conftest.in <<CF_EOF
4487.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
4488.SH SECTION
4489MARKER
4490CF_EOF
4491
4492	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
4493
4494	cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
4495	cf_man2html_top=`expr "$cf_man2html_1st" - 2`
4496	cf_man2html_bot="`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`"
4497	cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"`
4498	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
4499
4500	AC_MSG_RESULT($cf_man2html_top_bot)
4501
4502	AC_MSG_CHECKING(for pagesize to use)
4503	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
4504	do
4505	cat >>conftest.in <<CF_EOF
4506.nf
45070
45081
45092
45103
45114
45125
45136
45147
45158
45169
4517CF_EOF
4518	done
4519
4520	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
4521	cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
4522	test -z "$cf_man2html_page" && cf_man2html_page=99999
4523	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
4524
4525	rm -rf conftest*
4526	AC_MSG_RESULT($cf_man2html_page)
4527
4528	cat >>$MAN2HTML_TEMP <<CF_EOF
4529: \${MAN2HTML_PATH=$MAN2HTML_PATH}
4530MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title=\"\$ROOT(\$TYPE)\" -compress -pgsize $cf_man2html_page"
4531case \${TYPE} in
4532(ms)
4533	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
4534	;;
4535(*)
4536	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
4537	;;
4538esac
4539CF_EOF
4540fi
4541
4542chmod 700 $MAN2HTML_TEMP
4543
4544AC_SUBST(MAN2HTML_NOTE)
4545AC_SUBST(MAN2HTML_PATH)
4546AC_SUBST(MAN2HTML_TEMP)
4547])dnl
4548dnl ---------------------------------------------------------------------------
4549dnl CF_WITH_PCRE version: 12 updated: 2017/07/29 22:57:34
4550dnl ------------
4551dnl Add PCRE (Perl-compatible regular expressions) to the build if it is
4552dnl available and the user requests it.  Assume the application will otherwise
4553dnl use the POSIX interface.
4554dnl
4555dnl TODO allow $withval to specify package location
4556AC_DEFUN([CF_WITH_PCRE],
4557[
4558AC_REQUIRE([CF_PKG_CONFIG])
4559
4560AC_MSG_CHECKING(if you want to use PCRE for regular-expressions)
4561AC_ARG_WITH(pcre,
4562	[  --with-pcre             use PCRE for regular-expressions])
4563test -z "$with_pcre" && with_pcre=no
4564AC_MSG_RESULT($with_pcre)
4565
4566if test "$with_pcre" != no ; then
4567	CF_TRY_PKG_CONFIG(libpcre,,[
4568		AC_CHECK_LIB(pcre,pcre_compile,,
4569			AC_MSG_ERROR(Cannot find PCRE library))])
4570
4571	AC_DEFINE(HAVE_LIB_PCRE,1,[Define to 1 if we can/should compile with the PCRE library])
4572
4573	case $LIBS in
4574	(*pcreposix*)
4575		;;
4576	(*)
4577		AC_CHECK_LIB(pcreposix,pcreposix_regcomp,
4578			[AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
4579				CF_ADD_LIB(pcreposix)],
4580			[AC_CHECK_LIB(pcreposix,regcomp,[
4581				AC_DEFINE(HAVE_PCREPOSIX_H,1,[Define to 1 if we should include pcreposix.h])
4582				CF_ADD_LIB(pcreposix)],
4583				AC_MSG_ERROR(Cannot find PCRE POSIX library)]))
4584		;;
4585	esac
4586fi
4587])dnl
4588dnl ---------------------------------------------------------------------------
4589dnl CF_WITH_PCRE2 version: 6 updated: 2021/08/11 20:35:34
4590dnl -------------
4591dnl Add PCRE2 (Perl-compatible regular expressions v2) to the build if it is
4592dnl available and the user requests it.  Assume the application will otherwise
4593dnl use the POSIX interface.
4594dnl
4595dnl TODO allow $withval to specify package location
4596AC_DEFUN([CF_WITH_PCRE2],
4597[
4598AC_REQUIRE([CF_PKG_CONFIG])
4599
4600AC_MSG_CHECKING(if you want to use PCRE2 for regular-expressions)
4601AC_ARG_WITH(pcre2,
4602	[  --with-pcre2            use PCRE2 for regular-expressions])
4603test -z "$with_pcre2" && with_pcre2=no
4604AC_MSG_RESULT($with_pcre2)
4605
4606if test "x$with_pcre2" != xno ; then
4607	cf_with_pcre2_ok=no
4608	for cf_with_pcre2 in libpcre2 libpcre2-posix libpcre
4609	do
4610		CF_TRY_PKG_CONFIG($cf_with_pcre2,[cf_with_pcre2_ok=yes; break])
4611	done
4612	cf_with_pcre2_ok=yes || AC_MSG_ERROR(Cannot find PCRE2 library)
4613
4614	AC_DEFINE(HAVE_LIB_PCRE2,1,[Define to 1 if we can/should compile with the PCRE2 library])
4615
4616	# if pkgconfig gave no results, look for the libraries directly
4617	case "$LIBS" in
4618	(*pcre2-posix*|*pcreposix*)
4619		;;
4620	(*)
4621		AC_CHECK_LIB(pcre2-posix,regcomp,[
4622			CF_ADD_LIB(pcre2-posix)],
4623			[AC_CHECK_LIB(pcreposix,regcomp,[
4624			 CF_ADD_LIB(pcreposix)
4625			],[AC_MSG_ERROR(Cannot find PCRE2 POSIX library)])])
4626		;;
4627	esac
4628
4629	# either way, check for the library header files
4630	AC_CHECK_HEADERS(pcre2posix.h pcreposix.h)
4631	AC_CHECK_FUNCS(PCRE2regcomp)
4632fi
4633])dnl
4634dnl ---------------------------------------------------------------------------
4635dnl CF_WITH_PIXMAPDIR version: 3 updated: 2012/07/22 09:18:02
4636dnl -----------------
4637dnl Handle configure option "--with-pixmapdir", setting these shell variables:
4638dnl
4639dnl $PIXMAPDIR is the option value, used for installing pixmap files.
4640dnl $no_pixmapdir is a "#" (comment) if "--without-pixmapdir" is given.
4641AC_DEFUN([CF_WITH_PIXMAPDIR],[
4642AC_MSG_CHECKING(for directory to install pixmaps)
4643AC_ARG_WITH(pixmapdir,
4644	[  --with-pixmapdir=DIR    directory in which to install pixmaps (DATADIR/pixmaps)],
4645	[PIXMAPDIR=$withval],
4646	[test -z "$PIXMAPDIR" && PIXMAPDIR='${datadir}/pixmaps'])
4647
4648if test "x[$]PIXMAPDIR" = xauto
4649then
4650	PIXMAPDIR='${datadir}/pixmaps'
4651	for cf_path in \
4652		/usr/share/pixmaps \
4653		/usr/X11R6/share/pixmaps
4654	do
4655		if test -d "$cf_path" ; then
4656			PIXMAPDIR="$cf_path"
4657			break
4658		fi
4659	done
4660else
4661	cf_path=$PIXMAPDIR
4662	CF_PATH_SYNTAX(cf_path)
4663fi
4664AC_MSG_RESULT($PIXMAPDIR)
4665AC_SUBST(PIXMAPDIR)
4666
4667no_pixmapdir=
4668if test "$PIXMAPDIR" = no
4669then
4670	no_pixmapdir="#"
4671else
4672	EXTRA_INSTALL_DIRS="$EXTRA_INSTALL_DIRS \$(PIXMAPDIR)"
4673fi
4674AC_SUBST(no_pixmapdir)
4675])dnl
4676dnl ---------------------------------------------------------------------------
4677dnl CF_WITH_SYSTYPE version: 1 updated: 2013/01/26 16:26:12
4678dnl ---------------
4679dnl For testing, override the derived host system-type which is used to decide
4680dnl things such as the linker commands used to build shared libraries.  This is
4681dnl normally chosen automatically based on the type of system which you are
4682dnl building on.  We use it for testing the configure script.
4683dnl
4684dnl This is different from the --host option: it is used only for testing parts
4685dnl of the configure script which would not be reachable with --host since that
4686dnl relies on the build environment being real, rather than mocked up.
4687AC_DEFUN([CF_WITH_SYSTYPE],[
4688CF_CHECK_CACHE([AC_CANONICAL_SYSTEM])
4689AC_ARG_WITH(system-type,
4690	[  --with-system-type=XXX  test: override derived host system-type],
4691[AC_MSG_WARN(overriding system type to $withval)
4692	cf_cv_system_name=$withval
4693	host_os=$withval
4694])
4695])dnl
4696dnl ---------------------------------------------------------------------------
4697dnl CF_WITH_UTMP_PATH version: 1 updated: 2023/09/04 16:05:17
4698dnl -----------------
4699dnl utmp and wtmp have different pathnames on different systems, but there
4700dnl are only a few common choices.  Note that they may not necessarily appear
4701dnl in the same directories.  Prefer utmpx/wtmpx to utmp/wtmp, since that's
4702dnl the way the configure script is designed.
4703AC_DEFUN([CF_WITH_UTMP_PATH],[
4704AC_ARG_WITH(utmp-path,
4705	[  --with-utmp-path=XXX    use XXX rather than auto for utmp path],
4706	[cf_utmp_path=$withval],
4707	[cf_utmp_path=auto])
4708if test "$cf_utmp_path" = auto ; then
4709	for cf_utmp_path in /etc/utmp /var/adm/utmp /var/log/utmp /var/run/utmp
4710	do
4711		if test -f ${cf_utmp_path}x ; then
4712			cf_utmp_path=${cf_utmp_path}x
4713			break
4714		elif test -f $cf_utmp_path ; then
4715			break
4716		fi
4717	done
4718else
4719	CF_PATH_SYNTAX(cf_utmp_path)
4720fi
4721UTMP_PATH=$cf_utmp_path
4722UTMP_NAME=`echo "$cf_utmp_path" | sed -e 's,^.*/,,'`
4723AC_SUBST(UTMP_NAME)
4724AC_SUBST(UTMP_PATH)
4725])dnl
4726dnl ---------------------------------------------------------------------------
4727dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
4728dnl ----------------
4729AC_DEFUN([CF_WITH_VALGRIND],[
4730CF_NO_LEAKS_OPTION(valgrind,
4731	[  --with-valgrind         test: use valgrind],
4732	[USE_VALGRIND])
4733])dnl
4734dnl ---------------------------------------------------------------------------
4735dnl CF_WITH_WTMP_PATH version: 2 updated: 2023/10/02 17:22:48
4736dnl -----------------
4737dnl Like CF_WITH_UTMP_PATH, but for the wtmp file.
4738AC_DEFUN([CF_WITH_WTMP_PATH],[
4739AC_ARG_WITH(wtmp-path,
4740	[  --with-wtmp-path=XXX    use XXX rather than auto for wtmp path],
4741	[cf_wtmp_path=$withval],
4742	[cf_wtmp_path=auto])
4743if test "$cf_wtmp_path" = auto ; then
4744	for cf_wtmp_path in /etc/wtmp /var/adm/wtmp /var/run/wtmp /var/log/wtmp
4745	do
4746		if test -f ${cf_wtmp_path}x ; then
4747			cf_wtmp_path=${cf_wtmp_path}x
4748			break
4749		elif test -f $cf_wtmp_path/wtmp ; then
4750			break
4751		fi
4752	done
4753else
4754	CF_PATH_SYNTAX(cf_wtmp_path)
4755fi
4756WTMP_PATH=$cf_wtmp_path
4757WTMP_NAME=`echo "$cf_wtmp_path" | sed -e 's,^.*/,,'`
4758AC_SUBST(WTMP_NAME)
4759AC_SUBST(WTMP_PATH)
4760])dnl
4761dnl ---------------------------------------------------------------------------
4762dnl CF_WITH_XINERAMA version: 1 updated: 2016/05/28 14:41:12
4763dnl ----------------
4764AC_DEFUN([CF_WITH_XINERAMA],
4765[
4766AC_MSG_CHECKING(if you want to use the Xinerama extension)
4767AC_ARG_WITH(xinerama,
4768[  --without-xinerama      do not use Xinerama extension for multiscreen support],
4769	[cf_with_xinerama="$withval"],
4770	[cf_with_xinerama=yes])
4771AC_MSG_RESULT($cf_with_xinerama)
4772if test "$cf_with_xinerama" = yes; then
4773	CF_XINERAMA
4774fi
4775])dnl
4776dnl ---------------------------------------------------------------------------
4777dnl CF_WITH_XPM version: 4 updated: 2023/11/23 06:40:35
4778dnl -----------
4779dnl Test for Xpm library, update compiler/loader flags if it is wanted and
4780dnl found.
4781dnl
4782dnl Also sets ICON_SUFFIX
4783AC_DEFUN([CF_WITH_XPM],
4784[
4785ICON_SUFFIX=.xbm
4786
4787cf_save_cppflags="${CPPFLAGS}"
4788cf_save_ldflags="${LDFLAGS}"
4789
4790AC_MSG_CHECKING(if you want to use the Xpm library for colored icon)
4791AC_ARG_WITH(xpm,
4792[[  --with-xpm[=DIR]        use Xpm library for colored icon, may specify path]],
4793	[cf_Xpm_library="$withval"],
4794	[cf_Xpm_library=yes])
4795AC_MSG_RESULT($cf_Xpm_library)
4796
4797if test "$cf_Xpm_library" != no ; then
4798    if test "$cf_Xpm_library" != yes ; then
4799	CPPFLAGS="$CPPFLAGS -I$withval/include"
4800	LDFLAGS="$LDFLAGS -L$withval/lib"
4801    fi
4802    AC_CHECK_HEADER(X11/xpm.h,[
4803	AC_CHECK_LIB(Xpm, XpmCreatePixmapFromData,[
4804	    AC_DEFINE(HAVE_LIBXPM,1,[Define to 1 if we should use Xpm library])
4805	    ICON_SUFFIX=.xpm
4806	    LIBS="-lXpm $LIBS"],
4807	    [CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"],
4808	    [-lX11 $X_LIBS])],
4809	[CPPFLAGS="${cf_save_cppflags}" LDFLAGS="${cf_save_ldflags}"])
4810fi
4811
4812AC_SUBST(ICON_SUFFIX)
4813])dnl
4814dnl ---------------------------------------------------------------------------
4815dnl CF_XBOOL_RESULT version: 3 updated: 2015/04/12 15:39:00
4816dnl ---------------
4817dnl Translate an autoconf boolean yes/no into X11's booleans, e.g., True/False.
4818dnl Allow for more than two values, e.g., "maybe", still using the same leading
4819dnl capital convention.
4820dnl
4821dnl $1 = symbol to define
4822dnl $2 = symbol holding value
4823dnl $3 = description
4824define([CF_XBOOL_RESULT],[
4825AC_MSG_RESULT([$]$2)
4826case [$]$2 in
4827(yes)
4828	$2=true
4829	;;
4830(no)
4831	$2=false
4832	;;
4833esac
4834cf_xbool1=`echo "[$]$2"|sed -e 's/^\(.\).*/\1/'`
4835CF_UPPER(cf_xbool1,$cf_xbool1)
4836cf_xbool2=`echo "[$]$2"|sed -e 's/^.//'`
4837$2=${cf_xbool1}${cf_xbool2}
4838AC_DEFINE_UNQUOTED($1,[$]$2,$3)
4839AC_SUBST($2)
4840])
4841dnl ---------------------------------------------------------------------------
4842dnl CF_XINERAMA version: 2 updated: 2015/02/15 15:18:41
4843dnl -----------
4844AC_DEFUN([CF_XINERAMA],[
4845CF_TRY_PKG_CONFIG(xinerama,[
4846	AC_DEFINE(HAVE_X11_EXTENSIONS_XINERAMA_H)],[
4847	AC_CHECK_LIB(Xinerama,XineramaQueryScreens,
4848		[CF_ADD_LIB(Xinerama)
4849		 AC_CHECK_HEADERS( \
4850			X11/extensions/Xinerama.h \
4851			)
4852		])
4853	])
4854])dnl
4855dnl ---------------------------------------------------------------------------
4856dnl CF_XKB_BELL_EXT version: 7 updated: 2023/12/01 17:22:50
4857dnl ---------------
4858dnl Check for XKB bell extension
4859AC_DEFUN([CF_XKB_BELL_EXT],[
4860AC_REQUIRE([AC_PATH_XTRA])
4861
4862CF_SAVE_XTRA_FLAGS([CF_XKB_BELL_EXT])
4863
4864AC_CACHE_CHECK(for XKB Bell extension, cf_cv_xkb_bell_ext,[
4865AC_TRY_LINK([
4866#include <X11/Intrinsic.h>
4867#include <X11/XKBlib.h>		/* has the prototype */
4868#include <X11/extensions/XKBbells.h>	/* has the XkbBI_xxx definitions */
4869],[
4870	int x = (XkbBI_Info |XkbBI_MinorError |XkbBI_MajorError |XkbBI_TerminalBell |XkbBI_MarginBell);
4871	Atom y = 0;
4872	(void)x;
4873	XkbBell((Display *)0, (Window)0, 0, y);
4874],[cf_cv_xkb_bell_ext=yes],[cf_cv_xkb_bell_ext=no])
4875])
4876test "$cf_cv_xkb_bell_ext" = yes && AC_DEFINE(HAVE_XKB_BELL_EXT,1,[Define 1 if we have XKB Bell extension])
4877
4878CF_RESTORE_XTRA_FLAGS([CF_XKB_BELL_EXT])
4879])
4880dnl ---------------------------------------------------------------------------
4881dnl CF_XKB_KEYCODE_TO_KEYSYM version: 3 updated: 2020/03/10 18:53:47
4882dnl ------------------------
4883dnl Some older vendor-unix systems made a practice of delivering fragments of
4884dnl Xkb, requiring test-compiles.
4885AC_DEFUN([CF_XKB_KEYCODE_TO_KEYSYM],[
4886AC_CACHE_CHECK(if we can use XkbKeycodeToKeysym, cf_cv_xkb_keycode_to_keysym,[
4887AC_TRY_COMPILE([
4888#include <X11/Xlib.h>
4889#include <X11/XKBlib.h>
4890],[
4891    KeySym keysym = XkbKeycodeToKeysym((Display *)0, 0, 0, 0);
4892	(void)keysym;
4893],[
4894cf_cv_xkb_keycode_to_keysym=yes
4895],[
4896cf_cv_xkb_keycode_to_keysym=no
4897])
4898])
4899
4900if test $cf_cv_xkb_keycode_to_keysym = yes
4901then
4902	AC_CHECK_FUNCS(XkbKeycodeToKeysym)
4903fi
4904])
4905dnl ---------------------------------------------------------------------------
4906dnl CF_XKB_QUERY_EXTENSION version: 2 updated: 2012/09/28 20:23:46
4907dnl ----------------------
4908dnl see ifdef in scrollbar.c - iron out here
4909AC_DEFUN([CF_XKB_QUERY_EXTENSION],[
4910AC_CACHE_CHECK(if we can use XkbQueryExtension, cf_cv_xkb_query_extension,[
4911AC_TRY_COMPILE([
4912#include <X11/Xlib.h>
4913#include <X11/extensions/XKB.h>
4914#include <X11/XKBlib.h>
4915],[
4916	int xkbmajor = XkbMajorVersion;
4917	int xkbminor = XkbMinorVersion;
4918	int xkbopcode, xkbevent, xkberror;
4919
4920	if (XkbLibraryVersion(&xkbmajor, &xkbminor)
4921	    && XkbQueryExtension((Display *)0,
4922				 &xkbopcode,
4923				 &xkbevent,
4924				 &xkberror,
4925				 &xkbmajor,
4926				 &xkbminor))
4927		 return 0;
4928],[
4929cf_cv_xkb_query_extension=yes
4930],[
4931cf_cv_xkb_query_extension=no
4932])
4933])
4934
4935if test $cf_cv_xkb_query_extension = yes
4936then
4937	AC_CHECK_FUNCS(XkbQueryExtension)
4938fi
4939])
4940dnl ---------------------------------------------------------------------------
4941dnl CF_XOPEN_SOURCE version: 68 updated: 2024/11/09 18:07:29
4942dnl ---------------
4943dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
4944dnl or adapt to the vendor's definitions to get equivalent functionality,
4945dnl without losing the common non-POSIX features.
4946dnl
4947dnl Parameters:
4948dnl	$1 is the nominal value for _XOPEN_SOURCE
4949dnl	$2 is the nominal value for _POSIX_C_SOURCE
4950dnl
4951dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
4952dnl implementation predefines it, because X/Open and most implementations agree
4953dnl that the latter is a legacy or "aligned" value.
4954dnl
4955dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
4956dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
4957dnl
4958dnl References:
4959dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
4960dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
4961dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
4962AC_DEFUN([CF_XOPEN_SOURCE],[
4963AC_REQUIRE([AC_CANONICAL_HOST])
4964AC_REQUIRE([CF_POSIX_VISIBLE])
4965
4966if test "$cf_cv_posix_visible" = no; then
4967
4968cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
4969cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
4970cf_xopen_source=
4971
4972case "$host_os" in
4973(aix[[4-7]]*)
4974	cf_xopen_source="-D_ALL_SOURCE"
4975	;;
4976(darwin[[0-8]].*)
4977	cf_xopen_source="-D_APPLE_C_SOURCE"
4978	;;
4979(darwin*)
4980	cf_xopen_source="-D_DARWIN_C_SOURCE"
4981	cf_XOPEN_SOURCE=
4982	;;
4983(freebsd*|dragonfly*|midnightbsd*)
4984	# 5.x headers associate
4985	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
4986	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
4987	cf_POSIX_C_SOURCE=200112L
4988	cf_XOPEN_SOURCE=600
4989	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
4990	;;
4991(hpux11*)
4992	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
4993	;;
4994(hpux*)
4995	cf_xopen_source="-D_HPUX_SOURCE"
4996	;;
4997(irix[[56]].*)
4998	cf_xopen_source="-D_SGI_SOURCE"
4999	cf_XOPEN_SOURCE=
5000	;;
5001(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*|linux*uclibc)
5002	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
5003	;;
5004linux*musl)
5005	cf_xopen_source="-D_BSD_SOURCE"
5006	;;
5007(minix*)
5008	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
5009	;;
5010(mirbsd*)
5011	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
5012	cf_XOPEN_SOURCE=
5013	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
5014	;;
5015(netbsd*)
5016	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
5017	;;
5018(openbsd[[6-9]]*)
5019	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
5020	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
5021	# Abusing the conformance level is a workaround.
5022	AC_MSG_WARN(this system does not provide usable locale support)
5023	cf_xopen_source="-D_BSD_SOURCE"
5024	cf_XOPEN_SOURCE=700
5025	;;
5026(openbsd[[4-5]]*)
5027	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
5028	cf_xopen_source="-D_BSD_SOURCE"
5029	cf_XOPEN_SOURCE=600
5030	;;
5031(openbsd*)
5032	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
5033	;;
5034(osf[[45]]*)
5035	cf_xopen_source="-D_OSF_SOURCE"
5036	;;
5037(nto-qnx*)
5038	cf_xopen_source="-D_QNX_SOURCE"
5039	;;
5040(sco*)
5041	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
5042	;;
5043(solaris2.*)
5044	cf_xopen_source="-D__EXTENSIONS__"
5045	cf_cv_xopen_source=broken
5046	;;
5047(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
5048	cf_XOPEN_SOURCE=
5049	cf_POSIX_C_SOURCE=
5050	;;
5051(*)
5052	CF_TRY_XOPEN_SOURCE
5053	cf_save_xopen_cppflags="$CPPFLAGS"
5054	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
5055	# Some of these niche implementations use copy/paste, double-check...
5056	if test "$cf_cv_xopen_source" = no ; then
5057		CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
5058		AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[
5059			AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
5060			CPPFLAGS="$cf_save_xopen_cppflags"])
5061	fi
5062	;;
5063esac
5064
5065if test -n "$cf_xopen_source" ; then
5066	CF_APPEND_CFLAGS($cf_xopen_source,true)
5067fi
5068
5069dnl In anything but the default case, we may have system-specific setting
5070dnl which is still not guaranteed to provide all of the entrypoints that
5071dnl _XOPEN_SOURCE would yield.
5072if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
5073	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
5074	AC_TRY_COMPILE([#include <stdlib.h>],[
5075#ifndef _XOPEN_SOURCE
5076#error _XOPEN_SOURCE is not defined
5077#endif],
5078	[cf_XOPEN_SOURCE_set=yes],
5079	[cf_XOPEN_SOURCE_set=no])
5080	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
5081	if test "$cf_XOPEN_SOURCE_set" = yes
5082	then
5083		AC_TRY_COMPILE([#include <stdlib.h>],[
5084#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
5085#error (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
5086#endif],
5087		[cf_XOPEN_SOURCE_set_ok=yes],
5088		[cf_XOPEN_SOURCE_set_ok=no])
5089		if test "$cf_XOPEN_SOURCE_set_ok" = no
5090		then
5091			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
5092		fi
5093	else
5094		CF_TRY_XOPEN_SOURCE
5095	fi
5096fi
5097fi # cf_cv_posix_visible
5098])
5099dnl ---------------------------------------------------------------------------
5100dnl CF_X_ATHENA version: 25 updated: 2023/01/11 04:05:23
5101dnl -----------
5102dnl Check for Xaw (Athena) libraries
5103dnl
5104dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
5105AC_DEFUN([CF_X_ATHENA],
5106[
5107cf_x_athena=${cf_x_athena:-Xaw}
5108
5109AC_MSG_CHECKING(if you want to link with Xaw 3d library)
5110withval=
5111AC_ARG_WITH(Xaw3d,
5112	[  --with-Xaw3d            link with Xaw 3d library])
5113if test "$withval" = yes ; then
5114	cf_x_athena=Xaw3d
5115	AC_MSG_RESULT(yes)
5116else
5117	AC_MSG_RESULT(no)
5118fi
5119
5120AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
5121withval=
5122AC_ARG_WITH(Xaw3dxft,
5123	[  --with-Xaw3dxft         link with Xaw 3d xft library])
5124if test "$withval" = yes ; then
5125	cf_x_athena=Xaw3dxft
5126	AC_MSG_RESULT(yes)
5127else
5128	AC_MSG_RESULT(no)
5129fi
5130
5131AC_MSG_CHECKING(if you want to link with neXT Athena library)
5132withval=
5133AC_ARG_WITH(neXtaw,
5134	[  --with-neXtaw           link with neXT Athena library])
5135if test "$withval" = yes ; then
5136	cf_x_athena=neXtaw
5137	AC_MSG_RESULT(yes)
5138else
5139	AC_MSG_RESULT(no)
5140fi
5141
5142AC_MSG_CHECKING(if you want to link with Athena-Plus library)
5143withval=
5144AC_ARG_WITH(XawPlus,
5145	[  --with-XawPlus          link with Athena-Plus library])
5146if test "$withval" = yes ; then
5147	cf_x_athena=XawPlus
5148	AC_MSG_RESULT(yes)
5149else
5150	AC_MSG_RESULT(no)
5151fi
5152
5153cf_x_athena_lib=""
5154
5155if test "$PKG_CONFIG" != none ; then
5156	cf_athena_list=
5157	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
5158	for cf_athena_pkg in \
5159		$cf_athena_list \
5160		${cf_x_athena} \
5161		${cf_x_athena}-devel \
5162		lib${cf_x_athena} \
5163		lib${cf_x_athena}-devel
5164	do
5165		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
5166			cf_x_athena_lib="$cf_pkgconfig_libs"
5167			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
5168			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
5169
5170			CF_TRIM_X_LIBS
5171
5172AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
5173AC_TRY_LINK([
5174$ac_includes_default
5175#include <X11/Xmu/CharSet.h>
5176],[
5177int check = XmuCompareISOLatin1("big", "small");
5178(void)check;
5179],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
5180
5181			if test "$cf_cv_xaw_compat" = no
5182			then
5183				# workaround for broken ".pc" files...
5184				case "$cf_x_athena_lib" in
5185				(*-lXmu*)
5186					;;
5187				(*)
5188					CF_VERBOSE(work around broken package)
5189					cf_save_xmu="$LIBS"
5190					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
5191					CF_TRY_PKG_CONFIG(xmu,[
5192							LIBS="$cf_save_xmu"
5193							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
5194						],[
5195							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
5196						])
5197					CF_TRIM_X_LIBS
5198					;;
5199				esac
5200			fi
5201
5202			break])
5203	done
5204fi
5205
5206if test -z "$cf_x_athena_lib" ; then
5207	CF_X_EXT
5208	CF_X_TOOLKIT
5209	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
5210	CF_X_ATHENA_LIBS($cf_x_athena)
5211fi
5212])dnl
5213dnl ---------------------------------------------------------------------------
5214dnl CF_X_ATHENA_CPPFLAGS version: 9 updated: 2020/12/31 10:54:15
5215dnl --------------------
5216dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
5217dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
5218AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
5219[
5220AC_REQUIRE([AC_PATH_XTRA])
5221cf_x_athena_root=ifelse([$1],,Xaw,[$1])
5222cf_x_athena_inc=""
5223
5224for cf_path in default \
5225	/usr/contrib/X11R6 \
5226	/usr/contrib/X11R5 \
5227	/usr/lib/X11R5 \
5228	/usr/local
5229do
5230	if test -z "$cf_x_athena_inc" ; then
5231		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
5232		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
5233		if test "$cf_path" != default ; then
5234			CF_APPEND_TEXT(CPPFLAGS,-I$cf_path/include)
5235			AC_MSG_CHECKING(for $cf_test in $cf_path)
5236		else
5237			AC_MSG_CHECKING(for $cf_test)
5238		fi
5239		AC_TRY_COMPILE([
5240#include <X11/Intrinsic.h>
5241#include <$cf_test>],[],
5242			[cf_result=yes],
5243			[cf_result=no])
5244		AC_MSG_RESULT($cf_result)
5245		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
5246		if test "$cf_result" = yes ; then
5247			test "$cf_path"  = default && cf_x_athena_inc=default
5248			test "$cf_path" != default && cf_x_athena_inc="$cf_path/include"
5249			break
5250		fi
5251	fi
5252done
5253
5254if test -z "$cf_x_athena_inc" ; then
5255	AC_MSG_WARN([Unable to find Athena header files])
5256elif test "$cf_x_athena_inc" != default ; then
5257	CF_APPEND_TEXT(CPPFLAGS,-I$cf_x_athena_inc)
5258fi
5259])
5260dnl ---------------------------------------------------------------------------
5261dnl CF_X_ATHENA_LIBS version: 14 updated: 2023/01/11 04:05:23
5262dnl ----------------
5263dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
5264dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
5265AC_DEFUN([CF_X_ATHENA_LIBS],
5266[AC_REQUIRE([CF_X_TOOLKIT])
5267cf_x_athena_root=ifelse([$1],,Xaw,[$1])
5268cf_x_athena_lib=""
5269
5270for cf_path in default \
5271	/usr/contrib/X11R6 \
5272	/usr/contrib/X11R5 \
5273	/usr/lib/X11R5 \
5274	/usr/local
5275do
5276	for cf_lib in \
5277		${cf_x_athena_root} \
5278		${cf_x_athena_root}7 \
5279		${cf_x_athena_root}6
5280	do
5281	for cf_libs in \
5282		"-l$cf_lib -lXmu" \
5283		"-l$cf_lib -lXpm -lXmu" \
5284		"-l${cf_lib}_s -lXmu_s"
5285	do
5286		test -n "$cf_x_athena_lib" && break
5287
5288		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
5289		cf_test=XawSimpleMenuAddGlobalActions
5290		test "$cf_path" != default && cf_libs="-L$cf_path/lib $cf_libs"
5291		CF_ADD_LIBS($cf_libs)
5292		AC_MSG_CHECKING(for $cf_test in $cf_libs)
5293		AC_TRY_LINK([
5294$ac_includes_default
5295#include <X11/Intrinsic.h>
5296#include <X11/$cf_x_athena_root/SimpleMenu.h>
5297],[
5298$cf_test((XtAppContext) 0)],
5299			[cf_result=yes],
5300			[cf_result=no])
5301		AC_MSG_RESULT($cf_result)
5302		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
5303
5304		if test "$cf_result" = yes ; then
5305			cf_x_athena_lib="$cf_libs"
5306			break
5307		fi
5308	done # cf_libs
5309		test -n "$cf_x_athena_lib" && break
5310	done # cf_lib
5311done
5312
5313if test -z "$cf_x_athena_lib" ; then
5314	AC_MSG_ERROR(
5315[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
5316fi
5317
5318CF_ADD_LIBS($cf_x_athena_lib)
5319CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
5320AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
5321])
5322dnl ---------------------------------------------------------------------------
5323dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
5324dnl --------
5325AC_DEFUN([CF_X_EXT],[
5326CF_TRY_PKG_CONFIG(Xext,,[
5327	AC_CHECK_LIB(Xext,XextCreateExtension,
5328		[CF_ADD_LIB(Xext)])])
5329])dnl
5330dnl ---------------------------------------------------------------------------
5331dnl CF_X_EXT_DOUBLE_BUFFER version: 1 updated: 2019/07/18 21:09:40
5332dnl ----------------------
5333AC_DEFUN([CF_X_EXT_DOUBLE_BUFFER],[
5334AC_REQUIRE([CF_X_EXT])
5335AC_CHECK_HEADER(X11/extensions/Xdbe.h,
5336	AC_DEFINE(HAVE_X11_EXTENSIONS_XDBE_H,1,[Define to 1 if we have X11/extensions/Xdbe.h])
5337	AC_CHECK_FUNC(XdbeSwapBuffers,
5338				  [AC_DEFINE(HAVE_XDBESWAPBUFFERS,1,[Define to 1 if we have XdbeSwapBuffers])
5339				   cf_x_ext_double_buffer=yes]))
5340])dnl
5341dnl ---------------------------------------------------------------------------
5342dnl CF_X_FONTCONFIG version: 8 updated: 2024/11/25 04:10:12
5343dnl ---------------
5344dnl Check for fontconfig library, a dependency of the X FreeType library.
5345AC_DEFUN([CF_X_FONTCONFIG],
5346[
5347AC_REQUIRE([CF_X_FREETYPE])
5348
5349if test "$cf_cv_found_freetype" = yes ; then
5350AC_CACHE_CHECK(for usable Xft/fontconfig package,cf_cv_xft_compat,[
5351AC_TRY_LINK([
5352#include <X11/Xlib.h>
5353#include <X11/Xft/Xft.h>
5354],[
5355	XftPattern *pat = 0;
5356	XftPatternBuild(pat,
5357					XFT_FAMILY, XftTypeString, "mono",
5358					(void *) 0);
5359],[cf_cv_xft_compat=yes],[cf_cv_xft_compat=no])
5360])
5361
5362if test "$cf_cv_xft_compat" = no
5363then
5364	# workaround for broken ".pc" files used for Xft.
5365	case "$cf_cv_x_freetype_libs" in
5366	(*-lfontconfig*)
5367		;;
5368	(*)
5369		CF_VERBOSE(work around broken package)
5370		cf_save_fontconfig="$LIBS"
5371		CF_TRY_PKG_CONFIG(fontconfig,[
5372				CF_ADD_CFLAGS($cf_pkgconfig_incs)
5373				LIBS="$cf_save_fontconfig"
5374				CF_ADD_LIB_AFTER(-lXft,$cf_pkgconfig_libs)
5375			],[
5376				CF_ADD_LIB_AFTER(-lXft,-lfontconfig)
5377			])
5378		;;
5379	esac
5380fi
5381fi
5382])dnl
5383dnl ---------------------------------------------------------------------------
5384dnl CF_X_FREETYPE version: 28 updated: 2020/03/10 18:53:47
5385dnl -------------
5386dnl Check for X FreeType headers and libraries (XFree86 4.x, etc).
5387dnl
5388dnl First check for the appropriate config program, since the developers for
5389dnl these libraries change their configuration (and config program) more or
5390dnl less randomly.  If we cannot find the config program, do not bother trying
5391dnl to guess the latest variation of include/lib directories.
5392dnl
5393dnl If either or both of these configure-script options are not given, rely on
5394dnl the output of the config program to provide the cflags/libs options:
5395dnl	--with-freetype-cflags
5396dnl	--with-freetype-libs
5397AC_DEFUN([CF_X_FREETYPE],
5398[
5399AC_REQUIRE([CF_PKG_CONFIG])
5400
5401cf_cv_x_freetype_incs=no
5402cf_cv_x_freetype_libs=no
5403cf_extra_freetype_libs=
5404FREETYPE_CONFIG=none
5405FREETYPE_PARAMS=
5406
5407AC_MSG_CHECKING(for FreeType configuration script)
5408AC_ARG_WITH(freetype-config,
5409	[  --with-freetype-config  configure script to use for FreeType],
5410	[cf_cv_x_freetype_cfgs="$withval"],
5411	[cf_cv_x_freetype_cfgs=auto])
5412test -z $cf_cv_x_freetype_cfgs && cf_cv_x_freetype_cfgs=auto
5413test $cf_cv_x_freetype_cfgs = no && cf_cv_x_freetype_cfgs=none
5414AC_MSG_RESULT($cf_cv_x_freetype_cfgs)
5415
5416case $cf_cv_x_freetype_cfgs in
5417(none)
5418	AC_MSG_CHECKING(if you specified -D/-I options for FreeType)
5419	AC_ARG_WITH(freetype-cflags,
5420		[  --with-freetype-cflags  -D/-I options for compiling with FreeType],
5421		[cf_cv_x_freetype_incs="$with_freetype_cflags"],
5422		[cf_cv_x_freetype_incs=no])
5423	AC_MSG_RESULT($cf_cv_x_freetype_incs)
5424
5425	AC_MSG_CHECKING(if you specified -L/-l options for FreeType)
5426	AC_ARG_WITH(freetype-libs,
5427		[  --with-freetype-libs    -L/-l options to link FreeType],
5428		[cf_cv_x_freetype_libs="$with_freetype_libs"],
5429		[cf_cv_x_freetype_libs=no])
5430	AC_MSG_RESULT($cf_cv_x_freetype_libs)
5431	;;
5432(auto)
5433	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
5434		FREETYPE_CONFIG=$PKG_CONFIG
5435		FREETYPE_PARAMS=xft
5436	else
5437		AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, none)
5438		if test "$FREETYPE_CONFIG" != none; then
5439			FREETYPE_CONFIG=$FREETYPE_CONFIG
5440			cf_extra_freetype_libs="-lXft"
5441		else
5442			AC_PATH_PROG(FREETYPE_OLD_CONFIG, xft-config, none)
5443			if test "$FREETYPE_OLD_CONFIG" != none; then
5444				FREETYPE_CONFIG=$FREETYPE_OLD_CONFIG
5445			fi
5446		fi
5447	fi
5448	;;
5449(pkg*)
5450	if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists xft; then
5451		FREETYPE_CONFIG=$cf_cv_x_freetype_cfgs
5452		FREETYPE_PARAMS=xft
5453	else
5454		AC_MSG_WARN(cannot find pkg-config for Xft)
5455	fi
5456	;;
5457(*)
5458	AC_PATH_PROG(FREETYPE_XFT_CONFIG, $cf_cv_x_freetype_cfgs, none)
5459	if test "$FREETYPE_XFT_CONFIG" != none; then
5460		FREETYPE_CONFIG=$FREETYPE_XFT_CONFIG
5461	else
5462		AC_MSG_WARN(cannot find config script for Xft)
5463	fi
5464	;;
5465esac
5466
5467if test "$FREETYPE_CONFIG" != none ; then
5468	AC_MSG_CHECKING(for FreeType config)
5469	AC_MSG_RESULT($FREETYPE_CONFIG $FREETYPE_PARAMS)
5470
5471	if test "$cf_cv_x_freetype_incs" = no ; then
5472		AC_MSG_CHECKING(for $FREETYPE_CONFIG cflags)
5473		cf_cv_x_freetype_incs="`$FREETYPE_CONFIG $FREETYPE_PARAMS --cflags 2>/dev/null`"
5474		AC_MSG_RESULT($cf_cv_x_freetype_incs)
5475	fi
5476
5477	if test "$cf_cv_x_freetype_libs" = no ; then
5478		AC_MSG_CHECKING(for $FREETYPE_CONFIG libs)
5479		cf_cv_x_freetype_libs="$cf_extra_freetype_libs `$FREETYPE_CONFIG $FREETYPE_PARAMS --libs 2>/dev/null`"
5480		AC_MSG_RESULT($cf_cv_x_freetype_libs)
5481	fi
5482fi
5483
5484if test "$cf_cv_x_freetype_incs" = no ; then
5485	cf_cv_x_freetype_incs=
5486fi
5487
5488if test "$cf_cv_x_freetype_libs" = no ; then
5489	cf_cv_x_freetype_libs=-lXft
5490fi
5491
5492AC_MSG_CHECKING(if we can link with FreeType libraries)
5493
5494cf_save_LIBS="$LIBS"
5495cf_save_INCS="$CPPFLAGS"
5496
5497CF_ADD_LIBS($cf_cv_x_freetype_libs)
5498CPPFLAGS="$CPPFLAGS $cf_cv_x_freetype_incs"
5499
5500AC_TRY_LINK([
5501#include <X11/Xlib.h>
5502#include <X11/extensions/Xrender.h>
5503#include <X11/Xft/Xft.h>],[
5504	XftPattern  *pat = XftNameParse ("name"); (void)pat],
5505	[cf_cv_found_freetype=yes],
5506	[cf_cv_found_freetype=no])
5507AC_MSG_RESULT($cf_cv_found_freetype)
5508
5509LIBS="$cf_save_LIBS"
5510CPPFLAGS="$cf_save_INCS"
5511
5512if test "$cf_cv_found_freetype" = yes ; then
5513	CF_ADD_LIBS($cf_cv_x_freetype_libs)
5514	CF_ADD_CFLAGS($cf_cv_x_freetype_incs)
5515	AC_DEFINE(XRENDERFONT,1,[Define to 1 if we can/should link with FreeType libraries])
5516
5517AC_CHECK_FUNCS( \
5518	XftDrawCharSpec \
5519	XftDrawSetClip \
5520	XftDrawSetClipRectangles \
5521)
5522
5523else
5524	AC_MSG_WARN(No libraries found for FreeType)
5525	CPPFLAGS=`echo "$CPPFLAGS" | sed -e s/-DXRENDERFONT//`
5526fi
5527
5528# FIXME: revisit this if needed
5529AC_SUBST(HAVE_TYPE_FCCHAR32)
5530AC_SUBST(HAVE_TYPE_XFTCHARSPEC)
5531])
5532dnl ---------------------------------------------------------------------------
5533dnl CF_X_TOOLKIT version: 27 updated: 2023/01/11 04:05:23
5534dnl ------------
5535dnl Check for X Toolkit libraries
5536AC_DEFUN([CF_X_TOOLKIT],
5537[
5538AC_REQUIRE([AC_PATH_XTRA])
5539AC_REQUIRE([CF_CHECK_CACHE])
5540
5541# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new) (and
5542# in some cases has installed dummy files in the former, other cases replaced
5543# it with a link to the new location).  This complicates the configure script.
5544# Check for that pitfall, and recover using pkg-config
5545#
5546# If none of these are set, the configuration is almost certainly broken.
5547if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
5548then
5549	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
5550	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
5551	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
5552	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
5553else
5554	LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
5555fi
5556
5557cf_have_X_LIBS=no
5558
5559CF_TRY_PKG_CONFIG(xt,[
5560
5561	case "x$LIBS" in
5562	(*-lX11*)
5563		;;
5564	(*)
5565# we have an "xt" package, but it may omit Xt's dependency on X11
5566AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
5567AC_TRY_LINK([
5568$ac_includes_default
5569#include <X11/Xlib.h>
5570],[
5571	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
5572	int rc2 = XClearWindow((Display*) 0, (Window) 0);
5573	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
5574	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
5575],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
5576		if test "$cf_cv_xt_x11_compat" = no
5577		then
5578			CF_VERBOSE(work around broken X11 dependency)
5579			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
5580			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
5581		fi
5582		;;
5583	esac
5584
5585AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
5586AC_TRY_LINK([
5587$ac_includes_default
5588#include <X11/Shell.h>
5589],[int num = IceConnectionNumber(0); (void) num
5590],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
5591
5592	if test "$cf_cv_xt_ice_compat" = no
5593	then
5594		# workaround for broken ".pc" files used for X Toolkit.
5595		case "x$X_PRE_LIBS" in
5596		(*-lICE*)
5597			case "x$LIBS" in
5598			(*-lICE*)
5599				;;
5600			(*)
5601				CF_VERBOSE(work around broken ICE dependency)
5602				CF_TRY_PKG_CONFIG(ice,
5603					[CF_TRY_PKG_CONFIG(sm)],
5604					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
5605				;;
5606			esac
5607			;;
5608		esac
5609	fi
5610
5611	cf_have_X_LIBS=yes
5612],[
5613
5614	LDFLAGS="$X_LIBS $LDFLAGS"
5615	CF_CHECK_CFLAGS($X_CFLAGS)
5616
5617	AC_CHECK_FUNC(XOpenDisplay,,[
5618	AC_CHECK_LIB(X11,XOpenDisplay,
5619		[CF_ADD_LIB(X11)])])
5620
5621	AC_CHECK_FUNC(XtAppInitialize,,[
5622	AC_CHECK_LIB(Xt, XtAppInitialize,
5623		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
5624		 cf_have_X_LIBS=Xt
5625		 LIBS="-lXt $LIBS"])])
5626])
5627
5628if test "$cf_have_X_LIBS" = no ; then
5629	AC_MSG_WARN(
5630[Unable to successfully link X Toolkit library (-lXt) with
5631test program.  You will have to check and add the proper libraries by hand
5632to makefile.])
5633fi
5634])dnl
5635dnl ---------------------------------------------------------------------------
5636dnl CF__GRANTPT_BODY version: 6 updated: 2021/06/07 17:39:17
5637dnl ----------------
5638dnl Body for workability check of grantpt.
5639define([CF__GRANTPT_BODY],[
5640	int code = 0;
5641	int pty;
5642	int tty;
5643	char *slave;
5644	struct termios tio;
5645
5646	(void)tio;
5647	signal(SIGALRM, my_timeout);
5648
5649	if (alarm(2) == 9)
5650		failed(9);
5651	else if ((pty = posix_openpt(O_RDWR)) < 0)
5652		failed(1);
5653	else if (grantpt(pty) < 0)
5654		failed(2);
5655	else if (unlockpt(pty) < 0)
5656		failed(3);
5657	else if ((slave = ptsname(pty)) == 0)
5658		failed(4);
5659#if (CONFTEST == 3) || defined(CONFTEST_isatty)
5660	else if (!isatty(pty))
5661		failed(4);
5662#endif
5663#if CONFTEST >= 4
5664    else if (tcgetattr(pty, &tio) < 0)
5665		failed(20);
5666    else if (tcsetattr(pty, TCSAFLUSH, &tio) < 0)
5667		failed(21);
5668#endif
5669	/* BSD posix_openpt does not treat pty as a terminal until slave is opened.
5670	 * Linux does treat it that way.
5671	 */
5672	else if ((tty = open(slave, O_RDWR)) < 0)
5673		failed(5);
5674#ifdef CONFTEST
5675#ifdef I_PUSH
5676#if (CONFTEST == 0) || defined(CONFTEST_ptem)
5677    else if (ioctl(tty, I_PUSH, "ptem") < 0)
5678		failed(10);
5679#endif
5680#if (CONFTEST == 1) || defined(CONFTEST_ldterm)
5681    else if (ioctl(tty, I_PUSH, "ldterm") < 0)
5682		failed(11);
5683#endif
5684#if (CONFTEST == 2) || defined(CONFTEST_ttcompat)
5685    else if (ioctl(tty, I_PUSH, "ttcompat") < 0)
5686		failed(12);
5687#endif
5688#endif /* I_PUSH */
5689#if CONFTEST >= 5
5690    else if (tcgetattr(tty, &tio) < 0)
5691		failed(30);
5692    else if (tcsetattr(tty, TCSAFLUSH, &tio) < 0)
5693		failed(31);
5694#endif
5695#endif /* CONFTEST */
5696    (void) tty;
5697	${cf_cv_main_return:-return}(code);
5698])
5699dnl ---------------------------------------------------------------------------
5700dnl CF__GRANTPT_HEAD version: 4 updated: 2020/03/10 18:53:47
5701dnl ----------------
5702dnl Headers for workability check of grantpt.
5703define([CF__GRANTPT_HEAD],[
5704#include <stdlib.h>
5705#include <stdio.h>
5706#include <termios.h>
5707#include <unistd.h>
5708#include <signal.h>
5709#include <fcntl.h>
5710#include <errno.h>
5711
5712#ifndef HAVE_POSIX_OPENPT
5713#undef posix_openpt
5714#define posix_openpt(mode) open("/dev/ptmx", mode)
5715#endif
5716
5717#ifdef HAVE_STROPTS_H
5718#include <stropts.h>
5719#endif
5720
5721static void failed(int code)
5722{
5723	perror("conftest");
5724	exit(code);
5725}
5726
5727static void my_timeout(int sig)
5728{
5729	(void)sig;
5730	exit(99);
5731}
5732])
5733dnl ---------------------------------------------------------------------------
5734dnl CF__XOPEN_SOURCE_BODY version: 2 updated: 2023/02/18 17:41:25
5735dnl ---------------------
5736dnl body of test when test-compiling for _XOPEN_SOURCE check
5737define([CF__XOPEN_SOURCE_BODY],
5738[
5739#ifndef _XOPEN_SOURCE
5740#error _XOPEN_SOURCE is not defined
5741#endif
5742])
5743dnl ---------------------------------------------------------------------------
5744dnl CF__XOPEN_SOURCE_HEAD version: 2 updated: 2023/02/18 17:41:25
5745dnl ---------------------
5746dnl headers to include when test-compiling for _XOPEN_SOURCE check
5747define([CF__XOPEN_SOURCE_HEAD],
5748[
5749$ac_includes_default
5750])
5751