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