aclocal.m4 revision 217309
1dnl macros used for DIALOG configure script
2dnl Copyright 1999-2009,2010 -- Thomas E. Dickey
3dnl
4dnl see
5dnl http://invisible-island.net/autoconf/ 
6dnl
7dnl $Id: aclocal.m4,v 1.75 2010/04/28 20:36:28 tom Exp $
8dnl ---------------------------------------------------------------------------
9dnl ---------------------------------------------------------------------------
10dnl AM_GNU_GETTEXT version: 11 updated: 2004/01/26 20:58:40
11dnl --------------
12dnl Usage: Just like AM_WITH_NLS, which see.
13AC_DEFUN([AM_GNU_GETTEXT],
14  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
15   AC_REQUIRE([AC_PROG_CC])dnl
16   AC_REQUIRE([AC_CANONICAL_HOST])dnl
17   AC_REQUIRE([AC_PROG_RANLIB])dnl
18   AC_REQUIRE([AC_ISC_POSIX])dnl
19   AC_REQUIRE([AC_HEADER_STDC])dnl
20   AC_REQUIRE([AC_C_CONST])dnl
21   AC_REQUIRE([AC_C_INLINE])dnl
22   AC_REQUIRE([AC_TYPE_OFF_T])dnl
23   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
24   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
25   AC_REQUIRE([AC_FUNC_MMAP])dnl
26   AC_REQUIRE([jm_GLIBC21])dnl
27
28   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
29stdlib.h string.h unistd.h sys/param.h])
30   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
31getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
32strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
33
34   AM_ICONV
35   AM_LANGINFO_CODESET
36   AM_LC_MESSAGES
37   AM_WITH_NLS([$1],[$2],[$3],[$4])
38
39   if test "x$CATOBJEXT" != "x"; then
40     if test "x$ALL_LINGUAS" = "x"; then
41       LINGUAS=
42     else
43       AC_MSG_CHECKING(for catalogs to be installed)
44       NEW_LINGUAS=
45       for presentlang in $ALL_LINGUAS; do
46         useit=no
47         for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
48           # Use the presentlang catalog if desiredlang is
49           #   a. equal to presentlang, or
50           #   b. a variant of presentlang (because in this case,
51           #      presentlang can be used as a fallback for messages
52           #      which are not translated in the desiredlang catalog).
53           case "$desiredlang" in
54             "$presentlang"*) useit=yes;;
55           esac
56         done
57         if test $useit = yes; then
58           NEW_LINGUAS="$NEW_LINGUAS $presentlang"
59         fi
60       done
61       LINGUAS=$NEW_LINGUAS
62       AC_MSG_RESULT($LINGUAS)
63     fi
64
65     dnl Construct list of names of catalog files to be constructed.
66     if test -n "$LINGUAS"; then
67       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
68     fi
69   fi
70
71   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
72   dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
73   dnl Try to locate it.
74   dnl changed mkinstalldirs to mkdirs.sh for Lynx /je spath 1998-Aug-21
75   dnl added check for separate locations of scripts -mirabile 2004-Jan-18
76   MKINSTALLDIRS=
77   if test -n "$ac_aux_dir"; then
78     MKINSTALLDIRS="$ac_aux_dir/mkdirs.sh"
79   fi
80   if test -z "$MKINSTALLDIRS"; then
81     MKINSTALLDIRS="\$(top_srcdir)/mkdirs.sh"
82   fi
83   if test -n "$GNUSYSTEM_AUX_DIR" ; then
84     if test -e "${GNUSYSTEM_AUX_DIR}/mkinstalldirs"; then
85       MKINSTALLDIRS="${GNUSYSTEM_AUX_DIR}/mkinstalldirs"
86     fi
87   fi
88   AC_SUBST(MKINSTALLDIRS)
89
90   dnl Enable libtool support if the surrounding package wishes it.
91   INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
92   AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
93])dnl
94dnl ---------------------------------------------------------------------------
95dnl AM_ICONV version: 12 updated: 2007/07/30 19:12:03
96dnl --------
97dnl Inserted as requested by gettext 0.10.40
98dnl File from /usr/share/aclocal
99dnl iconv.m4
100dnl ====================
101dnl serial AM2
102dnl
103dnl From Bruno Haible.
104dnl
105dnl ====================
106dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
107dnl range of locations searched.  Retain the same cache-variable naming to
108dnl allow reuse with the other gettext macros -Thomas E Dickey
109AC_DEFUN([AM_ICONV],
110[
111  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
112  dnl those with the standalone portable GNU libiconv installed).
113
114  AC_ARG_WITH([libiconv-prefix],
115[  --with-libiconv-prefix=DIR
116                          search for libiconv in DIR/include and DIR/lib], [
117    CF_ADD_OPTIONAL_PATH($withval, libiconv)
118   ])
119
120  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
121    CF_FIND_LINKAGE(CF__ICONV_HEAD,
122      CF__ICONV_BODY,
123      iconv,
124      am_cv_func_iconv=yes,
125      am_cv_func_iconv=["no, consider installing GNU libiconv"])])
126
127  if test "$am_cv_func_iconv" = yes; then
128    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
129
130    AC_CACHE_CHECK([if the declaration of iconv() needs const.],
131		   am_cv_proto_iconv_const,[
132      AC_TRY_COMPILE(CF__ICONV_HEAD [
133extern
134#ifdef __cplusplus
135"C"
136#endif
137#if defined(__STDC__) || defined(__cplusplus)
138size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
139#else
140size_t iconv();
141#endif
142],[], am_cv_proto_iconv_const=no,
143      am_cv_proto_iconv_const=yes)])
144
145    if test "$am_cv_proto_iconv_const" = yes ; then
146      am_cv_proto_iconv_arg1="const"
147    else
148      am_cv_proto_iconv_arg1=""
149    fi
150
151    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
152      [Define as const if the declaration of iconv() needs const.])
153  fi
154
155  LIBICONV=
156  if test "$cf_cv_find_linkage_iconv" = yes; then
157    CF_ADD_INCDIR($cf_cv_header_path_iconv)
158    if test -n "$cf_cv_library_file_iconv" ; then
159      LIBICONV="-liconv"
160      CF_ADD_LIBDIR($cf_cv_library_path_iconv)
161    fi
162  fi
163
164  AC_SUBST(LIBICONV)
165])dnl
166dnl ---------------------------------------------------------------------------
167dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
168dnl -------------------
169dnl Inserted as requested by gettext 0.10.40
170dnl File from /usr/share/aclocal
171dnl codeset.m4
172dnl ====================
173dnl serial AM1
174dnl
175dnl From Bruno Haible.
176AC_DEFUN([AM_LANGINFO_CODESET],
177[
178  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
179    [AC_TRY_LINK([#include <langinfo.h>],
180      [char* cs = nl_langinfo(CODESET);],
181      am_cv_langinfo_codeset=yes,
182      am_cv_langinfo_codeset=no)
183    ])
184  if test $am_cv_langinfo_codeset = yes; then
185    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
186      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
187  fi
188])dnl
189dnl ---------------------------------------------------------------------------
190dnl AM_LC_MESSAGES version: 4 updated: 2002/10/27 23:21:42
191dnl --------------
192dnl Inserted as requested by gettext 0.10.40
193dnl File from /usr/share/aclocal
194dnl lcmessage.m4
195dnl ====================
196dnl Check whether LC_MESSAGES is available in <locale.h>.
197dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
198dnl
199dnl This file can be copied and used freely without restrictions.  It can
200dnl be used in projects which are not available under the GNU General Public
201dnl License or the GNU Library General Public License but which still want
202dnl to provide support for the GNU gettext functionality.
203dnl Please note that the actual code of the GNU gettext library is covered
204dnl by the GNU Library General Public License, and the rest of the GNU
205dnl gettext package package is covered by the GNU General Public License.
206dnl They are *not* in the public domain.
207dnl
208dnl serial 2
209dnl
210AC_DEFUN([AM_LC_MESSAGES],
211  [if test $ac_cv_header_locale_h = yes; then
212    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
213      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
214       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
215    if test $am_cv_val_LC_MESSAGES = yes; then
216      AC_DEFINE(HAVE_LC_MESSAGES, 1,
217        [Define if your <locale.h> file defines LC_MESSAGES.])
218    fi
219  fi])dnl
220dnl ---------------------------------------------------------------------------
221dnl AM_PATH_PROG_WITH_TEST version: 8 updated: 2009/01/11 20:31:12
222dnl ----------------------
223dnl Inserted as requested by gettext 0.10.40
224dnl File from /usr/share/aclocal
225dnl progtest.m4
226dnl ====================
227dnl Search path for a program which passes the given test.
228dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
229dnl
230dnl This file can be copied and used freely without restrictions.  It can
231dnl be used in projects which are not available under the GNU General Public
232dnl License or the GNU Library General Public License but which still want
233dnl to provide support for the GNU gettext functionality.
234dnl Please note that the actual code of the GNU gettext library is covered
235dnl by the GNU Library General Public License, and the rest of the GNU
236dnl gettext package package is covered by the GNU General Public License.
237dnl They are *not* in the public domain.
238dnl
239dnl serial 2
240dnl
241dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
242dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
243AC_DEFUN([AM_PATH_PROG_WITH_TEST],
244[# Extract the first word of "$2", so it can be a program name with args.
245AC_REQUIRE([CF_PATHSEP])
246set dummy $2; ac_word=[$]2
247AC_MSG_CHECKING([for $ac_word])
248AC_CACHE_VAL(ac_cv_path_$1,
249[case "[$]$1" in
250  [[\\/]*|?:[\\/]]*)
251  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
252  ;;
253  *)
254  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
255  for ac_dir in ifelse([$5], , $PATH, [$5]); do
256    test -z "$ac_dir" && ac_dir=.
257    if test -f $ac_dir/$ac_word$ac_exeext; then
258      if [$3]; then
259	ac_cv_path_$1="$ac_dir/$ac_word$ac_exeext"
260	break
261      fi
262    fi
263  done
264  IFS="$ac_save_ifs"
265dnl If no 4th arg is given, leave the cache variable unset,
266dnl so AC_PATH_PROGS will keep looking.
267ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
268])dnl
269  ;;
270esac])dnl
271$1="$ac_cv_path_$1"
272if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
273  AC_MSG_RESULT([$]$1)
274else
275  AC_MSG_RESULT(no)
276fi
277AC_SUBST($1)dnl
278])dnl
279dnl ---------------------------------------------------------------------------
280dnl AM_WITH_NLS version: 23 updated: 2009/01/11 19:52:42
281dnl -----------
282dnl Inserted as requested by gettext 0.10.40
283dnl File from /usr/share/aclocal
284dnl gettext.m4
285dnl ====================
286dnl Macro to add for using GNU gettext.
287dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
288dnl ====================
289dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
290dnl range of locations searched.  Retain the same cache-variable naming to
291dnl allow reuse with the other gettext macros -Thomas E Dickey
292dnl ====================
293dnl
294dnl This file can be copied and used freely without restrictions.  It can
295dnl be used in projects which are not available under the GNU General Public
296dnl License or the GNU Library General Public License but which still want
297dnl to provide support for the GNU gettext functionality.
298dnl Please note that the actual code of the GNU gettext library is covered
299dnl by the GNU Library General Public License, and the rest of the GNU
300dnl gettext package package is covered by the GNU General Public License.
301dnl They are *not* in the public domain.
302dnl
303dnl serial 10
304dnl
305dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
306dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
307dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
308dnl    depending on --{enable,disable}-{shared,static} and on the presence of
309dnl    AM-DISABLE-SHARED). Otherwise, a static library
310dnl    $(top_builddir)/intl/libintl.a will be created.
311dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
312dnl    implementations (in libc or libintl) without the ngettext() function
313dnl    will be ignored.
314dnl LIBDIR is used to find the intl libraries.  If empty,
315dnl    the value `$(top_builddir)/intl/' is used.
316dnl ENABLED is used to control the default for the related --enable-nls, since
317dnl    not all application developers want this feature by default, e.g., lynx.
318dnl
319dnl The result of the configuration is one of three cases:
320dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
321dnl    and used.
322dnl    Catalog format: GNU --> install in $(datadir)
323dnl    Catalog extension: .mo after installation, .gmo in source tree
324dnl 2) GNU gettext has been found in the system's C library.
325dnl    Catalog format: GNU --> install in $(datadir)
326dnl    Catalog extension: .mo after installation, .gmo in source tree
327dnl 3) No internationalization, always use English msgid.
328dnl    Catalog format: none
329dnl    Catalog extension: none
330dnl The use of .gmo is historical (it was needed to avoid overwriting the
331dnl GNU format catalogs when building on a platform with an X/Open gettext),
332dnl but we keep it in order not to force irrelevant filename changes on the
333dnl maintainers.
334dnl
335AC_DEFUN([AM_WITH_NLS],
336[AC_MSG_CHECKING([whether NLS is requested])
337  dnl Default is enabled NLS
338  ifelse([$4],,[
339  AC_ARG_ENABLE(nls,
340    [  --disable-nls           do not use Native Language Support],
341    USE_NLS=$enableval, USE_NLS=yes)],[
342  AC_ARG_ENABLE(nls,
343    [  --enable-nls            use Native Language Support],
344    USE_NLS=$enableval, USE_NLS=no)])
345  AC_MSG_RESULT($USE_NLS)
346  AC_SUBST(USE_NLS)
347
348  BUILD_INCLUDED_LIBINTL=no
349  USE_INCLUDED_LIBINTL=no
350  INTLLIBS=
351
352  dnl If we use NLS figure out what method
353  if test "$USE_NLS" = "yes"; then
354    AC_DEFINE(ENABLE_NLS, 1,
355      [Define to 1 if translation of program messages to the user's native language
356 is requested.])
357    AC_MSG_CHECKING([whether included gettext is requested])
358    AC_ARG_WITH(included-gettext,
359      [  --with-included-gettext use the GNU gettext library included here],
360      nls_cv_force_use_gnu_gettext=$withval,
361      nls_cv_force_use_gnu_gettext=no)
362    AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
363
364    nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
365    if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
366      dnl User does not insist on using GNU NLS library.  Figure out what
367      dnl to use.  If GNU gettext is available we use this.  Else we have
368      dnl to fall back to GNU NLS library.
369      CATOBJEXT=NONE
370
371      cf_save_LIBS_1="$LIBS"
372      LIBS="$LIBICONV $LIBS"
373      AC_CACHE_CHECK([for libintl.h and gettext()], cf_cv_func_gettext,[
374        CF_FIND_LINKAGE(CF__INTL_HEAD,
375        CF__INTL_BODY,
376        intl,
377        cf_cv_func_gettext=yes,
378        cf_cv_func_gettext=no)
379      ])
380      LIBS="$cf_save_LIBS_1"
381
382      if test "$cf_cv_func_gettext" = yes ; then
383        AC_DEFINE(HAVE_LIBINTL_H)
384
385        dnl If an already present or preinstalled GNU gettext() is found,
386        dnl use it.  But if this macro is used in GNU gettext, and GNU
387        dnl gettext is already preinstalled in libintl, we update this
388        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
389        if test "$PACKAGE" != gettext; then
390          AC_DEFINE(HAVE_GETTEXT, 1,
391              [Define if the GNU gettext() function is already present or preinstalled.])
392
393          CF_ADD_INCDIR($cf_cv_header_path_intl)
394
395          if test -n "$cf_cv_library_file_intl" ; then
396            dnl If iconv() is in a separate libiconv library, then anyone
397            dnl linking with libintl{.a,.so} also needs to link with
398            dnl libiconv.
399            INTLLIBS="$cf_cv_library_file_intl $LIBICONV"
400            CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
401          fi
402
403          gt_save_LIBS="$LIBS"
404          LIBS="$LIBS $INTLLIBS"
405          AC_CHECK_FUNCS(dcgettext)
406          LIBS="$gt_save_LIBS"
407
408          dnl Search for GNU msgfmt in the PATH.
409          AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
410              [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
411          AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
412
413          dnl Search for GNU xgettext in the PATH.
414          AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
415              [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
416
417          CATOBJEXT=.gmo
418        fi
419      fi
420
421      if test "$CATOBJEXT" = "NONE"; then
422        dnl GNU gettext is not found in the C library.
423        dnl Fall back on GNU gettext library.
424        nls_cv_use_gnu_gettext=yes
425      fi
426    fi
427
428    if test "$nls_cv_use_gnu_gettext" = "yes"; then
429      if test ! -d $srcdir/intl ; then
430        AC_MSG_ERROR(no NLS library is packaged with this application)
431      fi
432      dnl Mark actions used to generate GNU NLS library.
433      INTLOBJS="\$(GETTOBJS)"
434      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
435          [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
436      AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
437      AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
438          [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
439      AC_SUBST(MSGFMT)
440      BUILD_INCLUDED_LIBINTL=yes
441      USE_INCLUDED_LIBINTL=yes
442      CATOBJEXT=.gmo
443      INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
444      LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
445    fi
446
447    dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
448    dnl Test whether we really found GNU msgfmt.
449    if test "$GMSGFMT" != ":"; then
450      dnl If it is no GNU msgfmt we define it as : so that the
451      dnl Makefiles still can work.
452      if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
453        : ;
454      else
455        AC_MSG_RESULT(
456          [found msgfmt program is not GNU msgfmt; ignore it])
457        GMSGFMT=":"
458      fi
459    fi
460
461    dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
462    dnl Test whether we really found GNU xgettext.
463    if test "$XGETTEXT" != ":"; then
464        dnl If it is no GNU xgettext we define it as : so that the
465        dnl Makefiles still can work.
466      if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
467        : ;
468      else
469        AC_MSG_RESULT(
470          [found xgettext program is not GNU xgettext; ignore it])
471        XGETTEXT=":"
472      fi
473    fi
474
475    dnl We need to process the po/ directory.
476    POSUB=po
477  fi
478
479  AC_OUTPUT_COMMANDS(
480   [for ac_file in $CONFIG_FILES; do
481
482      # Support "outfile[:infile[:infile...]]"
483      case "$ac_file" in
484        *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
485      esac
486
487      # PO directories have a Makefile.in generated from Makefile.inn.
488      case "$ac_file" in */[Mm]akefile.in)
489        # Adjust a relative srcdir.
490        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
491        ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
492        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
493        ac_base=`basename $ac_file .in`
494        # In autoconf-2.13 it is called $ac_given_srcdir.
495        # In autoconf-2.50 it is called $srcdir.
496        test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
497
498        case "$ac_given_srcdir" in
499          .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
500          /*) top_srcdir="$ac_given_srcdir" ;;
501          *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
502        esac
503
504        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
505          rm -f "$ac_dir/POTFILES"
506          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
507          sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
508          test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
509          sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
510        fi
511        ;;
512      esac
513    done])
514
515  dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
516  dnl to 'yes' because some of the testsuite requires it.
517  if test "$PACKAGE" = gettext; then
518    BUILD_INCLUDED_LIBINTL=yes
519  fi
520
521  dnl intl/plural.c is generated from intl/plural.y. It requires bison,
522  dnl because plural.y uses bison specific features. It requires at least
523  dnl bison-1.26 because earlier versions generate a plural.c that doesn't
524  dnl compile.
525  dnl bison is only needed for the maintainer (who touches plural.y). But in
526  dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
527  dnl the rule in general Makefile. Now, some people carelessly touch the
528  dnl files or have a broken "make" program, hence the plural.c rule will
529  dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
530  dnl present or too old.
531  if test "$nls_cv_use_gnu_gettext" = "yes"; then
532    AC_CHECK_PROGS([INTLBISON], [bison])
533    if test -z "$INTLBISON"; then
534      ac_verc_fail=yes
535    else
536      dnl Found it, now check the version.
537      AC_MSG_CHECKING([version of bison])
538changequote(<<,>>)dnl
539      ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
540      case $ac_prog_version in
541        '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
542        1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
543changequote([,])dnl
544           ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
545        *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
546      esac
547    AC_MSG_RESULT([$ac_prog_version])
548    fi
549    if test $ac_verc_fail = yes; then
550      INTLBISON=:
551    fi
552  fi
553
554  dnl These rules are solely for the distribution goal.  While doing this
555  dnl we only have to keep exactly one list of the available catalogs
556  dnl in configure.in.
557  for lang in $ALL_LINGUAS; do
558    GMOFILES="$GMOFILES $lang.gmo"
559    POFILES="$POFILES $lang.po"
560  done
561
562  dnl Make all variables we use known to autoconf.
563  AC_SUBST(BUILD_INCLUDED_LIBINTL)
564  AC_SUBST(USE_INCLUDED_LIBINTL)
565  AC_SUBST(CATALOGS)
566  AC_SUBST(CATOBJEXT)
567  AC_SUBST(GMOFILES)
568  AC_SUBST(INTLLIBS)
569  AC_SUBST(INTLOBJS)
570  AC_SUBST(POFILES)
571  AC_SUBST(POSUB)
572
573  dnl For backward compatibility. Some configure.ins may be using this.
574  nls_cv_header_intl=
575  nls_cv_header_libgt=
576
577  dnl For backward compatibility. Some Makefiles may be using this.
578  DATADIRNAME=share
579  AC_SUBST(DATADIRNAME)
580
581  dnl For backward compatibility. Some Makefiles may be using this.
582  INSTOBJEXT=.mo
583  AC_SUBST(INSTOBJEXT)
584
585  dnl For backward compatibility. Some Makefiles may be using this.
586  GENCAT=gencat
587  AC_SUBST(GENCAT)
588])dnl
589dnl ---------------------------------------------------------------------------
590dnl CF_AC_PREREQ version: 2 updated: 1997/09/06 13:24:56
591dnl ------------
592dnl Conditionally generate script according to whether we're using the release
593dnl version of autoconf, or a patched version (using the ternary component as
594dnl the patch-version).
595define(CF_AC_PREREQ,
596[CF_PREREQ_COMPARE(
597AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)),
598AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), [$1], [$2], [$3])])dnl
599dnl ---------------------------------------------------------------------------
600dnl CF_ADD_CFLAGS version: 9 updated: 2010/01/09 11:05:50
601dnl -------------
602dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
603dnl The second parameter if given makes this macro verbose.
604dnl
605dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
606dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
607dnl confused by the quotes (which require backslashes to keep them usable).
608AC_DEFUN([CF_ADD_CFLAGS],
609[
610cf_fix_cppflags=no
611cf_new_cflags=
612cf_new_cppflags=
613cf_new_extra_cppflags=
614
615for cf_add_cflags in $1
616do
617case $cf_fix_cppflags in
618no)
619	case $cf_add_cflags in #(vi
620	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
621		case $cf_add_cflags in
622		-D*)
623			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
624
625			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
626				&& test -z "${cf_tst_cflags}" \
627				&& cf_fix_cppflags=yes
628
629			if test $cf_fix_cppflags = yes ; then
630				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
631				continue
632			elif test "${cf_tst_cflags}" = "\"'" ; then
633				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
634				continue
635			fi
636			;;
637		esac
638		case "$CPPFLAGS" in
639		*$cf_add_cflags) #(vi
640			;;
641		*) #(vi
642			case $cf_add_cflags in #(vi
643			-D*)
644				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
645				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
646				;;
647			esac
648			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
649			;;
650		esac
651		;;
652	*)
653		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
654		;;
655	esac
656	;;
657yes)
658	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
659
660	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
661
662	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
663		&& test -z "${cf_tst_cflags}" \
664		&& cf_fix_cppflags=no
665	;;
666esac
667done
668
669if test -n "$cf_new_cflags" ; then
670	ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
671	CFLAGS="$CFLAGS $cf_new_cflags"
672fi
673
674if test -n "$cf_new_cppflags" ; then
675	ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
676	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
677fi
678
679if test -n "$cf_new_extra_cppflags" ; then
680	ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
681	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
682fi
683
684AC_SUBST(EXTRA_CPPFLAGS)
685
686])dnl
687dnl ---------------------------------------------------------------------------
688dnl CF_ADD_INCDIR version: 12 updated: 2009/01/18 10:00:47
689dnl -------------
690dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
691dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
692dnl but old versions (and some misinstalled ones) need that.  To make things
693dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
694dnl the include-path).
695AC_DEFUN([CF_ADD_INCDIR],
696[
697if test -n "$1" ; then
698  for cf_add_incdir in $1
699  do
700	while test $cf_add_incdir != /usr/include
701	do
702	  if test -d $cf_add_incdir
703	  then
704		cf_have_incdir=no
705		if test -n "$CFLAGS$CPPFLAGS" ; then
706		  # a loop is needed to ensure we can add subdirs of existing dirs
707		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
708			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
709			  cf_have_incdir=yes; break
710			fi
711		  done
712		fi
713
714		if test "$cf_have_incdir" = no ; then
715		  if test "$cf_add_incdir" = /usr/local/include ; then
716			if test "$GCC" = yes
717			then
718			  cf_save_CPPFLAGS=$CPPFLAGS
719			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
720			  AC_TRY_COMPILE([#include <stdio.h>],
721				  [printf("Hello")],
722				  [],
723				  [cf_have_incdir=yes])
724			  CPPFLAGS=$cf_save_CPPFLAGS
725			fi
726		  fi
727		fi
728
729		if test "$cf_have_incdir" = no ; then
730		  CF_VERBOSE(adding $cf_add_incdir to include-path)
731		  ifelse($2,,CPPFLAGS,$2)="$ifelse($2,,CPPFLAGS,$2) -I$cf_add_incdir"
732
733		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
734		  test "$cf_top_incdir" = "$cf_add_incdir" && break
735		  cf_add_incdir="$cf_top_incdir"
736		else
737		  break
738		fi
739	  fi
740	done
741  done
742fi
743])dnl
744dnl ---------------------------------------------------------------------------
745dnl CF_ADD_LIBDIR version: 8 updated: 2009/01/18 10:01:08
746dnl -------------
747dnl	Adds to the library-path
748dnl
749dnl	Some machines have trouble with multiple -L options.
750dnl
751dnl $1 is the (list of) directory(s) to add
752dnl $2 is the optional name of the variable to update (default LDFLAGS)
753dnl
754AC_DEFUN([CF_ADD_LIBDIR],
755[
756if test -n "$1" ; then
757  for cf_add_libdir in $1
758  do
759    if test $cf_add_libdir = /usr/lib ; then
760      :
761    elif test -d $cf_add_libdir
762    then
763      cf_have_libdir=no
764      if test -n "$LDFLAGS$LIBS" ; then
765        # a loop is needed to ensure we can add subdirs of existing dirs
766        for cf_test_libdir in $LDFLAGS $LIBS ; do
767          if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
768            cf_have_libdir=yes; break
769          fi
770        done
771      fi
772      if test "$cf_have_libdir" = no ; then
773        CF_VERBOSE(adding $cf_add_libdir to library-path)
774        ifelse($2,,LDFLAGS,$2)="-L$cf_add_libdir $ifelse($2,,LDFLAGS,$2)"
775      fi
776    fi
777  done
778fi
779])dnl
780dnl ---------------------------------------------------------------------------
781dnl CF_ADD_OPTIONAL_PATH version: 1 updated: 2007/07/29 12:33:33
782dnl --------------------
783dnl Add an optional search-path to the compile/link variables.
784dnl See CF_WITH_PATH
785dnl
786dnl $1 = shell variable containing the result of --with-XXX=[DIR]
787dnl $2 = module to look for.
788AC_DEFUN([CF_ADD_OPTIONAL_PATH],[
789  case "$1" in #(vi
790  no) #(vi
791      ;;
792  yes) #(vi
793      ;;
794  *)
795      CF_ADD_SEARCHPATH([$1], [AC_MSG_ERROR(cannot find $2 under $1)])
796      ;;
797  esac
798])dnl
799dnl ---------------------------------------------------------------------------
800dnl CF_ADD_SEARCHPATH version: 5 updated: 2009/01/11 20:40:21
801dnl -----------------
802dnl Set $CPPFLAGS and $LDFLAGS with the directories given via the parameter.
803dnl They can be either the common root of include- and lib-directories, or the
804dnl lib-directory (to allow for things like lib64 directories).
805dnl See also CF_FIND_LINKAGE.
806dnl
807dnl $1 is the list of colon-separated directory names to search.
808dnl $2 is the action to take if a parameter does not yield a directory.
809AC_DEFUN([CF_ADD_SEARCHPATH],
810[
811AC_REQUIRE([CF_PATHSEP])
812for cf_searchpath in `echo "$1" | tr $PATH_SEPARATOR ' '`; do
813	if test -d $cf_searchpath/include; then
814		CF_ADD_INCDIR($cf_searchpath/include)
815	elif test -d $cf_searchpath/../include ; then
816		CF_ADD_INCDIR($cf_searchpath/../include)
817	ifelse([$2],,,[else
818$2])
819	fi
820	if test -d $cf_searchpath/lib; then
821		CF_ADD_LIBDIR($cf_searchpath/lib)
822	elif test -d $cf_searchpath ; then
823		CF_ADD_LIBDIR($cf_searchpath)
824	ifelse([$2],,,[else
825$2])
826	fi
827done
828])
829dnl ---------------------------------------------------------------------------
830dnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
831dnl ------------------
832dnl Append to a search-list for a nonstandard header/lib-file
833dnl	$1 = the variable to return as result
834dnl	$2 = the package name
835dnl	$3 = the subdirectory, e.g., bin, include or lib
836dnl $4 = the directory under which we will test for subdirectories
837dnl $5 = a directory that we do not want $4 to match
838AC_DEFUN([CF_ADD_SUBDIR_PATH],
839[
840test "$4" != "$5" && \
841test -d "$4" && \
842ifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
843	test -n "$verbose" && echo "	... testing for $3-directories under $4"
844	test -d $4/$3 &&          $1="[$]$1 $4/$3"
845	test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
846	test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
847	test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
848	test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
849}
850])dnl
851dnl ---------------------------------------------------------------------------
852dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
853dnl --------------
854dnl Allow user to disable a normally-on option.
855AC_DEFUN([CF_ARG_DISABLE],
856[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
857dnl ---------------------------------------------------------------------------
858dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
859dnl -------------
860dnl Allow user to enable a normally-off option.
861AC_DEFUN([CF_ARG_ENABLE],
862[CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
863dnl ---------------------------------------------------------------------------
864dnl CF_ARG_MSG_ENABLE version: 2 updated: 2000/07/29 19:32:03
865dnl -----------------
866dnl Verbose form of AC_ARG_ENABLE:
867dnl
868dnl Parameters:
869dnl $1 = message
870dnl $2 = option name
871dnl $3 = help-string
872dnl $4 = action to perform if option is enabled
873dnl $5 = action if perform if option is disabled
874dnl $6 = default option value (either 'yes' or 'no')
875AC_DEFUN([CF_ARG_MSG_ENABLE],[
876AC_MSG_CHECKING($1)
877AC_ARG_ENABLE($2,[$3],,enableval=ifelse($6,,no,$6))
878AC_MSG_RESULT($enableval)
879if test "$enableval" != no ; then
880ifelse($4,,[	:],$4)
881else
882ifelse($5,,[	:],$5)
883fi
884])dnl
885dnl ---------------------------------------------------------------------------
886dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
887dnl -------------
888dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
889dnl values.
890dnl
891dnl Parameters:
892dnl $1 = option name
893dnl $2 = help-string
894dnl $3 = action to perform if option is not default
895dnl $4 = action if perform if option is default
896dnl $5 = default option value (either 'yes' or 'no')
897AC_DEFUN([CF_ARG_OPTION],
898[AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
899  if test "$enableval" != "$5" ; then
900ifelse($3,,[    :]dnl
901,[    $3]) ifelse($4,,,[
902  else
903    $4])
904  fi],[enableval=$5 ifelse($4,,,[
905  $4
906])dnl
907  ])])dnl
908dnl ---------------------------------------------------------------------------
909dnl CF_BUNDLED_INTL version: 14 updated: 2010/01/17 20:37:27
910dnl ---------------
911dnl Top-level macro for configuring an application with a bundled copy of
912dnl the intl and po directories for gettext.
913dnl
914dnl $1 specifies either Makefile or makefile, defaulting to the former.
915dnl $2 if nonempty sets the option to --enable-nls rather than to --disable-nls
916dnl
917dnl Sets variables which can be used to substitute in makefiles:
918dnl	GT_YES       - "#" comment unless building intl library, otherwise empty
919dnl	GT_NO        - "#" comment if building intl library, otherwise empty
920dnl	INTLDIR_MAKE - to make ./intl directory
921dnl	MSG_DIR_MAKE - to make ./po directory
922dnl	SUB_MAKEFILE - list of makefiles in ./intl, ./po directories
923dnl Defines
924dnl	HAVE_LIBGETTEXT_H if we're using ./intl
925dnl
926dnl Environment:
927dnl	ALL_LINGUAS if set, lists the root names of the ".po" files.
928dnl	CONFIG_H assumed to be "config.h"
929dnl	VERSION may be set, otherwise extract from "VERSION" file.
930dnl
931AC_DEFUN([CF_BUNDLED_INTL],[
932cf_makefile=ifelse($1,,Makefile,$1)
933
934dnl Set of available languages (based on source distribution).  Note that
935dnl setting $LINGUAS overrides $ALL_LINGUAS.  Some environments set $LINGUAS
936dnl rather than $LC_ALL
937test -z "$ALL_LINGUAS" && ALL_LINGUAS=`test -d $srcdir/po && cd $srcdir/po && echo *.po|sed -e 's/\.po//g' -e 's/*//'`
938
939# Allow override of "config.h" definition:
940: ${CONFIG_H=config.h}
941AC_SUBST(CONFIG_H)
942
943if test -z "$VERSION" ; then
944if test -f $srcdir/VERSION ; then
945	VERSION=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
946else
947	VERSION=unknown
948fi
949fi
950AC_SUBST(VERSION)
951
952AM_GNU_GETTEXT(,,,[$2])
953
954INTLDIR_MAKE=
955MSG_DIR_MAKE=
956SUB_MAKEFILE=
957
958dnl this updates SUB_MAKEFILE and MSG_DIR_MAKE:
959CF_OUR_MESSAGES($1)
960
961if test "$USE_INCLUDED_LIBINTL" = yes ; then
962        if test "$nls_cv_force_use_gnu_gettext" = yes ; then
963		:
964	elif test "$nls_cv_use_gnu_gettext" = yes ; then
965		:
966	else
967		INTLDIR_MAKE="#"
968	fi
969	if test -z "$INTLDIR_MAKE"; then
970		AC_DEFINE(HAVE_LIBGETTEXT_H)
971		for cf_makefile in \
972			$srcdir/intl/Makefile.in \
973			$srcdir/intl/makefile.in
974		do
975			if test -f "$cf_makefile" ; then
976				SUB_MAKEFILE="$SUB_MAKEFILE `echo \"${cf_makefile}\"|sed -e 's,^'$srcdir/',,' -e 's/\.in$//'`:${cf_makefile}"
977				break
978			fi
979		done
980	fi
981else
982	INTLDIR_MAKE="#"
983	if test "$USE_NLS" = yes ; then
984		AC_CHECK_HEADERS(libintl.h)
985	fi
986fi
987
988if test -z "$INTLDIR_MAKE" ; then
989	CPPFLAGS="$CPPFLAGS -I../intl"
990fi
991
992dnl FIXME:  we use this in lynx (the alternative is a spurious dependency upon
993dnl GNU make)
994if test "$BUILD_INCLUDED_LIBINTL" = yes ; then
995	GT_YES="#"
996	GT_NO=
997else
998	GT_YES=
999	GT_NO="#"
1000fi
1001
1002AC_SUBST(INTLDIR_MAKE)
1003AC_SUBST(MSG_DIR_MAKE)
1004AC_SUBST(GT_YES)
1005AC_SUBST(GT_NO)
1006
1007dnl FIXME:  the underlying AM_GNU_GETTEXT macro either needs some fixes or a
1008dnl little documentation.  It doesn't define anything so that we can ifdef our
1009dnl own code, except ENABLE_NLS, which is too vague to be of any use.
1010
1011if test "$USE_INCLUDED_LIBINTL" = yes ; then
1012	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1013		AC_DEFINE(HAVE_GETTEXT)
1014	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1015		AC_DEFINE(HAVE_GETTEXT)
1016	fi
1017	if test -n "$nls_cv_header_intl" ; then
1018		AC_DEFINE(HAVE_LIBINTL_H)
1019	fi
1020fi
1021])dnl
1022dnl ---------------------------------------------------------------------------
1023dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
1024dnl --------------
1025dnl Check if we're accidentally using a cache from a different machine.
1026dnl Derive the system name, as a check for reusing the autoconf cache.
1027dnl
1028dnl If we've packaged config.guess and config.sub, run that (since it does a
1029dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1030dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1031dnl which is useful in cross-compiles.
1032dnl
1033dnl Note: we would use $ac_config_sub, but that is one of the places where
1034dnl autoconf 2.5x broke compatibility with autoconf 2.13
1035AC_DEFUN([CF_CHECK_CACHE],
1036[
1037if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
1038	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
1039	system_name="$host_os"
1040else
1041	system_name="`(uname -s -r) 2>/dev/null`"
1042	if test -z "$system_name" ; then
1043		system_name="`(hostname) 2>/dev/null`"
1044	fi
1045fi
1046test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
1047AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1048
1049test -z "$system_name" && system_name="$cf_cv_system_name"
1050test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1051
1052if test ".$system_name" != ".$cf_cv_system_name" ; then
1053	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
1054	AC_MSG_ERROR("Please remove config.cache and try again.")
1055fi
1056])dnl
1057dnl ---------------------------------------------------------------------------
1058dnl CF_CURSES_CHTYPE version: 6 updated: 2003/11/06 19:59:57
1059dnl ----------------
1060dnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
1061AC_DEFUN([CF_CURSES_CHTYPE],
1062[
1063AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1064AC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[
1065	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>],
1066		[chtype foo],
1067		[cf_cv_chtype_decl=yes],
1068		[cf_cv_chtype_decl=no])])
1069if test $cf_cv_chtype_decl = yes ; then
1070	AC_DEFINE(HAVE_TYPE_CHTYPE)
1071	AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[
1072		AC_TRY_COMPILE([#include <${cf_cv_ncurses_header-curses.h}>],
1073			[chtype foo; long x = foo],
1074			[cf_cv_chtype_type=scalar],
1075			[cf_cv_chtype_type=struct])])
1076	if test $cf_cv_chtype_type = scalar ; then
1077		AC_DEFINE(TYPE_CHTYPE_IS_SCALAR)
1078	fi
1079fi
1080])dnl
1081dnl ---------------------------------------------------------------------------
1082dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
1083dnl ----------------
1084dnl Tie together the configure-script macros for curses.  It may be ncurses,
1085dnl but unless asked, we do not make a special search for ncurses.  However,
1086dnl still check for the ncurses version number, for use in other macros.
1087AC_DEFUN([CF_CURSES_CONFIG],
1088[
1089CF_CURSES_CPPFLAGS
1090CF_NCURSES_VERSION
1091CF_CURSES_LIBS
1092])dnl
1093dnl ---------------------------------------------------------------------------
1094dnl CF_CURSES_CPPFLAGS version: 10 updated: 2009/01/06 19:34:11
1095dnl ------------------
1096dnl Look for the curses headers.
1097AC_DEFUN([CF_CURSES_CPPFLAGS],[
1098
1099AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
1100cf_cv_curses_incdir=no
1101case $host_os in #(vi
1102hpux10.*) #(vi
1103	test -d /usr/include/curses_colr && \
1104	cf_cv_curses_incdir="-I/usr/include/curses_colr"
1105	;;
1106sunos3*|sunos4*)
1107	test -d /usr/5lib && \
1108	test -d /usr/5include && \
1109	cf_cv_curses_incdir="-I/usr/5include"
1110	;;
1111esac
1112])
1113test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
1114
1115CF_CURSES_HEADER
1116CF_TERM_HEADER
1117])dnl
1118dnl ---------------------------------------------------------------------------
1119dnl CF_CURSES_FUNCS version: 14 updated: 2009/07/16 19:34:55
1120dnl ---------------
1121dnl Curses-functions are a little complicated, since a lot of them are macros.
1122AC_DEFUN([CF_CURSES_FUNCS],
1123[
1124AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1125AC_REQUIRE([CF_XOPEN_CURSES])
1126AC_REQUIRE([CF_CURSES_TERM_H])
1127for cf_func in $1
1128do
1129	CF_UPPER(cf_tr_func,$cf_func)
1130	AC_MSG_CHECKING(for ${cf_func})
1131	CF_MSG_LOG(${cf_func})
1132	AC_CACHE_VAL(cf_cv_func_$cf_func,[
1133		eval cf_result='$ac_cv_func_'$cf_func
1134		if test ".$cf_result" != ".no"; then
1135			AC_TRY_LINK(CF__CURSES_HEAD,
1136			[
1137#ifndef ${cf_func}
1138long foo = (long)(&${cf_func});
1139${cf_cv_main_return-return}(foo == 0);
1140#endif
1141			],
1142			[cf_result=yes],
1143			[cf_result=no])
1144		fi
1145		eval 'cf_cv_func_'$cf_func'=$cf_result'
1146	])
1147	# use the computed/retrieved cache-value:
1148	eval 'cf_result=$cf_cv_func_'$cf_func
1149	AC_MSG_RESULT($cf_result)
1150	if test $cf_result != no; then
1151		AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
1152	fi
1153done
1154])dnl
1155dnl ---------------------------------------------------------------------------
1156dnl CF_CURSES_HEADER version: 2 updated: 2010/04/28 06:02:16
1157dnl ----------------
1158dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1159dnl variations of ncurses' installs.
1160dnl
1161dnl $1 = ncurses when looking for ncurses, or is empty
1162AC_DEFUN([CF_CURSES_HEADER],[
1163AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
1164cf_cv_ncurses_header=none
1165for cf_header in ifelse($1,,,[ \
1166    $1/curses.h \
1167	$1/ncurses.h]) \
1168	curses.h \
1169	ncurses.h ifelse($1,,[ncurses/curses.h ncurses/ncurses.h])
1170do
1171AC_TRY_COMPILE([#include <${cf_header}>],
1172	[initscr(); tgoto("?", 0,0)],
1173	[cf_cv_ncurses_header=$cf_header; break],[])
1174done
1175])
1176
1177if test "$cf_cv_ncurses_header" = none ; then
1178	AC_MSG_ERROR(No curses header-files found)
1179fi
1180
1181# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
1182AC_CHECK_HEADERS($cf_cv_ncurses_header)
1183])dnl
1184dnl ---------------------------------------------------------------------------
1185dnl CF_CURSES_LIBS version: 29 updated: 2009/01/06 19:34:57
1186dnl --------------
1187dnl Look for the curses libraries.  Older curses implementations may require
1188dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
1189AC_DEFUN([CF_CURSES_LIBS],[
1190
1191AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1192AC_MSG_CHECKING(if we have identified curses libraries)
1193AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1194    [initscr(); tgoto("?", 0,0)],
1195    cf_result=yes,
1196    cf_result=no)
1197AC_MSG_RESULT($cf_result)
1198
1199if test "$cf_result" = no ; then
1200case $host_os in #(vi
1201freebsd*) #(vi
1202    AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
1203    ;;
1204hpux10.*) #(vi
1205    AC_CHECK_LIB(cur_colr,initscr,[
1206        LIBS="-lcur_colr $LIBS"
1207        ac_cv_func_initscr=yes
1208        ],[
1209    AC_CHECK_LIB(Hcurses,initscr,[
1210        # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
1211        LIBS="-lHcurses $LIBS"
1212        CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
1213        ac_cv_func_initscr=yes
1214        ])])
1215    ;;
1216linux*) # Suse Linux does not follow /usr/lib convention
1217    CF_ADD_LIBDIR(/lib)
1218    ;;
1219sunos3*|sunos4*)
1220    if test -d /usr/5lib ; then
1221      CF_ADD_LIBDIR(/usr/5lib)
1222      LIBS="$LIBS -lcurses -ltermcap"
1223    fi
1224    ac_cv_func_initscr=yes
1225    ;;
1226esac
1227
1228if test ".$ac_cv_func_initscr" != .yes ; then
1229    cf_save_LIBS="$LIBS"
1230    cf_term_lib=""
1231    cf_curs_lib=""
1232
1233    if test ".${cf_cv_ncurses_version-no}" != .no
1234    then
1235        cf_check_list="ncurses curses cursesX"
1236    else
1237        cf_check_list="cursesX curses ncurses"
1238    fi
1239
1240    # Check for library containing tgoto.  Do this before curses library
1241    # because it may be needed to link the test-case for initscr.
1242    AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
1243        for cf_term_lib in $cf_check_list termcap termlib unknown
1244        do
1245            AC_CHECK_LIB($cf_term_lib,tgoto,[break])
1246        done
1247    ])
1248
1249    # Check for library containing initscr
1250    test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
1251 	for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
1252    do
1253        AC_CHECK_LIB($cf_curs_lib,initscr,[break])
1254    done
1255    test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
1256
1257    LIBS="-l$cf_curs_lib $cf_save_LIBS"
1258    if test "$cf_term_lib" = unknown ; then
1259        AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
1260        AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1261            [initscr()],
1262            [cf_result=yes],
1263            [cf_result=no])
1264        AC_MSG_RESULT($cf_result)
1265        test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
1266    elif test "$cf_curs_lib" = "$cf_term_lib" ; then
1267        :
1268    elif test "$cf_term_lib" != predefined ; then
1269        AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
1270        AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1271            [initscr(); tgoto((char *)0, 0, 0);],
1272            [cf_result=no],
1273            [
1274            LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
1275            AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1276                [initscr()],
1277                [cf_result=yes],
1278                [cf_result=error])
1279            ])
1280        AC_MSG_RESULT($cf_result)
1281    fi
1282fi
1283fi
1284
1285])dnl
1286dnl ---------------------------------------------------------------------------
1287dnl CF_CURSES_TERM_H version: 7 updated: 2010/01/24 18:40:06
1288dnl ----------------
1289dnl SVr4 curses should have term.h as well (where it puts the definitions of
1290dnl the low-level interface).  This may not be true in old/broken implementations,
1291dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
1292dnl running with Solaris 2.5.1).
1293AC_DEFUN([CF_CURSES_TERM_H],
1294[
1295AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1296
1297AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
1298
1299# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
1300# for <term.h> if we do not find the variant.
1301for cf_header in \
1302	`echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
1303	term.h
1304do
1305	AC_TRY_COMPILE([
1306#include <${cf_cv_ncurses_header-curses.h}>
1307#include <${cf_header}>],
1308	[WINDOW *x],
1309	[cf_cv_term_header=$cf_header
1310	 break],
1311	[cf_cv_term_header=no])
1312done
1313
1314case $cf_cv_term_header in #(vi
1315no)
1316	# If curses is ncurses, some packagers still mess it up by trying to make
1317	# us use GNU termcap.  This handles the most common case.
1318	for cf_header in ncurses/term.h ncursesw/term.h
1319	do
1320		AC_TRY_COMPILE([
1321#include <${cf_cv_ncurses_header-curses.h}>
1322#ifdef NCURSES_VERSION
1323#include <${cf_header}>
1324#else
1325make an error
1326#endif],
1327			[WINDOW *x],
1328			[cf_cv_term_header=$cf_header
1329			 break],
1330			[cf_cv_term_header=no])
1331	done
1332	;;
1333esac
1334])
1335
1336case $cf_cv_term_header in #(vi
1337term.h) #(vi
1338	AC_DEFINE(HAVE_TERM_H)
1339	;;
1340ncurses/term.h) #(vi
1341	AC_DEFINE(HAVE_NCURSES_TERM_H)
1342	;;
1343ncursesw/term.h)
1344	AC_DEFINE(HAVE_NCURSESW_TERM_H)
1345	;;
1346esac
1347])dnl
1348dnl ---------------------------------------------------------------------------
1349dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
1350dnl ----------
1351dnl "dirname" is not portable, so we fake it with a shell script.
1352AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
1353dnl ---------------------------------------------------------------------------
1354dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
1355dnl ---------------
1356dnl You can always use "make -n" to see the actual options, but it's hard to
1357dnl pick out/analyze warning messages when the compile-line is long.
1358dnl
1359dnl Sets:
1360dnl	ECHO_LT - symbol to control if libtool is verbose
1361dnl	ECHO_LD - symbol to prefix "cc -o" lines
1362dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1363dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
1364dnl	ECHO_CC - symbol to put before any "cc" line
1365dnl
1366AC_DEFUN([CF_DISABLE_ECHO],[
1367AC_MSG_CHECKING(if you want to see long compiling messages)
1368CF_ARG_DISABLE(echo,
1369	[  --disable-echo          display "compiling" commands],
1370	[
1371    ECHO_LT='--silent'
1372    ECHO_LD='@echo linking [$]@;'
1373    RULE_CC='@echo compiling [$]<'
1374    SHOW_CC='@echo compiling [$]@'
1375    ECHO_CC='@'
1376],[
1377    ECHO_LT=''
1378    ECHO_LD=''
1379    RULE_CC=''
1380    SHOW_CC=''
1381    ECHO_CC=''
1382])
1383AC_MSG_RESULT($enableval)
1384AC_SUBST(ECHO_LT)
1385AC_SUBST(ECHO_LD)
1386AC_SUBST(RULE_CC)
1387AC_SUBST(SHOW_CC)
1388AC_SUBST(ECHO_CC)
1389])dnl
1390dnl ---------------------------------------------------------------------------
1391dnl CF_DISABLE_RPATH_HACK version: 1 updated: 2010/04/11 10:54:00
1392dnl ---------------------
1393dnl The rpath-hack makes it simpler to build programs, particularly with the
1394dnl *BSD ports which may have essential libraries in unusual places.  But it
1395dnl can interfere with building an executable for the base system.  Use this
1396dnl option in that case.
1397AC_DEFUN([CF_DISABLE_RPATH_HACK],
1398[
1399AC_MSG_CHECKING(if rpath should be not be set)
1400CF_ARG_DISABLE(rpath-hack,
1401	[  --disable-rpath-hack    don't add rpath options for additional libraries],
1402	[cf_disable_rpath_hack=yes],
1403	[cf_disable_rpath_hack=no])
1404AC_MSG_RESULT($cf_disable_rpath_hack)
1405if test "$cf_disable_rpath_hack" = no ; then
1406	CF_RPATH_HACK
1407fi
1408])
1409dnl ---------------------------------------------------------------------------
1410dnl CF_FIND_HEADER version: 2 updated: 2007/07/29 11:32:00
1411dnl --------------
1412dnl Find a header file, searching for it if it is not already in the include
1413dnl path.
1414dnl
1415dnl	$1 = the header filename
1416dnl	$2 = the package name
1417dnl	$3 = action to perform if successful
1418dnl	$4 = action to perform if not successful
1419AC_DEFUN([CF_FIND_HEADER],[
1420AC_CHECK_HEADER([$1],
1421	cf_find_header=yes,[
1422	cf_find_header=no
1423CF_HEADER_PATH(cf_search,$2)
1424for cf_incdir in $cf_search
1425do
1426	if test -f $cf_incdir/$1 ; then
1427		CF_ADD_INCDIR($cf_incdir)
1428		CF_VERBOSE(... found in $cf_incdir)
1429		cf_find_header=yes
1430		break
1431	fi
1432	CF_VERBOSE(... tested $cf_incdir)
1433done
1434])
1435if test "$cf_find_header" = yes ; then
1436ifelse([$3],,:,[$3])
1437ifelse([$4],,,[else
1438$4])
1439fi
1440])dnl
1441dnl ---------------------------------------------------------------------------
1442dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
1443dnl ---------------
1444dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
1445dnl prefer a standard location, and use -L options only if we do not find the
1446dnl library in the standard library location(s).
1447dnl	$1 = library name
1448dnl	$2 = library class, usually the same as library name
1449dnl	$3 = includes
1450dnl	$4 = code fragment to compile/link
1451dnl	$5 = corresponding function-name
1452dnl	$6 = flag, nonnull if failure should not cause an error-exit
1453dnl
1454dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
1455dnl to use a -L option.
1456AC_DEFUN([CF_FIND_LIBRARY],
1457[
1458	eval 'cf_cv_have_lib_'$1'=no'
1459	cf_libdir=""
1460	AC_CHECK_FUNC($5,
1461		eval 'cf_cv_have_lib_'$1'=yes',[
1462		cf_save_LIBS="$LIBS"
1463		AC_MSG_CHECKING(for $5 in -l$1)
1464		LIBS="-l$1 $LIBS"
1465		AC_TRY_LINK([$3],[$4],
1466			[AC_MSG_RESULT(yes)
1467			 eval 'cf_cv_have_lib_'$1'=yes'
1468			],
1469			[AC_MSG_RESULT(no)
1470			CF_LIBRARY_PATH(cf_search,$2)
1471			for cf_libdir in $cf_search
1472			do
1473				AC_MSG_CHECKING(for -l$1 in $cf_libdir)
1474				LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
1475				AC_TRY_LINK([$3],[$4],
1476					[AC_MSG_RESULT(yes)
1477			 		 eval 'cf_cv_have_lib_'$1'=yes'
1478					 break],
1479					[AC_MSG_RESULT(no)
1480					 LIBS="$cf_save_LIBS"])
1481			done
1482			])
1483		])
1484eval 'cf_found_library=[$]cf_cv_have_lib_'$1
1485ifelse($6,,[
1486if test $cf_found_library = no ; then
1487	AC_MSG_ERROR(Cannot link $1 library)
1488fi
1489])
1490])dnl
1491dnl ---------------------------------------------------------------------------
1492dnl CF_FIND_LINKAGE version: 16 updated: 2010/04/21 06:20:50
1493dnl ---------------
1494dnl Find a library (specifically the linkage used in the code fragment),
1495dnl searching for it if it is not already in the library path.
1496dnl See also CF_ADD_SEARCHPATH.
1497dnl
1498dnl Parameters (4-on are optional):
1499dnl     $1 = headers for library entrypoint
1500dnl     $2 = code fragment for library entrypoint
1501dnl     $3 = the library name without the "-l" option or ".so" suffix.
1502dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1503dnl     $5 = action to perform if not successful
1504dnl     $6 = module name, if not the same as the library name
1505dnl     $7 = extra libraries
1506dnl
1507dnl Sets these variables:
1508dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1509dnl     $cf_cv_header_path_$3 - include-directory if needed
1510dnl     $cf_cv_library_path_$3 - library-directory if needed
1511dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1512AC_DEFUN([CF_FIND_LINKAGE],[
1513
1514# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1515# will be set on completion of the AC_TRY_LINK below.
1516cf_cv_header_path_$3=
1517cf_cv_library_path_$3=
1518
1519CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1520
1521AC_TRY_LINK([$1],[$2],[
1522	cf_cv_find_linkage_$3=yes
1523],[
1524
1525cf_save_LIBS="$LIBS"
1526LIBS="-l$3 $7 $cf_save_LIBS"
1527
1528AC_TRY_LINK([$1],[$2],[
1529	cf_cv_find_linkage_$3=yes
1530	cf_cv_library_file_$3="-l$3"
1531],[
1532    cf_cv_find_linkage_$3=no
1533	LIBS="$cf_save_LIBS"
1534
1535    CF_VERBOSE(find linkage for $3 library)
1536    CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1537
1538    cf_save_CPPFLAGS="$CPPFLAGS"
1539    cf_test_CPPFLAGS="$CPPFLAGS"
1540
1541    CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1542    for cf_cv_header_path_$3 in $cf_search
1543    do
1544      if test -d $cf_cv_header_path_$3 ; then
1545        CF_VERBOSE(... testing $cf_cv_header_path_$3)
1546        CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1547        AC_TRY_COMPILE([$1],[$2],[
1548            CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1549            cf_cv_find_linkage_$3=maybe
1550            cf_test_CPPFLAGS="$CPPFLAGS"
1551            break],[
1552            CPPFLAGS="$cf_save_CPPFLAGS"
1553            ])
1554      fi
1555    done
1556
1557    if test "$cf_cv_find_linkage_$3" = maybe ; then
1558
1559      CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1560
1561      cf_save_LIBS="$LIBS"
1562      cf_save_LDFLAGS="$LDFLAGS"
1563
1564      ifelse([$6],,,[
1565        CPPFLAGS="$cf_test_CPPFLAGS"
1566        LIBS="-l$3 $7 $cf_save_LIBS"
1567        AC_TRY_LINK([$1],[$2],[
1568            CF_VERBOSE(... found $3 library in system)
1569            cf_cv_find_linkage_$3=yes])
1570            CPPFLAGS="$cf_save_CPPFLAGS"
1571            LIBS="$cf_save_LIBS"
1572            ])
1573
1574      if test "$cf_cv_find_linkage_$3" != yes ; then
1575        CF_LIBRARY_PATH(cf_search,$3)
1576        for cf_cv_library_path_$3 in $cf_search
1577        do
1578          if test -d $cf_cv_library_path_$3 ; then
1579            CF_VERBOSE(... testing $cf_cv_library_path_$3)
1580            CPPFLAGS="$cf_test_CPPFLAGS"
1581            LIBS="-l$3 $7 $cf_save_LIBS"
1582            LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1583            AC_TRY_LINK([$1],[$2],[
1584                CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1585                cf_cv_find_linkage_$3=yes
1586                cf_cv_library_file_$3="-l$3"
1587                break],[
1588                CPPFLAGS="$cf_save_CPPFLAGS"
1589                LIBS="$cf_save_LIBS"
1590                LDFLAGS="$cf_save_LDFLAGS"
1591                ])
1592          fi
1593        done
1594        LIBS="$cf_save_LIBS"
1595        CPPFLAGS="$cf_save_CPPFLAGS"
1596        LDFLAGS="$cf_save_LDFLAGS"
1597      fi
1598
1599    else
1600      cf_cv_find_linkage_$3=no
1601    fi
1602    ],$7)
1603])
1604
1605if test "$cf_cv_find_linkage_$3" = yes ; then
1606ifelse([$4],,[
1607	CF_ADD_INCDIR($cf_cv_header_path_$3)
1608	CF_ADD_LIBDIR($cf_cv_library_path_$3)
1609	LIBS="-l$3 $LIBS"
1610],[$4])
1611else
1612ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1613fi
1614])dnl
1615dnl ---------------------------------------------------------------------------
1616dnl CF_FUNC_WAIT version: 2 updated: 1997/10/21 19:45:33
1617dnl ------------
1618dnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
1619dnl and/or 'waitpid()'.
1620dnl
1621dnl Note that we cannot simply grep for 'union wait' in the wait.h file,
1622dnl because some Posix systems turn this on only when a BSD variable is
1623dnl defined.
1624dnl
1625dnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
1626dnl would conflict with an attempt to test that header directly.
1627dnl
1628AC_DEFUN([CF_FUNC_WAIT],
1629[
1630AC_REQUIRE([CF_UNION_WAIT])
1631if test $cf_cv_type_unionwait = yes; then
1632
1633	AC_MSG_CHECKING(if union wait can be used as wait-arg)
1634	AC_CACHE_VAL(cf_cv_arg_union_wait,[
1635		AC_TRY_COMPILE($cf_wait_headers,
1636 			[union wait x; wait(&x)],
1637			[cf_cv_arg_union_wait=yes],
1638			[cf_cv_arg_union_wait=no])
1639		])
1640	AC_MSG_RESULT($cf_cv_arg_union_wait)
1641	test $cf_cv_arg_union_wait = yes && AC_DEFINE(WAIT_USES_UNION)
1642
1643	AC_MSG_CHECKING(if union wait can be used as waitpid-arg)
1644	AC_CACHE_VAL(cf_cv_arg_union_waitpid,[
1645		AC_TRY_COMPILE($cf_wait_headers,
1646 			[union wait x; waitpid(0, &x, 0)],
1647			[cf_cv_arg_union_waitpid=yes],
1648			[cf_cv_arg_union_waitpid=no])
1649		])
1650	AC_MSG_RESULT($cf_cv_arg_union_waitpid)
1651	test $cf_cv_arg_union_waitpid = yes && AC_DEFINE(WAITPID_USES_UNION)
1652
1653fi
1654])dnl
1655dnl ---------------------------------------------------------------------------
1656dnl CF_GCC_ATTRIBUTES version: 13 updated: 2009/08/11 20:19:56
1657dnl -----------------
1658dnl Test for availability of useful gcc __attribute__ directives to quiet
1659dnl compiler warnings.  Though useful, not all are supported -- and contrary
1660dnl to documentation, unrecognized directives cause older compilers to barf.
1661AC_DEFUN([CF_GCC_ATTRIBUTES],
1662[
1663if test "$GCC" = yes
1664then
1665cat > conftest.i <<EOF
1666#ifndef GCC_PRINTF
1667#define GCC_PRINTF 0
1668#endif
1669#ifndef GCC_SCANF
1670#define GCC_SCANF 0
1671#endif
1672#ifndef GCC_NORETURN
1673#define GCC_NORETURN /* nothing */
1674#endif
1675#ifndef GCC_UNUSED
1676#define GCC_UNUSED /* nothing */
1677#endif
1678EOF
1679if test "$GCC" = yes
1680then
1681	AC_CHECKING([for $CC __attribute__ directives])
1682cat > conftest.$ac_ext <<EOF
1683#line __oline__ "${as_me-configure}"
1684#include "confdefs.h"
1685#include "conftest.h"
1686#include "conftest.i"
1687#if	GCC_PRINTF
1688#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1689#else
1690#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1691#endif
1692#if	GCC_SCANF
1693#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1694#else
1695#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1696#endif
1697extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1698extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1699extern void foo(void) GCC_NORETURN;
1700int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1701EOF
1702	cf_printf_attribute=no
1703	cf_scanf_attribute=no
1704	for cf_attribute in scanf printf unused noreturn
1705	do
1706		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1707		cf_directive="__attribute__(($cf_attribute))"
1708		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1709
1710		case $cf_attribute in #(vi
1711		printf) #(vi
1712			cf_printf_attribute=yes
1713			cat >conftest.h <<EOF
1714#define GCC_$cf_ATTRIBUTE 1
1715EOF
1716			;;
1717		scanf) #(vi
1718			cf_scanf_attribute=yes
1719			cat >conftest.h <<EOF
1720#define GCC_$cf_ATTRIBUTE 1
1721EOF
1722			;;
1723		*) #(vi
1724			cat >conftest.h <<EOF
1725#define GCC_$cf_ATTRIBUTE $cf_directive
1726EOF
1727			;;
1728		esac
1729
1730		if AC_TRY_EVAL(ac_compile); then
1731			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1732			cat conftest.h >>confdefs.h
1733			case $cf_attribute in #(vi
1734			printf) #(vi
1735				if test "$cf_printf_attribute" = no ; then
1736					cat >>confdefs.h <<EOF
1737#define GCC_PRINTFLIKE(fmt,var) /* nothing */
1738EOF
1739				else
1740					cat >>confdefs.h <<EOF
1741#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1742EOF
1743				fi
1744				;;
1745			scanf) #(vi
1746				if test "$cf_scanf_attribute" = no ; then
1747					cat >>confdefs.h <<EOF
1748#define GCC_SCANFLIKE(fmt,var) /* nothing */
1749EOF
1750				else
1751					cat >>confdefs.h <<EOF
1752#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1753EOF
1754				fi
1755				;;
1756			esac
1757		fi
1758	done
1759else
1760	fgrep define conftest.i >>confdefs.h
1761fi
1762rm -rf conftest*
1763fi
1764])dnl
1765dnl ---------------------------------------------------------------------------
1766dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
1767dnl --------------
1768dnl Find version of gcc
1769AC_DEFUN([CF_GCC_VERSION],[
1770AC_REQUIRE([AC_PROG_CC])
1771GCC_VERSION=none
1772if test "$GCC" = yes ; then
1773	AC_MSG_CHECKING(version of $CC)
1774	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1775	test -z "$GCC_VERSION" && GCC_VERSION=unknown
1776	AC_MSG_RESULT($GCC_VERSION)
1777fi
1778])dnl
1779dnl ---------------------------------------------------------------------------
1780dnl CF_GCC_WARNINGS version: 25 updated: 2010/04/24 11:03:31
1781dnl ---------------
1782dnl Check if the compiler supports useful warning options.  There's a few that
1783dnl we don't use, simply because they're too noisy:
1784dnl
1785dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1786dnl	-Wredundant-decls (system headers make this too noisy)
1787dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
1788dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
1789dnl		is enabled for ncurses using "--enable-const".
1790dnl	-pedantic
1791dnl
1792dnl Parameter:
1793dnl	$1 is an optional list of gcc warning flags that a particular
1794dnl		application might want to use, e.g., "no-unused" for
1795dnl		-Wno-unused
1796dnl Special:
1797dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
1798dnl
1799AC_DEFUN([CF_GCC_WARNINGS],
1800[
1801AC_REQUIRE([CF_GCC_VERSION])
1802CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1803
1804cat > conftest.$ac_ext <<EOF
1805#line __oline__ "${as_me-configure}"
1806int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1807EOF
1808
1809if test "$INTEL_COMPILER" = yes
1810then
1811# The "-wdXXX" options suppress warnings:
1812# remark #1419: external declaration in primary source file
1813# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1814# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1815# remark #193: zero used for undefined preprocessing identifier
1816# remark #593: variable "curs_sb_left_arrow" was set but never used
1817# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1818# remark #869: parameter "tw" was never referenced
1819# remark #981: operands are evaluated in unspecified order
1820# warning #279: controlling expression is constant
1821
1822	AC_CHECKING([for $CC warning options])
1823	cf_save_CFLAGS="$CFLAGS"
1824	EXTRA_CFLAGS="-Wall"
1825	for cf_opt in \
1826		wd1419 \
1827		wd1683 \
1828		wd1684 \
1829		wd193 \
1830		wd593 \
1831		wd279 \
1832		wd810 \
1833		wd869 \
1834		wd981
1835	do
1836		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1837		if AC_TRY_EVAL(ac_compile); then
1838			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1839			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1840		fi
1841	done
1842	CFLAGS="$cf_save_CFLAGS"
1843
1844elif test "$GCC" = yes
1845then
1846	AC_CHECKING([for $CC warning options])
1847	cf_save_CFLAGS="$CFLAGS"
1848	EXTRA_CFLAGS=
1849	cf_warn_CONST=""
1850	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1851	for cf_opt in W Wall \
1852		Wbad-function-cast \
1853		Wcast-align \
1854		Wcast-qual \
1855		Winline \
1856		Wmissing-declarations \
1857		Wmissing-prototypes \
1858		Wnested-externs \
1859		Wpointer-arith \
1860		Wshadow \
1861		Wstrict-prototypes \
1862		Wundef $cf_warn_CONST $1
1863	do
1864		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1865		if AC_TRY_EVAL(ac_compile); then
1866			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1867			case $cf_opt in #(vi
1868			Wcast-qual) #(vi
1869				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1870				;;
1871			Winline) #(vi
1872				case $GCC_VERSION in
1873				[[34]].*)
1874					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1875					continue;;
1876				esac
1877				;;
1878			esac
1879			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1880		fi
1881	done
1882	CFLAGS="$cf_save_CFLAGS"
1883fi
1884rm -f conftest*
1885
1886AC_SUBST(EXTRA_CFLAGS)
1887])dnl
1888dnl ---------------------------------------------------------------------------
1889dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1890dnl -------------
1891dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1892dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1893dnl (or misfeature) of glibc2, which breaks portability of many applications,
1894dnl since it is interwoven with GNU extensions.
1895dnl
1896dnl Well, yes we could work around it...
1897AC_DEFUN([CF_GNU_SOURCE],
1898[
1899AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1900AC_TRY_COMPILE([#include <sys/types.h>],[
1901#ifndef _XOPEN_SOURCE
1902make an error
1903#endif],
1904	[cf_cv_gnu_source=no],
1905	[cf_save="$CPPFLAGS"
1906	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1907	 AC_TRY_COMPILE([#include <sys/types.h>],[
1908#ifdef _XOPEN_SOURCE
1909make an error
1910#endif],
1911	[cf_cv_gnu_source=no],
1912	[cf_cv_gnu_source=yes])
1913	CPPFLAGS="$cf_save"
1914	])
1915])
1916test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1917])dnl
1918dnl ---------------------------------------------------------------------------
1919dnl CF_HEADERS_SH version: 1 updated: 2007/07/04 15:37:05
1920dnl -------------
1921dnl Setup variables needed to construct headers-sh
1922AC_DEFUN([CF_HEADERS_SH],[
1923PACKAGE_PREFIX=$1
1924PACKAGE_CONFIG=$2
1925AC_SUBST(PACKAGE_PREFIX)
1926AC_SUBST(PACKAGE_CONFIG)
1927EXTRA_OUTPUT="$EXTRA_OUTPUT headers-sh:$srcdir/headers-sh.in"
1928])
1929dnl ---------------------------------------------------------------------------
1930dnl CF_HEADER_PATH version: 11 updated: 2010/04/21 06:20:50
1931dnl --------------
1932dnl Construct a search-list of directories for a nonstandard header-file
1933dnl
1934dnl Parameters
1935dnl	$1 = the variable to return as result
1936dnl	$2 = the package name
1937AC_DEFUN([CF_HEADER_PATH],
1938[
1939$1=
1940
1941# collect the current set of include-directories from compiler flags
1942cf_header_path_list=""
1943if test -n "${CFLAGS}${CPPFLAGS}" ; then
1944	for cf_header_path in $CPPFLAGS $CFLAGS
1945	do
1946		case $cf_header_path in #(vi
1947		-I*)
1948			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1949			cf_header_path_list="$cf_header_path_list $cf_header_path"
1950			;;
1951		esac
1952	done
1953fi
1954
1955# add the variations for the package we are looking for
1956CF_SUBDIR_PATH($1,$2,include)
1957
1958test "$includedir" != NONE && \
1959test "$includedir" != "/usr/include" && \
1960test -d "$includedir" && {
1961	test -d $includedir &&    $1="[$]$1 $includedir"
1962	test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1963}
1964
1965test "$oldincludedir" != NONE && \
1966test "$oldincludedir" != "/usr/include" && \
1967test -d "$oldincludedir" && {
1968	test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1969	test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1970}
1971
1972$1="[$]$1 $cf_header_path_list"
1973])dnl
1974dnl ---------------------------------------------------------------------------
1975dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1976dnl ---------------
1977dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1978AC_DEFUN([CF_HELP_MESSAGE],
1979[AC_DIVERT_HELP([$1])dnl
1980])dnl
1981dnl ---------------------------------------------------------------------------
1982dnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
1983dnl ---------------
1984dnl Construct the list of include-options according to whether we're building
1985dnl in the source directory or using '--srcdir=DIR' option.  If we're building
1986dnl with gcc, don't append the includedir if it happens to be /usr/include,
1987dnl since that usually breaks gcc's shadow-includes.
1988AC_DEFUN([CF_INCLUDE_DIRS],
1989[
1990CPPFLAGS="$CPPFLAGS -I. -I../include"
1991if test "$srcdir" != "."; then
1992	CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
1993fi
1994if test "$GCC" != yes; then
1995	CPPFLAGS="$CPPFLAGS -I\${includedir}"
1996elif test "$includedir" != "/usr/include"; then
1997	if test "$includedir" = '${prefix}/include' ; then
1998		if test $prefix != /usr ; then
1999			CPPFLAGS="$CPPFLAGS -I\${includedir}"
2000		fi
2001	else
2002		CPPFLAGS="$CPPFLAGS -I\${includedir}"
2003	fi
2004fi
2005AC_SUBST(CPPFLAGS)
2006])dnl
2007dnl ---------------------------------------------------------------------------
2008dnl CF_INCLUDE_PATH version: 5 updated: 2010/01/17 20:36:17
2009dnl ---------------
2010dnl	Adds to the include-path
2011dnl
2012dnl	Autoconf 1.11 should have provided a way to add include path options to
2013dnl	the cpp-tests.
2014dnl
2015AC_DEFUN([CF_INCLUDE_PATH],
2016[
2017$1=
2018for cf_path in $1
2019do
2020	cf_result="no"
2021	AC_MSG_CHECKING(for directory $cf_path)
2022	if test -d $cf_path
2023	then
2024		INCLUDES="$INCLUDES -I$cf_path"
2025		ac_cpp="${ac_cpp} -I$cf_path"
2026		CFLAGS="$CFLAGS -I$cf_path"
2027		cf_result="yes"
2028		case $cf_path in
2029		/usr/include|/usr/include/*)
2030			;;
2031		*)
2032			CF_DIRNAME(cf_temp,$cf_path)
2033			case $cf_temp in
2034			*/include)
2035				INCLUDES="$INCLUDES -I$cf_temp"
2036				ac_cpp="${ac_cpp} -I$cf_temp"
2037				CFLAGS="$CFLAGS -I$cf_temp"
2038				;;
2039			esac
2040		esac
2041	fi
2042	AC_MSG_RESULT($cf_result)
2043done
2044])dnl
2045dnl ---------------------------------------------------------------------------
2046dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
2047dnl -----------------
2048dnl Check if the given compiler is really the Intel compiler for Linux.  It
2049dnl tries to imitate gcc, but does not return an error when it finds a mismatch
2050dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2051dnl
2052dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2053dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2054dnl the wrappers for gcc and g++ warnings.
2055dnl
2056dnl $1 = GCC (default) or GXX
2057dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2058dnl $3 = CFLAGS (default) or CXXFLAGS
2059AC_DEFUN([CF_INTEL_COMPILER],[
2060ifelse($2,,INTEL_COMPILER,[$2])=no
2061
2062if test "$ifelse($1,,[$1],GCC)" = yes ; then
2063	case $host_os in
2064	linux*|gnu*)
2065		AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
2066		cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
2067		ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
2068		AC_TRY_COMPILE([],[
2069#ifdef __INTEL_COMPILER
2070#else
2071make an error
2072#endif
2073],[ifelse($2,,INTEL_COMPILER,[$2])=yes
2074cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2075],[])
2076		ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
2077		AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
2078		;;
2079	esac
2080fi
2081])dnl
2082dnl ---------------------------------------------------------------------------
2083dnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
2084dnl ------------
2085dnl Add checks for large file support.
2086AC_DEFUN([CF_LARGEFILE],[
2087ifdef([AC_FUNC_FSEEKO],[
2088    AC_SYS_LARGEFILE
2089    if test "$enable_largefile" != no ; then
2090	AC_FUNC_FSEEKO
2091
2092	# Normally we would collect these definitions in the config.h,
2093	# but (like _XOPEN_SOURCE), some environments rely on having these
2094	# defined before any of the system headers are included.  Another
2095	# case comes up with C++, e.g., on AIX the compiler compiles the
2096	# header files by themselves before looking at the body files it is
2097	# told to compile.  For ncurses, those header files do not include
2098	# the config.h
2099	test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
2100	test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
2101	test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
2102
2103	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2104		AC_TRY_COMPILE([
2105#include <sys/types.h>
2106#include <dirent.h>
2107		],[
2108		/* if transitional largefile support is setup, this is true */
2109		extern struct dirent64 * readdir(DIR *);
2110		struct dirent64 *x = readdir((DIR *)0);
2111		struct dirent *y = readdir((DIR *)0);
2112		int z = x - y;
2113		],
2114		[cf_cv_struct_dirent64=yes],
2115		[cf_cv_struct_dirent64=no])
2116	])
2117	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
2118    fi
2119])
2120])
2121dnl ---------------------------------------------------------------------------
2122dnl CF_LD_RPATH_OPT version: 2 updated: 2010/03/27 19:27:54
2123dnl ---------------
2124dnl For the given system and compiler, find the compiler flags to pass to the
2125dnl loader to use the "rpath" feature.
2126AC_DEFUN([CF_LD_RPATH_OPT],
2127[
2128AC_REQUIRE([CF_CHECK_CACHE])
2129
2130LD_RPATH_OPT=
2131AC_MSG_CHECKING(for an rpath option)
2132case $cf_cv_system_name in #(vi
2133irix*) #(vi
2134	if test "$GCC" = yes; then
2135		LD_RPATH_OPT="-Wl,-rpath,"
2136	else
2137		LD_RPATH_OPT="-rpath "
2138	fi
2139	;;
2140linux*|gnu*|k*bsd*-gnu) #(vi
2141	LD_RPATH_OPT="-Wl,-rpath,"
2142	;;
2143openbsd[[2-9]].*) #(vi
2144	LD_RPATH_OPT="-Wl,-rpath,"
2145	;;
2146freebsd*) #(vi
2147	LD_RPATH_OPT="-rpath "
2148	;;
2149netbsd*) #(vi
2150	LD_RPATH_OPT="-Wl,-rpath,"
2151	;;
2152osf*|mls+*) #(vi
2153	LD_RPATH_OPT="-rpath "
2154	;;
2155solaris2*) #(vi
2156	LD_RPATH_OPT="-R"
2157	;;
2158*)
2159	;;
2160esac
2161AC_MSG_RESULT($LD_RPATH_OPT)
2162
2163case "x$LD_RPATH_OPT" in #(vi
2164x-R*)
2165	AC_MSG_CHECKING(if we need a space after rpath option)
2166	cf_save_LIBS="$LIBS"
2167	LIBS="${LD_RPATH_OPT}$libdir $LIBS"
2168	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2169	LIBS="$cf_save_LIBS"
2170	AC_MSG_RESULT($cf_rpath_space)
2171	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
2172	;;
2173esac
2174])dnl
2175dnl ---------------------------------------------------------------------------
2176dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
2177dnl ---------------
2178dnl Construct a search-list of directories for a nonstandard library-file
2179dnl
2180dnl Parameters
2181dnl	$1 = the variable to return as result
2182dnl	$2 = the package name
2183AC_DEFUN([CF_LIBRARY_PATH],
2184[
2185$1=
2186cf_library_path_list=""
2187if test -n "${LDFLAGS}${LIBS}" ; then
2188	for cf_library_path in $LDFLAGS $LIBS
2189	do
2190		case $cf_library_path in #(vi
2191		-L*)
2192			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
2193			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
2194			cf_library_path_list="$cf_library_path_list [$]$1"
2195			;;
2196		esac
2197	done
2198fi
2199
2200CF_SUBDIR_PATH($1,$2,lib)
2201
2202$1="$cf_library_path_list [$]$1"
2203])dnl
2204dnl ---------------------------------------------------------------------------
2205dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
2206dnl -------------
2207dnl Compute the library-prefix for the given host system
2208dnl $1 = variable to set
2209AC_DEFUN([CF_LIB_PREFIX],
2210[
2211	case $cf_cv_system_name in #(vi
2212	OS/2*|os2*) #(vi
2213        LIB_PREFIX=''
2214        ;;
2215	*)	LIB_PREFIX='lib'
2216        ;;
2217	esac
2218ifelse($1,,,[$1=$LIB_PREFIX])
2219	AC_SUBST(LIB_PREFIX)
2220])dnl
2221dnl ---------------------------------------------------------------------------
2222dnl CF_MAKEFLAGS version: 12 updated: 2006/10/21 08:27:03
2223dnl ------------
2224dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
2225dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
2226dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
2227dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
2228AC_DEFUN([CF_MAKEFLAGS],
2229[
2230AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
2231	cf_cv_makeflags=''
2232	for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
2233	do
2234		cat >cf_makeflags.tmp <<CF_EOF
2235SHELL = /bin/sh
2236all :
2237	@ echo '.$cf_option'
2238CF_EOF
2239		cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[ 	]]*$,,'`
2240		case "$cf_result" in
2241		.*k)
2242			cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
2243			case "$cf_result" in
2244			.*CC=*)	cf_cv_makeflags=
2245				;;
2246			*)	cf_cv_makeflags=$cf_option
2247				;;
2248			esac
2249			break
2250			;;
2251		.-)	;;
2252		*)	echo "given option \"$cf_option\", no match \"$cf_result\""
2253			;;
2254		esac
2255	done
2256	rm -f cf_makeflags.tmp
2257])
2258
2259AC_SUBST(cf_cv_makeflags)
2260])dnl
2261dnl ---------------------------------------------------------------------------
2262dnl CF_MAKE_TAGS version: 5 updated: 2010/04/03 20:07:32
2263dnl ------------
2264dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
2265dnl a monocase filesystem.
2266AC_DEFUN([CF_MAKE_TAGS],[
2267AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
2268
2269AC_CHECK_PROGS(CTAGS, exctags ctags)
2270AC_CHECK_PROGS(ETAGS, exetags etags)
2271
2272AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS-ctags}, yes, no)
2273
2274if test "$cf_cv_mixedcase" = yes ; then
2275	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS-etags}, yes, no)
2276else
2277	MAKE_UPPER_TAGS=no
2278fi
2279
2280if test "$MAKE_UPPER_TAGS" = yes ; then
2281	MAKE_UPPER_TAGS=
2282else
2283	MAKE_UPPER_TAGS="#"
2284fi
2285
2286if test "$MAKE_LOWER_TAGS" = yes ; then
2287	MAKE_LOWER_TAGS=
2288else
2289	MAKE_LOWER_TAGS="#"
2290fi
2291
2292AC_SUBST(CTAGS)
2293AC_SUBST(ETAGS)
2294
2295AC_SUBST(MAKE_UPPER_TAGS)
2296AC_SUBST(MAKE_LOWER_TAGS)
2297])dnl
2298dnl ---------------------------------------------------------------------------
2299dnl CF_MATH_LIB version: 6 updated: 2009/12/19 13:46:49
2300dnl -----------
2301dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
2302dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
2303dnl AC_CHECK_LIB(m,sin), because that fails for C++.
2304AC_DEFUN([CF_MATH_LIB],
2305[
2306AC_CACHE_CHECK(if -lm needed for math functions,
2307	cf_cv_need_libm,[
2308	AC_TRY_LINK([
2309	#include <stdio.h>
2310	#include <math.h>
2311	],
2312	[double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
2313	[cf_cv_need_libm=no],
2314	[cf_cv_need_libm=yes])])
2315if test "$cf_cv_need_libm" = yes
2316then
2317ifelse($1,,[
2318	LIBS="-lm $LIBS"
2319],[$1=-lm])
2320fi
2321])
2322dnl ---------------------------------------------------------------------------
2323dnl CF_MBSTATE_T version: 3 updated: 2007/03/25 15:55:36
2324dnl ------------
2325dnl Check if mbstate_t is declared, and if so, which header file.
2326dnl This (including wchar.h) is needed on Tru64 5.0 to declare mbstate_t,
2327dnl as well as include stdio.h to work around a misuse of varargs in wchar.h
2328AC_DEFUN([CF_MBSTATE_T],
2329[
2330AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_mbstate_t,[
2331AC_TRY_COMPILE([
2332#include <stdlib.h>
2333#include <stdio.h>
2334#ifdef HAVE_LIBUTF8_H
2335#include <libutf8.h>
2336#endif],
2337	[mbstate_t state],
2338	[cf_cv_mbstate_t=no],
2339	[AC_TRY_COMPILE([
2340#include <stdlib.h>
2341#include <stdio.h>
2342#include <wchar.h>
2343#ifdef HAVE_LIBUTF8_H
2344#include <libutf8.h>
2345#endif],
2346	[mbstate_t value],
2347	[cf_cv_mbstate_t=yes],
2348	[cf_cv_mbstate_t=unknown])])])
2349
2350if test "$cf_cv_mbstate_t" = yes ; then
2351	AC_DEFINE(NEED_WCHAR_H)
2352fi
2353
2354if test "$cf_cv_mbstate_t" != unknown ; then
2355	AC_DEFINE(HAVE_MBSTATE_T)
2356fi
2357])dnl
2358dnl ---------------------------------------------------------------------------
2359dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
2360dnl ----------------------
2361dnl Check if the file-system supports mixed-case filenames.  If we're able to
2362dnl create a lowercase name and see it as uppercase, it doesn't support that.
2363AC_DEFUN([CF_MIXEDCASE_FILENAMES],
2364[
2365AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
2366if test "$cross_compiling" = yes ; then
2367	case $target_alias in #(vi
2368	*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
2369		cf_cv_mixedcase=no
2370		;;
2371	*)
2372		cf_cv_mixedcase=yes
2373		;;
2374	esac
2375else
2376	rm -f conftest CONFTEST
2377	echo test >conftest
2378	if test -f CONFTEST ; then
2379		cf_cv_mixedcase=no
2380	else
2381		cf_cv_mixedcase=yes
2382	fi
2383	rm -f conftest CONFTEST
2384fi
2385])
2386test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
2387])dnl
2388dnl ---------------------------------------------------------------------------
2389dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
2390dnl ----------
2391dnl Write a debug message to config.log, along with the line number in the
2392dnl configure script.
2393AC_DEFUN([CF_MSG_LOG],[
2394echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
2395])dnl
2396dnl ---------------------------------------------------------------------------
2397dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
2398dnl -------------------
2399dnl Check if we can compile with ncurses' header file
2400dnl $1 is the cache variable to set
2401dnl $2 is the header-file to include
2402dnl $3 is the root name (ncurses or ncursesw)
2403AC_DEFUN([CF_NCURSES_CC_CHECK],[
2404	AC_TRY_COMPILE([
2405]ifelse($3,ncursesw,[
2406#define _XOPEN_SOURCE_EXTENDED
2407#undef  HAVE_LIBUTF8_H	/* in case we used CF_UTF8_LIB */
2408#define HAVE_LIBUTF8_H	/* to force ncurses' header file to use cchar_t */
2409])[
2410#include <$2>],[
2411#ifdef NCURSES_VERSION
2412]ifelse($3,ncursesw,[
2413#ifndef WACS_BSSB
2414	make an error
2415#endif
2416])[
2417printf("%s\n", NCURSES_VERSION);
2418#else
2419#ifdef __NCURSES_H
2420printf("old\n");
2421#else
2422	make an error
2423#endif
2424#endif
2425	]
2426	,[$1=$2]
2427	,[$1=no])
2428])dnl
2429dnl ---------------------------------------------------------------------------
2430dnl CF_NCURSES_CONFIG version: 6 updated: 2010/04/28 06:02:16
2431dnl -----------------
2432dnl Tie together the configure-script macros for ncurses.
2433dnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
2434dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
2435dnl
2436dnl $1 is the root library name (default: "ncurses")
2437AC_DEFUN([CF_NCURSES_CONFIG],
2438[
2439cf_ncuconfig_root=ifelse($1,,ncurses,$1)
2440
2441echo "Looking for ${cf_ncuconfig_root}-config"
2442AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
2443
2444if test "$NCURSES_CONFIG" != none ; then
2445
2446CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
2447LIBS="`$NCURSES_CONFIG --libs` $LIBS"
2448
2449# even with config script, some packages use no-override for curses.h
2450CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
2451
2452dnl like CF_NCURSES_CPPFLAGS
2453AC_DEFINE(NCURSES)
2454
2455dnl like CF_NCURSES_LIBS
2456CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
2457AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2458
2459dnl like CF_NCURSES_VERSION
2460cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
2461
2462else
2463
2464CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
2465CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2466
2467fi
2468])dnl
2469dnl ---------------------------------------------------------------------------
2470dnl CF_NCURSES_CPPFLAGS version: 19 updated: 2007/07/29 13:35:20
2471dnl -------------------
2472dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2473dnl the CPPFLAGS variable so we can include its header.
2474dnl
2475dnl The header files may be installed as either curses.h, or ncurses.h (would
2476dnl be obsolete, except that some packagers prefer this name to distinguish it
2477dnl from a "native" curses implementation).  If not installed for overwrite,
2478dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2479dnl /usr/include/ncurses), but someone may have installed overwriting the
2480dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2481dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2482dnl the header.
2483dnl
2484dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2485dnl is already in the include-path, don't even bother with this, since we cannot
2486dnl easily determine which file it is.  In this case, it has to be <curses.h>.
2487dnl
2488dnl The optional parameter gives the root name of the library, in case it is
2489dnl not installed as the default curses library.  That is how the
2490dnl wide-character version of ncurses is installed.
2491AC_DEFUN([CF_NCURSES_CPPFLAGS],
2492[AC_REQUIRE([CF_WITH_CURSES_DIR])
2493
2494AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2495cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2496
2497test -n "$cf_cv_curses_dir" && \
2498test "$cf_cv_curses_dir" != "no" && { \
2499  CF_ADD_INCDIR($cf_cv_curses_dir/include $cf_cv_curses_dir/include/$cf_ncuhdr_root)
2500}
2501
2502AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2503	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2504	( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2505	for cf_header in $cf_header_list
2506	do
2507		CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2508		test "$cf_cv_ncurses_h" != no && break
2509	done
2510])
2511
2512CF_NCURSES_HEADER
2513CF_TERM_HEADER
2514
2515# some applications need this, but should check for NCURSES_VERSION
2516AC_DEFINE(NCURSES)
2517
2518CF_NCURSES_VERSION
2519])dnl
2520dnl ---------------------------------------------------------------------------
2521dnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
2522dnl -----------------
2523dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2524dnl variations of ncurses' installs.
2525dnl
2526dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2527AC_DEFUN([CF_NCURSES_HEADER],[
2528
2529if test "$cf_cv_ncurses_h" != no ; then
2530	cf_cv_ncurses_header=$cf_cv_ncurses_h
2531else
2532
2533AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2534	test -n "$verbose" && echo
2535	CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2536	test -n "$verbose" && echo search path $cf_search
2537	cf_save2_CPPFLAGS="$CPPFLAGS"
2538	for cf_incdir in $cf_search
2539	do
2540		CF_ADD_INCDIR($cf_incdir)
2541		for cf_header in \
2542			ncurses.h \
2543			curses.h
2544		do
2545			CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2546			if test "$cf_cv_ncurses_h2" != no ; then
2547				cf_cv_ncurses_h2=$cf_incdir/$cf_header
2548				test -n "$verbose" && echo $ac_n "	... found $ac_c" 1>&AC_FD_MSG
2549				break
2550			fi
2551			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2552		done
2553		CPPFLAGS="$cf_save2_CPPFLAGS"
2554		test "$cf_cv_ncurses_h2" != no && break
2555	done
2556	test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2557	])
2558
2559	CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2560	cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2561	if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2562		cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2563	fi
2564	CF_ADD_INCDIR($cf_1st_incdir)
2565
2566fi
2567
2568# Set definitions to allow ifdef'ing for ncurses.h
2569
2570case $cf_cv_ncurses_header in # (vi
2571*ncurses.h)
2572	AC_DEFINE(HAVE_NCURSES_H)
2573	;;
2574esac
2575
2576case $cf_cv_ncurses_header in # (vi
2577ncurses/curses.h|ncurses/ncurses.h)
2578	AC_DEFINE(HAVE_NCURSES_NCURSES_H)
2579	;;
2580ncursesw/curses.h|ncursesw/ncurses.h)
2581	AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
2582	;;
2583esac
2584
2585])dnl
2586dnl ---------------------------------------------------------------------------
2587dnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
2588dnl ---------------
2589dnl Look for the ncurses library.  This is a little complicated on Linux,
2590dnl because it may be linked with the gpm (general purpose mouse) library.
2591dnl Some distributions have gpm linked with (bsd) curses, which makes it
2592dnl unusable with ncurses.  However, we don't want to link with gpm unless
2593dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2594dnl and the linker will record a dependency.
2595dnl
2596dnl The optional parameter gives the root name of the library, in case it is
2597dnl not installed as the default curses library.  That is how the
2598dnl wide-character version of ncurses is installed.
2599AC_DEFUN([CF_NCURSES_LIBS],
2600[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2601
2602cf_nculib_root=ifelse($1,,ncurses,$1)
2603	# This works, except for the special case where we find gpm, but
2604	# ncurses is in a nonstandard location via $LIBS, and we really want
2605	# to link gpm.
2606cf_ncurses_LIBS=""
2607cf_ncurses_SAVE="$LIBS"
2608AC_CHECK_LIB(gpm,Gpm_Open,
2609	[AC_CHECK_LIB(gpm,initscr,
2610		[LIBS="$cf_ncurses_SAVE"],
2611		[cf_ncurses_LIBS="-lgpm"])])
2612
2613case $host_os in #(vi
2614freebsd*)
2615	# This is only necessary if you are linking against an obsolete
2616	# version of ncurses (but it should do no harm, since it's static).
2617	if test "$cf_nculib_root" = ncurses ; then
2618		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2619	fi
2620	;;
2621esac
2622
2623LIBS="$cf_ncurses_LIBS $LIBS"
2624
2625if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2626then
2627	CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
2628	LIBS="-l$cf_nculib_root $LIBS"
2629else
2630	CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2631		[#include <${cf_cv_ncurses_header-curses.h}>],
2632		[initscr()],
2633		initscr)
2634fi
2635
2636if test -n "$cf_ncurses_LIBS" ; then
2637	AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2638	cf_ncurses_SAVE="$LIBS"
2639	for p in $cf_ncurses_LIBS ; do
2640		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2641		if test "$q" != "$LIBS" ; then
2642			LIBS="$q"
2643		fi
2644	done
2645	AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
2646		[initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2647		[AC_MSG_RESULT(yes)],
2648		[AC_MSG_RESULT(no)
2649		 LIBS="$cf_ncurses_SAVE"])
2650fi
2651
2652CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2653AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2654])dnl
2655dnl ---------------------------------------------------------------------------
2656dnl CF_NCURSES_VERSION version: 12 updated: 2007/04/28 09:15:55
2657dnl ------------------
2658dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2659dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2660dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2661AC_DEFUN([CF_NCURSES_VERSION],
2662[
2663AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2664AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2665	cf_cv_ncurses_version=no
2666	cf_tempfile=out$$
2667	rm -f $cf_tempfile
2668	AC_TRY_RUN([
2669#include <${cf_cv_ncurses_header-curses.h}>
2670#include <stdio.h>
2671int main()
2672{
2673	FILE *fp = fopen("$cf_tempfile", "w");
2674#ifdef NCURSES_VERSION
2675# ifdef NCURSES_VERSION_PATCH
2676	fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2677# else
2678	fprintf(fp, "%s\n", NCURSES_VERSION);
2679# endif
2680#else
2681# ifdef __NCURSES_H
2682	fprintf(fp, "old\n");
2683# else
2684	make an error
2685# endif
2686#endif
2687	${cf_cv_main_return-return}(0);
2688}],[
2689	cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2690
2691	# This will not work if the preprocessor splits the line after the
2692	# Autoconf token.  The 'unproto' program does that.
2693	cat > conftest.$ac_ext <<EOF
2694#include <${cf_cv_ncurses_header-curses.h}>
2695#undef Autoconf
2696#ifdef NCURSES_VERSION
2697Autoconf NCURSES_VERSION
2698#else
2699#ifdef __NCURSES_H
2700Autoconf "old"
2701#endif
2702;
2703#endif
2704EOF
2705	cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2706	AC_TRY_EVAL(cf_try)
2707	if test -f conftest.out ; then
2708		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2709		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2710		rm -f conftest.out
2711	fi
2712])
2713	rm -f $cf_tempfile
2714])
2715test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
2716])dnl
2717dnl ---------------------------------------------------------------------------
2718dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
2719dnl ------------------
2720dnl see CF_WITH_NO_LEAKS
2721AC_DEFUN([CF_NO_LEAKS_OPTION],[
2722AC_MSG_CHECKING(if you want to use $1 for testing)
2723AC_ARG_WITH($1,
2724	[$2],
2725	[AC_DEFINE($3)ifelse([$4],,[
2726	 $4
2727])
2728	: ${with_cflags:=-g}
2729	: ${with_no_leaks:=yes}
2730	 with_$1=yes],
2731	[with_$1=])
2732AC_MSG_RESULT(${with_$1:-no})
2733
2734case .$with_cflags in #(vi
2735.*-g*)
2736	case .$CFLAGS in #(vi
2737	.*-g*) #(vi
2738		;;
2739	*)
2740		CF_ADD_CFLAGS([-g])
2741		;;
2742	esac
2743	;;
2744esac
2745])dnl
2746dnl ---------------------------------------------------------------------------
2747dnl CF_OUR_MESSAGES version: 7 updated: 2004/09/12 19:45:55
2748dnl ---------------
2749dnl Check if we use the messages included with this program
2750dnl
2751dnl $1 specifies either Makefile or makefile, defaulting to the former.
2752dnl
2753dnl Sets variables which can be used to substitute in makefiles:
2754dnl	MSG_DIR_MAKE - to make ./po directory
2755dnl	SUB_MAKEFILE - makefile in ./po directory (see CF_BUNDLED_INTL)
2756dnl
2757AC_DEFUN([CF_OUR_MESSAGES],
2758[
2759cf_makefile=ifelse($1,,Makefile,$1)
2760
2761use_our_messages=no
2762if test "$USE_NLS" = yes ; then
2763if test -d $srcdir/po ; then
2764AC_MSG_CHECKING(if we should use included message-library)
2765	AC_ARG_ENABLE(included-msgs,
2766	[  --disable-included-msgs use included messages, for i18n support],
2767	[use_our_messages=$enableval],
2768	[use_our_messages=yes])
2769fi
2770AC_MSG_RESULT($use_our_messages)
2771fi
2772
2773MSG_DIR_MAKE="#"
2774if test "$use_our_messages" = yes
2775then
2776	SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:$srcdir/po/$cf_makefile.inn"
2777	MSG_DIR_MAKE=
2778fi
2779
2780AC_SUBST(MSG_DIR_MAKE)
2781AC_SUBST(SUB_MAKEFILE)
2782])dnl
2783dnl ---------------------------------------------------------------------------
2784dnl CF_PATHSEP version: 4 updated: 2009/01/11 20:30:23
2785dnl ----------
2786dnl Provide a value for the $PATH and similar separator
2787AC_DEFUN([CF_PATHSEP],
2788[
2789	case $cf_cv_system_name in
2790	os2*)	PATH_SEPARATOR=';'  ;;
2791	*)	PATH_SEPARATOR=':'  ;;
2792	esac
2793ifelse($1,,,[$1=$PATH_SEPARATOR])
2794	AC_SUBST(PATH_SEPARATOR)
2795])dnl
2796dnl ---------------------------------------------------------------------------
2797dnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
2798dnl --------------
2799dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2800dnl begins with one of the prefix/exec_prefix variables, and then again if the
2801dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2802dnl delayed evaluation of those symbols.
2803AC_DEFUN([CF_PATH_SYNTAX],[
2804if test "x$prefix" != xNONE; then
2805  cf_path_syntax="$prefix"
2806else
2807  cf_path_syntax="$ac_default_prefix"
2808fi
2809
2810case ".[$]$1" in #(vi
2811.\[$]\(*\)*|.\'*\'*) #(vi
2812  ;;
2813..|./*|.\\*) #(vi
2814  ;;
2815.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
2816  ;;
2817.\[$]{*prefix}*) #(vi
2818  eval $1="[$]$1"
2819  case ".[$]$1" in #(vi
2820  .NONE/*)
2821    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2822    ;;
2823  esac
2824  ;; #(vi
2825.no|.NONE/*)
2826  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2827  ;;
2828*)
2829  ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2830  ;;
2831esac
2832])dnl
2833dnl ---------------------------------------------------------------------------
2834dnl CF_POSIX_C_SOURCE version: 7 updated: 2010/01/09 11:05:50
2835dnl -----------------
2836dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2837dnl
2838dnl	POSIX.1-1990				_POSIX_SOURCE
2839dnl	POSIX.1-1990 and			_POSIX_SOURCE and
2840dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
2841dnl		Bindings Option
2842dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
2843dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
2844dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
2845dnl
2846dnl Parameters:
2847dnl	$1 is the nominal value for _POSIX_C_SOURCE
2848AC_DEFUN([CF_POSIX_C_SOURCE],
2849[
2850cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
2851
2852cf_save_CFLAGS="$CFLAGS"
2853cf_save_CPPFLAGS="$CPPFLAGS"
2854
2855CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2856CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2857
2858AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2859	CF_MSG_LOG(if the symbol is already defined go no further)
2860	AC_TRY_COMPILE([#include <sys/types.h>],[
2861#ifndef _POSIX_C_SOURCE
2862make an error
2863#endif],
2864	[cf_cv_posix_c_source=no],
2865	[cf_want_posix_source=no
2866	 case .$cf_POSIX_C_SOURCE in #(vi
2867	 .[[12]]??*) #(vi
2868		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2869		;;
2870	 .2) #(vi
2871		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2872		cf_want_posix_source=yes
2873		;;
2874	 .*)
2875		cf_want_posix_source=yes
2876		;;
2877	 esac
2878	 if test "$cf_want_posix_source" = yes ; then
2879		AC_TRY_COMPILE([#include <sys/types.h>],[
2880#ifdef _POSIX_SOURCE
2881make an error
2882#endif],[],
2883		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2884	 fi
2885	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2886	 CFLAGS="$cf_trim_CFLAGS"
2887	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2888	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
2889	 AC_TRY_COMPILE([#include <sys/types.h>],[
2890#ifndef _POSIX_C_SOURCE
2891make an error
2892#endif],,
2893	 [cf_cv_posix_c_source=no])
2894	 CFLAGS="$cf_save_CFLAGS"
2895	 CPPFLAGS="$cf_save_CPPFLAGS"
2896	])
2897])
2898
2899if test "$cf_cv_posix_c_source" != no ; then
2900	CFLAGS="$cf_trim_CFLAGS"
2901	CPPFLAGS="$cf_trim_CPPFLAGS"
2902	CF_ADD_CFLAGS($cf_cv_posix_c_source)
2903fi
2904
2905])dnl
2906dnl ---------------------------------------------------------------------------
2907dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
2908dnl --------------
2909dnl Check if C (preprocessor) -U and -D options are processed in the order
2910dnl given rather than by type of option.  Some compilers insist on apply all
2911dnl of the -U options after all of the -D options.  Others allow mixing them,
2912dnl and may predefine symbols that conflict with those we define.
2913AC_DEFUN([CF_PROG_CC_U_D],
2914[
2915AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
2916	cf_save_CPPFLAGS="$CPPFLAGS"
2917	CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
2918	AC_TRY_COMPILE([],[
2919#ifndef U_D_OPTIONS
2920make an undefined-error
2921#endif
2922#ifdef  D_U_OPTIONS
2923make a defined-error
2924#endif
2925	],[
2926	cf_cv_cc_u_d_options=yes],[
2927	cf_cv_cc_u_d_options=no])
2928	CPPFLAGS="$cf_save_CPPFLAGS"
2929])
2930])dnl
2931dnl ---------------------------------------------------------------------------
2932dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
2933dnl -----------
2934dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
2935AC_DEFUN([CF_PROG_EXT],
2936[
2937AC_REQUIRE([CF_CHECK_CACHE])
2938case $cf_cv_system_name in
2939os2*)
2940    CFLAGS="$CFLAGS -Zmt"
2941    CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
2942    CXXFLAGS="$CXXFLAGS -Zmt"
2943    # autoconf's macro sets -Zexe and suffix both, which conflict:w
2944    LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
2945    ac_cv_exeext=.exe
2946    ;;
2947esac
2948
2949AC_EXEEXT
2950AC_OBJEXT
2951
2952PROG_EXT="$EXEEXT"
2953AC_SUBST(PROG_EXT)
2954test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
2955])dnl
2956dnl ---------------------------------------------------------------------------
2957dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2958dnl ----------------
2959dnl Remove all -U and -D options that refer to the given symbol from a list
2960dnl of C compiler options.  This works around the problem that not all
2961dnl compilers process -U and -D options from left-to-right, so a -U option
2962dnl cannot be used to cancel the effect of a preceding -D option.
2963dnl
2964dnl $1 = target (which could be the same as the source variable)
2965dnl $2 = source (including '$')
2966dnl $3 = symbol to remove
2967define([CF_REMOVE_DEFINE],
2968[
2969$1=`echo "$2" | \
2970	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
2971		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
2972])dnl
2973dnl ---------------------------------------------------------------------------
2974dnl CF_RPATH_HACK version: 8 updated: 2010/04/17 15:38:58
2975dnl -------------
2976AC_DEFUN([CF_RPATH_HACK],
2977[
2978AC_REQUIRE([CF_LD_RPATH_OPT])
2979AC_MSG_CHECKING(for updated LDFLAGS)
2980if test -n "$LD_RPATH_OPT" ; then
2981	AC_MSG_RESULT(maybe)
2982
2983	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2984	cf_rpath_list="/usr/lib /lib"
2985	if test "$cf_ldd_prog" != no
2986	then
2987AC_TRY_LINK([#include <stdio.h>],
2988		[printf("Hello");],
2989		[cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort -u`])
2990	fi
2991
2992	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2993
2994	CF_RPATH_HACK_2(LDFLAGS)
2995	CF_RPATH_HACK_2(LIBS)
2996
2997	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2998fi
2999AC_SUBST(EXTRA_LDFLAGS)
3000])dnl
3001dnl ---------------------------------------------------------------------------
3002dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
3003dnl ---------------
3004dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
3005dnl EXTRA_LDFLAGS for each -L option found.
3006dnl
3007dnl $cf_rpath_list contains a list of directories to ignore.
3008dnl
3009dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
3010dnl      but LIBS often has misplaced -L options.
3011AC_DEFUN([CF_RPATH_HACK_2],
3012[
3013CF_VERBOSE(...checking $1 [$]$1)
3014
3015cf_rpath_dst=
3016for cf_rpath_src in [$]$1
3017do
3018	case $cf_rpath_src in #(vi
3019	-L*) #(vi
3020
3021		# check if this refers to a directory which we will ignore
3022		cf_rpath_skip=no
3023		if test -n "$cf_rpath_list"
3024		then
3025			for cf_rpath_item in $cf_rpath_list
3026			do
3027				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
3028				then
3029					cf_rpath_skip=yes
3030					break
3031				fi
3032			done
3033		fi
3034
3035		if test "$cf_rpath_skip" = no
3036		then
3037			# transform the option
3038			if test "$LD_RPATH_OPT" = "-R " ; then
3039				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
3040			else
3041				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
3042			fi
3043
3044			# if we have not already added this, add it now
3045			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
3046			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
3047			then
3048				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
3049				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
3050			fi
3051		fi
3052		;;
3053	esac
3054	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
3055done
3056$1=$cf_rpath_dst
3057
3058CF_VERBOSE(...checked $1 [$]$1)
3059AC_SUBST(EXTRA_LDFLAGS)
3060])dnl
3061dnl ---------------------------------------------------------------------------
3062dnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
3063dnl --------------
3064dnl Construct a search-list for a nonstandard header/lib-file
3065dnl	$1 = the variable to return as result
3066dnl	$2 = the package name
3067dnl	$3 = the subdirectory, e.g., bin, include or lib
3068AC_DEFUN([CF_SUBDIR_PATH],
3069[
3070$1=
3071
3072CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
3073CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
3074CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
3075CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
3076CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
3077])dnl
3078dnl ---------------------------------------------------------------------------
3079dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
3080dnl --------
3081dnl	Shorthand macro for substituting things that the user may override
3082dnl	with an environment variable.
3083dnl
3084dnl	$1 = long/descriptive name
3085dnl	$2 = environment variable
3086dnl	$3 = default value
3087AC_DEFUN([CF_SUBST],
3088[AC_CACHE_VAL(cf_cv_subst_$2,[
3089AC_MSG_CHECKING(for $1 (symbol $2))
3090CF_SUBST_IF([-z "[$]$2"], [$2], [$3])
3091cf_cv_subst_$2=[$]$2
3092AC_MSG_RESULT([$]$2)
3093])
3094])dnl
3095dnl ---------------------------------------------------------------------------
3096dnl CF_SYSTYPE version: 3 updated: 2001/02/03 00:14:59
3097dnl ----------
3098dnl Derive the system-type (our main clue to the method of building shared
3099dnl libraries).
3100AC_DEFUN([CF_SYSTYPE],
3101[
3102AC_MSG_CHECKING(for system type)
3103AC_CACHE_VAL(cf_cv_systype,[
3104AC_ARG_WITH(system-type,
3105[  --with-system-type=XXX  test: override derived host system-type],
3106[cf_cv_systype=$withval],
3107[
3108cf_cv_systype="`(uname -s || hostname || echo unknown) 2>/dev/null |sed -e s'/[[:\/.-]]/_/'g  | sed 1q`"
3109if test -z "$cf_cv_systype"; then cf_cv_systype=unknown;fi
3110])])
3111AC_MSG_RESULT($cf_cv_systype)
3112])dnl
3113dnl ---------------------------------------------------------------------------
3114dnl CF_SYS_NAME version: 3 updated: 2008/03/23 14:48:54
3115dnl -----------
3116dnl Derive the system name, as a check for reusing the autoconf cache
3117AC_DEFUN([CF_SYS_NAME],
3118[
3119SYS_NAME=`(uname -s -r || uname -a || hostname) 2>/dev/null | sed 1q`
3120test -z "$SYS_NAME" && SYS_NAME=unknown
3121AC_DEFINE_UNQUOTED(SYS_NAME,"$SYS_NAME")
3122
3123AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$SYS_NAME"])
3124
3125if test ".$SYS_NAME" != ".$cf_cv_system_name" ; then
3126	AC_MSG_RESULT("Cached system name does not agree with actual")
3127	AC_MSG_ERROR("Please remove config.cache and try again.")
3128fi])
3129dnl ---------------------------------------------------------------------------
3130dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
3131dnl --------------
3132dnl Look for term.h, which is part of X/Open curses.  It defines the interface
3133dnl to terminfo database.  Usually it is in the same include-path as curses.h,
3134dnl but some packagers change this, breaking various applications.
3135AC_DEFUN([CF_TERM_HEADER],[
3136AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
3137case ${cf_cv_ncurses_header} in #(vi
3138*/ncurses.h|*/ncursesw.h) #(vi
3139	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
3140	;;
3141*)
3142	cf_term_header=term.h
3143	;;
3144esac
3145
3146for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
3147do
3148AC_TRY_COMPILE([#include <stdio.h>
3149#include <${cf_cv_ncurses_header-curses.h}>
3150#include <$cf_test>
3151],[int x = auto_left_margin],[
3152	cf_cv_term_header="$cf_test"],[
3153	cf_cv_term_header=unknown
3154	])
3155	test "$cf_cv_term_header" != unknown && break
3156done
3157])
3158
3159# Set definitions to allow ifdef'ing to accommodate subdirectories
3160
3161case $cf_cv_term_header in # (vi
3162*term.h)
3163	AC_DEFINE(HAVE_TERM_H)
3164	;;
3165esac
3166
3167case $cf_cv_term_header in # (vi
3168ncurses/term.h) #(vi
3169	AC_DEFINE(HAVE_NCURSES_TERM_H)
3170	;;
3171ncursesw/term.h)
3172	AC_DEFINE(HAVE_NCURSESW_TERM_H)
3173	;;
3174esac
3175])dnl
3176dnl ---------------------------------------------------------------------------
3177dnl CF_UNION_WAIT version: 5 updated: 1997/11/23 14:49:44
3178dnl -------------
3179dnl Check to see if the BSD-style union wait is declared.  Some platforms may
3180dnl use this, though it is deprecated in favor of the 'int' type in Posix.
3181dnl Some vendors provide a bogus implementation that declares union wait, but
3182dnl uses the 'int' type instead; we try to spot these by checking for the
3183dnl associated macros.
3184dnl
3185dnl Ahem.  Some implementers cast the status value to an int*, as an attempt to
3186dnl use the macros for either union wait or int.  So we do a check compile to
3187dnl see if the macros are defined and apply to an int.
3188dnl
3189dnl Sets: $cf_cv_type_unionwait
3190dnl Defines: HAVE_TYPE_UNIONWAIT
3191AC_DEFUN([CF_UNION_WAIT],
3192[
3193AC_REQUIRE([CF_WAIT_HEADERS])
3194AC_MSG_CHECKING([for union wait])
3195AC_CACHE_VAL(cf_cv_type_unionwait,[
3196	AC_TRY_LINK($cf_wait_headers,
3197	[int x;
3198	 int y = WEXITSTATUS(x);
3199	 int z = WTERMSIG(x);
3200	 wait(&x);
3201	],
3202	[cf_cv_type_unionwait=no
3203	 echo compiles ok w/o union wait 1>&AC_FD_CC
3204	],[
3205	AC_TRY_LINK($cf_wait_headers,
3206	[union wait x;
3207#ifdef WEXITSTATUS
3208	 int y = WEXITSTATUS(x);
3209#endif
3210#ifdef WTERMSIG
3211	 int z = WTERMSIG(x);
3212#endif
3213	 wait(&x);
3214	],
3215	[cf_cv_type_unionwait=yes
3216	 echo compiles ok with union wait and possibly macros too 1>&AC_FD_CC
3217	],
3218	[cf_cv_type_unionwait=no])])])
3219AC_MSG_RESULT($cf_cv_type_unionwait)
3220test $cf_cv_type_unionwait = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT)
3221])dnl
3222dnl ---------------------------------------------------------------------------
3223dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3224dnl --------
3225dnl Make an uppercase version of a variable
3226dnl $1=uppercase($2)
3227AC_DEFUN([CF_UPPER],
3228[
3229$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3230])dnl
3231dnl ---------------------------------------------------------------------------
3232dnl CF_UTF8_LIB version: 6 updated: 2010/04/21 06:20:50
3233dnl -----------
3234dnl Check for multibyte support, and if not found, utf8 compatibility library
3235AC_DEFUN([CF_UTF8_LIB],
3236[
3237AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3238	cf_save_LIBS="$LIBS"
3239	AC_TRY_LINK([
3240#include <stdlib.h>],[putwc(0,0);],
3241	[cf_cv_utf8_lib=yes],
3242	[CF_FIND_LINKAGE([
3243#include <libutf8.h>],[putwc(0,0);],utf8,
3244		[cf_cv_utf8_lib=add-on],
3245		[cf_cv_utf8_lib=no])
3246])])
3247
3248# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3249# ncurses/ncursesw:
3250if test "$cf_cv_utf8_lib" = "add-on" ; then
3251	AC_DEFINE(HAVE_LIBUTF8_H)
3252	CF_ADD_INCDIR($cf_cv_header_path_utf8)
3253	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3254	LIBS="$cf_cv_library_file_utf8 $LIBS"
3255fi
3256])dnl
3257dnl ---------------------------------------------------------------------------
3258dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3259dnl ----------
3260dnl Use AC_VERBOSE w/o the warnings
3261AC_DEFUN([CF_VERBOSE],
3262[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
3263CF_MSG_LOG([$1])
3264])dnl
3265dnl ---------------------------------------------------------------------------
3266dnl CF_VERSION_INFO version: 3 updated: 2003/11/22 12:22:45
3267dnl ---------------
3268dnl Define several useful symbols derived from the VERSION file.  A separate
3269dnl file is preferred to embedding the version numbers in various scripts.
3270dnl (automake is a textbook-example of why the latter is a bad idea, but there
3271dnl are others).
3272dnl
3273dnl The file contents are:
3274dnl	libtool-version	release-version	patch-version
3275dnl or
3276dnl	release-version
3277dnl where
3278dnl	libtool-version (see ?) consists of 3 integers separated by '.'
3279dnl	release-version consists of a major version and minor version
3280dnl		separated by '.', optionally followed by a patch-version
3281dnl		separated by '-'.  The minor version need not be an
3282dnl		integer (but it is preferred).
3283dnl	patch-version is an integer in the form yyyymmdd, so ifdef's and
3284dnl		scripts can easily compare versions.
3285dnl
3286dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
3287dnl simply extracts the first field using 'cut -f1'.
3288AC_DEFUN([CF_VERSION_INFO],
3289[
3290if test -f $srcdir/VERSION ; then
3291	AC_MSG_CHECKING(for package version)
3292
3293	# if there are not enough fields, cut returns the last one...
3294	cf_field1=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
3295	cf_field2=`sed -e '2,$d' $srcdir/VERSION|cut -f2`
3296	cf_field3=`sed -e '2,$d' $srcdir/VERSION|cut -f3`
3297
3298	# this is how CF_BUNDLED_INTL uses $VERSION:
3299	VERSION="$cf_field1"
3300
3301	VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
3302	test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
3303
3304	VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
3305	test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
3306
3307	AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
3308
3309	AC_MSG_CHECKING(for package patch date)
3310	VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
3311	case .$VERSION_PATCH in
3312	.)
3313		AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
3314		;;
3315	.[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
3316		;;
3317	*)
3318		AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
3319		;;
3320	esac
3321	AC_MSG_RESULT($VERSION_PATCH)
3322else
3323	AC_MSG_ERROR(did not find $srcdir/VERSION)
3324fi
3325
3326# show the actual data that we have for versions:
3327CF_VERBOSE(VERSION $VERSION)
3328CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
3329CF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
3330CF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
3331
3332AC_SUBST(VERSION)
3333AC_SUBST(VERSION_MAJOR)
3334AC_SUBST(VERSION_MINOR)
3335AC_SUBST(VERSION_PATCH)
3336
3337dnl if a package name is given, define its corresponding version info.  We
3338dnl need the package name to ensure that the defined symbols are unique.
3339ifelse($1,,,[
3340	PACKAGE=$1
3341	AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
3342	AC_SUBST(PACKAGE)
3343	CF_UPPER(cf_PACKAGE,$PACKAGE)
3344	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}")
3345	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH})
3346])
3347])dnl
3348dnl ---------------------------------------------------------------------------
3349dnl CF_WAIT_HEADERS version: 2 updated: 1997/10/21 19:45:33
3350dnl ---------------
3351dnl Build up an expression $cf_wait_headers with the header files needed to
3352dnl compile against the prototypes for 'wait()', 'waitpid()', etc.  Assume it's
3353dnl Posix, which uses <sys/types.h> and <sys/wait.h>, but allow SVr4 variation
3354dnl with <wait.h>.
3355AC_DEFUN([CF_WAIT_HEADERS],
3356[
3357AC_HAVE_HEADERS(sys/wait.h)
3358cf_wait_headers="#include <sys/types.h>
3359"
3360if test $ac_cv_header_sys_wait_h = yes; then
3361cf_wait_headers="$cf_wait_headers
3362#include <sys/wait.h>
3363"
3364else
3365AC_HAVE_HEADERS(wait.h)
3366AC_HAVE_HEADERS(waitstatus.h)
3367if test $ac_cv_header_wait_h = yes; then
3368cf_wait_headers="$cf_wait_headers
3369#include <wait.h>
3370"
3371fi
3372if test $ac_cv_header_waitstatus_h = yes; then
3373cf_wait_headers="$cf_wait_headers
3374#include <waitstatus.h>
3375"
3376fi
3377fi
3378])dnl
3379dnl ---------------------------------------------------------------------------
3380dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
3381dnl ------------------
3382dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3383dnl libraries.
3384AC_DEFUN([CF_WITH_CURSES_DIR],[
3385AC_ARG_WITH(curses-dir,
3386	[  --with-curses-dir=DIR   directory in which (n)curses is installed],
3387	[CF_PATH_SYNTAX(withval)
3388	 cf_cv_curses_dir=$withval],
3389	[cf_cv_curses_dir=no])
3390])dnl
3391dnl ---------------------------------------------------------------------------
3392dnl CF_WITH_DBMALLOC version: 6 updated: 2006/12/16 14:24:05
3393dnl ----------------
3394dnl Configure-option for dbmalloc.  The optional parameter is used to override
3395dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3396AC_DEFUN([CF_WITH_DBMALLOC],[
3397CF_NO_LEAKS_OPTION(dbmalloc,
3398	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3399	[USE_DBMALLOC])
3400
3401if test "$with_dbmalloc" = yes ; then
3402	AC_CHECK_HEADER(dbmalloc.h,
3403		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
3404fi
3405])dnl
3406dnl ---------------------------------------------------------------------------
3407dnl CF_WITH_DMALLOC version: 6 updated: 2006/12/16 14:24:05
3408dnl ---------------
3409dnl Configure-option for dmalloc.  The optional parameter is used to override
3410dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3411AC_DEFUN([CF_WITH_DMALLOC],[
3412CF_NO_LEAKS_OPTION(dmalloc,
3413	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
3414	[USE_DMALLOC])
3415
3416if test "$with_dmalloc" = yes ; then
3417	AC_CHECK_HEADER(dmalloc.h,
3418		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
3419fi
3420])dnl
3421dnl ---------------------------------------------------------------------------
3422dnl CF_WITH_LIBTOOL version: 23 updated: 2009/03/28 14:26:27
3423dnl ---------------
3424dnl Provide a configure option to incorporate libtool.  Define several useful
3425dnl symbols for the makefile rules.
3426dnl
3427dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
3428dnl macros from libtool.m4 which is in the aclocal directory of automake.
3429dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
3430dnl But that still does not work properly since the macro is expanded outside
3431dnl the CF_WITH_LIBTOOL macro:
3432dnl
3433dnl	#!/bin/sh
3434dnl	ACLOCAL=`aclocal --print-ac-dir`
3435dnl	if test -z "$ACLOCAL" ; then
3436dnl		echo cannot find aclocal directory
3437dnl		exit 1
3438dnl	elif test ! -f $ACLOCAL/libtool.m4 ; then
3439dnl		echo cannot find libtool.m4 file
3440dnl		exit 1
3441dnl	fi
3442dnl
3443dnl	LOCAL=aclocal.m4
3444dnl	ORIG=aclocal.m4.orig
3445dnl
3446dnl	trap "mv $ORIG $LOCAL" 0 1 2 5 15
3447dnl	rm -f $ORIG
3448dnl	mv $LOCAL $ORIG
3449dnl
3450dnl	# sed the LIBTOOL= assignment to omit the current directory?
3451dnl	sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
3452dnl	cat $ORIG >>$LOCAL
3453dnl
3454dnl	autoconf-257 $*
3455dnl
3456AC_DEFUN([CF_WITH_LIBTOOL],
3457[
3458ifdef([AC_PROG_LIBTOOL],,[
3459LIBTOOL=
3460])
3461# common library maintenance symbols that are convenient for libtool scripts:
3462LIB_CREATE='${AR} -cr'
3463LIB_OBJECT='${OBJECTS}'
3464LIB_SUFFIX=.a
3465LIB_PREP="$RANLIB"
3466
3467# symbols used to prop libtool up to enable it to determine what it should be
3468# doing:
3469LIB_CLEAN=
3470LIB_COMPILE=
3471LIB_LINK='${CC}'
3472LIB_INSTALL=
3473LIB_UNINSTALL=
3474
3475AC_MSG_CHECKING(if you want to build libraries with libtool)
3476AC_ARG_WITH(libtool,
3477	[  --with-libtool          generate libraries with libtool],
3478	[with_libtool=$withval],
3479	[with_libtool=no])
3480AC_MSG_RESULT($with_libtool)
3481if test "$with_libtool" != "no"; then
3482ifdef([AC_PROG_LIBTOOL],[
3483	# missing_content_AC_PROG_LIBTOOL{{
3484	AC_PROG_LIBTOOL
3485	# missing_content_AC_PROG_LIBTOOL}}
3486],[
3487	if test "$with_libtool" != "yes" ; then
3488		CF_PATH_SYNTAX(with_libtool)
3489		LIBTOOL=$with_libtool
3490	else
3491		AC_PATH_PROG(LIBTOOL,libtool)
3492	fi
3493	if test -z "$LIBTOOL" ; then
3494		AC_MSG_ERROR(Cannot find libtool)
3495	fi
3496])dnl
3497	LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${DESTDIR}${libdir} -version-info `cut -f1 ${srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} -o'
3498	LIB_OBJECT='${OBJECTS:.o=.lo}'
3499	LIB_SUFFIX=.la
3500	LIB_CLEAN='${LIBTOOL} --mode=clean'
3501	LIB_COMPILE='${LIBTOOL} --mode=compile'
3502	LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
3503	LIB_INSTALL='${LIBTOOL} --mode=install'
3504	LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
3505	LIB_PREP=:
3506
3507	# Show the version of libtool
3508	AC_MSG_CHECKING(version of libtool)
3509
3510	# Save the version in a cache variable - this is not entirely a good
3511	# thing, but the version string from libtool is very ugly, and for
3512	# bug reports it might be useful to have the original string. "("
3513	cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' |sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
3514	AC_MSG_RESULT($cf_cv_libtool_version)
3515	if test -z "$cf_cv_libtool_version" ; then
3516		AC_MSG_ERROR(This is not GNU libtool)
3517	fi
3518
3519	# special hack to add -no-undefined (which libtool should do for itself)
3520	LT_UNDEF=
3521	case "$cf_cv_system_name" in #(vi
3522	cygwin*|mingw32*|uwin*|aix[[456]]) #(vi
3523		LT_UNDEF=-no-undefined
3524		;;
3525	esac
3526	AC_SUBST([LT_UNDEF])
3527
3528	# special hack to add --tag option for C++ compiler
3529	case $cf_cv_libtool_version in #(vi
3530	1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*) #(vi
3531		LIBTOOL_CXX="$LIBTOOL --tag=CXX"
3532		LIBTOOL="$LIBTOOL --tag=CC"
3533		;;
3534	*)
3535		LIBTOOL_CXX="$LIBTOOL"
3536		;;
3537	esac
3538else
3539	LIBTOOL=""
3540	LIBTOOL_CXX=""
3541fi
3542
3543test -z "$LIBTOOL" && ECHO_LT=
3544
3545AC_SUBST(LIBTOOL)
3546AC_SUBST(LIBTOOL_CXX)
3547AC_SUBST(LIBTOOL_OPTS)
3548
3549AC_SUBST(LIB_CREATE)
3550AC_SUBST(LIB_OBJECT)
3551AC_SUBST(LIB_SUFFIX)
3552AC_SUBST(LIB_PREP)
3553
3554AC_SUBST(LIB_CLEAN)
3555AC_SUBST(LIB_COMPILE)
3556AC_SUBST(LIB_LINK)
3557AC_SUBST(LIB_INSTALL)
3558AC_SUBST(LIB_UNINSTALL)
3559
3560])dnl
3561dnl ---------------------------------------------------------------------------
3562dnl CF_WITH_LIBTOOL_OPTS version: 2 updated: 2007/04/08 18:14:54
3563dnl --------------------
3564dnl Allow user to pass additional libtool options into the library creation
3565dnl and link steps.  The main use for this is to do something like
3566dnl	./configure --with-libtool-opts=-static
3567dnl to get the same behavior as automake-flavored
3568dnl	./configure --enable-static
3569AC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
3570AC_MSG_CHECKING(for additional libtool options)
3571AC_ARG_WITH(libtool-opts,
3572	[  --with-libtool-opts=XXX specify additional libtool options],
3573	[with_libtool_opts=$withval],
3574	[with_libtool_opts=no])
3575AC_MSG_RESULT($with_libtool_opts)
3576
3577case .$with_libtool_opts in
3578.yes|.no|.)
3579	;;
3580*)
3581	LIBTOOL_OPTS=$with_libtool_opts
3582	;;
3583esac
3584
3585AC_SUBST(LIBTOOL_OPTS)
3586])dnl
3587dnl ---------------------------------------------------------------------------
3588dnl CF_WITH_NO_LEAKS version: 1 updated: 2006/12/14 18:00:21
3589dnl ----------------
3590AC_DEFUN([CF_WITH_NO_LEAKS],[
3591
3592AC_REQUIRE([CF_WITH_DMALLOC])
3593AC_REQUIRE([CF_WITH_DBMALLOC])
3594AC_REQUIRE([CF_WITH_PURIFY])
3595AC_REQUIRE([CF_WITH_VALGRIND])
3596
3597AC_MSG_CHECKING(if you want to perform memory-leak testing)
3598AC_ARG_WITH(no-leaks,
3599	[  --with-no-leaks         test: free permanent memory, analyze leaks],
3600	[AC_DEFINE(NO_LEAKS)
3601	 cf_doalloc=".${with_dmalloc}${with_dbmalloc}${with_purify}${with_valgrind}"
3602	 case ${cf_doalloc} in #(vi
3603	 *yes*) ;;
3604	 *) AC_DEFINE(DOALLOC,10000) ;;
3605	 esac
3606	 with_no_leaks=yes],
3607	[with_no_leaks=])
3608AC_MSG_RESULT($with_no_leaks)
3609])dnl
3610dnl ---------------------------------------------------------------------------
3611dnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
3612dnl --------------
3613AC_DEFUN([CF_WITH_PURIFY],[
3614CF_NO_LEAKS_OPTION(purify,
3615	[  --with-purify           test: use Purify],
3616	[USE_PURIFY],
3617	[LINK_PREFIX="$LINK_PREFIX purify"])
3618AC_SUBST(LINK_PREFIX)
3619])dnl
3620dnl ---------------------------------------------------------------------------
3621dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3622dnl ----------------
3623AC_DEFUN([CF_WITH_VALGRIND],[
3624CF_NO_LEAKS_OPTION(valgrind,
3625	[  --with-valgrind         test: use valgrind],
3626	[USE_VALGRIND])
3627])dnl
3628dnl ---------------------------------------------------------------------------
3629dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
3630dnl ----------------
3631dnl Combine the checks for gcc features into a configure-script option
3632dnl
3633dnl Parameters:
3634dnl	$1 - see CF_GCC_WARNINGS
3635AC_DEFUN([CF_WITH_WARNINGS],
3636[
3637if ( test "$GCC" = yes || test "$GXX" = yes )
3638then
3639AC_MSG_CHECKING(if you want to check for gcc warnings)
3640AC_ARG_WITH(warnings,
3641	[  --with-warnings         test: turn on gcc warnings],
3642	[cf_opt_with_warnings=$withval],
3643	[cf_opt_with_warnings=no])
3644AC_MSG_RESULT($cf_opt_with_warnings)
3645if test "$cf_opt_with_warnings" != no ; then
3646	CF_GCC_ATTRIBUTES
3647	CF_GCC_WARNINGS([$1])
3648fi
3649fi
3650])dnl
3651dnl ---------------------------------------------------------------------------
3652dnl CF_XOPEN_CURSES version: 9 updated: 2010/04/28 06:02:16
3653dnl ---------------
3654dnl Test if we should define X/Open source for curses, needed on Digital Unix
3655dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
3656dnl
3657dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
3658dnl as getbegy().  The latter is better design, but the former is standard.
3659AC_DEFUN([CF_XOPEN_CURSES],
3660[
3661AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3662AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
3663AC_TRY_LINK([
3664#include <stdlib.h>
3665#include <${cf_cv_ncurses_header-curses.h}>],[
3666#if defined(NCURSES_VERSION_PATCH)
3667if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
3668	make an error
3669#endif
3670#endif
3671	long x = winnstr(stdscr, "", 0);
3672	int x1, y1;
3673	getbegyx(stdscr, y1, x1)],
3674	[cf_cv_need_xopen_extension=no],
3675	[AC_TRY_LINK([
3676#define _XOPEN_SOURCE_EXTENDED
3677#include <stdlib.h>
3678#include <${cf_cv_ncurses_header-curses.h}>],[
3679#ifdef NCURSES_VERSION
3680	cchar_t check;
3681	int check2 = curs_set((int)sizeof(check));
3682#endif
3683	long x = winnstr(stdscr, "", 0);
3684	int x1, y1;
3685	getbegyx(stdscr, y1, x1)],
3686	[cf_cv_need_xopen_extension=yes],
3687	[cf_cv_need_xopen_extension=unknown])])])
3688test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
3689])dnl
3690dnl ---------------------------------------------------------------------------
3691dnl CF_XOPEN_SOURCE version: 33 updated: 2010/03/28 15:35:52
3692dnl ---------------
3693dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3694dnl or adapt to the vendor's definitions to get equivalent functionality,
3695dnl without losing the common non-POSIX features.
3696dnl
3697dnl Parameters:
3698dnl	$1 is the nominal value for _XOPEN_SOURCE
3699dnl	$2 is the nominal value for _POSIX_C_SOURCE
3700AC_DEFUN([CF_XOPEN_SOURCE],[
3701
3702cf_XOPEN_SOURCE=ifelse($1,,500,$1)
3703cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
3704cf_xopen_source=
3705
3706case $host_os in #(vi
3707aix[[456]]*) #(vi
3708	cf_xopen_source="-D_ALL_SOURCE"
3709	;;
3710darwin[[0-8]].*) #(vi
3711	cf_xopen_source="-D_APPLE_C_SOURCE"
3712	;;
3713darwin*) #(vi
3714	cf_xopen_source="-D_DARWIN_C_SOURCE"
3715	;;
3716freebsd*|dragonfly*) #(vi
3717	# 5.x headers associate
3718	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3719	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3720	cf_POSIX_C_SOURCE=200112L
3721	cf_XOPEN_SOURCE=600
3722	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3723	;;
3724hpux11*) #(vi
3725	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3726	;;
3727hpux*) #(vi
3728	cf_xopen_source="-D_HPUX_SOURCE"
3729	;;
3730irix[[56]].*) #(vi
3731	cf_xopen_source="-D_SGI_SOURCE"
3732	;;
3733linux*|gnu*|mint*|k*bsd*-gnu) #(vi
3734	CF_GNU_SOURCE
3735	;;
3736mirbsd*) #(vi
3737	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
3738	;;
3739netbsd*) #(vi
3740	# setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3741	;;
3742openbsd*) #(vi
3743	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3744	;;
3745osf[[45]]*) #(vi
3746	cf_xopen_source="-D_OSF_SOURCE"
3747	;;
3748nto-qnx*) #(vi
3749	cf_xopen_source="-D_QNX_SOURCE"
3750	;;
3751sco*) #(vi
3752	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3753	;;
3754solaris2.1[[0-9]]) #(vi
3755	cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3756	;;
3757solaris2.[[1-9]]) #(vi
3758	cf_xopen_source="-D__EXTENSIONS__"
3759	;;
3760*)
3761	AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3762	AC_TRY_COMPILE([#include <sys/types.h>],[
3763#ifndef _XOPEN_SOURCE
3764make an error
3765#endif],
3766	[cf_cv_xopen_source=no],
3767	[cf_save="$CPPFLAGS"
3768	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3769	 AC_TRY_COMPILE([#include <sys/types.h>],[
3770#ifdef _XOPEN_SOURCE
3771make an error
3772#endif],
3773	[cf_cv_xopen_source=no],
3774	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3775	CPPFLAGS="$cf_save"
3776	])
3777])
3778	if test "$cf_cv_xopen_source" != no ; then
3779		CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3780		CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3781		cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3782		CF_ADD_CFLAGS($cf_temp_xopen_source)
3783	fi
3784	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3785	;;
3786esac
3787
3788if test -n "$cf_xopen_source" ; then
3789	CF_ADD_CFLAGS($cf_xopen_source)
3790fi
3791])
3792dnl ---------------------------------------------------------------------------
3793dnl CF__CURSES_HEAD version: 1 updated: 2009/07/16 19:32:31
3794dnl ---------------
3795dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
3796dnl are both available.
3797define([CF__CURSES_HEAD],[
3798#ifdef HAVE_XCURSES
3799#include <xcurses.h>
3800char * XCursesProgramName = "test";
3801#else
3802#include <${cf_cv_ncurses_header-curses.h}>
3803#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
3804#include <ncursesw/term.h>
3805#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
3806#include <ncurses/term.h>
3807#elif defined(HAVE_TERM_H)
3808#include <term.h>
3809#endif
3810#endif
3811])
3812dnl ---------------------------------------------------------------------------
3813dnl CF__ICONV_BODY version: 2 updated: 2007/07/26 17:35:47
3814dnl --------------
3815dnl Test-code needed for iconv compile-checks
3816define([CF__ICONV_BODY],[
3817	iconv_t cd = iconv_open("","");
3818	iconv(cd,NULL,NULL,NULL,NULL);
3819	iconv_close(cd);]
3820)dnl
3821dnl ---------------------------------------------------------------------------
3822dnl CF__ICONV_HEAD version: 1 updated: 2007/07/26 15:57:03
3823dnl --------------
3824dnl Header-files needed for iconv compile-checks
3825define([CF__ICONV_HEAD],[
3826#include <stdlib.h>
3827#include <iconv.h>]
3828)dnl
3829dnl ---------------------------------------------------------------------------
3830dnl CF__INTL_BODY version: 1 updated: 2007/07/26 17:35:47
3831dnl -------------
3832dnl Test-code needed for libintl compile-checks
3833dnl $1 = parameter 2 from AM_WITH_NLS
3834define([CF__INTL_BODY],[
3835    bindtextdomain ("", "");
3836    return (int) gettext ("")
3837            ifelse([$1], need-ngettext, [ + (int) ngettext ("", "", 0)], [])
3838            [ + _nl_msg_cat_cntr]
3839])
3840dnl ---------------------------------------------------------------------------
3841dnl CF__INTL_HEAD version: 1 updated: 2007/07/26 17:35:47
3842dnl -------------
3843dnl Header-files needed for libintl compile-checks
3844define([CF__INTL_HEAD],[
3845#include <libintl.h>
3846extern int _nl_msg_cat_cntr;
3847])dnl
3848dnl ---------------------------------------------------------------------------
3849dnl jm_GLIBC21 version: 3 updated: 2002/10/27 23:21:42
3850dnl ----------
3851dnl Inserted as requested by gettext 0.10.40
3852dnl File from /usr/share/aclocal
3853dnl glibc21.m4
3854dnl ====================
3855dnl serial 2
3856dnl
3857dnl Test for the GNU C Library, version 2.1 or newer.
3858dnl From Bruno Haible.
3859AC_DEFUN([jm_GLIBC21],
3860  [
3861    AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
3862      ac_cv_gnu_library_2_1,
3863      [AC_EGREP_CPP([Lucky GNU user],
3864	[
3865#include <features.h>
3866#ifdef __GNU_LIBRARY__
3867 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
3868  Lucky GNU user
3869 #endif
3870#endif
3871	],
3872	ac_cv_gnu_library_2_1=yes,
3873	ac_cv_gnu_library_2_1=no)
3874      ]
3875    )
3876    AC_SUBST(GLIBC21)
3877    GLIBC21="$ac_cv_gnu_library_2_1"
3878  ]
3879)
3880