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