1dnl $LynxId: aclocal.m4,v 1.304 2021/07/10 16:22:27 tom Exp $
2dnl Macros for auto-configure script.
3dnl by Thomas E. Dickey <dickey@invisible-island.net>
4dnl and Jim Spath <jspath@mail.bcpl.lib.md.us>
5dnl and Philippe De Muyter <phdm@macqel.be>
6dnl
7dnl Created: 1997/01/28
8dnl
9dnl The autoconf used in Lynx development is GNU autoconf 2.13 or 2.52, patched
10dnl by Thomas Dickey.  See your local GNU archives, and this URL:
11dnl https://invisible-island.net/autoconf/autoconf.html
12dnl
13dnl ---------------------------------------------------------------------------
14dnl
15dnl Copyright 1997-2020,2021 by Thomas E. Dickey
16dnl
17dnl Permission to use, copy, modify, and distribute this software and its
18dnl documentation for any purpose and without fee is hereby granted,
19dnl provided that the above copyright notice appear in all copies and that
20dnl both that copyright notice and this permission notice appear in
21dnl supporting documentation, and that the name of the above listed
22dnl copyright holder(s) not be used in advertising or publicity pertaining
23dnl to distribution of the software without specific, written prior
24dnl permission.
25dnl
26dnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
27dnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
28dnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
29dnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
30dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
31dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
32dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
33dnl
34dnl ---------------------------------------------------------------------------
35dnl A few macros (the AM_xxx ones) are originally from gettext 0.10.35 (but
36dnl are modified), and are part of this file due to mechanical limitations of
37dnl autoconf.
38dnl ---------------------------------------------------------------------------
39dnl See
40dnl     https://invisible-island.net/autoconf/autoconf.html
41dnl     https://invisible-island.net/autoconf/my-autoconf.html
42dnl ---------------------------------------------------------------------------
43dnl ---------------------------------------------------------------------------
44dnl AM_GNU_GETTEXT version: 15 updated: 2021/01/02 09:31:20
45dnl --------------
46dnl Usage: Just like AM_WITH_NLS, which see.
47AC_DEFUN([AM_GNU_GETTEXT],
48  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
49   AC_REQUIRE([AC_CANONICAL_HOST])dnl
50   AC_REQUIRE([AC_PROG_RANLIB])dnl
51   AC_REQUIRE([AC_HEADER_STDC])dnl
52   AC_REQUIRE([AC_C_INLINE])dnl
53   AC_REQUIRE([AC_TYPE_OFF_T])dnl
54   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
55   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
56   AC_REQUIRE([AC_FUNC_MMAP])dnl
57   AC_REQUIRE([jm_GLIBC21])dnl
58   AC_REQUIRE([CF_PROG_CC])dnl
59
60   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
61stdlib.h string.h unistd.h sys/param.h])
62   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
63getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
64strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
65
66   AM_ICONV
67   AM_LANGINFO_CODESET
68   AM_LC_MESSAGES
69   AM_WITH_NLS([$1],[$2],[$3],[$4])
70
71   if test "x$CATOBJEXT" != "x"; then
72     if test "x$ALL_LINGUAS" = "x"; then
73       LINGUAS=
74     else
75       AC_MSG_CHECKING(for catalogs to be installed)
76       NEW_LINGUAS=
77       for presentlang in $ALL_LINGUAS; do
78         useit=no
79         for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
80           # Use the presentlang catalog if desiredlang is
81           #   a. equal to presentlang, or
82           #   b. a variant of presentlang (because in this case,
83           #      presentlang can be used as a fallback for messages
84           #      which are not translated in the desiredlang catalog).
85           case "$desiredlang" in
86             ("$presentlang"*) useit=yes;;
87           esac
88         done
89         if test "$useit" = yes; then
90           NEW_LINGUAS="$NEW_LINGUAS $presentlang"
91         fi
92       done
93       LINGUAS=$NEW_LINGUAS
94       AC_MSG_RESULT($LINGUAS)
95     fi
96
97     dnl Construct list of names of catalog files to be constructed.
98     if test -n "$LINGUAS"; then
99       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
100     fi
101   fi
102
103   dnl Enable libtool support if the surrounding package wishes it.
104   INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
105   AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
106])dnl
107dnl ---------------------------------------------------------------------------
108dnl AM_ICONV version: 12 updated: 2007/07/30 19:12:03
109dnl --------
110dnl Inserted as requested by gettext 0.10.40
111dnl File from /usr/share/aclocal
112dnl iconv.m4
113dnl ====================
114dnl serial AM2
115dnl
116dnl From Bruno Haible.
117dnl
118dnl ====================
119dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
120dnl range of locations searched.  Retain the same cache-variable naming to
121dnl allow reuse with the other gettext macros -Thomas E Dickey
122AC_DEFUN([AM_ICONV],
123[
124  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
125  dnl those with the standalone portable GNU libiconv installed).
126
127  AC_ARG_WITH([libiconv-prefix],
128[  --with-libiconv-prefix=DIR
129                          search for libiconv in DIR/include and DIR/lib], [
130    CF_ADD_OPTIONAL_PATH($withval, libiconv)
131   ])
132
133  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
134    CF_FIND_LINKAGE(CF__ICONV_HEAD,
135      CF__ICONV_BODY,
136      iconv,
137      am_cv_func_iconv=yes,
138      am_cv_func_iconv=["no, consider installing GNU libiconv"])])
139
140  if test "$am_cv_func_iconv" = yes; then
141    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
142
143    AC_CACHE_CHECK([if the declaration of iconv() needs const.],
144		   am_cv_proto_iconv_const,[
145      AC_TRY_COMPILE(CF__ICONV_HEAD [
146extern
147#ifdef __cplusplus
148"C"
149#endif
150#if defined(__STDC__) || defined(__cplusplus)
151size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
152#else
153size_t iconv();
154#endif
155],[], am_cv_proto_iconv_const=no,
156      am_cv_proto_iconv_const=yes)])
157
158    if test "$am_cv_proto_iconv_const" = yes ; then
159      am_cv_proto_iconv_arg1="const"
160    else
161      am_cv_proto_iconv_arg1=""
162    fi
163
164    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
165      [Define as const if the declaration of iconv() needs const.])
166  fi
167
168  LIBICONV=
169  if test "$cf_cv_find_linkage_iconv" = yes; then
170    CF_ADD_INCDIR($cf_cv_header_path_iconv)
171    if test -n "$cf_cv_library_file_iconv" ; then
172      LIBICONV="-liconv"
173      CF_ADD_LIBDIR($cf_cv_library_path_iconv)
174    fi
175  fi
176
177  AC_SUBST(LIBICONV)
178])dnl
179dnl ---------------------------------------------------------------------------
180dnl AM_LANGINFO_CODESET version: 6 updated: 2021/01/01 16:53:59
181dnl -------------------
182dnl Inserted as requested by gettext 0.10.40
183dnl File from /usr/share/aclocal
184dnl codeset.m4
185dnl ====================
186dnl serial AM1
187dnl
188dnl From Bruno Haible.
189AC_DEFUN([AM_LANGINFO_CODESET],
190[
191AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
192	[AC_TRY_LINK([#include <langinfo.h>],
193	[char* cs = nl_langinfo(CODESET); (void)cs],
194	am_cv_langinfo_codeset=yes,
195	am_cv_langinfo_codeset=no)
196	])
197	if test "$am_cv_langinfo_codeset" = yes; then
198		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
199		[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
200	fi
201])dnl
202dnl ---------------------------------------------------------------------------
203dnl AM_LC_MESSAGES version: 6 updated: 2021/01/02 09:31:20
204dnl --------------
205dnl Inserted as requested by gettext 0.10.40
206dnl File from /usr/share/aclocal
207dnl lcmessage.m4
208dnl ====================
209dnl Check whether LC_MESSAGES is available in <locale.h>.
210dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
211dnl
212dnl This file can be copied and used freely without restrictions.  It can
213dnl be used in projects which are not available under the GNU General Public
214dnl License or the GNU Library General Public License but which still want
215dnl to provide support for the GNU gettext functionality.
216dnl Please note that the actual code of the GNU gettext library is covered
217dnl by the GNU Library General Public License, and the rest of the GNU
218dnl gettext package package is covered by the GNU General Public License.
219dnl They are *not* in the public domain.
220dnl
221dnl serial 2
222dnl
223AC_DEFUN([AM_LC_MESSAGES],
224[if test "$ac_cv_header_locale_h" = yes; then
225	AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
226		[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
227		am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
228	if test "$am_cv_val_LC_MESSAGES" = yes; then
229		AC_DEFINE(HAVE_LC_MESSAGES, 1,
230		[Define if your <locale.h> file defines LC_MESSAGES.])
231	fi
232fi])dnl
233dnl ---------------------------------------------------------------------------
234dnl AM_PATH_PROG_WITH_TEST version: 10 updated: 2021/01/02 09:31:20
235dnl ----------------------
236dnl Inserted as requested by gettext 0.10.40
237dnl File from /usr/share/aclocal
238dnl progtest.m4
239dnl ====================
240dnl Search path for a program which passes the given test.
241dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
242dnl
243dnl This file can be copied and used freely without restrictions.  It can
244dnl be used in projects which are not available under the GNU General Public
245dnl License or the GNU Library General Public License but which still want
246dnl to provide support for the GNU gettext functionality.
247dnl Please note that the actual code of the GNU gettext library is covered
248dnl by the GNU Library General Public License, and the rest of the GNU
249dnl gettext package package is covered by the GNU General Public License.
250dnl They are *not* in the public domain.
251dnl
252dnl serial 2
253dnl
254dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
255dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
256AC_DEFUN([AM_PATH_PROG_WITH_TEST],
257[# Extract the first word of "$2", so it can be a program name with args.
258AC_REQUIRE([CF_PATHSEP])
259set dummy $2; ac_word=[$]2
260AC_MSG_CHECKING([for $ac_word])
261AC_CACHE_VAL(ac_cv_path_$1,
262[case "[$]$1" in
263  ([[\\/]*|?:[\\/]]*)
264  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
265  ;;
266  (*)
267  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
268  for ac_dir in ifelse([$5], , $PATH, [$5]); do
269    test -z "$ac_dir" && ac_dir=.
270    if test -f "$ac_dir/$ac_word$ac_exeext" ; then
271      if [$3]; then
272	ac_cv_path_$1="$ac_dir/$ac_word$ac_exeext"
273	break
274      fi
275    fi
276  done
277  IFS="$ac_save_ifs"
278dnl If no 4th arg is given, leave the cache variable unset,
279dnl so AC_PATH_PROGS will keep looking.
280ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
281])dnl
282  ;;
283esac])dnl
284$1="$ac_cv_path_$1"
285if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
286  AC_MSG_RESULT([$]$1)
287else
288  AC_MSG_RESULT(no)
289fi
290AC_SUBST($1)dnl
291])dnl
292dnl ---------------------------------------------------------------------------
293dnl AM_WITH_NLS version: 31 updated: 2021/01/04 17:48:08
294dnl -----------
295dnl Inserted as requested by gettext 0.10.40
296dnl File from /usr/share/aclocal
297dnl gettext.m4
298dnl ====================
299dnl Macro to add for using GNU gettext.
300dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
301dnl ====================
302dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
303dnl range of locations searched.  Retain the same cache-variable naming to
304dnl allow reuse with the other gettext macros -Thomas E Dickey
305dnl ====================
306dnl
307dnl This file can be copied and used freely without restrictions.  It can
308dnl be used in projects which are not available under the GNU General Public
309dnl License or the GNU Library General Public License but which still want
310dnl to provide support for the GNU gettext functionality.
311dnl Please note that the actual code of the GNU gettext library is covered
312dnl by the GNU Library General Public License, and the rest of the GNU
313dnl gettext package package is covered by the GNU General Public License.
314dnl They are *not* in the public domain.
315dnl
316dnl serial 10
317dnl
318dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
319dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
320dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
321dnl    depending on --{enable,disable}-{shared,static} and on the presence of
322dnl    AM-DISABLE-SHARED). Otherwise, a static library
323dnl    $(top_builddir)/intl/libintl.a will be created.
324dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
325dnl    implementations (in libc or libintl) without the ngettext() function
326dnl    will be ignored.
327dnl LIBDIR is used to find the intl libraries.  If empty,
328dnl    the value `$(top_builddir)/intl/' is used.
329dnl ENABLED is used to control the default for the related --enable-nls, since
330dnl    not all application developers want this feature by default, e.g., lynx.
331dnl
332dnl The result of the configuration is one of three cases:
333dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
334dnl    and used.
335dnl    Catalog format: GNU --> install in $(datadir)
336dnl    Catalog extension: .mo after installation, .gmo in source tree
337dnl 2) GNU gettext has been found in the system's C library.
338dnl    Catalog format: GNU --> install in $(datadir)
339dnl    Catalog extension: .mo after installation, .gmo in source tree
340dnl 3) No internationalization, always use English msgid.
341dnl    Catalog format: none
342dnl    Catalog extension: none
343dnl The use of .gmo is historical (it was needed to avoid overwriting the
344dnl GNU format catalogs when building on a platform with an X/Open gettext),
345dnl but we keep it in order not to force irrelevant filename changes on the
346dnl maintainers.
347dnl
348AC_DEFUN([AM_WITH_NLS],
349[AC_MSG_CHECKING([whether NLS is requested])
350  dnl Default is enabled NLS
351  ifelse([$4],,[
352  AC_ARG_ENABLE(nls,
353    [  --disable-nls           do not use Native Language Support],
354    USE_NLS=$enableval, USE_NLS=yes)],[
355  AC_ARG_ENABLE(nls,
356    [  --enable-nls            use Native Language Support],
357    USE_NLS=$enableval, USE_NLS=no)])
358  AC_MSG_RESULT($USE_NLS)
359  AC_SUBST(USE_NLS)
360
361  BUILD_INCLUDED_LIBINTL=no
362  USE_INCLUDED_LIBINTL=no
363  INTLLIBS=
364
365  dnl If we use NLS figure out what method
366  if test "$USE_NLS" = "yes"; then
367    dnl We need to process the po/ directory.
368    POSUB=po
369    AC_DEFINE(ENABLE_NLS, 1,
370      [Define to 1 if translation of program messages to the user's native language
371 is requested.])
372    AC_MSG_CHECKING([whether included gettext is requested])
373    AC_ARG_WITH(included-gettext,
374      [  --with-included-gettext use the GNU gettext library included here],
375      nls_cv_force_use_gnu_gettext=$withval,
376      nls_cv_force_use_gnu_gettext=no)
377    AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
378
379    nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
380    if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
381      dnl User does not insist on using GNU NLS library.  Figure out what
382      dnl to use.  If GNU gettext is available we use this.  Else we may have
383      dnl to fall back to GNU NLS library.
384      CATOBJEXT=NONE
385
386      dnl Save these (possibly-set) variables for reference.  If the user
387      dnl overrode these to provide full pathnames, then warn if not actually
388      dnl GNU gettext, but do not override their values.  Also, if they were
389      dnl overridden, suppress the part of the library test which prevents it
390      dnl from finding anything other than GNU gettext.  Doing this also
391      dnl suppresses a bogus search for the intl library.
392      cf_save_msgfmt_path="$MSGFMT"
393      cf_save_xgettext_path="$XGETTEXT"
394
395      dnl Search for GNU msgfmt in the PATH.
396      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
397          ["$ac_dir/$ac_word" --statistics /dev/null >/dev/null 2>&1], :)
398      AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
399      AC_SUBST(MSGFMT)
400
401      dnl Search for GNU xgettext in the PATH.
402      AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
403          ["$ac_dir/$ac_word" --omit-header /dev/null >/dev/null 2>&1], :)
404
405      cf_save_OPTS_1="$CPPFLAGS"
406      if test "x$cf_save_msgfmt_path" = "x$MSGFMT" && \
407         test "x$cf_save_xgettext_path" = "x$XGETTEXT" ; then
408          CF_ADD_CFLAGS(-DIGNORE_MSGFMT_HACK)
409      fi
410
411      cf_save_LIBS_1="$LIBS"
412      CF_ADD_LIBS($LIBICONV)
413
414      CF_FIND_LINKAGE(CF__INTL_HEAD,
415        CF__INTL_BODY($2),
416        intl,
417        cf_cv_func_gettext=yes,
418        cf_cv_func_gettext=no)
419
420      AC_MSG_CHECKING([for libintl.h and gettext()])
421      AC_MSG_RESULT($cf_cv_func_gettext)
422
423      LIBS="$cf_save_LIBS_1"
424      CPPFLAGS="$cf_save_OPTS_1"
425
426      if test "$cf_cv_func_gettext" = yes ; then
427        AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have libintl.h])
428
429        dnl If an already present or preinstalled GNU gettext() is found,
430        dnl use it.  But if this macro is used in GNU gettext, and GNU
431        dnl gettext is already preinstalled in libintl, we update this
432        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
433        if test "$PACKAGE" != gettext; then
434          AC_DEFINE(HAVE_GETTEXT, 1,
435              [Define if the GNU gettext() function is already present or preinstalled.])
436
437          CF_ADD_INCDIR($cf_cv_header_path_intl)
438
439          if test -n "$cf_cv_library_file_intl" ; then
440            dnl If iconv() is in a separate libiconv library, then anyone
441            dnl linking with libintl{.a,.so} also needs to link with
442            dnl libiconv.
443            INTLLIBS="$cf_cv_library_file_intl $LIBICONV"
444            CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
445          fi
446
447          gt_save_LIBS="$LIBS"
448          LIBS="$LIBS $INTLLIBS"
449          AC_CHECK_FUNCS(dcgettext)
450          LIBS="$gt_save_LIBS"
451
452          CATOBJEXT=.gmo
453        fi
454      elif test -z "$MSGFMT" || test -z "$XGETTEXT" ; then
455        AC_MSG_WARN(disabling NLS feature)
456        sed -e /ENABLE_NLS/d confdefs.h >confdefs.tmp
457        mv confdefs.tmp confdefs.h
458        ALL_LINGUAS=
459        CATOBJEXT=.ignored
460        MSGFMT=":"
461        GMSGFMT=":"
462        XGETTEXT=":"
463        POSUB=
464        BUILD_INCLUDED_LIBINTL=no
465        USE_INCLUDED_LIBINTL=no
466        USE_NLS=no
467        nls_cv_use_gnu_gettext=no
468      fi
469
470      if test "$CATOBJEXT" = "NONE"; then
471        dnl GNU gettext is not found in the C library.
472        dnl Fall back on GNU gettext library.
473        nls_cv_use_gnu_gettext=maybe
474      fi
475    fi
476
477    if test "$nls_cv_use_gnu_gettext" != "no"; then
478      CATOBJEXT=.gmo
479      if test -f "$srcdir/intl/libintl.h" ; then
480        dnl Mark actions used to generate GNU NLS library.
481        INTLOBJS="\$(GETTOBJS)"
482        BUILD_INCLUDED_LIBINTL=yes
483        USE_INCLUDED_LIBINTL=yes
484        INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
485        LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
486      elif test "$nls_cv_use_gnu_gettext" = "yes"; then
487        nls_cv_use_gnu_gettext=no
488        AC_MSG_WARN(no NLS library is packaged with this application)
489      fi
490    fi
491
492    dnl Test whether we really found GNU msgfmt.
493    if test "$GMSGFMT" != ":"; then
494      if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
495        : ;
496      else
497        AC_MSG_WARN([found msgfmt program is not GNU msgfmt])
498      fi
499    fi
500
501    dnl Test whether we really found GNU xgettext.
502    if test "$XGETTEXT" != ":"; then
503      if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
504        : ;
505      else
506        AC_MSG_WARN([found xgettext program is not GNU xgettext])
507      fi
508    fi
509  fi
510
511  if test "$XGETTEXT" != ":"; then
512    AC_OUTPUT_COMMANDS(
513     [for ac_file in $CONFIG_FILES; do
514
515        # Support "outfile[:infile[:infile...]]"
516        case "$ac_file" in
517          (*:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
518        esac
519
520        # PO directories have a Makefile.in generated from Makefile.inn.
521        case "$ac_file" in
522        (*/[Mm]akefile.in)
523          # Adjust a relative srcdir.
524          ac_dir="`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`"
525          ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
526          ac_dots="`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`"
527          ac_base="`basename $ac_file .in`"
528          # In autoconf-2.13 it is called $ac_given_srcdir.
529          # In autoconf-2.50 it is called $srcdir.
530          test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
531
532          case "$ac_given_srcdir" in
533            (.)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
534            (/*) top_srcdir="$ac_given_srcdir" ;;
535            (*)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
536          esac
537
538          if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
539            rm -f "$ac_dir/POTFILES"
540            test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
541            sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
542            test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
543            sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
544          fi
545          ;;
546        esac
547      done])
548
549    dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
550    dnl to 'yes' because some of the testsuite requires it.
551    if test "$PACKAGE" = gettext; then
552      BUILD_INCLUDED_LIBINTL=yes
553    fi
554
555    dnl intl/plural.c is generated from intl/plural.y. It requires bison,
556    dnl because plural.y uses bison specific features. It requires at least
557    dnl bison-1.26 because earlier versions generate a plural.c that doesn't
558    dnl compile.
559    dnl bison is only needed for the maintainer (who touches plural.y). But in
560    dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
561    dnl the rule in general Makefile. Now, some people carelessly touch the
562    dnl files or have a broken "make" program, hence the plural.c rule will
563    dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
564    dnl present or too old.
565    if test "$nls_cv_use_gnu_gettext" = "yes"; then
566      AC_CHECK_PROGS([INTLBISON], [bison])
567      if test -z "$INTLBISON"; then
568        ac_verc_fail=yes
569      else
570        dnl Found it, now check the version.
571        AC_MSG_CHECKING([version of bison])
572changequote(<<,>>)dnl
573        ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
574        case "$ac_prog_version" in
575          ('') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
576          (1.2[6-9]*|1.[3-9][0-9]*|[2-9].*)
577changequote([,])dnl
578             ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
579          (*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
580        esac
581      AC_MSG_RESULT([$ac_prog_version])
582      fi
583      if test "$ac_verc_fail" = yes; then
584        INTLBISON=:
585      fi
586    fi
587
588    dnl These rules are solely for the distribution goal.  While doing this
589    dnl we only have to keep exactly one list of the available catalogs
590    dnl in configure.in.
591    for lang in $ALL_LINGUAS; do
592      GMOFILES="$GMOFILES $lang.gmo"
593      POFILES="$POFILES $lang.po"
594    done
595  fi
596
597  dnl Make all variables we use known to autoconf.
598  AC_SUBST(BUILD_INCLUDED_LIBINTL)
599  AC_SUBST(USE_INCLUDED_LIBINTL)
600  AC_SUBST(CATALOGS)
601  AC_SUBST(CATOBJEXT)
602  AC_SUBST(GMOFILES)
603  AC_SUBST(INTLLIBS)
604  AC_SUBST(INTLOBJS)
605  AC_SUBST(POFILES)
606  AC_SUBST(POSUB)
607
608  dnl For backward compatibility. Some configure.ins may be using this.
609  nls_cv_header_intl=
610  nls_cv_header_libgt=
611
612  dnl For backward compatibility. Some Makefiles may be using this.
613  DATADIRNAME=share
614  AC_SUBST(DATADIRNAME)
615
616  dnl For backward compatibility. Some Makefiles may be using this.
617  INSTOBJEXT=.mo
618  AC_SUBST(INSTOBJEXT)
619
620  dnl For backward compatibility. Some Makefiles may be using this.
621  GENCAT=gencat
622  AC_SUBST(GENCAT)
623])dnl
624dnl ---------------------------------------------------------------------------
625dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
626dnl ------------------
627dnl Conditionally generate script according to whether we're using a given autoconf.
628dnl
629dnl $1 = version to compare against
630dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
631dnl $3 = code to use if AC_ACVERSION is older than $1.
632define([CF_ACVERSION_CHECK],
633[
634ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
635ifdef([m4_version_compare],
636[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
637[CF_ACVERSION_COMPARE(
638AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
639AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
640dnl ---------------------------------------------------------------------------
641dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
642dnl --------------------
643dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
644dnl                      MAJOR2, MINOR2, TERNARY2,
645dnl                      PRINTABLE2, not FOUND, FOUND)
646define([CF_ACVERSION_COMPARE],
647[ifelse(builtin([eval], [$2 < $5]), 1,
648[ifelse([$8], , ,[$8])],
649[ifelse([$9], , ,[$9])])])dnl
650dnl ---------------------------------------------------------------------------
651dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15
652dnl -------------
653dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
654dnl $1 = flags to add
655dnl $2 = if given makes this macro verbose.
656dnl
657dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
658dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
659dnl confused by the quotes (which require backslashes to keep them usable).
660AC_DEFUN([CF_ADD_CFLAGS],
661[
662cf_fix_cppflags=no
663cf_new_cflags=
664cf_new_cppflags=
665cf_new_extra_cppflags=
666
667for cf_add_cflags in $1
668do
669case "$cf_fix_cppflags" in
670(no)
671	case "$cf_add_cflags" in
672	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
673		case "$cf_add_cflags" in
674		(-D*)
675			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
676
677			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
678				&& test -z "${cf_tst_cflags}" \
679				&& cf_fix_cppflags=yes
680
681			if test "$cf_fix_cppflags" = yes ; then
682				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
683				continue
684			elif test "${cf_tst_cflags}" = "\"'" ; then
685				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
686				continue
687			fi
688			;;
689		esac
690		case "$CPPFLAGS" in
691		(*$cf_add_cflags)
692			;;
693		(*)
694			case "$cf_add_cflags" in
695			(-D*)
696				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
697				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
698				;;
699			esac
700			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
701			;;
702		esac
703		;;
704	(*)
705		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
706		;;
707	esac
708	;;
709(yes)
710	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
711
712	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
713
714	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
715		&& test -z "${cf_tst_cflags}" \
716		&& cf_fix_cppflags=no
717	;;
718esac
719done
720
721if test -n "$cf_new_cflags" ; then
722	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
723	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
724fi
725
726if test -n "$cf_new_cppflags" ; then
727	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
728	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
729fi
730
731if test -n "$cf_new_extra_cppflags" ; then
732	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
733	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
734fi
735
736AC_SUBST(EXTRA_CPPFLAGS)
737
738])dnl
739dnl ---------------------------------------------------------------------------
740dnl CF_ADD_INCDIR version: 16 updated: 2020/12/31 20:19:42
741dnl -------------
742dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
743dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
744dnl but old versions (and some misinstalled ones) need that.  To make things
745dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
746dnl the include-path).
747AC_DEFUN([CF_ADD_INCDIR],
748[
749if test -n "$1" ; then
750  for cf_add_incdir in $1
751  do
752	while test "$cf_add_incdir" != /usr/include
753	do
754	  if test -d "$cf_add_incdir"
755	  then
756		cf_have_incdir=no
757		if test -n "$CFLAGS$CPPFLAGS" ; then
758		  # a loop is needed to ensure we can add subdirs of existing dirs
759		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
760			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
761			  cf_have_incdir=yes; break
762			fi
763		  done
764		fi
765
766		if test "$cf_have_incdir" = no ; then
767		  if test "$cf_add_incdir" = /usr/local/include ; then
768			if test "$GCC" = yes
769			then
770			  cf_save_CPPFLAGS=$CPPFLAGS
771			  CF_APPEND_TEXT(CPPFLAGS,-I$cf_add_incdir)
772			  AC_TRY_COMPILE([#include <stdio.h>],
773				  [printf("Hello")],
774				  [],
775				  [cf_have_incdir=yes])
776			  CPPFLAGS=$cf_save_CPPFLAGS
777			fi
778		  fi
779		fi
780
781		if test "$cf_have_incdir" = no ; then
782		  CF_VERBOSE(adding $cf_add_incdir to include-path)
783		  ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
784
785		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
786		  test "$cf_top_incdir" = "$cf_add_incdir" && break
787		  cf_add_incdir="$cf_top_incdir"
788		else
789		  break
790		fi
791	  else
792		break
793	  fi
794	done
795  done
796fi
797])dnl
798dnl ---------------------------------------------------------------------------
799dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
800dnl ----------
801dnl Add a library, used to enforce consistency.
802dnl
803dnl $1 = library to add, without the "-l"
804dnl $2 = variable to update (default $LIBS)
805AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
806dnl ---------------------------------------------------------------------------
807dnl CF_ADD_LIBDIR version: 11 updated: 2020/12/31 20:19:42
808dnl -------------
809dnl	Adds to the library-path
810dnl
811dnl	Some machines have trouble with multiple -L options.
812dnl
813dnl $1 is the (list of) directory(s) to add
814dnl $2 is the optional name of the variable to update (default LDFLAGS)
815dnl
816AC_DEFUN([CF_ADD_LIBDIR],
817[
818if test -n "$1" ; then
819	for cf_add_libdir in $1
820	do
821		if test "$cf_add_libdir" = /usr/lib ; then
822			:
823		elif test -d "$cf_add_libdir"
824		then
825			cf_have_libdir=no
826			if test -n "$LDFLAGS$LIBS" ; then
827				# a loop is needed to ensure we can add subdirs of existing dirs
828				for cf_test_libdir in $LDFLAGS $LIBS ; do
829					if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
830						cf_have_libdir=yes; break
831					fi
832				done
833			fi
834			if test "$cf_have_libdir" = no ; then
835				CF_VERBOSE(adding $cf_add_libdir to library-path)
836				ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
837			fi
838		fi
839	done
840fi
841])dnl
842dnl ---------------------------------------------------------------------------
843dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
844dnl -----------
845dnl Add one or more libraries, used to enforce consistency.  Libraries are
846dnl prepended to an existing list, since their dependencies are assumed to
847dnl already exist in the list.
848dnl
849dnl $1 = libraries to add, with the "-l", etc.
850dnl $2 = variable to update (default $LIBS)
851AC_DEFUN([CF_ADD_LIBS],[
852cf_add_libs="[$]ifelse($2,,LIBS,[$2])"
853# reverse order
854cf_add_0lib=
855for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
856# filter duplicates
857for cf_add_1lib in $cf_add_0lib; do
858	for cf_add_2lib in $cf_add_libs; do
859		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
860			cf_add_1lib=
861			break
862		fi
863	done
864	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
865done
866ifelse($2,,LIBS,[$2])="$cf_add_libs"
867])dnl
868dnl ---------------------------------------------------------------------------
869dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
870dnl ----------------
871dnl Add a given library after another, e.g., following the one it satisfies a
872dnl dependency for.
873dnl
874dnl $1 = the first library
875dnl $2 = its dependency
876AC_DEFUN([CF_ADD_LIB_AFTER],[
877CF_VERBOSE(...before $LIBS)
878LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
879CF_VERBOSE(...after  $LIBS)
880])dnl
881dnl ---------------------------------------------------------------------------
882dnl CF_ADD_OPTIONAL_PATH version: 3 updated: 2015/05/10 19:52:14
883dnl --------------------
884dnl Add an optional search-path to the compile/link variables.
885dnl See CF_WITH_PATH
886dnl
887dnl $1 = shell variable containing the result of --with-XXX=[DIR]
888dnl $2 = module to look for.
889AC_DEFUN([CF_ADD_OPTIONAL_PATH],[
890case "$1" in
891(no)
892	;;
893(yes)
894	;;
895(*)
896	CF_ADD_SEARCHPATH([$1], [AC_MSG_ERROR(cannot find $2 under $1)])
897	;;
898esac
899])dnl
900dnl ---------------------------------------------------------------------------
901dnl CF_ADD_SEARCHPATH version: 6 updated: 2020/12/31 20:19:42
902dnl -----------------
903dnl Set $CPPFLAGS and $LDFLAGS with the directories given via the parameter.
904dnl They can be either the common root of include- and lib-directories, or the
905dnl lib-directory (to allow for things like lib64 directories).
906dnl See also CF_FIND_LINKAGE.
907dnl
908dnl $1 is the list of colon-separated directory names to search.
909dnl $2 is the action to take if a parameter does not yield a directory.
910AC_DEFUN([CF_ADD_SEARCHPATH],
911[
912AC_REQUIRE([CF_PATHSEP])
913for cf_searchpath in `echo "$1" | tr $PATH_SEPARATOR ' '`; do
914	if test -d "$cf_searchpath/include" ; then
915		CF_ADD_INCDIR($cf_searchpath/include)
916	elif test -d "$cf_searchpath/../include" ; then
917		CF_ADD_INCDIR($cf_searchpath/../include)
918	ifelse([$2],,,[else
919$2])
920	fi
921	if test -d "$cf_searchpath/lib" ; then
922		CF_ADD_LIBDIR($cf_searchpath/lib)
923	elif test -d "$cf_searchpath" ; then
924		CF_ADD_LIBDIR($cf_searchpath)
925	ifelse([$2],,,[else
926$2])
927	fi
928done
929])
930dnl ---------------------------------------------------------------------------
931dnl CF_ADD_SUBDIR_PATH version: 5 updated: 2020/12/31 20:19:42
932dnl ------------------
933dnl Append to a search-list for a nonstandard header/lib-file
934dnl	$1 = the variable to return as result
935dnl	$2 = the package name
936dnl	$3 = the subdirectory, e.g., bin, include or lib
937dnl $4 = the directory under which we will test for subdirectories
938dnl $5 = a directory that we do not want $4 to match
939AC_DEFUN([CF_ADD_SUBDIR_PATH],
940[
941test "x$4" != "x$5" && \
942test -d "$4" && \
943ifelse([$5],NONE,,[{ test -z "$5" || test "x$5" = xNONE || test "x$4" != "x$5"; } &&]) {
944	test -n "$verbose" && echo "	... testing for $3-directories under $4"
945	test -d "$4/$3" &&          $1="[$]$1 $4/$3"
946	test -d "$4/$3/$2" &&       $1="[$]$1 $4/$3/$2"
947	test -d "$4/$3/$2/$3" &&    $1="[$]$1 $4/$3/$2/$3"
948	test -d "$4/$2/$3" &&       $1="[$]$1 $4/$2/$3"
949	test -d "$4/$2/$3/$2" &&    $1="[$]$1 $4/$2/$3/$2"
950}
951])dnl
952dnl ---------------------------------------------------------------------------
953dnl CF_ALT_CHAR_SET version: 10 updated: 2021/06/08 18:08:14
954dnl ---------------
955dnl Check for existence of alternate-character-set support in curses, so we
956dnl can decide to use it for box characters.
957dnl
958AC_DEFUN([CF_ALT_CHAR_SET],
959[
960AC_MSG_CHECKING([if curses supports alternate-character set])
961AC_CACHE_VAL(cf_cv_alt_char_set,[
962for mapname in acs_map _acs_map
963do
964	AC_TRY_LINK([
965#include <${cf_cv_ncurses_header:-curses.h}>
966	],[chtype x = ${mapname}['l']; ${mapname}['m'] = 0; (void)x],
967	[cf_cv_alt_char_set=$mapname
968	 break],
969	[cf_cv_alt_char_set=no])
970done
971	])
972AC_MSG_RESULT($cf_cv_alt_char_set)
973test "$cf_cv_alt_char_set" != no && AC_DEFINE_UNQUOTED(ALT_CHAR_SET,$cf_cv_alt_char_set,[Define to 1 if if curses supports alternate-character set])
974])dnl
975dnl ---------------------------------------------------------------------------
976dnl CF_ANSI_CC_CHECK version: 13 updated: 2012/10/06 11:17:15
977dnl ----------------
978dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
979dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
980AC_DEFUN([CF_ANSI_CC_CHECK],
981[
982CF_CC_ENV_FLAGS
983
984AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
985cf_cv_ansi_cc=no
986cf_save_CFLAGS="$CFLAGS"
987cf_save_CPPFLAGS="$CPPFLAGS"
988# Don't try gcc -ansi; that turns off useful extensions and
989# breaks some systems' header files.
990# AIX			-qlanglvl=ansi
991# Ultrix and OSF/1	-std1
992# HP-UX			-Aa -D_HPUX_SOURCE
993# SVR4			-Xc
994# UnixWare 1.2		(cannot use -Xc, since ANSI/POSIX clashes)
995for cf_arg in "-DCC_HAS_PROTOS" \
996	"" \
997	-qlanglvl=ansi \
998	-std1 \
999	-Ae \
1000	"-Aa -D_HPUX_SOURCE" \
1001	-Xc
1002do
1003	CF_ADD_CFLAGS($cf_arg)
1004	AC_TRY_COMPILE(
1005[
1006#ifndef CC_HAS_PROTOS
1007#if !defined(__STDC__) || (__STDC__ != 1)
1008choke me
1009#endif
1010#endif
1011],[
1012	int test (int i, double x);
1013	struct s1 {int (*f) (int a);};
1014	struct s2 {int (*f) (double a);};],
1015	[cf_cv_ansi_cc="$cf_arg"; break])
1016done
1017CFLAGS="$cf_save_CFLAGS"
1018CPPFLAGS="$cf_save_CPPFLAGS"
1019])
1020
1021if test "$cf_cv_ansi_cc" != "no"; then
1022if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
1023	CF_ADD_CFLAGS($cf_cv_ansi_cc)
1024else
1025	AC_DEFINE(CC_HAS_PROTOS,1,[Define to 1 if C compiler supports prototypes])
1026fi
1027fi
1028])dnl
1029dnl ---------------------------------------------------------------------------
1030dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
1031dnl ---------------
1032dnl For programs that must use an ANSI compiler, obtain compiler options that
1033dnl will make it recognize prototypes.  We'll do preprocessor checks in other
1034dnl macros, since tools such as unproto can fake prototypes, but only part of
1035dnl the preprocessor.
1036AC_DEFUN([CF_ANSI_CC_REQD],
1037[AC_REQUIRE([CF_ANSI_CC_CHECK])
1038if test "$cf_cv_ansi_cc" = "no"; then
1039	AC_MSG_ERROR(
1040[Your compiler does not appear to recognize prototypes.
1041You have the following choices:
1042	a. adjust your compiler options
1043	b. get an up-to-date compiler
1044	c. use a wrapper such as unproto])
1045fi
1046])dnl
1047dnl ---------------------------------------------------------------------------
1048dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
1049dnl --------------
1050dnl use this macro for appending text without introducing an extra blank at
1051dnl the beginning
1052define([CF_APPEND_TEXT],
1053[
1054	test -n "[$]$1" && $1="[$]$1 "
1055	$1="[$]{$1}$2"
1056])dnl
1057dnl ---------------------------------------------------------------------------
1058dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
1059dnl --------------
1060dnl Allow user to disable a normally-on option.
1061AC_DEFUN([CF_ARG_DISABLE],
1062[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
1063dnl ---------------------------------------------------------------------------
1064dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
1065dnl -------------
1066dnl Allow user to enable a normally-off option.
1067AC_DEFUN([CF_ARG_ENABLE],
1068[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
1069dnl ---------------------------------------------------------------------------
1070dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
1071dnl -------------
1072dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
1073dnl values.
1074dnl
1075dnl Parameters:
1076dnl $1 = option name
1077dnl $2 = help-string
1078dnl $3 = action to perform if option is not default
1079dnl $4 = action if perform if option is default
1080dnl $5 = default option value (either 'yes' or 'no')
1081AC_DEFUN([CF_ARG_OPTION],
1082[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
1083	if test "$enableval" != "$5" ; then
1084ifelse([$3],,[    :]dnl
1085,[    $3]) ifelse([$4],,,[
1086	else
1087		$4])
1088	fi],[enableval=$5 ifelse([$4],,,[
1089	$4
1090])dnl
1091])])dnl
1092dnl ---------------------------------------------------------------------------
1093dnl CF_AR_FLAGS version: 9 updated: 2021/01/01 13:31:04
1094dnl -----------
1095dnl Check for suitable "ar" (archiver) options for updating an archive.
1096dnl
1097dnl In particular, handle some obsolete cases where the "-" might be omitted,
1098dnl as well as a workaround for breakage of make's archive rules by the GNU
1099dnl binutils "ar" program.
1100AC_DEFUN([CF_AR_FLAGS],[
1101AC_REQUIRE([CF_PROG_AR])
1102
1103AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
1104	case "$cf_cv_system_name" in
1105	(*-msvc*)
1106		cf_cv_ar_flags=''
1107		cat >mk_static_lib.sh <<-EOF
1108		#!$SHELL
1109		MSVC_BIN="[$]AR"
1110		out="\[$]1"
1111		shift
1112		exec \[$]MSVC_BIN -out:"\[$]out" \[$]@
1113		EOF
1114		chmod +x mk_static_lib.sh
1115		AR=`pwd`/mk_static_lib.sh
1116		;;
1117	(*)
1118		cf_cv_ar_flags=unknown
1119		for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
1120		do
1121
1122			# check if $ARFLAGS already contains this choice
1123			if test "x$ARFLAGS" != "x" ; then
1124				cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
1125				if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
1126					cf_cv_ar_flags=
1127					break
1128				fi
1129			fi
1130
1131			rm -f "conftest.$ac_cv_objext"
1132			rm -f conftest.a
1133
1134			cat >"conftest.$ac_ext" <<EOF
1135#line __oline__ "configure"
1136int	testdata[[3]] = { 123, 456, 789 };
1137EOF
1138			if AC_TRY_EVAL(ac_compile) ; then
1139				echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
1140				$AR $ARFLAGS "$cf_ar_flags" conftest.a "conftest.$ac_cv_objext" 2>&AC_FD_CC 1>/dev/null
1141				if test -f conftest.a ; then
1142					cf_cv_ar_flags="$cf_ar_flags"
1143					break
1144				fi
1145			else
1146				CF_VERBOSE(cannot compile test-program)
1147				break
1148			fi
1149		done
1150		rm -f conftest.a "conftest.$ac_ext" "conftest.$ac_cv_objext"
1151		;;
1152	esac
1153])
1154
1155if test -n "$ARFLAGS" ; then
1156	if test -n "$cf_cv_ar_flags" ; then
1157		ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
1158	fi
1159else
1160	ARFLAGS=$cf_cv_ar_flags
1161fi
1162
1163AC_SUBST(ARFLAGS)
1164])
1165dnl ---------------------------------------------------------------------------
1166dnl CF_BOOL_DEFS version: 5 updated: 2012/11/08 20:57:52
1167dnl ------------
1168dnl Check if curses.h defines TRUE/FALSE (it does under SVr4).
1169AC_DEFUN([CF_BOOL_DEFS],
1170[
1171AC_MSG_CHECKING(if TRUE/FALSE are defined)
1172AC_CACHE_VAL(cf_cv_bool_defs,[
1173AC_TRY_COMPILE([
1174#include <${cf_cv_ncurses_header:-curses.h}>
1175#include <stdio.h>],[int x = TRUE, y = FALSE],
1176	[cf_cv_bool_defs=yes],
1177	[cf_cv_bool_defs=no])])
1178AC_MSG_RESULT($cf_cv_bool_defs)
1179if test "$cf_cv_bool_defs" = no ; then
1180	AC_DEFINE(TRUE,(1),[Define to TRUE if curses.h does not define])
1181	AC_DEFINE(FALSE,(0),[Define to FALSE if curses.h does not define])
1182fi
1183])dnl
1184dnl ---------------------------------------------------------------------------
1185dnl CF_BUILD_CC version: 9 updated: 2021/01/02 09:31:20
1186dnl -----------
1187dnl If we're cross-compiling, allow the user to override the tools and their
1188dnl options.  The configure script is oriented toward identifying the host
1189dnl compiler, etc., but we need a build compiler to generate parts of the
1190dnl source.
1191dnl
1192dnl $1 = default for $CPPFLAGS
1193dnl $2 = default for $LIBS
1194AC_DEFUN([CF_BUILD_CC],[
1195CF_ACVERSION_CHECK(2.52,,
1196	[AC_REQUIRE([CF_PROG_EXT])])
1197if test "$cross_compiling" = yes ; then
1198
1199	# defaults that we might want to override
1200	: ${BUILD_CFLAGS:=''}
1201	: ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
1202	: ${BUILD_LDFLAGS:=''}
1203	: ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
1204	: ${BUILD_EXEEXT:='$x'}
1205	: ${BUILD_OBJEXT:='o'}
1206
1207	AC_ARG_WITH(build-cc,
1208		[  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
1209		[BUILD_CC="$withval"],
1210		[AC_CHECK_PROGS(BUILD_CC, [gcc clang c99 c89 cc cl],none)])
1211	AC_MSG_CHECKING(for native build C compiler)
1212	AC_MSG_RESULT($BUILD_CC)
1213
1214	AC_MSG_CHECKING(for native build C preprocessor)
1215	AC_ARG_WITH(build-cpp,
1216		[  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
1217		[BUILD_CPP="$withval"],
1218		[BUILD_CPP='${BUILD_CC} -E'])
1219	AC_MSG_RESULT($BUILD_CPP)
1220
1221	AC_MSG_CHECKING(for native build C flags)
1222	AC_ARG_WITH(build-cflags,
1223		[  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
1224		[BUILD_CFLAGS="$withval"])
1225	AC_MSG_RESULT($BUILD_CFLAGS)
1226
1227	AC_MSG_CHECKING(for native build C preprocessor-flags)
1228	AC_ARG_WITH(build-cppflags,
1229		[  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
1230		[BUILD_CPPFLAGS="$withval"])
1231	AC_MSG_RESULT($BUILD_CPPFLAGS)
1232
1233	AC_MSG_CHECKING(for native build linker-flags)
1234	AC_ARG_WITH(build-ldflags,
1235		[  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
1236		[BUILD_LDFLAGS="$withval"])
1237	AC_MSG_RESULT($BUILD_LDFLAGS)
1238
1239	AC_MSG_CHECKING(for native build linker-libraries)
1240	AC_ARG_WITH(build-libs,
1241		[  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
1242		[BUILD_LIBS="$withval"])
1243	AC_MSG_RESULT($BUILD_LIBS)
1244
1245	# this assumes we're on Unix.
1246	BUILD_EXEEXT=
1247	BUILD_OBJEXT=o
1248
1249	: ${BUILD_CC:='${CC}'}
1250
1251	if { test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}'; } ; then
1252		AC_MSG_ERROR([Cross-build requires two compilers.
1253Use --with-build-cc to specify the native compiler.])
1254	fi
1255
1256else
1257	: ${BUILD_CC:='${CC}'}
1258	: ${BUILD_CPP:='${CPP}'}
1259	: ${BUILD_CFLAGS:='${CFLAGS}'}
1260	: ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
1261	: ${BUILD_LDFLAGS:='${LDFLAGS}'}
1262	: ${BUILD_LIBS:='${LIBS}'}
1263	: ${BUILD_EXEEXT:='$x'}
1264	: ${BUILD_OBJEXT:='o'}
1265fi
1266
1267AC_SUBST(BUILD_CC)
1268AC_SUBST(BUILD_CPP)
1269AC_SUBST(BUILD_CFLAGS)
1270AC_SUBST(BUILD_CPPFLAGS)
1271AC_SUBST(BUILD_LDFLAGS)
1272AC_SUBST(BUILD_LIBS)
1273AC_SUBST(BUILD_EXEEXT)
1274AC_SUBST(BUILD_OBJEXT)
1275])dnl
1276dnl ---------------------------------------------------------------------------
1277dnl CF_BUNDLED_INTL version: 20 updated: 2021/01/02 09:31:20
1278dnl ---------------
1279dnl Top-level macro for configuring an application with a bundled copy of
1280dnl the intl and po directories for gettext.
1281dnl
1282dnl $1 specifies either Makefile or makefile, defaulting to the former.
1283dnl $2 if nonempty sets the option to --enable-nls rather than to --disable-nls
1284dnl
1285dnl Sets variables which can be used to substitute in makefiles:
1286dnl	GT_YES       - "#" comment unless building intl library, otherwise empty
1287dnl	GT_NO        - "#" comment if building intl library, otherwise empty
1288dnl	INTLDIR_MAKE - to make ./intl directory
1289dnl	MSG_DIR_MAKE - to make ./po directory
1290dnl	SUB_MAKEFILE - list of makefiles in ./intl, ./po directories
1291dnl
1292dnl Defines:
1293dnl	HAVE_LIBGETTEXT_H if we're using ./intl
1294dnl	NLS_TEXTDOMAIN
1295dnl
1296dnl Environment:
1297dnl	ALL_LINGUAS if set, lists the root names of the ".po" files.
1298dnl	CONFIG_H assumed to be "config.h"
1299dnl	PACKAGE must be set, used as default for textdomain
1300dnl	VERSION may be set, otherwise extract from "VERSION" file.
1301dnl
1302AC_DEFUN([CF_BUNDLED_INTL],[
1303cf_makefile=ifelse($1,,Makefile,$1)
1304
1305dnl Set of available languages (based on source distribution).  Note that
1306dnl setting $LINGUAS overrides $ALL_LINGUAS.  Some environments set $LINGUAS
1307dnl rather than $LC_ALL
1308test -z "$ALL_LINGUAS" && ALL_LINGUAS=`test -d "$srcdir/po" && cd "$srcdir/po" && echo *.po|sed -e 's/\.po//g' -e 's/*//'`
1309
1310# Allow override of "config.h" definition:
1311: ${CONFIG_H:=config.h}
1312AC_SUBST(CONFIG_H)
1313
1314if test -z "$PACKAGE" ; then
1315	AC_MSG_ERROR([[CF_BUNDLED_INTL] used without setting [PACKAGE] variable])
1316fi
1317
1318if test -z "$VERSION" ; then
1319if test -f "$srcdir/VERSION" ; then
1320	VERSION=`sed -e '2,$d' "$srcdir/VERSION" |cut -f1`
1321else
1322	VERSION=unknown
1323fi
1324fi
1325AC_SUBST(VERSION)
1326
1327AM_GNU_GETTEXT(,,,[$2])
1328
1329if test "$USE_NLS" = yes ; then
1330	AC_ARG_WITH(textdomain,
1331		[  --with-textdomain=PKG   NLS text-domain (default is package name)],
1332		[NLS_TEXTDOMAIN=$withval],
1333		[NLS_TEXTDOMAIN=$PACKAGE])
1334	AC_DEFINE_UNQUOTED(NLS_TEXTDOMAIN,"$NLS_TEXTDOMAIN",[Define to the nls textdomain value])
1335	AC_SUBST(NLS_TEXTDOMAIN)
1336fi
1337
1338INTLDIR_MAKE=
1339MSG_DIR_MAKE=
1340SUB_MAKEFILE=
1341
1342dnl this updates SUB_MAKEFILE and MSG_DIR_MAKE:
1343CF_OUR_MESSAGES($1)
1344
1345if test "$USE_INCLUDED_LIBINTL" = yes ; then
1346	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1347		:
1348	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1349		:
1350	else
1351		INTLDIR_MAKE="#"
1352	fi
1353	if test -z "$INTLDIR_MAKE"; then
1354		AC_DEFINE(HAVE_LIBGETTEXT_H,1,[Define to 1 if we have libgettext.h])
1355		for cf_makefile in \
1356			$srcdir/intl/Makefile.in \
1357			$srcdir/intl/makefile.in
1358		do
1359			if test -f "$cf_makefile" ; then
1360				SUB_MAKEFILE="$SUB_MAKEFILE `echo \"${cf_makefile}\"|sed -e 's,^'$srcdir/',,' -e 's/\.in$//'`:${cf_makefile}"
1361				break
1362			fi
1363		done
1364	fi
1365else
1366	INTLDIR_MAKE="#"
1367	if test "$USE_NLS" = yes ; then
1368		AC_CHECK_HEADERS(libintl.h)
1369	fi
1370fi
1371
1372if test -z "$INTLDIR_MAKE" ; then
1373	CF_APPEND_TEXT(CPPFLAGS,-I../intl)
1374fi
1375
1376dnl FIXME:  we use this in lynx (the alternative is a spurious dependency upon
1377dnl GNU make)
1378if test "$BUILD_INCLUDED_LIBINTL" = yes ; then
1379	GT_YES="#"
1380	GT_NO=
1381else
1382	GT_YES=
1383	GT_NO="#"
1384fi
1385
1386AC_SUBST(INTLDIR_MAKE)
1387AC_SUBST(MSG_DIR_MAKE)
1388AC_SUBST(GT_YES)
1389AC_SUBST(GT_NO)
1390
1391dnl FIXME:  the underlying AM_GNU_GETTEXT macro either needs some fixes or a
1392dnl little documentation.  It doesn't define anything so that we can ifdef our
1393dnl own code, except ENABLE_NLS, which is too vague to be of any use.
1394
1395if test "$USE_INCLUDED_LIBINTL" = yes ; then
1396	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1397		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
1398	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1399		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
1400	fi
1401	if test -n "$nls_cv_header_intl" ; then
1402		AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have header-file for libintl])
1403	fi
1404fi
1405])dnl
1406dnl ---------------------------------------------------------------------------
1407dnl CF_C11_NORETURN version: 3 updated: 2021/03/28 11:36:23
1408dnl ---------------
1409AC_DEFUN([CF_C11_NORETURN],
1410[
1411AC_MSG_CHECKING(if you want to use C11 _Noreturn feature)
1412CF_ARG_ENABLE(stdnoreturn,
1413	[  --enable-stdnoreturn    enable C11 _Noreturn feature for diagnostics],
1414	[enable_stdnoreturn=yes],
1415	[enable_stdnoreturn=no])
1416AC_MSG_RESULT($enable_stdnoreturn)
1417
1418if test $enable_stdnoreturn = yes; then
1419AC_CACHE_CHECK([for C11 _Noreturn feature], cf_cv_c11_noreturn,
1420	[AC_TRY_COMPILE([
1421#include <stdio.h>
1422#include <stdlib.h>
1423#include <stdnoreturn.h>
1424static _Noreturn void giveup(void) { exit(0); }
1425	],
1426	[if (feof(stdin)) giveup()],
1427	cf_cv_c11_noreturn=yes,
1428	cf_cv_c11_noreturn=no)
1429	])
1430else
1431	cf_cv_c11_noreturn=no,
1432fi
1433
1434if test "$cf_cv_c11_noreturn" = yes; then
1435	AC_DEFINE(HAVE_STDNORETURN_H, 1,[Define if <stdnoreturn.h> header is available and working])
1436	AC_DEFINE_UNQUOTED(STDC_NORETURN,_Noreturn,[Define if C11 _Noreturn keyword is supported])
1437	HAVE_STDNORETURN_H=1
1438else
1439	HAVE_STDNORETURN_H=0
1440fi
1441
1442AC_SUBST(HAVE_STDNORETURN_H)
1443AC_SUBST(STDC_NORETURN)
1444])dnl
1445dnl ---------------------------------------------------------------------------
1446dnl CF_CC_ENV_FLAGS version: 10 updated: 2020/12/31 18:40:20
1447dnl ---------------
1448dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
1449dnl into CC.  This will not help with broken scripts that wrap the compiler
1450dnl with options, but eliminates a more common category of user confusion.
1451dnl
1452dnl In particular, it addresses the problem of being able to run the C
1453dnl preprocessor in a consistent manner.
1454dnl
1455dnl Caveat: this also disallows blanks in the pathname for the compiler, but
1456dnl the nuisance of having inconsistent settings for compiler and preprocessor
1457dnl outweighs that limitation.
1458AC_DEFUN([CF_CC_ENV_FLAGS],
1459[
1460# This should have been defined by AC_PROG_CC
1461: "${CC:=cc}"
1462
1463AC_MSG_CHECKING(\$CFLAGS variable)
1464case "x$CFLAGS" in
1465(*-[[IUD]]*)
1466	AC_MSG_RESULT(broken)
1467	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
1468	cf_flags="$CFLAGS"
1469	CFLAGS=
1470	for cf_arg in $cf_flags
1471	do
1472		CF_ADD_CFLAGS($cf_arg)
1473	done
1474	;;
1475(*)
1476	AC_MSG_RESULT(ok)
1477	;;
1478esac
1479
1480AC_MSG_CHECKING(\$CC variable)
1481case "$CC" in
1482(*[[\ \	]]-*)
1483	AC_MSG_RESULT(broken)
1484	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
1485	# humor him...
1486	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
1487	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
1488	CC="$cf_prog"
1489	for cf_arg in $cf_flags
1490	do
1491		case "x$cf_arg" in
1492		(x-[[IUDfgOW]]*)
1493			CF_ADD_CFLAGS($cf_arg)
1494			;;
1495		(*)
1496			CC="$CC $cf_arg"
1497			;;
1498		esac
1499	done
1500	CF_VERBOSE(resulting CC: '$CC')
1501	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
1502	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
1503	;;
1504(*)
1505	AC_MSG_RESULT(ok)
1506	;;
1507esac
1508])dnl
1509dnl ---------------------------------------------------------------------------
1510dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
1511dnl --------------
1512dnl Check if we're accidentally using a cache from a different machine.
1513dnl Derive the system name, as a check for reusing the autoconf cache.
1514dnl
1515dnl If we've packaged config.guess and config.sub, run that (since it does a
1516dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1517dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1518dnl which is useful in cross-compiles.
1519dnl
1520dnl Note: we would use $ac_config_sub, but that is one of the places where
1521dnl autoconf 2.5x broke compatibility with autoconf 2.13
1522AC_DEFUN([CF_CHECK_CACHE],
1523[
1524if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
1525	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
1526	system_name="$host_os"
1527else
1528	system_name="`(uname -s -r) 2>/dev/null`"
1529	if test -z "$system_name" ; then
1530		system_name="`(hostname) 2>/dev/null`"
1531	fi
1532fi
1533test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
1534AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1535
1536test -z "$system_name" && system_name="$cf_cv_system_name"
1537test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1538
1539if test ".$system_name" != ".$cf_cv_system_name" ; then
1540	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
1541	AC_MSG_ERROR("Please remove config.cache and try again.")
1542fi
1543])dnl
1544dnl ---------------------------------------------------------------------------
1545dnl CF_CHECK_CFLAGS version: 4 updated: 2021/01/02 19:22:58
1546dnl ---------------
1547dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
1548dnl a build-configuration such as imake.  These have the pitfall that they
1549dnl often contain compiler-specific options which we cannot use, mixed with
1550dnl preprocessor options that we usually can.
1551AC_DEFUN([CF_CHECK_CFLAGS],
1552[
1553CF_VERBOSE(checking additions to CFLAGS)
1554cf_check_cflags="$CFLAGS"
1555cf_check_cppflags="$CPPFLAGS"
1556CF_ADD_CFLAGS($1,yes)
1557if test "x$cf_check_cflags" != "x$CFLAGS" ; then
1558AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
1559	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
1560	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
1561		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
1562	 fi
1563	 CFLAGS="$cf_check_cflags"])
1564fi
1565])dnl
1566dnl ---------------------------------------------------------------------------
1567dnl CF_CHECK_ERRNO version: 13 updated: 2020/03/10 18:53:47
1568dnl --------------
1569dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
1570dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
1571dnl ourselves.
1572dnl
1573dnl $1 = the name to check
1574dnl $2 = the assumed type
1575AC_DEFUN([CF_CHECK_ERRNO],
1576[
1577AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
1578	AC_TRY_COMPILE([
1579#ifdef HAVE_STDLIB_H
1580#include <stdlib.h>
1581#endif
1582#include <stdio.h>
1583#include <sys/types.h>
1584#include <errno.h> ],
1585	ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1; (void)x,
1586	[cf_cv_dcl_$1=yes],
1587	[cf_cv_dcl_$1=no])
1588])
1589
1590if test "$cf_cv_dcl_$1" = no ; then
1591	CF_UPPER(cf_result,decl_$1)
1592	AC_DEFINE_UNQUOTED($cf_result)
1593fi
1594
1595# It's possible (for near-UNIX clones) that the data doesn't exist
1596CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
1597])dnl
1598dnl ---------------------------------------------------------------------------
1599dnl CF_CHECK_EXTERN_DATA version: 4 updated: 2015/04/18 08:56:57
1600dnl --------------------
1601dnl Check for existence of external data in the current set of libraries.  If
1602dnl we can modify it, it's real enough.
1603dnl $1 = the name to check
1604dnl $2 = its type
1605AC_DEFUN([CF_CHECK_EXTERN_DATA],
1606[
1607AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
1608	AC_TRY_LINK([
1609#undef $1
1610extern $2 $1;
1611],
1612	[$1 = 2],
1613	[cf_cv_have_$1=yes],
1614	[cf_cv_have_$1=no])
1615])
1616
1617if test "$cf_cv_have_$1" = yes ; then
1618	CF_UPPER(cf_result,have_$1)
1619	AC_DEFINE_UNQUOTED($cf_result)
1620fi
1621
1622])dnl
1623dnl ---------------------------------------------------------------------------
1624dnl CF_CHECK_FUNCDECL version: 7 updated: 2009/10/15 19:39:18
1625dnl -----------------
1626dnl Check if a function is declared by including a set of include files.
1627dnl Invoke the corresponding actions according to whether it is found or not.
1628dnl
1629dnl Gcc (unlike other compilers) will only warn about the miscast assignment
1630dnl in the first test, but most compilers will oblige with an error in the
1631dnl second test.
1632dnl
1633dnl CF_CHECK_FUNCDECL(INCLUDES, FUNCTION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
1634AC_DEFUN([CF_CHECK_FUNCDECL],
1635[
1636AC_MSG_CHECKING([for $2 declaration])
1637AC_CACHE_VAL(ac_cv_func_decl_$2,
1638[AC_TRY_COMPILE([$1],
1639[#ifndef $2
1640extern	int	$2();
1641#endif],[
1642AC_TRY_COMPILE([$1],
1643[#ifndef $2
1644int	(*p)() = $2;
1645#endif],[
1646eval "ac_cv_func_decl_$2=yes"],[
1647eval "ac_cv_func_decl_$2=no"])],[
1648eval "ac_cv_func_decl_$2=yes"])])
1649if eval "test \"`echo '$ac_cv_func_'decl_$2`\" = yes"; then
1650  AC_MSG_RESULT(yes)
1651  ifelse([$3], , :, [$3])
1652else
1653  AC_MSG_RESULT(no)
1654ifelse([$4], , , [$4
1655])dnl
1656fi
1657])dnl
1658dnl ---------------------------------------------------------------------------
1659dnl CF_CHECK_FUNCDECLS version: 4 updated: 1999/03/30 12:24:31
1660dnl ------------------
1661dnl Check if functions are declared by including a set of include files.
1662dnl and define DECL_XXX if not.
1663dnl
1664dnl CF_CHECK_FUNCDECLS(INCLUDES, FUNCTION... [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
1665AC_DEFUN([CF_CHECK_FUNCDECLS],
1666[for ac_func in $2
1667do
1668CF_CHECK_FUNCDECL([$1], $ac_func,
1669[$3],
1670[
1671  CF_UPPER(ac_tr_func,DECL_$ac_func)
1672  AC_DEFINE_UNQUOTED($ac_tr_func) $4])dnl
1673done
1674])dnl
1675dnl ---------------------------------------------------------------------------
1676dnl CF_CHECK_IPV6 version: 3 updated: 2004/01/22 17:38:22
1677dnl -------------
1678dnl Check for IPV6 configuration.
1679AC_DEFUN([CF_CHECK_IPV6],[
1680CF_FIND_IPV6_TYPE
1681CF_FIND_IPV6_LIBS
1682
1683CF_FUNC_GETADDRINFO
1684
1685if test "$cf_cv_getaddrinfo" != "yes"; then
1686	if test "$cf_cv_ipv6type" != "linux"; then
1687		AC_MSG_WARN(
1688[You must get working getaddrinfo() function,
1689or you can specify "--disable-ipv6"])
1690	else
1691		AC_MSG_WARN(
1692[The getaddrinfo() implementation on your system seems be buggy.
1693You should upgrade your system library to the newest version
1694of GNU C library (aka glibc).])
1695	fi
1696fi
1697
1698])dnl
1699dnl ---------------------------------------------------------------------------
1700dnl CF_CHECK_SIZEOF version: 4 updated: 2021/01/02 09:31:20
1701dnl ---------------
1702dnl Improve on AC_CHECK_SIZEOF for cases when the build-environment is
1703dnl deficient, e.g., if someone tries to build in busybox.  Use the second
1704dnl parameter as the fallback value.
1705dnl
1706dnl By the way, 2.13/2.52 differ in AC_CHECK_SIZEOF regarding the types they
1707dnl can detect; the former includes only stdio.h for types while the latter
1708dnl includes several header files.
1709AC_DEFUN([CF_CHECK_SIZEOF],[
1710AC_CHECK_SIZEOF([$1],[$2])
1711if test "${ac_cv_type_$1+set}" = set; then
1712	cf_cv_sizeof="$ac_cv_sizeof_$1"
1713	if test "${ac_cv_sizeof_$1+set}" != set; then
1714		AC_MSG_WARN(using $2 for sizeof $1)
1715		ac_cv_sizeof_$1=$2
1716	elif test "x${ac_cv_sizeof_$1}" = x0; then
1717		AC_MSG_WARN([sizeof $1 not found, using $2])
1718		ac_cv_sizeof_$1=$2
1719	fi
1720	if test "x$ac_cv_sizeof_$1" != "x$cf_cv_sizeof"
1721	then
1722		CF_UPPER(cf_cv_type,sizeof_$1)
1723		sed -e "s/\\([[ 	]]${cf_cv_type}[[ 	]]\\).*/\\1$ac_cv_sizeof_$1/" confdefs.h >conftest.val
1724		mv conftest.val confdefs.h
1725	fi
1726fi
1727])dnl
1728dnl ---------------------------------------------------------------------------
1729dnl CF_CHECK_SSL_X509 version: 5 updated: 2014/11/30 18:19:56
1730dnl -----------------
1731dnl Check for X509 support in the SSL library.
1732define([CF_CHECK_SSL_X509],[
1733AC_MSG_CHECKING(for X509 support)
1734AC_TRY_LINK(CF__SSL_HEAD [
1735#if defined(USE_GNUTLS_INCL)
1736#include <gnutls/x509.h>
1737#else
1738#include <openssl/x509.h>
1739#endif
1740],
1741	[X509_verify_cert_error_string(X509_STORE_CTX_get_error(NULL))],
1742	[cf_x509_support=yes],
1743	[cf_x509_support=no])
1744AC_MSG_RESULT($cf_x509_support)
1745
1746if test "$cf_x509_support" = yes ; then
1747	AC_DEFINE(USE_X509_SUPPORT)
1748fi
1749])dnl
1750dnl ---------------------------------------------------------------------------
1751dnl CF_CHECK_TYPE version: 4 updated: 2021/01/02 09:31:20
1752dnl -------------
1753dnl Add a 3rd parameter to AC_CHECK_TYPE, working around autoconf 2.5x's
1754dnl deliberate incompatibility.
1755dnl	$1 = name of type to check for
1756dnl	$2 = default type
1757dnl	$3 = additional #include's and related preprocessor lines.
1758ifdef([m4_HAS_AC_CT_FOURARGS], [m4_undefine([m4_HAS_AC_CT_FOURARGS])])dnl
1759ifelse(m4_PACKAGE_VERSION, [fnord_acsalt], [],
1760[ifdef([m4_version_compare],[m4_define([m4_HAS_AC_CT_FOURARGS])])])dnl
1761AC_DEFUN([CF_CHECK_TYPE],
1762[
1763ifdef([m4_HAS_AC_CT_FOURARGS],[
1764	AC_CHECK_TYPE([$1],ac_cv_type_$1=yes,ac_cv_type_$1=no,[$3])
1765	],[
1766	AC_MSG_CHECKING(for $1)
1767	AC_TRY_COMPILE([
1768#if STDC_HEADERS
1769#include <stdlib.h>
1770#include <stddef.h>
1771#endif
1772$3
1773],[
1774	static $1 dummy; if (sizeof(dummy)) return 0; else return 1;],
1775	ac_cv_type_$1=yes,
1776	ac_cv_type_$1=no)
1777	AC_MSG_RESULT($ac_cv_type_$1)
1778])dnl
1779if test "$ac_cv_type_$1" = no; then
1780	AC_DEFINE($1, $2, Define to $2 if $1 is not declared)
1781fi
1782])dnl
1783dnl ---------------------------------------------------------------------------
1784dnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04
1785dnl -----------------
1786dnl Check if the given compiler is really clang.  clang's C driver defines
1787dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
1788dnl not ignore some gcc options.
1789dnl
1790dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1791dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1792dnl the wrappers for gcc and g++ warnings.
1793dnl
1794dnl $1 = GCC (default) or GXX
1795dnl $2 = CLANG_COMPILER (default)
1796dnl $3 = CFLAGS (default) or CXXFLAGS
1797AC_DEFUN([CF_CLANG_COMPILER],[
1798ifelse([$2],,CLANG_COMPILER,[$2])=no
1799
1800if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1801	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
1802	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1803	AC_TRY_COMPILE([],[
1804#ifdef __clang__
1805#else
1806make an error
1807#endif
1808],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
1809],[])
1810	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1811	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
1812fi
1813
1814CLANG_VERSION=none
1815
1816if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
1817	case "$CC" in
1818	(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
1819		AC_MSG_WARN(replacing broken compiler alias $CC)
1820		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
1821		CC=clang
1822		;;
1823	esac
1824
1825	AC_MSG_CHECKING(version of $CC)
1826	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.]].*//'`"
1827	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
1828	AC_MSG_RESULT($CLANG_VERSION)
1829
1830	for cf_clang_opt in \
1831		-Qunused-arguments \
1832		-Wno-error=implicit-function-declaration
1833	do
1834		AC_MSG_CHECKING(if option $cf_clang_opt works)
1835		cf_save_CFLAGS="$CFLAGS"
1836		CFLAGS="$CFLAGS $cf_clang_opt"
1837		AC_TRY_LINK([
1838			#include <stdio.h>],[
1839			printf("hello!\\n");],[
1840			cf_clang_optok=yes],[
1841			cf_clang_optok=no])
1842		AC_MSG_RESULT($cf_clang_optok)
1843		CFLAGS="$cf_save_CFLAGS"
1844		if test "$cf_clang_optok" = yes; then
1845			CF_VERBOSE(adding option $cf_clang_opt)
1846			CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
1847		fi
1848	done
1849fi
1850])
1851dnl ---------------------------------------------------------------------------
1852dnl CF_COLOR_CURSES version: 9 updated: 2021/01/02 09:31:20
1853dnl ---------------
1854dnl Check if curses supports color.  (Note that while SVr3 curses supports
1855dnl color, it does this differently from SVr4 curses; more work would be needed
1856dnl to accommodate SVr3).
1857dnl
1858AC_DEFUN([CF_COLOR_CURSES],
1859[
1860AC_MSG_CHECKING(if curses supports color attributes)
1861AC_CACHE_VAL(cf_cv_color_curses,[
1862	AC_TRY_LINK([
1863#include <${cf_cv_ncurses_header:-curses.h}>
1864],
1865	[chtype x = COLOR_BLUE;
1866	 has_colors();
1867	 start_color();
1868#ifndef NCURSES_BROKEN
1869	 wbkgd(curscr, getbkgd(stdscr)); /* X/Open XPG4 aka SVr4 Curses */
1870#endif
1871	],
1872	[cf_cv_color_curses=yes],
1873	[cf_cv_color_curses=no])
1874	])
1875AC_MSG_RESULT($cf_cv_color_curses)
1876if test "$cf_cv_color_curses" = yes ; then
1877	AC_DEFINE(COLOR_CURSES,1,[Define to 1 if if curses supports color attributes])
1878	test ".$cf_cv_ncurses_broken" != .yes && AC_DEFINE(HAVE_GETBKGD,1,[Define to 1 if curses has getbkgd function])
1879fi
1880])dnl
1881dnl ---------------------------------------------------------------------------
1882dnl CF_CONST_X_STRING version: 7 updated: 2021/06/07 17:39:17
1883dnl -----------------
1884dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
1885dnl character-strings.
1886dnl
1887dnl It is ambiguous because the specification accommodated the pre-ANSI
1888dnl compilers bundled by more than one vendor in lieu of providing a standard C
1889dnl compiler other than by costly add-ons.  Because of this, the specification
1890dnl did not take into account the use of const for telling the compiler that
1891dnl string literals would be in readonly memory.
1892dnl
1893dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
1894dnl let the compiler decide how to represent Xt's strings which were #define'd.
1895dnl That does not solve the problem of using the block of Xt's strings which
1896dnl are compiled into the library (and is less efficient than one might want).
1897dnl
1898dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
1899dnl when compiling the library and compiling using the library, to tell the
1900dnl compiler that String is const.
1901AC_DEFUN([CF_CONST_X_STRING],
1902[
1903AC_REQUIRE([AC_PATH_XTRA])
1904
1905CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
1906
1907AC_TRY_COMPILE(
1908[
1909#include <stdlib.h>
1910#include <X11/Intrinsic.h>
1911],
1912[String foo = malloc(1); free((void*)foo)],[
1913
1914AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
1915	AC_TRY_COMPILE(
1916		[
1917#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
1918#undef  XTSTRINGDEFINES	/* X11R5 and later */
1919#include <stdlib.h>
1920#include <X11/Intrinsic.h>
1921		],[String foo = malloc(1); *foo = 0],[
1922			cf_cv_const_x_string=no
1923		],[
1924			cf_cv_const_x_string=yes
1925		])
1926])
1927
1928CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
1929
1930case "$cf_cv_const_x_string" in
1931(no)
1932	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
1933	;;
1934(*)
1935	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
1936	;;
1937esac
1938
1939])
1940])dnl
1941dnl ---------------------------------------------------------------------------
1942dnl CF_CURSES_CHTYPE version: 11 updated: 2021/01/02 09:31:20
1943dnl ----------------
1944dnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
1945AC_DEFUN([CF_CURSES_CHTYPE],
1946[
1947AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1948AC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[
1949	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1950		[chtype foo; (void)foo],
1951		[cf_cv_chtype_decl=yes],
1952		[cf_cv_chtype_decl=no])])
1953if test "$cf_cv_chtype_decl" = yes ; then
1954	AC_DEFINE(HAVE_TYPE_CHTYPE,1,[Define to 1 if chtype is declared])
1955	AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[
1956		AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1957			[static chtype foo; long x = foo; (void)x],
1958			[cf_cv_chtype_type=scalar],
1959			[cf_cv_chtype_type=struct])])
1960	if test "$cf_cv_chtype_type" = scalar ; then
1961		AC_DEFINE(TYPE_CHTYPE_IS_SCALAR,1,[Define to 1 if chtype is a scaler/integer])
1962	fi
1963fi
1964])dnl
1965dnl ---------------------------------------------------------------------------
1966dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
1967dnl ----------------
1968dnl Tie together the configure-script macros for curses.  It may be ncurses,
1969dnl but unless asked, we do not make a special search for ncurses.  However,
1970dnl still check for the ncurses version number, for use in other macros.
1971AC_DEFUN([CF_CURSES_CONFIG],
1972[
1973CF_CURSES_CPPFLAGS
1974CF_NCURSES_VERSION
1975CF_CURSES_LIBS
1976])dnl
1977dnl ---------------------------------------------------------------------------
1978dnl CF_CURSES_CPPFLAGS version: 14 updated: 2021/01/02 09:31:20
1979dnl ------------------
1980dnl Look for the curses headers.
1981AC_DEFUN([CF_CURSES_CPPFLAGS],[
1982
1983AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
1984cf_cv_curses_incdir=no
1985case "$host_os" in
1986(hpux10.*)
1987	if test "x$cf_cv_screen" = "xcurses_colr"
1988	then
1989		test -d /usr/include/curses_colr && \
1990		cf_cv_curses_incdir="-I/usr/include/curses_colr"
1991	fi
1992	;;
1993(sunos3*|sunos4*)
1994	if test "x$cf_cv_screen" = "xcurses_5lib"
1995	then
1996		test -d /usr/5lib && \
1997		test -d /usr/5include && \
1998		cf_cv_curses_incdir="-I/usr/5include"
1999	fi
2000	;;
2001esac
2002])
2003if test "$cf_cv_curses_incdir" != no
2004then
2005	CF_APPEND_TEXT(CPPFLAGS,$cf_cv_curses_incdir)
2006fi
2007
2008CF_CURSES_HEADER
2009CF_TERM_HEADER
2010])dnl
2011dnl ---------------------------------------------------------------------------
2012dnl CF_CURSES_FUNCS version: 20 updated: 2020/12/31 20:19:42
2013dnl ---------------
2014dnl Curses-functions are a little complicated, since a lot of them are macros.
2015AC_DEFUN([CF_CURSES_FUNCS],
2016[
2017AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2018AC_REQUIRE([CF_XOPEN_CURSES])
2019AC_REQUIRE([CF_CURSES_TERM_H])
2020AC_REQUIRE([CF_CURSES_UNCTRL_H])
2021for cf_func in $1
2022do
2023	CF_UPPER(cf_tr_func,$cf_func)
2024	AC_MSG_CHECKING(for ${cf_func})
2025	CF_MSG_LOG(${cf_func})
2026	AC_CACHE_VAL(cf_cv_func_$cf_func,[
2027		eval cf_result='$ac_cv_func_'$cf_func
2028		if test ".$cf_result" != ".no"; then
2029			AC_TRY_LINK(CF__CURSES_HEAD,
2030			[
2031#ifndef ${cf_func}
2032long foo = (long)(&${cf_func});
2033fprintf(stderr, "testing linkage of $cf_func:%p\\n", (void *)foo);
2034if (foo + 1234L > 5678L)
2035	${cf_cv_main_return:-return}(foo != 0);
2036#endif
2037			],
2038			[cf_result=yes],
2039			[cf_result=no])
2040		fi
2041		eval 'cf_cv_func_'$cf_func'="$cf_result"'
2042	])
2043	# use the computed/retrieved cache-value:
2044	eval 'cf_result=$cf_cv_func_'$cf_func
2045	AC_MSG_RESULT($cf_result)
2046	if test "$cf_result" != no; then
2047		AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
2048	fi
2049done
2050])dnl
2051dnl ---------------------------------------------------------------------------
2052dnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
2053dnl ----------------
2054dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2055dnl variations of ncurses' installs.
2056dnl
2057dnl $1 = ncurses when looking for ncurses, or is empty
2058AC_DEFUN([CF_CURSES_HEADER],[
2059AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
2060cf_cv_ncurses_header=none
2061for cf_header in \
2062	ncurses.h ifelse($1,,,[$1/ncurses.h]) \
2063	curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
2064do
2065AC_TRY_COMPILE([#include <${cf_header}>],
2066	[initscr(); tgoto("?", 0,0)],
2067	[cf_cv_ncurses_header=$cf_header; break],[])
2068done
2069])
2070
2071if test "$cf_cv_ncurses_header" = none ; then
2072	AC_MSG_ERROR(No curses header-files found)
2073fi
2074
2075# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
2076AC_CHECK_HEADERS($cf_cv_ncurses_header)
2077])dnl
2078dnl ---------------------------------------------------------------------------
2079dnl CF_CURSES_LIBS version: 44 updated: 2021/01/02 09:31:20
2080dnl --------------
2081dnl Look for the curses libraries.  Older curses implementations may require
2082dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
2083AC_DEFUN([CF_CURSES_LIBS],[
2084
2085AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2086AC_MSG_CHECKING(if we have identified curses libraries)
2087AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2088	[initscr(); tgoto("?", 0,0)],
2089	cf_result=yes,
2090	cf_result=no)
2091AC_MSG_RESULT($cf_result)
2092
2093if test "$cf_result" = no ; then
2094case "$host_os" in
2095(freebsd*)
2096	AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
2097	;;
2098(hpux10.*)
2099	# Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
2100	# next (1998), and xcurses "newer" (2000).  There is no header file for
2101	# Hcurses; the subdirectory curses_colr has the headers (curses.h and
2102	# term.h) for cur_colr
2103	if test "x$cf_cv_screen" = "xcurses_colr"
2104	then
2105		AC_CHECK_LIB(cur_colr,initscr,[
2106			CF_ADD_LIBS(-lcur_colr)
2107			ac_cv_func_initscr=yes
2108			],[
2109		AC_CHECK_LIB(Hcurses,initscr,[
2110			# HP's header uses __HP_CURSES, but user claims _HP_CURSES.
2111			CF_ADD_LIBS(-lHcurses)
2112			CF_APPEND_TEXT(CPPFLAGS,-D__HP_CURSES -D_HP_CURSES)
2113			ac_cv_func_initscr=yes
2114			])])
2115	fi
2116	;;
2117(linux*)
2118	case `arch 2>/dev/null` in
2119	(x86_64)
2120		if test -d /lib64
2121		then
2122			CF_ADD_LIBDIR(/lib64)
2123		else
2124			CF_ADD_LIBDIR(/lib)
2125		fi
2126		;;
2127	(*)
2128		CF_ADD_LIBDIR(/lib)
2129		;;
2130	esac
2131	;;
2132(sunos3*|sunos4*)
2133	if test "x$cf_cv_screen" = "xcurses_5lib"
2134	then
2135		if test -d /usr/5lib ; then
2136			CF_ADD_LIBDIR(/usr/5lib)
2137			CF_ADD_LIBS(-lcurses -ltermcap)
2138		fi
2139	fi
2140	ac_cv_func_initscr=yes
2141	;;
2142esac
2143
2144if test ".$ac_cv_func_initscr" != .yes ; then
2145	cf_save_LIBS="$LIBS"
2146
2147	if test ".${cf_cv_ncurses_version:-no}" != .no
2148	then
2149		cf_check_list="ncurses curses cursesX"
2150	else
2151		cf_check_list="cursesX curses ncurses"
2152	fi
2153
2154	# Check for library containing tgoto.  Do this before curses library
2155	# because it may be needed to link the test-case for initscr.
2156	if test "x$cf_term_lib" = x
2157	then
2158		AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
2159			for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
2160			do
2161				AC_CHECK_LIB($cf_term_lib,tgoto,[
2162					: "${cf_nculib_root:=$cf_term_lib}"
2163					break
2164				])
2165			done
2166		])
2167	fi
2168
2169	# Check for library containing initscr
2170	test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
2171	if test "x$cf_curs_lib" = x
2172	then
2173		for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
2174		do
2175			LIBS="-l$cf_curs_lib $cf_save_LIBS"
2176			if test "$cf_term_lib" = unknown || test "$cf_term_lib" = "$cf_curs_lib" ; then
2177				AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
2178				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2179					[initscr()],
2180					[cf_result=yes],
2181					[cf_result=no])
2182				AC_MSG_RESULT($cf_result)
2183				test "$cf_result" = yes && break
2184			elif test "$cf_curs_lib" = "$cf_term_lib" ; then
2185				cf_result=no
2186			elif test "$cf_term_lib" != predefined ; then
2187				AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
2188				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2189					[initscr(); tgoto((char *)0, 0, 0);],
2190					[cf_result=no],
2191					[
2192					LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
2193					AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2194						[initscr()],
2195						[cf_result=yes],
2196						[cf_result=error])
2197					])
2198				AC_MSG_RESULT($cf_result)
2199				test "$cf_result" != error && break
2200			fi
2201		done
2202	fi
2203	test "$cf_curs_lib" = unknown && AC_MSG_ERROR(no curses library found)
2204fi
2205fi
2206
2207])dnl
2208dnl ---------------------------------------------------------------------------
2209dnl CF_CURSES_TERM_H version: 15 updated: 2021/01/02 09:31:20
2210dnl ----------------
2211dnl SVr4 curses should have term.h as well (where it puts the definitions of
2212dnl the low-level interface).  This may not be true in old/broken implementations,
2213dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
2214dnl running with Solaris 2.5.1).
2215AC_DEFUN([CF_CURSES_TERM_H],
2216[
2217AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2218
2219AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
2220
2221# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
2222# for <term.h> if we do not find the variant.
2223
2224cf_header_list="term.h ncurses/term.h ncursesw/term.h"
2225
2226case "${cf_cv_ncurses_header:-curses.h}" in
2227(*/*)
2228	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
2229	cf_header_list="$cf_header_item $cf_header_list"
2230	;;
2231esac
2232
2233for cf_header in $cf_header_list
2234do
2235	AC_TRY_COMPILE([
2236#include <${cf_cv_ncurses_header:-curses.h}>
2237#include <${cf_header}>],
2238	[WINDOW *x; (void)x],
2239	[cf_cv_term_header=$cf_header
2240	 break],
2241	[cf_cv_term_header=no])
2242done
2243
2244case "$cf_cv_term_header" in
2245(no)
2246	# If curses is ncurses, some packagers still mess it up by trying to make
2247	# us use GNU termcap.  This handles the most common case.
2248	for cf_header in ncurses/term.h ncursesw/term.h
2249	do
2250		AC_TRY_COMPILE([
2251#include <${cf_cv_ncurses_header:-curses.h}>
2252#ifdef NCURSES_VERSION
2253#include <${cf_header}>
2254#else
2255make an error
2256#endif],
2257			[WINDOW *x; (void)x],
2258			[cf_cv_term_header=$cf_header
2259			 break],
2260			[cf_cv_term_header=no])
2261	done
2262	;;
2263esac
2264])
2265
2266case "$cf_cv_term_header" in
2267(term.h)
2268	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
2269	;;
2270(ncurses/term.h)
2271	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
2272	;;
2273(ncursesw/term.h)
2274	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
2275	;;
2276esac
2277])dnl
2278dnl ---------------------------------------------------------------------------
2279dnl CF_CURSES_UNCTRL_H version: 8 updated: 2021/01/02 09:31:20
2280dnl ------------------
2281dnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
2282dnl may put it in a subdirectory (along with ncurses' other headers, of
2283dnl course).  Packages which put the headers in inconsistent locations are
2284dnl broken).
2285AC_DEFUN([CF_CURSES_UNCTRL_H],
2286[
2287AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2288
2289AC_CACHE_CHECK(for unctrl.h, cf_cv_unctrl_header,[
2290
2291# If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
2292# for <unctrl.h> if we do not find the variant.
2293
2294cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
2295
2296case "${cf_cv_ncurses_header:-curses.h}" in
2297(*/*)
2298	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
2299	cf_header_list="$cf_header_item $cf_header_list"
2300	;;
2301esac
2302
2303for cf_header in $cf_header_list
2304do
2305	AC_TRY_COMPILE([
2306#include <${cf_cv_ncurses_header:-curses.h}>
2307#include <${cf_header}>],
2308	[WINDOW *x; (void)x],
2309	[cf_cv_unctrl_header=$cf_header
2310	 break],
2311	[cf_cv_unctrl_header=no])
2312done
2313])
2314
2315case "$cf_cv_unctrl_header" in
2316(no)
2317	AC_MSG_WARN(unctrl.h header not found)
2318	;;
2319esac
2320
2321case "$cf_cv_unctrl_header" in
2322(unctrl.h)
2323	AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
2324	;;
2325(ncurses/unctrl.h)
2326	AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
2327	;;
2328(ncursesw/unctrl.h)
2329	AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
2330	;;
2331esac
2332])dnl
2333dnl ---------------------------------------------------------------------------
2334dnl CF_CURS_PERFORMANCE version: 6 updated: 2021/01/02 09:31:20
2335dnl -------------------
2336dnl Solaris 2.x curses provides a "performance" tradeoff according to whether
2337dnl CURS_PERFORMANCE is defined.  If defined, the implementation defines macros
2338dnl that access the WINDOW structure.  Otherwise, function calls are used.
2339AC_DEFUN([CF_CURS_PERFORMANCE],
2340[
2341AC_MSG_CHECKING([for curses performance tradeoff])
2342AC_CACHE_VAL(cf_cv_curs_performance,[
2343    cf_cv_curs_performance=no
2344    AC_TRY_COMPILE([
2345#include <${cf_cv_ncurses_header:-curses.h}>],[
2346#if defined(wbkgdset) && defined(clearok) && defined(getbkgd)
2347	int x = ERR;
2348#else
2349	int x = ;	/* force an error */
2350#endif
2351	],[
2352	AC_TRY_COMPILE([
2353#define CURS_PERFORMANCE
2354#include <${cf_cv_ncurses_header:-curses.h}>],[
2355#if defined(wbkgdset) && defined(clearok) && defined(getbkgd)
2356	int x = ;	/* force an error */
2357#else
2358	int x = ERR;
2359#endif
2360	],[cf_cv_curs_performance=yes])])])
2361AC_MSG_RESULT($cf_cv_curs_performance)
2362test "$cf_cv_curs_performance" = yes && AC_DEFINE(CURS_PERFORMANCE,1,[Define to 1 ifr curses performance tradeoff available])
2363])dnl
2364dnl ---------------------------------------------------------------------------
2365dnl CF_CURS_TOUCHLINE version: 5 updated: 2015/04/15 19:08:48
2366dnl -----------------
2367dnl Check for the flavor of the touchline function, to distinguish between BSD
2368dnl and SYSV.  This is needed on NetBSD 1.5 which has a partial implementation
2369dnl of SVR4 curses.
2370AC_DEFUN([CF_CURS_TOUCHLINE],[
2371AC_CACHE_CHECK(for curses touchline function,cf_cv_curs_touchline,[
2372	AC_TRY_LINK([
2373#include <${cf_cv_ncurses_header:-curses.h}>],
2374	[touchline(stdscr, 1,2,3);],
2375	[cf_cv_curs_touchline=bsd],
2376	[AC_TRY_LINK([
2377#include <${cf_cv_ncurses_header:-curses.h}>],
2378		[touchline(stdscr, 1,2);],
2379		[cf_cv_curs_touchline=sysv],
2380		[cf_cv_curs_touchline=bsd])])])
2381case "$cf_cv_curs_touchline" in
2382(bsd)
2383	AC_DEFINE(HAVE_BSD_TOUCHLINE,1,[Define to 1 if curses has bsd-style touchline])
2384	;;
2385(sysv)
2386	AC_DEFINE(HAVE_SYSV_TOUCHLINE,1,[Define to 1 if curses has sysv-style touchline])
2387	;;
2388esac
2389])dnl
2390dnl ---------------------------------------------------------------------------
2391dnl CF_DEFINE_PROG version: 5 updated: 2021/01/02 09:31:20
2392dnl --------------
2393dnl Check for a program in the given list $3, defining the corresponding
2394dnl program variable $2.
2395dnl
2396AC_DEFUN([CF_DEFINE_PROG],[
2397AC_MSG_CHECKING(for $1)
2398AC_CACHE_VAL(cf_cv_$2,[
2399	cf_cv_$2=unknown
2400	for cv_path in $3
2401	do
2402		if test -f "$cv_path" ; then
2403			cf_cv_$2="$cv_path"
2404			break
2405		fi
2406	done
2407	])
2408AC_MSG_RESULT($cf_cv_$2)
2409AC_DEFINE_UNQUOTED($2,"$cf_cv_$2",[Define to program from list])
2410])dnl
2411dnl ---------------------------------------------------------------------------
2412dnl CF_DIRNAME version: 5 updated: 2020/12/31 20:19:42
2413dnl ----------
2414dnl "dirname" is not portable, so we fake it with a shell script.
2415AC_DEFUN([CF_DIRNAME],[$1=`echo "$2" | sed -e 's%/[[^/]]*$%%'`])dnl
2416dnl ---------------------------------------------------------------------------
2417dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
2418dnl ---------------
2419dnl You can always use "make -n" to see the actual options, but it's hard to
2420dnl pick out/analyze warning messages when the compile-line is long.
2421dnl
2422dnl Sets:
2423dnl	ECHO_LT - symbol to control if libtool is verbose
2424dnl	ECHO_LD - symbol to prefix "cc -o" lines
2425dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
2426dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
2427dnl	ECHO_CC - symbol to put before any "cc" line
2428dnl
2429AC_DEFUN([CF_DISABLE_ECHO],[
2430AC_MSG_CHECKING(if you want to see long compiling messages)
2431CF_ARG_DISABLE(echo,
2432	[  --disable-echo          do not display "compiling" commands],
2433	[
2434	ECHO_LT='--silent'
2435	ECHO_LD='@echo linking [$]@;'
2436	RULE_CC='@echo compiling [$]<'
2437	SHOW_CC='@echo compiling [$]@'
2438	ECHO_CC='@'
2439],[
2440	ECHO_LT=''
2441	ECHO_LD=''
2442	RULE_CC=''
2443	SHOW_CC=''
2444	ECHO_CC=''
2445])
2446AC_MSG_RESULT($enableval)
2447AC_SUBST(ECHO_LT)
2448AC_SUBST(ECHO_LD)
2449AC_SUBST(RULE_CC)
2450AC_SUBST(SHOW_CC)
2451AC_SUBST(ECHO_CC)
2452])dnl
2453dnl ---------------------------------------------------------------------------
2454dnl CF_DISABLE_RPATH_HACK version: 3 updated: 2021/01/05 20:14:44
2455dnl ---------------------
2456dnl The rpath-hack makes it simpler to build programs, particularly with the
2457dnl *BSD ports which may have essential libraries in unusual places.  But it
2458dnl can interfere with building an executable for the base system.  Use this
2459dnl option in that case.
2460AC_DEFUN([CF_DISABLE_RPATH_HACK],
2461[
2462AC_MSG_CHECKING(if rpath-hack should be disabled)
2463CF_ARG_DISABLE(rpath-hack,
2464	[  --disable-rpath-hack    don't add rpath options for additional libraries],
2465	[enable_rpath_hack=no],
2466	[enable_rpath_hack=yes])
2467dnl TODO - drop cf_disable_rpath_hack
2468if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
2469AC_MSG_RESULT($cf_disable_rpath_hack)
2470
2471if test "$enable_rpath_hack" = yes ; then
2472	CF_RPATH_HACK
2473fi
2474])
2475dnl ---------------------------------------------------------------------------
2476dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
2477dnl ------------------
2478dnl Configure-option to enable gcc warnings
2479dnl
2480dnl $1 = extra options to add, if supported
2481dnl $2 = option for checking attributes.  By default, this is done when
2482dnl      warnings are enabled.  For other values:
2483dnl      yes: always do this, e.g., to use in generated library-headers
2484dnl      no: never do this
2485AC_DEFUN([CF_ENABLE_WARNINGS],[
2486if test "$GCC" = yes || test "$GXX" = yes
2487then
2488CF_FIX_WARNINGS(CFLAGS)
2489CF_FIX_WARNINGS(CPPFLAGS)
2490CF_FIX_WARNINGS(LDFLAGS)
2491AC_MSG_CHECKING(if you want to turn on gcc warnings)
2492CF_ARG_ENABLE(warnings,
2493	[  --enable-warnings       test: turn on gcc compiler warnings],
2494	[enable_warnings=yes],
2495	[enable_warnings=no])
2496AC_MSG_RESULT($enable_warnings)
2497if test "$enable_warnings" = "yes"
2498then
2499	ifelse($2,,[CF_GCC_ATTRIBUTES])
2500	CF_GCC_WARNINGS($1)
2501fi
2502ifelse($2,yes,[CF_GCC_ATTRIBUTES])
2503fi
2504])dnl
2505dnl ---------------------------------------------------------------------------
2506dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
2507dnl --------
2508dnl Check if 'errno' is declared in <errno.h>
2509AC_DEFUN([CF_ERRNO],
2510[
2511CF_CHECK_ERRNO(errno)
2512])dnl
2513dnl ---------------------------------------------------------------------------
2514dnl CF_FANCY_CURSES version: 7 updated: 2021/01/02 09:31:20
2515dnl ---------------
2516AC_DEFUN([CF_FANCY_CURSES],
2517[
2518AC_MSG_CHECKING(if curses supports fancy attributes)
2519AC_CACHE_VAL(cf_cv_fancy_curses,[
2520	AC_TRY_LINK([
2521#include <${cf_cv_ncurses_header:-curses.h}>
2522],
2523	[attrset(A_UNDERLINE|A_BOLD|A_REVERSE);
2524	 wattrset(stdscr, A_BLINK|A_DIM);
2525	 attroff(A_BOLD);
2526	 keypad(stdscr,TRUE);
2527	],
2528	[cf_cv_fancy_curses=yes],
2529	[cf_cv_fancy_curses=no])
2530	])
2531AC_MSG_RESULT($cf_cv_fancy_curses)
2532test "$cf_cv_fancy_curses" = yes && AC_DEFINE(FANCY_CURSES,1,[Define to 1 if curses supports fancy attributes])
2533])dnl
2534dnl ---------------------------------------------------------------------------
2535dnl CF_FIND_IPV6_LIBS version: 9 updated: 2021/01/02 09:31:20
2536dnl -----------------
2537dnl Based on the IPV6 stack type, look for the corresponding library.
2538AC_DEFUN([CF_FIND_IPV6_LIBS],[
2539AC_REQUIRE([CF_FIND_IPV6_TYPE])
2540
2541cf_ipv6lib=none
2542cf_ipv6dir=none
2543
2544AC_MSG_CHECKING(for IPv6 library if required)
2545case "$cf_cv_ipv6type" in
2546(solaris)
2547	;;
2548(inria)
2549	;;
2550(kame)
2551	dnl http://www.kame.net/
2552	cf_ipv6lib=inet6
2553	cf_ipv6dir=v6
2554	;;
2555(linux-glibc)
2556	;;
2557(linux-libinet6)
2558	dnl http://www.v6.linux.or.jp/
2559	cf_ipv6lib=inet6
2560	cf_ipv6dir=inet6
2561	;;
2562(toshiba)
2563	cf_ipv6lib=inet6
2564	cf_ipv6dir=v6
2565	;;
2566(v6d)
2567	cf_ipv6lib=v6
2568	cf_ipv6dir=v6
2569	;;
2570(zeta)
2571	cf_ipv6lib=inet6
2572	cf_ipv6dir=v6
2573	;;
2574esac
2575AC_MSG_RESULT($cf_ipv6lib)
2576
2577if test "$cf_ipv6lib" != "none"; then
2578
2579	AC_TRY_LINK([
2580#include <sys/types.h>
2581#include <netdb.h>
2582#include <netinet/in.h>
2583#include <netinet/ip6.h>],
2584	[getaddrinfo(0, 0, 0, 0)],,[
2585	CF_HEADER_PATH(cf_search,$cf_ipv6dir)
2586	for cf_incdir in $cf_search
2587	do
2588		cf_header=$cf_incdir/netinet/ip6.h
2589		if test -f "$cf_header"
2590		then
2591			CF_ADD_INCDIR($cf_incdir)
2592			test -n "$verbose" && echo "	... found $cf_header" 1>&AC_FD_MSG
2593			break
2594		fi
2595		test -n "$verbose" && echo "	... tested $cf_header" 1>&AC_FD_MSG
2596	done
2597	])
2598
2599	CF_FIND_LIBRARY([$cf_ipv6lib],[$cf_ipv6dir],[
2600#include <sys/types.h>
2601#include <netdb.h>
2602#include <netinet/in.h>
2603#include <netinet/ip6.h>],
2604	[getaddrinfo(0, 0, 0, 0)],
2605	[getaddrinfo],
2606	noexit)
2607	if test "$cf_found_library" = no ; then
2608		AC_MSG_ERROR(
2609[No $cf_ipv6lib library found, cannot continue.  You must fetch lib$cf_ipv6lib.a
2610from an appropriate IPv6 kit and compile beforehand.])
2611	fi
2612fi
2613
2614])dnl
2615dnl ---------------------------------------------------------------------------
2616dnl CF_FIND_IPV6_TYPE version: 7 updated: 2021/01/02 09:31:20
2617dnl -----------------
2618AC_DEFUN([CF_FIND_IPV6_TYPE],[
2619AC_CACHE_CHECK(ipv6 stack type, cf_cv_ipv6type, [
2620cf_cv_ipv6type=unknown
2621for i in solaris inria kame linux-glibc linux-libinet6 toshiba v6d zeta
2622do
2623	case "$i" in
2624	(solaris)
2625		if test "SunOS" = "`uname -s`"
2626		then
2627		  if test -f /usr/include/netinet/ip6.h
2628		  then
2629			cf_cv_ipv6type=$i
2630		  fi
2631		fi
2632		;;
2633	(inria)
2634		dnl http://www.kame.net/
2635		AC_EGREP_CPP(yes, [
2636#include <netinet/in.h>
2637#ifdef IPV6_INRIA_VERSION
2638yes
2639#endif],	[cf_cv_ipv6type=$i])
2640		;;
2641	(kame)
2642		dnl http://www.kame.net/
2643		AC_EGREP_CPP(yes, [
2644#include <netinet/in.h>
2645#ifdef __KAME__
2646yes
2647#endif],	[cf_cv_ipv6type=$i])
2648		;;
2649	(linux-glibc)
2650		dnl http://www.v6.linux.or.jp/
2651		AC_EGREP_CPP(yes, [
2652#include <features.h>
2653#if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
2654yes
2655#endif],	[cf_cv_ipv6type=$i])
2656		;;
2657	(linux-libinet6)
2658		dnl http://www.v6.linux.or.jp/
2659		if test -d /usr/inet6
2660		then
2661			cf_cv_ipv6type=$i
2662		elif test -f /usr/include/netinet/ip6.h
2663		then
2664			cf_cv_ipv6type=$i
2665		fi
2666		;;
2667	(toshiba)
2668		AC_EGREP_CPP(yes, [
2669#include <sys/param.h>
2670#ifdef _TOSHIBA_INET6
2671yes
2672#endif],	[cf_cv_ipv6type=$i])
2673		;;
2674	(v6d)
2675		AC_EGREP_CPP(yes, [
2676#include </usr/local/v6/include/sys/v6config.h>
2677#ifdef __V6D__
2678yes
2679#endif],	[cf_cv_ipv6type=$i])
2680		;;
2681	(zeta)
2682		AC_EGREP_CPP(yes, [
2683#include <sys/param.h>
2684#ifdef _ZETA_MINAMI_INET6
2685yes
2686#endif],	[cf_cv_ipv6type=$i])
2687		;;
2688	esac
2689	if test "$cf_cv_ipv6type" != "unknown"; then
2690		break
2691	fi
2692done
2693])
2694])dnl
2695dnl ---------------------------------------------------------------------------
2696dnl CF_FIND_LIBRARY version: 11 updated: 2021/01/02 09:31:20
2697dnl ---------------
2698dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
2699dnl prefer a standard location, and use -L options only if we do not find the
2700dnl library in the standard library location(s).
2701dnl	$1 = library name
2702dnl	$2 = library class, usually the same as library name
2703dnl	$3 = includes
2704dnl	$4 = code fragment to compile/link
2705dnl	$5 = corresponding function-name
2706dnl	$6 = flag, nonnull if failure should not cause an error-exit
2707dnl
2708dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
2709dnl to use a -L option.
2710AC_DEFUN([CF_FIND_LIBRARY],
2711[
2712	eval 'cf_cv_have_lib_'"$1"'=no'
2713	cf_libdir=""
2714	AC_CHECK_FUNC($5,
2715		eval 'cf_cv_have_lib_'"$1"'=yes',[
2716		cf_save_LIBS="$LIBS"
2717		AC_MSG_CHECKING(for $5 in -l$1)
2718		LIBS="-l$1 $LIBS"
2719		AC_TRY_LINK([$3],[$4],
2720			[AC_MSG_RESULT(yes)
2721			 eval 'cf_cv_have_lib_'"$1"'=yes'
2722			],
2723			[AC_MSG_RESULT(no)
2724			CF_LIBRARY_PATH(cf_search,$2)
2725			for cf_libdir in $cf_search
2726			do
2727				AC_MSG_CHECKING(for -l$1 in $cf_libdir)
2728				LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
2729				AC_TRY_LINK([$3],[$4],
2730					[AC_MSG_RESULT(yes)
2731			 		 eval 'cf_cv_have_lib_'"$1"'=yes'
2732					 break],
2733					[AC_MSG_RESULT(no)
2734					 LIBS="$cf_save_LIBS"])
2735			done
2736			])
2737		])
2738eval 'cf_found_library="[$]cf_cv_have_lib_'"$1"\"
2739ifelse($6,,[
2740if test "$cf_found_library" = no ; then
2741	AC_MSG_ERROR(Cannot link $1 library)
2742fi
2743])
2744])dnl
2745dnl ---------------------------------------------------------------------------
2746dnl CF_FIND_LINKAGE version: 22 updated: 2020/12/31 20:19:42
2747dnl ---------------
2748dnl Find a library (specifically the linkage used in the code fragment),
2749dnl searching for it if it is not already in the library path.
2750dnl See also CF_ADD_SEARCHPATH.
2751dnl
2752dnl Parameters (4-on are optional):
2753dnl     $1 = headers for library entrypoint
2754dnl     $2 = code fragment for library entrypoint
2755dnl     $3 = the library name without the "-l" option or ".so" suffix.
2756dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
2757dnl     $5 = action to perform if not successful
2758dnl     $6 = module name, if not the same as the library name
2759dnl     $7 = extra libraries
2760dnl
2761dnl Sets these variables:
2762dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
2763dnl     $cf_cv_header_path_$3 - include-directory if needed
2764dnl     $cf_cv_library_path_$3 - library-directory if needed
2765dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
2766AC_DEFUN([CF_FIND_LINKAGE],[
2767
2768# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
2769# will be set on completion of the AC_TRY_LINK below.
2770cf_cv_header_path_$3=
2771cf_cv_library_path_$3=
2772
2773CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
2774
2775cf_save_LIBS="$LIBS"
2776
2777AC_TRY_LINK([$1],[$2],[
2778	cf_cv_find_linkage_$3=yes
2779	cf_cv_header_path_$3=/usr/include
2780	cf_cv_library_path_$3=/usr/lib
2781],[
2782
2783LIBS="-l$3 $7 $cf_save_LIBS"
2784
2785AC_TRY_LINK([$1],[$2],[
2786	cf_cv_find_linkage_$3=yes
2787	cf_cv_header_path_$3=/usr/include
2788	cf_cv_library_path_$3=/usr/lib
2789	cf_cv_library_file_$3="-l$3"
2790],[
2791	cf_cv_find_linkage_$3=no
2792	LIBS="$cf_save_LIBS"
2793
2794	CF_VERBOSE(find linkage for $3 library)
2795	CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
2796
2797	cf_save_CPPFLAGS="$CPPFLAGS"
2798	cf_test_CPPFLAGS="$CPPFLAGS"
2799
2800	CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
2801	for cf_cv_header_path_$3 in $cf_search
2802	do
2803		if test -d "$cf_cv_header_path_$3" ; then
2804			CF_VERBOSE(... testing $cf_cv_header_path_$3)
2805			CPPFLAGS="$cf_save_CPPFLAGS"
2806			CF_APPEND_TEXT(CPPFLAGS,-I$cf_cv_header_path_$3)
2807			AC_TRY_COMPILE([$1],[$2],[
2808				CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
2809				cf_cv_find_linkage_$3=maybe
2810				cf_test_CPPFLAGS="$CPPFLAGS"
2811				break],[
2812				CPPFLAGS="$cf_save_CPPFLAGS"
2813				])
2814		fi
2815	done
2816
2817	if test "$cf_cv_find_linkage_$3" = maybe ; then
2818
2819		CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
2820
2821		cf_save_LIBS="$LIBS"
2822		cf_save_LDFLAGS="$LDFLAGS"
2823
2824		ifelse([$6],,,[
2825		CPPFLAGS="$cf_test_CPPFLAGS"
2826		LIBS="-l$3 $7 $cf_save_LIBS"
2827		AC_TRY_LINK([$1],[$2],[
2828			CF_VERBOSE(... found $3 library in system)
2829			cf_cv_find_linkage_$3=yes])
2830			CPPFLAGS="$cf_save_CPPFLAGS"
2831			LIBS="$cf_save_LIBS"
2832			])
2833
2834		if test "$cf_cv_find_linkage_$3" != yes ; then
2835			CF_LIBRARY_PATH(cf_search,$3)
2836			for cf_cv_library_path_$3 in $cf_search
2837			do
2838				if test -d "$cf_cv_library_path_$3" ; then
2839					CF_VERBOSE(... testing $cf_cv_library_path_$3)
2840					CPPFLAGS="$cf_test_CPPFLAGS"
2841					LIBS="-l$3 $7 $cf_save_LIBS"
2842					LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
2843					AC_TRY_LINK([$1],[$2],[
2844					CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
2845					cf_cv_find_linkage_$3=yes
2846					cf_cv_library_file_$3="-l$3"
2847					break],[
2848					CPPFLAGS="$cf_save_CPPFLAGS"
2849					LIBS="$cf_save_LIBS"
2850					LDFLAGS="$cf_save_LDFLAGS"
2851					])
2852				fi
2853			done
2854			CPPFLAGS="$cf_save_CPPFLAGS"
2855			LDFLAGS="$cf_save_LDFLAGS"
2856		fi
2857
2858	else
2859		cf_cv_find_linkage_$3=no
2860	fi
2861	],$7)
2862])
2863
2864LIBS="$cf_save_LIBS"
2865
2866if test "$cf_cv_find_linkage_$3" = yes ; then
2867ifelse([$4],,[
2868	CF_ADD_INCDIR($cf_cv_header_path_$3)
2869	CF_ADD_LIBDIR($cf_cv_library_path_$3)
2870	CF_ADD_LIB($3)
2871],[$4])
2872else
2873ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
2874fi
2875])dnl
2876dnl ---------------------------------------------------------------------------
2877dnl CF_FIONBIO version: 4 updated: 2021/06/08 18:08:14
2878dnl ----------
2879dnl Check for availability of fcntl versus ioctl(,FIONBIO,).  Lynx uses this
2880dnl for Sequent (ptx), and it is needed for OS/2 EMX.
2881AC_DEFUN([CF_FIONBIO],
2882[
2883AC_CACHE_CHECK(if we should use fcntl or ioctl,cf_cv_fionbio,[
2884AC_TRY_LINK([
2885#include <sys/types.h>
2886#include <sys/ioctl.h>
2887],[
2888        int ret = ioctl(0, FIONBIO, (char *)0); (void) ret
2889	],[cf_cv_fionbio=ioctl],[
2890AC_TRY_LINK([
2891#include <sys/types.h>
2892#if HAVE_FCNTL_H
2893#include <fcntl.h>
2894#else
2895#if HAVE_SYS_FCNTL_H
2896#include <sys/fcntl.h>
2897#endif
2898#endif],[
2899        int ret = fcntl(0, F_SETFL, O_NONBLOCK);
2900	],
2901	[cf_cv_fionbio=fcntl],
2902	[cf_cv_fionbio=unknown])])
2903])
2904test "$cf_cv_fionbio" = "fcntl" && AC_DEFINE(USE_FCNTL,1,[Define to 1 if we should use fcntl])
2905])dnl
2906dnl ---------------------------------------------------------------------------
2907dnl CF_FIX_WARNINGS version: 3 updated: 2020/12/31 18:40:20
2908dnl ---------------
2909dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
2910dnl "-Werror" flags can interfere with configure-checks.  Those go into
2911dnl EXTRA_CFLAGS.
2912dnl
2913dnl $1 = variable name to repair
2914define([CF_FIX_WARNINGS],[
2915if test "$GCC" = yes || test "$GXX" = yes
2916then
2917	case [$]$1 in
2918	(*-Werror=*)
2919		CF_VERBOSE(repairing $1: [$]$1)
2920		cf_temp_flags=
2921		for cf_temp_scan in [$]$1
2922		do
2923			case "x$cf_temp_scan" in
2924			(x-Werror=*)
2925				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
2926				;;
2927			(*)
2928				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
2929				;;
2930			esac
2931		done
2932		$1="$cf_temp_flags"
2933		CF_VERBOSE(... fixed [$]$1)
2934		CF_VERBOSE(... extra $EXTRA_CFLAGS)
2935		;;
2936	esac
2937fi
2938AC_SUBST(EXTRA_CFLAGS)
2939])dnl
2940dnl ---------------------------------------------------------------------------
2941dnl CF_FUNC_CURSES_VERSION version: 8 updated: 2021/01/02 09:31:20
2942dnl ----------------------
2943dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
2944dnl It's a character string "SVR4", not documented.
2945AC_DEFUN([CF_FUNC_CURSES_VERSION],
2946[
2947AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
2948AC_TRY_RUN([
2949#include <${cf_cv_ncurses_header:-curses.h}>
2950int main(void)
2951{
2952	char temp[1024];
2953	sprintf(temp, "%s\\n", curses_version());
2954	${cf_cv_main_return:-return}(0);
2955}]
2956,[cf_cv_func_curses_version=yes]
2957,[cf_cv_func_curses_version=no]
2958,[cf_cv_func_curses_version=unknown])
2959rm -f core])
2960test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION,1,[Define to 1 if we have curses_version function])
2961])
2962dnl ---------------------------------------------------------------------------
2963dnl CF_FUNC_GETADDRINFO version: 9 updated: 2017/05/10 18:31:29
2964dnl -------------------
2965dnl Look for a working version of getaddrinfo(), for IPV6 support.
2966AC_DEFUN([CF_FUNC_GETADDRINFO],[
2967AC_CACHE_CHECK(working getaddrinfo, cf_cv_getaddrinfo,[
2968AC_TRY_RUN([
2969#include <sys/types.h>
2970#include <netdb.h>
2971#include <string.h>
2972#include <sys/socket.h>
2973#include <netinet/in.h>
2974
2975#define expect(a,b) if (strcmp(a,b) != 0) goto bad
2976
2977int main(void)
2978{
2979   int passive, gaierr, inet4 = 0, inet6 = 0;
2980   struct addrinfo hints, *ai, *aitop;
2981   char straddr[INET6_ADDRSTRLEN], strport[16];
2982
2983   for (passive = 0; passive <= 1; passive++) {
2984     memset(&hints, 0, sizeof(hints));
2985     hints.ai_family = AF_UNSPEC;
2986     hints.ai_flags = passive ? AI_PASSIVE : 0;
2987     hints.ai_socktype = SOCK_STREAM;
2988     if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) {
2989       (void)gai_strerror(gaierr);
2990       goto bad;
2991     }
2992     for (ai = aitop; ai; ai = ai->ai_next) {
2993       if (ai->ai_addr == NULL ||
2994           ai->ai_addrlen == 0 ||
2995           getnameinfo(ai->ai_addr, ai->ai_addrlen,
2996                       straddr, sizeof(straddr), strport, sizeof(strport),
2997                       NI_NUMERICHOST|NI_NUMERICSERV) != 0) {
2998         goto bad;
2999       }
3000       switch (ai->ai_family) {
3001       case AF_INET:
3002         expect(strport, "54321");
3003         if (passive) {
3004           expect(straddr, "0.0.0.0");
3005         } else {
3006           expect(straddr, "127.0.0.1");
3007         }
3008         inet4++;
3009         break;
3010       case AF_INET6:
3011         expect(strport, "54321");
3012         if (passive) {
3013           expect(straddr, "::");
3014         } else {
3015           expect(straddr, "::1");
3016         }
3017         inet6++;
3018         break;
3019       case AF_UNSPEC:
3020         goto bad;
3021         break;
3022       default:
3023         /* another family support? */
3024         break;
3025       }
3026     }
3027   }
3028
3029   if (!(inet4 == 0 || inet4 == 2))
3030     goto bad;
3031   if (!(inet6 == 0 || inet6 == 2))
3032     goto bad;
3033
3034   if (aitop)
3035     freeaddrinfo(aitop);
3036   ${cf_cv_main_return:-return}(0);
3037
3038  bad:
3039   if (aitop)
3040     freeaddrinfo(aitop);
3041   ${cf_cv_main_return:-return}(1);
3042}
3043],
3044[cf_cv_getaddrinfo=yes],
3045[cf_cv_getaddrinfo=no],
3046[cf_cv_getaddrinfo=unknown])
3047])
3048if test "$cf_cv_getaddrinfo" = yes ; then
3049	AC_DEFINE(HAVE_GAI_STRERROR,1,[Define to 1 if we have gai_strerror function])
3050	AC_DEFINE(HAVE_GETADDRINFO,1,[Define to 1 if we have getaddrinfo function])
3051fi
3052])dnl
3053dnl ---------------------------------------------------------------------------
3054dnl CF_FUNC_LSTAT version: 5 updated: 2021/06/08 18:08:14
3055dnl -------------
3056dnl A conventional existence-check for 'lstat' won't work with the Linux
3057dnl version of gcc 2.7.0, since the symbol is defined only within <sys/stat.h>
3058dnl as an inline function.
3059dnl
3060dnl So much for portability.
3061AC_DEFUN([CF_FUNC_LSTAT],
3062[
3063AC_MSG_CHECKING(for lstat)
3064AC_CACHE_VAL(ac_cv_func_lstat,[
3065AC_TRY_LINK([
3066#include <sys/types.h>
3067#include <sys/stat.h>],
3068	[struct stat sb; lstat(".", &sb); (void) sb],
3069	[ac_cv_func_lstat=yes],
3070	[ac_cv_func_lstat=no])
3071	])
3072AC_MSG_RESULT($ac_cv_func_lstat )
3073if test "$ac_cv_func_lstat" = yes; then
3074	AC_DEFINE(HAVE_LSTAT,1,[Define to 1 if we have lstat])
3075fi
3076])dnl
3077dnl ---------------------------------------------------------------------------
3078dnl CF_FUNC_SIGACTION version: 3 updated: 2012/11/08 20:57:52
3079dnl -----------------
3080dnl Check if we have the sigaction function and related structures.
3081AC_DEFUN([CF_FUNC_SIGACTION],[
3082AC_CACHE_CHECK(for sigaction and structs,cf_cv_func_sigaction,[
3083AC_TRY_LINK([
3084#include <sys/types.h>
3085#include <signal.h>],
3086	[struct sigaction act;
3087	act.sa_handler = SIG_DFL;
3088#ifdef SA_RESTART
3089	act.sa_flags |= SA_RESTART;
3090#endif /* SA_RESTART */
3091	sigaction(1, &act, 0);
3092	],
3093	[cf_cv_func_sigaction=yes],
3094	[cf_cv_func_sigaction=no])
3095])
3096test "$cf_cv_func_sigaction" = yes && AC_DEFINE(HAVE_SIGACTION,1,[Define to 1 if we have sigaction])
3097])dnl
3098dnl ---------------------------------------------------------------------------
3099dnl CF_FUNC_VASPRINTF version: 2 updated: 2019/12/31 10:27:03
3100dnl -----------------
3101dnl Check if vasprintf is available, and if it is (or can be) declared.
3102AC_DEFUN([CF_FUNC_VASPRINTF],[
3103AC_REQUIRE([CF_GNU_SOURCE])
3104AC_CHECK_FUNC(vasprintf,[
3105	AC_DEFINE(HAVE_VASPRINTF,1,[Define to 1 if we have vasprintf])
3106	AC_MSG_CHECKING(if vasprintf requires workaround)
3107	AC_TRY_COMPILE([
3108		#include <stdio.h>
3109		],[
3110		void *p = (void *)vasprintf; return (p != 0)
3111	],[
3112		AC_MSG_RESULT(no)
3113	],[
3114		AC_TRY_COMPILE([
3115			#ifndef _GNU_SOURCE
3116			#define _GNU_SOURCE 1
3117			#include <stdio.h>
3118			#endif
3119			],[
3120			void *p = (void *)vasprintf; return (p != 0)
3121		],[
3122			AC_MSG_RESULT(yes)
3123			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
3124		],[
3125			AC_MSG_RESULT(unknown)
3126		])
3127	])
3128])
3129])dnl
3130dnl ---------------------------------------------------------------------------
3131dnl CF_FUNC_WAIT version: 4 updated: 2021/01/02 09:31:20
3132dnl ------------
3133dnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
3134dnl and/or 'waitpid()'.
3135dnl
3136dnl Note that we cannot simply grep for 'union wait' in the wait.h file,
3137dnl because some Posix systems turn this on only when a BSD variable is
3138dnl defined.
3139dnl
3140dnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
3141dnl would conflict with an attempt to test that header directly.
3142dnl
3143AC_DEFUN([CF_FUNC_WAIT],
3144[
3145AC_REQUIRE([CF_UNION_WAIT])
3146if test "$cf_cv_type_unionwait" = yes; then
3147
3148	AC_MSG_CHECKING(if union wait can be used as wait-arg)
3149	AC_CACHE_VAL(cf_cv_arg_union_wait,[
3150		AC_TRY_COMPILE($cf_wait_headers,
3151 			[union wait x; wait(&x)],
3152			[cf_cv_arg_union_wait=yes],
3153			[cf_cv_arg_union_wait=no])
3154		])
3155	AC_MSG_RESULT($cf_cv_arg_union_wait)
3156	test "$cf_cv_arg_union_wait" = yes && AC_DEFINE(WAIT_USES_UNION,1,[Define to 1 if wait() uses a union parameter])
3157
3158	AC_MSG_CHECKING(if union wait can be used as waitpid-arg)
3159	AC_CACHE_VAL(cf_cv_arg_union_waitpid,[
3160		AC_TRY_COMPILE($cf_wait_headers,
3161 			[union wait x; waitpid(0, &x, 0)],
3162			[cf_cv_arg_union_waitpid=yes],
3163			[cf_cv_arg_union_waitpid=no])
3164		])
3165	AC_MSG_RESULT($cf_cv_arg_union_waitpid)
3166	test "$cf_cv_arg_union_waitpid" = yes && AC_DEFINE(WAITPID_USES_UNION,1,[Define to 1 if waitpid() uses a union parameter])
3167
3168fi
3169])dnl
3170dnl ---------------------------------------------------------------------------
3171dnl CF_GCC_ATTRIBUTES version: 24 updated: 2021/03/20 12:00:25
3172dnl -----------------
3173dnl Test for availability of useful gcc __attribute__ directives to quiet
3174dnl compiler warnings.  Though useful, not all are supported -- and contrary
3175dnl to documentation, unrecognized directives cause older compilers to barf.
3176AC_DEFUN([CF_GCC_ATTRIBUTES],
3177[AC_REQUIRE([AC_PROG_FGREP])dnl
3178AC_REQUIRE([CF_C11_NORETURN])dnl
3179
3180if test "$GCC" = yes || test "$GXX" = yes
3181then
3182cat > conftest.i <<EOF
3183#ifndef GCC_PRINTF
3184#define GCC_PRINTF 0
3185#endif
3186#ifndef GCC_SCANF
3187#define GCC_SCANF 0
3188#endif
3189#ifndef GCC_NORETURN
3190#define GCC_NORETURN /* nothing */
3191#endif
3192#ifndef GCC_UNUSED
3193#define GCC_UNUSED /* nothing */
3194#endif
3195EOF
3196if test "$GCC" = yes
3197then
3198	AC_CHECKING([for $CC __attribute__ directives])
3199cat > "conftest.$ac_ext" <<EOF
3200#line __oline__ "${as_me:-configure}"
3201#include "confdefs.h"
3202#include "conftest.h"
3203#include "conftest.i"
3204#if	GCC_PRINTF
3205#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
3206#else
3207#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
3208#endif
3209#if	GCC_SCANF
3210#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
3211#else
3212#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
3213#endif
3214extern void wow(char *,...) GCC_SCANFLIKE(1,2);
3215extern GCC_NORETURN void oops(char *,...) GCC_PRINTFLIKE(1,2);
3216extern GCC_NORETURN void foo(void);
3217int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
3218EOF
3219	cf_printf_attribute=no
3220	cf_scanf_attribute=no
3221	for cf_attribute in scanf printf unused noreturn
3222	do
3223		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
3224		cf_directive="__attribute__(($cf_attribute))"
3225		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
3226
3227		case "$cf_attribute" in
3228		(printf)
3229			cf_printf_attribute=yes
3230			cat >conftest.h <<EOF
3231#define GCC_$cf_ATTRIBUTE 1
3232EOF
3233			;;
3234		(scanf)
3235			cf_scanf_attribute=yes
3236			cat >conftest.h <<EOF
3237#define GCC_$cf_ATTRIBUTE 1
3238EOF
3239			;;
3240		(*)
3241			cat >conftest.h <<EOF
3242#define GCC_$cf_ATTRIBUTE $cf_directive
3243EOF
3244			;;
3245		esac
3246
3247		if AC_TRY_EVAL(ac_compile); then
3248			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
3249			cat conftest.h >>confdefs.h
3250			case "$cf_attribute" in
3251			(noreturn)
3252				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
3253				;;
3254			(printf)
3255				cf_value='/* nothing */'
3256				if test "$cf_printf_attribute" != no ; then
3257					cf_value='__attribute__((format(printf,fmt,var)))'
3258					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
3259				fi
3260				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
3261				;;
3262			(scanf)
3263				cf_value='/* nothing */'
3264				if test "$cf_scanf_attribute" != no ; then
3265					cf_value='__attribute__((format(scanf,fmt,var)))'
3266					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
3267				fi
3268				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
3269				;;
3270			(unused)
3271				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
3272				;;
3273			esac
3274		fi
3275	done
3276else
3277	${FGREP-fgrep} define conftest.i >>confdefs.h
3278fi
3279rm -rf ./conftest*
3280fi
3281])dnl
3282dnl ---------------------------------------------------------------------------
3283dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
3284dnl --------------
3285dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
3286dnl compatible), attempt to determine if icc/clang is actually used.
3287AC_DEFUN([CF_GCC_VERSION],[
3288AC_REQUIRE([AC_PROG_CC])
3289GCC_VERSION=none
3290if test "$GCC" = yes ; then
3291	AC_MSG_CHECKING(version of $CC)
3292	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.]].*//'`"
3293	test -z "$GCC_VERSION" && GCC_VERSION=unknown
3294	AC_MSG_RESULT($GCC_VERSION)
3295fi
3296CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
3297CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
3298])dnl
3299dnl ---------------------------------------------------------------------------
3300dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
3301dnl ---------------
3302dnl Check if the compiler supports useful warning options.  There's a few that
3303dnl we don't use, simply because they're too noisy:
3304dnl
3305dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
3306dnl	-Winline (usually not worthwhile)
3307dnl	-Wredundant-decls (system headers make this too noisy)
3308dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
3309dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
3310dnl		is enabled for ncurses using "--enable-const".
3311dnl	-pedantic
3312dnl
3313dnl Parameter:
3314dnl	$1 is an optional list of gcc warning flags that a particular
3315dnl		application might want to use, e.g., "no-unused" for
3316dnl		-Wno-unused
3317dnl Special:
3318dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
3319dnl
3320AC_DEFUN([CF_GCC_WARNINGS],
3321[
3322AC_REQUIRE([CF_GCC_VERSION])
3323if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
3324cat > "conftest.$ac_ext" <<EOF
3325#line __oline__ "${as_me:-configure}"
3326int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
3327EOF
3328if test "$INTEL_COMPILER" = yes
3329then
3330# The "-wdXXX" options suppress warnings:
3331# remark #1419: external declaration in primary source file
3332# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
3333# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
3334# remark #193: zero used for undefined preprocessing identifier
3335# remark #593: variable "curs_sb_left_arrow" was set but never used
3336# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
3337# remark #869: parameter "tw" was never referenced
3338# remark #981: operands are evaluated in unspecified order
3339# warning #279: controlling expression is constant
3340
3341	AC_CHECKING([for $CC warning options])
3342	cf_save_CFLAGS="$CFLAGS"
3343	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
3344	for cf_opt in \
3345		wd1419 \
3346		wd1683 \
3347		wd1684 \
3348		wd193 \
3349		wd593 \
3350		wd279 \
3351		wd810 \
3352		wd869 \
3353		wd981
3354	do
3355		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
3356		if AC_TRY_EVAL(ac_compile); then
3357			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3358			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
3359		fi
3360	done
3361	CFLAGS="$cf_save_CFLAGS"
3362elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
3363then
3364	AC_CHECKING([for $CC warning options])
3365	cf_save_CFLAGS="$CFLAGS"
3366	cf_warn_CONST=""
3367	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
3368	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
3369	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
3370	for cf_opt in W Wall \
3371		Wbad-function-cast \
3372		Wcast-align \
3373		Wcast-qual \
3374		Wdeclaration-after-statement \
3375		Wextra \
3376		Winline \
3377		Wmissing-declarations \
3378		Wmissing-prototypes \
3379		Wnested-externs \
3380		Wpointer-arith \
3381		Wshadow \
3382		Wstrict-prototypes \
3383		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
3384	do
3385		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
3386		if AC_TRY_EVAL(ac_compile); then
3387			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
3388			case "$cf_opt" in
3389			(Winline)
3390				case "$GCC_VERSION" in
3391				([[34]].*)
3392					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
3393					continue;;
3394				esac
3395				;;
3396			(Wpointer-arith)
3397				case "$GCC_VERSION" in
3398				([[12]].*)
3399					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
3400					continue;;
3401				esac
3402				;;
3403			esac
3404			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
3405		fi
3406	done
3407	CFLAGS="$cf_save_CFLAGS"
3408fi
3409rm -rf ./conftest*
3410
3411AC_SUBST(EXTRA_CFLAGS)
3412])dnl
3413dnl ---------------------------------------------------------------------------
3414dnl CF_GNUTLS version: 27 updated: 2021/01/02 09:31:20
3415dnl ---------
3416dnl Check for gnutls library (TLS "is" SSL)
3417dnl $1 = the [optional] directory in which the library may be found
3418dnl $2 = the [optional] stub file to provide OpenSSL compatibility
3419AC_DEFUN([CF_GNUTLS],[
3420	AC_REQUIRE([CF_PKG_CONFIG])
3421	cf_cv_have_gnutls=no
3422	cf_cv_pkg_config_ssl=no
3423
3424	CF_ADD_OPTIONAL_PATH($1, [ssl library])
3425
3426	cf_pkg_gnutls=none
3427	if test "x$PKG_CONFIG" != xnone; then
3428		cf_pkg_gnutls=ifelse([$2],,gnutls-openssl,gnutls)
3429		case "$1" in
3430		(no)
3431			;;
3432		(yes) # if no explicit directory given, try pkg-config
3433			CF_VERBOSE(checking pkg-config for $cf_pkg_gnutls)
3434			if "$PKG_CONFIG" --exists $cf_pkg_gnutls ; then
3435				CF_VERBOSE(... found $cf_pkg_gnutls in pkg-config)
3436				cf_cv_have_gnutls=yes
3437				cf_cv_pkg_config_ssl=yes
3438
3439				cf_cflags_ssl=`$PKG_CONFIG --cflags $cf_pkg_gnutls`
3440				cf_libs_ssl=`$PKG_CONFIG --libs $cf_pkg_gnutls`
3441
3442				if test -n "$cf_cflags_ssl" ; then
3443					case "$cf_cflags_ssl" in
3444					(*-I*)
3445						cf_cv_header_path_gnutls=`echo "$cf_cflags_ssl" | sed -e 's/^.*-I//' -e 's/ .*//'`
3446						;;
3447					(*)
3448						cf_cv_header_path_gnutls=/usr/include
3449						;;
3450					esac
3451					if test -d "$cf_cv_header_path_gnutls/gnutls" ; then
3452						cf_cv_header_path_gnutls=$cf_cv_header_path_gnutls/gnutls
3453					fi
3454					CF_ADD_CFLAGS($cf_cflags_ssl)
3455				fi
3456
3457				if test -n "$cf_libs_ssl" ; then
3458					case "x$cf_libs_ssl" in
3459					(*-L*)
3460						cf_cv_library_path_gnutls=`echo "$cf_libs_ssl" | sed -e 's/^.*-L//' -e 's/ .*//'`
3461						;;
3462					(*)
3463						cf_cv_library_path_gnutls=/usr/lib
3464						;;
3465					esac
3466					CF_VERBOSE(adding $cf_libs_ssl to LIBS)
3467					CF_ADD_LIBS($cf_libs_ssl)
3468				fi
3469			else
3470				CF_VERBOSE(... did not find $cf_pkg_gnutls in pkg-config)
3471				cf_pkg_gnutls=none
3472			fi
3473			;;
3474		esac
3475	fi
3476
3477	ifelse([$2],,
3478		[AC_DEFINE(USE_GNUTLS_INCL,1,[Define to 1 if we should include gnutls headers])],
3479		[AC_DEFINE(USE_GNUTLS_FUNCS,1,[Define to 1 if we should use gnutls functions])])
3480
3481	if test "$cf_cv_have_gnutls" = no ; then
3482		cf_gnutls_CPPFLAGS=$CPPFLAGS
3483
3484		CF_FIND_LINKAGE(CF__SSL_HEAD,
3485			CF__SSL_BODY,
3486			gnutls,
3487			cf_cv_have_gnutls=yes,
3488			cf_cv_have_gnutls=no,
3489			,
3490			ifelse([$2],,[-lgnutls-openssl]))
3491
3492		CPPFLAGS=$cf_gnutls_CPPFLAGS
3493	fi
3494
3495	if test "$cf_cv_have_gnutls" = yes ; then
3496		if test -n "$cf_cv_header_path_gnutls" ; then
3497			AC_DEFINE(USE_SSL)
3498			case "$cf_cv_header_path_gnutls" in
3499			(/usr/include/gnutls)
3500				;;
3501			(*)
3502				CF_ADD_INCDIR($cf_cv_header_path_gnutls)
3503				;;
3504			esac
3505		fi
3506		if test -n "$cf_cv_library_path_gnutls" ; then
3507			CF_ADD_LIBDIR($cf_cv_library_path_gnutls)
3508		fi
3509		CF_ADD_LIBS(-lgnutls)
3510		AC_CHECK_FUNCS(gnutls_protocol_set_priority)
3511		AC_CHECK_FUNC(gnutls_rnd,
3512				[AC_DEFINE(HAVE_GNUTLS_RND,1,[Define to 1 if we have gnutls_rnd])],
3513				[CF_ADD_LIBS(-lgcrypt)])
3514
3515		ifelse([$2],,
3516			[if test "$cf_pkg_gnutls" = none ; then
3517				AC_CHECK_LIB(gnutls-openssl,SSL_connect,
3518					[CF_ADD_LIBS(-lgnutls-openssl)],
3519					[AC_CHECK_LIB(gnutls-extra,SSL_connect,
3520					[CF_ADD_LIBS(-lgnutls-extra)],
3521					[AC_MSG_ERROR(cannot find gnutls openssl functions)])])
3522			fi],[EXTRA_OBJS="$EXTRA_OBJS $2"])
3523
3524		CF_CHECK_SSL_X509
3525	fi
3526])dnl
3527dnl ---------------------------------------------------------------------------
3528dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
3529dnl -------------
3530dnl Check if we must define _GNU_SOURCE to get a reasonable value for
3531dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
3532dnl (or misfeature) of glibc2, which breaks portability of many applications,
3533dnl since it is interwoven with GNU extensions.
3534dnl
3535dnl Well, yes we could work around it...
3536dnl
3537dnl Parameters:
3538dnl	$1 is the nominal value for _XOPEN_SOURCE
3539AC_DEFUN([CF_GNU_SOURCE],
3540[
3541cf_gnu_xopen_source=ifelse($1,,500,$1)
3542
3543AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
3544AC_TRY_COMPILE([#include <sys/types.h>],[
3545	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
3546		return 0;
3547	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
3548		return 0;
3549	#else
3550	#	error not GNU C library
3551	#endif],
3552	[cf_cv_gnu_library=yes],
3553	[cf_cv_gnu_library=no])
3554])
3555
3556if test x$cf_cv_gnu_library = xyes; then
3557
3558	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
3559	# was changed to help a little.  newlib incorporated the change about 4
3560	# years later.
3561	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
3562		cf_save="$CPPFLAGS"
3563		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
3564		AC_TRY_COMPILE([#include <sys/types.h>],[
3565			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
3566				return 0;
3567			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
3568				return 0;
3569			#else
3570			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
3571			#endif],
3572			[cf_cv_gnu_library_219=yes],
3573			[cf_cv_gnu_library_219=no])
3574		CPPFLAGS="$cf_save"
3575	])
3576
3577	if test "x$cf_cv_gnu_library_219" = xyes; then
3578		cf_save="$CPPFLAGS"
3579		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
3580			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
3581			AC_TRY_COMPILE([
3582				#include <limits.h>
3583				#include <sys/types.h>
3584				],[
3585				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
3586					return 0;
3587				#else
3588				#	error GNU C library is too old
3589				#endif],
3590				[cf_cv_gnu_dftsrc_219=yes],
3591				[cf_cv_gnu_dftsrc_219=no])
3592			])
3593		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
3594	else
3595		cf_cv_gnu_dftsrc_219=maybe
3596	fi
3597
3598	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
3599
3600		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
3601		AC_TRY_COMPILE([#include <sys/types.h>],[
3602			#ifndef _XOPEN_SOURCE
3603			#error	expected _XOPEN_SOURCE to be defined
3604			#endif],
3605			[cf_cv_gnu_source=no],
3606			[cf_save="$CPPFLAGS"
3607			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
3608			 AC_TRY_COMPILE([#include <sys/types.h>],[
3609				#ifdef _XOPEN_SOURCE
3610				#error	expected _XOPEN_SOURCE to be undefined
3611				#endif],
3612				[cf_cv_gnu_source=no],
3613				[cf_cv_gnu_source=yes])
3614			CPPFLAGS="$cf_save"
3615			])
3616		])
3617
3618		if test "$cf_cv_gnu_source" = yes
3619		then
3620		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
3621			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
3622			AC_TRY_COMPILE([#include <sys/types.h>],[
3623				#ifdef _DEFAULT_SOURCE
3624				#error	expected _DEFAULT_SOURCE to be undefined
3625				#endif],
3626				[cf_cv_default_source=no],
3627				[cf_cv_default_source=yes])
3628			])
3629			if test "$cf_cv_default_source" = yes
3630			then
3631				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
3632			fi
3633		fi
3634	fi
3635
3636fi
3637])dnl
3638dnl ---------------------------------------------------------------------------
3639dnl CF_HEADER_PATH version: 15 updated: 2021/01/01 13:31:04
3640dnl --------------
3641dnl Construct a search-list of directories for a nonstandard header-file
3642dnl
3643dnl Parameters
3644dnl	$1 = the variable to return as result
3645dnl	$2 = the package name
3646AC_DEFUN([CF_HEADER_PATH],
3647[
3648$1=
3649
3650# collect the current set of include-directories from compiler flags
3651cf_header_path_list=""
3652if test -n "${CFLAGS}${CPPFLAGS}" ; then
3653	for cf_header_path in $CPPFLAGS $CFLAGS
3654	do
3655		case "$cf_header_path" in
3656		(-I*)
3657			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
3658			CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
3659			cf_header_path_list="$cf_header_path_list [$]$1"
3660			;;
3661		esac
3662	done
3663fi
3664
3665# add the variations for the package we are looking for
3666CF_SUBDIR_PATH($1,$2,include)
3667
3668test "$includedir" != NONE && \
3669test "$includedir" != "/usr/include" && \
3670test -d "$includedir" && {
3671	test -d "$includedir" &&    $1="[$]$1 $includedir"
3672	test -d "$includedir/$2" && $1="[$]$1 $includedir/$2"
3673}
3674
3675test "$oldincludedir" != NONE && \
3676test "$oldincludedir" != "/usr/include" && \
3677test -d "$oldincludedir" && {
3678	test -d "$oldincludedir"    && $1="[$]$1 $oldincludedir"
3679	test -d "$oldincludedir/$2" && $1="[$]$1 $oldincludedir/$2"
3680}
3681
3682$1="[$]$1 $cf_header_path_list"
3683])dnl
3684dnl ---------------------------------------------------------------------------
3685dnl CF_HELP_MESSAGE version: 4 updated: 2019/12/31 08:53:54
3686dnl ---------------
3687dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
3688AC_DEFUN([CF_HELP_MESSAGE],
3689[CF_ACVERSION_CHECK(2.53,[],[
3690AC_DIVERT_HELP($1)])dnl
3691])dnl
3692dnl ---------------------------------------------------------------------------
3693dnl CF_INET_ADDR version: 7 updated: 2013/10/08 17:47:05
3694dnl ------------
3695dnl For Lynx, check if the libraries we have found give us inet_aton, or
3696dnl inet_addr.  If not, try to find the latter function with -lbind or
3697dnl -lresolv, and put that on the end of the libraries, i.e., after the network
3698dnl libraries.
3699dnl
3700dnl FIXME: the inner cases will probably need work on the header files.
3701AC_DEFUN([CF_INET_ADDR],[
3702AC_CACHE_CHECK(for inet_aton function,cf_cv_have_inet_aton,[
3703AC_TRY_LINK(CF__INET_HEAD,[inet_aton(0, (struct in_addr *)0)],
3704    [cf_cv_have_inet_aton=yes],
3705    [cf_cv_have_inet_aton=no])])
3706if test "$cf_cv_have_inet_aton" = yes ; then
3707    AC_DEFINE(HAVE_INET_ATON,1,[Define to 1 if we have inet_aton])
3708else
3709    AC_CACHE_CHECK(for inet_addr function,cf_cv_have_inet_addr,[
3710    AC_TRY_LINK(CF__INET_HEAD,[inet_addr(0)],
3711	[cf_cv_have_inet_addr=yes],
3712	[cf_cv_have_inet_addr=no])])
3713    if test "$cf_cv_have_inet_addr" = no ; then
3714	AC_CACHE_CHECK(for library with inet_addr,cf_cv_lib_inet_addr,[
3715	    cf_save_LIBS="$LIBS"
3716	    for cf_inetlib in -lbind -lresolv
3717	    do
3718		LIBS="$cf_save_LIBS $cf_inetlib"
3719		AC_TRY_LINK([#include <sys/types.h>
3720#include <sys/socket.h>
3721#include <netinet/in.h>
3722#include <arpa/inet.h>
3723		],[inet_addr(0)],
3724		    [cf_cv_lib_inet_addr=$cf_inetlib],
3725		    [cf_cv_lib_inet_addr=no])
3726		LIBS="$cf_save_LIBS"
3727		test "$cf_cv_lib_inet_addr" != no && break
3728	    done
3729	])
3730	if test "$cf_cv_lib_inet_addr" != no ; then
3731	    CF_ADD_LIBS($cf_cv_lib_inet_addr)
3732	else
3733	    AC_MSG_WARN(Unable to find library for inet_addr function)
3734	fi
3735    fi
3736fi
3737])dnl
3738dnl ---------------------------------------------------------------------------
3739dnl CF_INTEL_COMPILER version: 8 updated: 2021/01/01 16:53:59
3740dnl -----------------
3741dnl Check if the given compiler is really the Intel compiler for Linux.  It
3742dnl tries to imitate gcc, but does not return an error when it finds a mismatch
3743dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
3744dnl
3745dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
3746dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
3747dnl the wrappers for gcc and g++ warnings.
3748dnl
3749dnl $1 = GCC (default) or GXX
3750dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
3751dnl $3 = CFLAGS (default) or CXXFLAGS
3752AC_DEFUN([CF_INTEL_COMPILER],[
3753AC_REQUIRE([AC_CANONICAL_HOST])
3754ifelse([$2],,INTEL_COMPILER,[$2])=no
3755
3756if test "$ifelse([$1],,[$1],GCC)" = yes ; then
3757	case "$host_os" in
3758	(linux*|gnu*)
3759		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
3760		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
3761		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
3762		AC_TRY_COMPILE([],[
3763#ifdef __INTEL_COMPILER
3764#else
3765make an error
3766#endif
3767],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
3768cf_save_CFLAGS="$cf_save_CFLAGS -we147"
3769],[])
3770		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
3771		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
3772		;;
3773	esac
3774fi
3775])dnl
3776dnl ---------------------------------------------------------------------------
3777dnl CF_LARGEFILE version: 12 updated: 2020/03/19 20:23:48
3778dnl ------------
3779dnl Add checks for large file support.
3780AC_DEFUN([CF_LARGEFILE],[
3781ifdef([AC_FUNC_FSEEKO],[
3782	AC_SYS_LARGEFILE
3783	if test "$enable_largefile" != no ; then
3784	AC_FUNC_FSEEKO
3785
3786	# Normally we would collect these definitions in the config.h,
3787	# but (like _XOPEN_SOURCE), some environments rely on having these
3788	# defined before any of the system headers are included.  Another
3789	# case comes up with C++, e.g., on AIX the compiler compiles the
3790	# header files by themselves before looking at the body files it is
3791	# told to compile.  For ncurses, those header files do not include
3792	# the config.h
3793	if test "$ac_cv_sys_large_files" != no
3794	then
3795		CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES)
3796	fi
3797	if test "$ac_cv_sys_largefile_source" != no
3798	then
3799		CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE)
3800	fi
3801	if test "$ac_cv_sys_file_offset_bits" != no
3802	then
3803		CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits)
3804	fi
3805
3806	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
3807		AC_TRY_COMPILE([
3808#pragma GCC diagnostic error "-Wincompatible-pointer-types"
3809#include <sys/types.h>
3810#include <dirent.h>
3811		],[
3812		/* if transitional largefile support is setup, this is true */
3813		extern struct dirent64 * readdir(DIR *);
3814		struct dirent64 *x = readdir((DIR *)0);
3815		struct dirent *y = readdir((DIR *)0);
3816		int z = x - y;
3817		(void)z;
3818		],
3819		[cf_cv_struct_dirent64=yes],
3820		[cf_cv_struct_dirent64=no])
3821	])
3822	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64])
3823	fi
3824])
3825])
3826dnl ---------------------------------------------------------------------------
3827dnl CF_LASTLOG version: 7 updated: 2021/01/02 09:31:20
3828dnl ----------
3829dnl Check for header defining _PATH_LASTLOG, or failing that, see if the lastlog
3830dnl file exists.
3831AC_DEFUN([CF_LASTLOG],
3832[
3833AC_CHECK_HEADERS(lastlog.h paths.h)
3834AC_CACHE_CHECK(for lastlog path,cf_cv_path_lastlog,[
3835AC_TRY_COMPILE([
3836#include <sys/types.h>
3837#ifdef HAVE_LASTLOG_H
3838#include <lastlog.h>
3839#else
3840#ifdef HAVE_PATHS_H
3841#include <paths.h>
3842#endif
3843#endif],[char *path = _PATH_LASTLOG; (void)path],
3844	[cf_cv_path_lastlog="_PATH_LASTLOG"],
3845	[if test -f /usr/adm/lastlog ; then
3846	 	cf_cv_path_lastlog=/usr/adm/lastlog
3847	else
3848		cf_cv_path_lastlog=no
3849	fi])
3850])
3851test "$cf_cv_path_lastlog" != no && AC_DEFINE(USE_LASTLOG,1,[Define to 1 if we can define lastlog pathname])
3852])dnl
3853dnl ---------------------------------------------------------------------------
3854dnl CF_LD_RPATH_OPT version: 9 updated: 2021/01/01 13:31:04
3855dnl ---------------
3856dnl For the given system and compiler, find the compiler flags to pass to the
3857dnl loader to use the "rpath" feature.
3858AC_DEFUN([CF_LD_RPATH_OPT],
3859[
3860AC_REQUIRE([CF_CHECK_CACHE])
3861
3862LD_RPATH_OPT=
3863if test "x$cf_cv_enable_rpath" != xno
3864then
3865	AC_MSG_CHECKING(for an rpath option)
3866	case "$cf_cv_system_name" in
3867	(irix*)
3868		if test "$GCC" = yes; then
3869			LD_RPATH_OPT="-Wl,-rpath,"
3870		else
3871			LD_RPATH_OPT="-rpath "
3872		fi
3873		;;
3874	(linux*|gnu*|k*bsd*-gnu|freebsd*)
3875		LD_RPATH_OPT="-Wl,-rpath,"
3876		;;
3877	(openbsd[[2-9]].*|mirbsd*)
3878		LD_RPATH_OPT="-Wl,-rpath,"
3879		;;
3880	(dragonfly*)
3881		LD_RPATH_OPT="-rpath "
3882		;;
3883	(netbsd*)
3884		LD_RPATH_OPT="-Wl,-rpath,"
3885		;;
3886	(osf*|mls+*)
3887		LD_RPATH_OPT="-rpath "
3888		;;
3889	(solaris2*)
3890		LD_RPATH_OPT="-R"
3891		;;
3892	(*)
3893		;;
3894	esac
3895	AC_MSG_RESULT($LD_RPATH_OPT)
3896
3897	case "x$LD_RPATH_OPT" in
3898	(x-R*)
3899		AC_MSG_CHECKING(if we need a space after rpath option)
3900		cf_save_LIBS="$LIBS"
3901		CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
3902		AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
3903		LIBS="$cf_save_LIBS"
3904		AC_MSG_RESULT($cf_rpath_space)
3905		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
3906		;;
3907	esac
3908fi
3909])dnl
3910dnl ---------------------------------------------------------------------------
3911dnl CF_LIBRARY_PATH version: 11 updated: 2021/01/01 13:31:04
3912dnl ---------------
3913dnl Construct a search-list of directories for a nonstandard library-file
3914dnl
3915dnl Parameters
3916dnl	$1 = the variable to return as result
3917dnl	$2 = the package name
3918AC_DEFUN([CF_LIBRARY_PATH],
3919[
3920$1=
3921cf_library_path_list=""
3922if test -n "${LDFLAGS}${LIBS}" ; then
3923	for cf_library_path in $LDFLAGS $LIBS
3924	do
3925		case "$cf_library_path" in
3926		(-L*)
3927			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
3928			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
3929			cf_library_path_list="$cf_library_path_list [$]$1"
3930			;;
3931		esac
3932	done
3933fi
3934
3935CF_SUBDIR_PATH($1,$2,lib)
3936
3937$1="$cf_library_path_list [$]$1"
3938])dnl
3939dnl ---------------------------------------------------------------------------
3940dnl CF_LOCALE version: 6 updated: 2021/01/02 09:31:20
3941dnl ---------
3942dnl Check if we have setlocale() and its header, <locale.h>
3943dnl The optional parameter $1 tells what to do if we do have locale support.
3944AC_DEFUN([CF_LOCALE],
3945[
3946AC_MSG_CHECKING(for setlocale())
3947AC_CACHE_VAL(cf_cv_locale,[
3948AC_TRY_LINK([#include <locale.h>],
3949	[setlocale(LC_ALL, "")],
3950	[cf_cv_locale=yes],
3951	[cf_cv_locale=no])
3952	])
3953AC_MSG_RESULT($cf_cv_locale)
3954test "$cf_cv_locale" = yes && { ifelse($1,,AC_DEFINE(LOCALE,1,[Define to 1 if we have locale support]),[$1]) }
3955])dnl
3956dnl ---------------------------------------------------------------------------
3957dnl CF_MAKEFLAGS version: 20 updated: 2021/01/03 19:29:49
3958dnl ------------
3959dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
3960dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
3961dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
3962dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
3963AC_DEFUN([CF_MAKEFLAGS],
3964[AC_REQUIRE([AC_PROG_FGREP])dnl
3965
3966AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
3967	cf_cv_makeflags=''
3968	for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
3969	do
3970		cat >cf_makeflags.tmp <<CF_EOF
3971SHELL = $SHELL
3972all :
3973	@ echo '.$cf_option'
3974CF_EOF
3975		cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | ${FGREP-fgrep} -v "ing directory" | sed -e 's,[[ 	]]*$,,'`
3976		case "$cf_result" in
3977		(.*k|.*kw)
3978			cf_result="`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`"
3979			case "$cf_result" in
3980			(.*CC=*)	cf_cv_makeflags=
3981				;;
3982			(*)	cf_cv_makeflags=$cf_option
3983				;;
3984			esac
3985			break
3986			;;
3987		(.-)
3988			;;
3989		(*)
3990			CF_MSG_LOG(given option \"$cf_option\", no match \"$cf_result\")
3991			;;
3992		esac
3993	done
3994	rm -f cf_makeflags.tmp
3995])
3996
3997AC_SUBST(cf_cv_makeflags)
3998])dnl
3999dnl ---------------------------------------------------------------------------
4000dnl CF_MAKE_PHONY version: 3 updated: 2021/01/08 16:08:21
4001dnl -------------
4002dnl Check if the make-program handles a ".PHONY" target, e.g,. a target which
4003dnl acts as a placeholder.
4004dnl
4005dnl The ".PHONY" feature was proposed in 2011 here
4006dnl     https://www.austingroupbugs.net/view.php?id=523
4007dnl and is scheduled for release in P1003.1 Issue 8 (late 2022).
4008dnl
4009dnl This is not supported by SVr4 make (or SunOS 4, 4.3SD, etc), but works with
4010dnl a few others (i.e., GNU make and the non-POSIX "BSD" make):
4011dnl
4012dnl + This is a GNU make feature (since April 1988, but in turn from binutils,
4013dnl   date unspecified).
4014dnl
4015dnl + It was adopted in NetBSD make in June 1995.
4016dnl
4017dnl + The other BSD make programs are derived from the NetBSD make (and for
4018dnl   that reason are not actually different "implementations").
4019dnl
4020dnl + Some features of NetBSD make were actually adapted from pmake, which
4021dnl   began as a modified GNU make starting in 1993.
4022dnl
4023dnl + Version 3.8 of the dmake program in January 1992 also implemented this
4024dnl   GNU make extension, but is less well known than the BSD make.
4025AC_DEFUN([CF_MAKE_PHONY],[
4026AC_CACHE_CHECK(for \".PHONY\" make-support, cf_cv_make_PHONY,[
4027	rm -rf conftest*
4028	(
4029		mkdir conftest || exit 1
4030		cd conftest
4031		cat >makefile <<'CF_EOF'
4032.PHONY: always
4033DATA=0
4034always:	always.out
4035	@echo "** making [$]@ [$](DATA)"
4036once: once.out
4037	@echo "** making [$]@ [$](DATA)"
4038always.out:
4039	@echo "** making [$]@ [$](DATA)"
4040	echo [$](DATA) > [$]@
4041once.out:
4042	@echo "** making [$]@ [$](DATA)"
4043	echo [$](DATA) > [$]@
4044CF_EOF
4045		for cf_data in 1 2 3
4046		do
4047			${MAKE:-make} always DATA=$cf_data
4048			${MAKE:-make} once   DATA=$cf_data
4049			${MAKE:-make} -t always once
4050			if test -f always ; then
4051				echo "no (case 1)" > ../conftest.tmp
4052			elif test ! -f always.out ; then
4053				echo "no (case 2)" > ../conftest.tmp
4054			elif test ! -f once.out ; then
4055				echo "no (case 3)" > ../conftest.tmp
4056			elif ! cmp -s always.out once.out ; then
4057				echo "no (case 4)" > ../conftest.tmp
4058				diff always.out once.out
4059			else
4060				cf_check="`cat always.out`"
4061				if test "x$cf_check" != "x$cf_data" ; then
4062					echo "no (case 5)" > ../conftest.tmp
4063				else
4064					echo yes > ../conftest.tmp
4065					rm -f ./*.out
4066					continue
4067				fi
4068			fi
4069			break
4070		done
4071	) >&AC_FD_CC 2>&1
4072	cf_cv_make_PHONY="`cat conftest.tmp`"
4073	rm -rf conftest*
4074])
4075MAKE_NO_PHONY="#"
4076MAKE_PHONY="#"
4077test "x$cf_cv_make_PHONY" = xyes && MAKE_PHONY=
4078test "x$cf_cv_make_PHONY" != xyes && MAKE_NO_PHONY=
4079AC_SUBST(MAKE_NO_PHONY)
4080AC_SUBST(MAKE_PHONY)
4081])dnl
4082dnl ---------------------------------------------------------------------------
4083dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
4084dnl ------------
4085dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
4086dnl a monocase filesystem.
4087AC_DEFUN([CF_MAKE_TAGS],[
4088AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
4089
4090AC_CHECK_PROGS(CTAGS, exctags ctags)
4091AC_CHECK_PROGS(ETAGS, exetags etags)
4092
4093AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
4094
4095if test "$cf_cv_mixedcase" = yes ; then
4096	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
4097else
4098	MAKE_UPPER_TAGS=no
4099fi
4100
4101if test "$MAKE_UPPER_TAGS" = yes ; then
4102	MAKE_UPPER_TAGS=
4103else
4104	MAKE_UPPER_TAGS="#"
4105fi
4106
4107if test "$MAKE_LOWER_TAGS" = yes ; then
4108	MAKE_LOWER_TAGS=
4109else
4110	MAKE_LOWER_TAGS="#"
4111fi
4112
4113AC_SUBST(CTAGS)
4114AC_SUBST(ETAGS)
4115
4116AC_SUBST(MAKE_UPPER_TAGS)
4117AC_SUBST(MAKE_LOWER_TAGS)
4118])dnl
4119dnl ---------------------------------------------------------------------------
4120dnl CF_MATH_LIB version: 10 updated: 2020/12/31 18:40:20
4121dnl -----------
4122dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
4123dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
4124dnl AC_CHECK_LIB(m,sin), because that fails for C++.
4125AC_DEFUN([CF_MATH_LIB],
4126[
4127AC_CACHE_CHECK(if -lm needed for math functions,
4128	cf_cv_need_libm,[
4129	AC_TRY_LINK([
4130	#include <stdio.h>
4131	#include <stdlib.h>
4132	#include <math.h>
4133	],
4134	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
4135	[cf_cv_need_libm=no],
4136	[cf_cv_need_libm=yes])])
4137if test "$cf_cv_need_libm" = yes
4138then
4139ifelse($1,,[
4140	CF_ADD_LIB(m)
4141],[$1=-lm])
4142fi
4143])
4144dnl ---------------------------------------------------------------------------
4145dnl CF_MERGE_EXTRA_CFLAGS version: 2 updated: 2021/01/02 09:31:20
4146dnl ---------------------
4147dnl CF_FIX_WARNINGS moves problematic flags into EXTRA_CFLAGS, but some scripts
4148dnl may depend on being able to override that variable at build-time.  Move it
4149dnl all back.
4150define([CF_MERGE_EXTRA_CFLAGS],[
4151if test "$GCC" = yes || test "$GXX" = yes
4152then
4153	CF_APPEND_TEXT(CFLAGS,$EXTRA_CFLAGS)
4154	EXTRA_CFLAGS=
4155fi
4156])
4157dnl ---------------------------------------------------------------------------
4158dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
4159dnl ----------------------
4160dnl Check if the file-system supports mixed-case filenames.  If we're able to
4161dnl create a lowercase name and see it as uppercase, it doesn't support that.
4162AC_DEFUN([CF_MIXEDCASE_FILENAMES],
4163[
4164AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
4165if test "$cross_compiling" = yes ; then
4166	case "$target_alias" in
4167	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
4168		cf_cv_mixedcase=no
4169		;;
4170	(*)
4171		cf_cv_mixedcase=yes
4172		;;
4173	esac
4174else
4175	rm -f conftest CONFTEST
4176	echo test >conftest
4177	if test -f CONFTEST ; then
4178		cf_cv_mixedcase=no
4179	else
4180		cf_cv_mixedcase=yes
4181	fi
4182	rm -f conftest CONFTEST
4183fi
4184])
4185test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
4186])dnl
4187dnl ---------------------------------------------------------------------------
4188dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
4189dnl ----------
4190dnl Write a debug message to config.log, along with the line number in the
4191dnl configure script.
4192AC_DEFUN([CF_MSG_LOG],[
4193echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
4194])dnl
4195dnl ---------------------------------------------------------------------------
4196dnl CF_NCURSES_BROKEN version: 8 updated: 2012/11/08 20:57:52
4197dnl -----------------
4198dnl Check for pre-1.9.9g ncurses (among other problems, the most obvious is
4199dnl that color combinations don't work).
4200AC_DEFUN([CF_NCURSES_BROKEN],
4201[
4202AC_REQUIRE([CF_NCURSES_VERSION])
4203if test "$cf_cv_ncurses_version" != no ; then
4204AC_MSG_CHECKING(for obsolete/broken version of ncurses)
4205AC_CACHE_VAL(cf_cv_ncurses_broken,[
4206AC_TRY_COMPILE([
4207#include <${cf_cv_ncurses_header:-curses.h}>],[
4208#if defined(NCURSES_VERSION) && defined(wgetbkgd)
4209	make an error
4210#else
4211	int x = 1
4212#endif
4213],
4214	[cf_cv_ncurses_broken=no],
4215	[cf_cv_ncurses_broken=yes])
4216])
4217AC_MSG_RESULT($cf_cv_ncurses_broken)
4218if test "$cf_cv_ncurses_broken" = yes ; then
4219	AC_MSG_WARN(hmm... you should get an up-to-date version of ncurses)
4220	AC_DEFINE(NCURSES_BROKEN,1,[Define to 1 if you have an obsolete version of ncurses])
4221fi
4222fi
4223])dnl
4224dnl ---------------------------------------------------------------------------
4225dnl CF_NCURSES_CC_CHECK version: 5 updated: 2020/12/31 20:19:42
4226dnl -------------------
4227dnl Check if we can compile with ncurses' header file
4228dnl $1 is the cache variable to set
4229dnl $2 is the header-file to include
4230dnl $3 is the root name (ncurses or ncursesw)
4231AC_DEFUN([CF_NCURSES_CC_CHECK],[
4232	AC_TRY_COMPILE([
4233]ifelse($3,ncursesw,[
4234#define _XOPEN_SOURCE_EXTENDED
4235#undef  HAVE_LIBUTF8_H	/* in case we used CF_UTF8_LIB */
4236#define HAVE_LIBUTF8_H	/* to force ncurses' header file to use cchar_t */
4237])[
4238#include <$2>],[
4239#ifdef NCURSES_VERSION
4240]ifelse($3,ncursesw,[
4241#ifndef WACS_BSSB
4242	make an error
4243#endif
4244])[
4245printf("%s\\n", NCURSES_VERSION);
4246#else
4247#ifdef __NCURSES_H
4248printf("old\\n");
4249#else
4250	make an error
4251#endif
4252#endif
4253	]
4254	,[$1=$2]
4255	,[$1=no])
4256])dnl
4257dnl ---------------------------------------------------------------------------
4258dnl CF_NCURSES_CONFIG version: 27 updated: 2021/05/19 19:35:25
4259dnl -----------------
4260dnl Tie together the configure-script macros for ncurses, preferring these in
4261dnl order:
4262dnl a) ".pc" files for pkg-config, using $NCURSES_CONFIG_PKG
4263dnl b) the "-config" script from ncurses, using $NCURSES_CONFIG
4264dnl c) just plain libraries
4265dnl
4266dnl $1 is the root library name (default: "ncurses")
4267AC_DEFUN([CF_NCURSES_CONFIG],[
4268AC_REQUIRE([CF_PKG_CONFIG])
4269cf_ncuconfig_root=ifelse($1,,ncurses,$1)
4270cf_have_ncuconfig=no
4271
4272if test "x${PKG_CONFIG:=none}" != xnone; then
4273	AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
4274	if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
4275		AC_MSG_RESULT(yes)
4276
4277		AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
4278		cf_have_ncuconfig=unknown
4279
4280		cf_save_CFLAGS="$CFLAGS"
4281		cf_save_CPPFLAGS="$CPPFLAGS"
4282		cf_save_LIBS="$LIBS"
4283
4284		cf_pkg_cflags="`$PKG_CONFIG --cflags $cf_ncuconfig_root`"
4285		cf_pkg_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
4286
4287		# while -W for passing linker flags is prevalent, it is not "standard".
4288		# At least one wrapper for c89/c99 (in Apple's xcode) has its own
4289		# incompatible _and_ non-standard -W option which gives an error.  Work
4290		# around that pitfall.
4291		case "x${CC}@@${cf_pkg_libs}@${cf_pkg_cflags}" in
4292		(x*c[[89]]9@@*-W*)
4293			CF_ADD_CFLAGS($cf_pkg_cflags)
4294			CF_ADD_LIBS($cf_pkg_libs)
4295
4296			AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
4297				[initscr(); mousemask(0,0); tigetstr((char *)0);],
4298				[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
4299					int main(void)
4300					{ const char *xx = curses_version(); return (xx == 0); }],
4301					[cf_test_ncuconfig=yes],
4302					[cf_test_ncuconfig=no],
4303					[cf_test_ncuconfig=maybe])],
4304				[cf_test_ncuconfig=no])
4305
4306			CFLAGS="$cf_save_CFLAGS"
4307			CPPFLAGS="$cf_save_CPPFLAGS"
4308			LIBS="$cf_save_LIBS"
4309
4310			if test "x$cf_test_ncuconfig" != xyes; then
4311				cf_temp=`echo "x$cf_pkg_cflags" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
4312				cf_pkg_cflags="$cf_temp"
4313				cf_temp=`echo "x$cf_pkg_libs" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
4314				cf_pkg_libs="$cf_temp"
4315			fi
4316			;;
4317		esac
4318
4319		CF_ADD_CFLAGS($cf_pkg_cflags)
4320		CF_ADD_LIBS($cf_pkg_libs)
4321
4322		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
4323			[initscr(); mousemask(0,0); tigetstr((char *)0);],
4324			[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
4325				int main(void)
4326				{ const char *xx = curses_version(); return (xx == 0); }],
4327				[cf_have_ncuconfig=yes],
4328				[cf_have_ncuconfig=no],
4329				[cf_have_ncuconfig=maybe])],
4330			[cf_have_ncuconfig=no])
4331		AC_MSG_RESULT($cf_have_ncuconfig)
4332		test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
4333		if test "$cf_have_ncuconfig" != "yes"
4334		then
4335			CPPFLAGS="$cf_save_CPPFLAGS"
4336			LIBS="$cf_save_LIBS"
4337			NCURSES_CONFIG_PKG=none
4338		else
4339			AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
4340			NCURSES_CONFIG_PKG=$cf_ncuconfig_root
4341			CF_TERM_HEADER
4342		fi
4343
4344	else
4345		AC_MSG_RESULT(no)
4346		NCURSES_CONFIG_PKG=none
4347	fi
4348else
4349	NCURSES_CONFIG_PKG=none
4350fi
4351
4352if test "x$cf_have_ncuconfig" = "xno"; then
4353	cf_ncurses_config="${cf_ncuconfig_root}${NCURSES_CONFIG_SUFFIX}-config"; echo "Looking for ${cf_ncurses_config}"
4354
4355	CF_ACVERSION_CHECK(2.52,
4356		[AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
4357		[AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
4358
4359	if test "$NCURSES_CONFIG" != none ; then
4360
4361		CF_ADD_CFLAGS(`$NCURSES_CONFIG --cflags`)
4362		CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
4363
4364		# even with config script, some packages use no-override for curses.h
4365		CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
4366
4367		dnl like CF_NCURSES_CPPFLAGS
4368		AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
4369
4370		dnl like CF_NCURSES_LIBS
4371		CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
4372		AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
4373
4374		dnl like CF_NCURSES_VERSION
4375		cf_cv_ncurses_version="`$NCURSES_CONFIG --version`"
4376
4377	else
4378
4379		CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
4380		CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
4381
4382	fi
4383else
4384	NCURSES_CONFIG=none
4385fi
4386])dnl
4387dnl ---------------------------------------------------------------------------
4388dnl CF_NCURSES_CPPFLAGS version: 22 updated: 2021/01/02 09:31:20
4389dnl -------------------
4390dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
4391dnl the CPPFLAGS variable so we can include its header.
4392dnl
4393dnl The header files may be installed as either curses.h, or ncurses.h (would
4394dnl be obsolete, except that some packagers prefer this name to distinguish it
4395dnl from a "native" curses implementation).  If not installed for overwrite,
4396dnl the curses.h file would be in an ncurses subdirectory (e.g.,
4397dnl /usr/include/ncurses), but someone may have installed overwriting the
4398dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
4399dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
4400dnl the header.
4401dnl
4402dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
4403dnl is already in the include-path, don't even bother with this, since we cannot
4404dnl easily determine which file it is.  In this case, it has to be <curses.h>.
4405dnl
4406dnl The optional parameter gives the root name of the library, in case it is
4407dnl not installed as the default curses library.  That is how the
4408dnl wide-character version of ncurses is installed.
4409AC_DEFUN([CF_NCURSES_CPPFLAGS],
4410[AC_REQUIRE([CF_WITH_CURSES_DIR])
4411
4412AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
4413cf_ncuhdr_root=ifelse($1,,ncurses,$1)
4414
4415test -n "$cf_cv_curses_dir" && \
4416test "$cf_cv_curses_dir" != "no" && { \
4417  CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
4418}
4419
4420AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
4421	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
4422	{ test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw; } && cf_header_list="$cf_header_list curses.h ncurses.h"
4423	for cf_header in $cf_header_list
4424	do
4425		CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
4426		test "$cf_cv_ncurses_h" != no && break
4427	done
4428])
4429
4430CF_NCURSES_HEADER
4431CF_TERM_HEADER
4432
4433# some applications need this, but should check for NCURSES_VERSION
4434AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
4435
4436CF_NCURSES_VERSION
4437])dnl
4438dnl ---------------------------------------------------------------------------
4439dnl CF_NCURSES_HEADER version: 7 updated: 2021/01/04 19:33:05
4440dnl -----------------
4441dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
4442dnl variations of ncurses' installs.
4443dnl
4444dnl See also CF_CURSES_HEADER, which sets the same cache variable.
4445AC_DEFUN([CF_NCURSES_HEADER],[
4446
4447if test "$cf_cv_ncurses_h" != no ; then
4448	cf_cv_ncurses_header=$cf_cv_ncurses_h
4449else
4450
4451AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
4452	test -n "$verbose" && echo
4453	CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
4454	test -n "$verbose" && echo "search path $cf_search"
4455	cf_save2_CPPFLAGS="$CPPFLAGS"
4456	for cf_incdir in $cf_search
4457	do
4458		CF_ADD_INCDIR($cf_incdir)
4459		for cf_header in \
4460			ncurses.h \
4461			curses.h
4462		do
4463			CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
4464			if test "$cf_cv_ncurses_h2" != no ; then
4465				cf_cv_ncurses_h2=$cf_incdir/$cf_header
4466				test -n "$verbose" && echo $ECHO_N "	... found $ECHO_C" 1>&AC_FD_MSG
4467				break
4468			fi
4469			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
4470		done
4471		CPPFLAGS="$cf_save2_CPPFLAGS"
4472		test "$cf_cv_ncurses_h2" != no && break
4473	done
4474	test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
4475	])
4476
4477	CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
4478	cf_cv_ncurses_header="`basename "$cf_cv_ncurses_h2"`"
4479	if test "`basename "$cf_1st_incdir"`" = "$cf_ncuhdr_root" ; then
4480		cf_cv_ncurses_header="$cf_ncuhdr_root/$cf_cv_ncurses_header"
4481	fi
4482	CF_ADD_INCDIR($cf_1st_incdir)
4483
4484fi
4485
4486# Set definitions to allow ifdef'ing for ncurses.h
4487
4488case "$cf_cv_ncurses_header" in
4489(*ncurses.h)
4490	AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
4491	;;
4492esac
4493
4494case "$cf_cv_ncurses_header" in
4495(ncurses/curses.h|ncurses/ncurses.h)
4496	AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
4497	;;
4498(ncursesw/curses.h|ncursesw/ncurses.h)
4499	AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
4500	;;
4501esac
4502
4503])dnl
4504dnl ---------------------------------------------------------------------------
4505dnl CF_NCURSES_LIBS version: 20 updated: 2021/01/03 08:05:37
4506dnl ---------------
4507dnl Look for the ncurses library.  This is a little complicated on Linux,
4508dnl because it may be linked with the gpm (general purpose mouse) library.
4509dnl Some distributions have gpm linked with (bsd) curses, which makes it
4510dnl unusable with ncurses.  However, we don't want to link with gpm unless
4511dnl ncurses has a dependency, since gpm is normally set up as a shared library,
4512dnl and the linker will record a dependency.
4513dnl
4514dnl The optional parameter gives the root name of the library, in case it is
4515dnl not installed as the default curses library.  That is how the
4516dnl wide-character version of ncurses is installed.
4517AC_DEFUN([CF_NCURSES_LIBS],
4518[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
4519
4520cf_nculib_root=ifelse($1,,ncurses,$1)
4521	# This works, except for the special case where we find gpm, but
4522	# ncurses is in a nonstandard location via $LIBS, and we really want
4523	# to link gpm.
4524cf_ncurses_LIBS=""
4525cf_ncurses_SAVE="$LIBS"
4526AC_CHECK_LIB(gpm,Gpm_Open,
4527	[AC_CHECK_LIB(gpm,initscr,
4528		[LIBS="$cf_ncurses_SAVE"],
4529		[cf_ncurses_LIBS="-lgpm"])])
4530
4531case "$host_os" in
4532(freebsd*)
4533	# This is only necessary if you are linking against an obsolete
4534	# version of ncurses (but it should do no harm, since it's static).
4535	if test "$cf_nculib_root" = ncurses ; then
4536		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
4537	fi
4538	;;
4539esac
4540
4541CF_ADD_LIBS($cf_ncurses_LIBS)
4542
4543if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
4544then
4545	CF_ADD_LIBS(-l$cf_nculib_root)
4546else
4547	CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
4548		[#include <${cf_cv_ncurses_header:-curses.h}>],
4549		[initscr()],
4550		initscr)
4551fi
4552
4553if test -n "$cf_ncurses_LIBS" ; then
4554	AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
4555	cf_ncurses_SAVE="$LIBS"
4556	for p in $cf_ncurses_LIBS ; do
4557		q=`echo "$LIBS" | sed -e "s%$p %%" -e "s%$p$%%"`
4558		if test "$q" != "$LIBS" ; then
4559			LIBS="$q"
4560		fi
4561	done
4562	AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
4563		[initscr(); mousemask(0,0); tigetstr((char *)0);],
4564		[AC_MSG_RESULT(yes)],
4565		[AC_MSG_RESULT(no)
4566		 LIBS="$cf_ncurses_SAVE"])
4567fi
4568
4569CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
4570AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
4571])dnl
4572dnl ---------------------------------------------------------------------------
4573dnl CF_NCURSES_VERSION version: 16 updated: 2020/12/31 20:19:42
4574dnl ------------------
4575dnl Check for the version of ncurses, to aid in reporting bugs, etc.
4576dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
4577dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
4578AC_DEFUN([CF_NCURSES_VERSION],
4579[
4580AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
4581AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
4582	cf_cv_ncurses_version=no
4583	cf_tempfile=out$$
4584	rm -f "$cf_tempfile"
4585	AC_TRY_RUN([
4586#include <${cf_cv_ncurses_header:-curses.h}>
4587#include <stdio.h>
4588int main(void)
4589{
4590	FILE *fp = fopen("$cf_tempfile", "w");
4591#ifdef NCURSES_VERSION
4592# ifdef NCURSES_VERSION_PATCH
4593	fprintf(fp, "%s.%d\\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
4594# else
4595	fprintf(fp, "%s\\n", NCURSES_VERSION);
4596# endif
4597#else
4598# ifdef __NCURSES_H
4599	fprintf(fp, "old\\n");
4600# else
4601	make an error
4602# endif
4603#endif
4604	${cf_cv_main_return:-return}(0);
4605}],[
4606	cf_cv_ncurses_version=`cat $cf_tempfile`],,[
4607
4608	# This will not work if the preprocessor splits the line after the
4609	# Autoconf token.  The 'unproto' program does that.
4610	cat > "conftest.$ac_ext" <<EOF
4611#include <${cf_cv_ncurses_header:-curses.h}>
4612#undef Autoconf
4613#ifdef NCURSES_VERSION
4614Autoconf NCURSES_VERSION
4615#else
4616#ifdef __NCURSES_H
4617Autoconf "old"
4618#endif
4619;
4620#endif
4621EOF
4622	cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
4623	AC_TRY_EVAL(cf_try)
4624	if test -f conftest.out ; then
4625		cf_out=`sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%' conftest.out`
4626		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
4627		rm -f conftest.out
4628	fi
4629])
4630	rm -f "$cf_tempfile"
4631])
4632test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
4633])dnl
4634dnl ---------------------------------------------------------------------------
4635dnl CF_NETLIBS version: 12 updated: 2021/01/02 09:31:20
4636dnl ----------
4637dnl After checking for functions in the default $LIBS, make a further check
4638dnl for the functions that are netlib-related (these aren't always in the
4639dnl libc, etc., and have to be handled specially because there are conflicting
4640dnl and broken implementations.
4641dnl Common library requirements (in order):
4642dnl	-lresolv -lsocket -lnsl
4643dnl	-lnsl -lsocket
4644dnl	-lsocket
4645dnl	-lbsd
4646dnl	-lnetwork
4647AC_DEFUN([CF_NETLIBS],[
4648cf_test_netlibs=no
4649
4650AC_MSG_CHECKING(for network libraries)
4651
4652AC_CACHE_VAL(cf_cv_netlibs,[
4653AC_MSG_RESULT(working...)
4654
4655cf_cv_netlibs=""
4656cf_test_netlibs=yes
4657
4658case "$host_os" in
4659(mingw*)
4660	AC_CHECK_HEADERS( windows.h winsock.h winsock2.h )
4661
4662	if test "$ac_cv_header_winsock2_h" = "yes" ; then
4663		cf_winsock_lib="-lws2_32"
4664	elif test "$ac_cv_header_winsock_h" = "yes" ; then
4665		cf_winsock_lib="-lwsock32"
4666	fi
4667
4668	cf_save_LIBS="$LIBS"
4669	CF_ADD_LIBS($cf_winsock_lib)
4670
4671	AC_TRY_LINK([
4672#ifdef HAVE_WINDOWS_H
4673#undef WIN32_LEAN_AND_MEAN
4674#define WIN32_LEAN_AND_MEAN
4675#include <windows.h>
4676#ifdef HAVE_WINSOCK2_H
4677#include <winsock2.h>
4678#else
4679#ifdef HAVE_WINSOCK_H
4680#include <winsock.h>
4681#endif
4682#endif
4683#endif
4684],[
4685	char buffer[1024];
4686	gethostname(buffer, sizeof(buffer));],
4687	[cf_cv_netlibs="$cf_winsock_lib $cf_cv_netlibs"],
4688	[AC_MSG_ERROR(Cannot link against winsock library)])
4689
4690	LIBS="$cf_save_LIBS"
4691	;;
4692(*)
4693	AC_CHECK_FUNCS(gethostname,,[
4694		CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[
4695			CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])])
4696
4697	AC_CHECK_LIB(inet, main, cf_cv_netlibs="-linet $cf_cv_netlibs")
4698
4699	if test "$ac_cv_func_lsocket" != no ; then
4700	AC_CHECK_FUNCS(socket,,[
4701		CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[
4702			CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])])
4703	fi
4704
4705	AC_CHECK_FUNCS(gethostbyname,,[
4706		CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)])
4707
4708	AC_CHECK_FUNCS(inet_ntoa,,[
4709		CF_RECHECK_FUNC(inet_ntoa,nsl,cf_cv_netlibs)])
4710
4711	AC_CHECK_FUNCS(gethostbyname,,[
4712		CF_RECHECK_FUNC(gethostbyname,network,cf_cv_netlibs)])
4713
4714	AC_CHECK_FUNCS(strcasecmp,,[
4715		CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)])
4716	;;
4717esac
4718])
4719
4720case "$cf_cv_netlibs" in
4721(*ws2_32*)
4722	AC_DEFINE(USE_WINSOCK2_H,1,[Define to 1 if we should include winsock2.h])
4723	;;
4724esac
4725
4726CF_ADD_LIBS($cf_cv_netlibs)
4727test "$cf_test_netlibs" = no && echo "$cf_cv_netlibs" >&AC_FD_MSG
4728])dnl
4729dnl ---------------------------------------------------------------------------
4730dnl CF_NGROUPS version: 4 updated: 2012/11/08 20:57:52
4731dnl ----------
4732dnl Check for the symbol NGROUPS
4733AC_DEFUN([CF_NGROUPS],
4734[
4735AC_MSG_CHECKING(if NGROUPS is defined)
4736AC_CACHE_VAL(cf_cv_ngroups,[
4737AC_TRY_COMPILE([
4738#if HAVE_SYS_PARAM_H
4739#include <sys/param.h>
4740#endif
4741#if HAVE_LIMITS_H
4742#include <limits.h>
4743#endif
4744],[int x = NGROUPS],
4745	[cf_cv_ngroups=yes],
4746	[AC_TRY_COMPILE([
4747#if HAVE_SYS_PARAM_H
4748#include <sys/param.h>
4749#endif
4750#if HAVE_LIMITS_H
4751#include <limits.h>
4752#endif
4753],[int x = NGROUPS_MAX],
4754		[cf_cv_ngroups=NGROUPS_MAX],
4755		[cf_cv_ngroups=no])
4756	])
4757AC_MSG_RESULT($cf_cv_ngroups)
4758])
4759if test "$cf_cv_ngroups" = no ; then
4760	AC_DEFINE(NGROUPS,16,[Define to maximum number of groups])
4761elif test "$cf_cv_ngroups" = NGROUPS_MAX ; then
4762	AC_DEFINE(NGROUPS,NGROUPS_MAX)
4763fi
4764])dnl
4765dnl ---------------------------------------------------------------------------
4766dnl CF_NO_LEAKS_OPTION version: 9 updated: 2021/06/13 19:45:41
4767dnl ------------------
4768dnl see CF_WITH_NO_LEAKS
4769dnl
4770dnl $1 = option/name
4771dnl $2 = help-text
4772dnl $3 = symbol to define if the option is set
4773dnl $4 = additional actions to take if the option is set
4774AC_DEFUN([CF_NO_LEAKS_OPTION],[
4775AC_MSG_CHECKING(if you want to use $1 for testing)
4776AC_ARG_WITH($1,
4777	[$2],
4778	[case "x$withval" in
4779	(x|xno) ;;
4780	(*)
4781		: "${with_cflags:=-g}"
4782		: "${enable_leaks:=no}"
4783		with_$1=yes
4784		AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
4785	 $4
4786])
4787		;;
4788	esac],
4789	[with_$1=])
4790AC_MSG_RESULT(${with_$1:-no})
4791
4792case ".$with_cflags" in
4793(.*-g*)
4794	case .$CFLAGS in
4795	(.*-g*)
4796		;;
4797	(*)
4798		CF_ADD_CFLAGS([-g])
4799		;;
4800	esac
4801	;;
4802esac
4803])dnl
4804dnl ---------------------------------------------------------------------------
4805dnl CF_NSS_COMPAT version: 7 updated: 2021/01/02 09:31:20
4806dnl -------------
4807dnl Check for NSS compatible SSL libraries
4808dnl $1 = the [optional] directory in which the library may be found
4809AC_DEFUN([CF_NSS_COMPAT],[
4810check=`pkg-config --version 2>/dev/null`
4811if test -n "$check" ; then
4812	cf_ssl_library=`pkg-config --libs nss`
4813	cf_ssl_cflags=`pkg-config --cflags nss`
4814else
4815	# Without pkg-config, we'll kludge in some defaults
4816	cf_ssl_library="-lssl3 -lsmime3 -lnss3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl"
4817	cf_ssl_cflags="-I/usr/include/nss3 -I/usr/include/nspr4"
4818fi
4819cf_ssl_library="-lnss_compat_ossl $cf_ssl_library"
4820
4821case "$1" in
4822(no)
4823	cf_ssl_root=
4824	;;
4825(yes)
4826	AC_CHECK_LIB(nss_compat_ossl, SSL_get_version,[],[
4827		cf_ssl_root=/usr/local/nss_compat_ossl
4828		if test -d "$cf_ssl_root" ; then
4829			CF_VERBOSE(assume it is in $cf_ssl_root)
4830			cf_ssl_library="-L$cf_ssl_root/lib $cf_ssl_library"
4831		else
4832			AC_MSG_ERROR(cannot find NSS compliant libraries)
4833		fi
4834	],
4835	[-lnss_compat_ossl])
4836	;;
4837(*)
4838	if test -d "$1" ; then
4839		if test -d "$1/include" ; then
4840			cf_ssl_root=$1
4841		elif test -d "$1/../include" ; then
4842			cf_ssl_root=$1/..
4843		else
4844			AC_MSG_ERROR(cannot find NSS compliant library under $1)
4845		fi
4846		cf_ssl_library="-L$cf_ssl_root/lib $cf_ssl_library"
4847	else
4848		AC_MSG_WARN(expected a directory: $1)
4849	fi
4850	;;
4851esac
4852CF_ADD_LIBS($cf_ssl_library)
4853
4854cf_ssl_subincs=yes
4855if test -n "$cf_ssl_root" ; then
4856	if test -d "$cf_ssl_root/include" ; then
4857		cf_ssl_cflags="-I$cf_ssl_root/include  $cf_ssl_cflags"
4858		test -d "$cf_ssl_root/include/nss_compat_ossl" || cf_ssl_subincs=no
4859	fi
4860fi
4861CF_ADD_CFLAGS($cf_ssl_cflags)
4862
4863if test "$cf_ssl_subincs" = yes ; then
4864AC_MSG_CHECKING(for NSS compliant include directory)
4865AC_TRY_COMPILE([
4866#include <stdio.h>
4867#include <nss_compat_ossl/nss_compat_ossl.h>],
4868	[SSL_shutdown((SSL *)0)],
4869	[cf_ssl_incl=yes],
4870	[cf_ssl_incl=no])
4871AC_MSG_RESULT($cf_ssl_incl)
4872test "$cf_ssl_incl" = yes && AC_DEFINE(USE_NSS_COMPAT_INCL,1,[Define to 1 if we should use nss compatibility header])
4873fi
4874
4875AC_MSG_CHECKING(if we can link to NSS compliant library)
4876AC_TRY_LINK([
4877#include <stdio.h>
4878#ifdef USE_NSS_COMPAT_INCL
4879#include <nss_compat_ossl/nss_compat_ossl.h>
4880#else
4881#include <ssl.h>
4882#endif
4883],
4884	[SSL_shutdown((SSL *)0)],
4885	[cf_ssl_library=yes],
4886	[cf_ssl_library=no])
4887AC_MSG_RESULT($cf_ssl_library)
4888if test "$cf_ssl_library" = yes ; then
4889	AC_DEFINE(USE_SSL,1,[Define to 1 if we should use SSL])
4890	AC_DEFINE(USE_X509_SUPPORT,1,[Define to 1 if the SSL library provides X509 support])
4891else
4892	AC_MSG_ERROR(Cannot link with NSS compliant libraries)
4893fi
4894])dnl
4895dnl ---------------------------------------------------------------------------
4896dnl CF_OUR_MESSAGES version: 8 updated: 2021/01/02 09:31:20
4897dnl ---------------
4898dnl Check if we use the messages included with this program
4899dnl
4900dnl $1 specifies either Makefile or makefile, defaulting to the former.
4901dnl
4902dnl Sets variables which can be used to substitute in makefiles:
4903dnl	MSG_DIR_MAKE - to make ./po directory
4904dnl	SUB_MAKEFILE - makefile in ./po directory (see CF_BUNDLED_INTL)
4905dnl
4906AC_DEFUN([CF_OUR_MESSAGES],
4907[
4908cf_makefile=ifelse($1,,Makefile,$1)
4909
4910use_our_messages=no
4911if test "$USE_NLS" = yes ; then
4912if test -d "$srcdir/po" ; then
4913AC_MSG_CHECKING(if we should use included message-library)
4914	AC_ARG_ENABLE(included-msgs,
4915	[  --disable-included-msgs use included messages, for i18n support],
4916	[use_our_messages=$enableval],
4917	[use_our_messages=yes])
4918fi
4919AC_MSG_RESULT($use_our_messages)
4920fi
4921
4922MSG_DIR_MAKE="#"
4923if test "$use_our_messages" = yes
4924then
4925	SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:$srcdir/po/$cf_makefile.inn"
4926	MSG_DIR_MAKE=
4927fi
4928
4929AC_SUBST(MSG_DIR_MAKE)
4930AC_SUBST(SUB_MAKEFILE)
4931])dnl
4932dnl ---------------------------------------------------------------------------
4933dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
4934dnl ----------
4935dnl Provide a value for the $PATH and similar separator (or amend the value
4936dnl as provided in autoconf 2.5x).
4937AC_DEFUN([CF_PATHSEP],
4938[
4939	AC_MSG_CHECKING(for PATH separator)
4940	case "$cf_cv_system_name" in
4941	(os2*)	PATH_SEPARATOR=';'  ;;
4942	(*)	${PATH_SEPARATOR:=':'}  ;;
4943	esac
4944ifelse([$1],,,[$1=$PATH_SEPARATOR])
4945	AC_SUBST(PATH_SEPARATOR)
4946	AC_MSG_RESULT($PATH_SEPARATOR)
4947])dnl
4948dnl ---------------------------------------------------------------------------
4949dnl CF_PATH_PROG version: 12 updated: 2021/01/02 09:31:20
4950dnl ------------
4951dnl Check for a given program, defining corresponding symbol.
4952dnl	$1 = environment variable, which is suffixed by "_PATH" in the #define.
4953dnl	$2 = program name to find.
4954dnl	$3 = optional list of additional program names to test.
4955dnl $4 = $PATH
4956dnl
4957dnl If there is more than one token in the result, #define the remaining tokens
4958dnl to $1_ARGS.  We need this for 'install' in particular.
4959dnl
4960dnl FIXME: we should allow this to be overridden by environment variables
4961dnl
4962AC_DEFUN([CF_PATH_PROG],[
4963AC_REQUIRE([CF_PATHSEP])
4964test -z "[$]$1" && $1="$2"
4965AC_PATH_PROGS($1,[$]$1 $2 ifelse($3,,,$3),[$]$1, ifelse($4,,,$4))
4966
4967cf_path_prog=""
4968cf_path_args=""
4969IFS="${IFS:- 	}"; cf_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR"
4970for cf_temp in $ac_cv_path_$1
4971do
4972	if test -z "$cf_path_prog" ; then
4973		if test "$with_full_paths" = yes ; then
4974			CF_PATH_SYNTAX(cf_temp,break)
4975			cf_path_prog="$cf_temp"
4976		else
4977			cf_path_prog="`basename "$cf_temp"`"
4978		fi
4979	elif test -z "$cf_path_args" ; then
4980		cf_path_args="$cf_temp"
4981	else
4982		cf_path_args="$cf_path_args $cf_temp"
4983	fi
4984done
4985IFS="$cf_save_ifs"
4986
4987if test -n "$cf_path_prog" ; then
4988	CF_MSG_LOG(defining path for ${cf_path_prog})
4989	AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog",Define to pathname $1)
4990	test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args",Define to provide args for $1)
4991fi
4992])dnl
4993dnl ---------------------------------------------------------------------------
4994dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
4995dnl --------------
4996dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
4997dnl begins with one of the prefix/exec_prefix variables, and then again if the
4998dnl result begins with 'NONE'.  This is necessary to work around autoconf's
4999dnl delayed evaluation of those symbols.
5000AC_DEFUN([CF_PATH_SYNTAX],[
5001if test "x$prefix" != xNONE; then
5002	cf_path_syntax="$prefix"
5003else
5004	cf_path_syntax="$ac_default_prefix"
5005fi
5006
5007case ".[$]$1" in
5008(.\[$]\(*\)*|.\'*\'*)
5009	;;
5010(..|./*|.\\*)
5011	;;
5012(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
5013	;;
5014(.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
5015	eval $1="[$]$1"
5016	case ".[$]$1" in
5017	(.NONE/*)
5018		$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
5019		;;
5020	esac
5021	;;
5022(.no|.NONE/*)
5023	$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
5024	;;
5025(*)
5026	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
5027	;;
5028esac
5029])dnl
5030dnl ---------------------------------------------------------------------------
5031dnl CF_PDCURSES_W32 version: 2 updated: 2019/12/31 10:27:03
5032dnl ---------------
5033dnl Configure for PDCurses' Win32 library, checking for definitions as well
5034dnl which are needed to use its header file correctly.
5035AC_DEFUN([CF_PDCURSES_W32],[
5036
5037AC_CHECK_LIB(pdcurses,initscr,[
5038	CF_ADD_LIBS(-lpdcurses)
5039	cf_cv_term_header=no
5040	cf_cv_unctrl_header=no
5041	AC_CHECK_FUNC(winwstr,[AC_DEFINE(PDC_WIDE,1,[Define to 1 if PDCurses has winwstr])])
5042	AC_CHECK_FUNC(pdcurses_dll_iname,[AC_DEFINE(PDC_DLL_BUILD,1,[Define to 1 if PDCurses has pdcurses_dll_iname])])
5043])
5044
5045])dnl
5046dnl ---------------------------------------------------------------------------
5047dnl CF_PDCURSES_X11 version: 15 updated: 2021/01/02 09:31:20
5048dnl ---------------
5049dnl Configure for PDCurses' X11 library
5050AC_DEFUN([CF_PDCURSES_X11],[
5051AC_REQUIRE([CF_X_ATHENA])
5052
5053CF_ACVERSION_CHECK(2.52,
5054	[AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
5055	[AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
5056
5057if test "$XCURSES_CONFIG" != none ; then
5058
5059CF_ADD_CFLAGS(`$XCURSES_CONFIG --cflags`)
5060CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
5061
5062cf_cv_lib_XCurses=yes
5063
5064else
5065
5066LDFLAGS="$LDFLAGS $X_LIBS"
5067CF_CHECK_CFLAGS($X_CFLAGS)
5068AC_CHECK_LIB(X11,XOpenDisplay,
5069	[CF_ADD_LIBS(-lX11)],,
5070	[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
5071AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
5072CF_ADD_LIBS(-lXCurses)
5073AC_TRY_LINK([
5074#include <xcurses.h>
5075char *XCursesProgramName = "test";
5076],[XCursesExit();],
5077[cf_cv_lib_XCurses=yes],
5078[cf_cv_lib_XCurses=no])
5079])
5080
5081fi
5082
5083if test "$cf_cv_lib_XCurses" = yes ; then
5084	AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
5085	AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
5086	AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
5087else
5088	AC_MSG_ERROR(Cannot link with XCurses)
5089fi
5090])dnl
5091dnl ---------------------------------------------------------------------------
5092dnl CF_PKG_CONFIG version: 11 updated: 2021/01/01 13:31:04
5093dnl -------------
5094dnl Check for the package-config program, unless disabled by command-line.
5095AC_DEFUN([CF_PKG_CONFIG],
5096[
5097AC_MSG_CHECKING(if you want to use pkg-config)
5098AC_ARG_WITH(pkg-config,
5099	[  --with-pkg-config{=path} enable/disable use of pkg-config],
5100	[cf_pkg_config=$withval],
5101	[cf_pkg_config=yes])
5102AC_MSG_RESULT($cf_pkg_config)
5103
5104case "$cf_pkg_config" in
5105(no)
5106	PKG_CONFIG=none
5107	;;
5108(yes)
5109	CF_ACVERSION_CHECK(2.52,
5110		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
5111		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
5112	;;
5113(*)
5114	PKG_CONFIG=$withval
5115	;;
5116esac
5117
5118test -z "$PKG_CONFIG" && PKG_CONFIG=none
5119if test "$PKG_CONFIG" != none ; then
5120	CF_PATH_SYNTAX(PKG_CONFIG)
5121elif test "x$cf_pkg_config" != xno ; then
5122	AC_MSG_WARN(pkg-config is not installed)
5123fi
5124
5125AC_SUBST(PKG_CONFIG)
5126])dnl
5127dnl ---------------------------------------------------------------------------
5128dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
5129dnl -----------------
5130dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
5131dnl
5132dnl	POSIX.1-1990				_POSIX_SOURCE
5133dnl	POSIX.1-1990 and			_POSIX_SOURCE and
5134dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
5135dnl		Bindings Option
5136dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
5137dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
5138dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
5139dnl
5140dnl Parameters:
5141dnl	$1 is the nominal value for _POSIX_C_SOURCE
5142AC_DEFUN([CF_POSIX_C_SOURCE],
5143[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
5144
5145if test "$cf_cv_posix_visible" = no; then
5146
5147cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
5148
5149cf_save_CFLAGS="$CFLAGS"
5150cf_save_CPPFLAGS="$CPPFLAGS"
5151
5152CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
5153CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
5154
5155AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
5156	CF_MSG_LOG(if the symbol is already defined go no further)
5157	AC_TRY_COMPILE([#include <sys/types.h>],[
5158#ifndef _POSIX_C_SOURCE
5159make an error
5160#endif],
5161	[cf_cv_posix_c_source=no],
5162	[cf_want_posix_source=no
5163	 case .$cf_POSIX_C_SOURCE in
5164	 (.[[12]]??*)
5165		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
5166		;;
5167	 (.2)
5168		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
5169		cf_want_posix_source=yes
5170		;;
5171	 (.*)
5172		cf_want_posix_source=yes
5173		;;
5174	 esac
5175	 if test "$cf_want_posix_source" = yes ; then
5176		AC_TRY_COMPILE([#include <sys/types.h>],[
5177#ifdef _POSIX_SOURCE
5178make an error
5179#endif],[],
5180		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
5181	 fi
5182	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
5183	 CFLAGS="$cf_trim_CFLAGS"
5184	 CPPFLAGS="$cf_trim_CPPFLAGS"
5185	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
5186	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
5187	 AC_TRY_COMPILE([#include <sys/types.h>],[
5188#ifndef _POSIX_C_SOURCE
5189make an error
5190#endif],,
5191	 [cf_cv_posix_c_source=no])
5192	 CFLAGS="$cf_save_CFLAGS"
5193	 CPPFLAGS="$cf_save_CPPFLAGS"
5194	])
5195])
5196
5197if test "$cf_cv_posix_c_source" != no ; then
5198	CFLAGS="$cf_trim_CFLAGS"
5199	CPPFLAGS="$cf_trim_CPPFLAGS"
5200	CF_ADD_CFLAGS($cf_cv_posix_c_source)
5201fi
5202
5203fi # cf_cv_posix_visible
5204
5205])dnl
5206dnl ---------------------------------------------------------------------------
5207dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
5208dnl ----------------
5209dnl POSIX documents test-macros which an application may set before any system
5210dnl headers are included to make features available.
5211dnl
5212dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
5213dnl diverged from POSIX in 2002 by setting symbols which make all of the most
5214dnl recent features visible in the system header files unless the application
5215dnl overrides the corresponding test-macros.  Doing that introduces portability
5216dnl problems.
5217dnl
5218dnl This macro makes a special check for the symbols used for this, to avoid a
5219dnl conflicting definition.
5220AC_DEFUN([CF_POSIX_VISIBLE],
5221[
5222AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
5223AC_TRY_COMPILE([#include <stdio.h>],[
5224#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
5225	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
5226	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
5227	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
5228#error conflicting symbols found
5229#endif
5230],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
5231])
5232])dnl
5233dnl ---------------------------------------------------------------------------
5234dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
5235dnl ----------
5236dnl Check for archiver "ar".
5237AC_DEFUN([CF_PROG_AR],[
5238AC_CHECK_TOOL(AR, ar, ar)
5239])
5240dnl ---------------------------------------------------------------------------
5241dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
5242dnl ----------
5243dnl standard check for CC, plus followup sanity checks
5244dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
5245AC_DEFUN([CF_PROG_CC],[
5246CF_ACVERSION_CHECK(2.53,
5247	[AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
5248	 AC_REQUIRE([AC_PROG_CC])],
5249	[])
5250ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
5251CF_GCC_VERSION
5252CF_ACVERSION_CHECK(2.52,
5253	[AC_PROG_CC_STDC],
5254	[CF_ANSI_CC_REQD])
5255CF_CC_ENV_FLAGS
5256])dnl
5257dnl ---------------------------------------------------------------------------
5258dnl CF_PROG_CPP_COMMENTS version: 1 updated: 2017/07/02 14:31:07
5259dnl --------------------
5260dnl Ask for preprocessor "-C" option if we can get it.
5261AC_DEFUN([CF_PROG_CPP_COMMENTS],[
5262AC_REQUIRE([AC_PROG_CPP])
5263AC_MSG_CHECKING(if preprocessor -C option works)
5264AC_CACHE_VAL(cf_cv_prog_cpp_comments,[
5265cf_cv_prog_cpp_comments=no
5266cat >conftest.c <<CF_EOF
5267int main(void)
5268{
5269	/* COMMENT */
5270	return 0;
5271}
5272CF_EOF
5273if ( $CPP -C conftest.c >conftest.i 2>/dev/null )
5274then
5275	if ( grep COMMENT conftest.i >/dev/null 2>/dev/null )
5276	then
5277		cf_cv_prog_cpp_comments=yes
5278	fi
5279fi
5280rm -f conftest.[[ci]]
5281])
5282AC_MSG_RESULT($cf_cv_prog_cpp_comments)
5283if test x$cf_cv_prog_cpp_comments = xyes
5284then
5285	CPP="$CPP -C"
5286fi
5287])dnl
5288dnl ---------------------------------------------------------------------------
5289dnl CF_PROG_EXT version: 15 updated: 2021/01/02 09:31:20
5290dnl -----------
5291dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
5292AC_DEFUN([CF_PROG_EXT],
5293[
5294AC_REQUIRE([CF_CHECK_CACHE])
5295case "$cf_cv_system_name" in
5296(os2*)
5297	CFLAGS="$CFLAGS -Zmt"
5298	CF_APPEND_TEXT(CPPFLAGS,-D__ST_MT_ERRNO__)
5299	CXXFLAGS="$CXXFLAGS -Zmt"
5300	# autoconf's macro sets -Zexe and suffix both, which conflict:w
5301	LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
5302	ac_cv_exeext=.exe
5303	;;
5304esac
5305
5306AC_EXEEXT
5307AC_OBJEXT
5308
5309PROG_EXT="$EXEEXT"
5310AC_SUBST(PROG_EXT)
5311test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT",[Define to the program extension (normally blank)])
5312])dnl
5313dnl ---------------------------------------------------------------------------
5314dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
5315dnl ------------
5316AC_DEFUN([CF_PROG_LINT],
5317[
5318AC_CHECK_PROGS(LINT, lint cppcheck splint)
5319case "x$LINT" in
5320(xcppcheck|x*/cppcheck)
5321	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
5322	;;
5323esac
5324AC_SUBST(LINT_OPTS)
5325])dnl
5326dnl ---------------------------------------------------------------------------
5327dnl CF_PROG_RANLIB version: 1 updated: 2009/01/01 20:15:22
5328dnl --------------
5329dnl Check for ranlib.
5330dnl
5331dnl TODO: make this conditionally depend on autoconf version, since the later
5332dnl versions of autoconf use check-tool.
5333AC_DEFUN([CF_PROG_RANLIB],[
5334AC_CHECK_TOOL(RANLIB, ranlib, ':')
5335])
5336dnl ---------------------------------------------------------------------------
5337dnl CF_RECHECK_FUNC version: 3 updated: 2000/10/18 19:29:13
5338dnl ---------------
5339dnl Re-check on a function to see if we can pick it up by adding a library.
5340dnl	$1 = function to check
5341dnl	$2 = library to check in
5342dnl	$3 = environment to update (e.g., $LIBS)
5343dnl	$4 = what to do if this fails
5344dnl
5345dnl This uses 'unset' if the shell happens to support it, but leaves the
5346dnl configuration variable set to 'unknown' if not.  This is a little better
5347dnl than the normal autoconf test, which gives misleading results if a test
5348dnl for the function is made (e.g., with AC_CHECK_FUNC) after this macro is
5349dnl used (autoconf does not distinguish between a null token and one that is
5350dnl set to 'no').
5351AC_DEFUN([CF_RECHECK_FUNC],[
5352AC_CHECK_LIB($2,$1,[
5353	CF_UPPER(cf_tr_func,$1)
5354	AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func)
5355	ac_cv_func_$1=yes
5356	if test "$cf_used_lib_$2" != yes ; then cf_used_lib_$2=yes; $3="-l$2 [$]$3"; fi],[
5357	ac_cv_func_$1=unknown
5358	unset ac_cv_func_$1 2>/dev/null
5359	$4],
5360	[[$]$3])
5361])dnl
5362dnl ---------------------------------------------------------------------------
5363dnl CF_REMOVE_BROKEN version: 4 updated: 2012/11/08 20:57:52
5364dnl ----------------
5365dnl Check for broken definition of 'remove()'.  This is (in particular) broken
5366dnl on the older version of SCO (I'd cite version if I knew where to look) by
5367dnl having <stdio.h> #define remove to __unlink, which appears in no library.
5368dnl
5369dnl Fortuitously, we can combine this with a more general test: do we have
5370dnl 'unlink()' but no 'remove()'.  Note, however, that we cannot simply #define
5371dnl remove to unlink, but have to make a fallback function.
5372dnl
5373AC_DEFUN([CF_REMOVE_BROKEN],
5374[
5375AC_MSG_CHECKING(for broken/missing definition of remove)
5376AC_CACHE_VAL(cf_cv_baddef_remove,[
5377AC_TRY_LINK(
5378	[#include <stdio.h>],
5379	[remove("dummy")],
5380	[cf_cv_baddef_remove=no],
5381	[AC_TRY_LINK(
5382		[#include <stdio.h>
5383		int __unlink(name) { return unlink(name); } ],
5384		[remove("dummy")],
5385		[cf_cv_baddef_remove=yes],
5386		[cf_cv_baddef_remove=unknown])
5387	])
5388])
5389AC_MSG_RESULT($cf_cv_baddef_remove)
5390test "$cf_cv_baddef_remove" != no && AC_DEFINE(NEED_REMOVE,1,[Define to 1 if we should use remove rather than unlink])
5391])dnl
5392dnl ---------------------------------------------------------------------------
5393dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
5394dnl ----------------
5395dnl Remove all -U and -D options that refer to the given symbol from a list
5396dnl of C compiler options.  This works around the problem that not all
5397dnl compilers process -U and -D options from left-to-right, so a -U option
5398dnl cannot be used to cancel the effect of a preceding -D option.
5399dnl
5400dnl $1 = target (which could be the same as the source variable)
5401dnl $2 = source (including '$')
5402dnl $3 = symbol to remove
5403define([CF_REMOVE_DEFINE],
5404[
5405$1=`echo "$2" | \
5406	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
5407		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
5408])dnl
5409dnl ---------------------------------------------------------------------------
5410dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
5411dnl ---------------------
5412dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
5413dnl $1 = name of current macro
5414define([CF_RESTORE_XTRA_FLAGS],
5415[
5416LIBS="$cf_save_LIBS_$1"
5417CFLAGS="$cf_save_CFLAGS_$1"
5418CPPFLAGS="$cf_save_CPPFLAGS_$1"
5419])dnl
5420dnl ---------------------------------------------------------------------------
5421dnl CF_RPATH_HACK version: 13 updated: 2021/01/03 18:30:50
5422dnl -------------
5423AC_DEFUN([CF_RPATH_HACK],
5424[AC_REQUIRE([AC_PROG_FGREP])dnl
5425AC_REQUIRE([CF_LD_RPATH_OPT])dnl
5426
5427AC_MSG_CHECKING(for updated LDFLAGS)
5428if test -n "$LD_RPATH_OPT" ; then
5429	AC_MSG_RESULT(maybe)
5430
5431	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
5432	cf_rpath_list="/usr/lib /lib"
5433	if test "$cf_ldd_prog" != no
5434	then
5435		cf_rpath_oops=
5436
5437AC_TRY_LINK([#include <stdio.h>],
5438		[printf("Hello");],
5439		[cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
5440		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
5441
5442		# If we passed the link-test, but get a "not found" on a given library,
5443		# this could be due to inept reconfiguration of gcc to make it only
5444		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
5445		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
5446		# /usr/local libraries.
5447		if test -n "$cf_rpath_oops"
5448		then
5449			for cf_rpath_src in $cf_rpath_oops
5450			do
5451				for cf_rpath_dir in \
5452					/usr/local \
5453					/usr/pkg \
5454					/opt/sfw
5455				do
5456					if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
5457					then
5458						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
5459						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
5460						break
5461					fi
5462				done
5463			done
5464		fi
5465	fi
5466
5467	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
5468
5469	CF_RPATH_HACK_2(LDFLAGS)
5470	CF_RPATH_HACK_2(LIBS)
5471
5472	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
5473else
5474	AC_MSG_RESULT(no)
5475fi
5476AC_SUBST(EXTRA_LDFLAGS)
5477])dnl
5478dnl ---------------------------------------------------------------------------
5479dnl CF_RPATH_HACK_2 version: 8 updated: 2021/01/01 13:31:04
5480dnl ---------------
5481dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
5482dnl EXTRA_LDFLAGS for each -L option found.
5483dnl
5484dnl $cf_rpath_list contains a list of directories to ignore.
5485dnl
5486dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
5487dnl      but LIBS often has misplaced -L options.
5488AC_DEFUN([CF_RPATH_HACK_2],
5489[
5490CF_VERBOSE(...checking $1 [$]$1)
5491
5492cf_rpath_dst=
5493for cf_rpath_src in [$]$1
5494do
5495	case "$cf_rpath_src" in
5496	(-L*)
5497
5498		# check if this refers to a directory which we will ignore
5499		cf_rpath_skip=no
5500		if test -n "$cf_rpath_list"
5501		then
5502			for cf_rpath_item in $cf_rpath_list
5503			do
5504				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
5505				then
5506					cf_rpath_skip=yes
5507					break
5508				fi
5509			done
5510		fi
5511
5512		if test "$cf_rpath_skip" = no
5513		then
5514			# transform the option
5515			if test "$LD_RPATH_OPT" = "-R " ; then
5516				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
5517			else
5518				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
5519			fi
5520
5521			# if we have not already added this, add it now
5522			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
5523			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
5524			then
5525				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
5526				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
5527			fi
5528		fi
5529		;;
5530	esac
5531	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
5532done
5533$1=$cf_rpath_dst
5534
5535CF_VERBOSE(...checked $1 [$]$1)
5536AC_SUBST(EXTRA_LDFLAGS)
5537])dnl
5538dnl ---------------------------------------------------------------------------
5539dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
5540dnl ------------------
5541dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
5542dnl and libraries which do not update those variables.
5543dnl
5544dnl $1 = name of current macro
5545define([CF_SAVE_XTRA_FLAGS],
5546[
5547cf_save_LIBS_$1="$LIBS"
5548cf_save_CFLAGS_$1="$CFLAGS"
5549cf_save_CPPFLAGS_$1="$CPPFLAGS"
5550LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
5551for cf_X_CFLAGS in $X_CFLAGS
5552do
5553	case "x$cf_X_CFLAGS" in
5554	x-[[IUD]]*)
5555		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
5556		;;
5557	*)
5558		CFLAGS="$CFLAGS $cf_X_CFLAGS"
5559		;;
5560	esac
5561done
5562])dnl
5563dnl ---------------------------------------------------------------------------
5564dnl CF_SET_ERRNO version: 6 updated: 2017/05/10 18:31:29
5565dnl ------------
5566dnl Check if 'errno' is declared in a fashion that lets us set it.
5567AC_DEFUN([CF_SET_ERRNO],
5568[
5569AC_CACHE_CHECK(if we can set errno,cf_cv_set_errno,[
5570AC_TRY_RUN([
5571#include <errno.h>
5572int main(void)
5573{
5574	errno = 255;
5575	${cf_cv_main_return:-return}(errno != 255);
5576}],
5577	[cf_cv_set_errno=yes],
5578	[cf_cv_set_errno=no],
5579	[AC_TRY_LINK(
5580		[#include <errno.h>],
5581		[errno = 255],
5582		[cf_cv_set_errno=maybe],
5583		[cf_cv_set_errno=no])])
5584])
5585test "$cf_cv_set_errno" != no && AC_DEFINE(CAN_SET_ERRNO,1,[Define to 1 if we can set errno])
5586])dnl
5587dnl ---------------------------------------------------------------------------
5588dnl CF_SIGWINCH version: 6 updated: 2021/01/01 13:31:04
5589dnl -----------
5590dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
5591dnl programs need this test).
5592dnl
5593dnl This is really a Mac OS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
5594dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
5595dnl winsize declaration is left alone - we may revisit this if Apple choose to
5596dnl break that part of the interface as well.
5597AC_DEFUN([CF_SIGWINCH],
5598[
5599AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
5600	AC_TRY_COMPILE([
5601#include <sys/types.h>
5602#include <sys/signal.h>
5603],[int x = SIGWINCH; (void)x],
5604	[cf_cv_define_sigwinch=yes],
5605	[AC_TRY_COMPILE([
5606#undef _XOPEN_SOURCE
5607#undef _POSIX_SOURCE
5608#undef _POSIX_C_SOURCE
5609#include <sys/types.h>
5610#include <sys/signal.h>
5611],[int x = SIGWINCH; (void)x],
5612	[cf_cv_define_sigwinch=maybe],
5613	[cf_cv_define_sigwinch=no])
5614])
5615])
5616
5617if test "$cf_cv_define_sigwinch" = maybe ; then
5618AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
5619cf_cv_fixup_sigwinch=unknown
5620cf_sigwinch=32
5621while test "$cf_sigwinch" != 1
5622do
5623	AC_TRY_COMPILE([
5624#undef _XOPEN_SOURCE
5625#undef _POSIX_SOURCE
5626#undef _POSIX_C_SOURCE
5627#include <sys/types.h>
5628#include <sys/signal.h>
5629],[
5630#if SIGWINCH != $cf_sigwinch
5631make an error
5632#endif
5633int x = SIGWINCH; (void)x],
5634	[cf_cv_fixup_sigwinch=$cf_sigwinch
5635	 break])
5636
5637cf_sigwinch="`expr "$cf_sigwinch" - 1`"
5638done
5639])
5640
5641	if test "$cf_cv_fixup_sigwinch" != unknown ; then
5642		CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
5643	fi
5644fi
5645])dnl
5646dnl ---------------------------------------------------------------------------
5647dnl CF_SIZECHANGE version: 17 updated: 2021/01/01 13:31:04
5648dnl -------------
5649dnl Check for definitions & structures needed for window size-changing
5650dnl
5651dnl https://stackoverflow.com/questions/18878141/difference-between-structures-ttysize-and-winsize/50769952#50769952
5652AC_DEFUN([CF_SIZECHANGE],
5653[
5654AC_REQUIRE([CF_STRUCT_TERMIOS])
5655AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
5656	cf_cv_sizechange=unknown
5657	cf_save_CPPFLAGS="$CPPFLAGS"
5658
5659for cf_opts in "" "NEED_PTEM_H"
5660do
5661
5662	CPPFLAGS="$cf_save_CPPFLAGS"
5663	if test -n "$cf_opts"
5664	then
5665		CF_APPEND_TEXT(CPPFLAGS,-D$cf_opts)
5666	fi
5667	AC_TRY_COMPILE([#include <sys/types.h>
5668#ifdef HAVE_TERMIOS_H
5669#include <termios.h>
5670#else
5671#ifdef HAVE_TERMIO_H
5672#include <termio.h>
5673#endif
5674#endif
5675
5676#ifdef NEED_PTEM_H
5677/* This is a workaround for SCO:  they neglected to define struct winsize in
5678 * termios.h -- it's only in termio.h and ptem.h
5679 */
5680#include <sys/stream.h>
5681#include <sys/ptem.h>
5682#endif
5683
5684#ifdef HAVE_SYS_IOCTL_H
5685#include <sys/ioctl.h>
5686#endif
5687],[
5688#ifdef TIOCGSIZE
5689	struct ttysize win;	/* SunOS 3.0... */
5690	int y = win.ts_lines = 2;
5691	int x = win.ts_cols = 1;
5692	(void)y;
5693	(void)x;
5694#else
5695#ifdef TIOCGWINSZ
5696	struct winsize win;	/* everything else */
5697	int y = win.ws_row = 2;
5698	int x = win.ws_col = 1;
5699	(void)y;
5700	(void)x;
5701#else
5702	no TIOCGSIZE or TIOCGWINSZ
5703#endif /* TIOCGWINSZ */
5704#endif /* TIOCGSIZE */
5705	],
5706	[cf_cv_sizechange=yes],
5707	[cf_cv_sizechange=no])
5708
5709	CPPFLAGS="$cf_save_CPPFLAGS"
5710	if test "$cf_cv_sizechange" = yes ; then
5711		echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
5712		test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
5713		break
5714	fi
5715done
5716])
5717if test "$cf_cv_sizechange" != no ; then
5718	AC_DEFINE(HAVE_SIZECHANGE,1,[Define to 1 if sizechange declarations are provided])
5719	case "$cf_cv_sizechange" in
5720	(NEED*)
5721		AC_DEFINE_UNQUOTED($cf_cv_sizechange )
5722		;;
5723	esac
5724fi
5725])dnl
5726dnl ---------------------------------------------------------------------------
5727dnl CF_SLANG_CPPFLAGS version: 13 updated: 2021/01/04 17:48:08
5728dnl -----------------
5729dnl Look for the slang header files in the standard places, adjusting the
5730dnl CPPFLAGS variable.
5731dnl
5732dnl $1 = parameter to search for "slang2" class, e.g., for pkgsrc.
5733AC_DEFUN([CF_SLANG_CPPFLAGS],
5734[AC_REQUIRE([AC_PROG_EGREP])dnl
5735
5736AC_CACHE_CHECK(for $1 header file,cf_cv_$1_header,[
5737	cf_cv_$1_header=no
5738	AC_TRY_COMPILE([#include <slang.h>],
5739	[printf("%s\\n", SLANG_VERSION)],
5740	[cf_cv_$1_header=predefined],[
5741	CF_HEADER_PATH(cf_search,$1)
5742	for cf_incdir in $cf_search
5743	do
5744		for cf_header in \
5745			slang.h
5746		do
5747			echo trying "$cf_incdir/$cf_header" 1>&AC_FD_CC
5748			if ${EGREP-egrep} "SLANG_VERSION" "$cf_incdir/$cf_header" 1>&AC_FD_CC 2>&1; then
5749				cf_cv_$1_header=$cf_incdir/$cf_header
5750				break
5751			fi
5752		done
5753		test "$cf_cv_$1_header" != no && break
5754	done
5755	])])
5756
5757if test "x$cf_cv_$1_header" != xno
5758then
5759	AC_DEFINE(USE_SLANG,1,[Define to 1 if we should use s-lang library])
5760
5761	CF_DIRNAME(cf_incdir,$cf_cv_$1_header)
5762
5763	case "$cf_cv_$1_header" in
5764	(predefined)
5765		;;
5766	(*)
5767		CF_ADD_INCDIR($cf_incdir)
5768		;;
5769	esac
5770fi
5771])dnl
5772dnl ---------------------------------------------------------------------------
5773dnl CF_SLANG_LIBS version: 10 updated: 2021/01/02 09:31:20
5774dnl -------------
5775dnl Look for the slang library.
5776dnl
5777dnl $1 = the actual library name, usually "slang"
5778AC_DEFUN([CF_SLANG_LIBS],
5779[
5780cf_slang_LIBS1="$LIBS"
5781CF_TERMCAP_LIBS
5782cf_slang_LIBS2="$LIBS"
5783AC_CHECK_FUNC(acos,,[CF_RECHECK_FUNC(acos,m,LIBS)])
5784case "$host_os" in
5785(os2*)
5786	CF_FIND_LIBRARY(video,video,
5787		[#include <sys/video.h>],
5788		[v_init()],
5789		v_init)
5790	;;
5791esac
5792CF_FIND_LIBRARY($1,$1,
5793	[#include <slang.h>],
5794	[SLtt_get_screen_size()],
5795	SLtt_get_screen_size)
5796cf_slang_LIBS3="$LIBS"
5797AC_MSG_CHECKING(if we can link $1 without termcap)
5798if test -n "`echo "$cf_slang_LIBS1" | sed -e 's/ //g'`" ; then
5799	cf_exclude=`echo ".$cf_slang_LIBS2" | sed -e "s%$cf_slang_LIBS1%%" -e 's%^.%%'`
5800else
5801	cf_exclude="$cf_slang_LIBS2"
5802fi
5803LIBS=`echo ".$cf_slang_LIBS3" | sed -e "s%$cf_exclude%%" -e 's%^.%%'`
5804AC_TRY_LINK([#include <slang.h>],
5805	[SLtt_get_screen_size()],
5806	[cf_result=yes],
5807	[cf_result=no])
5808AC_MSG_RESULT($cf_result)
5809test "$cf_result" = no && LIBS="$cf_slang_LIBS3"
5810])dnl
5811dnl ---------------------------------------------------------------------------
5812dnl CF_SLANG_UNIX_DEFS version: 7 updated: 2021/01/02 09:31:20
5813dnl ------------------
5814dnl Slang's header files rely on some predefined symbols to declare variables
5815dnl that we might find useful.  This check is needed, because those symbols
5816dnl are generally not available.
5817AC_DEFUN([CF_SLANG_UNIX_DEFS],
5818[
5819
5820CF_SLANG_CPPFLAGS(slang)
5821if test "x$cf_cv_slang_header" != xno
5822then
5823	CF_SLANG_LIBS(slang)
5824else
5825	CF_SLANG_CPPFLAGS(slang2)
5826	if test "x$cf_cv_slang2_header" != xno
5827	then
5828		CF_SLANG_LIBS(slang2)
5829	else
5830		AC_MSG_ERROR(cannot find slang headers)
5831	fi
5832fi
5833
5834# There's an unofficial set of patches for slang that gives it some limited
5835# UTF8 capability.  Unfortunately it won't compile unless one defines UTF8.
5836AC_CACHE_CHECK(if we must define UTF8,cf_cv_slang_utf8,[
5837	AC_TRY_COMPILE([#include <slang.h>],
5838	[SLtt_get_screen_size()],
5839	[cf_cv_slang_utf8=no],
5840	[
5841	AC_TRY_COMPILE([
5842#define UTF8
5843#include <slang.h>],
5844	[SLtt_get_screen_size()],
5845	[cf_cv_slang_utf8=yes],
5846	[cf_cv_slang_utf8=unknown])])
5847])
5848
5849if test "$cf_cv_slang_utf8" = yes ; then
5850	AC_DEFINE(UTF8,1,[Define to 1 if we must define UTF-8 for s-lang headers])
5851fi
5852
5853AC_CACHE_CHECK(if we must tell slang this is UNIX,cf_cv_slang_unix,[
5854AC_TRY_LINK([#include <slang.h>],
5855	[
5856#ifdef REAL_UNIX_SYSTEM
5857make an error
5858#else
5859extern int SLang_TT_Baud_Rate;
5860SLang_TT_Baud_Rate = 1
5861#endif
5862],
5863	[cf_cv_slang_unix=yes],
5864	[cf_cv_slang_unix=no])
5865])
5866test "$cf_cv_slang_unix" = yes && AC_DEFINE(REAL_UNIX_SYSTEM,1,[Define to 1 if we must define REAL_UNIX_SYSTEM to compile with s-lang headers])
5867
5868CF_CHECK_TYPE(SLsmg_Color_Type,int,[#include <slang.h>])
5869CF_CHECK_TYPE(SLtt_Char_Type,unsigned long,[#include <slang.h>])
5870])dnl
5871dnl ---------------------------------------------------------------------------
5872dnl CF_SOCKS version: 9 updated: 2012/11/08 20:57:52
5873dnl --------
5874dnl Check for socks library
5875dnl $1 = the [optional] directory in which the library may be found
5876AC_DEFUN([CF_SOCKS],[
5877  CF_ADD_OPTIONAL_PATH($1, [socks library])
5878  CF_FIND_LINKAGE([
5879#include <stdio.h>
5880],[
5881      Raccept((char *)0)
5882],
5883      socks)
5884
5885  if test "x$cf_cv_find_linkage_socks" = "xyes" ; then
5886    AC_DEFINE(SOCKS,1,[Define to 1 if we are using socks library])
5887
5888    AC_DEFINE(accept,Raccept,[Define to override function name if using socks library])
5889    AC_DEFINE(bind,Rbind,[Define to override function name if using socks library])
5890    AC_DEFINE(connect,Rconnect,[Define to override function name if using socks library])
5891    AC_DEFINE(getpeername,Rgetpeername,[Define to override function name if using socks library])
5892    AC_DEFINE(getsockname,Rgetsockname,[Define to override function name if using socks library])
5893    AC_DEFINE(listen,Rlisten,[Define to override function name if using socks library])
5894    AC_DEFINE(recvfrom,Rrecvfrom,[Define to override function name if using socks library])
5895    AC_DEFINE(select,Rselect,[Define to override function name if using socks library])
5896  else
5897    AC_MSG_ERROR(cannot link with socks library)
5898  fi
5899])dnl
5900dnl ---------------------------------------------------------------------------
5901dnl CF_SOCKS5 version: 12 updated: 2012/11/08 20:57:52
5902dnl ---------
5903dnl Check for socks5 configuration
5904dnl $1 = the [optional] directory in which the library may be found
5905AC_DEFUN([CF_SOCKS5],[
5906  CF_ADD_OPTIONAL_PATH($1, [socks5 library])
5907
5908CF_ADD_LIBS(-lsocks5)
5909
5910AC_DEFINE(USE_SOCKS5,1,[Define to 1 if we are using socks5 library])
5911AC_DEFINE(SOCKS,1,[Define to 1 if we are using socks library])
5912
5913AC_MSG_CHECKING(if the socks library uses socks4 prefix)
5914cf_use_socks4=error
5915AC_TRY_LINK([
5916#include <socks.h>],[
5917	Rinit((char *)0)],
5918	[AC_DEFINE(USE_SOCKS4_PREFIX,1,[Define to 1 if socks library uses socks4 prefix])
5919	 cf_use_socks4=yes],
5920	[AC_TRY_LINK([#include <socks.h>],
5921		[SOCKSinit((char *)0)],
5922		[cf_use_socks4=no],
5923		[AC_MSG_ERROR(Cannot link with socks5 library)])])
5924AC_MSG_RESULT($cf_use_socks4)
5925
5926if test "$cf_use_socks4" = "yes" ; then
5927	AC_DEFINE(accept,Raccept)
5928	AC_DEFINE(bind,Rbind)
5929	AC_DEFINE(connect,Rconnect)
5930	AC_DEFINE(getpeername,Rgetpeername)
5931	AC_DEFINE(getsockname,Rgetsockname)
5932	AC_DEFINE(listen,Rlisten)
5933	AC_DEFINE(recvfrom,Rrecvfrom)
5934	AC_DEFINE(select,Rselect)
5935else
5936	AC_DEFINE(accept,SOCKSaccept)
5937	AC_DEFINE(getpeername,SOCKSgetpeername)
5938	AC_DEFINE(getsockname,SOCKSgetsockname)
5939	AC_DEFINE(recvfrom,SOCKSrecvfrom)
5940fi
5941
5942AC_MSG_CHECKING(if socks5p.h is available)
5943AC_TRY_COMPILE([
5944#define INCLUDE_PROTOTYPES
5945#include <socks.h>],[
5946	init((char *)0)],
5947	[cf_use_socks5p_h=yes],
5948	[cf_use_socks5p_h=no])
5949AC_MSG_RESULT($cf_use_socks5p_h)
5950
5951test "$cf_use_socks5p_h" = yes && AC_DEFINE(INCLUDE_PROTOTYPES,1,[Define to 1 if needed to declare prototypes in socks headers])
5952])dnl
5953dnl ---------------------------------------------------------------------------
5954dnl CF_SRAND version: 16 updated: 2021/06/08 18:08:14
5955dnl --------
5956dnl Check for functions similar to srand() and rand().  lrand48() and random()
5957dnl return a 31-bit value, while rand() returns a value less than RAND_MAX
5958dnl which usually is only 16-bits.
5959dnl
5960dnl On MirOS, use arc4random_push() and arc4random().
5961dnl Some systems support an asymmetric variation of this interface.
5962dnl
5963dnl $1 = optional prefix for resulting shell variables.  The default "my_"
5964dnl      gives $my_srand and $my_rand to the caller, as well as MY_RAND_MAX.
5965dnl      These are all AC_SUBST'd and AC_DEFINE'd.
5966AC_DEFUN([CF_SRAND],[
5967AC_CACHE_CHECK(for random-integer functions, cf_cv_srand_func,[
5968cf_cv_srand_func=unknown
5969for cf_func in arc4random_push/arc4random arc4random_stir/arc4random srandom/random srand48/lrand48 srand/rand
5970do
5971	CF_SRAND_PARSE($cf_func,cf_srand_func,cf_rand_func)
5972
5973AC_TRY_LINK([
5974#ifdef HAVE_STDLIB_H
5975#include <stdlib.h>
5976#endif
5977#ifdef HAVE_LIMITS_H
5978#include <limits.h>
5979#endif
5980],[long seed = 1; $cf_srand_func(seed); seed = $cf_rand_func(); (void)seed],
5981[cf_cv_srand_func=$cf_func
5982 break])
5983done
5984])
5985if test "$cf_cv_srand_func" != unknown ; then
5986	AC_CACHE_CHECK(for range of random-integers, cf_cv_rand_max,[
5987		case "$cf_cv_srand_func" in
5988		(srand/rand)
5989			cf_cv_rand_max=RAND_MAX
5990			cf_rand_max=16
5991			;;
5992		(*/arc4random)
5993			cf_cv_rand_max=0xFFFFFFFFUL
5994			cf_rand_max=32
5995			;;
5996		(*)
5997			cf_cv_rand_max=INT_MAX
5998			cf_rand_max=31
5999			;;
6000		esac
6001		AC_TRY_COMPILE([
6002#ifdef HAVE_STDLIB_H
6003#include <stdlib.h>
6004#endif
6005#ifdef HAVE_LIMITS_H
6006#include <limits.h>
6007#endif
6008		],[long x = $cf_cv_rand_max; (void)x],,
6009		[cf_cv_rand_max="(1UL<<$cf_rand_max)-1"])
6010	])
6011
6012	case "$cf_cv_srand_func" in
6013	(*/arc4random)
6014		AC_MSG_CHECKING(if <bsd/stdlib.h> should be included)
6015		AC_TRY_COMPILE([#include <bsd/stdlib.h>],
6016					   [void *arc4random(int);
6017						void *x = arc4random(1); (void)x],
6018					   [cf_bsd_stdlib_h=no],
6019					   [AC_TRY_COMPILE([#include <bsd/stdlib.h>],
6020									   [unsigned x = arc4random(); (void)x],
6021									   [cf_bsd_stdlib_h=yes],
6022									   [cf_bsd_stdlib_h=no])])
6023	    AC_MSG_RESULT($cf_bsd_stdlib_h)
6024		if test "$cf_bsd_stdlib_h" = yes
6025		then
6026			AC_DEFINE(HAVE_BSD_STDLIB_H,1,[Define to 1 if bsd/stdlib.h header should be used])
6027		else
6028			AC_MSG_CHECKING(if <bsd/random.h> should be included)
6029			AC_TRY_COMPILE([#include <bsd/random.h>],
6030						   [void *arc4random(int);
6031							void *x = arc4random(1); (void)x],
6032						   [cf_bsd_random_h=no],
6033						   [AC_TRY_COMPILE([#include <bsd/random.h>],
6034										   [unsigned x = arc4random(); (void)x],
6035										   [cf_bsd_random_h=yes],
6036										   [cf_bsd_random_h=no])])
6037			AC_MSG_RESULT($cf_bsd_random_h)
6038			if test "$cf_bsd_random_h" = yes
6039			then
6040				AC_DEFINE(HAVE_BSD_RANDOM_H,1,[Define to 1 if bsd/random.h header should be used])
6041			else
6042				AC_MSG_WARN(no header file found for arc4random)
6043			fi
6044		fi
6045		;;
6046	esac
6047
6048	CF_SRAND_PARSE($cf_func,cf_srand_func,cf_rand_func)
6049
6050	CF_UPPER(cf_rand_max,ifelse($1,,my_,$1)rand_max)
6051	AC_DEFINE_UNQUOTED(ifelse($1,,my_,$1)srand,$cf_srand_func,[Define to the name for the srand function])
6052	AC_DEFINE_UNQUOTED(ifelse($1,,my_,$1)rand, $cf_rand_func,[Define to the name for the rand function])
6053	AC_DEFINE_UNQUOTED([$]cf_rand_max, $cf_cv_rand_max,[Define to the name for the RAND_MAX constant])
6054fi
6055])dnl
6056dnl ---------------------------------------------------------------------------
6057dnl CF_SRAND_PARSE version: 2 updated: 2015/04/15 19:08:48
6058dnl --------------
6059dnl Parse the loop variable for CF_SRAND, with a workaround for asymmetric
6060dnl variations.
6061define([CF_SRAND_PARSE],[
6062	$2=`echo $1 | sed -e 's%/.*%%'`
6063	$3=`echo $1 | sed -e 's%.*/%%'`
6064
6065	case [$]$2 in
6066	(arc4random_stir)
6067		$2='(void)'
6068		;;
6069	esac
6070])dnl
6071dnl ---------------------------------------------------------------------------
6072dnl CF_SSL version: 26 updated: 2021/01/02 09:31:20
6073dnl ------
6074dnl Check for ssl library
6075dnl $1 = [optional] directory in which the library may be found, set by AC_ARG_WITH
6076AC_DEFUN([CF_SSL],[
6077	AC_REQUIRE([CF_PKG_CONFIG])
6078	cf_cv_have_ssl=no
6079	cf_cv_pkg_config_ssl=no
6080
6081	# command-line option, etc., override default behavior
6082	CF_ADD_OPTIONAL_PATH($1, [ssl library])
6083
6084	if test "x$PKG_CONFIG" != xnone; then
6085		case "$1" in
6086		(no)
6087			;;
6088		(yes) # if no explicit directory given, try pkg-config
6089			cf_cv_pkg_ssl=
6090			for cf_try_package in openssl libssl
6091			do
6092				AC_MSG_CHECKING(pkg-config for $cf_try_package)
6093				if "$PKG_CONFIG" --exists $cf_try_package ; then
6094					cf_cv_pkg_ssl=$cf_try_package
6095					AC_MSG_RESULT(yes)
6096					break
6097				else
6098					AC_MSG_RESULT(no)
6099				fi
6100			done
6101			if test -n "$cf_cv_pkg_ssl" ; then
6102				cf_cv_have_ssl=yes
6103				cf_cv_pkg_config_ssl=yes
6104
6105				cf_cflags_ssl=`$PKG_CONFIG --cflags $cf_cv_pkg_ssl`
6106				cf_libs_ssl=`$PKG_CONFIG --libs $cf_cv_pkg_ssl`
6107
6108				if test -n "$cf_cflags_ssl" ; then
6109					case "$cf_cflags_ssl" in
6110					(*-I*)
6111						cf_cv_header_path_ssl=`echo "$cf_cflags_ssl" | sed -e 's/^.*-I//' -e 's/ .*//'`
6112						;;
6113					(*)
6114						cf_cv_header_path_ssl=/usr/include
6115						;;
6116					esac
6117					CF_ADD_CFLAGS($cf_cflags_ssl)
6118
6119					# workaround for broken openssl package using kerberos
6120					case "$cf_cflags_ssl" in
6121					(*kerberos*)
6122						cf_cv_have_ssl=maybe
6123						;;
6124					esac
6125				else
6126					cf_cv_header_path_ssl=/usr/include
6127				fi
6128
6129				if test -d "$cf_cv_header_path_ssl/openssl" ; then
6130					cf_cv_header_path_ssl=$cf_cv_header_path_ssl/openssl
6131				fi
6132
6133				if test -n "$cf_libs_ssl" ; then
6134					case "x$cf_libs_ssl" in
6135					(*-L*)
6136						cf_cv_library_path_ssl=`echo "$cf_libs_ssl" | sed -e 's/^.*-L//' -e 's/ .*//'`
6137						;;
6138					(*)
6139						cf_cv_library_path_ssl=/usr/lib
6140						;;
6141					esac
6142					CF_VERBOSE(adding $cf_libs_ssl to LIBS)
6143					CF_ADD_LIBS($cf_libs_ssl)
6144				fi
6145			fi
6146			;;
6147		esac
6148	fi
6149
6150	if test "$cf_cv_have_ssl" != yes; then
6151		case "$host_os" in
6152		(mingw*)
6153			cf_extra_ssl_libs="-lcrypto -lgdi32"
6154			;;
6155		(*)
6156			# openssl 0.9.6 and up use dynamic loading for engines.
6157			cf_extra_ssl_libs="-lcrypto"
6158			case "x$LIBS" in
6159			(*-ldl)
6160				;;
6161			(*)
6162				AC_CHECK_LIB(dl,dlsym,
6163					[cf_extra_ssl_libs="$cf_extra_ssl_libs -ldl"])
6164				;;
6165			esac
6166			;;
6167		esac
6168
6169		CF_FIND_LINKAGE(CF__SSL_HEAD,
6170			CF__SSL_BODY,
6171			ssl,
6172			cf_cv_have_ssl=yes,
6173			cf_cv_have_ssl=no,
6174			openssl,
6175			$cf_extra_ssl_libs)
6176
6177		if test "$cf_cv_pkg_config_ssl" != yes ; then
6178			if test "$cf_cv_have_ssl" = yes ; then
6179				if test -n "$cf_cv_library_path_ssl" ; then
6180					CF_ADD_LIBDIR($cf_cv_library_path_ssl)
6181				fi
6182				CF_ADD_LIBS(-lssl $cf_extra_ssl_libs)
6183				if test -n "$cf_cv_header_path_ssl" ; then
6184					case "$cf_cv_header_path_ssl" in
6185					(/usr/include/openssl)
6186						;;
6187					(*)
6188						CF_ADD_INCDIR($cf_cv_header_path_ssl)
6189						;;
6190					esac
6191				fi
6192			fi
6193		fi
6194	fi
6195
6196	if test "$cf_cv_have_ssl" = yes ; then
6197		AC_DEFINE(USE_SSL,1,[Define to 1 if we are using SSL])
6198		if test -n "$cf_cv_header_path_ssl" ; then
6199			CF_VERBOSE(checking ssl header-path $cf_cv_header_path_ssl)
6200			case "$cf_cv_header_path_ssl" in
6201			(*/openssl)
6202				AC_DEFINE(USE_OPENSSL_INCL,1,[Define to 1 if we are using OpenSSL headers])
6203				;;
6204			esac
6205		fi
6206		CF_CHECK_SSL_X509
6207	fi
6208])dnl
6209dnl ---------------------------------------------------------------------------
6210dnl CF_STRIP_G_OPT version: 4 updated: 2021/01/02 09:31:20
6211dnl --------------
6212dnl	Remove "-g" option from the compiler options
6213AC_DEFUN([CF_STRIP_G_OPT],
6214[$1=`echo "${$1}" | CF__SED_TRIMBLANKS(-e 's%-g %%' -e 's%-g$%%')`])dnl
6215dnl ---------------------------------------------------------------------------
6216dnl CF_STRIP_O_OPT version: 4 updated: 2021/01/02 09:31:20
6217dnl --------------
6218dnl	Remove "-O" option from the compiler options
6219AC_DEFUN([CF_STRIP_O_OPT],[
6220$1=`echo "${$1}" | CF__SED_TRIMBLANKS(-e 's%-O[[1-9]]\? %%' -e 's%-O[[1-9]]\?$%%')`
6221])dnl
6222dnl ---------------------------------------------------------------------------
6223dnl CF_STRUCT_TERMIOS version: 11 updated: 2020/03/19 20:46:13
6224dnl -----------------
6225dnl Some machines require _POSIX_SOURCE to completely define struct termios.
6226AC_DEFUN([CF_STRUCT_TERMIOS],[
6227AC_REQUIRE([CF_XOPEN_SOURCE])
6228
6229AC_CHECK_HEADERS( \
6230termio.h \
6231termios.h \
6232unistd.h \
6233sys/ioctl.h \
6234sys/termio.h \
6235)
6236
6237if test "$ac_cv_header_termios_h" = yes ; then
6238	case "$CFLAGS $CPPFLAGS" in
6239	(*-D_POSIX_SOURCE*)
6240		termios_bad=dunno ;;
6241	(*)	termios_bad=maybe ;;
6242	esac
6243	if test "$termios_bad" = maybe ; then
6244	AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
6245	AC_TRY_COMPILE([#include <termios.h>],
6246		[struct termios foo; int x = foo.c_iflag = 1; (void)x],
6247		termios_bad=no, [
6248		AC_TRY_COMPILE([
6249#define _POSIX_SOURCE
6250#include <termios.h>],
6251			[struct termios foo; int x = foo.c_iflag = 2; (void)x],
6252			termios_bad=unknown,
6253			termios_bad=yes AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE]))
6254			])
6255	AC_MSG_RESULT($termios_bad)
6256	fi
6257fi
6258])dnl
6259dnl ---------------------------------------------------------------------------
6260dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
6261dnl --------------
6262dnl Construct a search-list for a nonstandard header/lib-file
6263dnl	$1 = the variable to return as result
6264dnl	$2 = the package name
6265dnl	$3 = the subdirectory, e.g., bin, include or lib
6266AC_DEFUN([CF_SUBDIR_PATH],
6267[
6268$1=
6269
6270CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
6271
6272for cf_subdir_prefix in \
6273	/usr \
6274	/usr/local \
6275	/usr/pkg \
6276	/opt \
6277	/opt/local \
6278	[$]HOME
6279do
6280	CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
6281done
6282])dnl
6283dnl ---------------------------------------------------------------------------
6284dnl CF_SYSTEM_MAIL_FLAGS version: 6 updated: 2021/01/02 09:31:20
6285dnl --------------------
6286AC_DEFUN([CF_SYSTEM_MAIL_FLAGS],
6287[
6288AC_MSG_CHECKING([system mail flags])
6289AC_CACHE_VAL(cf_cv_system_mail_flags,[
6290	case "$cf_cv_SYSTEM_MAIL" in
6291	(*/mmdf/*)
6292		[cf_cv_system_mail_flags="-mlruxto,cc\\\\*"]
6293        	;;
6294	(*)
6295        	[cf_cv_system_mail_flags="-t -oi"]
6296	esac
6297	])
6298AC_MSG_RESULT($cf_cv_system_mail_flags)
6299AC_DEFINE_UNQUOTED(SYSTEM_MAIL_FLAGS, "$cf_cv_system_mail_flags",[Define to value used for system mail-flags])
6300])dnl
6301dnl ---------------------------------------------------------------------------
6302dnl CF_SYSV_UTMP version: 7 updated: 2021/01/02 09:31:20
6303dnl ------------
6304dnl Check if this is a SYSV flavor of UTMP
6305AC_DEFUN([CF_SYSV_UTMP],
6306[
6307AC_CACHE_CHECK(if $cf_cv_have_utmp is SYSV flavor,cf_cv_sysv_utmp,[
6308test "$cf_cv_have_utmp" = "utmp" && cf_prefix="ut" || cf_prefix="utx"
6309AC_TRY_LINK([
6310#include <sys/types.h>
6311#include <${cf_cv_have_utmp}.h>],[
6312struct $cf_cv_have_utmp x;
6313	set${cf_prefix}ent ();
6314	get${cf_prefix}id(&x);
6315	put${cf_prefix}line(&x);
6316	end${cf_prefix}ent();],
6317	[cf_cv_sysv_utmp=yes],
6318	[cf_cv_sysv_utmp=no])
6319])
6320test "$cf_cv_sysv_utmp" = yes && AC_DEFINE(USE_SYSV_UTMP,1,[Define to 1 if utmp is SYSV flavor])
6321])dnl
6322dnl ---------------------------------------------------------------------------
6323dnl CF_SYS_ERRLIST version: 6 updated: 2001/12/30 13:03:23
6324dnl --------------
6325dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
6326dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
6327dnl declaration.  Reported by Keith Bostic.
6328AC_DEFUN([CF_SYS_ERRLIST],
6329[
6330    CF_CHECK_ERRNO(sys_nerr)
6331    CF_CHECK_ERRNO(sys_errlist)
6332])dnl
6333dnl ---------------------------------------------------------------------------
6334dnl CF_TAR_OPTIONS version: 3 updated: 2015/04/15 19:08:48
6335dnl --------------
6336dnl This is just a list of the most common tar options, allowing for variants
6337dnl that can operate with the "-" standard input/output option.
6338AC_DEFUN([CF_TAR_OPTIONS],
6339[
6340case ifelse($1,,tar,$1) in
6341(*pax|*pax$EXEEXT)
6342	TAR_UP_OPTIONS="-w"
6343	TAR_DOWN_OPTIONS="-r"
6344	TAR_PIPE_OPTIONS=""
6345	TAR_FILE_OPTIONS="-f"
6346	;;
6347(*star|*star$EXEEXT)
6348	TAR_UP_OPTIONS="-c -f"
6349	TAR_DOWN_OPTIONS="-x -U -f"
6350	TAR_PIPE_OPTIONS="-"
6351	TAR_FILE_OPTIONS=""
6352	;;
6353(*tar|*tar$EXEEXT)
6354	# FIXME: some versions of tar require, some don't allow the "-"
6355	TAR_UP_OPTIONS="-cf"
6356	TAR_DOWN_OPTIONS="-xf"
6357	TAR_PIPE_OPTIONS="-"
6358	TAR_FILE_OPTIONS=""
6359	;;
6360esac
6361
6362AC_SUBST(TAR_UP_OPTIONS)
6363AC_SUBST(TAR_DOWN_OPTIONS)
6364AC_SUBST(TAR_FILE_OPTIONS)
6365AC_SUBST(TAR_PIPE_OPTIONS)
6366])dnl
6367dnl ---------------------------------------------------------------------------
6368dnl CF_TERMCAP_LIBS version: 15 updated: 2015/04/15 19:08:48
6369dnl ---------------
6370dnl Look for termcap libraries, or the equivalent in terminfo.
6371dnl
6372dnl The optional parameter may be "ncurses", "ncursesw".
6373AC_DEFUN([CF_TERMCAP_LIBS],
6374[
6375AC_CACHE_VAL(cf_cv_termlib,[
6376cf_cv_termlib=none
6377AC_TRY_LINK([],[char *x=(char*)tgoto("",0,0)],
6378[AC_TRY_LINK([],[int x=tigetstr("")],
6379	[cf_cv_termlib=terminfo],
6380	[cf_cv_termlib=termcap])
6381	CF_VERBOSE(using functions in predefined $cf_cv_termlib LIBS)
6382],[
6383ifelse([$1],,,[
6384case "$1" in
6385(ncurses*)
6386	CF_NCURSES_CONFIG($1)
6387	cf_cv_termlib=terminfo
6388	;;
6389esac
6390])
6391if test "$cf_cv_termlib" = none; then
6392	# FreeBSD's linker gives bogus results for AC_CHECK_LIB, saying that
6393	# tgetstr lives in -lcurses when it is only an unsatisfied extern.
6394	cf_save_LIBS="$LIBS"
6395	for cf_lib in tinfo curses ncurses termlib termcap
6396	do
6397		LIBS="-l$cf_lib $cf_save_LIBS"
6398		for cf_func in tigetstr tgetstr
6399		do
6400			AC_MSG_CHECKING(for $cf_func in -l$cf_lib)
6401			AC_TRY_LINK([],[int x=$cf_func("")],[cf_result=yes],[cf_result=no])
6402			AC_MSG_RESULT($cf_result)
6403			if test "$cf_result" = yes ; then
6404				if test "$cf_func" = tigetstr ; then
6405					cf_cv_termlib=terminfo
6406				else
6407					cf_cv_termlib=termcap
6408				fi
6409				break
6410			fi
6411		done
6412		test "$cf_result" = yes && break
6413	done
6414	test "$cf_result" = no && LIBS="$cf_save_LIBS"
6415fi
6416if test "$cf_cv_termlib" = none; then
6417	# allow curses library for broken AIX system.
6418	AC_CHECK_LIB(curses, initscr, [CF_ADD_LIBS(-lcurses)])
6419	AC_CHECK_LIB(termcap, tgoto, [CF_ADD_LIBS(-ltermcap) cf_cv_termlib=termcap])
6420fi
6421])
6422if test "$cf_cv_termlib" = none; then
6423	AC_MSG_WARN([Cannot find -ltermlib, -lcurses, or -ltermcap])
6424fi
6425])])dnl
6426dnl ---------------------------------------------------------------------------
6427dnl CF_TERMIO_AND_CURSES version: 6 updated: 2021/01/02 09:31:20
6428dnl --------------------
6429dnl Check if including termio.h with <curses.h> dies like on sysv68
6430dnl FIXME: this is too Lynx-specific
6431AC_DEFUN([CF_TERMIO_AND_CURSES],
6432[
6433AC_CACHE_CHECK(if we can include termio.h with curses,cf_cv_termio_and_curses,[
6434    cf_save_CFLAGS="$CPPFLAGS"
6435    CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H -I. -I${srcdir:-.} -I${srcdir:-.}/src -I${srcdir:-.}/WWW/Library/Implementation"
6436    touch lynx_cfg.h
6437    AC_TRY_COMPILE([
6438#include <$1>
6439#include <termio.h>],
6440    [putchar(0x0a)],
6441    [cf_cv_termio_and_curses=yes],
6442    [cf_cv_termio_and_curses=no])
6443    CPPFLAGS="$cf_save_CFLAGS"
6444    rm -f lynx_cfg.h
6445])
6446
6447test "$cf_cv_termio_and_curses" = yes && AC_DEFINE(TERMIO_AND_CURSES,1,[Define to 1 if we can include termio.h with curses.h])
6448])dnl
6449dnl ---------------------------------------------------------------------------
6450dnl CF_TERMIO_AND_TERMIOS version: 4 updated: 2021/01/02 09:31:20
6451dnl ---------------------
6452dnl Check if including both termio.h and termios.h die like on DG.UX
6453AC_DEFUN([CF_TERMIO_AND_TERMIOS],
6454[
6455AC_MSG_CHECKING([termio.h and termios.h])
6456AC_CACHE_VAL(cf_cv_termio_and_termios,[
6457    AC_TRY_COMPILE([
6458#if HAVE_TERMIO_H
6459#include <termio.h>
6460#endif
6461#if HAVE_TERMIOS_H
6462#include <termios.h>
6463#endif ],
6464    [putchar (0x0a)],
6465    [cf_cv_termio_and_termios=yes],
6466    [cf_cv_termio_and_termios=no])])
6467AC_MSG_RESULT($cf_cv_termio_and_termios)
6468test "$cf_cv_termio_and_termios" = no && AC_DEFINE(TERMIO_AND_TERMIOS,1,[Define to 1 if we can include termio.h and termios.h])
6469])dnl
6470dnl ---------------------------------------------------------------------------
6471dnl CF_TERM_HEADER version: 6 updated: 2021/01/02 09:31:20
6472dnl --------------
6473dnl Look for term.h, which is part of X/Open curses.  It defines the interface
6474dnl to terminfo database.  Usually it is in the same include-path as curses.h,
6475dnl but some packagers change this, breaking various applications.
6476AC_DEFUN([CF_TERM_HEADER],[
6477AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
6478case "${cf_cv_ncurses_header}" in
6479(*/ncurses.h|*/ncursesw.h)
6480	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
6481	;;
6482(*)
6483	cf_term_header=term.h
6484	;;
6485esac
6486
6487for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
6488do
6489AC_TRY_COMPILE([#include <stdio.h>
6490#include <${cf_cv_ncurses_header:-curses.h}>
6491#include <$cf_test>
6492],[int x = auto_left_margin; (void)x],[
6493	cf_cv_term_header="$cf_test"],[
6494	cf_cv_term_header=unknown
6495	])
6496	test "$cf_cv_term_header" != unknown && break
6497done
6498])
6499
6500# Set definitions to allow ifdef'ing to accommodate subdirectories
6501
6502case "$cf_cv_term_header" in
6503(*term.h)
6504	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
6505	;;
6506esac
6507
6508case "$cf_cv_term_header" in
6509(ncurses/term.h)
6510	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
6511	;;
6512(ncursesw/term.h)
6513	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
6514	;;
6515esac
6516])dnl
6517dnl ---------------------------------------------------------------------------
6518dnl CF_TM_GMTOFF version: 5 updated: 2021/06/08 18:08:14
6519dnl ------------
6520dnl Check if the tm-struct defines the '.tm_gmtoff' member (useful in decoding
6521dnl dates).
6522AC_DEFUN([CF_TM_GMTOFF],
6523[
6524AC_MSG_CHECKING([for tm.tm_gmtoff])
6525AC_CACHE_VAL(cf_cv_tm_gmtoff,[
6526	AC_TRY_COMPILE([
6527#ifdef TIME_WITH_SYS_TIME
6528#	include <sys/time.h>
6529#	include <time.h>
6530#else
6531#	ifdef HAVE_SYS_TIME_H
6532#		include <sys/time.h>
6533#	else
6534#		include <time.h>
6535#	endif
6536#endif
6537],[
6538	static struct tm foo;
6539	long bar = foo.tm_gmtoff; (void) bar],
6540	[cf_cv_tm_gmtoff=yes],
6541	[cf_cv_tm_gmtoff=no])])
6542AC_MSG_RESULT($cf_cv_tm_gmtoff)
6543test "$cf_cv_tm_gmtoff" = no && AC_DEFINE(DONT_HAVE_TM_GMTOFF,1,[Define to 1 if the tm-struct defines .tm_gmtoff member])
6544])dnl
6545dnl ---------------------------------------------------------------------------
6546dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
6547dnl --------------
6548dnl Trim extra base X libraries added as a workaround for inconsistent library
6549dnl dependencies returned by "new" pkg-config files.
6550AC_DEFUN([CF_TRIM_X_LIBS],[
6551	for cf_trim_lib in Xmu Xt X11
6552	do
6553		case "$LIBS" in
6554		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
6555			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
6556			CF_VERBOSE(..trimmed $LIBS)
6557			;;
6558		esac
6559	done
6560])
6561dnl ---------------------------------------------------------------------------
6562dnl CF_TRY_PKG_CONFIG version: 6 updated: 2020/12/31 10:54:15
6563dnl -----------------
6564dnl This is a simple wrapper to use for pkg-config, for libraries which may be
6565dnl available in that form.
6566dnl
6567dnl $1 = package name, which may be a shell variable
6568dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
6569dnl $3 = logic to use if pkg-config does not have the package
6570AC_DEFUN([CF_TRY_PKG_CONFIG],[
6571AC_REQUIRE([CF_PKG_CONFIG])
6572
6573if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$1"; then
6574	CF_VERBOSE(found package $1)
6575	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$1" 2>/dev/null`"
6576	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$1" 2>/dev/null`"
6577	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
6578	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
6579	CF_ADD_CFLAGS($cf_pkgconfig_incs)
6580	CF_ADD_LIBS($cf_pkgconfig_libs)
6581	ifelse([$2],,:,[$2])
6582else
6583	cf_pkgconfig_incs=
6584	cf_pkgconfig_libs=
6585	ifelse([$3],,:,[$3])
6586fi
6587])
6588dnl ---------------------------------------------------------------------------
6589dnl CF_TRY_RPATH version: 2 updated: 2021/01/02 09:31:20
6590dnl ------------
6591dnl Work around broken-by-design packaging systems which solve at most the
6592dnl problem of building packages, without providing for library reuse...
6593AC_DEFUN([CF_TRY_RPATH],[
6594AC_REQUIRE([CF_LD_RPATH_OPT])
6595if test -z "$LD_RPATH_OPT"
6596then
6597	CF_VERBOSE(will not attempt to use rpath)
6598elif test "x${enable_rpath_hack:-yes}" = "xno"
6599then
6600	CF_VERBOSE(rpath is disabled)
6601elif test -z "${LD_RUN_PATH}${LD_LIBRARY_PATH}"
6602then
6603	case "$LIBS" in
6604	(*-L/*)
6605		CF__CHECK_RUN(cf_check_run)
6606		if test "x$cf_check_run" = xno
6607		then
6608			CF_VERBOSE(linkage is broken)
6609			cf_result=
6610			for cf_item in $LIBS
6611			do
6612				case " $cf_item" in
6613				(\ -L/*)
6614					cf_rpath_arg=`echo " $cf_item" | sed -e "s% -L%$LD_RPATH_OPT%"`
6615					cf_rpath_tmp=`echo "$cf_result " | sed -e "s% $cf_rpath_arg % %"`
6616					if test "x$cf_result " = "x$cf_rpath_tmp"
6617					then
6618						cf_result="$cf_result $cf_rpath_arg"
6619					fi
6620					cf_rpath_tmp=`echo "$cf_result " | sed -e "s% $cf_item % %g"`
6621					if test "x$cf_result " != "x$cf_rpath_tmp"
6622					then
6623						continue
6624					fi
6625					;;
6626				esac
6627				cf_result="$cf_result $cf_item"
6628			done
6629			cf_result=`echo "$cf_result" | sed -e 's/^ //'`
6630			if test "x$cf_result" != "x$LIBS"
6631			then
6632				cf_save_LIBS="$LIBS"
6633				LIBS="$cf_result"
6634				CF__CHECK_RUN(cf_check_run)
6635				if test "x$cf_check_run" = "xyes"
6636				then
6637					CF_VERBOSE(use rpath for $cf_save_LIBS)
6638					LIBS="$cf_result"
6639					CF_VERBOSE(result is now $LIBS)
6640				else
6641					LIBS="$cf_save_LIBS"
6642				fi
6643			fi
6644		fi
6645		;;
6646	(*)
6647		CF_VERBOSE(will not attempt to use rpath)
6648		;;
6649	esac
6650fi
6651])dnl
6652dnl ---------------------------------------------------------------------------
6653dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
6654dnl -------------------
6655dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
6656dnl can define it successfully.
6657AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
6658AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
6659	AC_TRY_COMPILE([
6660#include <stdlib.h>
6661#include <string.h>
6662#include <sys/types.h>
6663],[
6664#ifndef _XOPEN_SOURCE
6665make an error
6666#endif],
6667	[cf_cv_xopen_source=no],
6668	[cf_save="$CPPFLAGS"
6669	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
6670	 AC_TRY_COMPILE([
6671#include <stdlib.h>
6672#include <string.h>
6673#include <sys/types.h>
6674],[
6675#ifdef _XOPEN_SOURCE
6676make an error
6677#endif],
6678	[cf_cv_xopen_source=no],
6679	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
6680	CPPFLAGS="$cf_save"
6681	])
6682])
6683
6684if test "$cf_cv_xopen_source" != no ; then
6685	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
6686	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
6687	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
6688	CF_ADD_CFLAGS($cf_temp_xopen_source)
6689fi
6690])
6691dnl ---------------------------------------------------------------------------
6692dnl CF_TTYTYPE version: 7 updated: 2021/01/02 09:31:20
6693dnl ----------
6694AC_DEFUN([CF_TTYTYPE],
6695[
6696AC_MSG_CHECKING(if ttytype is declared in curses library)
6697AC_CACHE_VAL(cf_cv_have_ttytype,[
6698	AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
6699	[char *x = &ttytype[1]; *x = 1],
6700	[cf_cv_have_ttytype=yes],
6701	[cf_cv_have_ttytype=no])
6702	])
6703AC_MSG_RESULT($cf_cv_have_ttytype)
6704test "$cf_cv_have_ttytype" = yes && AC_DEFINE(HAVE_TTYTYPE,1,[Define to 1 if ttytype is declared in curses library])
6705])dnl
6706dnl ---------------------------------------------------------------------------
6707dnl CF_TYPE_LONG_LONG version: 5 updated: 2021/01/04 17:48:08
6708dnl -----------------
6709dnl Check for long long type.
6710AC_DEFUN([CF_TYPE_LONG_LONG],[
6711AC_REQUIRE([AC_PROG_FGREP])dnl
6712
6713AC_CACHE_CHECK(for long long type,cf_cv_type_long_long,[
6714	cat >conftest.$ac_ext <<_CFEOF
6715#include "confdefs.h"
6716int
6717main (void)
6718{
6719	long long foo = 123456789123456789LL;
6720	return (foo == 0);
6721}
6722_CFEOF
6723	(eval "[$]ac_compile") 2>conftest.err
6724	ac_status=$?
6725	if test "$ac_status" = 0 && test -s conftest.err
6726	then
6727		${FGREP-fgrep} warning conftest.err >/dev/null 2>&1 && ac_status=1
6728	fi
6729	if test "$ac_status" != 0
6730	then
6731		cf_cv_type_long_long=no
6732	else
6733		cf_cv_type_long_long=yes
6734	fi
6735	test -s conftest.err && cat conftest.err >&5
6736	rm -f conftest*
6737])
6738
6739if test "$cf_cv_type_long_long" = yes ; then
6740	AC_DEFINE(HAVE_LONG_LONG,1,[Define to 1 if compiler supports long long type])
6741fi
6742])dnl
6743dnl ---------------------------------------------------------------------------
6744dnl CF_UNION_WAIT version: 9 updated: 2021/06/08 18:08:14
6745dnl -------------
6746dnl Check to see if the BSD-style union wait is declared.  Some platforms may
6747dnl use this, though it is deprecated in favor of the 'int' type in Posix.
6748dnl Some vendors provide a bogus implementation that declares union wait, but
6749dnl uses the 'int' type instead; we try to spot these by checking for the
6750dnl associated macros.
6751dnl
6752dnl Ahem.  Some implementers cast the status value to an int*, as an attempt to
6753dnl use the macros for either union wait or int.  So we do a check compile to
6754dnl see if the macros are defined and apply to an int.
6755dnl
6756dnl Sets: $cf_cv_type_unionwait
6757dnl Defines: HAVE_TYPE_UNIONWAIT
6758AC_DEFUN([CF_UNION_WAIT],
6759[
6760AC_REQUIRE([CF_WAIT_HEADERS])
6761AC_MSG_CHECKING([for union wait])
6762AC_CACHE_VAL(cf_cv_type_unionwait,[
6763	AC_TRY_LINK($cf_wait_headers,
6764	[static int x;
6765	 int y = WEXITSTATUS(x);
6766	 int z = WTERMSIG(x);
6767	 wait(&x);
6768	 (void)x;
6769	 (void)y;
6770	 (void)z;
6771	],
6772	[cf_cv_type_unionwait=no
6773	 echo compiles ok w/o union wait 1>&AC_FD_CC
6774	],[
6775	AC_TRY_LINK($cf_wait_headers,
6776	[union wait x;
6777#ifdef WEXITSTATUS
6778	 int y = WEXITSTATUS(x);
6779#endif
6780#ifdef WTERMSIG
6781	 int z = WTERMSIG(x);
6782#endif
6783	 wait(&x);
6784	 (void)x;
6785#ifdef WEXITSTATUS
6786	 (void)y;
6787#endif
6788#ifdef WTERMSIG
6789	 (void)z;
6790#endif
6791	],
6792	[cf_cv_type_unionwait=yes
6793	 echo compiles ok with union wait and possibly macros too 1>&AC_FD_CC
6794	],
6795	[cf_cv_type_unionwait=no])])])
6796AC_MSG_RESULT($cf_cv_type_unionwait)
6797test "$cf_cv_type_unionwait" = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT,1,[Define to 1 if type unionwait is declared])
6798])dnl
6799dnl ---------------------------------------------------------------------------
6800dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
6801dnl --------
6802dnl Make an uppercase version of a variable
6803dnl $1=uppercase($2)
6804AC_DEFUN([CF_UPPER],
6805[
6806$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
6807])dnl
6808dnl ---------------------------------------------------------------------------
6809dnl CF_UTF8_LIB version: 9 updated: 2021/05/19 19:35:25
6810dnl -----------
6811dnl Check for multibyte support, and if not found, utf8 compatibility library
6812AC_DEFUN([CF_UTF8_LIB],
6813[
6814AC_HAVE_HEADERS(wchar.h)
6815AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
6816	cf_save_LIBS="$LIBS"
6817	AC_TRY_LINK([
6818#include <stdlib.h>
6819#include <stdio.h>
6820#ifdef HAVE_WCHAR_H
6821#include <wchar.h>
6822#endif
6823],[putwc(0,0);],
6824	[cf_cv_utf8_lib=yes],
6825	[CF_FIND_LINKAGE([
6826#include <libutf8.h>],[putwc(0,0);],utf8,
6827		[cf_cv_utf8_lib=add-on],
6828		[cf_cv_utf8_lib=no])
6829])])
6830
6831# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
6832# ncurses/ncursesw:
6833if test "$cf_cv_utf8_lib" = "add-on" ; then
6834	AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
6835	CF_ADD_INCDIR($cf_cv_header_path_utf8)
6836	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
6837	CF_ADD_LIBS($cf_cv_library_file_utf8)
6838fi
6839])dnl
6840dnl ---------------------------------------------------------------------------
6841dnl CF_UTMP version: 12 updated: 2021/01/02 09:31:20
6842dnl -------
6843dnl Check for UTMP/UTMPX headers
6844AC_DEFUN([CF_UTMP],
6845[
6846AC_REQUIRE([CF_LASTLOG])
6847
6848AC_CACHE_CHECK(for utmp implementation,cf_cv_have_utmp,[
6849	cf_cv_have_utmp=no
6850for cf_header in utmpx utmp ; do
6851cf_utmp_includes="
6852#include <sys/types.h>
6853#include <${cf_header}.h>
6854#define getutent getutxent
6855#ifdef USE_LASTLOG
6856#include <lastlog.h>	/* may conflict with utmpx.h on Linux */
6857#endif
6858"
6859	AC_TRY_COMPILE([$cf_utmp_includes],
6860	[struct $cf_header x;
6861	 char *name = x.ut_name; /* utmp.h and compatible definitions */
6862	 (void)x;
6863	 (void)name;
6864	],
6865	[cf_cv_have_utmp=$cf_header
6866	 break],
6867	[
6868	AC_TRY_COMPILE([$cf_utmp_includes],
6869	[struct $cf_header x;
6870	 char *name = x.ut_user; /* utmpx.h must declare this */
6871	 (void)x;
6872	 (void)name;
6873	],
6874	[cf_cv_have_utmp=$cf_header
6875	 break
6876	])])
6877done
6878])
6879
6880if test "$cf_cv_have_utmp" != no ; then
6881	AC_DEFINE(HAVE_UTMP,1,[Define to 1 if the utmp interface is available])
6882	test "$cf_cv_have_utmp" = utmpx && AC_DEFINE(UTMPX_FOR_UTMP,1,[Define if we have utmpx interface])
6883	CF_UTMP_UT_HOST
6884	CF_UTMP_UT_SYSLEN
6885	CF_UTMP_UT_NAME
6886	CF_UTMP_UT_XSTATUS
6887	CF_UTMP_UT_XTIME
6888	CF_UTMP_UT_SESSION
6889	CF_SYSV_UTMP
6890fi
6891])dnl
6892dnl ---------------------------------------------------------------------------
6893dnl CF_UTMP_UT_HOST version: 10 updated: 2021/01/02 09:31:20
6894dnl ---------------
6895dnl Check if UTMP/UTMPX struct defines ut_host member
6896AC_DEFUN([CF_UTMP_UT_HOST],
6897[
6898if test "$cf_cv_have_utmp" != no ; then
6899AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_host is declared)
6900AC_CACHE_VAL(cf_cv_have_utmp_ut_host,[
6901	AC_TRY_COMPILE([
6902#include <sys/types.h>
6903#include <${cf_cv_have_utmp}.h>],
6904	[struct $cf_cv_have_utmp x;
6905	 char *y = &x.ut_host[0];
6906	 (void)x;
6907	 (void)y],
6908	[cf_cv_have_utmp_ut_host=yes],
6909	[cf_cv_have_utmp_ut_host=no])
6910	])
6911AC_MSG_RESULT($cf_cv_have_utmp_ut_host)
6912test "$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])
6913fi
6914])dnl
6915dnl ---------------------------------------------------------------------------
6916dnl CF_UTMP_UT_NAME version: 8 updated: 2021/01/02 09:31:20
6917dnl ---------------
6918dnl Check if UTMP/UTMPX struct defines ut_name member
6919AC_DEFUN([CF_UTMP_UT_NAME],
6920[
6921if test "$cf_cv_have_utmp" != no ; then
6922AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_name is declared,cf_cv_have_utmp_ut_name,[
6923	cf_cv_have_utmp_ut_name=no
6924cf_utmp_includes="
6925#include <sys/types.h>
6926#include <${cf_cv_have_utmp}.h>
6927#define getutent getutxent
6928#ifdef USE_LASTLOG
6929#include <lastlog.h>		/* may conflict with utmpx.h on Linux */
6930#endif
6931"
6932for cf_header in ut_name ut_user ; do
6933	AC_TRY_COMPILE([$cf_utmp_includes],
6934	[struct $cf_cv_have_utmp x;
6935	 char *name = x.$cf_header;
6936	 (void)x;
6937	 (void)name;
6938	],
6939	[cf_cv_have_utmp_ut_name=$cf_header
6940	 break])
6941done
6942])
6943
6944case "$cf_cv_have_utmp_ut_name" in
6945(no)
6946	AC_MSG_ERROR(Cannot find declaration for ut.ut_name)
6947	;;
6948(ut_user)
6949	AC_DEFINE(ut_name,ut_user,[Define to rename UTMP/UTMPX struct ut_name member])
6950	;;
6951esac
6952fi
6953])dnl
6954dnl ---------------------------------------------------------------------------
6955dnl CF_UTMP_UT_SESSION version: 9 updated: 2021/06/07 17:39:17
6956dnl ------------------
6957dnl Check if UTMP/UTMPX struct defines ut_session member
6958AC_DEFUN([CF_UTMP_UT_SESSION],
6959[
6960if test "$cf_cv_have_utmp" != no ; then
6961AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_session is declared, cf_cv_have_utmp_ut_session,[
6962	AC_TRY_COMPILE([
6963#include <sys/types.h>
6964#include <${cf_cv_have_utmp}.h>],
6965	[static struct $cf_cv_have_utmp x;
6966	 long y = x.ut_session;
6967	 (void)x;
6968	 (void)y],
6969	[cf_cv_have_utmp_ut_session=yes],
6970	[cf_cv_have_utmp_ut_session=no])
6971])
6972if test "$cf_cv_have_utmp_ut_session" != no ; then
6973	AC_DEFINE(HAVE_UTMP_UT_SESSION,1,[Define to 1 if UTMP/UTMPX struct defines ut_session member])
6974fi
6975fi
6976])dnl
6977dnl ---------------------------------------------------------------------------
6978dnl CF_UTMP_UT_SYSLEN version: 4 updated: 2021/01/02 09:31:20
6979dnl -----------------
6980dnl Check if UTMP/UTMPX struct defines ut_syslen member
6981AC_DEFUN([CF_UTMP_UT_SYSLEN],
6982[
6983if test "$cf_cv_have_utmp" != no ; then
6984AC_MSG_CHECKING(if ${cf_cv_have_utmp}.ut_syslen is declared)
6985AC_CACHE_VAL(cf_cv_have_utmp_ut_syslen,[
6986	AC_TRY_COMPILE([
6987#include <sys/types.h>
6988#include <${cf_cv_have_utmp}.h>],
6989	[struct $cf_cv_have_utmp x;
6990	 int y = x.ut_syslen;
6991	 (void)x;
6992	 (void)y],
6993	[cf_cv_have_utmp_ut_syslen=yes],
6994	[cf_cv_have_utmp_ut_syslen=no])
6995	])
6996AC_MSG_RESULT($cf_cv_have_utmp_ut_syslen)
6997test "$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])
6998fi
6999])dnl
7000dnl ---------------------------------------------------------------------------
7001dnl CF_UTMP_UT_XSTATUS version: 6 updated: 2021/01/02 09:31:20
7002dnl ------------------
7003dnl Check for known variants on the UTMP/UTMPX struct's exit-status as reported
7004dnl by various people:
7005dnl
7006dnl	ut_exit.__e_exit (HPUX 11 - David Ellement, also in glibc2)
7007dnl	ut_exit.e_exit (SVR4)
7008dnl	ut_exit.ut_e_exit (os390 - Greg Smith)
7009dnl	ut_exit.ut_exit (Tru64 4.0f - Jeremie Petit, 4.0e - Tomas Vanhala)
7010dnl
7011dnl Note: utmp_xstatus is not a conventional compatibility definition in the
7012dnl system header files.
7013AC_DEFUN([CF_UTMP_UT_XSTATUS],
7014[
7015if test "$cf_cv_have_utmp" != no ; then
7016AC_CACHE_CHECK(for exit-status in $cf_cv_have_utmp,cf_cv_have_utmp_ut_xstatus,[
7017for cf_result in \
7018	ut_exit.__e_exit \
7019	ut_exit.e_exit \
7020	ut_exit.ut_e_exit \
7021	ut_exit.ut_exit
7022do
7023AC_TRY_COMPILE([
7024#include <sys/types.h>
7025#include <${cf_cv_have_utmp}.h>],
7026	[struct $cf_cv_have_utmp x;
7027	 long y = x.$cf_result = 0;
7028	 (void)x;
7029	 (void)y],
7030	[cf_cv_have_utmp_ut_xstatus=$cf_result
7031	 break],
7032	[cf_cv_have_utmp_ut_xstatus=no])
7033done
7034])
7035if test "$cf_cv_have_utmp_ut_xstatus" != no ; then
7036	AC_DEFINE(HAVE_UTMP_UT_XSTATUS,1,[Define to 1 if UTMP/UTMPX has exit-status member])
7037	AC_DEFINE_UNQUOTED(ut_xstatus,$cf_cv_have_utmp_ut_xstatus,[Define if needed to rename member ut_xstatus of UTMP/UTMPX])
7038fi
7039fi
7040])dnl
7041dnl ---------------------------------------------------------------------------
7042dnl CF_UTMP_UT_XTIME version: 11 updated: 2021/01/02 09:31:20
7043dnl ----------------
7044dnl Check if UTMP/UTMPX struct defines ut_xtime member
7045AC_DEFUN([CF_UTMP_UT_XTIME],
7046[
7047if test "$cf_cv_have_utmp" != no ; then
7048AC_CACHE_CHECK(if ${cf_cv_have_utmp}.ut_xtime is declared, cf_cv_have_utmp_ut_xtime,[
7049	AC_TRY_COMPILE([
7050#include <sys/types.h>
7051#include <${cf_cv_have_utmp}.h>],
7052	[struct $cf_cv_have_utmp x;
7053	 long y = x.ut_xtime = 0;
7054	 (void)x;
7055	 (void)y],
7056	[cf_cv_have_utmp_ut_xtime=yes],
7057	[AC_TRY_COMPILE([
7058#include <sys/types.h>
7059#include <${cf_cv_have_utmp}.h>],
7060	[struct $cf_cv_have_utmp x;
7061	 long y = x.ut_tv.tv_sec;
7062	 (void)x;
7063	 (void)y],
7064	[cf_cv_have_utmp_ut_xtime=define],
7065	[cf_cv_have_utmp_ut_xtime=no])
7066	])
7067])
7068if test "$cf_cv_have_utmp_ut_xtime" != no ; then
7069	AC_DEFINE(HAVE_UTMP_UT_XTIME,1,[Define to 1 if UTMP/UTMPX struct defines ut_xtime member])
7070	if test "$cf_cv_have_utmp_ut_xtime" = define ; then
7071		AC_DEFINE(ut_xtime,ut_tv.tv_sec,[Define if needed to alternate name for utmpx.ut_xtime member])
7072	fi
7073fi
7074fi
7075])dnl
7076dnl ---------------------------------------------------------------------------
7077dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
7078dnl ----------
7079dnl Use AC_VERBOSE w/o the warnings
7080AC_DEFUN([CF_VERBOSE],
7081[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
7082CF_MSG_LOG([$1])
7083])dnl
7084dnl ---------------------------------------------------------------------------
7085dnl CF_WAIT_HEADERS version: 3 updated: 2021/01/02 09:31:20
7086dnl ---------------
7087dnl Build up an expression $cf_wait_headers with the header files needed to
7088dnl compile against the prototypes for 'wait()', 'waitpid()', etc.  Assume it's
7089dnl Posix, which uses <sys/types.h> and <sys/wait.h>, but allow SVr4 variation
7090dnl with <wait.h>.
7091AC_DEFUN([CF_WAIT_HEADERS],
7092[
7093AC_HAVE_HEADERS(sys/wait.h)
7094cf_wait_headers="#include <sys/types.h>
7095"
7096if test "$ac_cv_header_sys_wait_h" = yes; then
7097cf_wait_headers="$cf_wait_headers
7098#include <sys/wait.h>
7099"
7100else
7101AC_HAVE_HEADERS(wait.h)
7102AC_HAVE_HEADERS(waitstatus.h)
7103if test "$ac_cv_header_wait_h" = yes; then
7104cf_wait_headers="$cf_wait_headers
7105#include <wait.h>
7106"
7107fi
7108if test "$ac_cv_header_waitstatus_h" = yes; then
7109cf_wait_headers="$cf_wait_headers
7110#include <waitstatus.h>
7111"
7112fi
7113fi
7114])dnl
7115dnl ---------------------------------------------------------------------------
7116dnl CF_WIDEC_CURSES version: 6 updated: 2020/03/19 20:23:48
7117dnl ---------------
7118dnl Check for curses implementations that can handle wide-characters
7119AC_DEFUN([CF_WIDEC_CURSES],
7120[
7121AC_CACHE_CHECK(if curses supports wide characters,cf_cv_widec_curses,[
7122AC_TRY_LINK([
7123#include <stdlib.h>
7124#include <${cf_cv_ncurses_header:-curses.h}>],[
7125    wchar_t temp[2];
7126    wchar_t wch = 'A';
7127    temp[0] = wch;
7128    waddnwstr(stdscr, temp, 1);
7129],
7130[cf_cv_widec_curses=yes],
7131[cf_cv_widec_curses=no])
7132])
7133
7134if test "$cf_cv_widec_curses" = yes ; then
7135	AC_DEFINE(WIDEC_CURSES,1,[Define to 1 if curses supports wide characters])
7136
7137	# This is needed on Tru64 5.0 to declare mbstate_t
7138	AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_widec_mbstate,[
7139	AC_TRY_COMPILE([
7140#include <stdlib.h>
7141#include <${cf_cv_ncurses_header:-curses.h}>],
7142[mbstate_t state; (void)state],
7143[cf_cv_widec_mbstate=no],
7144[AC_TRY_COMPILE([
7145#include <stdlib.h>
7146#include <wchar.h>
7147#include <${cf_cv_ncurses_header:-curses.h}>],
7148[mbstate_t state; (void)state],
7149[cf_cv_widec_mbstate=yes],
7150[cf_cv_widec_mbstate=unknown])])])
7151
7152if test "$cf_cv_widec_mbstate" = yes ; then
7153	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
7154fi
7155
7156if test "$cf_cv_widec_mbstate" != unknown ; then
7157	AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if we have mbstate_t type])
7158fi
7159
7160fi
7161])dnl
7162dnl ---------------------------------------------------------------------------
7163dnl CF_WITH_BZLIB version: 4 updated: 2007/07/29 13:19:54
7164dnl -------------
7165dnl Check for libbz2 aka "bzlib"
7166dnl
7167dnl $1 = optional path for headers/library
7168AC_DEFUN([CF_WITH_BZLIB],[
7169  CF_ADD_OPTIONAL_PATH($1)
7170
7171  CF_FIND_LINKAGE([
7172#include <stdio.h>
7173#include <bzlib.h>
7174],[
7175    BZ2_bzopen("name","mode")
7176],bz2,,,bzlib)
7177])dnl
7178dnl ---------------------------------------------------------------------------
7179dnl CF_WITH_CURSES_DIR version: 4 updated: 2021/01/02 19:22:58
7180dnl ------------------
7181dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
7182dnl libraries.
7183AC_DEFUN([CF_WITH_CURSES_DIR],[
7184
7185AC_MSG_CHECKING(for specific curses-directory)
7186AC_ARG_WITH(curses-dir,
7187	[  --with-curses-dir=DIR   directory in which (n)curses is installed],
7188	[cf_cv_curses_dir=$withval],
7189	[cf_cv_curses_dir=no])
7190AC_MSG_RESULT($cf_cv_curses_dir)
7191
7192if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
7193then
7194	CF_PATH_SYNTAX(withval)
7195	if test -d "$cf_cv_curses_dir"
7196	then
7197		CF_ADD_INCDIR($cf_cv_curses_dir/include)
7198		CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
7199	fi
7200fi
7201])dnl
7202dnl ---------------------------------------------------------------------------
7203dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
7204dnl ----------------
7205dnl Configure-option for dbmalloc.  The optional parameter is used to override
7206dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
7207AC_DEFUN([CF_WITH_DBMALLOC],[
7208CF_NO_LEAKS_OPTION(dbmalloc,
7209	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
7210	[USE_DBMALLOC])
7211
7212if test "$with_dbmalloc" = yes ; then
7213	AC_CHECK_HEADER(dbmalloc.h,
7214		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
7215fi
7216])dnl
7217dnl ---------------------------------------------------------------------------
7218dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
7219dnl ---------------
7220dnl Configure-option for dmalloc.  The optional parameter is used to override
7221dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
7222AC_DEFUN([CF_WITH_DMALLOC],[
7223CF_NO_LEAKS_OPTION(dmalloc,
7224	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
7225	[USE_DMALLOC])
7226
7227if test "$with_dmalloc" = yes ; then
7228	AC_CHECK_HEADER(dmalloc.h,
7229		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
7230fi
7231])dnl
7232dnl ---------------------------------------------------------------------------
7233dnl CF_WITH_IDNA version: 11 updated: 2021/07/05 09:09:42
7234dnl ------------
7235dnl Check for libidn2, use it if found.  Otherwise, check for libidn, use that.
7236dnl
7237dnl $1 = optional path for headers/library
7238AC_DEFUN([CF_WITH_IDNA],[
7239CF_ADD_OPTIONAL_PATH($1)
7240
7241CF_FIND_LINKAGE([
7242#include <stdio.h>
7243#include <idn2.h>
7244],[
7245	char *output = 0;
7246	int code = idn2_to_ascii_8z("name", &output, IDN2_USE_STD3_ASCII_RULES);
7247	(void) code;
7248],idn2,,[CF_VERBOSE([unsuccessful, will try idn (older)])],,[$LIBICONV])
7249
7250if test "x$cf_cv_find_linkage_idn2" = xyes ; then
7251	CF_VERBOSE(found idn2 library)
7252	AC_DEFINE(USE_IDN2,1,[Define to 1 if we should use IDN2 library])
7253else
7254	CF_FIND_LINKAGE([
7255#include <stdio.h>
7256#include <idna.h>
7257],[
7258	char *output = 0;
7259	int code = idna_to_ascii_8z("name", &output, IDNA_USE_STD3_ASCII_RULES);
7260	(void) code;
7261],idn,,,,[$LIBICONV])
7262
7263if test "x$cf_cv_find_linkage_idn" = xyes ; then
7264	CF_VERBOSE(found idn library)
7265	AC_DEFINE(USE_IDNA,1,[Define to 1 if we should use IDNA library])
7266fi
7267fi
7268])dnl
7269dnl ---------------------------------------------------------------------------
7270dnl CF_WITH_PATH version: 11 updated: 2012/09/29 15:04:19
7271dnl ------------
7272dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
7273dnl defaulting to yes/no.
7274dnl
7275dnl $1 = option name
7276dnl $2 = help-text
7277dnl $3 = environment variable to set
7278dnl $4 = default value, shown in the help-message, must be a constant
7279dnl $5 = default value, if it's an expression & cannot be in the help-message
7280dnl
7281AC_DEFUN([CF_WITH_PATH],
7282[AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
7283ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
7284if ifelse([$5],,true,[test -n "$5"]) ; then
7285CF_PATH_SYNTAX(withval)
7286fi
7287eval $3="$withval"
7288AC_SUBST($3)dnl
7289])dnl
7290dnl ---------------------------------------------------------------------------
7291dnl CF_WITH_SCREEN_PDCURSES version: 1 updated: 2020/08/28 16:56:27
7292dnl -----------------------
7293dnl Call this macro before CF_ENABLE_WARNINGS for configure scripts which use
7294dnl the "--with-screen=pdcurses" selection.  Doing that allows the configure
7295dnl script to search for the X11/Xt header files to declare (or not) the
7296dnl symbol needed to enable "const" in those header files.  If that configure
7297dnl option is not used, then those checks are unnecessary.
7298AC_DEFUN([CF_WITH_SCREEN_PDCURSES],[
7299AC_PROVIDE([AC_PATH_XTRA])
7300AC_PROVIDE([AC_PATH_X])
7301if test -n "$with_screen" && test "x$with_screen" = "xpdcurses"
7302then
7303	AC_PATH_X
7304	AC_PATH_XTRA
7305fi
7306])dnl
7307dnl ---------------------------------------------------------------------------
7308dnl CF_WITH_ZLIB version: 4 updated: 2011/05/28 12:10:58
7309dnl ------------
7310dnl check for libz aka "zlib"
7311AC_DEFUN([CF_WITH_ZLIB],[
7312  CF_ADD_OPTIONAL_PATH($1)
7313
7314  CF_FIND_LINKAGE([
7315#include <zlib.h>
7316],[
7317	gzopen("name","mode")
7318],z,,,zlib)
7319
7320AC_CHECK_FUNCS( \
7321	zError \
7322)
7323])dnl
7324dnl ---------------------------------------------------------------------------
7325dnl CF_XOPEN_CURSES version: 17 updated: 2021/07/10 12:22:27
7326dnl ---------------
7327dnl Test if we should define X/Open source for curses, needed on Digital Unix
7328dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
7329dnl
7330dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
7331dnl as getbegy().  The latter is better design, but the former is standard.
7332AC_DEFUN([CF_XOPEN_CURSES],
7333[
7334AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
7335AC_CACHE_CHECK(definition to turn on extended curses functions,cf_cv_need_xopen_extension,[
7336cf_cv_need_xopen_extension=unknown
7337AC_TRY_LINK([
7338#include <stdlib.h>
7339#include <${cf_cv_ncurses_header:-curses.h}>],[
7340#if defined(NCURSES_VERSION_PATCH)
7341#if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
7342	make an error
7343#endif
7344#endif
7345#ifdef NCURSES_WIDECHAR
7346make an error	/* prefer to fall-through on the second checks */
7347#endif
7348	cchar_t check;
7349	int check2 = curs_set((int)sizeof(check));
7350	long x = winnstr(stdscr, "", 0);
7351	int x1, y1;
7352	(void)check2;
7353	getbegyx(stdscr, y1, x1);
7354	(void)x;
7355	(void)y1;
7356	(void)x1;
7357	],
7358	[cf_cv_need_xopen_extension=none],
7359	[
7360	for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
7361	do
7362		AC_TRY_LINK([
7363#define $cf_try_xopen_extension 1
7364#include <stdlib.h>
7365#include <${cf_cv_ncurses_header:-curses.h}>],[
7366		cchar_t check;
7367		int check2 = curs_set((int)sizeof(check));
7368		long x = winnstr(stdscr, "", 0);
7369		int x1, y1;
7370		getbegyx(stdscr, y1, x1);
7371		(void)check2;
7372		(void)x;
7373		(void)y1;
7374		(void)x1;
7375		],
7376		[cf_cv_need_xopen_extension=$cf_try_xopen_extension; break])
7377	done
7378	])
7379])
7380
7381case "$cf_cv_need_xopen_extension" in
7382(*_*)
7383	CF_APPEND_TEXT(CPPFLAGS,-D$cf_cv_need_xopen_extension)
7384	;;
7385esac
7386
7387])dnl
7388dnl ---------------------------------------------------------------------------
7389dnl CF_XOPEN_SOURCE version: 58 updated: 2021/05/01 17:49:36
7390dnl ---------------
7391dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
7392dnl or adapt to the vendor's definitions to get equivalent functionality,
7393dnl without losing the common non-POSIX features.
7394dnl
7395dnl Parameters:
7396dnl	$1 is the nominal value for _XOPEN_SOURCE
7397dnl	$2 is the nominal value for _POSIX_C_SOURCE
7398AC_DEFUN([CF_XOPEN_SOURCE],[
7399AC_REQUIRE([AC_CANONICAL_HOST])
7400AC_REQUIRE([CF_POSIX_VISIBLE])
7401
7402if test "$cf_cv_posix_visible" = no; then
7403
7404cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
7405cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
7406cf_xopen_source=
7407
7408case "$host_os" in
7409(aix[[4-7]]*)
7410	cf_xopen_source="-D_ALL_SOURCE"
7411	;;
7412(msys)
7413	cf_XOPEN_SOURCE=600
7414	;;
7415(darwin[[0-8]].*)
7416	cf_xopen_source="-D_APPLE_C_SOURCE"
7417	;;
7418(darwin*)
7419	cf_xopen_source="-D_DARWIN_C_SOURCE"
7420	cf_XOPEN_SOURCE=
7421	;;
7422(freebsd*|dragonfly*|midnightbsd*)
7423	# 5.x headers associate
7424	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
7425	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
7426	cf_POSIX_C_SOURCE=200112L
7427	cf_XOPEN_SOURCE=600
7428	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
7429	;;
7430(hpux11*)
7431	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
7432	;;
7433(hpux*)
7434	cf_xopen_source="-D_HPUX_SOURCE"
7435	;;
7436(irix[[56]].*)
7437	cf_xopen_source="-D_SGI_SOURCE"
7438	cf_XOPEN_SOURCE=
7439	;;
7440(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
7441	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
7442	;;
7443(minix*)
7444	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
7445	;;
7446(mirbsd*)
7447	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
7448	cf_XOPEN_SOURCE=
7449	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
7450	;;
7451(netbsd*)
7452	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
7453	;;
7454(openbsd[[6-9]]*)
7455	# OpenBSD 6.x has broken locale support, both compile-time and runtime.
7456	# see https://www.mail-archive.com/bugs@openbsd.org/msg13200.html
7457	# Abusing the conformance level is a workaround.
7458	AC_MSG_WARN(this system does not provide usable locale support)
7459	cf_xopen_source="-D_BSD_SOURCE"
7460	cf_XOPEN_SOURCE=700
7461	;;
7462(openbsd[[4-5]]*)
7463	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
7464	cf_xopen_source="-D_BSD_SOURCE"
7465	cf_XOPEN_SOURCE=600
7466	;;
7467(openbsd*)
7468	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
7469	;;
7470(osf[[45]]*)
7471	cf_xopen_source="-D_OSF_SOURCE"
7472	;;
7473(nto-qnx*)
7474	cf_xopen_source="-D_QNX_SOURCE"
7475	;;
7476(sco*)
7477	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
7478	;;
7479(solaris2.*)
7480	cf_xopen_source="-D__EXTENSIONS__"
7481	cf_cv_xopen_source=broken
7482	;;
7483(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
7484	cf_XOPEN_SOURCE=
7485	cf_POSIX_C_SOURCE=
7486	;;
7487(*)
7488	CF_TRY_XOPEN_SOURCE
7489	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
7490	;;
7491esac
7492
7493if test -n "$cf_xopen_source" ; then
7494	CF_ADD_CFLAGS($cf_xopen_source,true)
7495fi
7496
7497dnl In anything but the default case, we may have system-specific setting
7498dnl which is still not guaranteed to provide all of the entrypoints that
7499dnl _XOPEN_SOURCE would yield.
7500if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
7501	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
7502	AC_TRY_COMPILE([#include <stdlib.h>],[
7503#ifndef _XOPEN_SOURCE
7504make an error
7505#endif],
7506	[cf_XOPEN_SOURCE_set=yes],
7507	[cf_XOPEN_SOURCE_set=no])
7508	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
7509	if test "$cf_XOPEN_SOURCE_set" = yes
7510	then
7511		AC_TRY_COMPILE([#include <stdlib.h>],[
7512#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
7513make an error
7514#endif],
7515		[cf_XOPEN_SOURCE_set_ok=yes],
7516		[cf_XOPEN_SOURCE_set_ok=no])
7517		if test "$cf_XOPEN_SOURCE_set_ok" = no
7518		then
7519			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
7520		fi
7521	else
7522		CF_TRY_XOPEN_SOURCE
7523	fi
7524fi
7525fi # cf_cv_posix_visible
7526])
7527dnl ---------------------------------------------------------------------------
7528dnl CF_X_ATHENA version: 24 updated: 2020/03/10 18:53:47
7529dnl -----------
7530dnl Check for Xaw (Athena) libraries
7531dnl
7532dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
7533AC_DEFUN([CF_X_ATHENA],
7534[
7535cf_x_athena=${cf_x_athena:-Xaw}
7536
7537AC_MSG_CHECKING(if you want to link with Xaw 3d library)
7538withval=
7539AC_ARG_WITH(Xaw3d,
7540	[  --with-Xaw3d            link with Xaw 3d library])
7541if test "$withval" = yes ; then
7542	cf_x_athena=Xaw3d
7543	AC_MSG_RESULT(yes)
7544else
7545	AC_MSG_RESULT(no)
7546fi
7547
7548AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
7549withval=
7550AC_ARG_WITH(Xaw3dxft,
7551	[  --with-Xaw3dxft         link with Xaw 3d xft library])
7552if test "$withval" = yes ; then
7553	cf_x_athena=Xaw3dxft
7554	AC_MSG_RESULT(yes)
7555else
7556	AC_MSG_RESULT(no)
7557fi
7558
7559AC_MSG_CHECKING(if you want to link with neXT Athena library)
7560withval=
7561AC_ARG_WITH(neXtaw,
7562	[  --with-neXtaw           link with neXT Athena library])
7563if test "$withval" = yes ; then
7564	cf_x_athena=neXtaw
7565	AC_MSG_RESULT(yes)
7566else
7567	AC_MSG_RESULT(no)
7568fi
7569
7570AC_MSG_CHECKING(if you want to link with Athena-Plus library)
7571withval=
7572AC_ARG_WITH(XawPlus,
7573	[  --with-XawPlus          link with Athena-Plus library])
7574if test "$withval" = yes ; then
7575	cf_x_athena=XawPlus
7576	AC_MSG_RESULT(yes)
7577else
7578	AC_MSG_RESULT(no)
7579fi
7580
7581cf_x_athena_lib=""
7582
7583if test "$PKG_CONFIG" != none ; then
7584	cf_athena_list=
7585	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
7586	for cf_athena_pkg in \
7587		$cf_athena_list \
7588		${cf_x_athena} \
7589		${cf_x_athena}-devel \
7590		lib${cf_x_athena} \
7591		lib${cf_x_athena}-devel
7592	do
7593		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
7594			cf_x_athena_lib="$cf_pkgconfig_libs"
7595			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
7596			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
7597
7598			CF_TRIM_X_LIBS
7599
7600AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
7601AC_TRY_LINK([
7602#include <X11/Xmu/CharSet.h>
7603],[
7604int check = XmuCompareISOLatin1("big", "small");
7605(void)check;
7606],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
7607
7608			if test "$cf_cv_xaw_compat" = no
7609			then
7610				# workaround for broken ".pc" files...
7611				case "$cf_x_athena_lib" in
7612				(*-lXmu*)
7613					;;
7614				(*)
7615					CF_VERBOSE(work around broken package)
7616					cf_save_xmu="$LIBS"
7617					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
7618					CF_TRY_PKG_CONFIG(xmu,[
7619							LIBS="$cf_save_xmu"
7620							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
7621						],[
7622							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
7623						])
7624					CF_TRIM_X_LIBS
7625					;;
7626				esac
7627			fi
7628
7629			break])
7630	done
7631fi
7632
7633if test -z "$cf_x_athena_lib" ; then
7634	CF_X_EXT
7635	CF_X_TOOLKIT
7636	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
7637	CF_X_ATHENA_LIBS($cf_x_athena)
7638fi
7639])dnl
7640dnl ---------------------------------------------------------------------------
7641dnl CF_X_ATHENA_CPPFLAGS version: 9 updated: 2020/12/31 10:54:15
7642dnl --------------------
7643dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
7644dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
7645AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
7646[
7647AC_REQUIRE([AC_PATH_XTRA])
7648cf_x_athena_root=ifelse([$1],,Xaw,[$1])
7649cf_x_athena_inc=""
7650
7651for cf_path in default \
7652	/usr/contrib/X11R6 \
7653	/usr/contrib/X11R5 \
7654	/usr/lib/X11R5 \
7655	/usr/local
7656do
7657	if test -z "$cf_x_athena_inc" ; then
7658		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
7659		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
7660		if test "$cf_path" != default ; then
7661			CF_APPEND_TEXT(CPPFLAGS,-I$cf_path/include)
7662			AC_MSG_CHECKING(for $cf_test in $cf_path)
7663		else
7664			AC_MSG_CHECKING(for $cf_test)
7665		fi
7666		AC_TRY_COMPILE([
7667#include <X11/Intrinsic.h>
7668#include <$cf_test>],[],
7669			[cf_result=yes],
7670			[cf_result=no])
7671		AC_MSG_RESULT($cf_result)
7672		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
7673		if test "$cf_result" = yes ; then
7674			test "$cf_path"  = default && cf_x_athena_inc=default
7675			test "$cf_path" != default && cf_x_athena_inc="$cf_path/include"
7676			break
7677		fi
7678	fi
7679done
7680
7681if test -z "$cf_x_athena_inc" ; then
7682	AC_MSG_WARN([Unable to find Athena header files])
7683elif test "$cf_x_athena_inc" != default ; then
7684	CF_APPEND_TEXT(CPPFLAGS,-I$cf_x_athena_inc)
7685fi
7686])
7687dnl ---------------------------------------------------------------------------
7688dnl CF_X_ATHENA_LIBS version: 13 updated: 2020/01/11 18:16:10
7689dnl ----------------
7690dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
7691dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
7692AC_DEFUN([CF_X_ATHENA_LIBS],
7693[AC_REQUIRE([CF_X_TOOLKIT])
7694cf_x_athena_root=ifelse([$1],,Xaw,[$1])
7695cf_x_athena_lib=""
7696
7697for cf_path in default \
7698	/usr/contrib/X11R6 \
7699	/usr/contrib/X11R5 \
7700	/usr/lib/X11R5 \
7701	/usr/local
7702do
7703	for cf_lib in \
7704		${cf_x_athena_root} \
7705		${cf_x_athena_root}7 \
7706		${cf_x_athena_root}6
7707	do
7708	for cf_libs in \
7709		"-l$cf_lib -lXmu" \
7710		"-l$cf_lib -lXpm -lXmu" \
7711		"-l${cf_lib}_s -lXmu_s"
7712	do
7713		test -n "$cf_x_athena_lib" && break
7714
7715		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
7716		cf_test=XawSimpleMenuAddGlobalActions
7717		test "$cf_path" != default && cf_libs="-L$cf_path/lib $cf_libs"
7718		CF_ADD_LIBS($cf_libs)
7719		AC_MSG_CHECKING(for $cf_test in $cf_libs)
7720		AC_TRY_LINK([
7721#include <X11/Intrinsic.h>
7722#include <X11/$cf_x_athena_root/SimpleMenu.h>
7723],[
7724$cf_test((XtAppContext) 0)],
7725			[cf_result=yes],
7726			[cf_result=no])
7727		AC_MSG_RESULT($cf_result)
7728		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
7729
7730		if test "$cf_result" = yes ; then
7731			cf_x_athena_lib="$cf_libs"
7732			break
7733		fi
7734	done # cf_libs
7735		test -n "$cf_x_athena_lib" && break
7736	done # cf_lib
7737done
7738
7739if test -z "$cf_x_athena_lib" ; then
7740	AC_MSG_ERROR(
7741[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
7742fi
7743
7744CF_ADD_LIBS($cf_x_athena_lib)
7745CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
7746AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
7747])
7748dnl ---------------------------------------------------------------------------
7749dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
7750dnl --------
7751AC_DEFUN([CF_X_EXT],[
7752CF_TRY_PKG_CONFIG(Xext,,[
7753	AC_CHECK_LIB(Xext,XextCreateExtension,
7754		[CF_ADD_LIB(Xext)])])
7755])dnl
7756dnl ---------------------------------------------------------------------------
7757dnl CF_X_TOOLKIT version: 26 updated: 2021/01/02 09:31:20
7758dnl ------------
7759dnl Check for X Toolkit libraries
7760AC_DEFUN([CF_X_TOOLKIT],
7761[
7762AC_REQUIRE([AC_PATH_XTRA])
7763AC_REQUIRE([CF_CHECK_CACHE])
7764
7765# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new) (and
7766# in some cases has installed dummy files in the former, other cases replaced
7767# it with a link to the new location).  This complicates the configure script.
7768# Check for that pitfall, and recover using pkg-config
7769#
7770# If none of these are set, the configuration is almost certainly broken.
7771if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
7772then
7773	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
7774	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
7775	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
7776	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
7777else
7778	LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
7779fi
7780
7781cf_have_X_LIBS=no
7782
7783CF_TRY_PKG_CONFIG(xt,[
7784
7785	case "x$LIBS" in
7786	(*-lX11*)
7787		;;
7788	(*)
7789# we have an "xt" package, but it may omit Xt's dependency on X11
7790AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
7791AC_TRY_LINK([
7792#include <X11/Xlib.h>
7793],[
7794	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
7795	int rc2 = XClearWindow((Display*) 0, (Window) 0);
7796	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
7797	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
7798],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
7799		if test "$cf_cv_xt_x11_compat" = no
7800		then
7801			CF_VERBOSE(work around broken X11 dependency)
7802			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
7803			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
7804		fi
7805		;;
7806	esac
7807
7808AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
7809AC_TRY_LINK([
7810#include <X11/Shell.h>
7811],[int num = IceConnectionNumber(0); (void) num
7812],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
7813
7814	if test "$cf_cv_xt_ice_compat" = no
7815	then
7816		# workaround for broken ".pc" files used for X Toolkit.
7817		case "x$X_PRE_LIBS" in
7818		(*-lICE*)
7819			case "x$LIBS" in
7820			(*-lICE*)
7821				;;
7822			(*)
7823				CF_VERBOSE(work around broken ICE dependency)
7824				CF_TRY_PKG_CONFIG(ice,
7825					[CF_TRY_PKG_CONFIG(sm)],
7826					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
7827				;;
7828			esac
7829			;;
7830		esac
7831	fi
7832
7833	cf_have_X_LIBS=yes
7834],[
7835
7836	LDFLAGS="$X_LIBS $LDFLAGS"
7837	CF_CHECK_CFLAGS($X_CFLAGS)
7838
7839	AC_CHECK_FUNC(XOpenDisplay,,[
7840	AC_CHECK_LIB(X11,XOpenDisplay,
7841		[CF_ADD_LIB(X11)])])
7842
7843	AC_CHECK_FUNC(XtAppInitialize,,[
7844	AC_CHECK_LIB(Xt, XtAppInitialize,
7845		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
7846		 cf_have_X_LIBS=Xt
7847		 LIBS="-lXt $LIBS"])])
7848])
7849
7850if test "$cf_have_X_LIBS" = no ; then
7851	AC_MSG_WARN(
7852[Unable to successfully link X Toolkit library (-lXt) with
7853test program.  You will have to check and add the proper libraries by hand
7854to makefile.])
7855fi
7856])dnl
7857dnl ---------------------------------------------------------------------------
7858dnl CF__CHECK_RUN version: 1 updated: 2018/02/21 21:26:03
7859dnl -------------
7860dnl Check if a simple program can be made to run with the existing libraries.
7861define([CF__CHECK_RUN],[
7862AC_TRY_RUN([#include <stdio.h>
7863int main(void) {
7864	fflush(stderr);
7865	${cf_cv_main_return:-return}(0);
7866}],
7867	$1=yes,
7868	$1=no,
7869	$1=unknown)
7870])
7871dnl ---------------------------------------------------------------------------
7872dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
7873dnl ---------------
7874dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
7875dnl are both available.
7876define([CF__CURSES_HEAD],[
7877#ifdef HAVE_XCURSES
7878#include <xcurses.h>
7879char * XCursesProgramName = "test";
7880#else
7881#include <${cf_cv_ncurses_header:-curses.h}>
7882#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
7883#include <ncursesw/term.h>
7884#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
7885#include <ncurses/term.h>
7886#elif defined(HAVE_TERM_H)
7887#include <term.h>
7888#endif
7889#endif
7890])
7891dnl ---------------------------------------------------------------------------
7892dnl CF__ICONV_BODY version: 2 updated: 2007/07/26 17:35:47
7893dnl --------------
7894dnl Test-code needed for iconv compile-checks
7895define([CF__ICONV_BODY],[
7896	iconv_t cd = iconv_open("","");
7897	iconv(cd,NULL,NULL,NULL,NULL);
7898	iconv_close(cd);]
7899)dnl
7900dnl ---------------------------------------------------------------------------
7901dnl CF__ICONV_HEAD version: 1 updated: 2007/07/26 15:57:03
7902dnl --------------
7903dnl Header-files needed for iconv compile-checks
7904define([CF__ICONV_HEAD],[
7905#include <stdlib.h>
7906#include <iconv.h>]
7907)dnl
7908dnl ---------------------------------------------------------------------------
7909dnl CF__INET_HEAD version: 1 updated: 2013/10/08 17:47:05
7910dnl -------------
7911dnl Header-files needed for inet.h compile-checks
7912define([CF__INET_HEAD],[
7913#if defined(__MINGW32__)
7914
7915#undef WIN32_LEAN_AND_MEAN
7916#define WIN32_LEAN_AND_MEAN
7917#include <windows.h>
7918
7919#ifdef HAVE_WINSOCK2_H
7920#include <winsock2.h>
7921#else
7922#ifdef HAVE_WINSOCK_H
7923#include <winsock.h>
7924#endif
7925#endif
7926
7927#else
7928
7929#include <sys/types.h>
7930#include <sys/socket.h>
7931#include <netinet/in.h>
7932#include <arpa/inet.h>
7933
7934#endif
7935])dnl
7936dnl ---------------------------------------------------------------------------
7937dnl CF__INTL_BODY version: 4 updated: 2021/05/19 19:35:25
7938dnl -------------
7939dnl Test-code needed for libintl compile-checks
7940dnl $1 = parameter 2 from AM_WITH_NLS
7941define([CF__INTL_BODY],[
7942	bindtextdomain ("", "");
7943	return (gettext ("") != 0)
7944			ifelse([$1], need-ngettext, [ + (ngettext ("", "", 0) != 0)], [])
7945#ifndef IGNORE_MSGFMT_HACK
7946			[ + _nl_msg_cat_cntr]
7947#endif
7948])
7949dnl ---------------------------------------------------------------------------
7950dnl CF__INTL_HEAD version: 1 updated: 2007/07/26 17:35:47
7951dnl -------------
7952dnl Header-files needed for libintl compile-checks
7953define([CF__INTL_HEAD],[
7954#include <libintl.h>
7955extern int _nl_msg_cat_cntr;
7956])dnl
7957dnl ---------------------------------------------------------------------------
7958dnl CF__SED_TRIMBLANKS version: 1 updated: 2021/01/02 09:31:20
7959dnl ------------------
7960dnl Trim something using sed, then trim extra whitespace
7961dnl $1 = extra parameters, e.g., in CF_STRIP_G_OPT
7962define([CF__SED_TRIMBLANKS],[sed ifelse($1,,,[$1] )-e 's%[[	]]% %g' -e 's% [[ ]]*% %g' -e 's%^ %%' -e 's% [$]%%'])dnl
7963dnl ---------------------------------------------------------------------------
7964dnl CF__SSL_BODY version: 2 updated: 2008/04/13 10:56:06
7965dnl ------------
7966dnl Body for test-compile of SSL code.
7967define([CF__SSL_BODY],[
7968#ifdef USE_GNUTLS_FUNCS
7969    gnutls_global_init();
7970#else
7971    SSL_shutdown((SSL *)0)
7972#endif
7973])dnl
7974dnl ---------------------------------------------------------------------------
7975dnl CF__SSL_HEAD version: 2 updated: 2008/04/13 10:56:06
7976dnl ------------
7977dnl Headers for test-compile of SSL code.
7978define([CF__SSL_HEAD],[
7979#include <stdio.h>
7980#if defined(USE_OPENSSL_INCL)
7981#include <openssl/ssl.h>
7982#elif defined(USE_GNUTLS_FUNCS)
7983#include <gnutls/gnutls.h>
7984#elif defined(USE_GNUTLS_INCL)
7985#include <gnutls/openssl.h>
7986#else
7987#include <ssl.h>
7988#endif
7989])dnl
7990dnl ---------------------------------------------------------------------------
7991dnl jm_GLIBC21 version: 4 updated: 2015/05/10 19:52:14
7992dnl ----------
7993dnl Inserted as requested by gettext 0.10.40
7994dnl File from /usr/share/aclocal
7995dnl glibc21.m4
7996dnl ====================
7997dnl serial 2
7998dnl
7999dnl Test for the GNU C Library, version 2.1 or newer.
8000dnl From Bruno Haible.
8001AC_DEFUN([jm_GLIBC21],
8002[
8003AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
8004	ac_cv_gnu_library_2_1,
8005	[AC_EGREP_CPP([Lucky GNU user],
8006	[
8007#include <features.h>
8008#ifdef __GNU_LIBRARY__
8009 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
8010  Lucky GNU user
8011 #endif
8012#endif
8013	],
8014	ac_cv_gnu_library_2_1=yes,
8015	ac_cv_gnu_library_2_1=no)])
8016	AC_SUBST(GLIBC21)
8017	GLIBC21="$ac_cv_gnu_library_2_1"
8018])
8019