1dnl macros used for DIALOG configure script
2dnl $Id: aclocal.m4,v 1.150 2021/01/11 09:03:36 tom Exp $
3dnl ---------------------------------------------------------------------------
4dnl Copyright 1999-2020,2021 -- Thomas E. Dickey
5dnl
6dnl Permission is hereby granted, free of charge, to any person obtaining a
7dnl copy of this software and associated documentation files (the
8dnl "Software"), to deal in the Software without restriction, including
9dnl without limitation the rights to use, copy, modify, merge, publish,
10dnl distribute, distribute with modifications, sublicense, and/or sell
11dnl copies of the Software, and to permit persons to whom the Software is
12dnl furnished to do so, subject to the following conditions:
13dnl 
14dnl The above copyright notice and this permission notice shall be included
15dnl in all copies or portions of the Software.
16dnl 
17dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24dnl 
25dnl Except as contained in this notice, the name(s) of the above copyright
26dnl holders shall not be used in advertising or otherwise to promote the
27dnl sale, use or other dealings in this Software without prior written
28dnl authorization.
29dnl
30dnl see
31dnl https://invisible-island.net/autoconf/ 
32dnl ---------------------------------------------------------------------------
33dnl ---------------------------------------------------------------------------
34dnl AM_GNU_GETTEXT version: 15 updated: 2021/01/02 09:31:20
35dnl --------------
36dnl Usage: Just like AM_WITH_NLS, which see.
37AC_DEFUN([AM_GNU_GETTEXT],
38  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
39   AC_REQUIRE([AC_CANONICAL_HOST])dnl
40   AC_REQUIRE([AC_PROG_RANLIB])dnl
41   AC_REQUIRE([AC_HEADER_STDC])dnl
42   AC_REQUIRE([AC_C_INLINE])dnl
43   AC_REQUIRE([AC_TYPE_OFF_T])dnl
44   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
45   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
46   AC_REQUIRE([AC_FUNC_MMAP])dnl
47   AC_REQUIRE([jm_GLIBC21])dnl
48   AC_REQUIRE([CF_PROG_CC])dnl
49
50   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
51stdlib.h string.h unistd.h sys/param.h])
52   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
53getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
54strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
55
56   AM_ICONV
57   AM_LANGINFO_CODESET
58   AM_LC_MESSAGES
59   AM_WITH_NLS([$1],[$2],[$3],[$4])
60
61   if test "x$CATOBJEXT" != "x"; then
62     if test "x$ALL_LINGUAS" = "x"; then
63       LINGUAS=
64     else
65       AC_MSG_CHECKING(for catalogs to be installed)
66       NEW_LINGUAS=
67       for presentlang in $ALL_LINGUAS; do
68         useit=no
69         for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
70           # Use the presentlang catalog if desiredlang is
71           #   a. equal to presentlang, or
72           #   b. a variant of presentlang (because in this case,
73           #      presentlang can be used as a fallback for messages
74           #      which are not translated in the desiredlang catalog).
75           case "$desiredlang" in
76             ("$presentlang"*) useit=yes;;
77           esac
78         done
79         if test "$useit" = yes; then
80           NEW_LINGUAS="$NEW_LINGUAS $presentlang"
81         fi
82       done
83       LINGUAS=$NEW_LINGUAS
84       AC_MSG_RESULT($LINGUAS)
85     fi
86
87     dnl Construct list of names of catalog files to be constructed.
88     if test -n "$LINGUAS"; then
89       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
90     fi
91   fi
92
93   dnl Enable libtool support if the surrounding package wishes it.
94   INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
95   AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
96])dnl
97dnl ---------------------------------------------------------------------------
98dnl AM_ICONV version: 12 updated: 2007/07/30 19:12:03
99dnl --------
100dnl Inserted as requested by gettext 0.10.40
101dnl File from /usr/share/aclocal
102dnl iconv.m4
103dnl ====================
104dnl serial AM2
105dnl
106dnl From Bruno Haible.
107dnl
108dnl ====================
109dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
110dnl range of locations searched.  Retain the same cache-variable naming to
111dnl allow reuse with the other gettext macros -Thomas E Dickey
112AC_DEFUN([AM_ICONV],
113[
114  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
115  dnl those with the standalone portable GNU libiconv installed).
116
117  AC_ARG_WITH([libiconv-prefix],
118[  --with-libiconv-prefix=DIR
119                          search for libiconv in DIR/include and DIR/lib], [
120    CF_ADD_OPTIONAL_PATH($withval, libiconv)
121   ])
122
123  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
124    CF_FIND_LINKAGE(CF__ICONV_HEAD,
125      CF__ICONV_BODY,
126      iconv,
127      am_cv_func_iconv=yes,
128      am_cv_func_iconv=["no, consider installing GNU libiconv"])])
129
130  if test "$am_cv_func_iconv" = yes; then
131    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
132
133    AC_CACHE_CHECK([if the declaration of iconv() needs const.],
134		   am_cv_proto_iconv_const,[
135      AC_TRY_COMPILE(CF__ICONV_HEAD [
136extern
137#ifdef __cplusplus
138"C"
139#endif
140#if defined(__STDC__) || defined(__cplusplus)
141size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
142#else
143size_t iconv();
144#endif
145],[], am_cv_proto_iconv_const=no,
146      am_cv_proto_iconv_const=yes)])
147
148    if test "$am_cv_proto_iconv_const" = yes ; then
149      am_cv_proto_iconv_arg1="const"
150    else
151      am_cv_proto_iconv_arg1=""
152    fi
153
154    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
155      [Define as const if the declaration of iconv() needs const.])
156  fi
157
158  LIBICONV=
159  if test "$cf_cv_find_linkage_iconv" = yes; then
160    CF_ADD_INCDIR($cf_cv_header_path_iconv)
161    if test -n "$cf_cv_library_file_iconv" ; then
162      LIBICONV="-liconv"
163      CF_ADD_LIBDIR($cf_cv_library_path_iconv)
164    fi
165  fi
166
167  AC_SUBST(LIBICONV)
168])dnl
169dnl ---------------------------------------------------------------------------
170dnl AM_LANGINFO_CODESET version: 6 updated: 2021/01/01 16:53:59
171dnl -------------------
172dnl Inserted as requested by gettext 0.10.40
173dnl File from /usr/share/aclocal
174dnl codeset.m4
175dnl ====================
176dnl serial AM1
177dnl
178dnl From Bruno Haible.
179AC_DEFUN([AM_LANGINFO_CODESET],
180[
181AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
182	[AC_TRY_LINK([#include <langinfo.h>],
183	[char* cs = nl_langinfo(CODESET); (void)cs],
184	am_cv_langinfo_codeset=yes,
185	am_cv_langinfo_codeset=no)
186	])
187	if test "$am_cv_langinfo_codeset" = yes; then
188		AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
189		[Define if you have <langinfo.h> and nl_langinfo(CODESET).])
190	fi
191])dnl
192dnl ---------------------------------------------------------------------------
193dnl AM_LC_MESSAGES version: 6 updated: 2021/01/02 09:31:20
194dnl --------------
195dnl Inserted as requested by gettext 0.10.40
196dnl File from /usr/share/aclocal
197dnl lcmessage.m4
198dnl ====================
199dnl Check whether LC_MESSAGES is available in <locale.h>.
200dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
201dnl
202dnl This file can be copied and used freely without restrictions.  It can
203dnl be used in projects which are not available under the GNU General Public
204dnl License or the GNU Library General Public License but which still want
205dnl to provide support for the GNU gettext functionality.
206dnl Please note that the actual code of the GNU gettext library is covered
207dnl by the GNU Library General Public License, and the rest of the GNU
208dnl gettext package package is covered by the GNU General Public License.
209dnl They are *not* in the public domain.
210dnl
211dnl serial 2
212dnl
213AC_DEFUN([AM_LC_MESSAGES],
214[if test "$ac_cv_header_locale_h" = yes; then
215	AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
216		[AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
217		am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
218	if test "$am_cv_val_LC_MESSAGES" = yes; then
219		AC_DEFINE(HAVE_LC_MESSAGES, 1,
220		[Define if your <locale.h> file defines LC_MESSAGES.])
221	fi
222fi])dnl
223dnl ---------------------------------------------------------------------------
224dnl AM_PATH_PROG_WITH_TEST version: 10 updated: 2021/01/02 09:31:20
225dnl ----------------------
226dnl Inserted as requested by gettext 0.10.40
227dnl File from /usr/share/aclocal
228dnl progtest.m4
229dnl ====================
230dnl Search path for a program which passes the given test.
231dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
232dnl
233dnl This file can be copied and used freely without restrictions.  It can
234dnl be used in projects which are not available under the GNU General Public
235dnl License or the GNU Library General Public License but which still want
236dnl to provide support for the GNU gettext functionality.
237dnl Please note that the actual code of the GNU gettext library is covered
238dnl by the GNU Library General Public License, and the rest of the GNU
239dnl gettext package package is covered by the GNU General Public License.
240dnl They are *not* in the public domain.
241dnl
242dnl serial 2
243dnl
244dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
245dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
246AC_DEFUN([AM_PATH_PROG_WITH_TEST],
247[# Extract the first word of "$2", so it can be a program name with args.
248AC_REQUIRE([CF_PATHSEP])
249set dummy $2; ac_word=[$]2
250AC_MSG_CHECKING([for $ac_word])
251AC_CACHE_VAL(ac_cv_path_$1,
252[case "[$]$1" in
253  ([[\\/]*|?:[\\/]]*)
254  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
255  ;;
256  (*)
257  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
258  for ac_dir in ifelse([$5], , $PATH, [$5]); do
259    test -z "$ac_dir" && ac_dir=.
260    if test -f "$ac_dir/$ac_word$ac_exeext" ; then
261      if [$3]; then
262	ac_cv_path_$1="$ac_dir/$ac_word$ac_exeext"
263	break
264      fi
265    fi
266  done
267  IFS="$ac_save_ifs"
268dnl If no 4th arg is given, leave the cache variable unset,
269dnl so AC_PATH_PROGS will keep looking.
270ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
271])dnl
272  ;;
273esac])dnl
274$1="$ac_cv_path_$1"
275if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
276  AC_MSG_RESULT([$]$1)
277else
278  AC_MSG_RESULT(no)
279fi
280AC_SUBST($1)dnl
281])dnl
282dnl ---------------------------------------------------------------------------
283dnl AM_WITH_NLS version: 31 updated: 2021/01/04 17:48:08
284dnl -----------
285dnl Inserted as requested by gettext 0.10.40
286dnl File from /usr/share/aclocal
287dnl gettext.m4
288dnl ====================
289dnl Macro to add for using GNU gettext.
290dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
291dnl ====================
292dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
293dnl range of locations searched.  Retain the same cache-variable naming to
294dnl allow reuse with the other gettext macros -Thomas E Dickey
295dnl ====================
296dnl
297dnl This file can be copied and used freely without restrictions.  It can
298dnl be used in projects which are not available under the GNU General Public
299dnl License or the GNU Library General Public License but which still want
300dnl to provide support for the GNU gettext functionality.
301dnl Please note that the actual code of the GNU gettext library is covered
302dnl by the GNU Library General Public License, and the rest of the GNU
303dnl gettext package package is covered by the GNU General Public License.
304dnl They are *not* in the public domain.
305dnl
306dnl serial 10
307dnl
308dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
309dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
310dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
311dnl    depending on --{enable,disable}-{shared,static} and on the presence of
312dnl    AM-DISABLE-SHARED). Otherwise, a static library
313dnl    $(top_builddir)/intl/libintl.a will be created.
314dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
315dnl    implementations (in libc or libintl) without the ngettext() function
316dnl    will be ignored.
317dnl LIBDIR is used to find the intl libraries.  If empty,
318dnl    the value `$(top_builddir)/intl/' is used.
319dnl ENABLED is used to control the default for the related --enable-nls, since
320dnl    not all application developers want this feature by default, e.g., lynx.
321dnl
322dnl The result of the configuration is one of three cases:
323dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
324dnl    and used.
325dnl    Catalog format: GNU --> install in $(datadir)
326dnl    Catalog extension: .mo after installation, .gmo in source tree
327dnl 2) GNU gettext has been found in the system's C library.
328dnl    Catalog format: GNU --> install in $(datadir)
329dnl    Catalog extension: .mo after installation, .gmo in source tree
330dnl 3) No internationalization, always use English msgid.
331dnl    Catalog format: none
332dnl    Catalog extension: none
333dnl The use of .gmo is historical (it was needed to avoid overwriting the
334dnl GNU format catalogs when building on a platform with an X/Open gettext),
335dnl but we keep it in order not to force irrelevant filename changes on the
336dnl maintainers.
337dnl
338AC_DEFUN([AM_WITH_NLS],
339[AC_MSG_CHECKING([whether NLS is requested])
340  dnl Default is enabled NLS
341  ifelse([$4],,[
342  AC_ARG_ENABLE(nls,
343    [  --disable-nls           do not use Native Language Support],
344    USE_NLS=$enableval, USE_NLS=yes)],[
345  AC_ARG_ENABLE(nls,
346    [  --enable-nls            use Native Language Support],
347    USE_NLS=$enableval, USE_NLS=no)])
348  AC_MSG_RESULT($USE_NLS)
349  AC_SUBST(USE_NLS)
350
351  BUILD_INCLUDED_LIBINTL=no
352  USE_INCLUDED_LIBINTL=no
353  INTLLIBS=
354
355  dnl If we use NLS figure out what method
356  if test "$USE_NLS" = "yes"; then
357    dnl We need to process the po/ directory.
358    POSUB=po
359    AC_DEFINE(ENABLE_NLS, 1,
360      [Define to 1 if translation of program messages to the user's native language
361 is requested.])
362    AC_MSG_CHECKING([whether included gettext is requested])
363    AC_ARG_WITH(included-gettext,
364      [  --with-included-gettext use the GNU gettext library included here],
365      nls_cv_force_use_gnu_gettext=$withval,
366      nls_cv_force_use_gnu_gettext=no)
367    AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
368
369    nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
370    if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
371      dnl User does not insist on using GNU NLS library.  Figure out what
372      dnl to use.  If GNU gettext is available we use this.  Else we may have
373      dnl to fall back to GNU NLS library.
374      CATOBJEXT=NONE
375
376      dnl Save these (possibly-set) variables for reference.  If the user
377      dnl overrode these to provide full pathnames, then warn if not actually
378      dnl GNU gettext, but do not override their values.  Also, if they were
379      dnl overridden, suppress the part of the library test which prevents it
380      dnl from finding anything other than GNU gettext.  Doing this also
381      dnl suppresses a bogus search for the intl library.
382      cf_save_msgfmt_path="$MSGFMT"
383      cf_save_xgettext_path="$XGETTEXT"
384
385      dnl Search for GNU msgfmt in the PATH.
386      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
387          ["$ac_dir/$ac_word" --statistics /dev/null >/dev/null 2>&1], :)
388      AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
389      AC_SUBST(MSGFMT)
390
391      dnl Search for GNU xgettext in the PATH.
392      AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
393          ["$ac_dir/$ac_word" --omit-header /dev/null >/dev/null 2>&1], :)
394
395      cf_save_OPTS_1="$CPPFLAGS"
396      if test "x$cf_save_msgfmt_path" = "x$MSGFMT" && \
397         test "x$cf_save_xgettext_path" = "x$XGETTEXT" ; then
398          CF_ADD_CFLAGS(-DIGNORE_MSGFMT_HACK)
399      fi
400
401      cf_save_LIBS_1="$LIBS"
402      CF_ADD_LIBS($LIBICONV)
403
404      CF_FIND_LINKAGE(CF__INTL_HEAD,
405        CF__INTL_BODY($2),
406        intl,
407        cf_cv_func_gettext=yes,
408        cf_cv_func_gettext=no)
409
410      AC_MSG_CHECKING([for libintl.h and gettext()])
411      AC_MSG_RESULT($cf_cv_func_gettext)
412
413      LIBS="$cf_save_LIBS_1"
414      CPPFLAGS="$cf_save_OPTS_1"
415
416      if test "$cf_cv_func_gettext" = yes ; then
417        AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have libintl.h])
418
419        dnl If an already present or preinstalled GNU gettext() is found,
420        dnl use it.  But if this macro is used in GNU gettext, and GNU
421        dnl gettext is already preinstalled in libintl, we update this
422        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
423        if test "$PACKAGE" != gettext; then
424          AC_DEFINE(HAVE_GETTEXT, 1,
425              [Define if the GNU gettext() function is already present or preinstalled.])
426
427          CF_ADD_INCDIR($cf_cv_header_path_intl)
428
429          if test -n "$cf_cv_library_file_intl" ; then
430            dnl If iconv() is in a separate libiconv library, then anyone
431            dnl linking with libintl{.a,.so} also needs to link with
432            dnl libiconv.
433            INTLLIBS="$cf_cv_library_file_intl $LIBICONV"
434            CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
435          fi
436
437          gt_save_LIBS="$LIBS"
438          LIBS="$LIBS $INTLLIBS"
439          AC_CHECK_FUNCS(dcgettext)
440          LIBS="$gt_save_LIBS"
441
442          CATOBJEXT=.gmo
443        fi
444      elif test -z "$MSGFMT" || test -z "$XGETTEXT" ; then
445        AC_MSG_WARN(disabling NLS feature)
446        sed -e /ENABLE_NLS/d confdefs.h >confdefs.tmp
447        mv confdefs.tmp confdefs.h
448        ALL_LINGUAS=
449        CATOBJEXT=.ignored
450        MSGFMT=":"
451        GMSGFMT=":"
452        XGETTEXT=":"
453        POSUB=
454        BUILD_INCLUDED_LIBINTL=no
455        USE_INCLUDED_LIBINTL=no
456        USE_NLS=no
457        nls_cv_use_gnu_gettext=no
458      fi
459
460      if test "$CATOBJEXT" = "NONE"; then
461        dnl GNU gettext is not found in the C library.
462        dnl Fall back on GNU gettext library.
463        nls_cv_use_gnu_gettext=maybe
464      fi
465    fi
466
467    if test "$nls_cv_use_gnu_gettext" != "no"; then
468      CATOBJEXT=.gmo
469      if test -f "$srcdir/intl/libintl.h" ; then
470        dnl Mark actions used to generate GNU NLS library.
471        INTLOBJS="\$(GETTOBJS)"
472        BUILD_INCLUDED_LIBINTL=yes
473        USE_INCLUDED_LIBINTL=yes
474        INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
475        LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
476      elif test "$nls_cv_use_gnu_gettext" = "yes"; then
477        nls_cv_use_gnu_gettext=no
478        AC_MSG_WARN(no NLS library is packaged with this application)
479      fi
480    fi
481
482    dnl Test whether we really found GNU msgfmt.
483    if test "$GMSGFMT" != ":"; then
484      if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
485        : ;
486      else
487        AC_MSG_WARN([found msgfmt program is not GNU msgfmt])
488      fi
489    fi
490
491    dnl Test whether we really found GNU xgettext.
492    if test "$XGETTEXT" != ":"; then
493      if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
494        : ;
495      else
496        AC_MSG_WARN([found xgettext program is not GNU xgettext])
497      fi
498    fi
499  fi
500
501  if test "$XGETTEXT" != ":"; then
502    AC_OUTPUT_COMMANDS(
503     [for ac_file in $CONFIG_FILES; do
504
505        # Support "outfile[:infile[:infile...]]"
506        case "$ac_file" in
507          (*:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
508        esac
509
510        # PO directories have a Makefile.in generated from Makefile.inn.
511        case "$ac_file" in
512        (*/[Mm]akefile.in)
513          # Adjust a relative srcdir.
514          ac_dir="`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`"
515          ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
516          ac_dots="`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`"
517          ac_base="`basename $ac_file .in`"
518          # In autoconf-2.13 it is called $ac_given_srcdir.
519          # In autoconf-2.50 it is called $srcdir.
520          test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
521
522          case "$ac_given_srcdir" in
523            (.)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
524            (/*) top_srcdir="$ac_given_srcdir" ;;
525            (*)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
526          esac
527
528          if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
529            rm -f "$ac_dir/POTFILES"
530            test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
531            sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
532            test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
533            sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
534          fi
535          ;;
536        esac
537      done])
538
539    dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
540    dnl to 'yes' because some of the testsuite requires it.
541    if test "$PACKAGE" = gettext; then
542      BUILD_INCLUDED_LIBINTL=yes
543    fi
544
545    dnl intl/plural.c is generated from intl/plural.y. It requires bison,
546    dnl because plural.y uses bison specific features. It requires at least
547    dnl bison-1.26 because earlier versions generate a plural.c that doesn't
548    dnl compile.
549    dnl bison is only needed for the maintainer (who touches plural.y). But in
550    dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
551    dnl the rule in general Makefile. Now, some people carelessly touch the
552    dnl files or have a broken "make" program, hence the plural.c rule will
553    dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
554    dnl present or too old.
555    if test "$nls_cv_use_gnu_gettext" = "yes"; then
556      AC_CHECK_PROGS([INTLBISON], [bison])
557      if test -z "$INTLBISON"; then
558        ac_verc_fail=yes
559      else
560        dnl Found it, now check the version.
561        AC_MSG_CHECKING([version of bison])
562changequote(<<,>>)dnl
563        ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
564        case "$ac_prog_version" in
565          ('') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
566          (1.2[6-9]*|1.[3-9][0-9]*|[2-9].*)
567changequote([,])dnl
568             ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
569          (*) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
570        esac
571      AC_MSG_RESULT([$ac_prog_version])
572      fi
573      if test "$ac_verc_fail" = yes; then
574        INTLBISON=:
575      fi
576    fi
577
578    dnl These rules are solely for the distribution goal.  While doing this
579    dnl we only have to keep exactly one list of the available catalogs
580    dnl in configure.in.
581    for lang in $ALL_LINGUAS; do
582      GMOFILES="$GMOFILES $lang.gmo"
583      POFILES="$POFILES $lang.po"
584    done
585  fi
586
587  dnl Make all variables we use known to autoconf.
588  AC_SUBST(BUILD_INCLUDED_LIBINTL)
589  AC_SUBST(USE_INCLUDED_LIBINTL)
590  AC_SUBST(CATALOGS)
591  AC_SUBST(CATOBJEXT)
592  AC_SUBST(GMOFILES)
593  AC_SUBST(INTLLIBS)
594  AC_SUBST(INTLOBJS)
595  AC_SUBST(POFILES)
596  AC_SUBST(POSUB)
597
598  dnl For backward compatibility. Some configure.ins may be using this.
599  nls_cv_header_intl=
600  nls_cv_header_libgt=
601
602  dnl For backward compatibility. Some Makefiles may be using this.
603  DATADIRNAME=share
604  AC_SUBST(DATADIRNAME)
605
606  dnl For backward compatibility. Some Makefiles may be using this.
607  INSTOBJEXT=.mo
608  AC_SUBST(INSTOBJEXT)
609
610  dnl For backward compatibility. Some Makefiles may be using this.
611  GENCAT=gencat
612  AC_SUBST(GENCAT)
613])dnl
614dnl ---------------------------------------------------------------------------
615dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
616dnl ------------------
617dnl Conditionally generate script according to whether we're using a given autoconf.
618dnl
619dnl $1 = version to compare against
620dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
621dnl $3 = code to use if AC_ACVERSION is older than $1.
622define([CF_ACVERSION_CHECK],
623[
624ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
625ifdef([m4_version_compare],
626[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
627[CF_ACVERSION_COMPARE(
628AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
629AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
630dnl ---------------------------------------------------------------------------
631dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
632dnl --------------------
633dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
634dnl                      MAJOR2, MINOR2, TERNARY2,
635dnl                      PRINTABLE2, not FOUND, FOUND)
636define([CF_ACVERSION_COMPARE],
637[ifelse(builtin([eval], [$2 < $5]), 1,
638[ifelse([$8], , ,[$8])],
639[ifelse([$9], , ,[$9])])])dnl
640dnl ---------------------------------------------------------------------------
641dnl CF_ADD_CFLAGS version: 15 updated: 2020/12/31 10:54:15
642dnl -------------
643dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
644dnl $1 = flags to add
645dnl $2 = if given makes this macro verbose.
646dnl
647dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
648dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
649dnl confused by the quotes (which require backslashes to keep them usable).
650AC_DEFUN([CF_ADD_CFLAGS],
651[
652cf_fix_cppflags=no
653cf_new_cflags=
654cf_new_cppflags=
655cf_new_extra_cppflags=
656
657for cf_add_cflags in $1
658do
659case "$cf_fix_cppflags" in
660(no)
661	case "$cf_add_cflags" in
662	(-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
663		case "$cf_add_cflags" in
664		(-D*)
665			cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
666
667			test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
668				&& test -z "${cf_tst_cflags}" \
669				&& cf_fix_cppflags=yes
670
671			if test "$cf_fix_cppflags" = yes ; then
672				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
673				continue
674			elif test "${cf_tst_cflags}" = "\"'" ; then
675				CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
676				continue
677			fi
678			;;
679		esac
680		case "$CPPFLAGS" in
681		(*$cf_add_cflags)
682			;;
683		(*)
684			case "$cf_add_cflags" in
685			(-D*)
686				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
687				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
688				;;
689			esac
690			CF_APPEND_TEXT(cf_new_cppflags,$cf_add_cflags)
691			;;
692		esac
693		;;
694	(*)
695		CF_APPEND_TEXT(cf_new_cflags,$cf_add_cflags)
696		;;
697	esac
698	;;
699(yes)
700	CF_APPEND_TEXT(cf_new_extra_cppflags,$cf_add_cflags)
701
702	cf_tst_cflags=`echo "${cf_add_cflags}" |sed -e 's/^[[^"]]*"'\''//'`
703
704	test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
705		&& test -z "${cf_tst_cflags}" \
706		&& cf_fix_cppflags=no
707	;;
708esac
709done
710
711if test -n "$cf_new_cflags" ; then
712	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
713	CF_APPEND_TEXT(CFLAGS,$cf_new_cflags)
714fi
715
716if test -n "$cf_new_cppflags" ; then
717	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
718	CF_APPEND_TEXT(CPPFLAGS,$cf_new_cppflags)
719fi
720
721if test -n "$cf_new_extra_cppflags" ; then
722	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
723	CF_APPEND_TEXT(EXTRA_CPPFLAGS,$cf_new_extra_cppflags)
724fi
725
726AC_SUBST(EXTRA_CPPFLAGS)
727
728])dnl
729dnl ---------------------------------------------------------------------------
730dnl CF_ADD_INCDIR version: 16 updated: 2020/12/31 20:19:42
731dnl -------------
732dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
733dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
734dnl but old versions (and some misinstalled ones) need that.  To make things
735dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
736dnl the include-path).
737AC_DEFUN([CF_ADD_INCDIR],
738[
739if test -n "$1" ; then
740  for cf_add_incdir in $1
741  do
742	while test "$cf_add_incdir" != /usr/include
743	do
744	  if test -d "$cf_add_incdir"
745	  then
746		cf_have_incdir=no
747		if test -n "$CFLAGS$CPPFLAGS" ; then
748		  # a loop is needed to ensure we can add subdirs of existing dirs
749		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
750			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
751			  cf_have_incdir=yes; break
752			fi
753		  done
754		fi
755
756		if test "$cf_have_incdir" = no ; then
757		  if test "$cf_add_incdir" = /usr/local/include ; then
758			if test "$GCC" = yes
759			then
760			  cf_save_CPPFLAGS=$CPPFLAGS
761			  CF_APPEND_TEXT(CPPFLAGS,-I$cf_add_incdir)
762			  AC_TRY_COMPILE([#include <stdio.h>],
763				  [printf("Hello")],
764				  [],
765				  [cf_have_incdir=yes])
766			  CPPFLAGS=$cf_save_CPPFLAGS
767			fi
768		  fi
769		fi
770
771		if test "$cf_have_incdir" = no ; then
772		  CF_VERBOSE(adding $cf_add_incdir to include-path)
773		  ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
774
775		  cf_top_incdir=`echo "$cf_add_incdir" | sed -e 's%/include/.*$%/include%'`
776		  test "$cf_top_incdir" = "$cf_add_incdir" && break
777		  cf_add_incdir="$cf_top_incdir"
778		else
779		  break
780		fi
781	  else
782		break
783	  fi
784	done
785  done
786fi
787])dnl
788dnl ---------------------------------------------------------------------------
789dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
790dnl ----------
791dnl Add a library, used to enforce consistency.
792dnl
793dnl $1 = library to add, without the "-l"
794dnl $2 = variable to update (default $LIBS)
795AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
796dnl ---------------------------------------------------------------------------
797dnl CF_ADD_LIBDIR version: 11 updated: 2020/12/31 20:19:42
798dnl -------------
799dnl	Adds to the library-path
800dnl
801dnl	Some machines have trouble with multiple -L options.
802dnl
803dnl $1 is the (list of) directory(s) to add
804dnl $2 is the optional name of the variable to update (default LDFLAGS)
805dnl
806AC_DEFUN([CF_ADD_LIBDIR],
807[
808if test -n "$1" ; then
809	for cf_add_libdir in $1
810	do
811		if test "$cf_add_libdir" = /usr/lib ; then
812			:
813		elif test -d "$cf_add_libdir"
814		then
815			cf_have_libdir=no
816			if test -n "$LDFLAGS$LIBS" ; then
817				# a loop is needed to ensure we can add subdirs of existing dirs
818				for cf_test_libdir in $LDFLAGS $LIBS ; do
819					if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
820						cf_have_libdir=yes; break
821					fi
822				done
823			fi
824			if test "$cf_have_libdir" = no ; then
825				CF_VERBOSE(adding $cf_add_libdir to library-path)
826				ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
827			fi
828		fi
829	done
830fi
831])dnl
832dnl ---------------------------------------------------------------------------
833dnl CF_ADD_LIBS version: 3 updated: 2019/11/02 16:47:33
834dnl -----------
835dnl Add one or more libraries, used to enforce consistency.  Libraries are
836dnl prepended to an existing list, since their dependencies are assumed to
837dnl already exist in the list.
838dnl
839dnl $1 = libraries to add, with the "-l", etc.
840dnl $2 = variable to update (default $LIBS)
841AC_DEFUN([CF_ADD_LIBS],[
842cf_add_libs="[$]ifelse($2,,LIBS,[$2])"
843# reverse order
844cf_add_0lib=
845for cf_add_1lib in $1; do cf_add_0lib="$cf_add_1lib $cf_add_0lib"; done
846# filter duplicates
847for cf_add_1lib in $cf_add_0lib; do
848	for cf_add_2lib in $cf_add_libs; do
849		if test "x$cf_add_1lib" = "x$cf_add_2lib"; then
850			cf_add_1lib=
851			break
852		fi
853	done
854	test -n "$cf_add_1lib" && cf_add_libs="$cf_add_1lib $cf_add_libs"
855done
856ifelse($2,,LIBS,[$2])="$cf_add_libs"
857])dnl
858dnl ---------------------------------------------------------------------------
859dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
860dnl ----------------
861dnl Add a given library after another, e.g., following the one it satisfies a
862dnl dependency for.
863dnl
864dnl $1 = the first library
865dnl $2 = its dependency
866AC_DEFUN([CF_ADD_LIB_AFTER],[
867CF_VERBOSE(...before $LIBS)
868LIBS=`echo "$LIBS" | sed -e "s/[[ 	]][[ 	]]*/ /g" -e "s%$1 %$1 $2 %" -e 's%  % %g'`
869CF_VERBOSE(...after  $LIBS)
870])dnl
871dnl ---------------------------------------------------------------------------
872dnl CF_ADD_OPTIONAL_PATH version: 3 updated: 2015/05/10 19:52:14
873dnl --------------------
874dnl Add an optional search-path to the compile/link variables.
875dnl See CF_WITH_PATH
876dnl
877dnl $1 = shell variable containing the result of --with-XXX=[DIR]
878dnl $2 = module to look for.
879AC_DEFUN([CF_ADD_OPTIONAL_PATH],[
880case "$1" in
881(no)
882	;;
883(yes)
884	;;
885(*)
886	CF_ADD_SEARCHPATH([$1], [AC_MSG_ERROR(cannot find $2 under $1)])
887	;;
888esac
889])dnl
890dnl ---------------------------------------------------------------------------
891dnl CF_ADD_SEARCHPATH version: 6 updated: 2020/12/31 20:19:42
892dnl -----------------
893dnl Set $CPPFLAGS and $LDFLAGS with the directories given via the parameter.
894dnl They can be either the common root of include- and lib-directories, or the
895dnl lib-directory (to allow for things like lib64 directories).
896dnl See also CF_FIND_LINKAGE.
897dnl
898dnl $1 is the list of colon-separated directory names to search.
899dnl $2 is the action to take if a parameter does not yield a directory.
900AC_DEFUN([CF_ADD_SEARCHPATH],
901[
902AC_REQUIRE([CF_PATHSEP])
903for cf_searchpath in `echo "$1" | tr $PATH_SEPARATOR ' '`; do
904	if test -d "$cf_searchpath/include" ; then
905		CF_ADD_INCDIR($cf_searchpath/include)
906	elif test -d "$cf_searchpath/../include" ; then
907		CF_ADD_INCDIR($cf_searchpath/../include)
908	ifelse([$2],,,[else
909$2])
910	fi
911	if test -d "$cf_searchpath/lib" ; then
912		CF_ADD_LIBDIR($cf_searchpath/lib)
913	elif test -d "$cf_searchpath" ; then
914		CF_ADD_LIBDIR($cf_searchpath)
915	ifelse([$2],,,[else
916$2])
917	fi
918done
919])
920dnl ---------------------------------------------------------------------------
921dnl CF_ADD_SUBDIR_PATH version: 5 updated: 2020/12/31 20:19:42
922dnl ------------------
923dnl Append to a search-list for a nonstandard header/lib-file
924dnl	$1 = the variable to return as result
925dnl	$2 = the package name
926dnl	$3 = the subdirectory, e.g., bin, include or lib
927dnl $4 = the directory under which we will test for subdirectories
928dnl $5 = a directory that we do not want $4 to match
929AC_DEFUN([CF_ADD_SUBDIR_PATH],
930[
931test "x$4" != "x$5" && \
932test -d "$4" && \
933ifelse([$5],NONE,,[{ test -z "$5" || test "x$5" = xNONE || test "x$4" != "x$5"; } &&]) {
934	test -n "$verbose" && echo "	... testing for $3-directories under $4"
935	test -d "$4/$3" &&          $1="[$]$1 $4/$3"
936	test -d "$4/$3/$2" &&       $1="[$]$1 $4/$3/$2"
937	test -d "$4/$3/$2/$3" &&    $1="[$]$1 $4/$3/$2/$3"
938	test -d "$4/$2/$3" &&       $1="[$]$1 $4/$2/$3"
939	test -d "$4/$2/$3/$2" &&    $1="[$]$1 $4/$2/$3/$2"
940}
941])dnl
942dnl ---------------------------------------------------------------------------
943dnl CF_APPEND_TEXT version: 1 updated: 2017/02/25 18:58:55
944dnl --------------
945dnl use this macro for appending text without introducing an extra blank at
946dnl the beginning
947define([CF_APPEND_TEXT],
948[
949	test -n "[$]$1" && $1="[$]$1 "
950	$1="[$]{$1}$2"
951])dnl
952dnl ---------------------------------------------------------------------------
953dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
954dnl --------------
955dnl Allow user to disable a normally-on option.
956AC_DEFUN([CF_ARG_DISABLE],
957[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
958dnl ---------------------------------------------------------------------------
959dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
960dnl -------------
961dnl Allow user to enable a normally-off option.
962AC_DEFUN([CF_ARG_ENABLE],
963[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
964dnl ---------------------------------------------------------------------------
965dnl CF_ARG_MSG_ENABLE version: 2 updated: 2000/07/29 19:32:03
966dnl -----------------
967dnl Verbose form of AC_ARG_ENABLE:
968dnl
969dnl Parameters:
970dnl $1 = message
971dnl $2 = option name
972dnl $3 = help-string
973dnl $4 = action to perform if option is enabled
974dnl $5 = action if perform if option is disabled
975dnl $6 = default option value (either 'yes' or 'no')
976AC_DEFUN([CF_ARG_MSG_ENABLE],[
977AC_MSG_CHECKING($1)
978AC_ARG_ENABLE($2,[$3],,enableval=ifelse($6,,no,$6))
979AC_MSG_RESULT($enableval)
980if test "$enableval" != no ; then
981ifelse($4,,[	:],$4)
982else
983ifelse($5,,[	:],$5)
984fi
985])dnl
986dnl ---------------------------------------------------------------------------
987dnl CF_ARG_OPTION version: 5 updated: 2015/05/10 19:52:14
988dnl -------------
989dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
990dnl values.
991dnl
992dnl Parameters:
993dnl $1 = option name
994dnl $2 = help-string
995dnl $3 = action to perform if option is not default
996dnl $4 = action if perform if option is default
997dnl $5 = default option value (either 'yes' or 'no')
998AC_DEFUN([CF_ARG_OPTION],
999[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
1000	if test "$enableval" != "$5" ; then
1001ifelse([$3],,[    :]dnl
1002,[    $3]) ifelse([$4],,,[
1003	else
1004		$4])
1005	fi],[enableval=$5 ifelse([$4],,,[
1006	$4
1007])dnl
1008])])dnl
1009dnl ---------------------------------------------------------------------------
1010dnl CF_AR_FLAGS version: 9 updated: 2021/01/01 13:31:04
1011dnl -----------
1012dnl Check for suitable "ar" (archiver) options for updating an archive.
1013dnl
1014dnl In particular, handle some obsolete cases where the "-" might be omitted,
1015dnl as well as a workaround for breakage of make's archive rules by the GNU
1016dnl binutils "ar" program.
1017AC_DEFUN([CF_AR_FLAGS],[
1018AC_REQUIRE([CF_PROG_AR])
1019
1020AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
1021	case "$cf_cv_system_name" in
1022	(*-msvc*)
1023		cf_cv_ar_flags=''
1024		cat >mk_static_lib.sh <<-EOF
1025		#!$SHELL
1026		MSVC_BIN="[$]AR"
1027		out="\[$]1"
1028		shift
1029		exec \[$]MSVC_BIN -out:"\[$]out" \[$]@
1030		EOF
1031		chmod +x mk_static_lib.sh
1032		AR=`pwd`/mk_static_lib.sh
1033		;;
1034	(*)
1035		cf_cv_ar_flags=unknown
1036		for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
1037		do
1038
1039			# check if $ARFLAGS already contains this choice
1040			if test "x$ARFLAGS" != "x" ; then
1041				cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
1042				if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
1043					cf_cv_ar_flags=
1044					break
1045				fi
1046			fi
1047
1048			rm -f "conftest.$ac_cv_objext"
1049			rm -f conftest.a
1050
1051			cat >"conftest.$ac_ext" <<EOF
1052#line __oline__ "configure"
1053int	testdata[[3]] = { 123, 456, 789 };
1054EOF
1055			if AC_TRY_EVAL(ac_compile) ; then
1056				echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
1057				$AR $ARFLAGS "$cf_ar_flags" conftest.a "conftest.$ac_cv_objext" 2>&AC_FD_CC 1>/dev/null
1058				if test -f conftest.a ; then
1059					cf_cv_ar_flags="$cf_ar_flags"
1060					break
1061				fi
1062			else
1063				CF_VERBOSE(cannot compile test-program)
1064				break
1065			fi
1066		done
1067		rm -f conftest.a "conftest.$ac_ext" "conftest.$ac_cv_objext"
1068		;;
1069	esac
1070])
1071
1072if test -n "$ARFLAGS" ; then
1073	if test -n "$cf_cv_ar_flags" ; then
1074		ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
1075	fi
1076else
1077	ARFLAGS=$cf_cv_ar_flags
1078fi
1079
1080AC_SUBST(ARFLAGS)
1081])
1082dnl ---------------------------------------------------------------------------
1083dnl CF_BUNDLED_INTL version: 20 updated: 2021/01/02 09:31:20
1084dnl ---------------
1085dnl Top-level macro for configuring an application with a bundled copy of
1086dnl the intl and po directories for gettext.
1087dnl
1088dnl $1 specifies either Makefile or makefile, defaulting to the former.
1089dnl $2 if nonempty sets the option to --enable-nls rather than to --disable-nls
1090dnl
1091dnl Sets variables which can be used to substitute in makefiles:
1092dnl	GT_YES       - "#" comment unless building intl library, otherwise empty
1093dnl	GT_NO        - "#" comment if building intl library, otherwise empty
1094dnl	INTLDIR_MAKE - to make ./intl directory
1095dnl	MSG_DIR_MAKE - to make ./po directory
1096dnl	SUB_MAKEFILE - list of makefiles in ./intl, ./po directories
1097dnl
1098dnl Defines:
1099dnl	HAVE_LIBGETTEXT_H if we're using ./intl
1100dnl	NLS_TEXTDOMAIN
1101dnl
1102dnl Environment:
1103dnl	ALL_LINGUAS if set, lists the root names of the ".po" files.
1104dnl	CONFIG_H assumed to be "config.h"
1105dnl	PACKAGE must be set, used as default for textdomain
1106dnl	VERSION may be set, otherwise extract from "VERSION" file.
1107dnl
1108AC_DEFUN([CF_BUNDLED_INTL],[
1109cf_makefile=ifelse($1,,Makefile,$1)
1110
1111dnl Set of available languages (based on source distribution).  Note that
1112dnl setting $LINGUAS overrides $ALL_LINGUAS.  Some environments set $LINGUAS
1113dnl rather than $LC_ALL
1114test -z "$ALL_LINGUAS" && ALL_LINGUAS=`test -d "$srcdir/po" && cd "$srcdir/po" && echo *.po|sed -e 's/\.po//g' -e 's/*//'`
1115
1116# Allow override of "config.h" definition:
1117: ${CONFIG_H:=config.h}
1118AC_SUBST(CONFIG_H)
1119
1120if test -z "$PACKAGE" ; then
1121	AC_MSG_ERROR([[CF_BUNDLED_INTL] used without setting [PACKAGE] variable])
1122fi
1123
1124if test -z "$VERSION" ; then
1125if test -f "$srcdir/VERSION" ; then
1126	VERSION=`sed -e '2,$d' "$srcdir/VERSION" |cut -f1`
1127else
1128	VERSION=unknown
1129fi
1130fi
1131AC_SUBST(VERSION)
1132
1133AM_GNU_GETTEXT(,,,[$2])
1134
1135if test "$USE_NLS" = yes ; then
1136	AC_ARG_WITH(textdomain,
1137		[  --with-textdomain=PKG   NLS text-domain (default is package name)],
1138		[NLS_TEXTDOMAIN=$withval],
1139		[NLS_TEXTDOMAIN=$PACKAGE])
1140	AC_DEFINE_UNQUOTED(NLS_TEXTDOMAIN,"$NLS_TEXTDOMAIN",[Define to the nls textdomain value])
1141	AC_SUBST(NLS_TEXTDOMAIN)
1142fi
1143
1144INTLDIR_MAKE=
1145MSG_DIR_MAKE=
1146SUB_MAKEFILE=
1147
1148dnl this updates SUB_MAKEFILE and MSG_DIR_MAKE:
1149CF_OUR_MESSAGES($1)
1150
1151if test "$USE_INCLUDED_LIBINTL" = yes ; then
1152	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1153		:
1154	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1155		:
1156	else
1157		INTLDIR_MAKE="#"
1158	fi
1159	if test -z "$INTLDIR_MAKE"; then
1160		AC_DEFINE(HAVE_LIBGETTEXT_H,1,[Define to 1 if we have libgettext.h])
1161		for cf_makefile in \
1162			$srcdir/intl/Makefile.in \
1163			$srcdir/intl/makefile.in
1164		do
1165			if test -f "$cf_makefile" ; then
1166				SUB_MAKEFILE="$SUB_MAKEFILE `echo \"${cf_makefile}\"|sed -e 's,^'$srcdir/',,' -e 's/\.in$//'`:${cf_makefile}"
1167				break
1168			fi
1169		done
1170	fi
1171else
1172	INTLDIR_MAKE="#"
1173	if test "$USE_NLS" = yes ; then
1174		AC_CHECK_HEADERS(libintl.h)
1175	fi
1176fi
1177
1178if test -z "$INTLDIR_MAKE" ; then
1179	CF_APPEND_TEXT(CPPFLAGS,-I../intl)
1180fi
1181
1182dnl FIXME:  we use this in lynx (the alternative is a spurious dependency upon
1183dnl GNU make)
1184if test "$BUILD_INCLUDED_LIBINTL" = yes ; then
1185	GT_YES="#"
1186	GT_NO=
1187else
1188	GT_YES=
1189	GT_NO="#"
1190fi
1191
1192AC_SUBST(INTLDIR_MAKE)
1193AC_SUBST(MSG_DIR_MAKE)
1194AC_SUBST(GT_YES)
1195AC_SUBST(GT_NO)
1196
1197dnl FIXME:  the underlying AM_GNU_GETTEXT macro either needs some fixes or a
1198dnl little documentation.  It doesn't define anything so that we can ifdef our
1199dnl own code, except ENABLE_NLS, which is too vague to be of any use.
1200
1201if test "$USE_INCLUDED_LIBINTL" = yes ; then
1202	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1203		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
1204	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1205		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
1206	fi
1207	if test -n "$nls_cv_header_intl" ; then
1208		AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have header-file for libintl])
1209	fi
1210fi
1211])dnl
1212dnl ---------------------------------------------------------------------------
1213dnl CF_CC_ENV_FLAGS version: 10 updated: 2020/12/31 18:40:20
1214dnl ---------------
1215dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
1216dnl into CC.  This will not help with broken scripts that wrap the compiler
1217dnl with options, but eliminates a more common category of user confusion.
1218dnl
1219dnl In particular, it addresses the problem of being able to run the C
1220dnl preprocessor in a consistent manner.
1221dnl
1222dnl Caveat: this also disallows blanks in the pathname for the compiler, but
1223dnl the nuisance of having inconsistent settings for compiler and preprocessor
1224dnl outweighs that limitation.
1225AC_DEFUN([CF_CC_ENV_FLAGS],
1226[
1227# This should have been defined by AC_PROG_CC
1228: "${CC:=cc}"
1229
1230AC_MSG_CHECKING(\$CFLAGS variable)
1231case "x$CFLAGS" in
1232(*-[[IUD]]*)
1233	AC_MSG_RESULT(broken)
1234	AC_MSG_WARN(your environment uses the CFLAGS variable to hold CPPFLAGS options)
1235	cf_flags="$CFLAGS"
1236	CFLAGS=
1237	for cf_arg in $cf_flags
1238	do
1239		CF_ADD_CFLAGS($cf_arg)
1240	done
1241	;;
1242(*)
1243	AC_MSG_RESULT(ok)
1244	;;
1245esac
1246
1247AC_MSG_CHECKING(\$CC variable)
1248case "$CC" in
1249(*[[\ \	]]-*)
1250	AC_MSG_RESULT(broken)
1251	AC_MSG_WARN(your environment uses the CC variable to hold CFLAGS/CPPFLAGS options)
1252	# humor him...
1253	cf_prog=`echo "$CC" | sed -e 's/	/ /g' -e 's/[[ ]]* / /g' -e 's/[[ ]]*[[ ]]-[[^ ]].*//'`
1254	cf_flags=`echo "$CC" | ${AWK:-awk} -v prog="$cf_prog" '{ printf("%s", [substr]([$]0,1+length(prog))); }'`
1255	CC="$cf_prog"
1256	for cf_arg in $cf_flags
1257	do
1258		case "x$cf_arg" in
1259		(x-[[IUDfgOW]]*)
1260			CF_ADD_CFLAGS($cf_arg)
1261			;;
1262		(*)
1263			CC="$CC $cf_arg"
1264			;;
1265		esac
1266	done
1267	CF_VERBOSE(resulting CC: '$CC')
1268	CF_VERBOSE(resulting CFLAGS: '$CFLAGS')
1269	CF_VERBOSE(resulting CPPFLAGS: '$CPPFLAGS')
1270	;;
1271(*)
1272	AC_MSG_RESULT(ok)
1273	;;
1274esac
1275])dnl
1276dnl ---------------------------------------------------------------------------
1277dnl CF_CHECK_CACHE version: 13 updated: 2020/12/31 10:54:15
1278dnl --------------
1279dnl Check if we're accidentally using a cache from a different machine.
1280dnl Derive the system name, as a check for reusing the autoconf cache.
1281dnl
1282dnl If we've packaged config.guess and config.sub, run that (since it does a
1283dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1284dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1285dnl which is useful in cross-compiles.
1286dnl
1287dnl Note: we would use $ac_config_sub, but that is one of the places where
1288dnl autoconf 2.5x broke compatibility with autoconf 2.13
1289AC_DEFUN([CF_CHECK_CACHE],
1290[
1291if test -f "$srcdir/config.guess" || test -f "$ac_aux_dir/config.guess" ; then
1292	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
1293	system_name="$host_os"
1294else
1295	system_name="`(uname -s -r) 2>/dev/null`"
1296	if test -z "$system_name" ; then
1297		system_name="`(hostname) 2>/dev/null`"
1298	fi
1299fi
1300test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
1301AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1302
1303test -z "$system_name" && system_name="$cf_cv_system_name"
1304test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1305
1306if test ".$system_name" != ".$cf_cv_system_name" ; then
1307	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
1308	AC_MSG_ERROR("Please remove config.cache and try again.")
1309fi
1310])dnl
1311dnl ---------------------------------------------------------------------------
1312dnl CF_CHECK_CFLAGS version: 4 updated: 2021/01/02 19:22:58
1313dnl ---------------
1314dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
1315dnl a build-configuration such as imake.  These have the pitfall that they
1316dnl often contain compiler-specific options which we cannot use, mixed with
1317dnl preprocessor options that we usually can.
1318AC_DEFUN([CF_CHECK_CFLAGS],
1319[
1320CF_VERBOSE(checking additions to CFLAGS)
1321cf_check_cflags="$CFLAGS"
1322cf_check_cppflags="$CPPFLAGS"
1323CF_ADD_CFLAGS($1,yes)
1324if test "x$cf_check_cflags" != "x$CFLAGS" ; then
1325AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
1326	[CF_VERBOSE(test-compile failed.  Undoing change to \$CFLAGS)
1327	 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
1328		 CF_VERBOSE(but keeping change to \$CPPFLAGS)
1329	 fi
1330	 CFLAGS="$cf_check_cflags"])
1331fi
1332])dnl
1333dnl ---------------------------------------------------------------------------
1334dnl CF_CHECK_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
1335dnl ------------------------
1336dnl Show the version of libtool
1337dnl
1338dnl Save the version in a cache variable - this is not entirely a good thing,
1339dnl but the version string from libtool is very ugly, and for bug reports it
1340dnl might be useful to have the original string.
1341AC_DEFUN([CF_CHECK_LIBTOOL_VERSION],[
1342if test -n "$LIBTOOL" && test "$LIBTOOL" != none
1343then
1344	AC_MSG_CHECKING(version of $LIBTOOL)
1345	CF_LIBTOOL_VERSION
1346	AC_MSG_RESULT($cf_cv_libtool_version)
1347	if test -z "$cf_cv_libtool_version" ; then
1348		AC_MSG_ERROR(This is not GNU libtool)
1349	fi
1350else
1351	AC_MSG_ERROR(GNU libtool has not been found)
1352fi
1353])dnl
1354dnl ---------------------------------------------------------------------------
1355dnl CF_CLANG_COMPILER version: 8 updated: 2021/01/01 13:31:04
1356dnl -----------------
1357dnl Check if the given compiler is really clang.  clang's C driver defines
1358dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
1359dnl not ignore some gcc options.
1360dnl
1361dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1362dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1363dnl the wrappers for gcc and g++ warnings.
1364dnl
1365dnl $1 = GCC (default) or GXX
1366dnl $2 = CLANG_COMPILER (default)
1367dnl $3 = CFLAGS (default) or CXXFLAGS
1368AC_DEFUN([CF_CLANG_COMPILER],[
1369ifelse([$2],,CLANG_COMPILER,[$2])=no
1370
1371if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1372	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
1373	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1374	AC_TRY_COMPILE([],[
1375#ifdef __clang__
1376#else
1377make an error
1378#endif
1379],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
1380],[])
1381	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1382	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
1383fi
1384
1385CLANG_VERSION=none
1386
1387if test "x$ifelse([$2],,CLANG_COMPILER,[$2])" = "xyes" ; then
1388	case "$CC" in
1389	(c[[1-9]][[0-9]]|*/c[[1-9]][[0-9]])
1390		AC_MSG_WARN(replacing broken compiler alias $CC)
1391		CFLAGS="$CFLAGS -std=`echo "$CC" | sed -e 's%.*/%%'`"
1392		CC=clang
1393		;;
1394	esac
1395
1396	AC_MSG_CHECKING(version of $CC)
1397	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.]].*//'`"
1398	test -z "$CLANG_VERSION" && CLANG_VERSION=unknown
1399	AC_MSG_RESULT($CLANG_VERSION)
1400
1401	for cf_clang_opt in \
1402		-Qunused-arguments \
1403		-Wno-error=implicit-function-declaration
1404	do
1405		AC_MSG_CHECKING(if option $cf_clang_opt works)
1406		cf_save_CFLAGS="$CFLAGS"
1407		CFLAGS="$CFLAGS $cf_clang_opt"
1408		AC_TRY_LINK([
1409			#include <stdio.h>],[
1410			printf("hello!\\n");],[
1411			cf_clang_optok=yes],[
1412			cf_clang_optok=no])
1413		AC_MSG_RESULT($cf_clang_optok)
1414		CFLAGS="$cf_save_CFLAGS"
1415		if test "$cf_clang_optok" = yes; then
1416			CF_VERBOSE(adding option $cf_clang_opt)
1417			CF_APPEND_TEXT(CFLAGS,$cf_clang_opt)
1418		fi
1419	done
1420fi
1421])
1422dnl ---------------------------------------------------------------------------
1423dnl CF_CONST_X_STRING version: 6 updated: 2021/01/01 13:31:04
1424dnl -----------------
1425dnl The X11R4-X11R6 Xt specification uses an ambiguous String type for most
1426dnl character-strings.
1427dnl
1428dnl It is ambiguous because the specification accommodated the pre-ANSI
1429dnl compilers bundled by more than one vendor in lieu of providing a standard C
1430dnl compiler other than by costly add-ons.  Because of this, the specification
1431dnl did not take into account the use of const for telling the compiler that
1432dnl string literals would be in readonly memory.
1433dnl
1434dnl As a workaround, one could (starting with X11R5) define XTSTRINGDEFINES, to
1435dnl let the compiler decide how to represent Xt's strings which were #define'd.
1436dnl That does not solve the problem of using the block of Xt's strings which
1437dnl are compiled into the library (and is less efficient than one might want).
1438dnl
1439dnl Xt specification 7 introduces the _CONST_X_STRING symbol which is used both
1440dnl when compiling the library and compiling using the library, to tell the
1441dnl compiler that String is const.
1442AC_DEFUN([CF_CONST_X_STRING],
1443[
1444AC_REQUIRE([AC_PATH_XTRA])
1445
1446CF_SAVE_XTRA_FLAGS([CF_CONST_X_STRING])
1447
1448AC_TRY_COMPILE(
1449[
1450#include <stdlib.h>
1451#include <X11/Intrinsic.h>
1452],
1453[String foo = malloc(1); (void)foo],[
1454
1455AC_CACHE_CHECK(for X11/Xt const-feature,cf_cv_const_x_string,[
1456	AC_TRY_COMPILE(
1457		[
1458#define _CONST_X_STRING	/* X11R7.8 (perhaps) */
1459#undef  XTSTRINGDEFINES	/* X11R5 and later */
1460#include <stdlib.h>
1461#include <X11/Intrinsic.h>
1462		],[String foo = malloc(1); *foo = 0],[
1463			cf_cv_const_x_string=no
1464		],[
1465			cf_cv_const_x_string=yes
1466		])
1467])
1468
1469CF_RESTORE_XTRA_FLAGS([CF_CONST_X_STRING])
1470
1471case "$cf_cv_const_x_string" in
1472(no)
1473	CF_APPEND_TEXT(CPPFLAGS,-DXTSTRINGDEFINES)
1474	;;
1475(*)
1476	CF_APPEND_TEXT(CPPFLAGS,-D_CONST_X_STRING)
1477	;;
1478esac
1479
1480])
1481])dnl
1482dnl ---------------------------------------------------------------------------
1483dnl CF_CURSES_CHTYPE version: 11 updated: 2021/01/02 09:31:20
1484dnl ----------------
1485dnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
1486AC_DEFUN([CF_CURSES_CHTYPE],
1487[
1488AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1489AC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[
1490	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1491		[chtype foo; (void)foo],
1492		[cf_cv_chtype_decl=yes],
1493		[cf_cv_chtype_decl=no])])
1494if test "$cf_cv_chtype_decl" = yes ; then
1495	AC_DEFINE(HAVE_TYPE_CHTYPE,1,[Define to 1 if chtype is declared])
1496	AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[
1497		AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1498			[static chtype foo; long x = foo; (void)x],
1499			[cf_cv_chtype_type=scalar],
1500			[cf_cv_chtype_type=struct])])
1501	if test "$cf_cv_chtype_type" = scalar ; then
1502		AC_DEFINE(TYPE_CHTYPE_IS_SCALAR,1,[Define to 1 if chtype is a scaler/integer])
1503	fi
1504fi
1505])dnl
1506dnl ---------------------------------------------------------------------------
1507dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
1508dnl ----------------
1509dnl Tie together the configure-script macros for curses.  It may be ncurses,
1510dnl but unless asked, we do not make a special search for ncurses.  However,
1511dnl still check for the ncurses version number, for use in other macros.
1512AC_DEFUN([CF_CURSES_CONFIG],
1513[
1514CF_CURSES_CPPFLAGS
1515CF_NCURSES_VERSION
1516CF_CURSES_LIBS
1517])dnl
1518dnl ---------------------------------------------------------------------------
1519dnl CF_CURSES_CPPFLAGS version: 14 updated: 2021/01/02 09:31:20
1520dnl ------------------
1521dnl Look for the curses headers.
1522AC_DEFUN([CF_CURSES_CPPFLAGS],[
1523
1524AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
1525cf_cv_curses_incdir=no
1526case "$host_os" in
1527(hpux10.*)
1528	if test "x$cf_cv_screen" = "xcurses_colr"
1529	then
1530		test -d /usr/include/curses_colr && \
1531		cf_cv_curses_incdir="-I/usr/include/curses_colr"
1532	fi
1533	;;
1534(sunos3*|sunos4*)
1535	if test "x$cf_cv_screen" = "xcurses_5lib"
1536	then
1537		test -d /usr/5lib && \
1538		test -d /usr/5include && \
1539		cf_cv_curses_incdir="-I/usr/5include"
1540	fi
1541	;;
1542esac
1543])
1544if test "$cf_cv_curses_incdir" != no
1545then
1546	CF_APPEND_TEXT(CPPFLAGS,$cf_cv_curses_incdir)
1547fi
1548
1549CF_CURSES_HEADER
1550CF_TERM_HEADER
1551])dnl
1552dnl ---------------------------------------------------------------------------
1553dnl CF_CURSES_EXIT version: 1 updated: 2020/03/26 19:15:16
1554dnl --------------
1555dnl Check for ncurses memory-leak/debug feature.  Starting with ncurses 6.2,
1556dnl the curses_exit() function is always present, simplifying linkage changes
1557dnl when switching to/from a debug-library.
1558AC_DEFUN([CF_CURSES_EXIT],
1559[
1560CF_CURSES_FUNCS(\
1561curses_exit \
1562_nc_free_and_exit \
1563)
1564])dnl
1565dnl ---------------------------------------------------------------------------
1566dnl CF_CURSES_FUNCS version: 20 updated: 2020/12/31 20:19:42
1567dnl ---------------
1568dnl Curses-functions are a little complicated, since a lot of them are macros.
1569AC_DEFUN([CF_CURSES_FUNCS],
1570[
1571AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1572AC_REQUIRE([CF_XOPEN_CURSES])
1573AC_REQUIRE([CF_CURSES_TERM_H])
1574AC_REQUIRE([CF_CURSES_UNCTRL_H])
1575for cf_func in $1
1576do
1577	CF_UPPER(cf_tr_func,$cf_func)
1578	AC_MSG_CHECKING(for ${cf_func})
1579	CF_MSG_LOG(${cf_func})
1580	AC_CACHE_VAL(cf_cv_func_$cf_func,[
1581		eval cf_result='$ac_cv_func_'$cf_func
1582		if test ".$cf_result" != ".no"; then
1583			AC_TRY_LINK(CF__CURSES_HEAD,
1584			[
1585#ifndef ${cf_func}
1586long foo = (long)(&${cf_func});
1587fprintf(stderr, "testing linkage of $cf_func:%p\\n", (void *)foo);
1588if (foo + 1234L > 5678L)
1589	${cf_cv_main_return:-return}(foo != 0);
1590#endif
1591			],
1592			[cf_result=yes],
1593			[cf_result=no])
1594		fi
1595		eval 'cf_cv_func_'$cf_func'="$cf_result"'
1596	])
1597	# use the computed/retrieved cache-value:
1598	eval 'cf_result=$cf_cv_func_'$cf_func
1599	AC_MSG_RESULT($cf_result)
1600	if test "$cf_result" != no; then
1601		AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
1602	fi
1603done
1604])dnl
1605dnl ---------------------------------------------------------------------------
1606dnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
1607dnl ----------------
1608dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1609dnl variations of ncurses' installs.
1610dnl
1611dnl $1 = ncurses when looking for ncurses, or is empty
1612AC_DEFUN([CF_CURSES_HEADER],[
1613AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
1614cf_cv_ncurses_header=none
1615for cf_header in \
1616	ncurses.h ifelse($1,,,[$1/ncurses.h]) \
1617	curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
1618do
1619AC_TRY_COMPILE([#include <${cf_header}>],
1620	[initscr(); tgoto("?", 0,0)],
1621	[cf_cv_ncurses_header=$cf_header; break],[])
1622done
1623])
1624
1625if test "$cf_cv_ncurses_header" = none ; then
1626	AC_MSG_ERROR(No curses header-files found)
1627fi
1628
1629# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
1630AC_CHECK_HEADERS($cf_cv_ncurses_header)
1631])dnl
1632dnl ---------------------------------------------------------------------------
1633dnl CF_CURSES_LIBS version: 44 updated: 2021/01/02 09:31:20
1634dnl --------------
1635dnl Look for the curses libraries.  Older curses implementations may require
1636dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
1637AC_DEFUN([CF_CURSES_LIBS],[
1638
1639AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1640AC_MSG_CHECKING(if we have identified curses libraries)
1641AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1642	[initscr(); tgoto("?", 0,0)],
1643	cf_result=yes,
1644	cf_result=no)
1645AC_MSG_RESULT($cf_result)
1646
1647if test "$cf_result" = no ; then
1648case "$host_os" in
1649(freebsd*)
1650	AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
1651	;;
1652(hpux10.*)
1653	# Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
1654	# next (1998), and xcurses "newer" (2000).  There is no header file for
1655	# Hcurses; the subdirectory curses_colr has the headers (curses.h and
1656	# term.h) for cur_colr
1657	if test "x$cf_cv_screen" = "xcurses_colr"
1658	then
1659		AC_CHECK_LIB(cur_colr,initscr,[
1660			CF_ADD_LIBS(-lcur_colr)
1661			ac_cv_func_initscr=yes
1662			],[
1663		AC_CHECK_LIB(Hcurses,initscr,[
1664			# HP's header uses __HP_CURSES, but user claims _HP_CURSES.
1665			CF_ADD_LIBS(-lHcurses)
1666			CF_APPEND_TEXT(CPPFLAGS,-D__HP_CURSES -D_HP_CURSES)
1667			ac_cv_func_initscr=yes
1668			])])
1669	fi
1670	;;
1671(linux*)
1672	case `arch 2>/dev/null` in
1673	(x86_64)
1674		if test -d /lib64
1675		then
1676			CF_ADD_LIBDIR(/lib64)
1677		else
1678			CF_ADD_LIBDIR(/lib)
1679		fi
1680		;;
1681	(*)
1682		CF_ADD_LIBDIR(/lib)
1683		;;
1684	esac
1685	;;
1686(sunos3*|sunos4*)
1687	if test "x$cf_cv_screen" = "xcurses_5lib"
1688	then
1689		if test -d /usr/5lib ; then
1690			CF_ADD_LIBDIR(/usr/5lib)
1691			CF_ADD_LIBS(-lcurses -ltermcap)
1692		fi
1693	fi
1694	ac_cv_func_initscr=yes
1695	;;
1696esac
1697
1698if test ".$ac_cv_func_initscr" != .yes ; then
1699	cf_save_LIBS="$LIBS"
1700
1701	if test ".${cf_cv_ncurses_version:-no}" != .no
1702	then
1703		cf_check_list="ncurses curses cursesX"
1704	else
1705		cf_check_list="cursesX curses ncurses"
1706	fi
1707
1708	# Check for library containing tgoto.  Do this before curses library
1709	# because it may be needed to link the test-case for initscr.
1710	if test "x$cf_term_lib" = x
1711	then
1712		AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
1713			for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
1714			do
1715				AC_CHECK_LIB($cf_term_lib,tgoto,[
1716					: "${cf_nculib_root:=$cf_term_lib}"
1717					break
1718				])
1719			done
1720		])
1721	fi
1722
1723	# Check for library containing initscr
1724	test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
1725	if test "x$cf_curs_lib" = x
1726	then
1727		for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
1728		do
1729			LIBS="-l$cf_curs_lib $cf_save_LIBS"
1730			if test "$cf_term_lib" = unknown || test "$cf_term_lib" = "$cf_curs_lib" ; then
1731				AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
1732				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1733					[initscr()],
1734					[cf_result=yes],
1735					[cf_result=no])
1736				AC_MSG_RESULT($cf_result)
1737				test "$cf_result" = yes && break
1738			elif test "$cf_curs_lib" = "$cf_term_lib" ; then
1739				cf_result=no
1740			elif test "$cf_term_lib" != predefined ; then
1741				AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
1742				AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1743					[initscr(); tgoto((char *)0, 0, 0);],
1744					[cf_result=no],
1745					[
1746					LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
1747					AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1748						[initscr()],
1749						[cf_result=yes],
1750						[cf_result=error])
1751					])
1752				AC_MSG_RESULT($cf_result)
1753				test "$cf_result" != error && break
1754			fi
1755		done
1756	fi
1757	test "$cf_curs_lib" = unknown && AC_MSG_ERROR(no curses library found)
1758fi
1759fi
1760
1761])dnl
1762dnl ---------------------------------------------------------------------------
1763dnl CF_CURSES_TERM_H version: 15 updated: 2021/01/02 09:31:20
1764dnl ----------------
1765dnl SVr4 curses should have term.h as well (where it puts the definitions of
1766dnl the low-level interface).  This may not be true in old/broken implementations,
1767dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
1768dnl running with Solaris 2.5.1).
1769AC_DEFUN([CF_CURSES_TERM_H],
1770[
1771AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1772
1773AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
1774
1775# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
1776# for <term.h> if we do not find the variant.
1777
1778cf_header_list="term.h ncurses/term.h ncursesw/term.h"
1779
1780case "${cf_cv_ncurses_header:-curses.h}" in
1781(*/*)
1782	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
1783	cf_header_list="$cf_header_item $cf_header_list"
1784	;;
1785esac
1786
1787for cf_header in $cf_header_list
1788do
1789	AC_TRY_COMPILE([
1790#include <${cf_cv_ncurses_header:-curses.h}>
1791#include <${cf_header}>],
1792	[WINDOW *x; (void)x],
1793	[cf_cv_term_header=$cf_header
1794	 break],
1795	[cf_cv_term_header=no])
1796done
1797
1798case "$cf_cv_term_header" in
1799(no)
1800	# If curses is ncurses, some packagers still mess it up by trying to make
1801	# us use GNU termcap.  This handles the most common case.
1802	for cf_header in ncurses/term.h ncursesw/term.h
1803	do
1804		AC_TRY_COMPILE([
1805#include <${cf_cv_ncurses_header:-curses.h}>
1806#ifdef NCURSES_VERSION
1807#include <${cf_header}>
1808#else
1809make an error
1810#endif],
1811			[WINDOW *x; (void)x],
1812			[cf_cv_term_header=$cf_header
1813			 break],
1814			[cf_cv_term_header=no])
1815	done
1816	;;
1817esac
1818])
1819
1820case "$cf_cv_term_header" in
1821(term.h)
1822	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
1823	;;
1824(ncurses/term.h)
1825	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
1826	;;
1827(ncursesw/term.h)
1828	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
1829	;;
1830esac
1831])dnl
1832dnl ---------------------------------------------------------------------------
1833dnl CF_CURSES_UNCTRL_H version: 8 updated: 2021/01/02 09:31:20
1834dnl ------------------
1835dnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
1836dnl may put it in a subdirectory (along with ncurses' other headers, of
1837dnl course).  Packages which put the headers in inconsistent locations are
1838dnl broken).
1839AC_DEFUN([CF_CURSES_UNCTRL_H],
1840[
1841AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1842
1843AC_CACHE_CHECK(for unctrl.h, cf_cv_unctrl_header,[
1844
1845# If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
1846# for <unctrl.h> if we do not find the variant.
1847
1848cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
1849
1850case "${cf_cv_ncurses_header:-curses.h}" in
1851(*/*)
1852	cf_header_item=`echo "${cf_cv_ncurses_header:-curses.h}" | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
1853	cf_header_list="$cf_header_item $cf_header_list"
1854	;;
1855esac
1856
1857for cf_header in $cf_header_list
1858do
1859	AC_TRY_COMPILE([
1860#include <${cf_cv_ncurses_header:-curses.h}>
1861#include <${cf_header}>],
1862	[WINDOW *x; (void)x],
1863	[cf_cv_unctrl_header=$cf_header
1864	 break],
1865	[cf_cv_unctrl_header=no])
1866done
1867])
1868
1869case "$cf_cv_unctrl_header" in
1870(no)
1871	AC_MSG_WARN(unctrl.h header not found)
1872	;;
1873esac
1874
1875case "$cf_cv_unctrl_header" in
1876(unctrl.h)
1877	AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
1878	;;
1879(ncurses/unctrl.h)
1880	AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
1881	;;
1882(ncursesw/unctrl.h)
1883	AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
1884	;;
1885esac
1886])dnl
1887dnl ---------------------------------------------------------------------------
1888dnl CF_CURSES_WACS_MAP version: 8 updated: 2021/01/04 19:45:09
1889dnl ------------------
1890dnl Check for likely values of wacs_map[].
1891AC_DEFUN([CF_CURSES_WACS_MAP],
1892[
1893AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
1894	cf_cv_curses_wacs_map=unknown
1895	for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
1896	do
1897	AC_TRY_LINK([
1898#ifndef _XOPEN_SOURCE_EXTENDED
1899#define _XOPEN_SOURCE_EXTENDED
1900#endif
1901#include <${cf_cv_ncurses_header:-curses.h}>],
1902	[void *foo = &(${name}['k']); (void)foo],
1903	[cf_cv_curses_wacs_map=$name
1904	 break])
1905	done])
1906
1907test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map,[Define to name of (n)curses wide-character array])
1908])dnl
1909dnl ---------------------------------------------------------------------------
1910dnl CF_CURSES_WACS_SYMBOLS version: 4 updated: 2021/01/04 19:45:09
1911dnl ----------------------
1912dnl Do a check to see if the WACS_xxx constants are defined compatibly with
1913dnl X/Open Curses.  In particular, NetBSD's implementation of the WACS_xxx
1914dnl constants is broken since those constants do not point to cchar_t's.
1915AC_DEFUN([CF_CURSES_WACS_SYMBOLS],
1916[
1917AC_REQUIRE([CF_CURSES_WACS_MAP])
1918
1919AC_CACHE_CHECK(for wide alternate character constants, cf_cv_curses_wacs_symbols,[
1920cf_cv_curses_wacs_symbols=no
1921if test "$cf_cv_curses_wacs_map" != unknown
1922then
1923	AC_TRY_LINK([
1924#ifndef _XOPEN_SOURCE_EXTENDED
1925#define _XOPEN_SOURCE_EXTENDED
1926#endif
1927#include <${cf_cv_ncurses_header:-curses.h}>],
1928	[cchar_t *foo = WACS_PLUS;
1929	 ${cf_cv_curses_wacs_map}['k'] = *WACS_PLUS; (void)foo],
1930	[cf_cv_curses_wacs_symbols=yes])
1931else
1932	AC_TRY_LINK([
1933#ifndef _XOPEN_SOURCE_EXTENDED
1934#define _XOPEN_SOURCE_EXTENDED
1935#endif
1936#include <${cf_cv_ncurses_header:-curses.h}>],
1937	[cchar_t *foo = WACS_PLUS; (void)foo],
1938	[cf_cv_curses_wacs_symbols=yes])
1939fi
1940])
1941
1942test "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS,1,[Define to 1 if (n)curses supports wide-character WACS_ symbols])
1943])dnl
1944dnl ---------------------------------------------------------------------------
1945dnl CF_CURSES_WGETPARENT version: 4 updated: 2020/03/19 20:23:48
1946dnl --------------------
1947dnl Check for curses support for directly determining the parent of a given
1948dnl window.  Some implementations make this difficult, so we provide for
1949dnl defining an application-specific function that gives this functionality.
1950dnl
1951dnl $1 = name of function to use if the feature is missing
1952AC_DEFUN([CF_CURSES_WGETPARENT],[
1953CF_CURSES_FUNCS(wgetparent)
1954if test "x$cf_cv_func_wgetparent" != xyes
1955then
1956	AC_MSG_CHECKING(if WINDOW has _parent member)
1957	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1958		[WINDOW *p = stdscr->_parent; (void)p],
1959		[cf_window__parent=yes],
1960		[cf_window__parent=no])
1961	AC_MSG_RESULT($cf_window__parent)
1962	if test "$cf_window__parent" = yes
1963	then
1964		AC_DEFINE(HAVE_WINDOW__PARENT,1,[Define to 1 if WINDOW struct has _parent member])
1965	fi
1966fi
1967])dnl
1968dnl ---------------------------------------------------------------------------
1969dnl CF_DIRNAME version: 5 updated: 2020/12/31 20:19:42
1970dnl ----------
1971dnl "dirname" is not portable, so we fake it with a shell script.
1972AC_DEFUN([CF_DIRNAME],[$1=`echo "$2" | sed -e 's%/[[^/]]*$%%'`])dnl
1973dnl ---------------------------------------------------------------------------
1974dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
1975dnl ---------------
1976dnl You can always use "make -n" to see the actual options, but it's hard to
1977dnl pick out/analyze warning messages when the compile-line is long.
1978dnl
1979dnl Sets:
1980dnl	ECHO_LT - symbol to control if libtool is verbose
1981dnl	ECHO_LD - symbol to prefix "cc -o" lines
1982dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1983dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
1984dnl	ECHO_CC - symbol to put before any "cc" line
1985dnl
1986AC_DEFUN([CF_DISABLE_ECHO],[
1987AC_MSG_CHECKING(if you want to see long compiling messages)
1988CF_ARG_DISABLE(echo,
1989	[  --disable-echo          do not display "compiling" commands],
1990	[
1991	ECHO_LT='--silent'
1992	ECHO_LD='@echo linking [$]@;'
1993	RULE_CC='@echo compiling [$]<'
1994	SHOW_CC='@echo compiling [$]@'
1995	ECHO_CC='@'
1996],[
1997	ECHO_LT=''
1998	ECHO_LD=''
1999	RULE_CC=''
2000	SHOW_CC=''
2001	ECHO_CC=''
2002])
2003AC_MSG_RESULT($enableval)
2004AC_SUBST(ECHO_LT)
2005AC_SUBST(ECHO_LD)
2006AC_SUBST(RULE_CC)
2007AC_SUBST(SHOW_CC)
2008AC_SUBST(ECHO_CC)
2009])dnl
2010dnl ---------------------------------------------------------------------------
2011dnl CF_DISABLE_LIBTOOL_VERSION version: 3 updated: 2015/04/17 21:13:04
2012dnl --------------------------
2013dnl Check if we should use the libtool 1.5 feature "-version-number" instead of
2014dnl the older "-version-info" feature.  The newer feature allows us to use
2015dnl version numbering on shared libraries which make them compatible with
2016dnl various systems.
2017AC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
2018[
2019AC_MSG_CHECKING(if libtool -version-number should be used)
2020CF_ARG_DISABLE(libtool-version,
2021	[  --disable-libtool-version  enable to use libtool's incompatible naming scheme],
2022	[cf_libtool_version=no],
2023	[cf_libtool_version=yes])
2024AC_MSG_RESULT($cf_libtool_version)
2025
2026if test "$cf_libtool_version" = yes ; then
2027	LIBTOOL_VERSION="-version-number"
2028else
2029	LIBTOOL_VERSION="-version-info"
2030	case "x$VERSION" in
2031	(x)
2032		AC_MSG_WARN(VERSION was not set)
2033		;;
2034	(x*.*.*)
2035		ABI_VERSION="$VERSION"
2036		CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
2037		;;
2038	(x*:*:*)
2039		ABI_VERSION=`echo "$VERSION" | sed -e 's/:/./g'`
2040		CF_VERBOSE(ABI_VERSION: $ABI_VERSION)
2041		;;
2042	(*)
2043		AC_MSG_WARN(unexpected VERSION value: $VERSION)
2044		;;
2045	esac
2046fi
2047
2048AC_SUBST(ABI_VERSION)
2049AC_SUBST(LIBTOOL_VERSION)
2050])dnl
2051dnl ---------------------------------------------------------------------------
2052dnl CF_DISABLE_RPATH_HACK version: 3 updated: 2021/01/05 20:14:44
2053dnl ---------------------
2054dnl The rpath-hack makes it simpler to build programs, particularly with the
2055dnl *BSD ports which may have essential libraries in unusual places.  But it
2056dnl can interfere with building an executable for the base system.  Use this
2057dnl option in that case.
2058AC_DEFUN([CF_DISABLE_RPATH_HACK],
2059[
2060AC_MSG_CHECKING(if rpath-hack should be disabled)
2061CF_ARG_DISABLE(rpath-hack,
2062	[  --disable-rpath-hack    don't add rpath options for additional libraries],
2063	[enable_rpath_hack=no],
2064	[enable_rpath_hack=yes])
2065dnl TODO - drop cf_disable_rpath_hack
2066if test "x$enable_rpath_hack" = xno; then cf_disable_rpath_hack=yes; else cf_disable_rpath_hack=no; fi
2067AC_MSG_RESULT($cf_disable_rpath_hack)
2068
2069if test "$enable_rpath_hack" = yes ; then
2070	CF_RPATH_HACK
2071fi
2072])
2073dnl ---------------------------------------------------------------------------
2074dnl CF_ENABLE_RPATH version: 2 updated: 2010/03/27 18:39:42
2075dnl ---------------
2076dnl Check if the rpath option should be used, setting cache variable
2077dnl cf_cv_enable_rpath if so.
2078AC_DEFUN([CF_ENABLE_RPATH],
2079[
2080AC_MSG_CHECKING(if rpath option should be used)
2081AC_ARG_ENABLE(rpath,
2082[  --enable-rpath          use rpath option when generating shared libraries],
2083[cf_cv_enable_rpath=$enableval],
2084[cf_cv_enable_rpath=no])
2085AC_MSG_RESULT($cf_cv_enable_rpath)
2086])dnl
2087dnl ---------------------------------------------------------------------------
2088dnl CF_ENABLE_WARNINGS version: 9 updated: 2021/01/05 19:40:50
2089dnl ------------------
2090dnl Configure-option to enable gcc warnings
2091dnl
2092dnl $1 = extra options to add, if supported
2093dnl $2 = option for checking attributes.  By default, this is done when
2094dnl      warnings are enabled.  For other values:
2095dnl      yes: always do this, e.g., to use in generated library-headers
2096dnl      no: never do this
2097AC_DEFUN([CF_ENABLE_WARNINGS],[
2098if test "$GCC" = yes || test "$GXX" = yes
2099then
2100CF_FIX_WARNINGS(CFLAGS)
2101CF_FIX_WARNINGS(CPPFLAGS)
2102CF_FIX_WARNINGS(LDFLAGS)
2103AC_MSG_CHECKING(if you want to turn on gcc warnings)
2104CF_ARG_ENABLE(warnings,
2105	[  --enable-warnings       test: turn on gcc compiler warnings],
2106	[enable_warnings=yes],
2107	[enable_warnings=no])
2108AC_MSG_RESULT($enable_warnings)
2109if test "$enable_warnings" = "yes"
2110then
2111	ifelse($2,,[CF_GCC_ATTRIBUTES])
2112	CF_GCC_WARNINGS($1)
2113fi
2114ifelse($2,yes,[CF_GCC_ATTRIBUTES])
2115fi
2116])dnl
2117dnl ---------------------------------------------------------------------------
2118dnl CF_FIND_LIBRARY version: 11 updated: 2021/01/02 09:31:20
2119dnl ---------------
2120dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
2121dnl prefer a standard location, and use -L options only if we do not find the
2122dnl library in the standard library location(s).
2123dnl	$1 = library name
2124dnl	$2 = library class, usually the same as library name
2125dnl	$3 = includes
2126dnl	$4 = code fragment to compile/link
2127dnl	$5 = corresponding function-name
2128dnl	$6 = flag, nonnull if failure should not cause an error-exit
2129dnl
2130dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
2131dnl to use a -L option.
2132AC_DEFUN([CF_FIND_LIBRARY],
2133[
2134	eval 'cf_cv_have_lib_'"$1"'=no'
2135	cf_libdir=""
2136	AC_CHECK_FUNC($5,
2137		eval 'cf_cv_have_lib_'"$1"'=yes',[
2138		cf_save_LIBS="$LIBS"
2139		AC_MSG_CHECKING(for $5 in -l$1)
2140		LIBS="-l$1 $LIBS"
2141		AC_TRY_LINK([$3],[$4],
2142			[AC_MSG_RESULT(yes)
2143			 eval 'cf_cv_have_lib_'"$1"'=yes'
2144			],
2145			[AC_MSG_RESULT(no)
2146			CF_LIBRARY_PATH(cf_search,$2)
2147			for cf_libdir in $cf_search
2148			do
2149				AC_MSG_CHECKING(for -l$1 in $cf_libdir)
2150				LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
2151				AC_TRY_LINK([$3],[$4],
2152					[AC_MSG_RESULT(yes)
2153			 		 eval 'cf_cv_have_lib_'"$1"'=yes'
2154					 break],
2155					[AC_MSG_RESULT(no)
2156					 LIBS="$cf_save_LIBS"])
2157			done
2158			])
2159		])
2160eval 'cf_found_library="[$]cf_cv_have_lib_'"$1"\"
2161ifelse($6,,[
2162if test "$cf_found_library" = no ; then
2163	AC_MSG_ERROR(Cannot link $1 library)
2164fi
2165])
2166])dnl
2167dnl ---------------------------------------------------------------------------
2168dnl CF_FIND_LINKAGE version: 22 updated: 2020/12/31 20:19:42
2169dnl ---------------
2170dnl Find a library (specifically the linkage used in the code fragment),
2171dnl searching for it if it is not already in the library path.
2172dnl See also CF_ADD_SEARCHPATH.
2173dnl
2174dnl Parameters (4-on are optional):
2175dnl     $1 = headers for library entrypoint
2176dnl     $2 = code fragment for library entrypoint
2177dnl     $3 = the library name without the "-l" option or ".so" suffix.
2178dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
2179dnl     $5 = action to perform if not successful
2180dnl     $6 = module name, if not the same as the library name
2181dnl     $7 = extra libraries
2182dnl
2183dnl Sets these variables:
2184dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
2185dnl     $cf_cv_header_path_$3 - include-directory if needed
2186dnl     $cf_cv_library_path_$3 - library-directory if needed
2187dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
2188AC_DEFUN([CF_FIND_LINKAGE],[
2189
2190# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
2191# will be set on completion of the AC_TRY_LINK below.
2192cf_cv_header_path_$3=
2193cf_cv_library_path_$3=
2194
2195CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
2196
2197cf_save_LIBS="$LIBS"
2198
2199AC_TRY_LINK([$1],[$2],[
2200	cf_cv_find_linkage_$3=yes
2201	cf_cv_header_path_$3=/usr/include
2202	cf_cv_library_path_$3=/usr/lib
2203],[
2204
2205LIBS="-l$3 $7 $cf_save_LIBS"
2206
2207AC_TRY_LINK([$1],[$2],[
2208	cf_cv_find_linkage_$3=yes
2209	cf_cv_header_path_$3=/usr/include
2210	cf_cv_library_path_$3=/usr/lib
2211	cf_cv_library_file_$3="-l$3"
2212],[
2213	cf_cv_find_linkage_$3=no
2214	LIBS="$cf_save_LIBS"
2215
2216	CF_VERBOSE(find linkage for $3 library)
2217	CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
2218
2219	cf_save_CPPFLAGS="$CPPFLAGS"
2220	cf_test_CPPFLAGS="$CPPFLAGS"
2221
2222	CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
2223	for cf_cv_header_path_$3 in $cf_search
2224	do
2225		if test -d "$cf_cv_header_path_$3" ; then
2226			CF_VERBOSE(... testing $cf_cv_header_path_$3)
2227			CPPFLAGS="$cf_save_CPPFLAGS"
2228			CF_APPEND_TEXT(CPPFLAGS,-I$cf_cv_header_path_$3)
2229			AC_TRY_COMPILE([$1],[$2],[
2230				CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
2231				cf_cv_find_linkage_$3=maybe
2232				cf_test_CPPFLAGS="$CPPFLAGS"
2233				break],[
2234				CPPFLAGS="$cf_save_CPPFLAGS"
2235				])
2236		fi
2237	done
2238
2239	if test "$cf_cv_find_linkage_$3" = maybe ; then
2240
2241		CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
2242
2243		cf_save_LIBS="$LIBS"
2244		cf_save_LDFLAGS="$LDFLAGS"
2245
2246		ifelse([$6],,,[
2247		CPPFLAGS="$cf_test_CPPFLAGS"
2248		LIBS="-l$3 $7 $cf_save_LIBS"
2249		AC_TRY_LINK([$1],[$2],[
2250			CF_VERBOSE(... found $3 library in system)
2251			cf_cv_find_linkage_$3=yes])
2252			CPPFLAGS="$cf_save_CPPFLAGS"
2253			LIBS="$cf_save_LIBS"
2254			])
2255
2256		if test "$cf_cv_find_linkage_$3" != yes ; then
2257			CF_LIBRARY_PATH(cf_search,$3)
2258			for cf_cv_library_path_$3 in $cf_search
2259			do
2260				if test -d "$cf_cv_library_path_$3" ; then
2261					CF_VERBOSE(... testing $cf_cv_library_path_$3)
2262					CPPFLAGS="$cf_test_CPPFLAGS"
2263					LIBS="-l$3 $7 $cf_save_LIBS"
2264					LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
2265					AC_TRY_LINK([$1],[$2],[
2266					CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
2267					cf_cv_find_linkage_$3=yes
2268					cf_cv_library_file_$3="-l$3"
2269					break],[
2270					CPPFLAGS="$cf_save_CPPFLAGS"
2271					LIBS="$cf_save_LIBS"
2272					LDFLAGS="$cf_save_LDFLAGS"
2273					])
2274				fi
2275			done
2276			CPPFLAGS="$cf_save_CPPFLAGS"
2277			LDFLAGS="$cf_save_LDFLAGS"
2278		fi
2279
2280	else
2281		cf_cv_find_linkage_$3=no
2282	fi
2283	],$7)
2284])
2285
2286LIBS="$cf_save_LIBS"
2287
2288if test "$cf_cv_find_linkage_$3" = yes ; then
2289ifelse([$4],,[
2290	CF_ADD_INCDIR($cf_cv_header_path_$3)
2291	CF_ADD_LIBDIR($cf_cv_library_path_$3)
2292	CF_ADD_LIB($3)
2293],[$4])
2294else
2295ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
2296fi
2297])dnl
2298dnl ---------------------------------------------------------------------------
2299dnl CF_FIX_WARNINGS version: 3 updated: 2020/12/31 18:40:20
2300dnl ---------------
2301dnl Warning flags do not belong in CFLAGS, CPPFLAGS, etc.  Any of gcc's
2302dnl "-Werror" flags can interfere with configure-checks.  Those go into
2303dnl EXTRA_CFLAGS.
2304dnl
2305dnl $1 = variable name to repair
2306define([CF_FIX_WARNINGS],[
2307if test "$GCC" = yes || test "$GXX" = yes
2308then
2309	case [$]$1 in
2310	(*-Werror=*)
2311		CF_VERBOSE(repairing $1: [$]$1)
2312		cf_temp_flags=
2313		for cf_temp_scan in [$]$1
2314		do
2315			case "x$cf_temp_scan" in
2316			(x-Werror=*)
2317				CF_APPEND_TEXT(EXTRA_CFLAGS,$cf_temp_scan)
2318				;;
2319			(*)
2320				CF_APPEND_TEXT(cf_temp_flags,$cf_temp_scan)
2321				;;
2322			esac
2323		done
2324		$1="$cf_temp_flags"
2325		CF_VERBOSE(... fixed [$]$1)
2326		CF_VERBOSE(... extra $EXTRA_CFLAGS)
2327		;;
2328	esac
2329fi
2330AC_SUBST(EXTRA_CFLAGS)
2331])dnl
2332dnl ---------------------------------------------------------------------------
2333dnl CF_FORGET_TOOL version: 1 updated: 2013/04/06 18:03:09
2334dnl --------------
2335dnl Forget that we saw the given tool.
2336AC_DEFUN([CF_FORGET_TOOL],[
2337unset ac_cv_prog_ac_ct_$1
2338unset ac_ct_$1
2339unset $1
2340])dnl
2341dnl ---------------------------------------------------------------------------
2342dnl CF_FUNC_WAIT version: 4 updated: 2021/01/02 09:31:20
2343dnl ------------
2344dnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
2345dnl and/or 'waitpid()'.
2346dnl
2347dnl Note that we cannot simply grep for 'union wait' in the wait.h file,
2348dnl because some Posix systems turn this on only when a BSD variable is
2349dnl defined.
2350dnl
2351dnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
2352dnl would conflict with an attempt to test that header directly.
2353dnl
2354AC_DEFUN([CF_FUNC_WAIT],
2355[
2356AC_REQUIRE([CF_UNION_WAIT])
2357if test "$cf_cv_type_unionwait" = yes; then
2358
2359	AC_MSG_CHECKING(if union wait can be used as wait-arg)
2360	AC_CACHE_VAL(cf_cv_arg_union_wait,[
2361		AC_TRY_COMPILE($cf_wait_headers,
2362 			[union wait x; wait(&x)],
2363			[cf_cv_arg_union_wait=yes],
2364			[cf_cv_arg_union_wait=no])
2365		])
2366	AC_MSG_RESULT($cf_cv_arg_union_wait)
2367	test "$cf_cv_arg_union_wait" = yes && AC_DEFINE(WAIT_USES_UNION,1,[Define to 1 if wait() uses a union parameter])
2368
2369	AC_MSG_CHECKING(if union wait can be used as waitpid-arg)
2370	AC_CACHE_VAL(cf_cv_arg_union_waitpid,[
2371		AC_TRY_COMPILE($cf_wait_headers,
2372 			[union wait x; waitpid(0, &x, 0)],
2373			[cf_cv_arg_union_waitpid=yes],
2374			[cf_cv_arg_union_waitpid=no])
2375		])
2376	AC_MSG_RESULT($cf_cv_arg_union_waitpid)
2377	test "$cf_cv_arg_union_waitpid" = yes && AC_DEFINE(WAITPID_USES_UNION,1,[Define to 1 if waitpid() uses a union parameter])
2378
2379fi
2380])dnl
2381dnl ---------------------------------------------------------------------------
2382dnl CF_GCC_ATTRIBUTES version: 23 updated: 2021/01/03 18:30:50
2383dnl -----------------
2384dnl Test for availability of useful gcc __attribute__ directives to quiet
2385dnl compiler warnings.  Though useful, not all are supported -- and contrary
2386dnl to documentation, unrecognized directives cause older compilers to barf.
2387AC_DEFUN([CF_GCC_ATTRIBUTES],
2388[AC_REQUIRE([AC_PROG_FGREP])dnl
2389
2390if test "$GCC" = yes || test "$GXX" = yes
2391then
2392cat > conftest.i <<EOF
2393#ifndef GCC_PRINTF
2394#define GCC_PRINTF 0
2395#endif
2396#ifndef GCC_SCANF
2397#define GCC_SCANF 0
2398#endif
2399#ifndef GCC_NORETURN
2400#define GCC_NORETURN /* nothing */
2401#endif
2402#ifndef GCC_UNUSED
2403#define GCC_UNUSED /* nothing */
2404#endif
2405EOF
2406if test "$GCC" = yes
2407then
2408	AC_CHECKING([for $CC __attribute__ directives])
2409cat > "conftest.$ac_ext" <<EOF
2410#line __oline__ "${as_me:-configure}"
2411#include "confdefs.h"
2412#include "conftest.h"
2413#include "conftest.i"
2414#if	GCC_PRINTF
2415#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
2416#else
2417#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
2418#endif
2419#if	GCC_SCANF
2420#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
2421#else
2422#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
2423#endif
2424extern void wow(char *,...) GCC_SCANFLIKE(1,2);
2425extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
2426extern void foo(void) GCC_NORETURN;
2427int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { (void)argc; (void)argv; return 0; }
2428EOF
2429	cf_printf_attribute=no
2430	cf_scanf_attribute=no
2431	for cf_attribute in scanf printf unused noreturn
2432	do
2433		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
2434		cf_directive="__attribute__(($cf_attribute))"
2435		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
2436
2437		case "$cf_attribute" in
2438		(printf)
2439			cf_printf_attribute=yes
2440			cat >conftest.h <<EOF
2441#define GCC_$cf_ATTRIBUTE 1
2442EOF
2443			;;
2444		(scanf)
2445			cf_scanf_attribute=yes
2446			cat >conftest.h <<EOF
2447#define GCC_$cf_ATTRIBUTE 1
2448EOF
2449			;;
2450		(*)
2451			cat >conftest.h <<EOF
2452#define GCC_$cf_ATTRIBUTE $cf_directive
2453EOF
2454			;;
2455		esac
2456
2457		if AC_TRY_EVAL(ac_compile); then
2458			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
2459			cat conftest.h >>confdefs.h
2460			case "$cf_attribute" in
2461			(noreturn)
2462				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
2463				;;
2464			(printf)
2465				cf_value='/* nothing */'
2466				if test "$cf_printf_attribute" != no ; then
2467					cf_value='__attribute__((format(printf,fmt,var)))'
2468					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
2469				fi
2470				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
2471				;;
2472			(scanf)
2473				cf_value='/* nothing */'
2474				if test "$cf_scanf_attribute" != no ; then
2475					cf_value='__attribute__((format(scanf,fmt,var)))'
2476					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
2477				fi
2478				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
2479				;;
2480			(unused)
2481				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
2482				;;
2483			esac
2484		fi
2485	done
2486else
2487	${FGREP-fgrep} define conftest.i >>confdefs.h
2488fi
2489rm -rf ./conftest*
2490fi
2491])dnl
2492dnl ---------------------------------------------------------------------------
2493dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
2494dnl --------------
2495dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
2496dnl compatible), attempt to determine if icc/clang is actually used.
2497AC_DEFUN([CF_GCC_VERSION],[
2498AC_REQUIRE([AC_PROG_CC])
2499GCC_VERSION=none
2500if test "$GCC" = yes ; then
2501	AC_MSG_CHECKING(version of $CC)
2502	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.]].*//'`"
2503	test -z "$GCC_VERSION" && GCC_VERSION=unknown
2504	AC_MSG_RESULT($GCC_VERSION)
2505fi
2506CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
2507CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
2508])dnl
2509dnl ---------------------------------------------------------------------------
2510dnl CF_GCC_WARNINGS version: 41 updated: 2021/01/01 16:53:59
2511dnl ---------------
2512dnl Check if the compiler supports useful warning options.  There's a few that
2513dnl we don't use, simply because they're too noisy:
2514dnl
2515dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
2516dnl	-Winline (usually not worthwhile)
2517dnl	-Wredundant-decls (system headers make this too noisy)
2518dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
2519dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
2520dnl		is enabled for ncurses using "--enable-const".
2521dnl	-pedantic
2522dnl
2523dnl Parameter:
2524dnl	$1 is an optional list of gcc warning flags that a particular
2525dnl		application might want to use, e.g., "no-unused" for
2526dnl		-Wno-unused
2527dnl Special:
2528dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
2529dnl
2530AC_DEFUN([CF_GCC_WARNINGS],
2531[
2532AC_REQUIRE([CF_GCC_VERSION])
2533if test "x$have_x" = xyes; then CF_CONST_X_STRING fi
2534cat > "conftest.$ac_ext" <<EOF
2535#line __oline__ "${as_me:-configure}"
2536int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
2537EOF
2538if test "$INTEL_COMPILER" = yes
2539then
2540# The "-wdXXX" options suppress warnings:
2541# remark #1419: external declaration in primary source file
2542# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2543# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
2544# remark #193: zero used for undefined preprocessing identifier
2545# remark #593: variable "curs_sb_left_arrow" was set but never used
2546# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
2547# remark #869: parameter "tw" was never referenced
2548# remark #981: operands are evaluated in unspecified order
2549# warning #279: controlling expression is constant
2550
2551	AC_CHECKING([for $CC warning options])
2552	cf_save_CFLAGS="$CFLAGS"
2553	EXTRA_CFLAGS="$EXTRA_CFLAGS -Wall"
2554	for cf_opt in \
2555		wd1419 \
2556		wd1683 \
2557		wd1684 \
2558		wd193 \
2559		wd593 \
2560		wd279 \
2561		wd810 \
2562		wd869 \
2563		wd981
2564	do
2565		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2566		if AC_TRY_EVAL(ac_compile); then
2567			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2568			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2569		fi
2570	done
2571	CFLAGS="$cf_save_CFLAGS"
2572elif test "$GCC" = yes && test "$GCC_VERSION" != "unknown"
2573then
2574	AC_CHECKING([for $CC warning options])
2575	cf_save_CFLAGS="$CFLAGS"
2576	cf_warn_CONST=""
2577	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
2578	cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
2579	test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
2580	for cf_opt in W Wall \
2581		Wbad-function-cast \
2582		Wcast-align \
2583		Wcast-qual \
2584		Wdeclaration-after-statement \
2585		Wextra \
2586		Winline \
2587		Wmissing-declarations \
2588		Wmissing-prototypes \
2589		Wnested-externs \
2590		Wpointer-arith \
2591		Wshadow \
2592		Wstrict-prototypes \
2593		Wundef Wno-inline $cf_gcc_warnings $cf_warn_CONST $1
2594	do
2595		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2596		if AC_TRY_EVAL(ac_compile); then
2597			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2598			case "$cf_opt" in
2599			(Winline)
2600				case "$GCC_VERSION" in
2601				([[34]].*)
2602					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2603					continue;;
2604				esac
2605				;;
2606			(Wpointer-arith)
2607				case "$GCC_VERSION" in
2608				([[12]].*)
2609					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2610					continue;;
2611				esac
2612				;;
2613			esac
2614			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2615		fi
2616	done
2617	CFLAGS="$cf_save_CFLAGS"
2618fi
2619rm -rf ./conftest*
2620
2621AC_SUBST(EXTRA_CFLAGS)
2622])dnl
2623dnl ---------------------------------------------------------------------------
2624dnl CF_GNU_SOURCE version: 10 updated: 2018/12/10 20:09:41
2625dnl -------------
2626dnl Check if we must define _GNU_SOURCE to get a reasonable value for
2627dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
2628dnl (or misfeature) of glibc2, which breaks portability of many applications,
2629dnl since it is interwoven with GNU extensions.
2630dnl
2631dnl Well, yes we could work around it...
2632dnl
2633dnl Parameters:
2634dnl	$1 is the nominal value for _XOPEN_SOURCE
2635AC_DEFUN([CF_GNU_SOURCE],
2636[
2637cf_gnu_xopen_source=ifelse($1,,500,$1)
2638
2639AC_CACHE_CHECK(if this is the GNU C library,cf_cv_gnu_library,[
2640AC_TRY_COMPILE([#include <sys/types.h>],[
2641	#if __GLIBC__ > 0 && __GLIBC_MINOR__ >= 0
2642		return 0;
2643	#elif __NEWLIB__ > 0 && __NEWLIB_MINOR__ >= 0
2644		return 0;
2645	#else
2646	#	error not GNU C library
2647	#endif],
2648	[cf_cv_gnu_library=yes],
2649	[cf_cv_gnu_library=no])
2650])
2651
2652if test x$cf_cv_gnu_library = xyes; then
2653
2654	# With glibc 2.19 (13 years after this check was begun), _DEFAULT_SOURCE
2655	# was changed to help a little.  newlib incorporated the change about 4
2656	# years later.
2657	AC_CACHE_CHECK(if _DEFAULT_SOURCE can be used as a basis,cf_cv_gnu_library_219,[
2658		cf_save="$CPPFLAGS"
2659		CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
2660		AC_TRY_COMPILE([#include <sys/types.h>],[
2661			#if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 19) || (__GLIBC__ > 2)
2662				return 0;
2663			#elif (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 4) || (__GLIBC__ > 3)
2664				return 0;
2665			#else
2666			#	error GNU C library __GLIBC__.__GLIBC_MINOR__ is too old
2667			#endif],
2668			[cf_cv_gnu_library_219=yes],
2669			[cf_cv_gnu_library_219=no])
2670		CPPFLAGS="$cf_save"
2671	])
2672
2673	if test "x$cf_cv_gnu_library_219" = xyes; then
2674		cf_save="$CPPFLAGS"
2675		AC_CACHE_CHECK(if _XOPEN_SOURCE=$cf_gnu_xopen_source works with _DEFAULT_SOURCE,cf_cv_gnu_dftsrc_219,[
2676			CF_ADD_CFLAGS(-D_DEFAULT_SOURCE -D_XOPEN_SOURCE=$cf_gnu_xopen_source)
2677			AC_TRY_COMPILE([
2678				#include <limits.h>
2679				#include <sys/types.h>
2680				],[
2681				#if (_XOPEN_SOURCE >= $cf_gnu_xopen_source) && (MB_LEN_MAX > 1)
2682					return 0;
2683				#else
2684				#	error GNU C library is too old
2685				#endif],
2686				[cf_cv_gnu_dftsrc_219=yes],
2687				[cf_cv_gnu_dftsrc_219=no])
2688			])
2689		test "x$cf_cv_gnu_dftsrc_219" = "xyes" || CPPFLAGS="$cf_save"
2690	else
2691		cf_cv_gnu_dftsrc_219=maybe
2692	fi
2693
2694	if test "x$cf_cv_gnu_dftsrc_219" != xyes; then
2695
2696		AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
2697		AC_TRY_COMPILE([#include <sys/types.h>],[
2698			#ifndef _XOPEN_SOURCE
2699			#error	expected _XOPEN_SOURCE to be defined
2700			#endif],
2701			[cf_cv_gnu_source=no],
2702			[cf_save="$CPPFLAGS"
2703			 CF_ADD_CFLAGS(-D_GNU_SOURCE)
2704			 AC_TRY_COMPILE([#include <sys/types.h>],[
2705				#ifdef _XOPEN_SOURCE
2706				#error	expected _XOPEN_SOURCE to be undefined
2707				#endif],
2708				[cf_cv_gnu_source=no],
2709				[cf_cv_gnu_source=yes])
2710			CPPFLAGS="$cf_save"
2711			])
2712		])
2713
2714		if test "$cf_cv_gnu_source" = yes
2715		then
2716		AC_CACHE_CHECK(if we should also define _DEFAULT_SOURCE,cf_cv_default_source,[
2717			CF_APPEND_TEXT(CPPFLAGS,-D_GNU_SOURCE)
2718			AC_TRY_COMPILE([#include <sys/types.h>],[
2719				#ifdef _DEFAULT_SOURCE
2720				#error	expected _DEFAULT_SOURCE to be undefined
2721				#endif],
2722				[cf_cv_default_source=no],
2723				[cf_cv_default_source=yes])
2724			])
2725			if test "$cf_cv_default_source" = yes
2726			then
2727				CF_APPEND_TEXT(CPPFLAGS,-D_DEFAULT_SOURCE)
2728			fi
2729		fi
2730	fi
2731
2732fi
2733])dnl
2734dnl ---------------------------------------------------------------------------
2735dnl CF_HEADERS_SH version: 1 updated: 2007/07/04 15:37:05
2736dnl -------------
2737dnl Setup variables needed to construct headers-sh
2738AC_DEFUN([CF_HEADERS_SH],[
2739PACKAGE_PREFIX=$1
2740PACKAGE_CONFIG=$2
2741AC_SUBST(PACKAGE_PREFIX)
2742AC_SUBST(PACKAGE_CONFIG)
2743EXTRA_OUTPUT="$EXTRA_OUTPUT headers-sh:$srcdir/headers-sh.in"
2744])
2745dnl ---------------------------------------------------------------------------
2746dnl CF_HEADER_PATH version: 15 updated: 2021/01/01 13:31:04
2747dnl --------------
2748dnl Construct a search-list of directories for a nonstandard header-file
2749dnl
2750dnl Parameters
2751dnl	$1 = the variable to return as result
2752dnl	$2 = the package name
2753AC_DEFUN([CF_HEADER_PATH],
2754[
2755$1=
2756
2757# collect the current set of include-directories from compiler flags
2758cf_header_path_list=""
2759if test -n "${CFLAGS}${CPPFLAGS}" ; then
2760	for cf_header_path in $CPPFLAGS $CFLAGS
2761	do
2762		case "$cf_header_path" in
2763		(-I*)
2764			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
2765			CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
2766			cf_header_path_list="$cf_header_path_list [$]$1"
2767			;;
2768		esac
2769	done
2770fi
2771
2772# add the variations for the package we are looking for
2773CF_SUBDIR_PATH($1,$2,include)
2774
2775test "$includedir" != NONE && \
2776test "$includedir" != "/usr/include" && \
2777test -d "$includedir" && {
2778	test -d "$includedir" &&    $1="[$]$1 $includedir"
2779	test -d "$includedir/$2" && $1="[$]$1 $includedir/$2"
2780}
2781
2782test "$oldincludedir" != NONE && \
2783test "$oldincludedir" != "/usr/include" && \
2784test -d "$oldincludedir" && {
2785	test -d "$oldincludedir"    && $1="[$]$1 $oldincludedir"
2786	test -d "$oldincludedir/$2" && $1="[$]$1 $oldincludedir/$2"
2787}
2788
2789$1="[$]$1 $cf_header_path_list"
2790])dnl
2791dnl ---------------------------------------------------------------------------
2792dnl CF_INTEL_COMPILER version: 8 updated: 2021/01/01 16:53:59
2793dnl -----------------
2794dnl Check if the given compiler is really the Intel compiler for Linux.  It
2795dnl tries to imitate gcc, but does not return an error when it finds a mismatch
2796dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2797dnl
2798dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2799dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2800dnl the wrappers for gcc and g++ warnings.
2801dnl
2802dnl $1 = GCC (default) or GXX
2803dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2804dnl $3 = CFLAGS (default) or CXXFLAGS
2805AC_DEFUN([CF_INTEL_COMPILER],[
2806AC_REQUIRE([AC_CANONICAL_HOST])
2807ifelse([$2],,INTEL_COMPILER,[$2])=no
2808
2809if test "$ifelse([$1],,[$1],GCC)" = yes ; then
2810	case "$host_os" in
2811	(linux*|gnu*)
2812		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
2813		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
2814		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
2815		AC_TRY_COMPILE([],[
2816#ifdef __INTEL_COMPILER
2817#else
2818make an error
2819#endif
2820],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
2821cf_save_CFLAGS="$cf_save_CFLAGS -we147"
2822],[])
2823		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
2824		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
2825		;;
2826	esac
2827fi
2828])dnl
2829dnl ---------------------------------------------------------------------------
2830dnl CF_LARGEFILE version: 12 updated: 2020/03/19 20:23:48
2831dnl ------------
2832dnl Add checks for large file support.
2833AC_DEFUN([CF_LARGEFILE],[
2834ifdef([AC_FUNC_FSEEKO],[
2835	AC_SYS_LARGEFILE
2836	if test "$enable_largefile" != no ; then
2837	AC_FUNC_FSEEKO
2838
2839	# Normally we would collect these definitions in the config.h,
2840	# but (like _XOPEN_SOURCE), some environments rely on having these
2841	# defined before any of the system headers are included.  Another
2842	# case comes up with C++, e.g., on AIX the compiler compiles the
2843	# header files by themselves before looking at the body files it is
2844	# told to compile.  For ncurses, those header files do not include
2845	# the config.h
2846	if test "$ac_cv_sys_large_files" != no
2847	then
2848		CF_APPEND_TEXT(CPPFLAGS,-D_LARGE_FILES)
2849	fi
2850	if test "$ac_cv_sys_largefile_source" != no
2851	then
2852		CF_APPEND_TEXT(CPPFLAGS,-D_LARGEFILE_SOURCE)
2853	fi
2854	if test "$ac_cv_sys_file_offset_bits" != no
2855	then
2856		CF_APPEND_TEXT(CPPFLAGS,-D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits)
2857	fi
2858
2859	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2860		AC_TRY_COMPILE([
2861#pragma GCC diagnostic error "-Wincompatible-pointer-types"
2862#include <sys/types.h>
2863#include <dirent.h>
2864		],[
2865		/* if transitional largefile support is setup, this is true */
2866		extern struct dirent64 * readdir(DIR *);
2867		struct dirent64 *x = readdir((DIR *)0);
2868		struct dirent *y = readdir((DIR *)0);
2869		int z = x - y;
2870		(void)z;
2871		],
2872		[cf_cv_struct_dirent64=yes],
2873		[cf_cv_struct_dirent64=no])
2874	])
2875	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64])
2876	fi
2877])
2878])
2879dnl ---------------------------------------------------------------------------
2880dnl CF_LD_RPATH_OPT version: 9 updated: 2021/01/01 13:31:04
2881dnl ---------------
2882dnl For the given system and compiler, find the compiler flags to pass to the
2883dnl loader to use the "rpath" feature.
2884AC_DEFUN([CF_LD_RPATH_OPT],
2885[
2886AC_REQUIRE([CF_CHECK_CACHE])
2887
2888LD_RPATH_OPT=
2889if test "x$cf_cv_enable_rpath" != xno
2890then
2891	AC_MSG_CHECKING(for an rpath option)
2892	case "$cf_cv_system_name" in
2893	(irix*)
2894		if test "$GCC" = yes; then
2895			LD_RPATH_OPT="-Wl,-rpath,"
2896		else
2897			LD_RPATH_OPT="-rpath "
2898		fi
2899		;;
2900	(linux*|gnu*|k*bsd*-gnu|freebsd*)
2901		LD_RPATH_OPT="-Wl,-rpath,"
2902		;;
2903	(openbsd[[2-9]].*|mirbsd*)
2904		LD_RPATH_OPT="-Wl,-rpath,"
2905		;;
2906	(dragonfly*)
2907		LD_RPATH_OPT="-rpath "
2908		;;
2909	(netbsd*)
2910		LD_RPATH_OPT="-Wl,-rpath,"
2911		;;
2912	(osf*|mls+*)
2913		LD_RPATH_OPT="-rpath "
2914		;;
2915	(solaris2*)
2916		LD_RPATH_OPT="-R"
2917		;;
2918	(*)
2919		;;
2920	esac
2921	AC_MSG_RESULT($LD_RPATH_OPT)
2922
2923	case "x$LD_RPATH_OPT" in
2924	(x-R*)
2925		AC_MSG_CHECKING(if we need a space after rpath option)
2926		cf_save_LIBS="$LIBS"
2927		CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
2928		AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2929		LIBS="$cf_save_LIBS"
2930		AC_MSG_RESULT($cf_rpath_space)
2931		test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
2932		;;
2933	esac
2934fi
2935])dnl
2936dnl ---------------------------------------------------------------------------
2937dnl CF_LD_SEARCHPATH version: 2 updated: 2019/09/26 20:34:14
2938dnl ----------------
2939dnl Try to obtain the linker's search-path, for use in scripts.
2940dnl
2941dnl Ignore LD_LIBRARY_PATH, etc.
2942AC_DEFUN([CF_LD_SEARCHPATH],[
2943AC_CACHE_CHECK(for linker search path,cf_cv_ld_searchpath,[
2944
2945if test "$cross_compiling" != yes ; then
2946
2947# GNU binutils' ld does not involve permissions which may stop ldconfig.
2948cf_pathlist=`ld --verbose 2>/dev/null | grep SEARCH_DIR | sed -e 's,SEARCH_DIR[[("=]][[("=]]*,,g' -e 's/"[[)]];//gp' | sort -u`
2949
2950# The -NX options tell newer versions of Linux ldconfig to not attempt to
2951# update the cache, which makes it run faster.
2952test -z "$cf_pathlist" && \
2953	cf_pathlist=`ldconfig -NX -v 2>/dev/null | sed -e '/^[[ 	]]/d' -e 's/:$//' | sort -u`
2954
2955test -z "$cf_pathlist" &&
2956	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e '/^[[ 	]]/d' -e 's/:$//p' | sort -u`
2957
2958# This works with OpenBSD 6.5, which lists only filenames
2959test -z "$cf_pathlist" &&
2960	cf_pathlist=`ldconfig -v 2>/dev/null | sed -n -e 's,^Adding \(.*\)/.*[$],\1,p' | sort -u`
2961
2962if test -z "$cf_pathlist"
2963then
2964	# dyld default path with MacOS
2965	if test -f /usr/bin/otool && test "x`uname -s`" = xDarwin
2966	then
2967		# do this to bypass check
2968		cf_cv_ld_searchpath='$HOME/lib'
2969		cf_pathlist="/usr/local/lib /lib /usr/lib"
2970	fi
2971fi
2972
2973if test -z "$cf_pathlist"
2974then
2975	# Solaris is hardcoded
2976	if test -d /opt/SUNWspro/lib
2977	then
2978		cf_pathlist="/opt/SUNWspro/lib /usr/ccs/lib /usr/lib"
2979	elif test -d /usr/ccs/lib
2980	then
2981		cf_pathlist="/usr/ccs/lib /usr/lib"
2982	fi
2983fi
2984
2985fi
2986
2987# If nothing else, assume it is conventional
2988test -z "$cf_pathlist" && cf_pathlist="/usr/lib /lib"
2989
2990# Finally, check that this is only directories
2991for cf_path in [$]0 $cf_pathlist
2992do
2993	if test -d "$cf_path"; then
2994		test -n "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath="${cf_cv_ld_searchpath} "
2995		cf_cv_ld_searchpath="${cf_cv_ld_searchpath}${cf_path}"
2996	fi
2997done
2998
2999# Ensure that it is nonempty
3000test -z "$cf_cv_ld_searchpath" && cf_cv_ld_searchpath=/usr/lib
3001])
3002
3003LD_SEARCHPATH=`echo "$cf_cv_ld_searchpath"|sed -e 's/ /|/g'`
3004AC_SUBST(LD_SEARCHPATH)
3005])dnl
3006dnl ---------------------------------------------------------------------------
3007dnl CF_LIBRARY_PATH version: 11 updated: 2021/01/01 13:31:04
3008dnl ---------------
3009dnl Construct a search-list of directories for a nonstandard library-file
3010dnl
3011dnl Parameters
3012dnl	$1 = the variable to return as result
3013dnl	$2 = the package name
3014AC_DEFUN([CF_LIBRARY_PATH],
3015[
3016$1=
3017cf_library_path_list=""
3018if test -n "${LDFLAGS}${LIBS}" ; then
3019	for cf_library_path in $LDFLAGS $LIBS
3020	do
3021		case "$cf_library_path" in
3022		(-L*)
3023			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
3024			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
3025			cf_library_path_list="$cf_library_path_list [$]$1"
3026			;;
3027		esac
3028	done
3029fi
3030
3031CF_SUBDIR_PATH($1,$2,lib)
3032
3033$1="$cf_library_path_list [$]$1"
3034])dnl
3035dnl ---------------------------------------------------------------------------
3036dnl CF_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
3037dnl ------------------
3038AC_DEFUN([CF_LIBTOOL_VERSION],[
3039if test -n "$LIBTOOL" && test "$LIBTOOL" != none
3040then
3041	cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' |sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
3042else
3043	cf_cv_libtool_version=
3044fi
3045test -z "$cf_cv_libtool_version" && unset cf_cv_libtool_version
3046])dnl
3047dnl ---------------------------------------------------------------------------
3048dnl CF_LIB_PREFIX version: 14 updated: 2021/01/01 13:31:04
3049dnl -------------
3050dnl Compute the library-prefix for the given host system
3051dnl $1 = variable to set
3052define([CF_LIB_PREFIX],
3053[
3054	case "$cf_cv_system_name" in
3055	(OS/2*|os2*)
3056		if test "$DFT_LWR_MODEL" = libtool; then
3057			LIB_PREFIX='lib'
3058		else
3059			LIB_PREFIX=''
3060		fi
3061		;;
3062	(*-msvc*)
3063		LIB_PREFIX=''
3064		;;
3065	(*)	LIB_PREFIX='lib'
3066		;;
3067	esac
3068ifelse($1,,,[$1=$LIB_PREFIX])
3069	AC_SUBST(LIB_PREFIX)
3070])dnl
3071dnl ---------------------------------------------------------------------------
3072dnl CF_LIB_SUFFIX version: 28 updated: 2021/01/01 16:53:59
3073dnl -------------
3074dnl Compute the library file-suffix from the given model name
3075dnl $1 = model name
3076dnl $2 = variable to set (the nominal library suffix)
3077dnl $3 = dependency variable to set (actual filename)
3078dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
3079AC_DEFUN([CF_LIB_SUFFIX],
3080[
3081	case X$1 in
3082	(Xlibtool)
3083		$2='.la'
3084		$3=[$]$2
3085		;;
3086	(Xdebug)
3087		case "$cf_cv_system_name" in
3088		(*-msvc*)
3089			$2='_g.lib'
3090			;;
3091		(*)
3092			$2='_g.a'
3093			;;
3094		esac
3095		$3=[$]$2
3096		;;
3097	(Xprofile)
3098		case "$cf_cv_system_name" in
3099		(*-msvc*)
3100			$2='_p.lib'
3101			;;
3102		(*)
3103			$2='_p.a'
3104			;;
3105		esac
3106		$3=[$]$2
3107		;;
3108	(Xshared)
3109		case "$cf_cv_system_name" in
3110		(aix[[5-7]]*)
3111			$2='.so'
3112			$3=[$]$2
3113			;;
3114		(*-msvc*)
3115			$2='.dll'
3116			$3='.dll.lib'
3117			;;
3118		(cygwin*|msys*|mingw*)
3119			$2='.dll'
3120			$3='.dll.a'
3121			;;
3122		(darwin*)
3123			$2='.dylib'
3124			$3=[$]$2
3125			;;
3126		(hpux*)
3127			case "$target" in
3128			(ia64*)
3129				$2='.so'
3130				$3=[$]$2
3131				;;
3132			(*)
3133				$2='.sl'
3134				$3=[$]$2
3135				;;
3136			esac
3137			;;
3138		(*)
3139			$2='.so'
3140			$3=[$]$2
3141			;;
3142		esac
3143		;;
3144	(*)
3145		case "$target" in
3146		(*-msvc*)
3147			$2='.lib'
3148			;;
3149		(*)
3150			$2='.a'
3151			;;
3152		esac
3153		$3=[$]$2
3154		;;
3155	esac
3156	if test -n "${LIB_SUFFIX}${EXTRA_SUFFIX}"
3157	then
3158		$2="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$2}"
3159		$3="${LIB_SUFFIX}${EXTRA_SUFFIX}[$]{$3}"
3160	fi
3161])dnl
3162dnl ---------------------------------------------------------------------------
3163dnl CF_MAKEFLAGS version: 20 updated: 2021/01/03 19:29:49
3164dnl ------------
3165dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
3166dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
3167dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
3168dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
3169AC_DEFUN([CF_MAKEFLAGS],
3170[AC_REQUIRE([AC_PROG_FGREP])dnl
3171
3172AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
3173	cf_cv_makeflags=''
3174	for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
3175	do
3176		cat >cf_makeflags.tmp <<CF_EOF
3177SHELL = $SHELL
3178all :
3179	@ echo '.$cf_option'
3180CF_EOF
3181		cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | ${FGREP-fgrep} -v "ing directory" | sed -e 's,[[ 	]]*$,,'`
3182		case "$cf_result" in
3183		(.*k|.*kw)
3184			cf_result="`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`"
3185			case "$cf_result" in
3186			(.*CC=*)	cf_cv_makeflags=
3187				;;
3188			(*)	cf_cv_makeflags=$cf_option
3189				;;
3190			esac
3191			break
3192			;;
3193		(.-)
3194			;;
3195		(*)
3196			CF_MSG_LOG(given option \"$cf_option\", no match \"$cf_result\")
3197			;;
3198		esac
3199	done
3200	rm -f cf_makeflags.tmp
3201])
3202
3203AC_SUBST(cf_cv_makeflags)
3204])dnl
3205dnl ---------------------------------------------------------------------------
3206dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
3207dnl ------------
3208dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
3209dnl a monocase filesystem.
3210AC_DEFUN([CF_MAKE_TAGS],[
3211AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
3212
3213AC_CHECK_PROGS(CTAGS, exctags ctags)
3214AC_CHECK_PROGS(ETAGS, exetags etags)
3215
3216AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
3217
3218if test "$cf_cv_mixedcase" = yes ; then
3219	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
3220else
3221	MAKE_UPPER_TAGS=no
3222fi
3223
3224if test "$MAKE_UPPER_TAGS" = yes ; then
3225	MAKE_UPPER_TAGS=
3226else
3227	MAKE_UPPER_TAGS="#"
3228fi
3229
3230if test "$MAKE_LOWER_TAGS" = yes ; then
3231	MAKE_LOWER_TAGS=
3232else
3233	MAKE_LOWER_TAGS="#"
3234fi
3235
3236AC_SUBST(CTAGS)
3237AC_SUBST(ETAGS)
3238
3239AC_SUBST(MAKE_UPPER_TAGS)
3240AC_SUBST(MAKE_LOWER_TAGS)
3241])dnl
3242dnl ---------------------------------------------------------------------------
3243dnl CF_MATH_LIB version: 10 updated: 2020/12/31 18:40:20
3244dnl -----------
3245dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
3246dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
3247dnl AC_CHECK_LIB(m,sin), because that fails for C++.
3248AC_DEFUN([CF_MATH_LIB],
3249[
3250AC_CACHE_CHECK(if -lm needed for math functions,
3251	cf_cv_need_libm,[
3252	AC_TRY_LINK([
3253	#include <stdio.h>
3254	#include <stdlib.h>
3255	#include <math.h>
3256	],
3257	[double x = rand(); printf("result = %g\\n", ]ifelse([$2],,sin(x),$2)[)],
3258	[cf_cv_need_libm=no],
3259	[cf_cv_need_libm=yes])])
3260if test "$cf_cv_need_libm" = yes
3261then
3262ifelse($1,,[
3263	CF_ADD_LIB(m)
3264],[$1=-lm])
3265fi
3266])
3267dnl ---------------------------------------------------------------------------
3268dnl CF_MBSTATE_T version: 5 updated: 2020/03/19 20:23:48
3269dnl ------------
3270dnl Check if mbstate_t is declared, and if so, which header file.
3271dnl This (including wchar.h) is needed on Tru64 5.0 to declare mbstate_t,
3272dnl as well as include stdio.h to work around a misuse of varargs in wchar.h
3273AC_DEFUN([CF_MBSTATE_T],
3274[
3275AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_mbstate_t,[
3276AC_TRY_COMPILE([
3277#include <stdlib.h>
3278#include <stdio.h>
3279#ifdef HAVE_LIBUTF8_H
3280#include <libutf8.h>
3281#endif],
3282	[mbstate_t state; (void)state],
3283	[cf_cv_mbstate_t=no],
3284	[AC_TRY_COMPILE([
3285#include <stdlib.h>
3286#include <stdio.h>
3287#include <wchar.h>
3288#ifdef HAVE_LIBUTF8_H
3289#include <libutf8.h>
3290#endif],
3291	[mbstate_t value; (void)value],
3292	[cf_cv_mbstate_t=yes],
3293	[cf_cv_mbstate_t=unknown])])])
3294
3295if test "$cf_cv_mbstate_t" = yes ; then
3296	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
3297fi
3298
3299if test "$cf_cv_mbstate_t" != unknown ; then
3300	AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if mbstate_t is declared])
3301fi
3302])dnl
3303dnl ---------------------------------------------------------------------------
3304dnl CF_MERGE_EXTRA_CFLAGS version: 2 updated: 2021/01/02 09:31:20
3305dnl ---------------------
3306dnl CF_FIX_WARNINGS moves problematic flags into EXTRA_CFLAGS, but some scripts
3307dnl may depend on being able to override that variable at build-time.  Move it
3308dnl all back.
3309define([CF_MERGE_EXTRA_CFLAGS],[
3310if test "$GCC" = yes || test "$GXX" = yes
3311then
3312	CF_APPEND_TEXT(CFLAGS,$EXTRA_CFLAGS)
3313	EXTRA_CFLAGS=
3314fi
3315])
3316dnl ---------------------------------------------------------------------------
3317dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
3318dnl ----------------------
3319dnl Check if the file-system supports mixed-case filenames.  If we're able to
3320dnl create a lowercase name and see it as uppercase, it doesn't support that.
3321AC_DEFUN([CF_MIXEDCASE_FILENAMES],
3322[
3323AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
3324if test "$cross_compiling" = yes ; then
3325	case "$target_alias" in
3326	(*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*|darwin*)
3327		cf_cv_mixedcase=no
3328		;;
3329	(*)
3330		cf_cv_mixedcase=yes
3331		;;
3332	esac
3333else
3334	rm -f conftest CONFTEST
3335	echo test >conftest
3336	if test -f CONFTEST ; then
3337		cf_cv_mixedcase=no
3338	else
3339		cf_cv_mixedcase=yes
3340	fi
3341	rm -f conftest CONFTEST
3342fi
3343])
3344test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
3345])dnl
3346dnl ---------------------------------------------------------------------------
3347dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
3348dnl ----------
3349dnl Write a debug message to config.log, along with the line number in the
3350dnl configure script.
3351AC_DEFUN([CF_MSG_LOG],[
3352echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
3353])dnl
3354dnl ---------------------------------------------------------------------------
3355dnl CF_NCURSES_CC_CHECK version: 5 updated: 2020/12/31 20:19:42
3356dnl -------------------
3357dnl Check if we can compile with ncurses' header file
3358dnl $1 is the cache variable to set
3359dnl $2 is the header-file to include
3360dnl $3 is the root name (ncurses or ncursesw)
3361AC_DEFUN([CF_NCURSES_CC_CHECK],[
3362	AC_TRY_COMPILE([
3363]ifelse($3,ncursesw,[
3364#define _XOPEN_SOURCE_EXTENDED
3365#undef  HAVE_LIBUTF8_H	/* in case we used CF_UTF8_LIB */
3366#define HAVE_LIBUTF8_H	/* to force ncurses' header file to use cchar_t */
3367])[
3368#include <$2>],[
3369#ifdef NCURSES_VERSION
3370]ifelse($3,ncursesw,[
3371#ifndef WACS_BSSB
3372	make an error
3373#endif
3374])[
3375printf("%s\\n", NCURSES_VERSION);
3376#else
3377#ifdef __NCURSES_H
3378printf("old\\n");
3379#else
3380	make an error
3381#endif
3382#endif
3383	]
3384	,[$1=$2]
3385	,[$1=no])
3386])dnl
3387dnl ---------------------------------------------------------------------------
3388dnl CF_NCURSES_CONFIG version: 26 updated: 2021/01/03 08:05:37
3389dnl -----------------
3390dnl Tie together the configure-script macros for ncurses, preferring these in
3391dnl order:
3392dnl a) ".pc" files for pkg-config, using $NCURSES_CONFIG_PKG
3393dnl b) the "-config" script from ncurses, using $NCURSES_CONFIG
3394dnl c) just plain libraries
3395dnl
3396dnl $1 is the root library name (default: "ncurses")
3397AC_DEFUN([CF_NCURSES_CONFIG],[
3398AC_REQUIRE([CF_PKG_CONFIG])
3399cf_ncuconfig_root=ifelse($1,,ncurses,$1)
3400cf_have_ncuconfig=no
3401
3402if test "x${PKG_CONFIG:=none}" != xnone; then
3403	AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
3404	if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
3405		AC_MSG_RESULT(yes)
3406
3407		AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
3408		cf_have_ncuconfig=unknown
3409
3410		cf_save_CFLAGS="$CFLAGS"
3411		cf_save_CPPFLAGS="$CPPFLAGS"
3412		cf_save_LIBS="$LIBS"
3413
3414		cf_pkg_cflags="`$PKG_CONFIG --cflags $cf_ncuconfig_root`"
3415		cf_pkg_libs="`$PKG_CONFIG --libs $cf_ncuconfig_root`"
3416
3417		# while -W for passing linker flags is prevalent, it is not "standard".
3418		# At least one wrapper for c89/c99 (in Apple's xcode) has its own
3419		# incompatible _and_ non-standard -W option which gives an error.  Work
3420		# around that pitfall.
3421		case "x${CC}@@${cf_pkg_libs}@${cf_pkg_cflags}" in
3422		(x*c[[89]]9@@*-W*)
3423			CF_ADD_CFLAGS($cf_pkg_cflags)
3424			CF_ADD_LIBS($cf_pkg_libs)
3425
3426			AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
3427				[initscr(); mousemask(0,0); tigetstr((char *)0);],
3428				[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
3429					int main(void)
3430					{ char *xx = curses_version(); return (xx == 0); }],
3431					[cf_test_ncuconfig=yes],
3432					[cf_test_ncuconfig=no],
3433					[cf_test_ncuconfig=maybe])],
3434				[cf_test_ncuconfig=no])
3435
3436			CFLAGS="$cf_save_CFLAGS"
3437			CPPFLAGS="$cf_save_CPPFLAGS"
3438			LIBS="$cf_save_LIBS"
3439
3440			if test "x$cf_test_ncuconfig" != xyes; then
3441				cf_temp=`echo "x$cf_pkg_cflags" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
3442				cf_pkg_cflags="$cf_temp"
3443				cf_temp=`echo "x$cf_pkg_libs" | sed -e s/^x// -e 's/-W[[^ 	]]*//g'`
3444				cf_pkg_libs="$cf_temp"
3445			fi
3446			;;
3447		esac
3448
3449		CF_ADD_CFLAGS($cf_pkg_cflags)
3450		CF_ADD_LIBS($cf_pkg_libs)
3451
3452		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
3453			[initscr(); mousemask(0,0); tigetstr((char *)0);],
3454			[AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
3455				int main(void)
3456				{ char *xx = curses_version(); return (xx == 0); }],
3457				[cf_have_ncuconfig=yes],
3458				[cf_have_ncuconfig=no],
3459				[cf_have_ncuconfig=maybe])],
3460			[cf_have_ncuconfig=no])
3461		AC_MSG_RESULT($cf_have_ncuconfig)
3462		test "$cf_have_ncuconfig" = maybe && cf_have_ncuconfig=yes
3463		if test "$cf_have_ncuconfig" != "yes"
3464		then
3465			CPPFLAGS="$cf_save_CPPFLAGS"
3466			LIBS="$cf_save_LIBS"
3467			NCURSES_CONFIG_PKG=none
3468		else
3469			AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
3470			NCURSES_CONFIG_PKG=$cf_ncuconfig_root
3471			CF_TERM_HEADER
3472		fi
3473
3474	else
3475		AC_MSG_RESULT(no)
3476		NCURSES_CONFIG_PKG=none
3477	fi
3478else
3479	NCURSES_CONFIG_PKG=none
3480fi
3481
3482if test "x$cf_have_ncuconfig" = "xno"; then
3483	cf_ncurses_config="${cf_ncuconfig_root}${NCURSES_CONFIG_SUFFIX}-config"; echo "Looking for ${cf_ncurses_config}"
3484
3485	CF_ACVERSION_CHECK(2.52,
3486		[AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
3487		[AC_PATH_PROGS(NCURSES_CONFIG,  ${cf_ncurses_config} ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
3488
3489	if test "$NCURSES_CONFIG" != none ; then
3490
3491		CF_ADD_CFLAGS(`$NCURSES_CONFIG --cflags`)
3492		CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
3493
3494		# even with config script, some packages use no-override for curses.h
3495		CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
3496
3497		dnl like CF_NCURSES_CPPFLAGS
3498		AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
3499
3500		dnl like CF_NCURSES_LIBS
3501		CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
3502		AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
3503
3504		dnl like CF_NCURSES_VERSION
3505		cf_cv_ncurses_version="`$NCURSES_CONFIG --version`"
3506
3507	else
3508
3509		CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
3510		CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
3511
3512	fi
3513else
3514	NCURSES_CONFIG=none
3515fi
3516])dnl
3517dnl ---------------------------------------------------------------------------
3518dnl CF_NCURSES_CPPFLAGS version: 22 updated: 2021/01/02 09:31:20
3519dnl -------------------
3520dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
3521dnl the CPPFLAGS variable so we can include its header.
3522dnl
3523dnl The header files may be installed as either curses.h, or ncurses.h (would
3524dnl be obsolete, except that some packagers prefer this name to distinguish it
3525dnl from a "native" curses implementation).  If not installed for overwrite,
3526dnl the curses.h file would be in an ncurses subdirectory (e.g.,
3527dnl /usr/include/ncurses), but someone may have installed overwriting the
3528dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
3529dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
3530dnl the header.
3531dnl
3532dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
3533dnl is already in the include-path, don't even bother with this, since we cannot
3534dnl easily determine which file it is.  In this case, it has to be <curses.h>.
3535dnl
3536dnl The optional parameter gives the root name of the library, in case it is
3537dnl not installed as the default curses library.  That is how the
3538dnl wide-character version of ncurses is installed.
3539AC_DEFUN([CF_NCURSES_CPPFLAGS],
3540[AC_REQUIRE([CF_WITH_CURSES_DIR])
3541
3542AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
3543cf_ncuhdr_root=ifelse($1,,ncurses,$1)
3544
3545test -n "$cf_cv_curses_dir" && \
3546test "$cf_cv_curses_dir" != "no" && { \
3547  CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
3548}
3549
3550AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
3551	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
3552	{ test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw; } && cf_header_list="$cf_header_list curses.h ncurses.h"
3553	for cf_header in $cf_header_list
3554	do
3555		CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
3556		test "$cf_cv_ncurses_h" != no && break
3557	done
3558])
3559
3560CF_NCURSES_HEADER
3561CF_TERM_HEADER
3562
3563# some applications need this, but should check for NCURSES_VERSION
3564AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
3565
3566CF_NCURSES_VERSION
3567])dnl
3568dnl ---------------------------------------------------------------------------
3569dnl CF_NCURSES_HEADER version: 7 updated: 2021/01/04 19:33:05
3570dnl -----------------
3571dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
3572dnl variations of ncurses' installs.
3573dnl
3574dnl See also CF_CURSES_HEADER, which sets the same cache variable.
3575AC_DEFUN([CF_NCURSES_HEADER],[
3576
3577if test "$cf_cv_ncurses_h" != no ; then
3578	cf_cv_ncurses_header=$cf_cv_ncurses_h
3579else
3580
3581AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
3582	test -n "$verbose" && echo
3583	CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
3584	test -n "$verbose" && echo "search path $cf_search"
3585	cf_save2_CPPFLAGS="$CPPFLAGS"
3586	for cf_incdir in $cf_search
3587	do
3588		CF_ADD_INCDIR($cf_incdir)
3589		for cf_header in \
3590			ncurses.h \
3591			curses.h
3592		do
3593			CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
3594			if test "$cf_cv_ncurses_h2" != no ; then
3595				cf_cv_ncurses_h2=$cf_incdir/$cf_header
3596				test -n "$verbose" && echo $ECHO_N "	... found $ECHO_C" 1>&AC_FD_MSG
3597				break
3598			fi
3599			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
3600		done
3601		CPPFLAGS="$cf_save2_CPPFLAGS"
3602		test "$cf_cv_ncurses_h2" != no && break
3603	done
3604	test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
3605	])
3606
3607	CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
3608	cf_cv_ncurses_header="`basename "$cf_cv_ncurses_h2"`"
3609	if test "`basename "$cf_1st_incdir"`" = "$cf_ncuhdr_root" ; then
3610		cf_cv_ncurses_header="$cf_ncuhdr_root/$cf_cv_ncurses_header"
3611	fi
3612	CF_ADD_INCDIR($cf_1st_incdir)
3613
3614fi
3615
3616# Set definitions to allow ifdef'ing for ncurses.h
3617
3618case "$cf_cv_ncurses_header" in
3619(*ncurses.h)
3620	AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
3621	;;
3622esac
3623
3624case "$cf_cv_ncurses_header" in
3625(ncurses/curses.h|ncurses/ncurses.h)
3626	AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
3627	;;
3628(ncursesw/curses.h|ncursesw/ncurses.h)
3629	AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
3630	;;
3631esac
3632
3633])dnl
3634dnl ---------------------------------------------------------------------------
3635dnl CF_NCURSES_LIBS version: 20 updated: 2021/01/03 08:05:37
3636dnl ---------------
3637dnl Look for the ncurses library.  This is a little complicated on Linux,
3638dnl because it may be linked with the gpm (general purpose mouse) library.
3639dnl Some distributions have gpm linked with (bsd) curses, which makes it
3640dnl unusable with ncurses.  However, we don't want to link with gpm unless
3641dnl ncurses has a dependency, since gpm is normally set up as a shared library,
3642dnl and the linker will record a dependency.
3643dnl
3644dnl The optional parameter gives the root name of the library, in case it is
3645dnl not installed as the default curses library.  That is how the
3646dnl wide-character version of ncurses is installed.
3647AC_DEFUN([CF_NCURSES_LIBS],
3648[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
3649
3650cf_nculib_root=ifelse($1,,ncurses,$1)
3651	# This works, except for the special case where we find gpm, but
3652	# ncurses is in a nonstandard location via $LIBS, and we really want
3653	# to link gpm.
3654cf_ncurses_LIBS=""
3655cf_ncurses_SAVE="$LIBS"
3656AC_CHECK_LIB(gpm,Gpm_Open,
3657	[AC_CHECK_LIB(gpm,initscr,
3658		[LIBS="$cf_ncurses_SAVE"],
3659		[cf_ncurses_LIBS="-lgpm"])])
3660
3661case "$host_os" in
3662(freebsd*)
3663	# This is only necessary if you are linking against an obsolete
3664	# version of ncurses (but it should do no harm, since it's static).
3665	if test "$cf_nculib_root" = ncurses ; then
3666		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
3667	fi
3668	;;
3669esac
3670
3671CF_ADD_LIBS($cf_ncurses_LIBS)
3672
3673if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
3674then
3675	CF_ADD_LIBS(-l$cf_nculib_root)
3676else
3677	CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
3678		[#include <${cf_cv_ncurses_header:-curses.h}>],
3679		[initscr()],
3680		initscr)
3681fi
3682
3683if test -n "$cf_ncurses_LIBS" ; then
3684	AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
3685	cf_ncurses_SAVE="$LIBS"
3686	for p in $cf_ncurses_LIBS ; do
3687		q=`echo "$LIBS" | sed -e "s%$p %%" -e "s%$p$%%"`
3688		if test "$q" != "$LIBS" ; then
3689			LIBS="$q"
3690		fi
3691	done
3692	AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
3693		[initscr(); mousemask(0,0); tigetstr((char *)0);],
3694		[AC_MSG_RESULT(yes)],
3695		[AC_MSG_RESULT(no)
3696		 LIBS="$cf_ncurses_SAVE"])
3697fi
3698
3699CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
3700AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
3701])dnl
3702dnl ---------------------------------------------------------------------------
3703dnl CF_NCURSES_PTHREADS version: 2 updated: 2016/04/22 05:07:41
3704dnl -------------------
3705dnl Use this followup check to ensure that we link with pthreads if ncurses
3706dnl uses it.
3707AC_DEFUN([CF_NCURSES_PTHREADS],[
3708: ${cf_nculib_root:=ifelse($1,,ncurses,$1)}
3709AC_CHECK_LIB($cf_nculib_root,_nc_init_pthreads,
3710	cf_cv_ncurses_pthreads=yes,
3711	cf_cv_ncurses_pthreads=no)
3712if test "$cf_cv_ncurses_pthreads" = yes
3713then
3714	CF_ADD_LIBS(-lpthread)
3715fi
3716])dnl
3717dnl ---------------------------------------------------------------------------
3718dnl CF_NCURSES_VERSION version: 16 updated: 2020/12/31 20:19:42
3719dnl ------------------
3720dnl Check for the version of ncurses, to aid in reporting bugs, etc.
3721dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
3722dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
3723AC_DEFUN([CF_NCURSES_VERSION],
3724[
3725AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3726AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
3727	cf_cv_ncurses_version=no
3728	cf_tempfile=out$$
3729	rm -f "$cf_tempfile"
3730	AC_TRY_RUN([
3731#include <${cf_cv_ncurses_header:-curses.h}>
3732#include <stdio.h>
3733int main(void)
3734{
3735	FILE *fp = fopen("$cf_tempfile", "w");
3736#ifdef NCURSES_VERSION
3737# ifdef NCURSES_VERSION_PATCH
3738	fprintf(fp, "%s.%d\\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
3739# else
3740	fprintf(fp, "%s\\n", NCURSES_VERSION);
3741# endif
3742#else
3743# ifdef __NCURSES_H
3744	fprintf(fp, "old\\n");
3745# else
3746	make an error
3747# endif
3748#endif
3749	${cf_cv_main_return:-return}(0);
3750}],[
3751	cf_cv_ncurses_version=`cat $cf_tempfile`],,[
3752
3753	# This will not work if the preprocessor splits the line after the
3754	# Autoconf token.  The 'unproto' program does that.
3755	cat > "conftest.$ac_ext" <<EOF
3756#include <${cf_cv_ncurses_header:-curses.h}>
3757#undef Autoconf
3758#ifdef NCURSES_VERSION
3759Autoconf NCURSES_VERSION
3760#else
3761#ifdef __NCURSES_H
3762Autoconf "old"
3763#endif
3764;
3765#endif
3766EOF
3767	cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
3768	AC_TRY_EVAL(cf_try)
3769	if test -f conftest.out ; then
3770		cf_out=`sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%' conftest.out`
3771		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
3772		rm -f conftest.out
3773	fi
3774])
3775	rm -f "$cf_tempfile"
3776])
3777test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
3778])dnl
3779dnl ---------------------------------------------------------------------------
3780dnl CF_NL_LANGINFO_1STDAY version: 3 updated: 2020/03/19 20:23:48
3781dnl ---------------------
3782dnl glibc locale support has runtime extensions which might be implemented in
3783dnl other systems.
3784AC_DEFUN([CF_NL_LANGINFO_1STDAY],[
3785AC_CACHE_CHECK(if runtime has nl_langinfo support for first weekday,
3786	cf_nl_langinfo_1stday,[
3787	AC_TRY_COMPILE([
3788#include <langinfo.h>
3789#include <locale.h>
3790],[
3791	int first_weekday = nl_langinfo (_NL_TIME_FIRST_WEEKDAY)[0];
3792	long week_1stday_l = (long) nl_langinfo (_NL_TIME_WEEK_1STDAY);
3793	(void) first_weekday;
3794	(void) week_1stday_l;
3795],[cf_nl_langinfo_1stday=yes
3796],[cf_nl_langinfo_1stday=no
3797])
3798])
3799test "x$cf_nl_langinfo_1stday" = xyes && AC_DEFINE(HAVE_NL_LANGINFO_1STDAY,1,[Define to 1 if runtime has nl_langinfo support for first weekday])
3800])dnl
3801dnl ---------------------------------------------------------------------------
3802dnl CF_NO_LEAKS_OPTION version: 8 updated: 2021/01/05 20:05:09
3803dnl ------------------
3804dnl see CF_WITH_NO_LEAKS
3805AC_DEFUN([CF_NO_LEAKS_OPTION],[
3806AC_MSG_CHECKING(if you want to use $1 for testing)
3807AC_ARG_WITH($1,
3808	[$2],
3809	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
3810	 $4
3811])
3812	: "${with_cflags:=-g}"
3813	: "${enable_leaks:=no}"
3814	 with_$1=yes],
3815	[with_$1=])
3816AC_MSG_RESULT(${with_$1:-no})
3817
3818case ".$with_cflags" in
3819(.*-g*)
3820	case .$CFLAGS in
3821	(.*-g*)
3822		;;
3823	(*)
3824		CF_ADD_CFLAGS([-g])
3825		;;
3826	esac
3827	;;
3828esac
3829])dnl
3830dnl ---------------------------------------------------------------------------
3831dnl CF_NUMBER_SYNTAX version: 2 updated: 2015/04/17 21:13:04
3832dnl ----------------
3833dnl Check if the given variable is a number.  If not, report an error.
3834dnl $1 is the variable
3835dnl $2 is the message
3836AC_DEFUN([CF_NUMBER_SYNTAX],[
3837if test -n "$1" ; then
3838  case $1 in
3839  ([[0-9]]*)
3840 	;;
3841  (*)
3842	AC_MSG_ERROR($2 is not a number: $1)
3843 	;;
3844  esac
3845else
3846  AC_MSG_ERROR($2 value is empty)
3847fi
3848])dnl
3849dnl ---------------------------------------------------------------------------
3850dnl CF_OUR_MESSAGES version: 8 updated: 2021/01/02 09:31:20
3851dnl ---------------
3852dnl Check if we use the messages included with this program
3853dnl
3854dnl $1 specifies either Makefile or makefile, defaulting to the former.
3855dnl
3856dnl Sets variables which can be used to substitute in makefiles:
3857dnl	MSG_DIR_MAKE - to make ./po directory
3858dnl	SUB_MAKEFILE - makefile in ./po directory (see CF_BUNDLED_INTL)
3859dnl
3860AC_DEFUN([CF_OUR_MESSAGES],
3861[
3862cf_makefile=ifelse($1,,Makefile,$1)
3863
3864use_our_messages=no
3865if test "$USE_NLS" = yes ; then
3866if test -d "$srcdir/po" ; then
3867AC_MSG_CHECKING(if we should use included message-library)
3868	AC_ARG_ENABLE(included-msgs,
3869	[  --disable-included-msgs use included messages, for i18n support],
3870	[use_our_messages=$enableval],
3871	[use_our_messages=yes])
3872fi
3873AC_MSG_RESULT($use_our_messages)
3874fi
3875
3876MSG_DIR_MAKE="#"
3877if test "$use_our_messages" = yes
3878then
3879	SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:$srcdir/po/$cf_makefile.inn"
3880	MSG_DIR_MAKE=
3881fi
3882
3883AC_SUBST(MSG_DIR_MAKE)
3884AC_SUBST(SUB_MAKEFILE)
3885])dnl
3886dnl ---------------------------------------------------------------------------
3887dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
3888dnl ----------
3889dnl Provide a value for the $PATH and similar separator (or amend the value
3890dnl as provided in autoconf 2.5x).
3891AC_DEFUN([CF_PATHSEP],
3892[
3893	AC_MSG_CHECKING(for PATH separator)
3894	case "$cf_cv_system_name" in
3895	(os2*)	PATH_SEPARATOR=';'  ;;
3896	(*)	${PATH_SEPARATOR:=':'}  ;;
3897	esac
3898ifelse([$1],,,[$1=$PATH_SEPARATOR])
3899	AC_SUBST(PATH_SEPARATOR)
3900	AC_MSG_RESULT($PATH_SEPARATOR)
3901])dnl
3902dnl ---------------------------------------------------------------------------
3903dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
3904dnl --------------
3905dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
3906dnl begins with one of the prefix/exec_prefix variables, and then again if the
3907dnl result begins with 'NONE'.  This is necessary to work around autoconf's
3908dnl delayed evaluation of those symbols.
3909AC_DEFUN([CF_PATH_SYNTAX],[
3910if test "x$prefix" != xNONE; then
3911	cf_path_syntax="$prefix"
3912else
3913	cf_path_syntax="$ac_default_prefix"
3914fi
3915
3916case ".[$]$1" in
3917(.\[$]\(*\)*|.\'*\'*)
3918	;;
3919(..|./*|.\\*)
3920	;;
3921(.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
3922	;;
3923(.\[$]\{*prefix\}*|.\[$]\{*dir\}*)
3924	eval $1="[$]$1"
3925	case ".[$]$1" in
3926	(.NONE/*)
3927		$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
3928		;;
3929	esac
3930	;;
3931(.no|.NONE/*)
3932	$1=`echo "[$]$1" | sed -e s%NONE%$cf_path_syntax%`
3933	;;
3934(*)
3935	ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
3936	;;
3937esac
3938])dnl
3939dnl ---------------------------------------------------------------------------
3940dnl CF_PDCURSES_X11 version: 15 updated: 2021/01/02 09:31:20
3941dnl ---------------
3942dnl Configure for PDCurses' X11 library
3943AC_DEFUN([CF_PDCURSES_X11],[
3944AC_REQUIRE([CF_X_ATHENA])
3945
3946CF_ACVERSION_CHECK(2.52,
3947	[AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
3948	[AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
3949
3950if test "$XCURSES_CONFIG" != none ; then
3951
3952CF_ADD_CFLAGS(`$XCURSES_CONFIG --cflags`)
3953CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
3954
3955cf_cv_lib_XCurses=yes
3956
3957else
3958
3959LDFLAGS="$LDFLAGS $X_LIBS"
3960CF_CHECK_CFLAGS($X_CFLAGS)
3961AC_CHECK_LIB(X11,XOpenDisplay,
3962	[CF_ADD_LIBS(-lX11)],,
3963	[$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
3964AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
3965CF_ADD_LIBS(-lXCurses)
3966AC_TRY_LINK([
3967#include <xcurses.h>
3968char *XCursesProgramName = "test";
3969],[XCursesExit();],
3970[cf_cv_lib_XCurses=yes],
3971[cf_cv_lib_XCurses=no])
3972])
3973
3974fi
3975
3976if test "$cf_cv_lib_XCurses" = yes ; then
3977	AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
3978	AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
3979	AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
3980else
3981	AC_MSG_ERROR(Cannot link with XCurses)
3982fi
3983])dnl
3984dnl ---------------------------------------------------------------------------
3985dnl CF_PKG_CONFIG version: 11 updated: 2021/01/01 13:31:04
3986dnl -------------
3987dnl Check for the package-config program, unless disabled by command-line.
3988AC_DEFUN([CF_PKG_CONFIG],
3989[
3990AC_MSG_CHECKING(if you want to use pkg-config)
3991AC_ARG_WITH(pkg-config,
3992	[  --with-pkg-config{=path} enable/disable use of pkg-config],
3993	[cf_pkg_config=$withval],
3994	[cf_pkg_config=yes])
3995AC_MSG_RESULT($cf_pkg_config)
3996
3997case "$cf_pkg_config" in
3998(no)
3999	PKG_CONFIG=none
4000	;;
4001(yes)
4002	CF_ACVERSION_CHECK(2.52,
4003		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
4004		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
4005	;;
4006(*)
4007	PKG_CONFIG=$withval
4008	;;
4009esac
4010
4011test -z "$PKG_CONFIG" && PKG_CONFIG=none
4012if test "$PKG_CONFIG" != none ; then
4013	CF_PATH_SYNTAX(PKG_CONFIG)
4014elif test "x$cf_pkg_config" != xno ; then
4015	AC_MSG_WARN(pkg-config is not installed)
4016fi
4017
4018AC_SUBST(PKG_CONFIG)
4019])dnl
4020dnl ---------------------------------------------------------------------------
4021dnl CF_POSIX_C_SOURCE version: 11 updated: 2018/12/31 20:46:17
4022dnl -----------------
4023dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
4024dnl
4025dnl	POSIX.1-1990				_POSIX_SOURCE
4026dnl	POSIX.1-1990 and			_POSIX_SOURCE and
4027dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
4028dnl		Bindings Option
4029dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
4030dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
4031dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
4032dnl
4033dnl Parameters:
4034dnl	$1 is the nominal value for _POSIX_C_SOURCE
4035AC_DEFUN([CF_POSIX_C_SOURCE],
4036[AC_REQUIRE([CF_POSIX_VISIBLE])dnl
4037
4038if test "$cf_cv_posix_visible" = no; then
4039
4040cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
4041
4042cf_save_CFLAGS="$CFLAGS"
4043cf_save_CPPFLAGS="$CPPFLAGS"
4044
4045CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
4046CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
4047
4048AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
4049	CF_MSG_LOG(if the symbol is already defined go no further)
4050	AC_TRY_COMPILE([#include <sys/types.h>],[
4051#ifndef _POSIX_C_SOURCE
4052make an error
4053#endif],
4054	[cf_cv_posix_c_source=no],
4055	[cf_want_posix_source=no
4056	 case .$cf_POSIX_C_SOURCE in
4057	 (.[[12]]??*)
4058		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
4059		;;
4060	 (.2)
4061		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
4062		cf_want_posix_source=yes
4063		;;
4064	 (.*)
4065		cf_want_posix_source=yes
4066		;;
4067	 esac
4068	 if test "$cf_want_posix_source" = yes ; then
4069		AC_TRY_COMPILE([#include <sys/types.h>],[
4070#ifdef _POSIX_SOURCE
4071make an error
4072#endif],[],
4073		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
4074	 fi
4075	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
4076	 CFLAGS="$cf_trim_CFLAGS"
4077	 CPPFLAGS="$cf_trim_CPPFLAGS"
4078	 CF_APPEND_TEXT(CPPFLAGS,$cf_cv_posix_c_source)
4079	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
4080	 AC_TRY_COMPILE([#include <sys/types.h>],[
4081#ifndef _POSIX_C_SOURCE
4082make an error
4083#endif],,
4084	 [cf_cv_posix_c_source=no])
4085	 CFLAGS="$cf_save_CFLAGS"
4086	 CPPFLAGS="$cf_save_CPPFLAGS"
4087	])
4088])
4089
4090if test "$cf_cv_posix_c_source" != no ; then
4091	CFLAGS="$cf_trim_CFLAGS"
4092	CPPFLAGS="$cf_trim_CPPFLAGS"
4093	CF_ADD_CFLAGS($cf_cv_posix_c_source)
4094fi
4095
4096fi # cf_cv_posix_visible
4097
4098])dnl
4099dnl ---------------------------------------------------------------------------
4100dnl CF_POSIX_VISIBLE version: 1 updated: 2018/12/31 20:46:17
4101dnl ----------------
4102dnl POSIX documents test-macros which an application may set before any system
4103dnl headers are included to make features available.
4104dnl
4105dnl Some BSD platforms (originally FreeBSD, but copied by a few others)
4106dnl diverged from POSIX in 2002 by setting symbols which make all of the most
4107dnl recent features visible in the system header files unless the application
4108dnl overrides the corresponding test-macros.  Doing that introduces portability
4109dnl problems.
4110dnl
4111dnl This macro makes a special check for the symbols used for this, to avoid a
4112dnl conflicting definition.
4113AC_DEFUN([CF_POSIX_VISIBLE],
4114[
4115AC_CACHE_CHECK(if the POSIX test-macros are already defined,cf_cv_posix_visible,[
4116AC_TRY_COMPILE([#include <stdio.h>],[
4117#if defined(__POSIX_VISIBLE) && ((__POSIX_VISIBLE - 0L) > 0) \
4118	&& defined(__XSI_VISIBLE) && ((__XSI_VISIBLE - 0L) > 0) \
4119	&& defined(__BSD_VISIBLE) && ((__BSD_VISIBLE - 0L) > 0) \
4120	&& defined(__ISO_C_VISIBLE) && ((__ISO_C_VISIBLE - 0L) > 0)
4121#error conflicting symbols found
4122#endif
4123],[cf_cv_posix_visible=no],[cf_cv_posix_visible=yes])
4124])
4125])dnl
4126dnl ---------------------------------------------------------------------------
4127dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
4128dnl ----------
4129dnl Check for archiver "ar".
4130AC_DEFUN([CF_PROG_AR],[
4131AC_CHECK_TOOL(AR, ar, ar)
4132])
4133dnl ---------------------------------------------------------------------------
4134dnl CF_PROG_CC version: 5 updated: 2019/12/31 08:53:54
4135dnl ----------
4136dnl standard check for CC, plus followup sanity checks
4137dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
4138AC_DEFUN([CF_PROG_CC],[
4139CF_ACVERSION_CHECK(2.53,
4140	[AC_MSG_WARN(this will incorrectly handle gnatgcc choice)
4141	 AC_REQUIRE([AC_PROG_CC])],
4142	[])
4143ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
4144CF_GCC_VERSION
4145CF_ACVERSION_CHECK(2.52,
4146	[AC_PROG_CC_STDC],
4147	[CF_ANSI_CC_REQD])
4148CF_CC_ENV_FLAGS
4149])dnl
4150dnl ---------------------------------------------------------------------------
4151dnl CF_PROG_EXT version: 15 updated: 2021/01/02 09:31:20
4152dnl -----------
4153dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
4154AC_DEFUN([CF_PROG_EXT],
4155[
4156AC_REQUIRE([CF_CHECK_CACHE])
4157case "$cf_cv_system_name" in
4158(os2*)
4159	CFLAGS="$CFLAGS -Zmt"
4160	CF_APPEND_TEXT(CPPFLAGS,-D__ST_MT_ERRNO__)
4161	CXXFLAGS="$CXXFLAGS -Zmt"
4162	# autoconf's macro sets -Zexe and suffix both, which conflict:w
4163	LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
4164	ac_cv_exeext=.exe
4165	;;
4166esac
4167
4168AC_EXEEXT
4169AC_OBJEXT
4170
4171PROG_EXT="$EXEEXT"
4172AC_SUBST(PROG_EXT)
4173test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT",[Define to the program extension (normally blank)])
4174])dnl
4175dnl ---------------------------------------------------------------------------
4176dnl CF_PROG_GROFF version: 3 updated: 2018/01/07 13:16:19
4177dnl -------------
4178dnl Check if groff is available, for cases (such as html output) where nroff
4179dnl is not enough.
4180AC_DEFUN([CF_PROG_GROFF],[
4181AC_PATH_PROG(GROFF_PATH,groff,no)
4182AC_PATH_PROGS(NROFF_PATH,nroff mandoc,no)
4183AC_PATH_PROG(TBL_PATH,tbl,cat)
4184if test "x$GROFF_PATH" = xno
4185then
4186	NROFF_NOTE=
4187	GROFF_NOTE="#"
4188else
4189	NROFF_NOTE="#"
4190	GROFF_NOTE=
4191fi
4192AC_SUBST(GROFF_NOTE)
4193AC_SUBST(NROFF_NOTE)
4194])dnl
4195dnl ---------------------------------------------------------------------------
4196dnl CF_PROG_LINT version: 4 updated: 2019/11/20 18:55:37
4197dnl ------------
4198AC_DEFUN([CF_PROG_LINT],
4199[
4200AC_CHECK_PROGS(LINT, lint cppcheck splint)
4201case "x$LINT" in
4202(xcppcheck|x*/cppcheck)
4203	test -z "$LINT_OPTS" && LINT_OPTS="--enable=all"
4204	;;
4205esac
4206AC_SUBST(LINT_OPTS)
4207])dnl
4208dnl ---------------------------------------------------------------------------
4209dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
4210dnl ------------
4211dnl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
4212dnl option if it is supported.
4213AC_DEFUN([CF_PROG_LN_S],[
4214AC_PROG_LN_S
4215AC_MSG_CHECKING(if $LN_S -f options work)
4216
4217rm -f conf$$.src conf$$dst
4218echo >conf$$.dst
4219echo first >conf$$.src
4220if $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
4221	cf_prog_ln_sf=yes
4222else
4223	cf_prog_ln_sf=no
4224fi
4225rm -f conf$$.dst conf$$src
4226AC_MSG_RESULT($cf_prog_ln_sf)
4227
4228test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
4229])dnl
4230dnl ---------------------------------------------------------------------------
4231dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
4232dnl ----------------
4233dnl Remove all -U and -D options that refer to the given symbol from a list
4234dnl of C compiler options.  This works around the problem that not all
4235dnl compilers process -U and -D options from left-to-right, so a -U option
4236dnl cannot be used to cancel the effect of a preceding -D option.
4237dnl
4238dnl $1 = target (which could be the same as the source variable)
4239dnl $2 = source (including '$')
4240dnl $3 = symbol to remove
4241define([CF_REMOVE_DEFINE],
4242[
4243$1=`echo "$2" | \
4244	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
4245		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
4246])dnl
4247dnl ---------------------------------------------------------------------------
4248dnl CF_RESTORE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:47:45
4249dnl ---------------------
4250dnl Restore flags saved in CF_SAVE_XTRA_FLAGS
4251dnl $1 = name of current macro
4252define([CF_RESTORE_XTRA_FLAGS],
4253[
4254LIBS="$cf_save_LIBS_$1"
4255CFLAGS="$cf_save_CFLAGS_$1"
4256CPPFLAGS="$cf_save_CPPFLAGS_$1"
4257])dnl
4258dnl ---------------------------------------------------------------------------
4259dnl CF_RPATH_HACK version: 13 updated: 2021/01/03 18:30:50
4260dnl -------------
4261AC_DEFUN([CF_RPATH_HACK],
4262[AC_REQUIRE([AC_PROG_FGREP])dnl
4263AC_REQUIRE([CF_LD_RPATH_OPT])dnl
4264
4265AC_MSG_CHECKING(for updated LDFLAGS)
4266if test -n "$LD_RPATH_OPT" ; then
4267	AC_MSG_RESULT(maybe)
4268
4269	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
4270	cf_rpath_list="/usr/lib /lib"
4271	if test "$cf_ldd_prog" != no
4272	then
4273		cf_rpath_oops=
4274
4275AC_TRY_LINK([#include <stdio.h>],
4276		[printf("Hello");],
4277		[cf_rpath_oops=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
4278		 cf_rpath_list=`"$cf_ldd_prog" "conftest$ac_exeext" | ${FGREP-fgrep} / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
4279
4280		# If we passed the link-test, but get a "not found" on a given library,
4281		# this could be due to inept reconfiguration of gcc to make it only
4282		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
4283		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
4284		# /usr/local libraries.
4285		if test -n "$cf_rpath_oops"
4286		then
4287			for cf_rpath_src in $cf_rpath_oops
4288			do
4289				for cf_rpath_dir in \
4290					/usr/local \
4291					/usr/pkg \
4292					/opt/sfw
4293				do
4294					if test -f "$cf_rpath_dir/lib/$cf_rpath_src"
4295					then
4296						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
4297						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
4298						break
4299					fi
4300				done
4301			done
4302		fi
4303	fi
4304
4305	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4306
4307	CF_RPATH_HACK_2(LDFLAGS)
4308	CF_RPATH_HACK_2(LIBS)
4309
4310	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4311else
4312	AC_MSG_RESULT(no)
4313fi
4314AC_SUBST(EXTRA_LDFLAGS)
4315])dnl
4316dnl ---------------------------------------------------------------------------
4317dnl CF_RPATH_HACK_2 version: 8 updated: 2021/01/01 13:31:04
4318dnl ---------------
4319dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
4320dnl EXTRA_LDFLAGS for each -L option found.
4321dnl
4322dnl $cf_rpath_list contains a list of directories to ignore.
4323dnl
4324dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
4325dnl      but LIBS often has misplaced -L options.
4326AC_DEFUN([CF_RPATH_HACK_2],
4327[
4328CF_VERBOSE(...checking $1 [$]$1)
4329
4330cf_rpath_dst=
4331for cf_rpath_src in [$]$1
4332do
4333	case "$cf_rpath_src" in
4334	(-L*)
4335
4336		# check if this refers to a directory which we will ignore
4337		cf_rpath_skip=no
4338		if test -n "$cf_rpath_list"
4339		then
4340			for cf_rpath_item in $cf_rpath_list
4341			do
4342				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
4343				then
4344					cf_rpath_skip=yes
4345					break
4346				fi
4347			done
4348		fi
4349
4350		if test "$cf_rpath_skip" = no
4351		then
4352			# transform the option
4353			if test "$LD_RPATH_OPT" = "-R " ; then
4354				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
4355			else
4356				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
4357			fi
4358
4359			# if we have not already added this, add it now
4360			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
4361			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
4362			then
4363				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
4364				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
4365			fi
4366		fi
4367		;;
4368	esac
4369	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
4370done
4371$1=$cf_rpath_dst
4372
4373CF_VERBOSE(...checked $1 [$]$1)
4374AC_SUBST(EXTRA_LDFLAGS)
4375])dnl
4376dnl ---------------------------------------------------------------------------
4377dnl CF_SAVE_XTRA_FLAGS version: 1 updated: 2020/01/11 16:46:44
4378dnl ------------------
4379dnl Use this macro to save CFLAGS/CPPFLAGS/LIBS before checks against X headers
4380dnl and libraries which do not update those variables.
4381dnl
4382dnl $1 = name of current macro
4383define([CF_SAVE_XTRA_FLAGS],
4384[
4385cf_save_LIBS_$1="$LIBS"
4386cf_save_CFLAGS_$1="$CFLAGS"
4387cf_save_CPPFLAGS_$1="$CPPFLAGS"
4388LIBS="$LIBS ${X_PRE_LIBS} ${X_LIBS} ${X_EXTRA_LIBS}"
4389for cf_X_CFLAGS in $X_CFLAGS
4390do
4391	case "x$cf_X_CFLAGS" in
4392	x-[[IUD]]*)
4393		CPPFLAGS="$CPPFLAGS $cf_X_CFLAGS"
4394		;;
4395	*)
4396		CFLAGS="$CFLAGS $cf_X_CFLAGS"
4397		;;
4398	esac
4399done
4400])dnl
4401dnl ---------------------------------------------------------------------------
4402dnl CF_SHARED_OPTS version: 105 updated: 2021/01/02 17:09:14
4403dnl --------------
4404dnl --------------
4405dnl Attempt to determine the appropriate CC/LD options for creating a shared
4406dnl library.
4407dnl
4408dnl Notes:
4409dnl a) ${LOCAL_LDFLAGS} is used to link executables that will run within
4410dnl the build-tree, i.e., by making use of the libraries that are compiled in
4411dnl $rel_builddir/lib We avoid compiling-in a $rel_builddir/lib path for the
4412dnl shared library since that can lead to unexpected results at runtime.
4413dnl b) ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared
4414dnl libraries are compiled in ../../lib
4415dnl
4416dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
4417dnl to install symbolic links to the rel/abi versions of shared libraries.
4418dnl
4419dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
4420dnl version when making symbolic links.
4421dnl
4422dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
4423dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
4424dnl (ex: libncurses.so.<ver>).
4425dnl
4426dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
4427AC_DEFUN([CF_SHARED_OPTS],
4428[
4429	AC_REQUIRE([CF_LD_RPATH_OPT])
4430
4431	RM_SHARED_OPTS=
4432	LOCAL_LDFLAGS=
4433	LOCAL_LDFLAGS2=
4434	LD_SHARED_OPTS=
4435	INSTALL_LIB="-m 644"
4436	: ${rel_builddir:=.}
4437
4438	shlibdir=$libdir
4439	AC_SUBST(shlibdir)
4440
4441	MAKE_DLLS="#"
4442	AC_SUBST(MAKE_DLLS)
4443
4444	cf_cv_do_symlinks=no
4445	cf_ld_rpath_opt=
4446	test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
4447
4448	AC_MSG_CHECKING(if release/abi version should be used for shared libs)
4449	AC_ARG_WITH(shlib-version,
4450	[  --with-shlib-version=X  Specify rel or abi version for shared libs],
4451	[test -z "$withval" && withval=auto
4452	case "$withval" in
4453	(yes)
4454		cf_cv_shlib_version=auto
4455		;;
4456	(rel|abi|auto)
4457		cf_cv_shlib_version=$withval
4458		;;
4459	(*)
4460		AC_MSG_RESULT($withval)
4461		AC_MSG_ERROR([option value must be one of: rel, abi, or auto])
4462		;;
4463	esac
4464	],[cf_cv_shlib_version=auto])
4465	AC_MSG_RESULT($cf_cv_shlib_version)
4466
4467	cf_cv_rm_so_locs=no
4468	cf_try_cflags=
4469
4470	# Some less-capable ports of gcc support only -fpic
4471	CC_SHARED_OPTS=
4472
4473	cf_try_fPIC=no
4474	if test "$GCC" = yes
4475	then
4476		cf_try_fPIC=yes
4477	else
4478		case "$cf_cv_system_name" in
4479		(*linux*)	# e.g., PGI compiler
4480			cf_try_fPIC=yes
4481			;;
4482		esac
4483	fi
4484
4485	if test "$cf_try_fPIC" = yes
4486	then
4487		AC_MSG_CHECKING(which $CC option to use)
4488		cf_save_CFLAGS="$CFLAGS"
4489		for CC_SHARED_OPTS in -fPIC -fpic ''
4490		do
4491			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
4492			AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
4493		done
4494		AC_MSG_RESULT($CC_SHARED_OPTS)
4495		CFLAGS="$cf_save_CFLAGS"
4496	fi
4497
4498	cf_cv_shlib_version_infix=no
4499
4500	case "$cf_cv_system_name" in
4501	(aix4.[3-9]*|aix[[5-7]]*)
4502		if test "$GCC" = yes; then
4503			CC_SHARED_OPTS='-Wl,-brtl'
4504			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
4505		else
4506			CC_SHARED_OPTS='-brtl'
4507			# as well as '-qpic=large -G' or perhaps "-bM:SRE -bnoentry -bexpall"
4508			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -G -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
4509		fi
4510		;;
4511	(beos*)
4512		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
4513		;;
4514	(cygwin*)
4515		CC_SHARED_OPTS=
4516		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4517		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
4518		cf_cv_shlib_version=cygdll
4519		cf_cv_shlib_version_infix=cygdll
4520		shlibdir=$bindir
4521		MAKE_DLLS=
4522		cat >mk_shared_lib.sh <<-CF_EOF
4523		#!$SHELL
4524		SHARED_LIB=\[$]1
4525		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4526		shift
4527		cat <<-EOF
4528		Linking shared library
4529		** SHARED_LIB \[$]SHARED_LIB
4530		** IMPORT_LIB \[$]IMPORT_LIB
4531EOF
4532		exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
4533CF_EOF
4534		chmod +x mk_shared_lib.sh
4535		;;
4536	(msys*)
4537		CC_SHARED_OPTS=
4538		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4539		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
4540		cf_cv_shlib_version=msysdll
4541		cf_cv_shlib_version_infix=msysdll
4542		shlibdir=$bindir
4543		MAKE_DLLS=
4544		cat >mk_shared_lib.sh <<-CF_EOF
4545		#!$SHELL
4546		SHARED_LIB=\[$]1
4547		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/msys-/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4548		shift
4549		cat <<-EOF
4550		Linking shared library
4551		** SHARED_LIB \[$]SHARED_LIB
4552		** IMPORT_LIB \[$]IMPORT_LIB
4553EOF
4554		exec \[$]* ${LDFLAGS} -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
4555CF_EOF
4556		chmod +x mk_shared_lib.sh
4557		;;
4558	(darwin*)
4559		cf_try_cflags="no-cpp-precomp"
4560		CC_SHARED_OPTS="-dynamic"
4561		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
4562		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
4563		cf_cv_shlib_version_infix=yes
4564		AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
4565			cf_save_LDFLAGS=$LDFLAGS
4566			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4567			AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
4568				LDFLAGS=$cf_save_LDFLAGS])
4569		if test "$cf_cv_ldflags_search_paths_first" = yes; then
4570			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4571		fi
4572		;;
4573	(hpux[[7-8]]*)
4574		# HP-UX 8.07 ld lacks "+b" option used for libdir search-list
4575		if test "$GCC" != yes; then
4576			CC_SHARED_OPTS='+Z'
4577		fi
4578		MK_SHARED_LIB='${LD} ${LDFLAGS} -b -o $[@]'
4579		INSTALL_LIB="-m 555"
4580		;;
4581	(hpux*)
4582		# (tested with gcc 2.7.2 -- I don't have c89)
4583		if test "$GCC" = yes; then
4584			LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
4585		else
4586			CC_SHARED_OPTS='+Z'
4587			LD_SHARED_OPTS='-Wl,+b,${libdir}'
4588		fi
4589		MK_SHARED_LIB='${LD} ${LDFLAGS} +b ${libdir} -b -o $[@]'
4590		# HP-UX shared libraries must be executable, and should be
4591		# readonly to exploit a quirk in the memory manager.
4592		INSTALL_LIB="-m 555"
4593		;;
4594	(interix*)
4595		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4596		if test "$cf_cv_shlib_version" = rel; then
4597			cf_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
4598		else
4599			cf_shared_soname='`basename $[@]`'
4600		fi
4601		CC_SHARED_OPTS=
4602		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-rpath,${RPATH_LIST} -Wl,-h,'$cf_shared_soname' -o $[@]'
4603		;;
4604	(irix*)
4605		if test "$cf_cv_enable_rpath" = yes ; then
4606			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4607		fi
4608		# tested with IRIX 5.2 and 'cc'.
4609		if test "$GCC" != yes; then
4610			CC_SHARED_OPTS='-KPIC'
4611			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
4612		else
4613			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,`basename $[@]` -o $[@]'
4614		fi
4615		cf_cv_rm_so_locs=yes
4616		;;
4617	(linux*|gnu*|k*bsd*-gnu)
4618		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
4619			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
4620			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4621		fi
4622		if test "$cf_cv_enable_rpath" = yes ; then
4623			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4624		fi
4625		CF_SHARED_SONAME
4626		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4627		;;
4628	(mingw*msvc*)
4629		cf_cv_shlib_version=msvcdll
4630		cf_cv_shlib_version_infix=msvcdll
4631		shlibdir=$bindir
4632		MAKE_DLLS=
4633		if test "$DFT_LWR_MODEL" = "shared" ; then
4634			LOCAL_LDFLAGS="-link -dll"
4635			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4636			EXTRA_LDFLAGS="-link -dll $EXTRA_LDFLAGS"
4637		fi
4638		CC_SHARED_OPTS=
4639		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ ${LD} [$]{CFLAGS}'
4640		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.lib"
4641		cat >mk_shared_lib.sh <<-CF_EOF
4642		#!$SHELL
4643		SHARED_LIB=\[$]1
4644		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.lib/'\`
4645		shift
4646		my_ld=\[$]1
4647		shift
4648		cat <<-EOF
4649		Linking shared library
4650		** SHARED LIB \$SHARED_LIB
4651		** IMPORT_LIB \$IMPORT_LIB
4652EOF
4653		args=\$(echo \[$]* | sed -E "s#-l(\w*)#\1.dll.lib#g" | sed -E "s#-L(\w*)#-LIBPATH:\1#g")
4654		exec \$my_ld -DLL -IMPLIB:"\${IMPORT_LIB}" -OUT:"\${SHARED_LIB}" ${LDFLAGS} \$args
4655		mv "\${IMPORT_LIB}" "\${IMPORT_LIB}"
4656CF_EOF
4657		chmod +x mk_shared_lib.sh
4658		cat >mk_prog.sh <<-CF_EOF
4659		#!$SHELL
4660		shift
4661		# Ignore first argument (compiler) and use LD (link.exe) unconditionally
4662		LD="[$]LD"
4663		clopts=()
4664		ldopts=("/subsystem:console")
4665		libs=()
4666		isdll=0
4667		while test \[$]# -gt 0; do
4668			case "\[$]1" in
4669				-link)
4670					# ignore -link argument
4671					;;
4672				-M[[TD]] | -M[[TD]]d)
4673					# ignore runtime-library option
4674					;;
4675				-dll)
4676					isdll=1
4677					;;
4678				-W* | -w*)
4679					# ignore warnings
4680					;;
4681				-D*)
4682					clopts+=("\[$]1")
4683					;;
4684				-I*)
4685					clopts+=("\[$]1")
4686					;;
4687				-l*)
4688					libs+=("\`echo \"\[$]1\" | sed \"s/^-l//\"\`")
4689					;;
4690				-L*)
4691					ldopts+=("\`echo \"\[$]1\" | sed \"s/^-L/-LIBPATH:/\"\`")
4692					;;
4693				*.obj | *.o)
4694					ldopts+=("\[$]1")
4695					;;
4696				-Wl,*)
4697					for linkarg in \`echo '\[$]1' | sed -e 's/-Wl,//' -e 's/,/ /'\`; do
4698						ldopts+=("\[$]{linkarg}")
4699					done
4700					;;
4701				*.lib)
4702					ldopts+=("\[$]1")
4703					;;
4704				-o)
4705					shift
4706					ldopts+=("-out:\[$]1")
4707					;;
4708				*)
4709					clopts+=("\[$]1")
4710					ldopts+=("\[$]1")
4711					;;
4712			esac
4713			shift
4714		done
4715		if [[ "\$isdll" -ne 0 ]]; then
4716			for lib in \[$]{libs[[*]]}; do
4717				ldopts+=("\[$]lib.dll.lib")
4718			done
4719		else
4720			for lib in \[$]{libs[[*]]}; do
4721				ldopts+=("\[$]lib.lib")
4722			done
4723		fi
4724		cat <<-EOF
4725		Creating program
4726		** ld options:   "\[$]{ldopts[[@]]}"
4727EOF
4728		exec \[$]LD \[$]{ldopts[[@]]}
4729CF_EOF
4730		chmod +x mk_prog.sh
4731		LINK_PROGS="$SHELL ${rel_builddir}/mk_prog.sh"
4732		LINK_TESTS="$SHELL ${rel_builddir}/mk_prog.sh"
4733		;;
4734	(mingw*)
4735		cf_cv_shlib_version=mingw
4736		cf_cv_shlib_version_infix=mingw
4737		shlibdir=$bindir
4738		MAKE_DLLS=
4739		if test "$DFT_LWR_MODEL" = "shared" ; then
4740			LOCAL_LDFLAGS="-Wl,--enable-auto-import"
4741			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4742			EXTRA_LDFLAGS="-Wl,--enable-auto-import $EXTRA_LDFLAGS"
4743		fi
4744		CC_SHARED_OPTS=
4745		MK_SHARED_LIB=$SHELL' '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4746		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
4747		cat >mk_shared_lib.sh <<-CF_EOF
4748		#!$SHELL
4749		SHARED_LIB=\[$]1
4750		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4751		shift
4752		cat <<-EOF
4753		Linking shared library
4754		** SHARED_LIB \[$]SHARED_LIB
4755		** IMPORT_LIB \[$]IMPORT_LIB
4756EOF
4757		exec \[$]* ${LDFLAGS} -shared -Wl,--enable-auto-import,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
4758CF_EOF
4759		chmod +x mk_shared_lib.sh
4760		;;
4761	(openbsd[[2-9]].*|mirbsd*)
4762		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
4763			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
4764			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4765		fi
4766		if test "$cf_cv_enable_rpath" = yes ; then
4767			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4768		fi
4769		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4770		CF_SHARED_SONAME
4771		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4772		;;
4773	(nskJ*)
4774		CC_SHARED_OPTS=
4775		MK_SHARED_LIB='${LD} -Wshared -Weld=-export_all -o $[@]'
4776		;;
4777	(nskL*)
4778		CC_SHARED_OPTS=
4779		MK_SHARED_LIB='${LD} -Wshared -Wxld=-export_all -o $[@]'
4780		;;
4781	(nto-qnx*|openbsd*|freebsd[[12]].*)
4782		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4783		MK_SHARED_LIB='${LD} ${LDFLAGS} -Bshareable -o $[@]'
4784		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4785		;;
4786	(dragonfly*|freebsd*)
4787		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4788		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
4789			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
4790			LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${RPATH_LIST} $LOCAL_LDFLAGS"
4791			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4792		fi
4793		CF_SHARED_SONAME
4794		MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
4795		;;
4796	(netbsd*)
4797		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
4798		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
4799			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
4800			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4801			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
4802			if test "$cf_cv_shlib_version" = auto; then
4803			if test -f /usr/libexec/ld.elf_so; then
4804				cf_cv_shlib_version=abi
4805			else
4806				cf_cv_shlib_version=rel
4807			fi
4808			fi
4809			CF_SHARED_SONAME
4810			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
4811		else
4812			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -o $[@]'
4813		fi
4814		;;
4815	(osf*|mls+*)
4816		# tested with OSF/1 V3.2 and 'cc'
4817		# tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
4818		# link with shared libs).
4819		MK_SHARED_LIB='${LD} ${LDFLAGS} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
4820		case "$host_os" in
4821		(osf4*)
4822			MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
4823			;;
4824		esac
4825		MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
4826		if test "$DFT_LWR_MODEL" = "shared" && test -n "$LD_RPATH_OPT" ; then
4827			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
4828			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4829		fi
4830		cf_cv_rm_so_locs=yes
4831		;;
4832	(sco3.2v5*)  # also uw2* and UW7: hops 13-Apr-98
4833		# tested with osr5.0.5
4834		if test "$GCC" != yes; then
4835			CC_SHARED_OPTS='-belf -KPIC'
4836		fi
4837		MK_SHARED_LIB='${LD} ${LDFLAGS} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
4838		if test "$cf_cv_enable_rpath" = yes ; then
4839			# only way is to set LD_RUN_PATH but no switch for it
4840			RUN_PATH=$libdir
4841		fi
4842		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4843		LINK_PROGS='LD_RUN_PATH=${libdir}'
4844		LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
4845		;;
4846	(sunos4*)
4847		# tested with SunOS 4.1.1 and gcc 2.7.0
4848		if test "$GCC" != yes; then
4849			CC_SHARED_OPTS='-KPIC'
4850		fi
4851		MK_SHARED_LIB='${LD} ${LDFLAGS} -assert pure-text -o $[@]'
4852		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
4853		;;
4854	(solaris2*)
4855		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
4856		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
4857		if test "$DFT_LWR_MODEL" = "shared" ; then
4858			LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
4859			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
4860		fi
4861		if test "$cf_cv_enable_rpath" = yes ; then
4862			EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
4863		fi
4864		CF_SHARED_SONAME
4865		if test "$GCC" != yes; then
4866			cf_save_CFLAGS="$CFLAGS"
4867			for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
4868			do
4869				CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
4870				AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\\n");],[break])
4871			done
4872			CFLAGS="$cf_save_CFLAGS"
4873			CC_SHARED_OPTS=$cf_shared_opts
4874			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4875		else
4876			MK_SHARED_LIB='${CC} ${LDFLAGS} ${CFLAGS} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
4877		fi
4878		;;
4879	(sysv5uw7*|unix_sv*)
4880		# tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
4881		if test "$GCC" != yes; then
4882			CC_SHARED_OPTS='-KPIC'
4883		fi
4884		MK_SHARED_LIB='${LD} ${LDFLAGS} -d y -G -o [$]@'
4885		;;
4886	(*)
4887		CC_SHARED_OPTS='unknown'
4888		MK_SHARED_LIB='echo unknown'
4889		;;
4890	esac
4891
4892	# This works if the last tokens in $MK_SHARED_LIB are the -o target.
4893	case "$cf_cv_shlib_version" in
4894	(rel|abi)
4895		case "$MK_SHARED_LIB" in
4896		(*'-o $[@]')
4897			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
4898			;;
4899		(*)
4900			AC_MSG_WARN(ignored --with-shlib-version)
4901			;;
4902		esac
4903		;;
4904	esac
4905
4906	if test -n "$cf_try_cflags"
4907	then
4908cat > conftest.$ac_ext <<EOF
4909#line __oline__ "${as_me:-configure}"
4910#include <stdio.h>
4911int main(int argc, char *argv[[]])
4912{
4913	printf("hello\\n");
4914	return (argv[[argc-1]] == 0) ;
4915}
4916EOF
4917		cf_save_CFLAGS="$CFLAGS"
4918		for cf_opt in $cf_try_cflags
4919		do
4920			CFLAGS="$cf_save_CFLAGS -$cf_opt"
4921			AC_MSG_CHECKING(if CFLAGS option -$cf_opt works)
4922			if AC_TRY_EVAL(ac_compile); then
4923				AC_MSG_RESULT(yes)
4924				cf_save_CFLAGS="$CFLAGS"
4925			else
4926				AC_MSG_RESULT(no)
4927			fi
4928		done
4929		CFLAGS="$cf_save_CFLAGS"
4930	fi
4931
4932
4933	# RPATH_LIST is a colon-separated list of directories
4934	test -n "$cf_ld_rpath_opt" && MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${RPATH_LIST}"
4935	test -z "$RPATH_LIST" && RPATH_LIST="\${libdir}"
4936
4937	test "$cf_cv_rm_so_locs" = yes && RM_SHARED_OPTS="$RM_SHARED_OPTS so_locations"
4938
4939	CF_VERBOSE(CC_SHARED_OPTS: $CC_SHARED_OPTS)
4940	CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
4941
4942	AC_SUBST(CC_SHARED_OPTS)
4943	AC_SUBST(LD_RPATH_OPT)
4944	AC_SUBST(LD_SHARED_OPTS)
4945	AC_SUBST(MK_SHARED_LIB)
4946	AC_SUBST(RM_SHARED_OPTS)
4947
4948	AC_SUBST(LINK_PROGS)
4949	AC_SUBST(LINK_TESTS)
4950
4951	AC_SUBST(EXTRA_LDFLAGS)
4952	AC_SUBST(LOCAL_LDFLAGS)
4953	AC_SUBST(LOCAL_LDFLAGS2)
4954
4955	AC_SUBST(INSTALL_LIB)
4956	AC_SUBST(RPATH_LIST)
4957])dnl
4958dnl ---------------------------------------------------------------------------
4959dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
4960dnl ----------------
4961dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
4962dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
4963dnl option.
4964dnl
4965dnl $1 is the default that should be used for "$cf_cv_shlib_version".
4966dnl If missing, use "rel".
4967define([CF_SHARED_SONAME],
4968[
4969	test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
4970	if test "$cf_cv_shlib_version" = rel; then
4971		cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
4972	else
4973		cf_cv_shared_soname='`basename $[@]`'
4974	fi
4975])
4976dnl ---------------------------------------------------------------------------
4977dnl CF_SIZECHANGE version: 17 updated: 2021/01/01 13:31:04
4978dnl -------------
4979dnl Check for definitions & structures needed for window size-changing
4980dnl
4981dnl https://stackoverflow.com/questions/18878141/difference-between-structures-ttysize-and-winsize/50769952#50769952
4982AC_DEFUN([CF_SIZECHANGE],
4983[
4984AC_REQUIRE([CF_STRUCT_TERMIOS])
4985AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
4986	cf_cv_sizechange=unknown
4987	cf_save_CPPFLAGS="$CPPFLAGS"
4988
4989for cf_opts in "" "NEED_PTEM_H"
4990do
4991
4992	CPPFLAGS="$cf_save_CPPFLAGS"
4993	if test -n "$cf_opts"
4994	then
4995		CF_APPEND_TEXT(CPPFLAGS,-D$cf_opts)
4996	fi
4997	AC_TRY_COMPILE([#include <sys/types.h>
4998#ifdef HAVE_TERMIOS_H
4999#include <termios.h>
5000#else
5001#ifdef HAVE_TERMIO_H
5002#include <termio.h>
5003#endif
5004#endif
5005
5006#ifdef NEED_PTEM_H
5007/* This is a workaround for SCO:  they neglected to define struct winsize in
5008 * termios.h -- it's only in termio.h and ptem.h
5009 */
5010#include <sys/stream.h>
5011#include <sys/ptem.h>
5012#endif
5013
5014#ifdef HAVE_SYS_IOCTL_H
5015#include <sys/ioctl.h>
5016#endif
5017],[
5018#ifdef TIOCGSIZE
5019	struct ttysize win;	/* SunOS 3.0... */
5020	int y = win.ts_lines = 2;
5021	int x = win.ts_cols = 1;
5022	(void)y;
5023	(void)x;
5024#else
5025#ifdef TIOCGWINSZ
5026	struct winsize win;	/* everything else */
5027	int y = win.ws_row = 2;
5028	int x = win.ws_col = 1;
5029	(void)y;
5030	(void)x;
5031#else
5032	no TIOCGSIZE or TIOCGWINSZ
5033#endif /* TIOCGWINSZ */
5034#endif /* TIOCGSIZE */
5035	],
5036	[cf_cv_sizechange=yes],
5037	[cf_cv_sizechange=no])
5038
5039	CPPFLAGS="$cf_save_CPPFLAGS"
5040	if test "$cf_cv_sizechange" = yes ; then
5041		echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
5042		test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
5043		break
5044	fi
5045done
5046])
5047if test "$cf_cv_sizechange" != no ; then
5048	AC_DEFINE(HAVE_SIZECHANGE,1,[Define to 1 if sizechange declarations are provided])
5049	case "$cf_cv_sizechange" in
5050	(NEED*)
5051		AC_DEFINE_UNQUOTED($cf_cv_sizechange )
5052		;;
5053	esac
5054fi
5055])dnl
5056dnl ---------------------------------------------------------------------------
5057dnl CF_STRUCT_TERMIOS version: 11 updated: 2020/03/19 20:46:13
5058dnl -----------------
5059dnl Some machines require _POSIX_SOURCE to completely define struct termios.
5060AC_DEFUN([CF_STRUCT_TERMIOS],[
5061AC_REQUIRE([CF_XOPEN_SOURCE])
5062
5063AC_CHECK_HEADERS( \
5064termio.h \
5065termios.h \
5066unistd.h \
5067sys/ioctl.h \
5068sys/termio.h \
5069)
5070
5071if test "$ac_cv_header_termios_h" = yes ; then
5072	case "$CFLAGS $CPPFLAGS" in
5073	(*-D_POSIX_SOURCE*)
5074		termios_bad=dunno ;;
5075	(*)	termios_bad=maybe ;;
5076	esac
5077	if test "$termios_bad" = maybe ; then
5078	AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
5079	AC_TRY_COMPILE([#include <termios.h>],
5080		[struct termios foo; int x = foo.c_iflag = 1; (void)x],
5081		termios_bad=no, [
5082		AC_TRY_COMPILE([
5083#define _POSIX_SOURCE
5084#include <termios.h>],
5085			[struct termios foo; int x = foo.c_iflag = 2; (void)x],
5086			termios_bad=unknown,
5087			termios_bad=yes AC_DEFINE(_POSIX_SOURCE,1,[Define to 1 if we must define _POSIX_SOURCE]))
5088			])
5089	AC_MSG_RESULT($termios_bad)
5090	fi
5091fi
5092])dnl
5093dnl ---------------------------------------------------------------------------
5094dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
5095dnl --------------
5096dnl Construct a search-list for a nonstandard header/lib-file
5097dnl	$1 = the variable to return as result
5098dnl	$2 = the package name
5099dnl	$3 = the subdirectory, e.g., bin, include or lib
5100AC_DEFUN([CF_SUBDIR_PATH],
5101[
5102$1=
5103
5104CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
5105
5106for cf_subdir_prefix in \
5107	/usr \
5108	/usr/local \
5109	/usr/pkg \
5110	/opt \
5111	/opt/local \
5112	[$]HOME
5113do
5114	CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
5115done
5116])dnl
5117dnl ---------------------------------------------------------------------------
5118dnl CF_TERM_HEADER version: 6 updated: 2021/01/02 09:31:20
5119dnl --------------
5120dnl Look for term.h, which is part of X/Open curses.  It defines the interface
5121dnl to terminfo database.  Usually it is in the same include-path as curses.h,
5122dnl but some packagers change this, breaking various applications.
5123AC_DEFUN([CF_TERM_HEADER],[
5124AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
5125case "${cf_cv_ncurses_header}" in
5126(*/ncurses.h|*/ncursesw.h)
5127	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
5128	;;
5129(*)
5130	cf_term_header=term.h
5131	;;
5132esac
5133
5134for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
5135do
5136AC_TRY_COMPILE([#include <stdio.h>
5137#include <${cf_cv_ncurses_header:-curses.h}>
5138#include <$cf_test>
5139],[int x = auto_left_margin; (void)x],[
5140	cf_cv_term_header="$cf_test"],[
5141	cf_cv_term_header=unknown
5142	])
5143	test "$cf_cv_term_header" != unknown && break
5144done
5145])
5146
5147# Set definitions to allow ifdef'ing to accommodate subdirectories
5148
5149case "$cf_cv_term_header" in
5150(*term.h)
5151	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
5152	;;
5153esac
5154
5155case "$cf_cv_term_header" in
5156(ncurses/term.h)
5157	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
5158	;;
5159(ncursesw/term.h)
5160	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
5161	;;
5162esac
5163])dnl
5164dnl ---------------------------------------------------------------------------
5165dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
5166dnl --------------
5167dnl Trim extra base X libraries added as a workaround for inconsistent library
5168dnl dependencies returned by "new" pkg-config files.
5169AC_DEFUN([CF_TRIM_X_LIBS],[
5170	for cf_trim_lib in Xmu Xt X11
5171	do
5172		case "$LIBS" in
5173		(*-l$cf_trim_lib\ *-l$cf_trim_lib*)
5174			LIBS=`echo "$LIBS " | sed -e 's/  / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
5175			CF_VERBOSE(..trimmed $LIBS)
5176			;;
5177		esac
5178	done
5179])
5180dnl ---------------------------------------------------------------------------
5181dnl CF_TRY_PKG_CONFIG version: 6 updated: 2020/12/31 10:54:15
5182dnl -----------------
5183dnl This is a simple wrapper to use for pkg-config, for libraries which may be
5184dnl available in that form.
5185dnl
5186dnl $1 = package name, which may be a shell variable
5187dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
5188dnl $3 = logic to use if pkg-config does not have the package
5189AC_DEFUN([CF_TRY_PKG_CONFIG],[
5190AC_REQUIRE([CF_PKG_CONFIG])
5191
5192if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists "$1"; then
5193	CF_VERBOSE(found package $1)
5194	cf_pkgconfig_incs="`$PKG_CONFIG --cflags "$1" 2>/dev/null`"
5195	cf_pkgconfig_libs="`$PKG_CONFIG --libs   "$1" 2>/dev/null`"
5196	CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
5197	CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
5198	CF_ADD_CFLAGS($cf_pkgconfig_incs)
5199	CF_ADD_LIBS($cf_pkgconfig_libs)
5200	ifelse([$2],,:,[$2])
5201else
5202	cf_pkgconfig_incs=
5203	cf_pkgconfig_libs=
5204	ifelse([$3],,:,[$3])
5205fi
5206])
5207dnl ---------------------------------------------------------------------------
5208dnl CF_TRY_XOPEN_SOURCE version: 2 updated: 2018/06/20 20:23:13
5209dnl -------------------
5210dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
5211dnl can define it successfully.
5212AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
5213AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
5214	AC_TRY_COMPILE([
5215#include <stdlib.h>
5216#include <string.h>
5217#include <sys/types.h>
5218],[
5219#ifndef _XOPEN_SOURCE
5220make an error
5221#endif],
5222	[cf_cv_xopen_source=no],
5223	[cf_save="$CPPFLAGS"
5224	 CF_APPEND_TEXT(CPPFLAGS,-D_XOPEN_SOURCE=$cf_XOPEN_SOURCE)
5225	 AC_TRY_COMPILE([
5226#include <stdlib.h>
5227#include <string.h>
5228#include <sys/types.h>
5229],[
5230#ifdef _XOPEN_SOURCE
5231make an error
5232#endif],
5233	[cf_cv_xopen_source=no],
5234	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
5235	CPPFLAGS="$cf_save"
5236	])
5237])
5238
5239if test "$cf_cv_xopen_source" != no ; then
5240	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
5241	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
5242	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
5243	CF_ADD_CFLAGS($cf_temp_xopen_source)
5244fi
5245])
5246dnl ---------------------------------------------------------------------------
5247dnl CF_UNION_WAIT version: 8 updated: 2021/01/02 09:31:20
5248dnl -------------
5249dnl Check to see if the BSD-style union wait is declared.  Some platforms may
5250dnl use this, though it is deprecated in favor of the 'int' type in Posix.
5251dnl Some vendors provide a bogus implementation that declares union wait, but
5252dnl uses the 'int' type instead; we try to spot these by checking for the
5253dnl associated macros.
5254dnl
5255dnl Ahem.  Some implementers cast the status value to an int*, as an attempt to
5256dnl use the macros for either union wait or int.  So we do a check compile to
5257dnl see if the macros are defined and apply to an int.
5258dnl
5259dnl Sets: $cf_cv_type_unionwait
5260dnl Defines: HAVE_TYPE_UNIONWAIT
5261AC_DEFUN([CF_UNION_WAIT],
5262[
5263AC_REQUIRE([CF_WAIT_HEADERS])
5264AC_MSG_CHECKING([for union wait])
5265AC_CACHE_VAL(cf_cv_type_unionwait,[
5266	AC_TRY_LINK($cf_wait_headers,
5267	[int x;
5268	 int y = WEXITSTATUS(x);
5269	 int z = WTERMSIG(x);
5270	 wait(&x);
5271	 (void)x;
5272	 (void)y;
5273	 (void)z;
5274	],
5275	[cf_cv_type_unionwait=no
5276	 echo compiles ok w/o union wait 1>&AC_FD_CC
5277	],[
5278	AC_TRY_LINK($cf_wait_headers,
5279	[union wait x;
5280#ifdef WEXITSTATUS
5281	 int y = WEXITSTATUS(x);
5282#endif
5283#ifdef WTERMSIG
5284	 int z = WTERMSIG(x);
5285#endif
5286	 wait(&x);
5287	 (void)x;
5288#ifdef WEXITSTATUS
5289	 (void)y;
5290#endif
5291#ifdef WTERMSIG
5292	 (void)z;
5293#endif
5294	],
5295	[cf_cv_type_unionwait=yes
5296	 echo compiles ok with union wait and possibly macros too 1>&AC_FD_CC
5297	],
5298	[cf_cv_type_unionwait=no])])])
5299AC_MSG_RESULT($cf_cv_type_unionwait)
5300test "$cf_cv_type_unionwait" = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT,1,[Define to 1 if type unionwait is declared])
5301])dnl
5302dnl ---------------------------------------------------------------------------
5303dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
5304dnl --------
5305dnl Make an uppercase version of a variable
5306dnl $1=uppercase($2)
5307AC_DEFUN([CF_UPPER],
5308[
5309$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
5310])dnl
5311dnl ---------------------------------------------------------------------------
5312dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
5313dnl -----------
5314dnl Check for multibyte support, and if not found, utf8 compatibility library
5315AC_DEFUN([CF_UTF8_LIB],
5316[
5317AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
5318	cf_save_LIBS="$LIBS"
5319	AC_TRY_LINK([
5320#include <stdlib.h>],[putwc(0,0);],
5321	[cf_cv_utf8_lib=yes],
5322	[CF_FIND_LINKAGE([
5323#include <libutf8.h>],[putwc(0,0);],utf8,
5324		[cf_cv_utf8_lib=add-on],
5325		[cf_cv_utf8_lib=no])
5326])])
5327
5328# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
5329# ncurses/ncursesw:
5330if test "$cf_cv_utf8_lib" = "add-on" ; then
5331	AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
5332	CF_ADD_INCDIR($cf_cv_header_path_utf8)
5333	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
5334	CF_ADD_LIBS($cf_cv_library_file_utf8)
5335fi
5336])dnl
5337dnl ---------------------------------------------------------------------------
5338dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
5339dnl ----------
5340dnl Use AC_VERBOSE w/o the warnings
5341AC_DEFUN([CF_VERBOSE],
5342[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
5343CF_MSG_LOG([$1])
5344])dnl
5345dnl ---------------------------------------------------------------------------
5346dnl CF_VERSION_INFO version: 8 updated: 2021/01/01 13:31:04
5347dnl ---------------
5348dnl Define several useful symbols derived from the VERSION file.  A separate
5349dnl file is preferred to embedding the version numbers in various scripts.
5350dnl (automake is a textbook-example of why the latter is a bad idea, but there
5351dnl are others).
5352dnl
5353dnl The file contents are:
5354dnl	libtool-version	release-version	patch-version
5355dnl or
5356dnl	release-version
5357dnl where
5358dnl	libtool-version (see ?) consists of 3 integers separated by '.'
5359dnl	release-version consists of a major version and minor version
5360dnl		separated by '.', optionally followed by a patch-version
5361dnl		separated by '-'.  The minor version need not be an
5362dnl		integer (but it is preferred).
5363dnl	patch-version is an integer in the form yyyymmdd, so ifdef's and
5364dnl		scripts can easily compare versions.
5365dnl
5366dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
5367dnl simply extracts the first field using 'cut -f1'.
5368dnl
5369dnl Optional parameters:
5370dnl $1 = internal name for package
5371dnl $2 = external name for package
5372AC_DEFUN([CF_VERSION_INFO],
5373[
5374if test -f "$srcdir/VERSION" ; then
5375	AC_MSG_CHECKING(for package version)
5376
5377	# if there are not enough fields, cut returns the last one...
5378	cf_field1=`sed -e '2,$d' "$srcdir/VERSION" |cut -f1`
5379	cf_field2=`sed -e '2,$d' "$srcdir/VERSION" |cut -f2`
5380	cf_field3=`sed -e '2,$d' "$srcdir/VERSION" |cut -f3`
5381
5382	# this is how CF_BUNDLED_INTL uses $VERSION:
5383	VERSION="$cf_field1"
5384
5385	VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
5386	test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
5387
5388	VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
5389	test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
5390
5391	AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
5392
5393	AC_MSG_CHECKING(for package patch date)
5394	VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
5395	case .$VERSION_PATCH in
5396	(.)
5397		AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
5398		;;
5399	(.[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
5400		;;
5401	(*)
5402		AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
5403		;;
5404	esac
5405	AC_MSG_RESULT($VERSION_PATCH)
5406else
5407	AC_MSG_ERROR(did not find $srcdir/VERSION)
5408fi
5409
5410# show the actual data that we have for versions:
5411CF_VERBOSE(ABI VERSION $VERSION)
5412CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
5413CF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
5414CF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
5415
5416AC_SUBST(VERSION)
5417AC_SUBST(VERSION_MAJOR)
5418AC_SUBST(VERSION_MINOR)
5419AC_SUBST(VERSION_PATCH)
5420
5421dnl if a package name is given, define its corresponding version info.  We
5422dnl need the package name to ensure that the defined symbols are unique.
5423ifelse($1,,,[
5424	cf_PACKAGE=$1
5425	PACKAGE=ifelse($2,,$1,$2)
5426	AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",[Define to the package-name])
5427	AC_SUBST(PACKAGE)
5428	CF_UPPER(cf_PACKAGE,$cf_PACKAGE)
5429	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}")
5430	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH})
5431])
5432])dnl
5433dnl ---------------------------------------------------------------------------
5434dnl CF_WAIT_HEADERS version: 3 updated: 2021/01/02 09:31:20
5435dnl ---------------
5436dnl Build up an expression $cf_wait_headers with the header files needed to
5437dnl compile against the prototypes for 'wait()', 'waitpid()', etc.  Assume it's
5438dnl Posix, which uses <sys/types.h> and <sys/wait.h>, but allow SVr4 variation
5439dnl with <wait.h>.
5440AC_DEFUN([CF_WAIT_HEADERS],
5441[
5442AC_HAVE_HEADERS(sys/wait.h)
5443cf_wait_headers="#include <sys/types.h>
5444"
5445if test "$ac_cv_header_sys_wait_h" = yes; then
5446cf_wait_headers="$cf_wait_headers
5447#include <sys/wait.h>
5448"
5449else
5450AC_HAVE_HEADERS(wait.h)
5451AC_HAVE_HEADERS(waitstatus.h)
5452if test "$ac_cv_header_wait_h" = yes; then
5453cf_wait_headers="$cf_wait_headers
5454#include <wait.h>
5455"
5456fi
5457if test "$ac_cv_header_waitstatus_h" = yes; then
5458cf_wait_headers="$cf_wait_headers
5459#include <waitstatus.h>
5460"
5461fi
5462fi
5463])dnl
5464dnl ---------------------------------------------------------------------------
5465dnl CF_WIDEC_CURSES version: 6 updated: 2020/03/19 20:23:48
5466dnl ---------------
5467dnl Check for curses implementations that can handle wide-characters
5468AC_DEFUN([CF_WIDEC_CURSES],
5469[
5470AC_CACHE_CHECK(if curses supports wide characters,cf_cv_widec_curses,[
5471AC_TRY_LINK([
5472#include <stdlib.h>
5473#include <${cf_cv_ncurses_header:-curses.h}>],[
5474    wchar_t temp[2];
5475    wchar_t wch = 'A';
5476    temp[0] = wch;
5477    waddnwstr(stdscr, temp, 1);
5478],
5479[cf_cv_widec_curses=yes],
5480[cf_cv_widec_curses=no])
5481])
5482
5483if test "$cf_cv_widec_curses" = yes ; then
5484	AC_DEFINE(WIDEC_CURSES,1,[Define to 1 if curses supports wide characters])
5485
5486	# This is needed on Tru64 5.0 to declare mbstate_t
5487	AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_widec_mbstate,[
5488	AC_TRY_COMPILE([
5489#include <stdlib.h>
5490#include <${cf_cv_ncurses_header:-curses.h}>],
5491[mbstate_t state; (void)state],
5492[cf_cv_widec_mbstate=no],
5493[AC_TRY_COMPILE([
5494#include <stdlib.h>
5495#include <wchar.h>
5496#include <${cf_cv_ncurses_header:-curses.h}>],
5497[mbstate_t state; (void)state],
5498[cf_cv_widec_mbstate=yes],
5499[cf_cv_widec_mbstate=unknown])])])
5500
5501if test "$cf_cv_widec_mbstate" = yes ; then
5502	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
5503fi
5504
5505if test "$cf_cv_widec_mbstate" != unknown ; then
5506	AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if we have mbstate_t type])
5507fi
5508
5509fi
5510])dnl
5511dnl ---------------------------------------------------------------------------
5512dnl CF_WITH_ABI_VERSION version: 4 updated: 2021/01/01 13:31:04
5513dnl -------------------
5514dnl Allow library's ABI to be overridden.  Generally this happens when a
5515dnl packager has incremented the ABI past that used in the original package,
5516dnl and wishes to keep doing this.
5517dnl
5518dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
5519dnl symbol.
5520AC_DEFUN([CF_WITH_ABI_VERSION],[
5521test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
5522AC_ARG_WITH(abi-version,
5523[  --with-abi-version=XXX  override derived ABI version],[
5524	if test "x$cf_cv_abi_version" != "x$withval"
5525	then
5526		AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
5527		case "$cf_cv_rel_version" in
5528		(5.*)
5529			cf_cv_rel_version=$withval.0
5530			;;
5531		(6.*)
5532			cf_cv_rel_version=$withval.9	# FIXME: should be 10 as of 6.0 release
5533			;;
5534		esac
5535	fi
5536	cf_cv_abi_version=$withval])
5537	CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
5538ifelse($1,,,[
5539$1_ABI=$cf_cv_abi_version
5540])
5541])dnl
5542dnl ---------------------------------------------------------------------------
5543dnl CF_WITH_CURSES_DIR version: 4 updated: 2021/01/02 19:22:58
5544dnl ------------------
5545dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
5546dnl libraries.
5547AC_DEFUN([CF_WITH_CURSES_DIR],[
5548
5549AC_MSG_CHECKING(for specific curses-directory)
5550AC_ARG_WITH(curses-dir,
5551	[  --with-curses-dir=DIR   directory in which (n)curses is installed],
5552	[cf_cv_curses_dir=$withval],
5553	[cf_cv_curses_dir=no])
5554AC_MSG_RESULT($cf_cv_curses_dir)
5555
5556if test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no"
5557then
5558	CF_PATH_SYNTAX(withval)
5559	if test -d "$cf_cv_curses_dir"
5560	then
5561		CF_ADD_INCDIR($cf_cv_curses_dir/include)
5562		CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
5563	fi
5564fi
5565])dnl
5566dnl ---------------------------------------------------------------------------
5567dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
5568dnl ----------------
5569dnl Configure-option for dbmalloc.  The optional parameter is used to override
5570dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
5571AC_DEFUN([CF_WITH_DBMALLOC],[
5572CF_NO_LEAKS_OPTION(dbmalloc,
5573	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
5574	[USE_DBMALLOC])
5575
5576if test "$with_dbmalloc" = yes ; then
5577	AC_CHECK_HEADER(dbmalloc.h,
5578		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
5579fi
5580])dnl
5581dnl ---------------------------------------------------------------------------
5582dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
5583dnl ---------------
5584dnl Configure-option for dmalloc.  The optional parameter is used to override
5585dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
5586AC_DEFUN([CF_WITH_DMALLOC],[
5587CF_NO_LEAKS_OPTION(dmalloc,
5588	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
5589	[USE_DMALLOC])
5590
5591if test "$with_dmalloc" = yes ; then
5592	AC_CHECK_HEADER(dmalloc.h,
5593		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
5594fi
5595])dnl
5596dnl ---------------------------------------------------------------------------
5597dnl CF_WITH_EXPORT_SYMS version: 3 updated: 2014/12/20 19:16:08
5598dnl -------------------
5599dnl Use this with libtool to specify the list of symbols that may be exported.
5600dnl The input file contains one symbol per line; comments work with "#".
5601dnl
5602dnl $1 = basename of the ".sym" file (default $PACKAGE)
5603AC_DEFUN([CF_WITH_EXPORT_SYMS],
5604[
5605AC_MSG_CHECKING(if exported-symbols file should be used)
5606AC_ARG_WITH(export-syms,
5607	[  --with-export-syms=XXX  limit exported symbols using libtool],
5608	[with_export_syms=$withval],
5609	[with_export_syms=no])
5610if test "x$with_export_syms" = xyes
5611then
5612	with_export_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).sym'
5613	AC_SUBST(PACKAGE)
5614fi
5615AC_MSG_RESULT($with_export_syms)
5616if test "x$with_export_syms" != xno
5617then
5618	EXPORT_SYMS="-export-symbols $with_export_syms"
5619	AC_SUBST(EXPORT_SYMS)
5620fi
5621])dnl
5622dnl ---------------------------------------------------------------------------
5623dnl CF_WITH_INSTALL_PREFIX version: 4 updated: 2010/10/23 15:52:32
5624dnl ----------------------
5625dnl Configure-script option to give a default value for the poorly-chosen name
5626dnl $(DESTDIR).
5627AC_DEFUN([CF_WITH_INSTALL_PREFIX],
5628[
5629AC_MSG_CHECKING(for install-prefix)
5630AC_ARG_WITH(install-prefix,
5631	[  --with-install-prefix=XXX sets DESTDIR, useful for packaging],
5632	[cf_opt_with_install_prefix=$withval],
5633	[cf_opt_with_install_prefix=${DESTDIR:-no}])
5634AC_MSG_RESULT($cf_opt_with_install_prefix)
5635if test "$cf_opt_with_install_prefix" != no ; then
5636	CF_PATH_SYNTAX(cf_opt_with_install_prefix)
5637	DESTDIR=$cf_opt_with_install_prefix
5638fi
5639AC_SUBST(DESTDIR)
5640])dnl
5641dnl ---------------------------------------------------------------------------
5642dnl CF_WITH_LIBTOOL version: 36 updated: 2021/01/01 13:31:04
5643dnl ---------------
5644dnl Provide a configure option to incorporate libtool.  Define several useful
5645dnl symbols for the makefile rules.
5646dnl
5647dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
5648dnl macros from libtool.m4 which is in the aclocal directory of automake.
5649dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
5650dnl But that still does not work properly since the macro is expanded outside
5651dnl the CF_WITH_LIBTOOL macro:
5652dnl
5653dnl	#!/bin/sh
5654dnl	ACLOCAL=`aclocal --print-ac-dir`
5655dnl	if test -z "$ACLOCAL" ; then
5656dnl		echo cannot find aclocal directory
5657dnl		exit 1
5658dnl	elif test ! -f $ACLOCAL/libtool.m4 ; then
5659dnl		echo cannot find libtool.m4 file
5660dnl		exit 1
5661dnl	fi
5662dnl
5663dnl	LOCAL=aclocal.m4
5664dnl	ORIG=aclocal.m4.orig
5665dnl
5666dnl	trap "mv $ORIG $LOCAL" 0 1 2 3 15
5667dnl	rm -f $ORIG
5668dnl	mv $LOCAL $ORIG
5669dnl
5670dnl	# sed the LIBTOOL= assignment to omit the current directory?
5671dnl	sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL:-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
5672dnl	cat $ORIG >>$LOCAL
5673dnl
5674dnl	autoconf-257 $*
5675dnl
5676AC_DEFUN([CF_WITH_LIBTOOL],
5677[
5678AC_REQUIRE([CF_DISABLE_LIBTOOL_VERSION])
5679ifdef([AC_PROG_LIBTOOL],,[
5680LIBTOOL=
5681])
5682# common library maintenance symbols that are convenient for libtool scripts:
5683LIB_CREATE='${AR} -cr'
5684LIB_OBJECT='${OBJECTS}'
5685LIB_SUFFIX=.a
5686LIB_PREP="$RANLIB"
5687
5688# symbols used to prop libtool up to enable it to determine what it should be
5689# doing:
5690LIB_CLEAN=
5691LIB_COMPILE=
5692LIB_LINK='${CC}'
5693LIB_INSTALL=
5694LIB_UNINSTALL=
5695
5696AC_MSG_CHECKING(if you want to build libraries with libtool)
5697AC_ARG_WITH(libtool,
5698	[  --with-libtool          generate libraries with libtool],
5699	[with_libtool=$withval],
5700	[with_libtool=no])
5701AC_MSG_RESULT($with_libtool)
5702if test "$with_libtool" != "no"; then
5703ifdef([AC_PROG_LIBTOOL],[
5704	# missing_content_AC_PROG_LIBTOOL{{
5705	AC_PROG_LIBTOOL
5706	# missing_content_AC_PROG_LIBTOOL}}
5707],[
5708	if test "$with_libtool" != "yes" ; then
5709		CF_PATH_SYNTAX(with_libtool)
5710		LIBTOOL=$with_libtool
5711	else
5712		AC_CHECK_TOOLS(LIBTOOL,[libtool glibtool],none)
5713		CF_LIBTOOL_VERSION
5714		if test -z "$cf_cv_libtool_version" && test "$LIBTOOL" = libtool
5715		then
5716			CF_FORGET_TOOL(LIBTOOL)
5717			AC_CHECK_TOOLS(LIBTOOL,[glibtool],none)
5718			CF_LIBTOOL_VERSION
5719		fi
5720	fi
5721	if test -z "$LIBTOOL" ; then
5722		AC_MSG_ERROR(Cannot find libtool)
5723	fi
5724])dnl
5725	LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${libdir} ${LIBTOOL_VERSION} `cut -f1 ${top_srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} $(LIBS) -o'
5726	LIB_OBJECT='${OBJECTS:.o=.lo}'
5727	LIB_SUFFIX=.la
5728	LIB_CLEAN='${LIBTOOL} --mode=clean'
5729	LIB_COMPILE='${LIBTOOL} --mode=compile'
5730	LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
5731	LIB_INSTALL='${LIBTOOL} --mode=install'
5732	LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
5733	LIB_PREP=:
5734
5735	CF_CHECK_LIBTOOL_VERSION
5736
5737	# special hack to add -no-undefined (which libtool should do for itself)
5738	LT_UNDEF=
5739	case "$cf_cv_system_name" in
5740	(cygwin*|msys*|mingw32*|os2*|uwin*|aix[[4-7]])
5741		LT_UNDEF=-no-undefined
5742		;;
5743	esac
5744	AC_SUBST([LT_UNDEF])
5745
5746	# special hack to add --tag option for C++ compiler
5747	case "$cf_cv_libtool_version" in
5748	(1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*)
5749		LIBTOOL_CXX="$LIBTOOL --tag=CXX"
5750		LIBTOOL="$LIBTOOL --tag=CC"
5751		;;
5752	(*)
5753		LIBTOOL_CXX="$LIBTOOL"
5754		;;
5755	esac
5756else
5757	LIBTOOL=""
5758	LIBTOOL_CXX=""
5759fi
5760
5761test -z "$LIBTOOL" && ECHO_LT=
5762
5763AC_SUBST(LIBTOOL)
5764AC_SUBST(LIBTOOL_CXX)
5765AC_SUBST(LIBTOOL_OPTS)
5766
5767AC_SUBST(LIB_CREATE)
5768AC_SUBST(LIB_OBJECT)
5769AC_SUBST(LIB_SUFFIX)
5770AC_SUBST(LIB_PREP)
5771
5772AC_SUBST(LIB_CLEAN)
5773AC_SUBST(LIB_COMPILE)
5774AC_SUBST(LIB_LINK)
5775AC_SUBST(LIB_INSTALL)
5776AC_SUBST(LIB_UNINSTALL)
5777
5778])dnl
5779dnl ---------------------------------------------------------------------------
5780dnl CF_WITH_LIBTOOL_OPTS version: 4 updated: 2015/04/17 21:13:04
5781dnl --------------------
5782dnl Allow user to pass additional libtool options into the library creation
5783dnl and link steps.  The main use for this is to do something like
5784dnl	./configure --with-libtool-opts=-static
5785dnl to get the same behavior as automake-flavored
5786dnl	./configure --enable-static
5787AC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
5788AC_MSG_CHECKING(for additional libtool options)
5789AC_ARG_WITH(libtool-opts,
5790	[  --with-libtool-opts=XXX specify additional libtool options],
5791	[with_libtool_opts=$withval],
5792	[with_libtool_opts=no])
5793AC_MSG_RESULT($with_libtool_opts)
5794
5795case .$with_libtool_opts in
5796(.yes|.no|.)
5797	;;
5798(*)
5799	LIBTOOL_OPTS="$LIBTOOL_OPTS $with_libtool_opts"
5800	;;
5801esac
5802
5803AC_SUBST(LIBTOOL_OPTS)
5804])dnl
5805dnl ---------------------------------------------------------------------------
5806dnl CF_WITH_MAN2HTML version: 12 updated: 2021/01/03 18:30:50
5807dnl ----------------
5808dnl Check for man2html and groff.  Prefer man2html over groff, but use groff
5809dnl as a fallback.  See
5810dnl
5811dnl		http://invisible-island.net/scripts/man2html.html
5812dnl
5813dnl Generate a shell script which hides the differences between the two.
5814dnl
5815dnl We name that "man2html.tmp".
5816dnl
5817dnl The shell script can be removed later, e.g., using "make distclean".
5818AC_DEFUN([CF_WITH_MAN2HTML],[
5819AC_REQUIRE([CF_PROG_GROFF])dnl
5820AC_REQUIRE([AC_PROG_FGREP])dnl
5821
5822case "x${with_man2html}" in
5823(xno)
5824	cf_man2html=no
5825	;;
5826(x|xyes)
5827	AC_PATH_PROG(cf_man2html,man2html,no)
5828	case "x$cf_man2html" in
5829	(x/*)
5830		AC_MSG_CHECKING(for the modified Earl Hood script)
5831		if ( $cf_man2html -help 2>&1 | grep 'Make an index of headers at the end' >/dev/null )
5832		then
5833			cf_man2html_ok=yes
5834		else
5835			cf_man2html=no
5836			cf_man2html_ok=no
5837		fi
5838		AC_MSG_RESULT($cf_man2html_ok)
5839		;;
5840	(*)
5841		cf_man2html=no
5842		;;
5843	esac
5844esac
5845
5846AC_MSG_CHECKING(for program to convert manpage to html)
5847AC_ARG_WITH(man2html,
5848	[  --with-man2html=XXX     use XXX rather than groff],
5849	[cf_man2html=$withval],
5850	[cf_man2html=$cf_man2html])
5851
5852cf_with_groff=no
5853
5854case $cf_man2html in
5855(yes)
5856	AC_MSG_RESULT(man2html)
5857	AC_PATH_PROG(cf_man2html,man2html,no)
5858	;;
5859(no|groff|*/groff*)
5860	cf_with_groff=yes
5861	cf_man2html=$GROFF_PATH
5862	AC_MSG_RESULT($cf_man2html)
5863	;;
5864(*)
5865	AC_MSG_RESULT($cf_man2html)
5866	;;
5867esac
5868
5869MAN2HTML_TEMP="man2html.tmp"
5870	cat >$MAN2HTML_TEMP <<CF_EOF
5871#!$SHELL
5872# Temporary script generated by CF_WITH_MAN2HTML
5873# Convert inputs to html, sending result to standard output.
5874#
5875# Parameters:
5876# \${1} = rootname of file to convert
5877# \${2} = suffix of file to convert, e.g., "1"
5878# \${3} = macros to use, e.g., "man"
5879#
5880ROOT=\[$]1
5881TYPE=\[$]2
5882MACS=\[$]3
5883
5884unset LANG
5885unset LC_ALL
5886unset LC_CTYPE
5887unset LANGUAGE
5888GROFF_NO_SGR=stupid
5889export GROFF_NO_SGR
5890
5891CF_EOF
5892
5893NROFF_OPTS=
5894if test "x$cf_with_groff" = xyes
5895then
5896	MAN2HTML_NOTE="$GROFF_NOTE"
5897	MAN2HTML_PATH="$GROFF_PATH"
5898	cat >>$MAN2HTML_TEMP <<CF_EOF
5899$SHELL -c "$TBL_PATH \${ROOT}.\${TYPE} | $GROFF_PATH -P -o0 -I\${ROOT}_ -Thtml -\${MACS}"
5900CF_EOF
5901else
5902	# disable hyphenation if this is groff
5903	if test "x$GROFF_PATH" != xno
5904	then
5905		AC_MSG_CHECKING(if nroff is really groff)
5906		cf_check_groff="`$NROFF_PATH --version 2>/dev/null | grep groff`"
5907		test -n "$cf_check_groff" && cf_check_groff=yes
5908		test -n "$cf_check_groff" || cf_check_groff=no
5909		AC_MSG_RESULT($cf_check_groff)
5910		test "x$cf_check_groff" = xyes && NROFF_OPTS="-rHY=0"
5911	fi
5912	MAN2HTML_NOTE=""
5913	CF_PATH_SYNTAX(cf_man2html)
5914	MAN2HTML_PATH="$cf_man2html"
5915	AC_MSG_CHECKING(for $cf_man2html top/bottom margins)
5916
5917	# for this example, expect 3 lines of content, the remainder is head/foot
5918	cat >conftest.in <<CF_EOF
5919.TH HEAD1 HEAD2 HEAD3 HEAD4 HEAD5
5920.SH SECTION
5921MARKER
5922CF_EOF
5923
5924	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
5925
5926	cf_man2html_1st="`${FGREP-fgrep} -n MARKER conftest.out |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
5927	cf_man2html_top=`expr "$cf_man2html_1st" - 2`
5928	cf_man2html_bot="`wc -l conftest.out |sed -e 's/[[^0-9]]//g'`"
5929	cf_man2html_bot=`expr "$cf_man2html_bot" - 2 - "$cf_man2html_top"`
5930	cf_man2html_top_bot="-topm=$cf_man2html_top -botm=$cf_man2html_bot"
5931
5932	AC_MSG_RESULT($cf_man2html_top_bot)
5933
5934	AC_MSG_CHECKING(for pagesize to use)
5935	for cf_block in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
5936	do
5937	cat >>conftest.in <<CF_EOF
5938.nf
59390
59401
59412
59423
59434
59445
59456
59467
59478
59489
5949CF_EOF
5950	done
5951
5952	LC_ALL=C LC_CTYPE=C LANG=C LANGUAGE=C $NROFF_PATH -man conftest.in >conftest.out
5953	cf_man2html_page="`${FGREP-fgrep} -n HEAD1 conftest.out |sed -n '$p' |sed -e 's/^[[^0-9]]*://' -e 's/:.*//'`"
5954	test -z "$cf_man2html_page" && cf_man2html_page=99999
5955	test "$cf_man2html_page" -gt 100 && cf_man2html_page=99999
5956
5957	rm -rf conftest*
5958	AC_MSG_RESULT($cf_man2html_page)
5959
5960	cat >>$MAN2HTML_TEMP <<CF_EOF
5961: \${MAN2HTML_PATH=$MAN2HTML_PATH}
5962MAN2HTML_OPTS="\$MAN2HTML_OPTS -index -title=\"\$ROOT(\$TYPE)\" -compress -pgsize $cf_man2html_page"
5963case \${TYPE} in
5964(ms)
5965	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH -topm=0 -botm=0 \$MAN2HTML_OPTS
5966	;;
5967(*)
5968	$TBL_PATH \${ROOT}.\${TYPE} | $NROFF_PATH $NROFF_OPTS -\${MACS} | \$MAN2HTML_PATH $cf_man2html_top_bot \$MAN2HTML_OPTS
5969	;;
5970esac
5971CF_EOF
5972fi
5973
5974chmod 700 $MAN2HTML_TEMP
5975
5976AC_SUBST(MAN2HTML_NOTE)
5977AC_SUBST(MAN2HTML_PATH)
5978AC_SUBST(MAN2HTML_TEMP)
5979])dnl
5980dnl ---------------------------------------------------------------------------
5981dnl CF_WITH_NCURSES_ETC version: 5 updated: 2016/02/20 19:23:20
5982dnl -------------------
5983dnl Use this macro for programs which use any variant of "curses", e.g.,
5984dnl "ncurses", and "PDCurses".  Programs that can use curses and some unrelated
5985dnl library (such as slang) should use a "--with-screen=XXX" option.
5986dnl
5987dnl This does not use AC_DEFUN, because that would tell autoconf to run each
5988dnl of the macros inside this one - before this macro.
5989define([CF_WITH_NCURSES_ETC],[
5990CF_WITH_CURSES_DIR
5991
5992cf_cv_screen=curses
5993
5994AC_MSG_CHECKING(for specified curses library type)
5995AC_ARG_WITH(screen,
5996	[  --with-screen=XXX       use specified curses-libraries],
5997	[cf_cv_screen=$withval],[
5998
5999AC_ARG_WITH(ncursesw,
6000	[  --with-ncursesw         use wide ncurses-libraries],
6001	[cf_cv_screen=ncursesw],[
6002
6003AC_ARG_WITH(ncurses,
6004	[  --with-ncurses          use ncurses-libraries],
6005	[cf_cv_screen=ncurses],[
6006
6007AC_ARG_WITH(pdcurses,
6008	[  --with-pdcurses         compile/link with pdcurses X11 library],
6009	[cf_cv_screen=pdcurses],[
6010
6011AC_ARG_WITH(curses-colr,
6012	[  --with-curses-colr      compile/link with HPUX 10.x color-curses],
6013	[cf_cv_screen=curses_colr],[
6014
6015AC_ARG_WITH(curses-5lib,
6016	[  --with-curses-5lib      compile/link with SunOS 5lib curses],
6017	[cf_cv_screen=curses_5lib])])])])])])
6018
6019AC_MSG_RESULT($cf_cv_screen)
6020
6021case $cf_cv_screen in
6022(curses|curses_*)
6023	CF_CURSES_CONFIG
6024	;;
6025(ncursesw*)
6026	CF_UTF8_LIB
6027	CF_NCURSES_CONFIG($cf_cv_screen)
6028	;;
6029(ncurses*)
6030	CF_NCURSES_CONFIG($cf_cv_screen)
6031	;;
6032(pdcurses)
6033	CF_PDCURSES_X11
6034	;;
6035(*)
6036	AC_MSG_ERROR(unexpected screen-value: $cf_cv_screen)
6037	;;
6038esac
6039
6040CF_NCURSES_PTHREADS($cf_cv_screen)
6041
6042])dnl
6043dnl ---------------------------------------------------------------------------
6044dnl CF_WITH_NO_LEAKS version: 4 updated: 2021/01/05 20:08:11
6045dnl ----------------
6046AC_DEFUN([CF_WITH_NO_LEAKS],[
6047
6048AC_REQUIRE([CF_WITH_DMALLOC])
6049AC_REQUIRE([CF_WITH_DBMALLOC])
6050AC_REQUIRE([CF_WITH_PURIFY])
6051AC_REQUIRE([CF_WITH_VALGRIND])
6052
6053AC_MSG_CHECKING(if you want to perform memory-leak testing)
6054AC_ARG_WITH(no-leaks,
6055	[  --with-no-leaks         test: free permanent memory, analyze leaks],
6056	[AC_DEFINE(NO_LEAKS,1,[Define to 1 to enable leak-checking])
6057	 cf_doalloc=".${with_dmalloc}${with_dbmalloc}${with_purify}${with_valgrind}"
6058	 case ${cf_doalloc} in
6059	 (*yes*) ;;
6060	 (*) AC_DEFINE(DOALLOC,10000,[Define to size of malloc-array]) ;;
6061	 esac
6062	 enable_leaks=no],
6063	[enable_leaks=yes])
6064dnl TODO - drop with_no_leaks
6065if test "x$enable_leaks" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi
6066AC_MSG_RESULT($with_no_leaks)
6067])dnl
6068dnl ---------------------------------------------------------------------------
6069dnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
6070dnl --------------
6071AC_DEFUN([CF_WITH_PURIFY],[
6072CF_NO_LEAKS_OPTION(purify,
6073	[  --with-purify           test: use Purify],
6074	[USE_PURIFY],
6075	[LINK_PREFIX="$LINK_PREFIX purify"])
6076AC_SUBST(LINK_PREFIX)
6077])dnl
6078dnl ---------------------------------------------------------------------------
6079dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
6080dnl -------------------
6081dnl Allow library's release-version to be overridden.  Generally this happens when a
6082dnl packager has incremented the release-version past that used in the original package,
6083dnl and wishes to keep doing this.
6084dnl
6085dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
6086dnl and {package}_MINOR symbols
6087dnl symbol.
6088AC_DEFUN([CF_WITH_REL_VERSION],[
6089test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
6090AC_ARG_WITH(rel-version,
6091[  --with-rel-version=XXX  override derived release version],
6092[AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
6093 cf_cv_rel_version=$withval])
6094ifelse($1,,[
6095 CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
6096],[
6097 $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
6098 $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
6099 CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
6100 CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
6101])
6102])dnl
6103dnl ---------------------------------------------------------------------------
6104dnl CF_WITH_SCREEN_PDCURSES version: 1 updated: 2020/08/28 16:56:27
6105dnl -----------------------
6106dnl Call this macro before CF_ENABLE_WARNINGS for configure scripts which use
6107dnl the "--with-screen=pdcurses" selection.  Doing that allows the configure
6108dnl script to search for the X11/Xt header files to declare (or not) the
6109dnl symbol needed to enable "const" in those header files.  If that configure
6110dnl option is not used, then those checks are unnecessary.
6111AC_DEFUN([CF_WITH_SCREEN_PDCURSES],[
6112AC_PROVIDE([AC_PATH_XTRA])
6113AC_PROVIDE([AC_PATH_X])
6114if test -n "$with_screen" && test "x$with_screen" = "xpdcurses"
6115then
6116	AC_PATH_X
6117	AC_PATH_XTRA
6118fi
6119])dnl
6120dnl ---------------------------------------------------------------------------
6121dnl CF_WITH_SHARED_OR_LIBTOOL version: 7 updated: 2014/11/02 16:11:49
6122dnl -------------------------
6123dnl Provide shared libraries using either autoconf macros (--with-shared) or
6124dnl using the external libtool script (--with-libtool).
6125dnl
6126dnl $1 = program name (all caps preferred)
6127dnl $1 = release version
6128dnl $2 = ABI version
6129define([CF_WITH_SHARED_OR_LIBTOOL],[
6130
6131REL_VERSION=$2
6132ABI_VERSION=$3
6133cf_cv_rel_version=$REL_VERSION
6134AC_SUBST(ABI_VERSION)
6135AC_SUBST(REL_VERSION)
6136
6137CF_WITH_REL_VERSION($1)
6138CF_WITH_ABI_VERSION
6139
6140LIB_MODEL=static
6141DFT_LWR_MODEL=$LIB_MODEL
6142LIBTOOL_MAKE="#"
6143
6144# use to comment-out makefile lines
6145MAKE_NORMAL=
6146MAKE_STATIC=
6147MAKE_SHARED="#"
6148MAKE_DLLS="#"
6149
6150shlibdir=$libdir
6151AC_SUBST(shlibdir)
6152
6153CF_WITH_LIBTOOL
6154
6155LIB_CREATE="$LIB_CREATE \[$]@"
6156
6157if test "$with_libtool" = "yes" ; then
6158	OBJEXT="lo"
6159	LIB_MODEL=libtool
6160	DFT_LWR_MODEL=$LIB_MODEL
6161	LIBTOOL_MAKE=
6162	CF_WITH_LIBTOOL_OPTS
6163	CF_WITH_EXPORT_SYMS
6164	MAKE_NORMAL="#"
6165	MAKE_STATIC="#"
6166	MAKE_SHARED=
6167else
6168	AC_MSG_CHECKING(if you want to build shared libraries)
6169	AC_ARG_WITH(shared,
6170		[  --with-shared           generate shared-libraries],
6171		[with_shared=$withval],
6172		[with_shared=no])
6173	AC_MSG_RESULT($with_shared)
6174	if test "$with_shared" = "yes" ; then
6175		LIB_MODEL=shared
6176		DFT_LWR_MODEL=$LIB_MODEL
6177		CF_SHARED_OPTS
6178		CF_WITH_VERSIONED_SYMS
6179		LIB_PREP=:
6180		LIB_CREATE="[$]MK_SHARED_LIB"
6181		CFLAGS="$CFLAGS $CC_SHARED_OPTS"
6182		MAKE_NORMAL="#"
6183		MAKE_STATIC="#"
6184		MAKE_SHARED=
6185	fi
6186fi
6187
6188LIB_SUFFIX=
6189CF_LIB_SUFFIX($LIB_MODEL, DFT_LIB_SUFFIX, DFT_DEP_SUFFIX)
6190LIB_SUFFIX=$DFT_LIB_SUFFIX
6191
6192AC_SUBST(DFT_LWR_MODEL)
6193AC_SUBST(DFT_LIB_SUFFIX)
6194AC_SUBST(DFT_DEP_SUFFIX)
6195AC_SUBST(LIB_MODEL)
6196
6197AC_SUBST(LIBTOOL_MAKE)
6198
6199AC_SUBST(MAKE_DLLS)
6200AC_SUBST(MAKE_NORMAL)
6201AC_SUBST(MAKE_SHARED)
6202AC_SUBST(MAKE_STATIC)
6203])dnl
6204dnl ---------------------------------------------------------------------------
6205dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
6206dnl ----------------
6207AC_DEFUN([CF_WITH_VALGRIND],[
6208CF_NO_LEAKS_OPTION(valgrind,
6209	[  --with-valgrind         test: use valgrind],
6210	[USE_VALGRIND])
6211])dnl
6212dnl ---------------------------------------------------------------------------
6213dnl CF_WITH_VERSIONED_SYMS version: 10 updated: 2021/01/04 18:48:01
6214dnl ----------------------
6215dnl Use this when building shared library with ELF, to markup symbols with the
6216dnl version identifier from the given input file.  Generally that identifier is
6217dnl the same as the SONAME at which the symbol was first introduced.
6218dnl
6219dnl $1 = basename of the ".map" file (default $PACKAGE)
6220AC_DEFUN([CF_WITH_VERSIONED_SYMS],
6221[AC_REQUIRE([AC_PROG_FGREP])dnl
6222AC_REQUIRE([AC_PROG_EGREP])dnl
6223
6224AC_MSG_CHECKING(if versioned-symbols file should be used)
6225AC_ARG_WITH(versioned-syms,
6226	[  --with-versioned-syms=X markup versioned symbols using ld],
6227	[with_versioned_syms=$withval],
6228	[with_versioned_syms=no])
6229case "x$with_versioned_syms" in
6230(xyes)
6231	with_versioned_syms='${top_srcdir}/package/ifelse($1,,${PACKAGE},[$1]).map'
6232	AC_SUBST(PACKAGE)
6233	;;
6234(xno)
6235	;;
6236(x/*)
6237	test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
6238	;;
6239(*)
6240	test -f "$with_versioned_syms" || AC_MSG_ERROR(expected a filename: $with_versioned_syms)
6241	with_versioned_syms=`pwd`/"$with_versioned_syms"
6242	;;
6243esac
6244AC_MSG_RESULT($with_versioned_syms)
6245
6246RESULTING_SYMS=
6247VERSIONED_SYMS=
6248WILDCARD_SYMS=
6249
6250if test "x$with_versioned_syms" != xno
6251then
6252	RESULTING_SYMS=$with_versioned_syms
6253	case "x$MK_SHARED_LIB" in
6254	(*-Wl,*)
6255		VERSIONED_SYMS="-Wl,--version-script,\${RESULTING_SYMS}"
6256		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-Wl,%\\[$]{VERSIONED_SYMS} -Wl,%"`
6257		CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
6258		;;
6259	(*-dy\ *)
6260		VERSIONED_SYMS="-Wl,-M,\${RESULTING_SYMS}"
6261		MK_SHARED_LIB=`echo "$MK_SHARED_LIB" | sed -e "s%-dy%\\[$]{VERSIONED_SYMS} -dy%"`
6262		CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
6263		;;
6264	(*)
6265		AC_MSG_WARN(this system does not support versioned-symbols)
6266		;;
6267	esac
6268
6269	# Linux ld can selectively override scope, e.g., of symbols beginning with
6270	# "_" by first declaring some as global, and then using a wildcard to
6271	# declare the others as local.  Some other loaders cannot do this.  Check
6272	# by constructing a (very) simple shared library and inspecting its
6273	# symbols.
6274	if test "x$VERSIONED_SYMS" != "x"
6275	then
6276		AC_MSG_CHECKING(if wildcards can be used to selectively omit symbols)
6277		WILDCARD_SYMS=no
6278
6279		# make sources
6280		rm -f conftest.*
6281
6282		cat >conftest.ver <<EOF
6283module_1.0 {
6284global:
6285	globalf1;
6286local:
6287	localf1;
6288};
6289module_2.0 {
6290global:
6291	globalf2;
6292local:
6293	localf2;
6294	_*;
6295} module_1.0;
6296submodule_1.0 {
6297global:
6298	subglobalf1;
6299	_ismissing;
6300local:
6301	sublocalf1;
6302};
6303submodule_2.0 {
6304global:
6305	subglobalf2;
6306local:
6307	sublocalf2;
6308	_*;
6309} submodule_1.0;
6310EOF
6311		cat >conftest.$ac_ext <<EOF
6312#line __oline__ "configure"
6313int	_ismissing(void) { return 1; }
6314int	_localf1(void) { return 1; }
6315int	_localf2(void) { return 2; }
6316int	globalf1(void) { return 1; }
6317int	globalf2(void) { return 2; }
6318int	_sublocalf1(void) { return 1; }
6319int	_sublocalf2(void) { return 2; }
6320int	subglobalf1(void) { return 1; }
6321int	subglobalf2(void) { return 2; }
6322EOF
6323		cat >conftest.mk <<EOF
6324CC=${CC}
6325CFLAGS=${CFLAGS}
6326CPPFLAGS=${CPPFLAGS}
6327LDFLAGS=${LDFLAGS}
6328LIBS=${LIBS}
6329VERSIONED_SYMS=${VERSIONED_SYMS}
6330RESULTING_SYMS=conftest.ver
6331MK_SHARED_LIB=${MK_SHARED_LIB}
6332conftest.so: conftest.$ac_cv_objext
6333		\$(MK_SHARED_LIB) conftest.$ac_cv_objext
6334EOF
6335
6336		# compile source, make library
6337		if make -f conftest.mk 2>&AC_FD_CC >/dev/null
6338		then
6339			# test for missing symbol in either Data or Text section
6340			cf_missing="`nm -P conftest.so 2>&AC_FD_CC |${FGREP-fgrep} _ismissing | ${EGREP-egrep} '[[ 	]][[DT]][[ 	]]'`"
6341			test -n "$cf_missing" && WILDCARD_SYMS=yes
6342		fi
6343		AC_MSG_RESULT($WILDCARD_SYMS)
6344		rm -f conftest.*
6345	fi
6346fi
6347AC_SUBST(RESULTING_SYMS)
6348AC_SUBST(VERSIONED_SYMS)
6349AC_SUBST(WILDCARD_SYMS)
6350])dnl
6351dnl ---------------------------------------------------------------------------
6352dnl CF_XOPEN_CURSES version: 16 updated: 2021/01/02 09:31:20
6353dnl ---------------
6354dnl Test if we should define X/Open source for curses, needed on Digital Unix
6355dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
6356dnl
6357dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
6358dnl as getbegy().  The latter is better design, but the former is standard.
6359AC_DEFUN([CF_XOPEN_CURSES],
6360[
6361AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
6362AC_CACHE_CHECK(definition to turn on extended curses functions,cf_cv_need_xopen_extension,[
6363cf_cv_need_xopen_extension=unknown
6364AC_TRY_LINK([
6365#include <stdlib.h>
6366#include <${cf_cv_ncurses_header:-curses.h}>],[
6367#if defined(NCURSES_VERSION_PATCH)
6368#if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
6369	make an error
6370#endif
6371#endif
6372#ifdef NCURSES_VERSION
6373	cchar_t check;
6374	int check2 = curs_set((int)sizeof(check));
6375#endif
6376	long x = winnstr(stdscr, "", 0);
6377	int x1, y1;
6378#ifdef NCURSES_VERSION
6379	(void)check2;
6380#endif
6381	getbegyx(stdscr, y1, x1);
6382	(void)x;
6383	(void)y1;
6384	(void)x1;
6385	],
6386	[cf_cv_need_xopen_extension=none],
6387	[
6388	for cf_try_xopen_extension in _XOPEN_SOURCE_EXTENDED NCURSES_WIDECHAR
6389	do
6390		AC_TRY_LINK([
6391#define $cf_try_xopen_extension 1
6392#include <stdlib.h>
6393#include <${cf_cv_ncurses_header:-curses.h}>],[
6394#ifdef NCURSES_VERSION
6395		cchar_t check;
6396		int check2 = curs_set((int)sizeof(check));
6397#endif
6398		long x = winnstr(stdscr, "", 0);
6399		int x1, y1;
6400		getbegyx(stdscr, y1, x1);
6401#ifdef NCURSES_VERSION
6402		(void)check2;
6403#endif
6404		(void)x;
6405		(void)y1;
6406		(void)x1;
6407		],
6408		[cf_cv_need_xopen_extension=$cf_try_xopen_extension; break])
6409	done
6410	])
6411])
6412
6413case "$cf_cv_need_xopen_extension" in
6414(*_*)
6415	CF_APPEND_TEXT(CPPFLAGS,-D$cf_cv_need_xopen_extension)
6416	;;
6417esac
6418
6419])dnl
6420dnl ---------------------------------------------------------------------------
6421dnl CF_XOPEN_SOURCE version: 57 updated: 2021/01/01 16:53:59
6422dnl ---------------
6423dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
6424dnl or adapt to the vendor's definitions to get equivalent functionality,
6425dnl without losing the common non-POSIX features.
6426dnl
6427dnl Parameters:
6428dnl	$1 is the nominal value for _XOPEN_SOURCE
6429dnl	$2 is the nominal value for _POSIX_C_SOURCE
6430AC_DEFUN([CF_XOPEN_SOURCE],[
6431AC_REQUIRE([AC_CANONICAL_HOST])
6432AC_REQUIRE([CF_POSIX_VISIBLE])
6433
6434if test "$cf_cv_posix_visible" = no; then
6435
6436cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
6437cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
6438cf_xopen_source=
6439
6440case "$host_os" in
6441(aix[[4-7]]*)
6442	cf_xopen_source="-D_ALL_SOURCE"
6443	;;
6444(msys)
6445	cf_XOPEN_SOURCE=600
6446	;;
6447(darwin[[0-8]].*)
6448	cf_xopen_source="-D_APPLE_C_SOURCE"
6449	;;
6450(darwin*)
6451	cf_xopen_source="-D_DARWIN_C_SOURCE"
6452	cf_XOPEN_SOURCE=
6453	;;
6454(freebsd*|dragonfly*|midnightbsd*)
6455	# 5.x headers associate
6456	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
6457	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
6458	cf_POSIX_C_SOURCE=200112L
6459	cf_XOPEN_SOURCE=600
6460	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
6461	;;
6462(hpux11*)
6463	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
6464	;;
6465(hpux*)
6466	cf_xopen_source="-D_HPUX_SOURCE"
6467	;;
6468(irix[[56]].*)
6469	cf_xopen_source="-D_SGI_SOURCE"
6470	cf_XOPEN_SOURCE=
6471	;;
6472(linux*|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin)
6473	CF_GNU_SOURCE($cf_XOPEN_SOURCE)
6474	;;
6475(minix*)
6476	cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
6477	;;
6478(mirbsd*)
6479	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
6480	cf_XOPEN_SOURCE=
6481	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
6482	;;
6483(netbsd*)
6484	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
6485	;;
6486(openbsd[[4-9]]*)
6487	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
6488	cf_xopen_source="-D_BSD_SOURCE"
6489	cf_XOPEN_SOURCE=600
6490	;;
6491(openbsd*)
6492	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
6493	;;
6494(osf[[45]]*)
6495	cf_xopen_source="-D_OSF_SOURCE"
6496	;;
6497(nto-qnx*)
6498	cf_xopen_source="-D_QNX_SOURCE"
6499	;;
6500(sco*)
6501	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
6502	;;
6503(solaris2.*)
6504	cf_xopen_source="-D__EXTENSIONS__"
6505	cf_cv_xopen_source=broken
6506	;;
6507(sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
6508	cf_XOPEN_SOURCE=
6509	cf_POSIX_C_SOURCE=
6510	;;
6511(*)
6512	CF_TRY_XOPEN_SOURCE
6513	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
6514	;;
6515esac
6516
6517if test -n "$cf_xopen_source" ; then
6518	CF_ADD_CFLAGS($cf_xopen_source,true)
6519fi
6520
6521dnl In anything but the default case, we may have system-specific setting
6522dnl which is still not guaranteed to provide all of the entrypoints that
6523dnl _XOPEN_SOURCE would yield.
6524if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
6525	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
6526	AC_TRY_COMPILE([#include <stdlib.h>],[
6527#ifndef _XOPEN_SOURCE
6528make an error
6529#endif],
6530	[cf_XOPEN_SOURCE_set=yes],
6531	[cf_XOPEN_SOURCE_set=no])
6532	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
6533	if test "$cf_XOPEN_SOURCE_set" = yes
6534	then
6535		AC_TRY_COMPILE([#include <stdlib.h>],[
6536#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
6537make an error
6538#endif],
6539		[cf_XOPEN_SOURCE_set_ok=yes],
6540		[cf_XOPEN_SOURCE_set_ok=no])
6541		if test "$cf_XOPEN_SOURCE_set_ok" = no
6542		then
6543			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
6544		fi
6545	else
6546		CF_TRY_XOPEN_SOURCE
6547	fi
6548fi
6549fi # cf_cv_posix_visible
6550])
6551dnl ---------------------------------------------------------------------------
6552dnl CF_X_ATHENA version: 24 updated: 2020/03/10 18:53:47
6553dnl -----------
6554dnl Check for Xaw (Athena) libraries
6555dnl
6556dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
6557AC_DEFUN([CF_X_ATHENA],
6558[
6559cf_x_athena=${cf_x_athena:-Xaw}
6560
6561AC_MSG_CHECKING(if you want to link with Xaw 3d library)
6562withval=
6563AC_ARG_WITH(Xaw3d,
6564	[  --with-Xaw3d            link with Xaw 3d library])
6565if test "$withval" = yes ; then
6566	cf_x_athena=Xaw3d
6567	AC_MSG_RESULT(yes)
6568else
6569	AC_MSG_RESULT(no)
6570fi
6571
6572AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
6573withval=
6574AC_ARG_WITH(Xaw3dxft,
6575	[  --with-Xaw3dxft         link with Xaw 3d xft library])
6576if test "$withval" = yes ; then
6577	cf_x_athena=Xaw3dxft
6578	AC_MSG_RESULT(yes)
6579else
6580	AC_MSG_RESULT(no)
6581fi
6582
6583AC_MSG_CHECKING(if you want to link with neXT Athena library)
6584withval=
6585AC_ARG_WITH(neXtaw,
6586	[  --with-neXtaw           link with neXT Athena library])
6587if test "$withval" = yes ; then
6588	cf_x_athena=neXtaw
6589	AC_MSG_RESULT(yes)
6590else
6591	AC_MSG_RESULT(no)
6592fi
6593
6594AC_MSG_CHECKING(if you want to link with Athena-Plus library)
6595withval=
6596AC_ARG_WITH(XawPlus,
6597	[  --with-XawPlus          link with Athena-Plus library])
6598if test "$withval" = yes ; then
6599	cf_x_athena=XawPlus
6600	AC_MSG_RESULT(yes)
6601else
6602	AC_MSG_RESULT(no)
6603fi
6604
6605cf_x_athena_lib=""
6606
6607if test "$PKG_CONFIG" != none ; then
6608	cf_athena_list=
6609	test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
6610	for cf_athena_pkg in \
6611		$cf_athena_list \
6612		${cf_x_athena} \
6613		${cf_x_athena}-devel \
6614		lib${cf_x_athena} \
6615		lib${cf_x_athena}-devel
6616	do
6617		CF_TRY_PKG_CONFIG($cf_athena_pkg,[
6618			cf_x_athena_lib="$cf_pkgconfig_libs"
6619			CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
6620			AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
6621
6622			CF_TRIM_X_LIBS
6623
6624AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
6625AC_TRY_LINK([
6626#include <X11/Xmu/CharSet.h>
6627],[
6628int check = XmuCompareISOLatin1("big", "small");
6629(void)check;
6630],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
6631
6632			if test "$cf_cv_xaw_compat" = no
6633			then
6634				# workaround for broken ".pc" files...
6635				case "$cf_x_athena_lib" in
6636				(*-lXmu*)
6637					;;
6638				(*)
6639					CF_VERBOSE(work around broken package)
6640					cf_save_xmu="$LIBS"
6641					cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
6642					CF_TRY_PKG_CONFIG(xmu,[
6643							LIBS="$cf_save_xmu"
6644							CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
6645						],[
6646							CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
6647						])
6648					CF_TRIM_X_LIBS
6649					;;
6650				esac
6651			fi
6652
6653			break])
6654	done
6655fi
6656
6657if test -z "$cf_x_athena_lib" ; then
6658	CF_X_EXT
6659	CF_X_TOOLKIT
6660	CF_X_ATHENA_CPPFLAGS($cf_x_athena)
6661	CF_X_ATHENA_LIBS($cf_x_athena)
6662fi
6663])dnl
6664dnl ---------------------------------------------------------------------------
6665dnl CF_X_ATHENA_CPPFLAGS version: 9 updated: 2020/12/31 10:54:15
6666dnl --------------------
6667dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
6668dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
6669AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
6670[
6671AC_REQUIRE([AC_PATH_XTRA])
6672cf_x_athena_root=ifelse([$1],,Xaw,[$1])
6673cf_x_athena_inc=""
6674
6675for cf_path in default \
6676	/usr/contrib/X11R6 \
6677	/usr/contrib/X11R5 \
6678	/usr/lib/X11R5 \
6679	/usr/local
6680do
6681	if test -z "$cf_x_athena_inc" ; then
6682		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
6683		cf_test=X11/$cf_x_athena_root/SimpleMenu.h
6684		if test "$cf_path" != default ; then
6685			CF_APPEND_TEXT(CPPFLAGS,-I$cf_path/include)
6686			AC_MSG_CHECKING(for $cf_test in $cf_path)
6687		else
6688			AC_MSG_CHECKING(for $cf_test)
6689		fi
6690		AC_TRY_COMPILE([
6691#include <X11/Intrinsic.h>
6692#include <$cf_test>],[],
6693			[cf_result=yes],
6694			[cf_result=no])
6695		AC_MSG_RESULT($cf_result)
6696		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_CPPFLAGS])
6697		if test "$cf_result" = yes ; then
6698			test "$cf_path"  = default && cf_x_athena_inc=default
6699			test "$cf_path" != default && cf_x_athena_inc="$cf_path/include"
6700			break
6701		fi
6702	fi
6703done
6704
6705if test -z "$cf_x_athena_inc" ; then
6706	AC_MSG_WARN([Unable to find Athena header files])
6707elif test "$cf_x_athena_inc" != default ; then
6708	CF_APPEND_TEXT(CPPFLAGS,-I$cf_x_athena_inc)
6709fi
6710])
6711dnl ---------------------------------------------------------------------------
6712dnl CF_X_ATHENA_LIBS version: 13 updated: 2020/01/11 18:16:10
6713dnl ----------------
6714dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
6715dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
6716AC_DEFUN([CF_X_ATHENA_LIBS],
6717[AC_REQUIRE([CF_X_TOOLKIT])
6718cf_x_athena_root=ifelse([$1],,Xaw,[$1])
6719cf_x_athena_lib=""
6720
6721for cf_path in default \
6722	/usr/contrib/X11R6 \
6723	/usr/contrib/X11R5 \
6724	/usr/lib/X11R5 \
6725	/usr/local
6726do
6727	for cf_lib in \
6728		${cf_x_athena_root} \
6729		${cf_x_athena_root}7 \
6730		${cf_x_athena_root}6
6731	do
6732	for cf_libs in \
6733		"-l$cf_lib -lXmu" \
6734		"-l$cf_lib -lXpm -lXmu" \
6735		"-l${cf_lib}_s -lXmu_s"
6736	do
6737		test -n "$cf_x_athena_lib" && break
6738
6739		CF_SAVE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
6740		cf_test=XawSimpleMenuAddGlobalActions
6741		test "$cf_path" != default && cf_libs="-L$cf_path/lib $cf_libs"
6742		CF_ADD_LIBS($cf_libs)
6743		AC_MSG_CHECKING(for $cf_test in $cf_libs)
6744		AC_TRY_LINK([
6745#include <X11/Intrinsic.h>
6746#include <X11/$cf_x_athena_root/SimpleMenu.h>
6747],[
6748$cf_test((XtAppContext) 0)],
6749			[cf_result=yes],
6750			[cf_result=no])
6751		AC_MSG_RESULT($cf_result)
6752		CF_RESTORE_XTRA_FLAGS([CF_X_ATHENA_LIBS])
6753
6754		if test "$cf_result" = yes ; then
6755			cf_x_athena_lib="$cf_libs"
6756			break
6757		fi
6758	done # cf_libs
6759		test -n "$cf_x_athena_lib" && break
6760	done # cf_lib
6761done
6762
6763if test -z "$cf_x_athena_lib" ; then
6764	AC_MSG_ERROR(
6765[Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
6766fi
6767
6768CF_ADD_LIBS($cf_x_athena_lib)
6769CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
6770AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
6771])
6772dnl ---------------------------------------------------------------------------
6773dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
6774dnl --------
6775AC_DEFUN([CF_X_EXT],[
6776CF_TRY_PKG_CONFIG(Xext,,[
6777	AC_CHECK_LIB(Xext,XextCreateExtension,
6778		[CF_ADD_LIB(Xext)])])
6779])dnl
6780dnl ---------------------------------------------------------------------------
6781dnl CF_X_TOOLKIT version: 26 updated: 2021/01/02 09:31:20
6782dnl ------------
6783dnl Check for X Toolkit libraries
6784AC_DEFUN([CF_X_TOOLKIT],
6785[
6786AC_REQUIRE([AC_PATH_XTRA])
6787AC_REQUIRE([CF_CHECK_CACHE])
6788
6789# OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new) (and
6790# in some cases has installed dummy files in the former, other cases replaced
6791# it with a link to the new location).  This complicates the configure script.
6792# Check for that pitfall, and recover using pkg-config
6793#
6794# If none of these are set, the configuration is almost certainly broken.
6795if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
6796then
6797	CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
6798	CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
6799	CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
6800	CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
6801else
6802	LIBS="$X_PRE_LIBS $LIBS $X_EXTRA_LIBS"
6803fi
6804
6805cf_have_X_LIBS=no
6806
6807CF_TRY_PKG_CONFIG(xt,[
6808
6809	case "x$LIBS" in
6810	(*-lX11*)
6811		;;
6812	(*)
6813# we have an "xt" package, but it may omit Xt's dependency on X11
6814AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
6815AC_TRY_LINK([
6816#include <X11/Xlib.h>
6817],[
6818	int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
6819	int rc2 = XClearWindow((Display*) 0, (Window) 0);
6820	int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
6821	int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
6822],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
6823		if test "$cf_cv_xt_x11_compat" = no
6824		then
6825			CF_VERBOSE(work around broken X11 dependency)
6826			# 2010/11/19 - good enough until a working Xt on Xcb is delivered.
6827			CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
6828		fi
6829		;;
6830	esac
6831
6832AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
6833AC_TRY_LINK([
6834#include <X11/Shell.h>
6835],[int num = IceConnectionNumber(0); (void) num
6836],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
6837
6838	if test "$cf_cv_xt_ice_compat" = no
6839	then
6840		# workaround for broken ".pc" files used for X Toolkit.
6841		case "x$X_PRE_LIBS" in
6842		(*-lICE*)
6843			case "x$LIBS" in
6844			(*-lICE*)
6845				;;
6846			(*)
6847				CF_VERBOSE(work around broken ICE dependency)
6848				CF_TRY_PKG_CONFIG(ice,
6849					[CF_TRY_PKG_CONFIG(sm)],
6850					[CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
6851				;;
6852			esac
6853			;;
6854		esac
6855	fi
6856
6857	cf_have_X_LIBS=yes
6858],[
6859
6860	LDFLAGS="$X_LIBS $LDFLAGS"
6861	CF_CHECK_CFLAGS($X_CFLAGS)
6862
6863	AC_CHECK_FUNC(XOpenDisplay,,[
6864	AC_CHECK_LIB(X11,XOpenDisplay,
6865		[CF_ADD_LIB(X11)])])
6866
6867	AC_CHECK_FUNC(XtAppInitialize,,[
6868	AC_CHECK_LIB(Xt, XtAppInitialize,
6869		[AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
6870		 cf_have_X_LIBS=Xt
6871		 LIBS="-lXt $LIBS"])])
6872])
6873
6874if test "$cf_have_X_LIBS" = no ; then
6875	AC_MSG_WARN(
6876[Unable to successfully link X Toolkit library (-lXt) with
6877test program.  You will have to check and add the proper libraries by hand
6878to makefile.])
6879fi
6880])dnl
6881dnl ---------------------------------------------------------------------------
6882dnl CF__ADD_SHLIB_RULES version: 6 updated: 2016/04/21 21:07:50
6883dnl -------------------
6884dnl Append rules for creating, installing, uninstalling and cleaning library.
6885dnl In particular, this is needed for shared libraries since there are symbolic
6886dnl links which depend on configuration choices.
6887dnl
6888dnl The logic is controlled by these cache variables:
6889dnl $cf_cv_do_symlinks
6890dnl $cf_cv_shlib_version
6891dnl
6892dnl The macro uses variables set by CF__DEFINE_SHLIB_VARS
6893dnl
6894dnl $1 = makefile to append to
6895dnl $2 = model (static, shared, libtool)
6896dnl $3 = objects (dependencies)
6897dnl $4 = additional libraries needed to link the shared library
6898define([CF__ADD_SHLIB_RULES],[
6899
6900CF__DEFINE_LIB_TARGET
6901
6902case x$2 in
6903(xlibtool|xshared)
6904	cf_libdeps="ifelse($4,,,[$4])"
6905	;;
6906(x*)
6907	cf_libdeps=
6908	;;
6909esac
6910
6911cat >>$1 <<CF_EOF
6912
6913# generated by CF__ADD_SHLIB_RULES
6914# libmodel: $2
6915# symlinks: $cf_cv_do_symlinks
6916# shlibver: $cf_cv_shlib_version
6917
6918CF_EOF
6919
6920cat >>$1 <<CF_EOF
6921$cf_libname :: \\
6922CF_EOF
6923
6924cat >>$1 <<CF_EOF
6925		$3
6926	@echo linking \[$]@
6927	\$(LIBTOOL_CREATE) $3 $cf_libdeps
6928CF_EOF
6929
6930if test "x$cf_cv_do_symlinks" = xyes
6931then
6932cat >>$1 <<CF_EOF
6933	\$(LN_S) $cf_libname $cf_liblink
6934	\$(LN_S) $cf_liblink $cf_libroot
6935CF_EOF
6936fi
6937
6938cat >>$1 <<CF_EOF
6939
6940install \\
6941install.libs :: \$(DESTDIR)\$(libdir)/$cf_libname
6942
6943\$(DESTDIR)\$(libdir)/$cf_libname :: \\
6944		\$(DESTDIR)\$(libdir) \\
6945		$3
6946	@echo linking \[$]@
6947	\$(LIBTOOL_CREATE) $3 $cf_libdeps
6948CF_EOF
6949
6950if test "x$cf_cv_do_symlinks" = xyes
6951then
6952cat >>$1 <<CF_EOF
6953	cd \$(DESTDIR)\$(libdir) && (\$(LN_S) $cf_libname $cf_liblink; \$(LN_S) $cf_liblink $cf_libroot; )
6954CF_EOF
6955fi
6956
6957if test x$2 = xshared
6958then
6959cat >>$1 <<CF_EOF
6960	- \$(SHELL) -c "if test -z "\$(DESTDIR)" ; then /sbin/ldconfig; fi"
6961CF_EOF
6962fi
6963
6964cat >>$1 <<CF_EOF
6965
6966uninstall \\
6967uninstall.libs ::
6968	@echo uninstalling \$(DESTDIR)\$(libdir)/$cf_libname
6969CF_EOF
6970
6971if test "x$cf_cv_do_symlinks" = xyes
6972then
6973cat >>$1 <<CF_EOF
6974	-rm -f \$(DESTDIR)\$(libdir)/$cf_libroot
6975	-rm -f \$(DESTDIR)\$(libdir)/$cf_liblink
6976CF_EOF
6977fi
6978
6979cat >>$1 <<CF_EOF
6980	-rm -f \$(DESTDIR)\$(libdir)/$cf_libname
6981
6982clean \\
6983clean.libs ::
6984CF_EOF
6985
6986if test "x$cf_cv_do_symlinks" = xyes
6987then
6988cat >>$1 <<CF_EOF
6989	-rm -f $cf_libroot
6990	-rm -f $cf_liblink
6991CF_EOF
6992fi
6993
6994cat >>$1 <<CF_EOF
6995	-rm -f $cf_libname
6996
6997mostlyclean::
6998	-rm -f $3
6999# end generated by CF__ADD_SHLIB_RULES
7000CF_EOF
7001])dnl
7002dnl ---------------------------------------------------------------------------
7003dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
7004dnl ---------------
7005dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
7006dnl are both available.
7007define([CF__CURSES_HEAD],[
7008#ifdef HAVE_XCURSES
7009#include <xcurses.h>
7010char * XCursesProgramName = "test";
7011#else
7012#include <${cf_cv_ncurses_header:-curses.h}>
7013#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
7014#include <ncursesw/term.h>
7015#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
7016#include <ncurses/term.h>
7017#elif defined(HAVE_TERM_H)
7018#include <term.h>
7019#endif
7020#endif
7021])
7022dnl ---------------------------------------------------------------------------
7023dnl CF__DEFINE_LIB_TARGET version: 2 updated: 2015/05/10 19:52:14
7024dnl ---------------------
7025define([CF__DEFINE_LIB_TARGET],[
7026cf_libname=\${LIB_BASENAME}
7027cf_liblink=$cf_libname
7028cf_libroot=$cf_libname
7029
7030if test "x$cf_cv_do_symlinks" = xyes
7031then
7032	case "x$cf_cv_shlib_version" in
7033	(xrel)
7034		cf_liblink="\${LIB_ABI_NAME}"
7035		cf_libname="\${LIB_REL_NAME}"
7036		;;
7037	(xabi)
7038		cf_liblink="\${LIB_REL_NAME}"
7039		cf_libname="\${LIB_ABI_NAME}"
7040		;;
7041	esac
7042fi
7043LIB_TARGET=$cf_libname
7044])dnl
7045dnl ---------------------------------------------------------------------------
7046dnl CF__DEFINE_SHLIB_VARS version: 4 updated: 2015/09/28 17:49:10
7047dnl ---------------------
7048dnl Substitute makefile variables useful for CF__ADD_SHLIB_RULES.
7049dnl
7050dnl The substitution requires these variables:
7051dnl		LIB_PREFIX - "lib"
7052dnl		LIB_ROOTNAME - "foo"
7053dnl		LIB_SUFFIX - ".so"
7054dnl		REL_VERSION - "5.0"
7055dnl		ABI_VERSION - "4.2.4"
7056define([CF__DEFINE_SHLIB_VARS],[
7057CF__DEFINE_LIB_TARGET
7058SET_SHLIB_VARS="# begin CF__DEFINE_SHLIB_VARS\\
7059LIB_BASENAME	= \${LIB_PREFIX}\${LIB_ROOTNAME}\${LIB_SUFFIX}\\
7060LIB_REL_NAME	= \${LIB_BASENAME}.\${REL_VERSION}\\
7061LIB_ABI_NAME	= \${LIB_BASENAME}.\${ABI_VERSION}\\
7062LIB_TARGET	= $LIB_TARGET\\
7063RM_SHARED_OPTS	= $RM_SHARED_OPTS\\
7064# end CF__DEFINE_SHLIB_VARS"
7065AC_SUBST(SET_SHLIB_VARS)
7066AC_SUBST(LIB_TARGET)
7067])dnl
7068dnl ---------------------------------------------------------------------------
7069dnl CF__ICONV_BODY version: 2 updated: 2007/07/26 17:35:47
7070dnl --------------
7071dnl Test-code needed for iconv compile-checks
7072define([CF__ICONV_BODY],[
7073	iconv_t cd = iconv_open("","");
7074	iconv(cd,NULL,NULL,NULL,NULL);
7075	iconv_close(cd);]
7076)dnl
7077dnl ---------------------------------------------------------------------------
7078dnl CF__ICONV_HEAD version: 1 updated: 2007/07/26 15:57:03
7079dnl --------------
7080dnl Header-files needed for iconv compile-checks
7081define([CF__ICONV_HEAD],[
7082#include <stdlib.h>
7083#include <iconv.h>]
7084)dnl
7085dnl ---------------------------------------------------------------------------
7086dnl CF__INIT_SHLIB_RULES version: 2 updated: 2013/07/27 17:38:32
7087dnl --------------------
7088dnl The third parameter to AC_OUTPUT, used to pass variables needed for
7089dnl CF__ADD_SHLIB_RULES.
7090define([CF__INIT_SHLIB_RULES],[
7091ABI_VERSION="$ABI_VERSION"
7092REL_VERSION="$REL_VERSION"
7093LIB_MODEL="$LIB_MODEL"
7094LIB_PREFIX="$LIB_PREFIX"
7095LIB_ROOTNAME="$LIB_ROOTNAME"
7096DFT_DEP_SUFFIX="$DFT_DEP_SUFFIX"
7097RM_SHARED_OPTS="$RM_SHARED_OPTS"
7098cf_cv_do_symlinks="$cf_cv_do_symlinks"
7099cf_cv_shlib_version="$cf_cv_shlib_version"
7100])
7101dnl ---------------------------------------------------------------------------
7102dnl CF__INTL_BODY version: 3 updated: 2017/07/10 20:13:33
7103dnl -------------
7104dnl Test-code needed for libintl compile-checks
7105dnl $1 = parameter 2 from AM_WITH_NLS
7106define([CF__INTL_BODY],[
7107	bindtextdomain ("", "");
7108	return (int) gettext ("")
7109			ifelse([$1], need-ngettext, [ + (int) ngettext ("", "", 0)], [])
7110#ifndef IGNORE_MSGFMT_HACK
7111			[ + _nl_msg_cat_cntr]
7112#endif
7113])
7114dnl ---------------------------------------------------------------------------
7115dnl CF__INTL_HEAD version: 1 updated: 2007/07/26 17:35:47
7116dnl -------------
7117dnl Header-files needed for libintl compile-checks
7118define([CF__INTL_HEAD],[
7119#include <libintl.h>
7120extern int _nl_msg_cat_cntr;
7121])dnl
7122dnl ---------------------------------------------------------------------------
7123dnl jm_GLIBC21 version: 4 updated: 2015/05/10 19:52:14
7124dnl ----------
7125dnl Inserted as requested by gettext 0.10.40
7126dnl File from /usr/share/aclocal
7127dnl glibc21.m4
7128dnl ====================
7129dnl serial 2
7130dnl
7131dnl Test for the GNU C Library, version 2.1 or newer.
7132dnl From Bruno Haible.
7133AC_DEFUN([jm_GLIBC21],
7134[
7135AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
7136	ac_cv_gnu_library_2_1,
7137	[AC_EGREP_CPP([Lucky GNU user],
7138	[
7139#include <features.h>
7140#ifdef __GNU_LIBRARY__
7141 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
7142  Lucky GNU user
7143 #endif
7144#endif
7145	],
7146	ac_cv_gnu_library_2_1=yes,
7147	ac_cv_gnu_library_2_1=no)])
7148	AC_SUBST(GLIBC21)
7149	GLIBC21="$ac_cv_gnu_library_2_1"
7150])
7151