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