1dnl macros used for DIALOG configure script
2dnl $Id: aclocal.m4,v 1.94 2013/09/22 14:26:24 tom Exp $
3dnl ---------------------------------------------------------------------------
4dnl Copyright 1999-2012,2013 -- Thomas E. Dickey
5dnl
6dnl Permission is hereby granted, free of charge, to any person obtaining a
7dnl copy of this software and associated documentation files (the
8dnl "Software"), to deal in the Software without restriction, including
9dnl without limitation the rights to use, copy, modify, merge, publish,
10dnl distribute, distribute with modifications, sublicense, and/or sell
11dnl copies of the Software, and to permit persons to whom the Software is
12dnl furnished to do so, subject to the following conditions:
13dnl 
14dnl The above copyright notice and this permission notice shall be included
15dnl in all copies or portions of the Software.
16dnl 
17dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24dnl 
25dnl Except as contained in this notice, the name(s) of the above copyright
26dnl holders shall not be used in advertising or otherwise to promote the
27dnl sale, use or other dealings in this Software without prior written
28dnl authorization.
29dnl
30dnl see
31dnl http://invisible-island.net/autoconf/ 
32dnl ---------------------------------------------------------------------------
33dnl ---------------------------------------------------------------------------
34dnl AM_GNU_GETTEXT version: 13 updated: 2012/11/09 05:47:26
35dnl --------------
36dnl Usage: Just like AM_WITH_NLS, which see.
37AC_DEFUN([AM_GNU_GETTEXT],
38  [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
39   AC_REQUIRE([AC_CANONICAL_HOST])dnl
40   AC_REQUIRE([AC_PROG_RANLIB])dnl
41   AC_REQUIRE([AC_HEADER_STDC])dnl
42   AC_REQUIRE([AC_C_INLINE])dnl
43   AC_REQUIRE([AC_TYPE_OFF_T])dnl
44   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
45   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
46   AC_REQUIRE([AC_FUNC_MMAP])dnl
47   AC_REQUIRE([jm_GLIBC21])dnl
48   AC_REQUIRE([CF_PROG_CC])dnl
49
50   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
51stdlib.h string.h unistd.h sys/param.h])
52   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
53getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
54strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
55
56   AM_ICONV
57   AM_LANGINFO_CODESET
58   AM_LC_MESSAGES
59   AM_WITH_NLS([$1],[$2],[$3],[$4])
60
61   if test "x$CATOBJEXT" != "x"; then
62     if test "x$ALL_LINGUAS" = "x"; then
63       LINGUAS=
64     else
65       AC_MSG_CHECKING(for catalogs to be installed)
66       NEW_LINGUAS=
67       for presentlang in $ALL_LINGUAS; do
68         useit=no
69         for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
70           # Use the presentlang catalog if desiredlang is
71           #   a. equal to presentlang, or
72           #   b. a variant of presentlang (because in this case,
73           #      presentlang can be used as a fallback for messages
74           #      which are not translated in the desiredlang catalog).
75           case "$desiredlang" in
76             "$presentlang"*) useit=yes;;
77           esac
78         done
79         if test $useit = yes; then
80           NEW_LINGUAS="$NEW_LINGUAS $presentlang"
81         fi
82       done
83       LINGUAS=$NEW_LINGUAS
84       AC_MSG_RESULT($LINGUAS)
85     fi
86
87     dnl Construct list of names of catalog files to be constructed.
88     if test -n "$LINGUAS"; then
89       for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
90     fi
91   fi
92
93   dnl Enable libtool support if the surrounding package wishes it.
94   INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
95   AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
96])dnl
97dnl ---------------------------------------------------------------------------
98dnl AM_ICONV version: 12 updated: 2007/07/30 19:12:03
99dnl --------
100dnl Inserted as requested by gettext 0.10.40
101dnl File from /usr/share/aclocal
102dnl iconv.m4
103dnl ====================
104dnl serial AM2
105dnl
106dnl From Bruno Haible.
107dnl
108dnl ====================
109dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
110dnl range of locations searched.  Retain the same cache-variable naming to
111dnl allow reuse with the other gettext macros -Thomas E Dickey
112AC_DEFUN([AM_ICONV],
113[
114  dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
115  dnl those with the standalone portable GNU libiconv installed).
116
117  AC_ARG_WITH([libiconv-prefix],
118[  --with-libiconv-prefix=DIR
119                          search for libiconv in DIR/include and DIR/lib], [
120    CF_ADD_OPTIONAL_PATH($withval, libiconv)
121   ])
122
123  AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
124    CF_FIND_LINKAGE(CF__ICONV_HEAD,
125      CF__ICONV_BODY,
126      iconv,
127      am_cv_func_iconv=yes,
128      am_cv_func_iconv=["no, consider installing GNU libiconv"])])
129
130  if test "$am_cv_func_iconv" = yes; then
131    AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
132
133    AC_CACHE_CHECK([if the declaration of iconv() needs const.],
134		   am_cv_proto_iconv_const,[
135      AC_TRY_COMPILE(CF__ICONV_HEAD [
136extern
137#ifdef __cplusplus
138"C"
139#endif
140#if defined(__STDC__) || defined(__cplusplus)
141size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
142#else
143size_t iconv();
144#endif
145],[], am_cv_proto_iconv_const=no,
146      am_cv_proto_iconv_const=yes)])
147
148    if test "$am_cv_proto_iconv_const" = yes ; then
149      am_cv_proto_iconv_arg1="const"
150    else
151      am_cv_proto_iconv_arg1=""
152    fi
153
154    AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
155      [Define as const if the declaration of iconv() needs const.])
156  fi
157
158  LIBICONV=
159  if test "$cf_cv_find_linkage_iconv" = yes; then
160    CF_ADD_INCDIR($cf_cv_header_path_iconv)
161    if test -n "$cf_cv_library_file_iconv" ; then
162      LIBICONV="-liconv"
163      CF_ADD_LIBDIR($cf_cv_library_path_iconv)
164    fi
165  fi
166
167  AC_SUBST(LIBICONV)
168])dnl
169dnl ---------------------------------------------------------------------------
170dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
171dnl -------------------
172dnl Inserted as requested by gettext 0.10.40
173dnl File from /usr/share/aclocal
174dnl codeset.m4
175dnl ====================
176dnl serial AM1
177dnl
178dnl From Bruno Haible.
179AC_DEFUN([AM_LANGINFO_CODESET],
180[
181  AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
182    [AC_TRY_LINK([#include <langinfo.h>],
183      [char* cs = nl_langinfo(CODESET);],
184      am_cv_langinfo_codeset=yes,
185      am_cv_langinfo_codeset=no)
186    ])
187  if test $am_cv_langinfo_codeset = yes; then
188    AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
189      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
190  fi
191])dnl
192dnl ---------------------------------------------------------------------------
193dnl AM_LC_MESSAGES version: 4 updated: 2002/10/27 23:21:42
194dnl --------------
195dnl Inserted as requested by gettext 0.10.40
196dnl File from /usr/share/aclocal
197dnl lcmessage.m4
198dnl ====================
199dnl Check whether LC_MESSAGES is available in <locale.h>.
200dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
201dnl
202dnl This file can be copied and used freely without restrictions.  It can
203dnl be used in projects which are not available under the GNU General Public
204dnl License or the GNU Library General Public License but which still want
205dnl to provide support for the GNU gettext functionality.
206dnl Please note that the actual code of the GNU gettext library is covered
207dnl by the GNU Library General Public License, and the rest of the GNU
208dnl gettext package package is covered by the GNU General Public License.
209dnl They are *not* in the public domain.
210dnl
211dnl serial 2
212dnl
213AC_DEFUN([AM_LC_MESSAGES],
214  [if test $ac_cv_header_locale_h = yes; then
215    AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
216      [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
217       am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
218    if test $am_cv_val_LC_MESSAGES = yes; then
219      AC_DEFINE(HAVE_LC_MESSAGES, 1,
220        [Define if your <locale.h> file defines LC_MESSAGES.])
221    fi
222  fi])dnl
223dnl ---------------------------------------------------------------------------
224dnl AM_PATH_PROG_WITH_TEST version: 8 updated: 2009/01/11 20:31:12
225dnl ----------------------
226dnl Inserted as requested by gettext 0.10.40
227dnl File from /usr/share/aclocal
228dnl progtest.m4
229dnl ====================
230dnl Search path for a program which passes the given test.
231dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
232dnl
233dnl This file can be copied and used freely without restrictions.  It can
234dnl be used in projects which are not available under the GNU General Public
235dnl License or the GNU Library General Public License but which still want
236dnl to provide support for the GNU gettext functionality.
237dnl Please note that the actual code of the GNU gettext library is covered
238dnl by the GNU Library General Public License, and the rest of the GNU
239dnl gettext package package is covered by the GNU General Public License.
240dnl They are *not* in the public domain.
241dnl
242dnl serial 2
243dnl
244dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
245dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
246AC_DEFUN([AM_PATH_PROG_WITH_TEST],
247[# Extract the first word of "$2", so it can be a program name with args.
248AC_REQUIRE([CF_PATHSEP])
249set dummy $2; ac_word=[$]2
250AC_MSG_CHECKING([for $ac_word])
251AC_CACHE_VAL(ac_cv_path_$1,
252[case "[$]$1" in
253  [[\\/]*|?:[\\/]]*)
254  ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
255  ;;
256  *)
257  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
258  for ac_dir in ifelse([$5], , $PATH, [$5]); do
259    test -z "$ac_dir" && ac_dir=.
260    if test -f $ac_dir/$ac_word$ac_exeext; then
261      if [$3]; then
262	ac_cv_path_$1="$ac_dir/$ac_word$ac_exeext"
263	break
264      fi
265    fi
266  done
267  IFS="$ac_save_ifs"
268dnl If no 4th arg is given, leave the cache variable unset,
269dnl so AC_PATH_PROGS will keep looking.
270ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
271])dnl
272  ;;
273esac])dnl
274$1="$ac_cv_path_$1"
275if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
276  AC_MSG_RESULT([$]$1)
277else
278  AC_MSG_RESULT(no)
279fi
280AC_SUBST($1)dnl
281])dnl
282dnl ---------------------------------------------------------------------------
283dnl AM_WITH_NLS version: 25 updated: 2012/10/06 08:57:51
284dnl -----------
285dnl Inserted as requested by gettext 0.10.40
286dnl File from /usr/share/aclocal
287dnl gettext.m4
288dnl ====================
289dnl Macro to add for using GNU gettext.
290dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
291dnl ====================
292dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
293dnl range of locations searched.  Retain the same cache-variable naming to
294dnl allow reuse with the other gettext macros -Thomas E Dickey
295dnl ====================
296dnl
297dnl This file can be copied and used freely without restrictions.  It can
298dnl be used in projects which are not available under the GNU General Public
299dnl License or the GNU Library General Public License but which still want
300dnl to provide support for the GNU gettext functionality.
301dnl Please note that the actual code of the GNU gettext library is covered
302dnl by the GNU Library General Public License, and the rest of the GNU
303dnl gettext package package is covered by the GNU General Public License.
304dnl They are *not* in the public domain.
305dnl
306dnl serial 10
307dnl
308dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
309dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
310dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
311dnl    depending on --{enable,disable}-{shared,static} and on the presence of
312dnl    AM-DISABLE-SHARED). Otherwise, a static library
313dnl    $(top_builddir)/intl/libintl.a will be created.
314dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
315dnl    implementations (in libc or libintl) without the ngettext() function
316dnl    will be ignored.
317dnl LIBDIR is used to find the intl libraries.  If empty,
318dnl    the value `$(top_builddir)/intl/' is used.
319dnl ENABLED is used to control the default for the related --enable-nls, since
320dnl    not all application developers want this feature by default, e.g., lynx.
321dnl
322dnl The result of the configuration is one of three cases:
323dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
324dnl    and used.
325dnl    Catalog format: GNU --> install in $(datadir)
326dnl    Catalog extension: .mo after installation, .gmo in source tree
327dnl 2) GNU gettext has been found in the system's C library.
328dnl    Catalog format: GNU --> install in $(datadir)
329dnl    Catalog extension: .mo after installation, .gmo in source tree
330dnl 3) No internationalization, always use English msgid.
331dnl    Catalog format: none
332dnl    Catalog extension: none
333dnl The use of .gmo is historical (it was needed to avoid overwriting the
334dnl GNU format catalogs when building on a platform with an X/Open gettext),
335dnl but we keep it in order not to force irrelevant filename changes on the
336dnl maintainers.
337dnl
338AC_DEFUN([AM_WITH_NLS],
339[AC_MSG_CHECKING([whether NLS is requested])
340  dnl Default is enabled NLS
341  ifelse([$4],,[
342  AC_ARG_ENABLE(nls,
343    [  --disable-nls           do not use Native Language Support],
344    USE_NLS=$enableval, USE_NLS=yes)],[
345  AC_ARG_ENABLE(nls,
346    [  --enable-nls            use Native Language Support],
347    USE_NLS=$enableval, USE_NLS=no)])
348  AC_MSG_RESULT($USE_NLS)
349  AC_SUBST(USE_NLS)
350
351  BUILD_INCLUDED_LIBINTL=no
352  USE_INCLUDED_LIBINTL=no
353  INTLLIBS=
354
355  dnl If we use NLS figure out what method
356  if test "$USE_NLS" = "yes"; then
357    AC_DEFINE(ENABLE_NLS, 1,
358      [Define to 1 if translation of program messages to the user's native language
359 is requested.])
360    AC_MSG_CHECKING([whether included gettext is requested])
361    AC_ARG_WITH(included-gettext,
362      [  --with-included-gettext use the GNU gettext library included here],
363      nls_cv_force_use_gnu_gettext=$withval,
364      nls_cv_force_use_gnu_gettext=no)
365    AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
366
367    nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
368    if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
369      dnl User does not insist on using GNU NLS library.  Figure out what
370      dnl to use.  If GNU gettext is available we use this.  Else we have
371      dnl to fall back to GNU NLS library.
372      CATOBJEXT=NONE
373
374      cf_save_LIBS_1="$LIBS"
375      CF_ADD_LIBS($LIBICONV)
376      AC_CACHE_CHECK([for libintl.h and gettext()], cf_cv_func_gettext,[
377        CF_FIND_LINKAGE(CF__INTL_HEAD,
378        CF__INTL_BODY,
379        intl,
380        cf_cv_func_gettext=yes,
381        cf_cv_func_gettext=no)
382      ])
383      LIBS="$cf_save_LIBS_1"
384
385      if test "$cf_cv_func_gettext" = yes ; then
386        AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have libintl.h])
387
388        dnl If an already present or preinstalled GNU gettext() is found,
389        dnl use it.  But if this macro is used in GNU gettext, and GNU
390        dnl gettext is already preinstalled in libintl, we update this
391        dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
392        if test "$PACKAGE" != gettext; then
393          AC_DEFINE(HAVE_GETTEXT, 1,
394              [Define if the GNU gettext() function is already present or preinstalled.])
395
396          CF_ADD_INCDIR($cf_cv_header_path_intl)
397
398          if test -n "$cf_cv_library_file_intl" ; then
399            dnl If iconv() is in a separate libiconv library, then anyone
400            dnl linking with libintl{.a,.so} also needs to link with
401            dnl libiconv.
402            INTLLIBS="$cf_cv_library_file_intl $LIBICONV"
403            CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
404          fi
405
406          gt_save_LIBS="$LIBS"
407          LIBS="$LIBS $INTLLIBS"
408          AC_CHECK_FUNCS(dcgettext)
409          LIBS="$gt_save_LIBS"
410
411          dnl Search for GNU msgfmt in the PATH.
412          AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
413              [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
414          AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
415
416          dnl Search for GNU xgettext in the PATH.
417          AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
418              [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
419
420          CATOBJEXT=.gmo
421        fi
422      fi
423
424      if test "$CATOBJEXT" = "NONE"; then
425        dnl GNU gettext is not found in the C library.
426        dnl Fall back on GNU gettext library.
427        nls_cv_use_gnu_gettext=yes
428      fi
429    fi
430
431    if test "$nls_cv_use_gnu_gettext" = "yes"; then
432      if test ! -d $srcdir/intl ; then
433        AC_MSG_ERROR(no NLS library is packaged with this application)
434      fi
435      dnl Mark actions used to generate GNU NLS library.
436      INTLOBJS="\$(GETTOBJS)"
437      AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
438          [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
439      AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
440      AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
441          [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
442      AC_SUBST(MSGFMT)
443      BUILD_INCLUDED_LIBINTL=yes
444      USE_INCLUDED_LIBINTL=yes
445      CATOBJEXT=.gmo
446      INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
447      LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
448    fi
449
450    dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
451    dnl Test whether we really found GNU msgfmt.
452    if test "$GMSGFMT" != ":"; then
453      dnl If it is no GNU msgfmt we define it as : so that the
454      dnl Makefiles still can work.
455      if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
456        : ;
457      else
458        AC_MSG_RESULT(
459          [found msgfmt program is not GNU msgfmt; ignore it])
460        GMSGFMT=":"
461      fi
462    fi
463
464    dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
465    dnl Test whether we really found GNU xgettext.
466    if test "$XGETTEXT" != ":"; then
467        dnl If it is no GNU xgettext we define it as : so that the
468        dnl Makefiles still can work.
469      if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
470        : ;
471      else
472        AC_MSG_RESULT(
473          [found xgettext program is not GNU xgettext; ignore it])
474        XGETTEXT=":"
475      fi
476    fi
477
478    dnl We need to process the po/ directory.
479    POSUB=po
480  fi
481
482  AC_OUTPUT_COMMANDS(
483   [for ac_file in $CONFIG_FILES; do
484
485      # Support "outfile[:infile[:infile...]]"
486      case "$ac_file" in
487        *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
488      esac
489
490      # PO directories have a Makefile.in generated from Makefile.inn.
491      case "$ac_file" in */[Mm]akefile.in)
492        # Adjust a relative srcdir.
493        ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
494        ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
495        ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
496        ac_base=`basename $ac_file .in`
497        # In autoconf-2.13 it is called $ac_given_srcdir.
498        # In autoconf-2.50 it is called $srcdir.
499        test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
500
501        case "$ac_given_srcdir" in
502          .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
503          /*) top_srcdir="$ac_given_srcdir" ;;
504          *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
505        esac
506
507        if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
508          rm -f "$ac_dir/POTFILES"
509          test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
510          sed -e "/^#/d" -e "/^[ 	]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
511          test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
512          sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
513        fi
514        ;;
515      esac
516    done])
517
518  dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
519  dnl to 'yes' because some of the testsuite requires it.
520  if test "$PACKAGE" = gettext; then
521    BUILD_INCLUDED_LIBINTL=yes
522  fi
523
524  dnl intl/plural.c is generated from intl/plural.y. It requires bison,
525  dnl because plural.y uses bison specific features. It requires at least
526  dnl bison-1.26 because earlier versions generate a plural.c that doesn't
527  dnl compile.
528  dnl bison is only needed for the maintainer (who touches plural.y). But in
529  dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
530  dnl the rule in general Makefile. Now, some people carelessly touch the
531  dnl files or have a broken "make" program, hence the plural.c rule will
532  dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
533  dnl present or too old.
534  if test "$nls_cv_use_gnu_gettext" = "yes"; then
535    AC_CHECK_PROGS([INTLBISON], [bison])
536    if test -z "$INTLBISON"; then
537      ac_verc_fail=yes
538    else
539      dnl Found it, now check the version.
540      AC_MSG_CHECKING([version of bison])
541changequote(<<,>>)dnl
542      ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
543      case $ac_prog_version in
544        '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
545        1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
546changequote([,])dnl
547           ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
548        *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
549      esac
550    AC_MSG_RESULT([$ac_prog_version])
551    fi
552    if test $ac_verc_fail = yes; then
553      INTLBISON=:
554    fi
555  fi
556
557  dnl These rules are solely for the distribution goal.  While doing this
558  dnl we only have to keep exactly one list of the available catalogs
559  dnl in configure.in.
560  for lang in $ALL_LINGUAS; do
561    GMOFILES="$GMOFILES $lang.gmo"
562    POFILES="$POFILES $lang.po"
563  done
564
565  dnl Make all variables we use known to autoconf.
566  AC_SUBST(BUILD_INCLUDED_LIBINTL)
567  AC_SUBST(USE_INCLUDED_LIBINTL)
568  AC_SUBST(CATALOGS)
569  AC_SUBST(CATOBJEXT)
570  AC_SUBST(GMOFILES)
571  AC_SUBST(INTLLIBS)
572  AC_SUBST(INTLOBJS)
573  AC_SUBST(POFILES)
574  AC_SUBST(POSUB)
575
576  dnl For backward compatibility. Some configure.ins may be using this.
577  nls_cv_header_intl=
578  nls_cv_header_libgt=
579
580  dnl For backward compatibility. Some Makefiles may be using this.
581  DATADIRNAME=share
582  AC_SUBST(DATADIRNAME)
583
584  dnl For backward compatibility. Some Makefiles may be using this.
585  INSTOBJEXT=.mo
586  AC_SUBST(INSTOBJEXT)
587
588  dnl For backward compatibility. Some Makefiles may be using this.
589  GENCAT=gencat
590  AC_SUBST(GENCAT)
591])dnl
592dnl ---------------------------------------------------------------------------
593dnl CF_ACVERSION_CHECK version: 4 updated: 2013/03/04 19:52:56
594dnl ------------------
595dnl Conditionally generate script according to whether we're using a given autoconf.
596dnl
597dnl $1 = version to compare against
598dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
599dnl $3 = code to use if AC_ACVERSION is older than $1.
600define([CF_ACVERSION_CHECK],
601[
602ifdef([AC_ACVERSION], ,[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])dnl
603ifdef([m4_version_compare],
604[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
605[CF_ACVERSION_COMPARE(
606AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
607AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
608dnl ---------------------------------------------------------------------------
609dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
610dnl --------------------
611dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
612dnl                      MAJOR2, MINOR2, TERNARY2,
613dnl                      PRINTABLE2, not FOUND, FOUND)
614define([CF_ACVERSION_COMPARE],
615[ifelse(builtin([eval], [$2 < $5]), 1,
616[ifelse([$8], , ,[$8])],
617[ifelse([$9], , ,[$9])])])dnl
618dnl ---------------------------------------------------------------------------
619dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
620dnl -------------
621dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
622dnl The second parameter if given makes this macro verbose.
623dnl
624dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
625dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
626dnl confused by the quotes (which require backslashes to keep them usable).
627AC_DEFUN([CF_ADD_CFLAGS],
628[
629cf_fix_cppflags=no
630cf_new_cflags=
631cf_new_cppflags=
632cf_new_extra_cppflags=
633
634for cf_add_cflags in $1
635do
636case $cf_fix_cppflags in
637no)
638	case $cf_add_cflags in #(vi
639	-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
640		case $cf_add_cflags in
641		-D*)
642			cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
643
644			test "${cf_add_cflags}" != "${cf_tst_cflags}" \
645				&& test -z "${cf_tst_cflags}" \
646				&& cf_fix_cppflags=yes
647
648			if test $cf_fix_cppflags = yes ; then
649				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
650				continue
651			elif test "${cf_tst_cflags}" = "\"'" ; then
652				cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
653				continue
654			fi
655			;;
656		esac
657		case "$CPPFLAGS" in
658		*$cf_add_cflags) #(vi
659			;;
660		*) #(vi
661			case $cf_add_cflags in #(vi
662			-D*)
663				cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
664				CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
665				;;
666			esac
667			cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
668			;;
669		esac
670		;;
671	*)
672		cf_new_cflags="$cf_new_cflags $cf_add_cflags"
673		;;
674	esac
675	;;
676yes)
677	cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
678
679	cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
680
681	test "${cf_add_cflags}" != "${cf_tst_cflags}" \
682		&& test -z "${cf_tst_cflags}" \
683		&& cf_fix_cppflags=no
684	;;
685esac
686done
687
688if test -n "$cf_new_cflags" ; then
689	ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
690	CFLAGS="$CFLAGS $cf_new_cflags"
691fi
692
693if test -n "$cf_new_cppflags" ; then
694	ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
695	CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
696fi
697
698if test -n "$cf_new_extra_cppflags" ; then
699	ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
700	EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
701fi
702
703AC_SUBST(EXTRA_CPPFLAGS)
704
705])dnl
706dnl ---------------------------------------------------------------------------
707dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
708dnl -------------
709dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
710dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
711dnl but old versions (and some misinstalled ones) need that.  To make things
712dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
713dnl the include-path).
714AC_DEFUN([CF_ADD_INCDIR],
715[
716if test -n "$1" ; then
717  for cf_add_incdir in $1
718  do
719	while test $cf_add_incdir != /usr/include
720	do
721	  if test -d $cf_add_incdir
722	  then
723		cf_have_incdir=no
724		if test -n "$CFLAGS$CPPFLAGS" ; then
725		  # a loop is needed to ensure we can add subdirs of existing dirs
726		  for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
727			if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
728			  cf_have_incdir=yes; break
729			fi
730		  done
731		fi
732
733		if test "$cf_have_incdir" = no ; then
734		  if test "$cf_add_incdir" = /usr/local/include ; then
735			if test "$GCC" = yes
736			then
737			  cf_save_CPPFLAGS=$CPPFLAGS
738			  CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
739			  AC_TRY_COMPILE([#include <stdio.h>],
740				  [printf("Hello")],
741				  [],
742				  [cf_have_incdir=yes])
743			  CPPFLAGS=$cf_save_CPPFLAGS
744			fi
745		  fi
746		fi
747
748		if test "$cf_have_incdir" = no ; then
749		  CF_VERBOSE(adding $cf_add_incdir to include-path)
750		  ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
751
752		  cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
753		  test "$cf_top_incdir" = "$cf_add_incdir" && break
754		  cf_add_incdir="$cf_top_incdir"
755		else
756		  break
757		fi
758	  fi
759	done
760  done
761fi
762])dnl
763dnl ---------------------------------------------------------------------------
764dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
765dnl ----------
766dnl Add a library, used to enforce consistency.
767dnl
768dnl $1 = library to add, without the "-l"
769dnl $2 = variable to update (default $LIBS)
770AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
771dnl ---------------------------------------------------------------------------
772dnl CF_ADD_LIBDIR version: 9 updated: 2010/05/26 16:44:57
773dnl -------------
774dnl	Adds to the library-path
775dnl
776dnl	Some machines have trouble with multiple -L options.
777dnl
778dnl $1 is the (list of) directory(s) to add
779dnl $2 is the optional name of the variable to update (default LDFLAGS)
780dnl
781AC_DEFUN([CF_ADD_LIBDIR],
782[
783if test -n "$1" ; then
784  for cf_add_libdir in $1
785  do
786    if test $cf_add_libdir = /usr/lib ; then
787      :
788    elif test -d $cf_add_libdir
789    then
790      cf_have_libdir=no
791      if test -n "$LDFLAGS$LIBS" ; then
792        # a loop is needed to ensure we can add subdirs of existing dirs
793        for cf_test_libdir in $LDFLAGS $LIBS ; do
794          if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
795            cf_have_libdir=yes; break
796          fi
797        done
798      fi
799      if test "$cf_have_libdir" = no ; then
800        CF_VERBOSE(adding $cf_add_libdir to library-path)
801        ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
802      fi
803    fi
804  done
805fi
806])dnl
807dnl ---------------------------------------------------------------------------
808dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
809dnl -----------
810dnl Add one or more libraries, used to enforce consistency.
811dnl
812dnl $1 = libraries to add, with the "-l", etc.
813dnl $2 = variable to update (default $LIBS)
814AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
815dnl ---------------------------------------------------------------------------
816dnl CF_ADD_OPTIONAL_PATH version: 1 updated: 2007/07/29 12:33:33
817dnl --------------------
818dnl Add an optional search-path to the compile/link variables.
819dnl See CF_WITH_PATH
820dnl
821dnl $1 = shell variable containing the result of --with-XXX=[DIR]
822dnl $2 = module to look for.
823AC_DEFUN([CF_ADD_OPTIONAL_PATH],[
824  case "$1" in #(vi
825  no) #(vi
826      ;;
827  yes) #(vi
828      ;;
829  *)
830      CF_ADD_SEARCHPATH([$1], [AC_MSG_ERROR(cannot find $2 under $1)])
831      ;;
832  esac
833])dnl
834dnl ---------------------------------------------------------------------------
835dnl CF_ADD_SEARCHPATH version: 5 updated: 2009/01/11 20:40:21
836dnl -----------------
837dnl Set $CPPFLAGS and $LDFLAGS with the directories given via the parameter.
838dnl They can be either the common root of include- and lib-directories, or the
839dnl lib-directory (to allow for things like lib64 directories).
840dnl See also CF_FIND_LINKAGE.
841dnl
842dnl $1 is the list of colon-separated directory names to search.
843dnl $2 is the action to take if a parameter does not yield a directory.
844AC_DEFUN([CF_ADD_SEARCHPATH],
845[
846AC_REQUIRE([CF_PATHSEP])
847for cf_searchpath in `echo "$1" | tr $PATH_SEPARATOR ' '`; do
848	if test -d $cf_searchpath/include; then
849		CF_ADD_INCDIR($cf_searchpath/include)
850	elif test -d $cf_searchpath/../include ; then
851		CF_ADD_INCDIR($cf_searchpath/../include)
852	ifelse([$2],,,[else
853$2])
854	fi
855	if test -d $cf_searchpath/lib; then
856		CF_ADD_LIBDIR($cf_searchpath/lib)
857	elif test -d $cf_searchpath ; then
858		CF_ADD_LIBDIR($cf_searchpath)
859	ifelse([$2],,,[else
860$2])
861	fi
862done
863])
864dnl ---------------------------------------------------------------------------
865dnl CF_ADD_SUBDIR_PATH version: 3 updated: 2010/07/03 20:58:12
866dnl ------------------
867dnl Append to a search-list for a nonstandard header/lib-file
868dnl	$1 = the variable to return as result
869dnl	$2 = the package name
870dnl	$3 = the subdirectory, e.g., bin, include or lib
871dnl $4 = the directory under which we will test for subdirectories
872dnl $5 = a directory that we do not want $4 to match
873AC_DEFUN([CF_ADD_SUBDIR_PATH],
874[
875test "$4" != "$5" && \
876test -d "$4" && \
877ifelse([$5],NONE,,[(test $5 = NONE || test "$4" != "$5") &&]) {
878	test -n "$verbose" && echo "	... testing for $3-directories under $4"
879	test -d $4/$3 &&          $1="[$]$1 $4/$3"
880	test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
881	test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
882	test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
883	test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
884}
885])dnl
886dnl ---------------------------------------------------------------------------
887dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
888dnl --------------
889dnl Allow user to disable a normally-on option.
890AC_DEFUN([CF_ARG_DISABLE],
891[CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
892dnl ---------------------------------------------------------------------------
893dnl CF_ARG_MSG_ENABLE version: 2 updated: 2000/07/29 19:32:03
894dnl -----------------
895dnl Verbose form of AC_ARG_ENABLE:
896dnl
897dnl Parameters:
898dnl $1 = message
899dnl $2 = option name
900dnl $3 = help-string
901dnl $4 = action to perform if option is enabled
902dnl $5 = action if perform if option is disabled
903dnl $6 = default option value (either 'yes' or 'no')
904AC_DEFUN([CF_ARG_MSG_ENABLE],[
905AC_MSG_CHECKING($1)
906AC_ARG_ENABLE($2,[$3],,enableval=ifelse($6,,no,$6))
907AC_MSG_RESULT($enableval)
908if test "$enableval" != no ; then
909ifelse($4,,[	:],$4)
910else
911ifelse($5,,[	:],$5)
912fi
913])dnl
914dnl ---------------------------------------------------------------------------
915dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
916dnl -------------
917dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
918dnl values.
919dnl
920dnl Parameters:
921dnl $1 = option name
922dnl $2 = help-string
923dnl $3 = action to perform if option is not default
924dnl $4 = action if perform if option is default
925dnl $5 = default option value (either 'yes' or 'no')
926AC_DEFUN([CF_ARG_OPTION],
927[AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
928  if test "$enableval" != "$5" ; then
929ifelse([$3],,[    :]dnl
930,[    $3]) ifelse([$4],,,[
931  else
932    $4])
933  fi],[enableval=$5 ifelse([$4],,,[
934  $4
935])dnl
936  ])])dnl
937dnl ---------------------------------------------------------------------------
938dnl CF_BUNDLED_INTL version: 17 updated: 2012/10/06 08:57:51
939dnl ---------------
940dnl Top-level macro for configuring an application with a bundled copy of
941dnl the intl and po directories for gettext.
942dnl
943dnl $1 specifies either Makefile or makefile, defaulting to the former.
944dnl $2 if nonempty sets the option to --enable-nls rather than to --disable-nls
945dnl
946dnl Sets variables which can be used to substitute in makefiles:
947dnl	GT_YES       - "#" comment unless building intl library, otherwise empty
948dnl	GT_NO        - "#" comment if building intl library, otherwise empty
949dnl	INTLDIR_MAKE - to make ./intl directory
950dnl	MSG_DIR_MAKE - to make ./po directory
951dnl	SUB_MAKEFILE - list of makefiles in ./intl, ./po directories
952dnl
953dnl Defines:
954dnl	HAVE_LIBGETTEXT_H if we're using ./intl
955dnl	NLS_TEXTDOMAIN
956dnl
957dnl Environment:
958dnl	ALL_LINGUAS if set, lists the root names of the ".po" files.
959dnl	CONFIG_H assumed to be "config.h"
960dnl	PACKAGE must be set, used as default for textdomain
961dnl	VERSION may be set, otherwise extract from "VERSION" file.
962dnl
963AC_DEFUN([CF_BUNDLED_INTL],[
964cf_makefile=ifelse($1,,Makefile,$1)
965
966dnl Set of available languages (based on source distribution).  Note that
967dnl setting $LINGUAS overrides $ALL_LINGUAS.  Some environments set $LINGUAS
968dnl rather than $LC_ALL
969test -z "$ALL_LINGUAS" && ALL_LINGUAS=`test -d $srcdir/po && cd $srcdir/po && echo *.po|sed -e 's/\.po//g' -e 's/*//'`
970
971# Allow override of "config.h" definition:
972: ${CONFIG_H:=config.h}
973AC_SUBST(CONFIG_H)
974
975if test -z "$PACKAGE" ; then
976	AC_MSG_ERROR([[CF_BUNDLED_INTL] used without setting [PACKAGE] variable])
977fi
978
979if test -z "$VERSION" ; then
980if test -f $srcdir/VERSION ; then
981	VERSION=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
982else
983	VERSION=unknown
984fi
985fi
986AC_SUBST(VERSION)
987
988AM_GNU_GETTEXT(,,,[$2])
989
990if test "$USE_NLS" = yes ; then
991	AC_ARG_WITH(textdomain,
992		[  --with-textdomain=PKG   NLS text-domain (default is package name)],
993		[NLS_TEXTDOMAIN=$withval],
994		[NLS_TEXTDOMAIN=$PACKAGE])
995	AC_DEFINE_UNQUOTED(NLS_TEXTDOMAIN,"$NLS_TEXTDOMAIN",[Define to the nls textdomain value])
996	AC_SUBST(NLS_TEXTDOMAIN)
997fi
998
999INTLDIR_MAKE=
1000MSG_DIR_MAKE=
1001SUB_MAKEFILE=
1002
1003dnl this updates SUB_MAKEFILE and MSG_DIR_MAKE:
1004CF_OUR_MESSAGES($1)
1005
1006if test "$USE_INCLUDED_LIBINTL" = yes ; then
1007        if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1008		:
1009	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1010		:
1011	else
1012		INTLDIR_MAKE="#"
1013	fi
1014	if test -z "$INTLDIR_MAKE"; then
1015		AC_DEFINE(HAVE_LIBGETTEXT_H,1,[Define to 1 if we have libgettext.h])
1016		for cf_makefile in \
1017			$srcdir/intl/Makefile.in \
1018			$srcdir/intl/makefile.in
1019		do
1020			if test -f "$cf_makefile" ; then
1021				SUB_MAKEFILE="$SUB_MAKEFILE `echo \"${cf_makefile}\"|sed -e 's,^'$srcdir/',,' -e 's/\.in$//'`:${cf_makefile}"
1022				break
1023			fi
1024		done
1025	fi
1026else
1027	INTLDIR_MAKE="#"
1028	if test "$USE_NLS" = yes ; then
1029		AC_CHECK_HEADERS(libintl.h)
1030	fi
1031fi
1032
1033if test -z "$INTLDIR_MAKE" ; then
1034	CPPFLAGS="$CPPFLAGS -I../intl"
1035fi
1036
1037dnl FIXME:  we use this in lynx (the alternative is a spurious dependency upon
1038dnl GNU make)
1039if test "$BUILD_INCLUDED_LIBINTL" = yes ; then
1040	GT_YES="#"
1041	GT_NO=
1042else
1043	GT_YES=
1044	GT_NO="#"
1045fi
1046
1047AC_SUBST(INTLDIR_MAKE)
1048AC_SUBST(MSG_DIR_MAKE)
1049AC_SUBST(GT_YES)
1050AC_SUBST(GT_NO)
1051
1052dnl FIXME:  the underlying AM_GNU_GETTEXT macro either needs some fixes or a
1053dnl little documentation.  It doesn't define anything so that we can ifdef our
1054dnl own code, except ENABLE_NLS, which is too vague to be of any use.
1055
1056if test "$USE_INCLUDED_LIBINTL" = yes ; then
1057	if test "$nls_cv_force_use_gnu_gettext" = yes ; then
1058		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
1059	elif test "$nls_cv_use_gnu_gettext" = yes ; then
1060		AC_DEFINE(HAVE_GETTEXT,1,[Define to 1 if we have gettext function])
1061	fi
1062	if test -n "$nls_cv_header_intl" ; then
1063		AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have header-file for libintl])
1064	fi
1065fi
1066])dnl
1067dnl ---------------------------------------------------------------------------
1068dnl CF_CC_ENV_FLAGS version: 1 updated: 2012/10/03 05:25:49
1069dnl ---------------
1070dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
1071dnl into CC.  This will not help with broken scripts that wrap the compiler with
1072dnl options, but eliminates a more common category of user confusion.
1073AC_DEFUN([CF_CC_ENV_FLAGS],
1074[
1075# This should have been defined by AC_PROG_CC
1076: ${CC:=cc}
1077
1078AC_MSG_CHECKING(\$CC variable)
1079case "$CC" in #(vi
1080*[[\ \	]]-[[IUD]]*)
1081	AC_MSG_RESULT(broken)
1082	AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
1083	# humor him...
1084	cf_flags=`echo "$CC" | sed -e 's/^[[^ 	]]*[[ 	]]//'`
1085	CC=`echo "$CC" | sed -e 's/[[ 	]].*//'`
1086	CF_ADD_CFLAGS($cf_flags)
1087	;;
1088*)
1089	AC_MSG_RESULT(ok)
1090	;;
1091esac
1092])dnl
1093dnl ---------------------------------------------------------------------------
1094dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
1095dnl --------------
1096dnl Check if we're accidentally using a cache from a different machine.
1097dnl Derive the system name, as a check for reusing the autoconf cache.
1098dnl
1099dnl If we've packaged config.guess and config.sub, run that (since it does a
1100dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1101dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1102dnl which is useful in cross-compiles.
1103dnl
1104dnl Note: we would use $ac_config_sub, but that is one of the places where
1105dnl autoconf 2.5x broke compatibility with autoconf 2.13
1106AC_DEFUN([CF_CHECK_CACHE],
1107[
1108if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
1109	ifelse([$1],,[AC_CANONICAL_HOST],[$1])
1110	system_name="$host_os"
1111else
1112	system_name="`(uname -s -r) 2>/dev/null`"
1113	if test -z "$system_name" ; then
1114		system_name="`(hostname) 2>/dev/null`"
1115	fi
1116fi
1117test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
1118AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1119
1120test -z "$system_name" && system_name="$cf_cv_system_name"
1121test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1122
1123if test ".$system_name" != ".$cf_cv_system_name" ; then
1124	AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
1125	AC_MSG_ERROR("Please remove config.cache and try again.")
1126fi
1127])dnl
1128dnl ---------------------------------------------------------------------------
1129dnl CF_CHECK_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
1130dnl ------------------------
1131dnl Show the version of libtool
1132dnl
1133dnl Save the version in a cache variable - this is not entirely a good thing,
1134dnl but the version string from libtool is very ugly, and for bug reports it
1135dnl might be useful to have the original string.
1136AC_DEFUN([CF_CHECK_LIBTOOL_VERSION],[
1137if test -n "$LIBTOOL" && test "$LIBTOOL" != none
1138then
1139	AC_MSG_CHECKING(version of $LIBTOOL)
1140	CF_LIBTOOL_VERSION
1141	AC_MSG_RESULT($cf_cv_libtool_version)
1142	if test -z "$cf_cv_libtool_version" ; then
1143		AC_MSG_ERROR(This is not GNU libtool)
1144	fi
1145else
1146	AC_MSG_ERROR(GNU libtool has not been found)
1147fi
1148])dnl
1149dnl ---------------------------------------------------------------------------
1150dnl CF_CLANG_COMPILER version: 1 updated: 2012/06/16 14:55:39
1151dnl -----------------
1152dnl Check if the given compiler is really clang.  clang's C driver defines
1153dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
1154dnl not ignore some gcc options.
1155dnl
1156dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1157dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1158dnl the wrappers for gcc and g++ warnings.
1159dnl
1160dnl $1 = GCC (default) or GXX
1161dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1162dnl $3 = CFLAGS (default) or CXXFLAGS
1163AC_DEFUN([CF_CLANG_COMPILER],[
1164ifelse([$2],,CLANG_COMPILER,[$2])=no
1165
1166if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1167	AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
1168	cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1169	ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
1170	AC_TRY_COMPILE([],[
1171#ifdef __clang__
1172#else
1173make an error
1174#endif
1175],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
1176cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
1177],[])
1178	ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1179	AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
1180fi
1181])
1182dnl ---------------------------------------------------------------------------
1183dnl CF_CURSES_CHTYPE version: 8 updated: 2012/10/06 08:57:51
1184dnl ----------------
1185dnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
1186AC_DEFUN([CF_CURSES_CHTYPE],
1187[
1188AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1189AC_CACHE_CHECK(for chtype typedef,cf_cv_chtype_decl,[
1190	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1191		[chtype foo],
1192		[cf_cv_chtype_decl=yes],
1193		[cf_cv_chtype_decl=no])])
1194if test $cf_cv_chtype_decl = yes ; then
1195	AC_DEFINE(HAVE_TYPE_CHTYPE,1,[Define to 1 if chtype is declared])
1196	AC_CACHE_CHECK(if chtype is scalar or struct,cf_cv_chtype_type,[
1197		AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1198			[chtype foo; long x = foo],
1199			[cf_cv_chtype_type=scalar],
1200			[cf_cv_chtype_type=struct])])
1201	if test $cf_cv_chtype_type = scalar ; then
1202		AC_DEFINE(TYPE_CHTYPE_IS_SCALAR,1,[Define to 1 if chtype is a scaler/integer])
1203	fi
1204fi
1205])dnl
1206dnl ---------------------------------------------------------------------------
1207dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
1208dnl ----------------
1209dnl Tie together the configure-script macros for curses.  It may be ncurses,
1210dnl but unless asked, we do not make a special search for ncurses.  However,
1211dnl still check for the ncurses version number, for use in other macros.
1212AC_DEFUN([CF_CURSES_CONFIG],
1213[
1214CF_CURSES_CPPFLAGS
1215CF_NCURSES_VERSION
1216CF_CURSES_LIBS
1217])dnl
1218dnl ---------------------------------------------------------------------------
1219dnl CF_CURSES_CPPFLAGS version: 11 updated: 2011/04/09 14:51:08
1220dnl ------------------
1221dnl Look for the curses headers.
1222AC_DEFUN([CF_CURSES_CPPFLAGS],[
1223
1224AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
1225cf_cv_curses_incdir=no
1226case $host_os in #(vi
1227hpux10.*) #(vi
1228	if test "x$cf_cv_screen" = "xcurses_colr"
1229	then
1230		test -d /usr/include/curses_colr && \
1231		cf_cv_curses_incdir="-I/usr/include/curses_colr"
1232	fi
1233	;;
1234sunos3*|sunos4*)
1235	if test "x$cf_cv_screen" = "xcurses_5lib"
1236	then
1237		test -d /usr/5lib && \
1238		test -d /usr/5include && \
1239		cf_cv_curses_incdir="-I/usr/5include"
1240	fi
1241	;;
1242esac
1243])
1244test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
1245
1246CF_CURSES_HEADER
1247CF_TERM_HEADER
1248])dnl
1249dnl ---------------------------------------------------------------------------
1250dnl CF_CURSES_FUNCS version: 17 updated: 2011/05/14 16:07:29
1251dnl ---------------
1252dnl Curses-functions are a little complicated, since a lot of them are macros.
1253AC_DEFUN([CF_CURSES_FUNCS],
1254[
1255AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1256AC_REQUIRE([CF_XOPEN_CURSES])
1257AC_REQUIRE([CF_CURSES_TERM_H])
1258AC_REQUIRE([CF_CURSES_UNCTRL_H])
1259for cf_func in $1
1260do
1261	CF_UPPER(cf_tr_func,$cf_func)
1262	AC_MSG_CHECKING(for ${cf_func})
1263	CF_MSG_LOG(${cf_func})
1264	AC_CACHE_VAL(cf_cv_func_$cf_func,[
1265		eval cf_result='$ac_cv_func_'$cf_func
1266		if test ".$cf_result" != ".no"; then
1267			AC_TRY_LINK(CF__CURSES_HEAD,
1268			[
1269#ifndef ${cf_func}
1270long foo = (long)(&${cf_func});
1271if (foo + 1234 > 5678)
1272	${cf_cv_main_return:-return}(foo);
1273#endif
1274			],
1275			[cf_result=yes],
1276			[cf_result=no])
1277		fi
1278		eval 'cf_cv_func_'$cf_func'=$cf_result'
1279	])
1280	# use the computed/retrieved cache-value:
1281	eval 'cf_result=$cf_cv_func_'$cf_func
1282	AC_MSG_RESULT($cf_result)
1283	if test $cf_result != no; then
1284		AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
1285	fi
1286done
1287])dnl
1288dnl ---------------------------------------------------------------------------
1289dnl CF_CURSES_HEADER version: 3 updated: 2011/05/01 19:47:45
1290dnl ----------------
1291dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1292dnl variations of ncurses' installs.
1293dnl
1294dnl $1 = ncurses when looking for ncurses, or is empty
1295AC_DEFUN([CF_CURSES_HEADER],[
1296AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
1297cf_cv_ncurses_header=none
1298for cf_header in ifelse($1,,,[ \
1299    $1/ncurses.h \
1300	$1/curses.h]) \
1301	ncurses.h \
1302	curses.h ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
1303do
1304AC_TRY_COMPILE([#include <${cf_header}>],
1305	[initscr(); tgoto("?", 0,0)],
1306	[cf_cv_ncurses_header=$cf_header; break],[])
1307done
1308])
1309
1310if test "$cf_cv_ncurses_header" = none ; then
1311	AC_MSG_ERROR(No curses header-files found)
1312fi
1313
1314# cheat, to get the right #define's for HAVE_NCURSES_H, etc.
1315AC_CHECK_HEADERS($cf_cv_ncurses_header)
1316])dnl
1317dnl ---------------------------------------------------------------------------
1318dnl CF_CURSES_LIBS version: 37 updated: 2013/02/09 17:33:50
1319dnl --------------
1320dnl Look for the curses libraries.  Older curses implementations may require
1321dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
1322AC_DEFUN([CF_CURSES_LIBS],[
1323
1324AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1325AC_MSG_CHECKING(if we have identified curses libraries)
1326AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1327    [initscr(); tgoto("?", 0,0)],
1328    cf_result=yes,
1329    cf_result=no)
1330AC_MSG_RESULT($cf_result)
1331
1332if test "$cf_result" = no ; then
1333case $host_os in #(vi
1334freebsd*) #(vi
1335    AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
1336    ;;
1337hpux10.*) #(vi
1338	# Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
1339	# next (1998), and xcurses "newer" (2000).  There is no header file for
1340	# Hcurses; the subdirectory curses_colr has the headers (curses.h and
1341	# term.h) for cur_colr
1342	if test "x$cf_cv_screen" = "xcurses_colr"
1343	then
1344		AC_CHECK_LIB(cur_colr,initscr,[
1345			CF_ADD_LIBS(-lcur_colr)
1346			ac_cv_func_initscr=yes
1347			],[
1348		AC_CHECK_LIB(Hcurses,initscr,[
1349			# HP's header uses __HP_CURSES, but user claims _HP_CURSES.
1350			CF_ADD_LIBS(-lHcurses)
1351			CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
1352			ac_cv_func_initscr=yes
1353			])])
1354	fi
1355	;;
1356linux*)
1357	case `arch 2>/dev/null` in
1358	x86_64)
1359		if test -d /lib64
1360		then
1361			CF_ADD_LIBDIR(/lib64)
1362		else
1363			CF_ADD_LIBDIR(/lib)
1364		fi
1365		;;
1366	*)
1367		CF_ADD_LIBDIR(/lib)
1368		;;
1369	esac
1370	;;
1371sunos3*|sunos4*)
1372	if test "x$cf_cv_screen" = "xcurses_5lib"
1373	then
1374		if test -d /usr/5lib ; then
1375			CF_ADD_LIBDIR(/usr/5lib)
1376			CF_ADD_LIBS(-lcurses -ltermcap)
1377		fi
1378    fi
1379    ac_cv_func_initscr=yes
1380    ;;
1381esac
1382
1383if test ".$ac_cv_func_initscr" != .yes ; then
1384	cf_save_LIBS="$LIBS"
1385
1386	if test ".${cf_cv_ncurses_version:-no}" != .no
1387	then
1388		cf_check_list="ncurses curses cursesX"
1389	else
1390		cf_check_list="cursesX curses ncurses"
1391	fi
1392
1393	# Check for library containing tgoto.  Do this before curses library
1394	# because it may be needed to link the test-case for initscr.
1395	if test "x$cf_term_lib" = x
1396	then
1397		AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
1398			for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
1399			do
1400				AC_CHECK_LIB($cf_term_lib,tgoto,[break])
1401			done
1402		])
1403	fi
1404
1405	# Check for library containing initscr
1406	test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
1407	if test "x$cf_curs_lib" = x
1408	then
1409		for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
1410		do
1411			AC_CHECK_LIB($cf_curs_lib,initscr,[break])
1412		done
1413	fi
1414	test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
1415
1416	LIBS="-l$cf_curs_lib $cf_save_LIBS"
1417	if test "$cf_term_lib" = unknown ; then
1418		AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
1419		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1420			[initscr()],
1421			[cf_result=yes],
1422			[cf_result=no])
1423		AC_MSG_RESULT($cf_result)
1424		test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
1425	elif test "$cf_curs_lib" = "$cf_term_lib" ; then
1426		:
1427	elif test "$cf_term_lib" != predefined ; then
1428		AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
1429		AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1430			[initscr(); tgoto((char *)0, 0, 0);],
1431			[cf_result=no],
1432			[
1433			LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
1434			AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1435				[initscr()],
1436				[cf_result=yes],
1437				[cf_result=error])
1438			])
1439		AC_MSG_RESULT($cf_result)
1440	fi
1441fi
1442fi
1443
1444])dnl
1445dnl ---------------------------------------------------------------------------
1446dnl CF_CURSES_TERM_H version: 10 updated: 2012/10/06 08:57:51
1447dnl ----------------
1448dnl SVr4 curses should have term.h as well (where it puts the definitions of
1449dnl the low-level interface).  This may not be true in old/broken implementations,
1450dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
1451dnl running with Solaris 2.5.1).
1452AC_DEFUN([CF_CURSES_TERM_H],
1453[
1454AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1455
1456AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
1457
1458# If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
1459# for <term.h> if we do not find the variant.
1460
1461cf_header_list="term.h ncurses/term.h ncursesw/term.h"
1462
1463case ${cf_cv_ncurses_header:-curses.h} in #(vi
1464*/*)
1465	cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
1466	cf_header_list="$cf_header_item $cf_header_list"
1467	;;
1468esac
1469
1470for cf_header in $cf_header_list
1471do
1472	AC_TRY_COMPILE([
1473#include <${cf_cv_ncurses_header:-curses.h}>
1474#include <${cf_header}>],
1475	[WINDOW *x],
1476	[cf_cv_term_header=$cf_header
1477	 break],
1478	[cf_cv_term_header=no])
1479done
1480
1481case $cf_cv_term_header in #(vi
1482no)
1483	# If curses is ncurses, some packagers still mess it up by trying to make
1484	# us use GNU termcap.  This handles the most common case.
1485	for cf_header in ncurses/term.h ncursesw/term.h
1486	do
1487		AC_TRY_COMPILE([
1488#include <${cf_cv_ncurses_header:-curses.h}>
1489#ifdef NCURSES_VERSION
1490#include <${cf_header}>
1491#else
1492make an error
1493#endif],
1494			[WINDOW *x],
1495			[cf_cv_term_header=$cf_header
1496			 break],
1497			[cf_cv_term_header=no])
1498	done
1499	;;
1500esac
1501])
1502
1503case $cf_cv_term_header in #(vi
1504term.h) #(vi
1505	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
1506	;;
1507ncurses/term.h) #(vi
1508	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
1509	;;
1510ncursesw/term.h)
1511	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
1512	;;
1513esac
1514])dnl
1515dnl ---------------------------------------------------------------------------
1516dnl CF_CURSES_UNCTRL_H version: 2 updated: 2012/10/06 08:57:51
1517dnl ------------------
1518dnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
1519dnl may put it in a subdirectory (along with ncurses' other headers, of
1520dnl course).  Packages which put the headers in inconsistent locations are
1521dnl broken).
1522AC_DEFUN([CF_CURSES_UNCTRL_H],
1523[
1524AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1525
1526AC_CACHE_CHECK(for unctrl.h, cf_cv_unctrl_header,[
1527
1528# If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
1529# for <unctrl.h> if we do not find the variant.
1530
1531cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
1532
1533case ${cf_cv_ncurses_header:-curses.h} in #(vi
1534*/*)
1535	cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
1536	cf_header_list="$cf_header_item $cf_header_list"
1537	;;
1538esac
1539
1540for cf_header in $cf_header_list
1541do
1542	AC_TRY_COMPILE([
1543#include <${cf_cv_ncurses_header:-curses.h}>
1544#include <${cf_header}>],
1545	[WINDOW *x],
1546	[cf_cv_unctrl_header=$cf_header
1547	 break],
1548	[cf_cv_unctrl_header=no])
1549done
1550
1551case $cf_cv_unctrl_header in #(vi
1552no)
1553	AC_MSG_WARN(unctrl.h header not found)
1554	;;
1555esac
1556])
1557
1558case $cf_cv_unctrl_header in #(vi
1559unctrl.h) #(vi
1560	AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
1561	;;
1562ncurses/unctrl.h) #(vi
1563	AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
1564	;;
1565ncursesw/unctrl.h)
1566	AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
1567	;;
1568esac
1569])dnl
1570dnl ---------------------------------------------------------------------------
1571dnl CF_CURSES_WACS_MAP version: 6 updated: 2012/10/06 08:57:51
1572dnl ------------------
1573dnl Check for likely values of wacs_map[].
1574AC_DEFUN([CF_CURSES_WACS_MAP],
1575[
1576AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
1577	cf_cv_curses_wacs_map=unknown
1578	for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
1579	do
1580	AC_TRY_LINK([
1581#ifndef _XOPEN_SOURCE_EXTENDED
1582#define _XOPEN_SOURCE_EXTENDED
1583#endif
1584#include <${cf_cv_ncurses_header:-curses.h}>],
1585	[void *foo = &($name['k'])],
1586	[cf_cv_curses_wacs_map=$name
1587	 break])
1588	done])
1589
1590test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map,[Define to name of (n)curses wide-character array])
1591])dnl
1592dnl ---------------------------------------------------------------------------
1593dnl CF_CURSES_WACS_SYMBOLS version: 2 updated: 2012/10/06 08:57:51
1594dnl ----------------------
1595dnl Do a check to see if the WACS_xxx constants are defined compatibly with
1596dnl X/Open Curses.  In particular, NetBSD's implementation of the WACS_xxx
1597dnl constants is broken since those constants do not point to cchar_t's.
1598AC_DEFUN([CF_CURSES_WACS_SYMBOLS],
1599[
1600AC_REQUIRE([CF_CURSES_WACS_MAP])
1601
1602AC_CACHE_CHECK(for wide alternate character constants, cf_cv_curses_wacs_symbols,[
1603cf_cv_curses_wacs_symbols=no
1604if test "$cf_cv_curses_wacs_map" != unknown
1605then
1606	AC_TRY_LINK([
1607#ifndef _XOPEN_SOURCE_EXTENDED
1608#define _XOPEN_SOURCE_EXTENDED
1609#endif
1610#include <${cf_cv_ncurses_header:-curses.h}>],
1611	[cchar_t *foo = WACS_PLUS;
1612	 $cf_cv_curses_wacs_map['k'] = *WACS_PLUS],
1613	[cf_cv_curses_wacs_symbols=yes])
1614else
1615	AC_TRY_LINK([
1616#ifndef _XOPEN_SOURCE_EXTENDED
1617#define _XOPEN_SOURCE_EXTENDED
1618#endif
1619#include <${cf_cv_ncurses_header:-curses.h}>],
1620	[cchar_t *foo = WACS_PLUS],
1621	[cf_cv_curses_wacs_symbols=yes])
1622fi
1623])
1624
1625test "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS,1,[Define to 1 if (n)curses supports wide-character WACS_ symbols])
1626])dnl
1627dnl ---------------------------------------------------------------------------
1628dnl CF_CURSES_WGETPARENT version: 3 updated: 2012/10/06 08:57:51
1629dnl --------------------
1630dnl Check for curses support for directly determining the parent of a given
1631dnl window.  Some implementations make this difficult, so we provide for
1632dnl defining an application-specific function that gives this functionality.
1633dnl
1634dnl $1 = name of function to use if the feature is missing
1635AC_DEFUN([CF_CURSES_WGETPARENT],[
1636CF_CURSES_FUNCS(wgetparent)
1637if test "x$cf_cv_func_wgetparent" != xyes
1638then
1639	AC_MSG_CHECKING(if WINDOW has _parent member)
1640	AC_TRY_COMPILE([#include <${cf_cv_ncurses_header:-curses.h}>],
1641		[WINDOW *p = stdscr->_parent],
1642		[cf_window__parent=yes],
1643		[cf_window__parent=no])
1644	AC_MSG_RESULT($cf_window__parent)
1645	if test "$cf_window__parent" = yes
1646	then
1647		AC_DEFINE(HAVE_WINDOW__PARENT,1,[Define to 1 if WINDOW struct has _parent member])
1648	fi
1649fi
1650])dnl
1651dnl ---------------------------------------------------------------------------
1652dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
1653dnl ----------
1654dnl "dirname" is not portable, so we fake it with a shell script.
1655AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
1656dnl ---------------------------------------------------------------------------
1657dnl CF_DISABLE_ECHO version: 12 updated: 2012/10/06 16:30:28
1658dnl ---------------
1659dnl You can always use "make -n" to see the actual options, but it's hard to
1660dnl pick out/analyze warning messages when the compile-line is long.
1661dnl
1662dnl Sets:
1663dnl	ECHO_LT - symbol to control if libtool is verbose
1664dnl	ECHO_LD - symbol to prefix "cc -o" lines
1665dnl	RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1666dnl	SHOW_CC - symbol to put before explicit "cc -c" lines
1667dnl	ECHO_CC - symbol to put before any "cc" line
1668dnl
1669AC_DEFUN([CF_DISABLE_ECHO],[
1670AC_MSG_CHECKING(if you want to see long compiling messages)
1671CF_ARG_DISABLE(echo,
1672	[  --disable-echo          do not display "compiling" commands],
1673	[
1674    ECHO_LT='--silent'
1675    ECHO_LD='@echo linking [$]@;'
1676    RULE_CC='@echo compiling [$]<'
1677    SHOW_CC='@echo compiling [$]@'
1678    ECHO_CC='@'
1679],[
1680    ECHO_LT=''
1681    ECHO_LD=''
1682    RULE_CC=''
1683    SHOW_CC=''
1684    ECHO_CC=''
1685])
1686AC_MSG_RESULT($enableval)
1687AC_SUBST(ECHO_LT)
1688AC_SUBST(ECHO_LD)
1689AC_SUBST(RULE_CC)
1690AC_SUBST(SHOW_CC)
1691AC_SUBST(ECHO_CC)
1692])dnl
1693dnl ---------------------------------------------------------------------------
1694dnl CF_DISABLE_LIBTOOL_VERSION version: 1 updated: 2010/05/15 15:45:59
1695dnl --------------------------
1696dnl Check if we should use the libtool 1.5 feature "-version-number" instead of
1697dnl the older "-version-info" feature.  The newer feature allows us to use
1698dnl version numbering on shared libraries which make them compatible with
1699dnl various systems.
1700AC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
1701[
1702AC_MSG_CHECKING(if libtool -version-number should be used)
1703CF_ARG_DISABLE(libtool-version,
1704	[  --disable-libtool-version  enable to use libtool's incompatible naming scheme],
1705	[cf_libtool_version=no],
1706	[cf_libtool_version=yes])
1707AC_MSG_RESULT($cf_libtool_version)
1708
1709if test "$cf_libtool_version" = yes ; then
1710	LIBTOOL_VERSION="-version-number"
1711else
1712	LIBTOOL_VERSION="-version-info"
1713fi
1714
1715AC_SUBST(LIBTOOL_VERSION)
1716])dnl
1717dnl ---------------------------------------------------------------------------
1718dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
1719dnl ---------------------
1720dnl The rpath-hack makes it simpler to build programs, particularly with the
1721dnl *BSD ports which may have essential libraries in unusual places.  But it
1722dnl can interfere with building an executable for the base system.  Use this
1723dnl option in that case.
1724AC_DEFUN([CF_DISABLE_RPATH_HACK],
1725[
1726AC_MSG_CHECKING(if rpath-hack should be disabled)
1727CF_ARG_DISABLE(rpath-hack,
1728	[  --disable-rpath-hack    don't add rpath options for additional libraries],
1729	[cf_disable_rpath_hack=yes],
1730	[cf_disable_rpath_hack=no])
1731AC_MSG_RESULT($cf_disable_rpath_hack)
1732if test "$cf_disable_rpath_hack" = no ; then
1733	CF_RPATH_HACK
1734fi
1735])
1736dnl ---------------------------------------------------------------------------
1737dnl CF_ENABLE_RPATH version: 2 updated: 2010/03/27 18:39:42
1738dnl ---------------
1739dnl Check if the rpath option should be used, setting cache variable
1740dnl cf_cv_enable_rpath if so.
1741AC_DEFUN([CF_ENABLE_RPATH],
1742[
1743AC_MSG_CHECKING(if rpath option should be used)
1744AC_ARG_ENABLE(rpath,
1745[  --enable-rpath          use rpath option when generating shared libraries],
1746[cf_cv_enable_rpath=$enableval],
1747[cf_cv_enable_rpath=no])
1748AC_MSG_RESULT($cf_cv_enable_rpath)
1749])dnl
1750dnl ---------------------------------------------------------------------------
1751dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
1752dnl ---------------
1753dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
1754dnl prefer a standard location, and use -L options only if we do not find the
1755dnl library in the standard library location(s).
1756dnl	$1 = library name
1757dnl	$2 = library class, usually the same as library name
1758dnl	$3 = includes
1759dnl	$4 = code fragment to compile/link
1760dnl	$5 = corresponding function-name
1761dnl	$6 = flag, nonnull if failure should not cause an error-exit
1762dnl
1763dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
1764dnl to use a -L option.
1765AC_DEFUN([CF_FIND_LIBRARY],
1766[
1767	eval 'cf_cv_have_lib_'$1'=no'
1768	cf_libdir=""
1769	AC_CHECK_FUNC($5,
1770		eval 'cf_cv_have_lib_'$1'=yes',[
1771		cf_save_LIBS="$LIBS"
1772		AC_MSG_CHECKING(for $5 in -l$1)
1773		LIBS="-l$1 $LIBS"
1774		AC_TRY_LINK([$3],[$4],
1775			[AC_MSG_RESULT(yes)
1776			 eval 'cf_cv_have_lib_'$1'=yes'
1777			],
1778			[AC_MSG_RESULT(no)
1779			CF_LIBRARY_PATH(cf_search,$2)
1780			for cf_libdir in $cf_search
1781			do
1782				AC_MSG_CHECKING(for -l$1 in $cf_libdir)
1783				LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
1784				AC_TRY_LINK([$3],[$4],
1785					[AC_MSG_RESULT(yes)
1786			 		 eval 'cf_cv_have_lib_'$1'=yes'
1787					 break],
1788					[AC_MSG_RESULT(no)
1789					 LIBS="$cf_save_LIBS"])
1790			done
1791			])
1792		])
1793eval 'cf_found_library=[$]cf_cv_have_lib_'$1
1794ifelse($6,,[
1795if test $cf_found_library = no ; then
1796	AC_MSG_ERROR(Cannot link $1 library)
1797fi
1798])
1799])dnl
1800dnl ---------------------------------------------------------------------------
1801dnl CF_FIND_LINKAGE version: 19 updated: 2010/05/29 16:31:02
1802dnl ---------------
1803dnl Find a library (specifically the linkage used in the code fragment),
1804dnl searching for it if it is not already in the library path.
1805dnl See also CF_ADD_SEARCHPATH.
1806dnl
1807dnl Parameters (4-on are optional):
1808dnl     $1 = headers for library entrypoint
1809dnl     $2 = code fragment for library entrypoint
1810dnl     $3 = the library name without the "-l" option or ".so" suffix.
1811dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1812dnl     $5 = action to perform if not successful
1813dnl     $6 = module name, if not the same as the library name
1814dnl     $7 = extra libraries
1815dnl
1816dnl Sets these variables:
1817dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1818dnl     $cf_cv_header_path_$3 - include-directory if needed
1819dnl     $cf_cv_library_path_$3 - library-directory if needed
1820dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1821AC_DEFUN([CF_FIND_LINKAGE],[
1822
1823# If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1824# will be set on completion of the AC_TRY_LINK below.
1825cf_cv_header_path_$3=
1826cf_cv_library_path_$3=
1827
1828CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1829
1830cf_save_LIBS="$LIBS"
1831
1832AC_TRY_LINK([$1],[$2],[
1833	cf_cv_find_linkage_$3=yes
1834	cf_cv_header_path_$3=/usr/include
1835	cf_cv_library_path_$3=/usr/lib
1836],[
1837
1838LIBS="-l$3 $7 $cf_save_LIBS"
1839
1840AC_TRY_LINK([$1],[$2],[
1841	cf_cv_find_linkage_$3=yes
1842	cf_cv_header_path_$3=/usr/include
1843	cf_cv_library_path_$3=/usr/lib
1844	cf_cv_library_file_$3="-l$3"
1845],[
1846	cf_cv_find_linkage_$3=no
1847	LIBS="$cf_save_LIBS"
1848
1849    CF_VERBOSE(find linkage for $3 library)
1850    CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1851
1852    cf_save_CPPFLAGS="$CPPFLAGS"
1853    cf_test_CPPFLAGS="$CPPFLAGS"
1854
1855    CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1856    for cf_cv_header_path_$3 in $cf_search
1857    do
1858      if test -d $cf_cv_header_path_$3 ; then
1859        CF_VERBOSE(... testing $cf_cv_header_path_$3)
1860        CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1861        AC_TRY_COMPILE([$1],[$2],[
1862            CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1863            cf_cv_find_linkage_$3=maybe
1864            cf_test_CPPFLAGS="$CPPFLAGS"
1865            break],[
1866            CPPFLAGS="$cf_save_CPPFLAGS"
1867            ])
1868      fi
1869    done
1870
1871    if test "$cf_cv_find_linkage_$3" = maybe ; then
1872
1873      CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1874
1875      cf_save_LIBS="$LIBS"
1876      cf_save_LDFLAGS="$LDFLAGS"
1877
1878      ifelse([$6],,,[
1879        CPPFLAGS="$cf_test_CPPFLAGS"
1880        LIBS="-l$3 $7 $cf_save_LIBS"
1881        AC_TRY_LINK([$1],[$2],[
1882            CF_VERBOSE(... found $3 library in system)
1883            cf_cv_find_linkage_$3=yes])
1884            CPPFLAGS="$cf_save_CPPFLAGS"
1885            LIBS="$cf_save_LIBS"
1886            ])
1887
1888      if test "$cf_cv_find_linkage_$3" != yes ; then
1889        CF_LIBRARY_PATH(cf_search,$3)
1890        for cf_cv_library_path_$3 in $cf_search
1891        do
1892          if test -d $cf_cv_library_path_$3 ; then
1893            CF_VERBOSE(... testing $cf_cv_library_path_$3)
1894            CPPFLAGS="$cf_test_CPPFLAGS"
1895            LIBS="-l$3 $7 $cf_save_LIBS"
1896            LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1897            AC_TRY_LINK([$1],[$2],[
1898                CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1899                cf_cv_find_linkage_$3=yes
1900                cf_cv_library_file_$3="-l$3"
1901                break],[
1902                CPPFLAGS="$cf_save_CPPFLAGS"
1903                LIBS="$cf_save_LIBS"
1904                LDFLAGS="$cf_save_LDFLAGS"
1905                ])
1906          fi
1907        done
1908        CPPFLAGS="$cf_save_CPPFLAGS"
1909        LDFLAGS="$cf_save_LDFLAGS"
1910      fi
1911
1912    else
1913      cf_cv_find_linkage_$3=no
1914    fi
1915    ],$7)
1916])
1917
1918LIBS="$cf_save_LIBS"
1919
1920if test "$cf_cv_find_linkage_$3" = yes ; then
1921ifelse([$4],,[
1922	CF_ADD_INCDIR($cf_cv_header_path_$3)
1923	CF_ADD_LIBDIR($cf_cv_library_path_$3)
1924	CF_ADD_LIB($3)
1925],[$4])
1926else
1927ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1928fi
1929])dnl
1930dnl ---------------------------------------------------------------------------
1931dnl CF_FORGET_TOOL version: 1 updated: 2013/04/06 18:03:09
1932dnl --------------
1933dnl Forget that we saw the given tool.
1934AC_DEFUN([CF_FORGET_TOOL],[
1935unset ac_cv_prog_ac_ct_$1
1936unset ac_ct_$1
1937unset $1
1938])dnl
1939dnl ---------------------------------------------------------------------------
1940dnl CF_FUNC_WAIT version: 3 updated: 2012/10/06 08:57:51
1941dnl ------------
1942dnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
1943dnl and/or 'waitpid()'.
1944dnl
1945dnl Note that we cannot simply grep for 'union wait' in the wait.h file,
1946dnl because some Posix systems turn this on only when a BSD variable is
1947dnl defined.
1948dnl
1949dnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
1950dnl would conflict with an attempt to test that header directly.
1951dnl
1952AC_DEFUN([CF_FUNC_WAIT],
1953[
1954AC_REQUIRE([CF_UNION_WAIT])
1955if test $cf_cv_type_unionwait = yes; then
1956
1957	AC_MSG_CHECKING(if union wait can be used as wait-arg)
1958	AC_CACHE_VAL(cf_cv_arg_union_wait,[
1959		AC_TRY_COMPILE($cf_wait_headers,
1960 			[union wait x; wait(&x)],
1961			[cf_cv_arg_union_wait=yes],
1962			[cf_cv_arg_union_wait=no])
1963		])
1964	AC_MSG_RESULT($cf_cv_arg_union_wait)
1965	test $cf_cv_arg_union_wait = yes && AC_DEFINE(WAIT_USES_UNION,1,[Define to 1 if wait() uses a union parameter])
1966
1967	AC_MSG_CHECKING(if union wait can be used as waitpid-arg)
1968	AC_CACHE_VAL(cf_cv_arg_union_waitpid,[
1969		AC_TRY_COMPILE($cf_wait_headers,
1970 			[union wait x; waitpid(0, &x, 0)],
1971			[cf_cv_arg_union_waitpid=yes],
1972			[cf_cv_arg_union_waitpid=no])
1973		])
1974	AC_MSG_RESULT($cf_cv_arg_union_waitpid)
1975	test $cf_cv_arg_union_waitpid = yes && AC_DEFINE(WAITPID_USES_UNION,1,[Define to 1 if waitpid() uses a union parameter])
1976
1977fi
1978])dnl
1979dnl ---------------------------------------------------------------------------
1980dnl CF_GCC_ATTRIBUTES version: 16 updated: 2012/10/02 20:55:03
1981dnl -----------------
1982dnl Test for availability of useful gcc __attribute__ directives to quiet
1983dnl compiler warnings.  Though useful, not all are supported -- and contrary
1984dnl to documentation, unrecognized directives cause older compilers to barf.
1985AC_DEFUN([CF_GCC_ATTRIBUTES],
1986[
1987if test "$GCC" = yes
1988then
1989cat > conftest.i <<EOF
1990#ifndef GCC_PRINTF
1991#define GCC_PRINTF 0
1992#endif
1993#ifndef GCC_SCANF
1994#define GCC_SCANF 0
1995#endif
1996#ifndef GCC_NORETURN
1997#define GCC_NORETURN /* nothing */
1998#endif
1999#ifndef GCC_UNUSED
2000#define GCC_UNUSED /* nothing */
2001#endif
2002EOF
2003if test "$GCC" = yes
2004then
2005	AC_CHECKING([for $CC __attribute__ directives])
2006cat > conftest.$ac_ext <<EOF
2007#line __oline__ "${as_me:-configure}"
2008#include "confdefs.h"
2009#include "conftest.h"
2010#include "conftest.i"
2011#if	GCC_PRINTF
2012#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
2013#else
2014#define GCC_PRINTFLIKE(fmt,var) /*nothing*/
2015#endif
2016#if	GCC_SCANF
2017#define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
2018#else
2019#define GCC_SCANFLIKE(fmt,var)  /*nothing*/
2020#endif
2021extern void wow(char *,...) GCC_SCANFLIKE(1,2);
2022extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
2023extern void foo(void) GCC_NORETURN;
2024int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
2025EOF
2026	cf_printf_attribute=no
2027	cf_scanf_attribute=no
2028	for cf_attribute in scanf printf unused noreturn
2029	do
2030		CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
2031		cf_directive="__attribute__(($cf_attribute))"
2032		echo "checking for $CC $cf_directive" 1>&AC_FD_CC
2033
2034		case $cf_attribute in #(vi
2035		printf) #(vi
2036			cf_printf_attribute=yes
2037			cat >conftest.h <<EOF
2038#define GCC_$cf_ATTRIBUTE 1
2039EOF
2040			;;
2041		scanf) #(vi
2042			cf_scanf_attribute=yes
2043			cat >conftest.h <<EOF
2044#define GCC_$cf_ATTRIBUTE 1
2045EOF
2046			;;
2047		*) #(vi
2048			cat >conftest.h <<EOF
2049#define GCC_$cf_ATTRIBUTE $cf_directive
2050EOF
2051			;;
2052		esac
2053
2054		if AC_TRY_EVAL(ac_compile); then
2055			test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
2056			cat conftest.h >>confdefs.h
2057			case $cf_attribute in #(vi
2058			noreturn) #(vi
2059				AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
2060				;;
2061			printf) #(vi
2062				cf_value='/* nothing */'
2063				if test "$cf_printf_attribute" != no ; then
2064					cf_value='__attribute__((format(printf,fmt,var)))'
2065					AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
2066				fi
2067				AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
2068				;;
2069			scanf) #(vi
2070				cf_value='/* nothing */'
2071				if test "$cf_scanf_attribute" != no ; then
2072					cf_value='__attribute__((format(scanf,fmt,var)))'
2073					AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
2074				fi
2075				AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
2076				;;
2077			unused) #(vi
2078				AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
2079				;;
2080			esac
2081		fi
2082	done
2083else
2084	fgrep define conftest.i >>confdefs.h
2085fi
2086rm -rf conftest*
2087fi
2088])dnl
2089dnl ---------------------------------------------------------------------------
2090dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
2091dnl --------------
2092dnl Find version of gcc
2093AC_DEFUN([CF_GCC_VERSION],[
2094AC_REQUIRE([AC_PROG_CC])
2095GCC_VERSION=none
2096if test "$GCC" = yes ; then
2097	AC_MSG_CHECKING(version of $CC)
2098	GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
2099	test -z "$GCC_VERSION" && GCC_VERSION=unknown
2100	AC_MSG_RESULT($GCC_VERSION)
2101fi
2102])dnl
2103dnl ---------------------------------------------------------------------------
2104dnl CF_GCC_WARNINGS version: 29 updated: 2012/06/16 14:55:39
2105dnl ---------------
2106dnl Check if the compiler supports useful warning options.  There's a few that
2107dnl we don't use, simply because they're too noisy:
2108dnl
2109dnl	-Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
2110dnl	-Wredundant-decls (system headers make this too noisy)
2111dnl	-Wtraditional (combines too many unrelated messages, only a few useful)
2112dnl	-Wwrite-strings (too noisy, but should review occasionally).  This
2113dnl		is enabled for ncurses using "--enable-const".
2114dnl	-pedantic
2115dnl
2116dnl Parameter:
2117dnl	$1 is an optional list of gcc warning flags that a particular
2118dnl		application might want to use, e.g., "no-unused" for
2119dnl		-Wno-unused
2120dnl Special:
2121dnl	If $with_ext_const is "yes", add a check for -Wwrite-strings
2122dnl
2123AC_DEFUN([CF_GCC_WARNINGS],
2124[
2125AC_REQUIRE([CF_GCC_VERSION])
2126CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
2127CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
2128
2129cat > conftest.$ac_ext <<EOF
2130#line __oline__ "${as_me:-configure}"
2131int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
2132EOF
2133
2134if test "$INTEL_COMPILER" = yes
2135then
2136# The "-wdXXX" options suppress warnings:
2137# remark #1419: external declaration in primary source file
2138# remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2139# remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
2140# remark #193: zero used for undefined preprocessing identifier
2141# remark #593: variable "curs_sb_left_arrow" was set but never used
2142# remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
2143# remark #869: parameter "tw" was never referenced
2144# remark #981: operands are evaluated in unspecified order
2145# warning #279: controlling expression is constant
2146
2147	AC_CHECKING([for $CC warning options])
2148	cf_save_CFLAGS="$CFLAGS"
2149	EXTRA_CFLAGS="-Wall"
2150	for cf_opt in \
2151		wd1419 \
2152		wd1683 \
2153		wd1684 \
2154		wd193 \
2155		wd593 \
2156		wd279 \
2157		wd810 \
2158		wd869 \
2159		wd981
2160	do
2161		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2162		if AC_TRY_EVAL(ac_compile); then
2163			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2164			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2165		fi
2166	done
2167	CFLAGS="$cf_save_CFLAGS"
2168
2169elif test "$GCC" = yes
2170then
2171	AC_CHECKING([for $CC warning options])
2172	cf_save_CFLAGS="$CFLAGS"
2173	EXTRA_CFLAGS=
2174	cf_warn_CONST=""
2175	test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
2176	for cf_opt in W Wall \
2177		Wbad-function-cast \
2178		Wcast-align \
2179		Wcast-qual \
2180		Winline \
2181		Wmissing-declarations \
2182		Wmissing-prototypes \
2183		Wnested-externs \
2184		Wpointer-arith \
2185		Wshadow \
2186		Wstrict-prototypes \
2187		Wundef $cf_warn_CONST $1
2188	do
2189		CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
2190		if AC_TRY_EVAL(ac_compile); then
2191			test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2192			case $cf_opt in #(vi
2193			Wcast-qual) #(vi
2194				CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
2195				;;
2196			Winline) #(vi
2197				case $GCC_VERSION in
2198				[[34]].*)
2199					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2200					continue;;
2201				esac
2202				;;
2203			Wpointer-arith) #(vi
2204				case $GCC_VERSION in
2205				[[12]].*)
2206					CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
2207					continue;;
2208				esac
2209				;;
2210			esac
2211			EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
2212		fi
2213	done
2214	CFLAGS="$cf_save_CFLAGS"
2215fi
2216rm -rf conftest*
2217
2218AC_SUBST(EXTRA_CFLAGS)
2219])dnl
2220dnl ---------------------------------------------------------------------------
2221dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
2222dnl -------------
2223dnl Check if we must define _GNU_SOURCE to get a reasonable value for
2224dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
2225dnl (or misfeature) of glibc2, which breaks portability of many applications,
2226dnl since it is interwoven with GNU extensions.
2227dnl
2228dnl Well, yes we could work around it...
2229AC_DEFUN([CF_GNU_SOURCE],
2230[
2231AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
2232AC_TRY_COMPILE([#include <sys/types.h>],[
2233#ifndef _XOPEN_SOURCE
2234make an error
2235#endif],
2236	[cf_cv_gnu_source=no],
2237	[cf_save="$CPPFLAGS"
2238	 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
2239	 AC_TRY_COMPILE([#include <sys/types.h>],[
2240#ifdef _XOPEN_SOURCE
2241make an error
2242#endif],
2243	[cf_cv_gnu_source=no],
2244	[cf_cv_gnu_source=yes])
2245	CPPFLAGS="$cf_save"
2246	])
2247])
2248test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
2249])dnl
2250dnl ---------------------------------------------------------------------------
2251dnl CF_HEADERS_SH version: 1 updated: 2007/07/04 15:37:05
2252dnl -------------
2253dnl Setup variables needed to construct headers-sh
2254AC_DEFUN([CF_HEADERS_SH],[
2255PACKAGE_PREFIX=$1
2256PACKAGE_CONFIG=$2
2257AC_SUBST(PACKAGE_PREFIX)
2258AC_SUBST(PACKAGE_CONFIG)
2259EXTRA_OUTPUT="$EXTRA_OUTPUT headers-sh:$srcdir/headers-sh.in"
2260])
2261dnl ---------------------------------------------------------------------------
2262dnl CF_HEADER_PATH version: 12 updated: 2010/05/05 05:22:40
2263dnl --------------
2264dnl Construct a search-list of directories for a nonstandard header-file
2265dnl
2266dnl Parameters
2267dnl	$1 = the variable to return as result
2268dnl	$2 = the package name
2269AC_DEFUN([CF_HEADER_PATH],
2270[
2271$1=
2272
2273# collect the current set of include-directories from compiler flags
2274cf_header_path_list=""
2275if test -n "${CFLAGS}${CPPFLAGS}" ; then
2276	for cf_header_path in $CPPFLAGS $CFLAGS
2277	do
2278		case $cf_header_path in #(vi
2279		-I*)
2280			cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
2281			CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
2282			cf_header_path_list="$cf_header_path_list [$]$1"
2283			;;
2284		esac
2285	done
2286fi
2287
2288# add the variations for the package we are looking for
2289CF_SUBDIR_PATH($1,$2,include)
2290
2291test "$includedir" != NONE && \
2292test "$includedir" != "/usr/include" && \
2293test -d "$includedir" && {
2294	test -d $includedir &&    $1="[$]$1 $includedir"
2295	test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
2296}
2297
2298test "$oldincludedir" != NONE && \
2299test "$oldincludedir" != "/usr/include" && \
2300test -d "$oldincludedir" && {
2301	test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
2302	test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
2303}
2304
2305$1="[$]$1 $cf_header_path_list"
2306])dnl
2307dnl ---------------------------------------------------------------------------
2308dnl CF_INTEL_COMPILER version: 5 updated: 2013/02/10 10:41:05
2309dnl -----------------
2310dnl Check if the given compiler is really the Intel compiler for Linux.  It
2311dnl tries to imitate gcc, but does not return an error when it finds a mismatch
2312dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2313dnl
2314dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2315dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2316dnl the wrappers for gcc and g++ warnings.
2317dnl
2318dnl $1 = GCC (default) or GXX
2319dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2320dnl $3 = CFLAGS (default) or CXXFLAGS
2321AC_DEFUN([CF_INTEL_COMPILER],[
2322AC_REQUIRE([AC_CANONICAL_HOST])
2323ifelse([$2],,INTEL_COMPILER,[$2])=no
2324
2325if test "$ifelse([$1],,[$1],GCC)" = yes ; then
2326	case $host_os in
2327	linux*|gnu*)
2328		AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
2329		cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
2330		ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
2331		AC_TRY_COMPILE([],[
2332#ifdef __INTEL_COMPILER
2333#else
2334make an error
2335#endif
2336],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
2337cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2338],[])
2339		ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
2340		AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
2341		;;
2342	esac
2343fi
2344])dnl
2345dnl ---------------------------------------------------------------------------
2346dnl CF_LARGEFILE version: 8 updated: 2012/10/06 08:57:51
2347dnl ------------
2348dnl Add checks for large file support.
2349AC_DEFUN([CF_LARGEFILE],[
2350ifdef([AC_FUNC_FSEEKO],[
2351    AC_SYS_LARGEFILE
2352    if test "$enable_largefile" != no ; then
2353	AC_FUNC_FSEEKO
2354
2355	# Normally we would collect these definitions in the config.h,
2356	# but (like _XOPEN_SOURCE), some environments rely on having these
2357	# defined before any of the system headers are included.  Another
2358	# case comes up with C++, e.g., on AIX the compiler compiles the
2359	# header files by themselves before looking at the body files it is
2360	# told to compile.  For ncurses, those header files do not include
2361	# the config.h
2362	test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
2363	test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
2364	test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
2365
2366	AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2367		AC_TRY_COMPILE([
2368#include <sys/types.h>
2369#include <dirent.h>
2370		],[
2371		/* if transitional largefile support is setup, this is true */
2372		extern struct dirent64 * readdir(DIR *);
2373		struct dirent64 *x = readdir((DIR *)0);
2374		struct dirent *y = readdir((DIR *)0);
2375		int z = x - y;
2376		],
2377		[cf_cv_struct_dirent64=yes],
2378		[cf_cv_struct_dirent64=no])
2379	])
2380	test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Define to 1 if we have struct dirent64])
2381    fi
2382])
2383])
2384dnl ---------------------------------------------------------------------------
2385dnl CF_LD_RPATH_OPT version: 5 updated: 2011/07/17 14:48:41
2386dnl ---------------
2387dnl For the given system and compiler, find the compiler flags to pass to the
2388dnl loader to use the "rpath" feature.
2389AC_DEFUN([CF_LD_RPATH_OPT],
2390[
2391AC_REQUIRE([CF_CHECK_CACHE])
2392
2393LD_RPATH_OPT=
2394AC_MSG_CHECKING(for an rpath option)
2395case $cf_cv_system_name in #(vi
2396irix*) #(vi
2397	if test "$GCC" = yes; then
2398		LD_RPATH_OPT="-Wl,-rpath,"
2399	else
2400		LD_RPATH_OPT="-rpath "
2401	fi
2402	;;
2403linux*|gnu*|k*bsd*-gnu) #(vi
2404	LD_RPATH_OPT="-Wl,-rpath,"
2405	;;
2406openbsd[[2-9]].*|mirbsd*) #(vi
2407	LD_RPATH_OPT="-Wl,-rpath,"
2408	;;
2409dragonfly*|freebsd*) #(vi
2410	LD_RPATH_OPT="-rpath "
2411	;;
2412netbsd*) #(vi
2413	LD_RPATH_OPT="-Wl,-rpath,"
2414	;;
2415osf*|mls+*) #(vi
2416	LD_RPATH_OPT="-rpath "
2417	;;
2418solaris2*) #(vi
2419	LD_RPATH_OPT="-R"
2420	;;
2421*)
2422	;;
2423esac
2424AC_MSG_RESULT($LD_RPATH_OPT)
2425
2426case "x$LD_RPATH_OPT" in #(vi
2427x-R*)
2428	AC_MSG_CHECKING(if we need a space after rpath option)
2429	cf_save_LIBS="$LIBS"
2430	CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
2431	AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2432	LIBS="$cf_save_LIBS"
2433	AC_MSG_RESULT($cf_rpath_space)
2434	test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
2435	;;
2436esac
2437])dnl
2438dnl ---------------------------------------------------------------------------
2439dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
2440dnl ---------------
2441dnl Construct a search-list of directories for a nonstandard library-file
2442dnl
2443dnl Parameters
2444dnl	$1 = the variable to return as result
2445dnl	$2 = the package name
2446AC_DEFUN([CF_LIBRARY_PATH],
2447[
2448$1=
2449cf_library_path_list=""
2450if test -n "${LDFLAGS}${LIBS}" ; then
2451	for cf_library_path in $LDFLAGS $LIBS
2452	do
2453		case $cf_library_path in #(vi
2454		-L*)
2455			cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
2456			CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
2457			cf_library_path_list="$cf_library_path_list [$]$1"
2458			;;
2459		esac
2460	done
2461fi
2462
2463CF_SUBDIR_PATH($1,$2,lib)
2464
2465$1="$cf_library_path_list [$]$1"
2466])dnl
2467dnl ---------------------------------------------------------------------------
2468dnl CF_LIBTOOL_VERSION version: 1 updated: 2013/04/06 18:03:09
2469dnl ------------------
2470AC_DEFUN([CF_LIBTOOL_VERSION],[
2471if test -n "$LIBTOOL" && test "$LIBTOOL" != none
2472then
2473	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.]].*//'`
2474else
2475	cf_cv_libtool_version=
2476fi
2477test -z "$cf_cv_libtool_version" && unset cf_cv_libtool_version
2478])dnl
2479dnl ---------------------------------------------------------------------------
2480dnl CF_LIB_PREFIX version: 9 updated: 2012/01/21 19:28:10
2481dnl -------------
2482dnl Compute the library-prefix for the given host system
2483dnl $1 = variable to set
2484define([CF_LIB_PREFIX],
2485[
2486	case $cf_cv_system_name in #(vi
2487	OS/2*|os2*) #(vi
2488        LIB_PREFIX=''
2489        ;;
2490	*)	LIB_PREFIX='lib'
2491        ;;
2492	esac
2493ifelse($1,,,[$1=$LIB_PREFIX])
2494	AC_SUBST(LIB_PREFIX)
2495])dnl
2496dnl ---------------------------------------------------------------------------
2497dnl CF_LIB_SUFFIX version: 22 updated: 2013/09/07 13:54:05
2498dnl -------------
2499dnl Compute the library file-suffix from the given model name
2500dnl $1 = model name
2501dnl $2 = variable to set (the nominal library suffix)
2502dnl $3 = dependency variable to set (actual filename)
2503dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
2504AC_DEFUN([CF_LIB_SUFFIX],
2505[
2506	case X$1 in #(vi
2507	Xlibtool) #(vi
2508		$2='.la'
2509		$3=[$]$2
2510		;;
2511	Xdebug) #(vi
2512		$2='_g.a'
2513		$3=[$]$2
2514		;;
2515	Xprofile) #(vi
2516		$2='_p.a'
2517		$3=[$]$2
2518		;;
2519	Xshared) #(vi
2520		case $cf_cv_system_name in
2521		aix[[5-7]]*) #(vi
2522			$2='.a'
2523			$3=[$]$2
2524			;;
2525		cygwin*|msys*|mingw*) #(vi
2526			$2='.dll'
2527			$3='.dll.a'
2528			;;
2529		darwin*) #(vi
2530			$2='.dylib'
2531			$3=[$]$2
2532			;;
2533		hpux*) #(vi
2534			case $target in
2535			ia64*) #(vi
2536				$2='.so'
2537				$3=[$]$2
2538				;;
2539			*) #(vi
2540				$2='.sl'
2541				$3=[$]$2
2542				;;
2543			esac
2544			;;
2545		*) #(vi
2546			$2='.so'
2547			$3=[$]$2
2548			;;
2549		esac
2550		;;
2551	*)
2552		$2='.a'
2553		$3=[$]$2
2554		;;
2555	esac
2556	test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
2557	test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
2558])dnl
2559dnl ---------------------------------------------------------------------------
2560dnl CF_MAKEFLAGS version: 14 updated: 2011/03/31 19:29:46
2561dnl ------------
2562dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
2563dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
2564dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
2565dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
2566AC_DEFUN([CF_MAKEFLAGS],
2567[
2568AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
2569	cf_cv_makeflags=''
2570	for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
2571	do
2572		cat >cf_makeflags.tmp <<CF_EOF
2573SHELL = /bin/sh
2574all :
2575	@ echo '.$cf_option'
2576CF_EOF
2577		cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | fgrep -v "ing directory" | sed -e 's,[[ 	]]*$,,'`
2578		case "$cf_result" in
2579		.*k)
2580			cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
2581			case "$cf_result" in
2582			.*CC=*)	cf_cv_makeflags=
2583				;;
2584			*)	cf_cv_makeflags=$cf_option
2585				;;
2586			esac
2587			break
2588			;;
2589		.-)	;;
2590		*)	echo "given option \"$cf_option\", no match \"$cf_result\""
2591			;;
2592		esac
2593	done
2594	rm -f cf_makeflags.tmp
2595])
2596
2597AC_SUBST(cf_cv_makeflags)
2598])dnl
2599dnl ---------------------------------------------------------------------------
2600dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
2601dnl ------------
2602dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
2603dnl a monocase filesystem.
2604AC_DEFUN([CF_MAKE_TAGS],[
2605AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
2606
2607AC_CHECK_PROGS(CTAGS, exctags ctags)
2608AC_CHECK_PROGS(ETAGS, exetags etags)
2609
2610AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
2611
2612if test "$cf_cv_mixedcase" = yes ; then
2613	AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
2614else
2615	MAKE_UPPER_TAGS=no
2616fi
2617
2618if test "$MAKE_UPPER_TAGS" = yes ; then
2619	MAKE_UPPER_TAGS=
2620else
2621	MAKE_UPPER_TAGS="#"
2622fi
2623
2624if test "$MAKE_LOWER_TAGS" = yes ; then
2625	MAKE_LOWER_TAGS=
2626else
2627	MAKE_LOWER_TAGS="#"
2628fi
2629
2630AC_SUBST(CTAGS)
2631AC_SUBST(ETAGS)
2632
2633AC_SUBST(MAKE_UPPER_TAGS)
2634AC_SUBST(MAKE_LOWER_TAGS)
2635])dnl
2636dnl ---------------------------------------------------------------------------
2637dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
2638dnl -----------
2639dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
2640dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
2641dnl AC_CHECK_LIB(m,sin), because that fails for C++.
2642AC_DEFUN([CF_MATH_LIB],
2643[
2644AC_CACHE_CHECK(if -lm needed for math functions,
2645	cf_cv_need_libm,[
2646	AC_TRY_LINK([
2647	#include <stdio.h>
2648	#include <math.h>
2649	],
2650	[double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
2651	[cf_cv_need_libm=no],
2652	[cf_cv_need_libm=yes])])
2653if test "$cf_cv_need_libm" = yes
2654then
2655ifelse($1,,[
2656	CF_ADD_LIB(m)
2657],[$1=-lm])
2658fi
2659])
2660dnl ---------------------------------------------------------------------------
2661dnl CF_MBSTATE_T version: 4 updated: 2012/10/06 08:57:51
2662dnl ------------
2663dnl Check if mbstate_t is declared, and if so, which header file.
2664dnl This (including wchar.h) is needed on Tru64 5.0 to declare mbstate_t,
2665dnl as well as include stdio.h to work around a misuse of varargs in wchar.h
2666AC_DEFUN([CF_MBSTATE_T],
2667[
2668AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_mbstate_t,[
2669AC_TRY_COMPILE([
2670#include <stdlib.h>
2671#include <stdio.h>
2672#ifdef HAVE_LIBUTF8_H
2673#include <libutf8.h>
2674#endif],
2675	[mbstate_t state],
2676	[cf_cv_mbstate_t=no],
2677	[AC_TRY_COMPILE([
2678#include <stdlib.h>
2679#include <stdio.h>
2680#include <wchar.h>
2681#ifdef HAVE_LIBUTF8_H
2682#include <libutf8.h>
2683#endif],
2684	[mbstate_t value],
2685	[cf_cv_mbstate_t=yes],
2686	[cf_cv_mbstate_t=unknown])])])
2687
2688if test "$cf_cv_mbstate_t" = yes ; then
2689	AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
2690fi
2691
2692if test "$cf_cv_mbstate_t" != unknown ; then
2693	AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if mbstate_t is declared])
2694fi
2695])dnl
2696dnl ---------------------------------------------------------------------------
2697dnl CF_MIXEDCASE_FILENAMES version: 5 updated: 2013/09/07 13:54:05
2698dnl ----------------------
2699dnl Check if the file-system supports mixed-case filenames.  If we're able to
2700dnl create a lowercase name and see it as uppercase, it doesn't support that.
2701AC_DEFUN([CF_MIXEDCASE_FILENAMES],
2702[
2703AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
2704if test "$cross_compiling" = yes ; then
2705	case $target_alias in #(vi
2706	*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw32*|*-uwin*) #(vi
2707		cf_cv_mixedcase=no
2708		;;
2709	*)
2710		cf_cv_mixedcase=yes
2711		;;
2712	esac
2713else
2714	rm -f conftest CONFTEST
2715	echo test >conftest
2716	if test -f CONFTEST ; then
2717		cf_cv_mixedcase=no
2718	else
2719		cf_cv_mixedcase=yes
2720	fi
2721	rm -f conftest CONFTEST
2722fi
2723])
2724test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
2725])dnl
2726dnl ---------------------------------------------------------------------------
2727dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
2728dnl ----------
2729dnl Write a debug message to config.log, along with the line number in the
2730dnl configure script.
2731AC_DEFUN([CF_MSG_LOG],[
2732echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
2733])dnl
2734dnl ---------------------------------------------------------------------------
2735dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
2736dnl -------------------
2737dnl Check if we can compile with ncurses' header file
2738dnl $1 is the cache variable to set
2739dnl $2 is the header-file to include
2740dnl $3 is the root name (ncurses or ncursesw)
2741AC_DEFUN([CF_NCURSES_CC_CHECK],[
2742	AC_TRY_COMPILE([
2743]ifelse($3,ncursesw,[
2744#define _XOPEN_SOURCE_EXTENDED
2745#undef  HAVE_LIBUTF8_H	/* in case we used CF_UTF8_LIB */
2746#define HAVE_LIBUTF8_H	/* to force ncurses' header file to use cchar_t */
2747])[
2748#include <$2>],[
2749#ifdef NCURSES_VERSION
2750]ifelse($3,ncursesw,[
2751#ifndef WACS_BSSB
2752	make an error
2753#endif
2754])[
2755printf("%s\n", NCURSES_VERSION);
2756#else
2757#ifdef __NCURSES_H
2758printf("old\n");
2759#else
2760	make an error
2761#endif
2762#endif
2763	]
2764	,[$1=$2]
2765	,[$1=no])
2766])dnl
2767dnl ---------------------------------------------------------------------------
2768dnl CF_NCURSES_CONFIG version: 10 updated: 2012/10/06 08:57:51
2769dnl -----------------
2770dnl Tie together the configure-script macros for ncurses.
2771dnl Prefer the "-config" script from ncurses 6.x, to simplify analysis.
2772dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
2773dnl
2774dnl $1 is the root library name (default: "ncurses")
2775AC_DEFUN([CF_NCURSES_CONFIG],
2776[
2777cf_ncuconfig_root=ifelse($1,,ncurses,$1)
2778
2779echo "Looking for ${cf_ncuconfig_root}-config"
2780
2781CF_ACVERSION_CHECK(2.52,
2782	[AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
2783	[AC_PATH_PROGS(NCURSES_CONFIG, ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
2784
2785if test "$NCURSES_CONFIG" != none ; then
2786
2787CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
2788CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
2789
2790# even with config script, some packages use no-override for curses.h
2791CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
2792
2793dnl like CF_NCURSES_CPPFLAGS
2794AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2795
2796dnl like CF_NCURSES_LIBS
2797CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
2798AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2799
2800dnl like CF_NCURSES_VERSION
2801cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
2802
2803else
2804
2805CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
2806CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2807
2808fi
2809])dnl
2810dnl ---------------------------------------------------------------------------
2811dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
2812dnl -------------------
2813dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2814dnl the CPPFLAGS variable so we can include its header.
2815dnl
2816dnl The header files may be installed as either curses.h, or ncurses.h (would
2817dnl be obsolete, except that some packagers prefer this name to distinguish it
2818dnl from a "native" curses implementation).  If not installed for overwrite,
2819dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2820dnl /usr/include/ncurses), but someone may have installed overwriting the
2821dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2822dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2823dnl the header.
2824dnl
2825dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2826dnl is already in the include-path, don't even bother with this, since we cannot
2827dnl easily determine which file it is.  In this case, it has to be <curses.h>.
2828dnl
2829dnl The optional parameter gives the root name of the library, in case it is
2830dnl not installed as the default curses library.  That is how the
2831dnl wide-character version of ncurses is installed.
2832AC_DEFUN([CF_NCURSES_CPPFLAGS],
2833[AC_REQUIRE([CF_WITH_CURSES_DIR])
2834
2835AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2836cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2837
2838test -n "$cf_cv_curses_dir" && \
2839test "$cf_cv_curses_dir" != "no" && { \
2840  CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2841}
2842
2843AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2844	cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2845	( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2846	for cf_header in $cf_header_list
2847	do
2848		CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2849		test "$cf_cv_ncurses_h" != no && break
2850	done
2851])
2852
2853CF_NCURSES_HEADER
2854CF_TERM_HEADER
2855
2856# some applications need this, but should check for NCURSES_VERSION
2857AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2858
2859CF_NCURSES_VERSION
2860])dnl
2861dnl ---------------------------------------------------------------------------
2862dnl CF_NCURSES_HEADER version: 3 updated: 2012/10/06 08:57:51
2863dnl -----------------
2864dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2865dnl variations of ncurses' installs.
2866dnl
2867dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2868AC_DEFUN([CF_NCURSES_HEADER],[
2869
2870if test "$cf_cv_ncurses_h" != no ; then
2871	cf_cv_ncurses_header=$cf_cv_ncurses_h
2872else
2873
2874AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2875	test -n "$verbose" && echo
2876	CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2877	test -n "$verbose" && echo search path $cf_search
2878	cf_save2_CPPFLAGS="$CPPFLAGS"
2879	for cf_incdir in $cf_search
2880	do
2881		CF_ADD_INCDIR($cf_incdir)
2882		for cf_header in \
2883			ncurses.h \
2884			curses.h
2885		do
2886			CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2887			if test "$cf_cv_ncurses_h2" != no ; then
2888				cf_cv_ncurses_h2=$cf_incdir/$cf_header
2889				test -n "$verbose" && echo $ac_n "	... found $ac_c" 1>&AC_FD_MSG
2890				break
2891			fi
2892			test -n "$verbose" && echo "	... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2893		done
2894		CPPFLAGS="$cf_save2_CPPFLAGS"
2895		test "$cf_cv_ncurses_h2" != no && break
2896	done
2897	test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2898	])
2899
2900	CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2901	cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2902	if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2903		cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2904	fi
2905	CF_ADD_INCDIR($cf_1st_incdir)
2906
2907fi
2908
2909# Set definitions to allow ifdef'ing for ncurses.h
2910
2911case $cf_cv_ncurses_header in # (vi
2912*ncurses.h)
2913	AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
2914	;;
2915esac
2916
2917case $cf_cv_ncurses_header in # (vi
2918ncurses/curses.h|ncurses/ncurses.h)
2919	AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
2920	;;
2921ncursesw/curses.h|ncursesw/ncurses.h)
2922	AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2923	;;
2924esac
2925
2926])dnl
2927dnl ---------------------------------------------------------------------------
2928dnl CF_NCURSES_LIBS version: 16 updated: 2010/11/20 17:02:38
2929dnl ---------------
2930dnl Look for the ncurses library.  This is a little complicated on Linux,
2931dnl because it may be linked with the gpm (general purpose mouse) library.
2932dnl Some distributions have gpm linked with (bsd) curses, which makes it
2933dnl unusable with ncurses.  However, we don't want to link with gpm unless
2934dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2935dnl and the linker will record a dependency.
2936dnl
2937dnl The optional parameter gives the root name of the library, in case it is
2938dnl not installed as the default curses library.  That is how the
2939dnl wide-character version of ncurses is installed.
2940AC_DEFUN([CF_NCURSES_LIBS],
2941[AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2942
2943cf_nculib_root=ifelse($1,,ncurses,$1)
2944	# This works, except for the special case where we find gpm, but
2945	# ncurses is in a nonstandard location via $LIBS, and we really want
2946	# to link gpm.
2947cf_ncurses_LIBS=""
2948cf_ncurses_SAVE="$LIBS"
2949AC_CHECK_LIB(gpm,Gpm_Open,
2950	[AC_CHECK_LIB(gpm,initscr,
2951		[LIBS="$cf_ncurses_SAVE"],
2952		[cf_ncurses_LIBS="-lgpm"])])
2953
2954case $host_os in #(vi
2955freebsd*)
2956	# This is only necessary if you are linking against an obsolete
2957	# version of ncurses (but it should do no harm, since it's static).
2958	if test "$cf_nculib_root" = ncurses ; then
2959		AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2960	fi
2961	;;
2962esac
2963
2964CF_ADD_LIBS($cf_ncurses_LIBS)
2965
2966if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2967then
2968	CF_ADD_LIBS(-l$cf_nculib_root)
2969else
2970	CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2971		[#include <${cf_cv_ncurses_header:-curses.h}>],
2972		[initscr()],
2973		initscr)
2974fi
2975
2976if test -n "$cf_ncurses_LIBS" ; then
2977	AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2978	cf_ncurses_SAVE="$LIBS"
2979	for p in $cf_ncurses_LIBS ; do
2980		q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2981		if test "$q" != "$LIBS" ; then
2982			LIBS="$q"
2983		fi
2984	done
2985	AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2986		[initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2987		[AC_MSG_RESULT(yes)],
2988		[AC_MSG_RESULT(no)
2989		 LIBS="$cf_ncurses_SAVE"])
2990fi
2991
2992CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2993AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2994])dnl
2995dnl ---------------------------------------------------------------------------
2996dnl CF_NCURSES_VERSION version: 14 updated: 2012/10/06 08:57:51
2997dnl ------------------
2998dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2999dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
3000dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
3001AC_DEFUN([CF_NCURSES_VERSION],
3002[
3003AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3004AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
3005	cf_cv_ncurses_version=no
3006	cf_tempfile=out$$
3007	rm -f $cf_tempfile
3008	AC_TRY_RUN([
3009#include <${cf_cv_ncurses_header:-curses.h}>
3010#include <stdio.h>
3011int main()
3012{
3013	FILE *fp = fopen("$cf_tempfile", "w");
3014#ifdef NCURSES_VERSION
3015# ifdef NCURSES_VERSION_PATCH
3016	fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
3017# else
3018	fprintf(fp, "%s\n", NCURSES_VERSION);
3019# endif
3020#else
3021# ifdef __NCURSES_H
3022	fprintf(fp, "old\n");
3023# else
3024	make an error
3025# endif
3026#endif
3027	${cf_cv_main_return:-return}(0);
3028}],[
3029	cf_cv_ncurses_version=`cat $cf_tempfile`],,[
3030
3031	# This will not work if the preprocessor splits the line after the
3032	# Autoconf token.  The 'unproto' program does that.
3033	cat > conftest.$ac_ext <<EOF
3034#include <${cf_cv_ncurses_header:-curses.h}>
3035#undef Autoconf
3036#ifdef NCURSES_VERSION
3037Autoconf NCURSES_VERSION
3038#else
3039#ifdef __NCURSES_H
3040Autoconf "old"
3041#endif
3042;
3043#endif
3044EOF
3045	cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
3046	AC_TRY_EVAL(cf_try)
3047	if test -f conftest.out ; then
3048		cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
3049		test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
3050		rm -f conftest.out
3051	fi
3052])
3053	rm -f $cf_tempfile
3054])
3055test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
3056])dnl
3057dnl ---------------------------------------------------------------------------
3058dnl CF_NO_LEAKS_OPTION version: 5 updated: 2012/10/02 20:55:03
3059dnl ------------------
3060dnl see CF_WITH_NO_LEAKS
3061AC_DEFUN([CF_NO_LEAKS_OPTION],[
3062AC_MSG_CHECKING(if you want to use $1 for testing)
3063AC_ARG_WITH($1,
3064	[$2],
3065	[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
3066	 $4
3067])
3068	: ${with_cflags:=-g}
3069	: ${with_no_leaks:=yes}
3070	 with_$1=yes],
3071	[with_$1=])
3072AC_MSG_RESULT(${with_$1:-no})
3073
3074case .$with_cflags in #(vi
3075.*-g*)
3076	case .$CFLAGS in #(vi
3077	.*-g*) #(vi
3078		;;
3079	*)
3080		CF_ADD_CFLAGS([-g])
3081		;;
3082	esac
3083	;;
3084esac
3085])dnl
3086dnl ---------------------------------------------------------------------------
3087dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
3088dnl ----------------
3089dnl Check if the given variable is a number.  If not, report an error.
3090dnl $1 is the variable
3091dnl $2 is the message
3092AC_DEFUN([CF_NUMBER_SYNTAX],[
3093if test -n "$1" ; then
3094  case $1 in #(vi
3095  [[0-9]]*) #(vi
3096 	;;
3097  *)
3098	AC_MSG_ERROR($2 is not a number: $1)
3099 	;;
3100  esac
3101else
3102  AC_MSG_ERROR($2 value is empty)
3103fi
3104])dnl
3105dnl ---------------------------------------------------------------------------
3106dnl CF_OUR_MESSAGES version: 7 updated: 2004/09/12 19:45:55
3107dnl ---------------
3108dnl Check if we use the messages included with this program
3109dnl
3110dnl $1 specifies either Makefile or makefile, defaulting to the former.
3111dnl
3112dnl Sets variables which can be used to substitute in makefiles:
3113dnl	MSG_DIR_MAKE - to make ./po directory
3114dnl	SUB_MAKEFILE - makefile in ./po directory (see CF_BUNDLED_INTL)
3115dnl
3116AC_DEFUN([CF_OUR_MESSAGES],
3117[
3118cf_makefile=ifelse($1,,Makefile,$1)
3119
3120use_our_messages=no
3121if test "$USE_NLS" = yes ; then
3122if test -d $srcdir/po ; then
3123AC_MSG_CHECKING(if we should use included message-library)
3124	AC_ARG_ENABLE(included-msgs,
3125	[  --disable-included-msgs use included messages, for i18n support],
3126	[use_our_messages=$enableval],
3127	[use_our_messages=yes])
3128fi
3129AC_MSG_RESULT($use_our_messages)
3130fi
3131
3132MSG_DIR_MAKE="#"
3133if test "$use_our_messages" = yes
3134then
3135	SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:$srcdir/po/$cf_makefile.inn"
3136	MSG_DIR_MAKE=
3137fi
3138
3139AC_SUBST(MSG_DIR_MAKE)
3140AC_SUBST(SUB_MAKEFILE)
3141])dnl
3142dnl ---------------------------------------------------------------------------
3143dnl CF_PATHSEP version: 6 updated: 2012/09/29 18:38:12
3144dnl ----------
3145dnl Provide a value for the $PATH and similar separator (or amend the value
3146dnl as provided in autoconf 2.5x).
3147AC_DEFUN([CF_PATHSEP],
3148[
3149	AC_MSG_CHECKING(for PATH separator)
3150	case $cf_cv_system_name in
3151	os2*)	PATH_SEPARATOR=';'  ;;
3152	*)	${PATH_SEPARATOR:=':'}  ;;
3153	esac
3154ifelse([$1],,,[$1=$PATH_SEPARATOR])
3155	AC_SUBST(PATH_SEPARATOR)
3156	AC_MSG_RESULT($PATH_SEPARATOR)
3157])dnl
3158dnl ---------------------------------------------------------------------------
3159dnl CF_PATH_SYNTAX version: 14 updated: 2012/06/19 20:58:54
3160dnl --------------
3161dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
3162dnl begins with one of the prefix/exec_prefix variables, and then again if the
3163dnl result begins with 'NONE'.  This is necessary to work around autoconf's
3164dnl delayed evaluation of those symbols.
3165AC_DEFUN([CF_PATH_SYNTAX],[
3166if test "x$prefix" != xNONE; then
3167  cf_path_syntax="$prefix"
3168else
3169  cf_path_syntax="$ac_default_prefix"
3170fi
3171
3172case ".[$]$1" in #(vi
3173.\[$]\(*\)*|.\'*\'*) #(vi
3174  ;;
3175..|./*|.\\*) #(vi
3176  ;;
3177.[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
3178  ;;
3179.\[$]{*prefix}*|.\[$]{*dir}*) #(vi
3180  eval $1="[$]$1"
3181  case ".[$]$1" in #(vi
3182  .NONE/*)
3183    $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
3184    ;;
3185  esac
3186  ;; #(vi
3187.no|.NONE/*)
3188  $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
3189  ;;
3190*)
3191  ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
3192  ;;
3193esac
3194])dnl
3195dnl ---------------------------------------------------------------------------
3196dnl CF_PKG_CONFIG version: 7 updated: 2011/04/29 04:53:22
3197dnl -------------
3198dnl Check for the package-config program, unless disabled by command-line.
3199AC_DEFUN([CF_PKG_CONFIG],
3200[
3201AC_MSG_CHECKING(if you want to use pkg-config)
3202AC_ARG_WITH(pkg-config,
3203	[  --with-pkg-config{=path} enable/disable use of pkg-config],
3204	[cf_pkg_config=$withval],
3205	[cf_pkg_config=yes])
3206AC_MSG_RESULT($cf_pkg_config)
3207
3208case $cf_pkg_config in #(vi
3209no) #(vi
3210	PKG_CONFIG=none
3211	;;
3212yes) #(vi
3213	CF_ACVERSION_CHECK(2.52,
3214		[AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
3215		[AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
3216	;;
3217*)
3218	PKG_CONFIG=$withval
3219	;;
3220esac
3221
3222test -z "$PKG_CONFIG" && PKG_CONFIG=none
3223if test "$PKG_CONFIG" != none ; then
3224	CF_PATH_SYNTAX(PKG_CONFIG)
3225fi
3226
3227AC_SUBST(PKG_CONFIG)
3228])dnl
3229dnl ---------------------------------------------------------------------------
3230dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
3231dnl -----------------
3232dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
3233dnl
3234dnl	POSIX.1-1990				_POSIX_SOURCE
3235dnl	POSIX.1-1990 and			_POSIX_SOURCE and
3236dnl		POSIX.2-1992 C-Language			_POSIX_C_SOURCE=2
3237dnl		Bindings Option
3238dnl	POSIX.1b-1993				_POSIX_C_SOURCE=199309L
3239dnl	POSIX.1c-1996				_POSIX_C_SOURCE=199506L
3240dnl	X/Open 2000				_POSIX_C_SOURCE=200112L
3241dnl
3242dnl Parameters:
3243dnl	$1 is the nominal value for _POSIX_C_SOURCE
3244AC_DEFUN([CF_POSIX_C_SOURCE],
3245[
3246cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
3247
3248cf_save_CFLAGS="$CFLAGS"
3249cf_save_CPPFLAGS="$CPPFLAGS"
3250
3251CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
3252CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
3253
3254AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
3255	CF_MSG_LOG(if the symbol is already defined go no further)
3256	AC_TRY_COMPILE([#include <sys/types.h>],[
3257#ifndef _POSIX_C_SOURCE
3258make an error
3259#endif],
3260	[cf_cv_posix_c_source=no],
3261	[cf_want_posix_source=no
3262	 case .$cf_POSIX_C_SOURCE in #(vi
3263	 .[[12]]??*) #(vi
3264		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3265		;;
3266	 .2) #(vi
3267		cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3268		cf_want_posix_source=yes
3269		;;
3270	 .*)
3271		cf_want_posix_source=yes
3272		;;
3273	 esac
3274	 if test "$cf_want_posix_source" = yes ; then
3275		AC_TRY_COMPILE([#include <sys/types.h>],[
3276#ifdef _POSIX_SOURCE
3277make an error
3278#endif],[],
3279		cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
3280	 fi
3281	 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
3282	 CFLAGS="$cf_trim_CFLAGS"
3283	 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
3284	 CF_MSG_LOG(if the second compile does not leave our definition intact error)
3285	 AC_TRY_COMPILE([#include <sys/types.h>],[
3286#ifndef _POSIX_C_SOURCE
3287make an error
3288#endif],,
3289	 [cf_cv_posix_c_source=no])
3290	 CFLAGS="$cf_save_CFLAGS"
3291	 CPPFLAGS="$cf_save_CPPFLAGS"
3292	])
3293])
3294
3295if test "$cf_cv_posix_c_source" != no ; then
3296	CFLAGS="$cf_trim_CFLAGS"
3297	CPPFLAGS="$cf_trim_CPPFLAGS"
3298	CF_ADD_CFLAGS($cf_cv_posix_c_source)
3299fi
3300
3301])dnl
3302dnl ---------------------------------------------------------------------------
3303dnl CF_PROG_CC version: 3 updated: 2012/10/06 15:31:55
3304dnl ----------
3305dnl standard check for CC, plus followup sanity checks
3306dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
3307AC_DEFUN([CF_PROG_CC],[
3308ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
3309CF_GCC_VERSION
3310CF_ACVERSION_CHECK(2.52,
3311	[AC_PROG_CC_STDC],
3312	[CF_ANSI_CC_REQD])
3313CF_CC_ENV_FLAGS 
3314])dnl
3315dnl ---------------------------------------------------------------------------
3316dnl CF_PROG_EXT version: 11 updated: 2012/10/06 08:57:51
3317dnl -----------
3318dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
3319AC_DEFUN([CF_PROG_EXT],
3320[
3321AC_REQUIRE([CF_CHECK_CACHE])
3322case $cf_cv_system_name in
3323os2*)
3324    CFLAGS="$CFLAGS -Zmt"
3325    CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
3326    CXXFLAGS="$CXXFLAGS -Zmt"
3327    # autoconf's macro sets -Zexe and suffix both, which conflict:w
3328    LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
3329    ac_cv_exeext=.exe
3330    ;;
3331esac
3332
3333AC_EXEEXT
3334AC_OBJEXT
3335
3336PROG_EXT="$EXEEXT"
3337AC_SUBST(PROG_EXT)
3338test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT",[Define to the program extension (normally blank)])
3339])dnl
3340dnl ---------------------------------------------------------------------------
3341dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
3342dnl ------------
3343AC_DEFUN([CF_PROG_LINT],
3344[
3345AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
3346AC_SUBST(LINT_OPTS)
3347])dnl
3348dnl ---------------------------------------------------------------------------
3349dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
3350dnl ------------
3351dnl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
3352dnl option if it is supported.
3353AC_DEFUN([CF_PROG_LN_S],[
3354AC_PROG_LN_S
3355AC_MSG_CHECKING(if $LN_S -f options work)
3356
3357rm -f conf$$.src conf$$dst
3358echo >conf$$.dst
3359echo first >conf$$.src
3360if $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
3361	cf_prog_ln_sf=yes
3362else
3363	cf_prog_ln_sf=no
3364fi
3365rm -f conf$$.dst conf$$src
3366AC_MSG_RESULT($cf_prog_ln_sf)
3367
3368test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
3369])dnl
3370dnl ---------------------------------------------------------------------------
3371dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
3372dnl ----------------
3373dnl Remove all -U and -D options that refer to the given symbol from a list
3374dnl of C compiler options.  This works around the problem that not all
3375dnl compilers process -U and -D options from left-to-right, so a -U option
3376dnl cannot be used to cancel the effect of a preceding -D option.
3377dnl
3378dnl $1 = target (which could be the same as the source variable)
3379dnl $2 = source (including '$')
3380dnl $3 = symbol to remove
3381define([CF_REMOVE_DEFINE],
3382[
3383$1=`echo "$2" | \
3384	sed	-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[[ 	]]/ /g' \
3385		-e 's/-[[UD]]'"$3"'\(=[[^ 	]]*\)\?[$]//g'`
3386])dnl
3387dnl ---------------------------------------------------------------------------
3388dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
3389dnl -------------
3390AC_DEFUN([CF_RPATH_HACK],
3391[
3392AC_REQUIRE([CF_LD_RPATH_OPT])
3393AC_MSG_CHECKING(for updated LDFLAGS)
3394if test -n "$LD_RPATH_OPT" ; then
3395	AC_MSG_RESULT(maybe)
3396
3397	AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
3398	cf_rpath_list="/usr/lib /lib"
3399	if test "$cf_ldd_prog" != no
3400	then
3401		cf_rpath_oops=
3402
3403AC_TRY_LINK([#include <stdio.h>],
3404		[printf("Hello");],
3405		[cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
3406		 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ 	]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
3407
3408		# If we passed the link-test, but get a "not found" on a given library,
3409		# this could be due to inept reconfiguration of gcc to make it only
3410		# partly honor /usr/local/lib (or whatever).  Sometimes this behavior
3411		# is intentional, e.g., installing gcc in /usr/bin and suppressing the
3412		# /usr/local libraries.
3413		if test -n "$cf_rpath_oops"
3414		then
3415			for cf_rpath_src in $cf_rpath_oops
3416			do
3417				for cf_rpath_dir in \
3418					/usr/local \
3419					/usr/pkg \
3420					/opt/sfw
3421				do
3422					if test -f $cf_rpath_dir/lib/$cf_rpath_src
3423					then
3424						CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
3425						LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
3426						break
3427					fi
3428				done
3429			done
3430		fi
3431	fi
3432
3433	CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
3434
3435	CF_RPATH_HACK_2(LDFLAGS)
3436	CF_RPATH_HACK_2(LIBS)
3437
3438	CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
3439else
3440	AC_MSG_RESULT(no)
3441fi
3442AC_SUBST(EXTRA_LDFLAGS)
3443])dnl
3444dnl ---------------------------------------------------------------------------
3445dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
3446dnl ---------------
3447dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
3448dnl EXTRA_LDFLAGS for each -L option found.
3449dnl
3450dnl $cf_rpath_list contains a list of directories to ignore.
3451dnl
3452dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
3453dnl      but LIBS often has misplaced -L options.
3454AC_DEFUN([CF_RPATH_HACK_2],
3455[
3456CF_VERBOSE(...checking $1 [$]$1)
3457
3458cf_rpath_dst=
3459for cf_rpath_src in [$]$1
3460do
3461	case $cf_rpath_src in #(vi
3462	-L*) #(vi
3463
3464		# check if this refers to a directory which we will ignore
3465		cf_rpath_skip=no
3466		if test -n "$cf_rpath_list"
3467		then
3468			for cf_rpath_item in $cf_rpath_list
3469			do
3470				if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
3471				then
3472					cf_rpath_skip=yes
3473					break
3474				fi
3475			done
3476		fi
3477
3478		if test "$cf_rpath_skip" = no
3479		then
3480			# transform the option
3481			if test "$LD_RPATH_OPT" = "-R " ; then
3482				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
3483			else
3484				cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
3485			fi
3486
3487			# if we have not already added this, add it now
3488			cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
3489			if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
3490			then
3491				CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
3492				EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
3493			fi
3494		fi
3495		;;
3496	esac
3497	cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
3498done
3499$1=$cf_rpath_dst
3500
3501CF_VERBOSE(...checked $1 [$]$1)
3502AC_SUBST(EXTRA_LDFLAGS)
3503])dnl
3504dnl ---------------------------------------------------------------------------
3505dnl CF_SHARED_OPTS version: 83 updated: 2013/09/21 17:34:53
3506dnl --------------
3507dnl --------------
3508dnl Attempt to determine the appropriate CC/LD options for creating a shared
3509dnl library.
3510dnl
3511dnl Notes:
3512dnl a) ${LOCAL_LDFLAGS} is used to link executables that will run within
3513dnl the build-tree, i.e., by making use of the libraries that are compiled in
3514dnl $rel_builddir/lib We avoid compiling-in a $rel_builddir/lib path for the
3515dnl shared library since that can lead to unexpected results at runtime.
3516dnl b) ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared
3517dnl libraries are compiled in ../../lib
3518dnl
3519dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
3520dnl to install symbolic links to the rel/abi versions of shared libraries.
3521dnl
3522dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
3523dnl version when making symbolic links.
3524dnl
3525dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
3526dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
3527dnl (ex: libncurses.so.<ver>).
3528dnl
3529dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
3530AC_DEFUN([CF_SHARED_OPTS],
3531[
3532	AC_REQUIRE([CF_LD_RPATH_OPT])
3533	RM_SHARED_OPTS=
3534	LOCAL_LDFLAGS=
3535	LOCAL_LDFLAGS2=
3536	LD_SHARED_OPTS=
3537	INSTALL_LIB="-m 644"
3538	: ${rel_builddir:=.}
3539
3540	cf_cv_do_symlinks=no
3541	cf_ld_rpath_opt=
3542	test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
3543
3544	AC_MSG_CHECKING(if release/abi version should be used for shared libs)
3545	AC_ARG_WITH(shlib-version,
3546	[  --with-shlib-version=X  Specify rel or abi version for shared libs],
3547	[test -z "$withval" && withval=auto
3548	case $withval in #(vi
3549	yes) #(vi
3550		cf_cv_shlib_version=auto
3551		;;
3552	rel|abi|auto|no) #(vi
3553		cf_cv_shlib_version=$withval
3554		;;
3555	*)
3556		AC_MSG_ERROR([option value must be one of: rel, abi, auto or no])
3557		;;
3558	esac
3559	],[cf_cv_shlib_version=auto])
3560	AC_MSG_RESULT($cf_cv_shlib_version)
3561
3562	cf_cv_rm_so_locs=no
3563	cf_try_cflags=
3564
3565	# Some less-capable ports of gcc support only -fpic
3566	CC_SHARED_OPTS=
3567	if test "$GCC" = yes
3568	then
3569		AC_MSG_CHECKING(which $CC option to use)
3570		cf_save_CFLAGS="$CFLAGS"
3571		for CC_SHARED_OPTS in -fPIC -fpic ''
3572		do
3573			CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
3574			AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
3575		done
3576		AC_MSG_RESULT($CC_SHARED_OPTS)
3577		CFLAGS="$cf_save_CFLAGS"
3578	fi
3579
3580	cf_cv_shlib_version_infix=no
3581
3582	case $cf_cv_system_name in #(vi
3583	aix4.[3-9]*|aix[[5-7]]*) #(vi
3584		if test "$GCC" = yes; then
3585			CC_SHARED_OPTS=
3586			MK_SHARED_LIB='${CC} -shared -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
3587		else
3588			# CC_SHARED_OPTS='-qpic=large -G'
3589			# perhaps "-bM:SRE -bnoentry -bexpall"
3590			MK_SHARED_LIB='${CC} -G -Wl,-brtl -Wl,-blibpath:${RPATH_LIST}:/usr/lib -o [$]@'
3591		fi
3592		;;
3593	beos*) #(vi
3594		MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
3595		;;
3596	cygwin*) #(vi
3597		CC_SHARED_OPTS=
3598		MK_SHARED_LIB='sh '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
3599		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
3600		cf_cv_shlib_version=cygdll
3601		cf_cv_shlib_version_infix=cygdll
3602		cat >mk_shared_lib.sh <<-CF_EOF
3603		#!/bin/sh
3604		SHARED_LIB=\[$]1
3605		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
3606		shift
3607		cat <<-EOF
3608		Linking shared library
3609		** SHARED_LIB \[$]SHARED_LIB
3610		** IMPORT_LIB \[$]IMPORT_LIB
3611EOF
3612		exec \[$]* -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
3613CF_EOF
3614		chmod +x mk_shared_lib.sh
3615		;;
3616	msys*) #(vi
3617		CC_SHARED_OPTS=
3618		MK_SHARED_LIB='sh '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
3619		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
3620		cf_cv_shlib_version=msysdll
3621		cf_cv_shlib_version_infix=msysdll
3622		cat >mk_shared_lib.sh <<-CF_EOF
3623		#!/bin/sh
3624		SHARED_LIB=\[$]1
3625		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/msys-/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
3626		shift
3627		cat <<-EOF
3628		Linking shared library
3629		** SHARED_LIB \[$]SHARED_LIB
3630		** IMPORT_LIB \[$]IMPORT_LIB
3631EOF
3632		exec \[$]* -shared -Wl,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
3633CF_EOF
3634		chmod +x mk_shared_lib.sh
3635		;;
3636	darwin*) #(vi
3637		cf_try_cflags="no-cpp-precomp"
3638		CC_SHARED_OPTS="-dynamic"
3639		MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
3640		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
3641		cf_cv_shlib_version_infix=yes
3642		AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
3643			cf_save_LDFLAGS=$LDFLAGS
3644			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
3645			AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
3646				LDFLAGS=$cf_save_LDFLAGS])
3647		if test $cf_cv_ldflags_search_paths_first = yes; then
3648			LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
3649		fi
3650		;;
3651	hpux[[7-8]]*) #(vi
3652		# HP-UX 8.07 ld lacks "+b" option used for libdir search-list 
3653		if test "$GCC" != yes; then
3654			CC_SHARED_OPTS='+Z'
3655		fi
3656		MK_SHARED_LIB='${LD} -b -o $[@]'
3657		INSTALL_LIB="-m 555"
3658		;;
3659	hpux*) #(vi
3660		# (tested with gcc 2.7.2 -- I don't have c89)
3661		if test "$GCC" = yes; then
3662			LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
3663		else
3664			CC_SHARED_OPTS='+Z'
3665			LD_SHARED_OPTS='-Wl,+b,${libdir}'
3666		fi
3667		MK_SHARED_LIB='${LD} +b ${libdir} -b -o $[@]'
3668		# HP-UX shared libraries must be executable, and should be
3669		# readonly to exploit a quirk in the memory manager.
3670		INSTALL_LIB="-m 555"
3671		;;
3672	interix*)
3673		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3674		if test "$cf_cv_shlib_version" = rel; then
3675			cf_shared_soname='`basename $@ .${REL_VERSION}`.${ABI_VERSION}'
3676		else
3677			cf_shared_soname='`basename $@`'
3678		fi
3679		CC_SHARED_OPTS=
3680		MK_SHARED_LIB='${CC} -shared -Wl,-rpath,${RPATH_LIST} -Wl,-h,'$cf_shared_soname' -o $@'
3681		;;
3682	irix*) #(vi
3683		if test "$cf_cv_enable_rpath" = yes ; then
3684			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3685		fi
3686		# tested with IRIX 5.2 and 'cc'.
3687		if test "$GCC" != yes; then
3688			CC_SHARED_OPTS='-KPIC'
3689			MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
3690		else
3691			MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
3692		fi
3693		cf_cv_rm_so_locs=yes
3694		;;
3695	linux*|gnu*|k*bsd*-gnu) #(vi
3696		if test "$DFT_LWR_MODEL" = "shared" ; then
3697			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
3698			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3699		fi
3700		if test "$cf_cv_enable_rpath" = yes ; then
3701			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3702		fi
3703		CF_SHARED_SONAME
3704		MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
3705		;;
3706	mingw*) #(vi
3707		cf_cv_shlib_version=mingw
3708		cf_cv_shlib_version_infix=mingw
3709		if test "$DFT_LWR_MODEL" = "shared" ; then
3710			LOCAL_LDFLAGS="-Wl,--enable-auto-import"
3711			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3712			EXTRA_LDFLAGS="-Wl,--enable-auto-import $EXTRA_LDFLAGS"
3713		fi
3714		CC_SHARED_OPTS=
3715		MK_SHARED_LIB='sh '$rel_builddir'/mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
3716		RM_SHARED_OPTS="$RM_SHARED_OPTS $rel_builddir/mk_shared_lib.sh *.dll.a"
3717		cat >mk_shared_lib.sh <<-CF_EOF
3718		#!/bin/sh
3719		SHARED_LIB=\[$]1
3720		IMPORT_LIB=\`echo "\[$]1" | sed -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
3721		shift
3722		cat <<-EOF
3723		Linking shared library
3724		** SHARED_LIB \[$]SHARED_LIB
3725		** IMPORT_LIB \[$]IMPORT_LIB
3726EOF
3727		exec \[$]* -shared -Wl,--enable-auto-import,--out-implib=\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o \[$]{SHARED_LIB}
3728CF_EOF
3729		chmod +x mk_shared_lib.sh
3730		;;
3731	openbsd[[2-9]].*|mirbsd*) #(vi
3732		if test "$DFT_LWR_MODEL" = "shared" ; then
3733			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
3734			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3735		fi
3736		if test "$cf_cv_enable_rpath" = yes ; then
3737			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3738		fi
3739		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3740		CF_SHARED_SONAME
3741		MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
3742		;;
3743	nto-qnx*|openbsd*|freebsd[[12]].*) #(vi
3744		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3745		MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
3746		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3747		;;
3748	dragonfly*|freebsd*) #(vi
3749		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3750		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
3751			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
3752			LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${RPATH_LIST} $LOCAL_LDFLAGS"
3753			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3754		fi
3755		CF_SHARED_SONAME
3756		MK_SHARED_LIB='${LD} -shared -Bshareable -soname=`basename $[@]` -o $[@]'
3757		;;
3758	netbsd*) #(vi
3759		CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3760		if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
3761			LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
3762			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3763			EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${RPATH_LIST} $EXTRA_LDFLAGS"
3764			if test "$cf_cv_shlib_version" = auto; then
3765			if test -f /usr/libexec/ld.elf_so; then
3766				cf_cv_shlib_version=abi
3767			else
3768				cf_cv_shlib_version=rel
3769			fi
3770			fi
3771			CF_SHARED_SONAME
3772			MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
3773		else
3774			MK_SHARED_LIB='${CC} -Wl,-shared -Wl,-Bshareable -o $[@]'
3775		fi
3776		;;
3777	osf*|mls+*) #(vi
3778		# tested with OSF/1 V3.2 and 'cc'
3779		# tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
3780		# link with shared libs).
3781		MK_SHARED_LIB='${LD} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
3782		case $host_os in #(vi
3783		osf4*)
3784			MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
3785			;;
3786		esac
3787		MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
3788		if test "$DFT_LWR_MODEL" = "shared" ; then
3789			LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
3790			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3791		fi
3792		cf_cv_rm_so_locs=yes
3793		;;
3794	sco3.2v5*)  # (also uw2* and UW7: hops 13-Apr-98
3795		# tested with osr5.0.5
3796		if test "$GCC" != yes; then
3797			CC_SHARED_OPTS='-belf -KPIC'
3798		fi
3799		MK_SHARED_LIB='${LD} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
3800		if test "$cf_cv_enable_rpath" = yes ; then
3801			# only way is to set LD_RUN_PATH but no switch for it
3802			RUN_PATH=$libdir
3803		fi
3804		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3805		LINK_PROGS='LD_RUN_PATH=${libdir}'
3806		LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
3807		;;
3808	sunos4*) #(vi
3809		# tested with SunOS 4.1.1 and gcc 2.7.0
3810		if test "$GCC" != yes; then
3811			CC_SHARED_OPTS='-KPIC'
3812		fi
3813		MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
3814		test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3815		;;
3816	solaris2*) #(vi
3817		# tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
3818		# tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
3819		if test "$DFT_LWR_MODEL" = "shared" ; then
3820			LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
3821			LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3822		fi
3823		if test "$cf_cv_enable_rpath" = yes ; then
3824			EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
3825		fi
3826		CF_SHARED_SONAME
3827		if test "$GCC" != yes; then
3828			cf_save_CFLAGS="$CFLAGS"
3829			for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
3830			do
3831				CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
3832				AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\n");],[break])
3833			done
3834			CFLAGS="$cf_save_CFLAGS"
3835			CC_SHARED_OPTS=$cf_shared_opts
3836			MK_SHARED_LIB='${CC} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
3837		else
3838			MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
3839		fi
3840		;;
3841	sysv5uw7*|unix_sv*) #(vi
3842		# tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
3843		if test "$GCC" != yes; then
3844			CC_SHARED_OPTS='-KPIC'
3845		fi
3846		MK_SHARED_LIB='${LD} -d y -G -o [$]@'
3847		;;
3848	*)
3849		CC_SHARED_OPTS='unknown'
3850		MK_SHARED_LIB='echo unknown'
3851		;;
3852	esac
3853
3854	# This works if the last tokens in $MK_SHARED_LIB are the -o target.
3855	case "$cf_cv_shlib_version" in #(vi
3856	rel|abi)
3857		case "$MK_SHARED_LIB" in #(vi
3858		*'-o $[@]') #(vi
3859			test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
3860			;;
3861		*)
3862			AC_MSG_WARN(ignored --with-shlib-version)
3863			;;
3864		esac
3865		;;
3866	esac
3867
3868	if test -n "$cf_try_cflags"
3869	then
3870cat > conftest.$ac_ext <<EOF
3871#line __oline__ "${as_me:-configure}"
3872#include <stdio.h>
3873int main(int argc, char *argv[[]])
3874{
3875	printf("hello\n");
3876	return (argv[[argc-1]] == 0) ;
3877}
3878EOF
3879		cf_save_CFLAGS="$CFLAGS"
3880		for cf_opt in $cf_try_cflags
3881		do
3882			CFLAGS="$cf_save_CFLAGS -$cf_opt"
3883			AC_MSG_CHECKING(if CFLAGS option -$cf_opt works)
3884			if AC_TRY_EVAL(ac_compile); then
3885				AC_MSG_RESULT(yes)
3886				cf_save_CFLAGS="$CFLAGS"
3887			else
3888				AC_MSG_RESULT(no)
3889			fi
3890		done
3891		CFLAGS="$cf_save_CFLAGS"
3892	fi
3893
3894
3895	# RPATH_LIST is a colon-separated list of directories
3896	test -n "$cf_ld_rpath_opt" && MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${RPATH_LIST}"
3897	test -z "$RPATH_LIST" && RPATH_LIST="\${libdir}"
3898
3899	test $cf_cv_rm_so_locs = yes && RM_SHARED_OPTS="$RM_SHARED_OPTS so_locations"
3900
3901	CF_VERBOSE(CC_SHARED_OPTS: $CC_SHARED_OPTS)
3902	CF_VERBOSE(MK_SHARED_LIB:  $MK_SHARED_LIB)
3903
3904	AC_SUBST(CC_SHARED_OPTS)
3905	AC_SUBST(LD_RPATH_OPT)
3906	AC_SUBST(LD_SHARED_OPTS)
3907	AC_SUBST(MK_SHARED_LIB)
3908	AC_SUBST(RM_SHARED_OPTS)
3909
3910	AC_SUBST(LINK_PROGS)
3911	AC_SUBST(LINK_TESTS)
3912
3913	AC_SUBST(EXTRA_LDFLAGS)
3914	AC_SUBST(LOCAL_LDFLAGS)
3915	AC_SUBST(LOCAL_LDFLAGS2)
3916
3917	AC_SUBST(INSTALL_LIB)
3918	AC_SUBST(RPATH_LIST)
3919])dnl
3920dnl ---------------------------------------------------------------------------
3921dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
3922dnl ----------------
3923dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
3924dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
3925dnl option.
3926dnl
3927dnl $1 is the default that should be used for "$cf_cv_shlib_version".
3928dnl If missing, use "rel".
3929define([CF_SHARED_SONAME],
3930[
3931	test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
3932	if test "$cf_cv_shlib_version" = rel; then
3933		cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
3934	else
3935		cf_cv_shared_soname='`basename $[@]`'
3936	fi
3937])
3938dnl ---------------------------------------------------------------------------
3939dnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
3940dnl --------------
3941dnl Construct a search-list for a nonstandard header/lib-file
3942dnl	$1 = the variable to return as result
3943dnl	$2 = the package name
3944dnl	$3 = the subdirectory, e.g., bin, include or lib
3945AC_DEFUN([CF_SUBDIR_PATH],
3946[
3947$1=
3948
3949CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
3950CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
3951CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
3952CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
3953CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
3954])dnl
3955dnl ---------------------------------------------------------------------------
3956dnl CF_TERM_HEADER version: 3 updated: 2012/10/06 08:57:51
3957dnl --------------
3958dnl Look for term.h, which is part of X/Open curses.  It defines the interface
3959dnl to terminfo database.  Usually it is in the same include-path as curses.h,
3960dnl but some packagers change this, breaking various applications.
3961AC_DEFUN([CF_TERM_HEADER],[
3962AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
3963case ${cf_cv_ncurses_header} in #(vi
3964*/ncurses.h|*/ncursesw.h) #(vi
3965	cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
3966	;;
3967*)
3968	cf_term_header=term.h
3969	;;
3970esac
3971
3972for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
3973do
3974AC_TRY_COMPILE([#include <stdio.h>
3975#include <${cf_cv_ncurses_header:-curses.h}>
3976#include <$cf_test>
3977],[int x = auto_left_margin],[
3978	cf_cv_term_header="$cf_test"],[
3979	cf_cv_term_header=unknown
3980	])
3981	test "$cf_cv_term_header" != unknown && break
3982done
3983])
3984
3985# Set definitions to allow ifdef'ing to accommodate subdirectories
3986
3987case $cf_cv_term_header in # (vi
3988*term.h)
3989	AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
3990	;;
3991esac
3992
3993case $cf_cv_term_header in # (vi
3994ncurses/term.h) #(vi
3995	AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
3996	;;
3997ncursesw/term.h)
3998	AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
3999	;;
4000esac
4001])dnl
4002dnl ---------------------------------------------------------------------------
4003dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
4004dnl -------------------
4005dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
4006dnl can define it successfully.
4007AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
4008AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
4009	AC_TRY_COMPILE([
4010#include <stdlib.h>
4011#include <string.h>
4012#include <sys/types.h>
4013],[
4014#ifndef _XOPEN_SOURCE
4015make an error
4016#endif],
4017	[cf_cv_xopen_source=no],
4018	[cf_save="$CPPFLAGS"
4019	 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
4020	 AC_TRY_COMPILE([
4021#include <stdlib.h>
4022#include <string.h>
4023#include <sys/types.h>
4024],[
4025#ifdef _XOPEN_SOURCE
4026make an error
4027#endif],
4028	[cf_cv_xopen_source=no],
4029	[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
4030	CPPFLAGS="$cf_save"
4031	])
4032])
4033
4034if test "$cf_cv_xopen_source" != no ; then
4035	CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
4036	CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
4037	cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
4038	CF_ADD_CFLAGS($cf_temp_xopen_source)
4039fi
4040])
4041dnl ---------------------------------------------------------------------------
4042dnl CF_UNION_WAIT version: 6 updated: 2012/10/06 08:57:51
4043dnl -------------
4044dnl Check to see if the BSD-style union wait is declared.  Some platforms may
4045dnl use this, though it is deprecated in favor of the 'int' type in Posix.
4046dnl Some vendors provide a bogus implementation that declares union wait, but
4047dnl uses the 'int' type instead; we try to spot these by checking for the
4048dnl associated macros.
4049dnl
4050dnl Ahem.  Some implementers cast the status value to an int*, as an attempt to
4051dnl use the macros for either union wait or int.  So we do a check compile to
4052dnl see if the macros are defined and apply to an int.
4053dnl
4054dnl Sets: $cf_cv_type_unionwait
4055dnl Defines: HAVE_TYPE_UNIONWAIT
4056AC_DEFUN([CF_UNION_WAIT],
4057[
4058AC_REQUIRE([CF_WAIT_HEADERS])
4059AC_MSG_CHECKING([for union wait])
4060AC_CACHE_VAL(cf_cv_type_unionwait,[
4061	AC_TRY_LINK($cf_wait_headers,
4062	[int x;
4063	 int y = WEXITSTATUS(x);
4064	 int z = WTERMSIG(x);
4065	 wait(&x);
4066	],
4067	[cf_cv_type_unionwait=no
4068	 echo compiles ok w/o union wait 1>&AC_FD_CC
4069	],[
4070	AC_TRY_LINK($cf_wait_headers,
4071	[union wait x;
4072#ifdef WEXITSTATUS
4073	 int y = WEXITSTATUS(x);
4074#endif
4075#ifdef WTERMSIG
4076	 int z = WTERMSIG(x);
4077#endif
4078	 wait(&x);
4079	],
4080	[cf_cv_type_unionwait=yes
4081	 echo compiles ok with union wait and possibly macros too 1>&AC_FD_CC
4082	],
4083	[cf_cv_type_unionwait=no])])])
4084AC_MSG_RESULT($cf_cv_type_unionwait)
4085test $cf_cv_type_unionwait = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT,1,[Define to 1 if type unionwait is declared])
4086])dnl
4087dnl ---------------------------------------------------------------------------
4088dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
4089dnl --------
4090dnl Make an uppercase version of a variable
4091dnl $1=uppercase($2)
4092AC_DEFUN([CF_UPPER],
4093[
4094$1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
4095])dnl
4096dnl ---------------------------------------------------------------------------
4097dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
4098dnl -----------
4099dnl Check for multibyte support, and if not found, utf8 compatibility library
4100AC_DEFUN([CF_UTF8_LIB],
4101[
4102AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
4103	cf_save_LIBS="$LIBS"
4104	AC_TRY_LINK([
4105#include <stdlib.h>],[putwc(0,0);],
4106	[cf_cv_utf8_lib=yes],
4107	[CF_FIND_LINKAGE([
4108#include <libutf8.h>],[putwc(0,0);],utf8,
4109		[cf_cv_utf8_lib=add-on],
4110		[cf_cv_utf8_lib=no])
4111])])
4112
4113# HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
4114# ncurses/ncursesw:
4115if test "$cf_cv_utf8_lib" = "add-on" ; then
4116	AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
4117	CF_ADD_INCDIR($cf_cv_header_path_utf8)
4118	CF_ADD_LIBDIR($cf_cv_library_path_utf8)
4119	CF_ADD_LIBS($cf_cv_library_file_utf8)
4120fi
4121])dnl
4122dnl ---------------------------------------------------------------------------
4123dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
4124dnl ----------
4125dnl Use AC_VERBOSE w/o the warnings
4126AC_DEFUN([CF_VERBOSE],
4127[test -n "$verbose" && echo "	$1" 1>&AC_FD_MSG
4128CF_MSG_LOG([$1])
4129])dnl
4130dnl ---------------------------------------------------------------------------
4131dnl CF_VERSION_INFO version: 6 updated: 2013/06/16 10:25:53
4132dnl ---------------
4133dnl Define several useful symbols derived from the VERSION file.  A separate
4134dnl file is preferred to embedding the version numbers in various scripts.
4135dnl (automake is a textbook-example of why the latter is a bad idea, but there
4136dnl are others).
4137dnl
4138dnl The file contents are:
4139dnl	libtool-version	release-version	patch-version
4140dnl or
4141dnl	release-version
4142dnl where
4143dnl	libtool-version (see ?) consists of 3 integers separated by '.'
4144dnl	release-version consists of a major version and minor version
4145dnl		separated by '.', optionally followed by a patch-version
4146dnl		separated by '-'.  The minor version need not be an
4147dnl		integer (but it is preferred).
4148dnl	patch-version is an integer in the form yyyymmdd, so ifdef's and
4149dnl		scripts can easily compare versions.
4150dnl
4151dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
4152dnl simply extracts the first field using 'cut -f1'.
4153dnl
4154dnl Optional parameters:
4155dnl $1 = internal name for package
4156dnl $2 = external name for package
4157AC_DEFUN([CF_VERSION_INFO],
4158[
4159if test -f $srcdir/VERSION ; then
4160	AC_MSG_CHECKING(for package version)
4161
4162	# if there are not enough fields, cut returns the last one...
4163	cf_field1=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
4164	cf_field2=`sed -e '2,$d' $srcdir/VERSION|cut -f2`
4165	cf_field3=`sed -e '2,$d' $srcdir/VERSION|cut -f3`
4166
4167	# this is how CF_BUNDLED_INTL uses $VERSION:
4168	VERSION="$cf_field1"
4169
4170	VERSION_MAJOR=`echo "$cf_field2" | sed -e 's/\..*//'`
4171	test -z "$VERSION_MAJOR" && AC_MSG_ERROR(missing major-version)
4172
4173	VERSION_MINOR=`echo "$cf_field2" | sed -e 's/^[[^.]]*\.//' -e 's/-.*//'`
4174	test -z "$VERSION_MINOR" && AC_MSG_ERROR(missing minor-version)
4175
4176	AC_MSG_RESULT(${VERSION_MAJOR}.${VERSION_MINOR})
4177
4178	AC_MSG_CHECKING(for package patch date)
4179	VERSION_PATCH=`echo "$cf_field3" | sed -e 's/^[[^-]]*-//'`
4180	case .$VERSION_PATCH in
4181	.)
4182		AC_MSG_ERROR(missing patch-date $VERSION_PATCH)
4183		;;
4184	.[[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]][[0-9]])
4185		;;
4186	*)
4187		AC_MSG_ERROR(illegal patch-date $VERSION_PATCH)
4188		;;
4189	esac
4190	AC_MSG_RESULT($VERSION_PATCH)
4191else
4192	AC_MSG_ERROR(did not find $srcdir/VERSION)
4193fi
4194
4195# show the actual data that we have for versions:
4196CF_VERBOSE(ABI VERSION $VERSION)
4197CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
4198CF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
4199CF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
4200
4201AC_SUBST(VERSION)
4202AC_SUBST(VERSION_MAJOR)
4203AC_SUBST(VERSION_MINOR)
4204AC_SUBST(VERSION_PATCH)
4205
4206dnl if a package name is given, define its corresponding version info.  We
4207dnl need the package name to ensure that the defined symbols are unique.
4208ifelse($1,,,[
4209	cf_PACKAGE=$1
4210	PACKAGE=ifelse($2,,$1,$2)
4211	AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE",[Define to the package-name])
4212	AC_SUBST(PACKAGE)
4213	CF_UPPER(cf_PACKAGE,$cf_PACKAGE)
4214	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_VERSION,"${VERSION_MAJOR}.${VERSION_MINOR}")
4215	AC_DEFINE_UNQUOTED(${cf_PACKAGE}_PATCHDATE,${VERSION_PATCH})
4216])
4217])dnl
4218dnl ---------------------------------------------------------------------------
4219dnl CF_WAIT_HEADERS version: 2 updated: 1997/10/21 19:45:33
4220dnl ---------------
4221dnl Build up an expression $cf_wait_headers with the header files needed to
4222dnl compile against the prototypes for 'wait()', 'waitpid()', etc.  Assume it's
4223dnl Posix, which uses <sys/types.h> and <sys/wait.h>, but allow SVr4 variation
4224dnl with <wait.h>.
4225AC_DEFUN([CF_WAIT_HEADERS],
4226[
4227AC_HAVE_HEADERS(sys/wait.h)
4228cf_wait_headers="#include <sys/types.h>
4229"
4230if test $ac_cv_header_sys_wait_h = yes; then
4231cf_wait_headers="$cf_wait_headers
4232#include <sys/wait.h>
4233"
4234else
4235AC_HAVE_HEADERS(wait.h)
4236AC_HAVE_HEADERS(waitstatus.h)
4237if test $ac_cv_header_wait_h = yes; then
4238cf_wait_headers="$cf_wait_headers
4239#include <wait.h>
4240"
4241fi
4242if test $ac_cv_header_waitstatus_h = yes; then
4243cf_wait_headers="$cf_wait_headers
4244#include <waitstatus.h>
4245"
4246fi
4247fi
4248])dnl
4249dnl ---------------------------------------------------------------------------
4250dnl CF_WITH_ABI_VERSION version: 1 updated: 2003/09/20 18:12:49
4251dnl -------------------
4252dnl Allow library's ABI to be overridden.  Generally this happens when a
4253dnl packager has incremented the ABI past that used in the original package,
4254dnl and wishes to keep doing this.
4255dnl
4256dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
4257dnl symbol.
4258AC_DEFUN([CF_WITH_ABI_VERSION],[
4259test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
4260AC_ARG_WITH(abi-version,
4261[  --with-abi-version=XXX  override derived ABI version],
4262[AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
4263 cf_cv_abi_version=$withval])
4264 CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
4265ifelse($1,,,[
4266$1_ABI=$cf_cv_abi_version
4267])
4268])dnl
4269dnl ---------------------------------------------------------------------------
4270dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
4271dnl ------------------
4272dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
4273dnl libraries.
4274AC_DEFUN([CF_WITH_CURSES_DIR],[
4275
4276AC_MSG_CHECKING(for specific curses-directory)
4277AC_ARG_WITH(curses-dir,
4278	[  --with-curses-dir=DIR   directory in which (n)curses is installed],
4279	[cf_cv_curses_dir=$withval],
4280	[cf_cv_curses_dir=no])
4281AC_MSG_RESULT($cf_cv_curses_dir)
4282
4283if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
4284then
4285	CF_PATH_SYNTAX(withval)
4286	if test -d "$cf_cv_curses_dir"
4287	then
4288		CF_ADD_INCDIR($cf_cv_curses_dir/include)
4289		CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
4290	fi
4291fi
4292])dnl
4293dnl ---------------------------------------------------------------------------
4294dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
4295dnl ----------------
4296dnl Configure-option for dbmalloc.  The optional parameter is used to override
4297dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
4298AC_DEFUN([CF_WITH_DBMALLOC],[
4299CF_NO_LEAKS_OPTION(dbmalloc,
4300	[  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
4301	[USE_DBMALLOC])
4302
4303if test "$with_dbmalloc" = yes ; then
4304	AC_CHECK_HEADER(dbmalloc.h,
4305		[AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
4306fi
4307])dnl
4308dnl ---------------------------------------------------------------------------
4309dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
4310dnl ---------------
4311dnl Configure-option for dmalloc.  The optional parameter is used to override
4312dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
4313AC_DEFUN([CF_WITH_DMALLOC],[
4314CF_NO_LEAKS_OPTION(dmalloc,
4315	[  --with-dmalloc          test: use Gray Watson's dmalloc library],
4316	[USE_DMALLOC])
4317
4318if test "$with_dmalloc" = yes ; then
4319	AC_CHECK_HEADER(dmalloc.h,
4320		[AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
4321fi
4322])dnl
4323dnl ---------------------------------------------------------------------------
4324dnl CF_WITH_LIBTOOL version: 30 updated: 2013/09/07 13:54:05
4325dnl ---------------
4326dnl Provide a configure option to incorporate libtool.  Define several useful
4327dnl symbols for the makefile rules.
4328dnl
4329dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
4330dnl macros from libtool.m4 which is in the aclocal directory of automake.
4331dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
4332dnl But that still does not work properly since the macro is expanded outside
4333dnl the CF_WITH_LIBTOOL macro:
4334dnl
4335dnl	#!/bin/sh
4336dnl	ACLOCAL=`aclocal --print-ac-dir`
4337dnl	if test -z "$ACLOCAL" ; then
4338dnl		echo cannot find aclocal directory
4339dnl		exit 1
4340dnl	elif test ! -f $ACLOCAL/libtool.m4 ; then
4341dnl		echo cannot find libtool.m4 file
4342dnl		exit 1
4343dnl	fi
4344dnl
4345dnl	LOCAL=aclocal.m4
4346dnl	ORIG=aclocal.m4.orig
4347dnl
4348dnl	trap "mv $ORIG $LOCAL" 0 1 2 5 15
4349dnl	rm -f $ORIG
4350dnl	mv $LOCAL $ORIG
4351dnl
4352dnl	# sed the LIBTOOL= assignment to omit the current directory?
4353dnl	sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL:-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
4354dnl	cat $ORIG >>$LOCAL
4355dnl
4356dnl	autoconf-257 $*
4357dnl
4358AC_DEFUN([CF_WITH_LIBTOOL],
4359[
4360AC_REQUIRE([CF_DISABLE_LIBTOOL_VERSION])
4361ifdef([AC_PROG_LIBTOOL],,[
4362LIBTOOL=
4363])
4364# common library maintenance symbols that are convenient for libtool scripts:
4365LIB_CREATE='${AR} -cr'
4366LIB_OBJECT='${OBJECTS}'
4367LIB_SUFFIX=.a
4368LIB_PREP="$RANLIB"
4369
4370# symbols used to prop libtool up to enable it to determine what it should be
4371# doing:
4372LIB_CLEAN=
4373LIB_COMPILE=
4374LIB_LINK='${CC}'
4375LIB_INSTALL=
4376LIB_UNINSTALL=
4377
4378AC_MSG_CHECKING(if you want to build libraries with libtool)
4379AC_ARG_WITH(libtool,
4380	[  --with-libtool          generate libraries with libtool],
4381	[with_libtool=$withval],
4382	[with_libtool=no])
4383AC_MSG_RESULT($with_libtool)
4384if test "$with_libtool" != "no"; then
4385ifdef([AC_PROG_LIBTOOL],[
4386	# missing_content_AC_PROG_LIBTOOL{{
4387	AC_PROG_LIBTOOL
4388	# missing_content_AC_PROG_LIBTOOL}}
4389],[
4390	if test "$with_libtool" != "yes" ; then
4391		CF_PATH_SYNTAX(with_libtool)
4392		LIBTOOL=$with_libtool
4393	else
4394		AC_CHECK_TOOLS(LIBTOOL,[libtool glibtool],none)
4395		CF_LIBTOOL_VERSION
4396		if test -z "$cf_cv_libtool_version" && test "$LIBTOOL" = libtool
4397		then
4398			CF_FORGET_TOOL(LIBTOOL)
4399			AC_CHECK_TOOLS(LIBTOOL,[glibtool],none)
4400			CF_LIBTOOL_VERSION
4401		fi
4402	fi
4403	if test -z "$LIBTOOL" ; then
4404		AC_MSG_ERROR(Cannot find libtool)
4405	fi
4406])dnl
4407	LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${DESTDIR}${libdir} ${LIBTOOL_VERSION} `cut -f1 ${srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} $(LIBS) -o'
4408	LIB_OBJECT='${OBJECTS:.o=.lo}'
4409	LIB_SUFFIX=.la
4410	LIB_CLEAN='${LIBTOOL} --mode=clean'
4411	LIB_COMPILE='${LIBTOOL} --mode=compile'
4412	LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
4413	LIB_INSTALL='${LIBTOOL} --mode=install'
4414	LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
4415	LIB_PREP=:
4416
4417	CF_CHECK_LIBTOOL_VERSION
4418
4419	# special hack to add -no-undefined (which libtool should do for itself)
4420	LT_UNDEF=
4421	case "$cf_cv_system_name" in #(vi
4422	cygwin*|msys*|mingw32*|uwin*|aix[[4-7]]) #(vi
4423		LT_UNDEF=-no-undefined
4424		;;
4425	esac
4426	AC_SUBST([LT_UNDEF])
4427
4428	# special hack to add --tag option for C++ compiler
4429	case $cf_cv_libtool_version in #(vi
4430	1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*) #(vi
4431		LIBTOOL_CXX="$LIBTOOL --tag=CXX"
4432		LIBTOOL="$LIBTOOL --tag=CC"
4433		;;
4434	*)
4435		LIBTOOL_CXX="$LIBTOOL"
4436		;;
4437	esac
4438else
4439	LIBTOOL=""
4440	LIBTOOL_CXX=""
4441fi
4442
4443test -z "$LIBTOOL" && ECHO_LT=
4444
4445AC_SUBST(LIBTOOL)
4446AC_SUBST(LIBTOOL_CXX)
4447AC_SUBST(LIBTOOL_OPTS)
4448
4449AC_SUBST(LIB_CREATE)
4450AC_SUBST(LIB_OBJECT)
4451AC_SUBST(LIB_SUFFIX)
4452AC_SUBST(LIB_PREP)
4453
4454AC_SUBST(LIB_CLEAN)
4455AC_SUBST(LIB_COMPILE)
4456AC_SUBST(LIB_LINK)
4457AC_SUBST(LIB_INSTALL)
4458AC_SUBST(LIB_UNINSTALL)
4459
4460])dnl
4461dnl ---------------------------------------------------------------------------
4462dnl CF_WITH_LIBTOOL_OPTS version: 2 updated: 2007/04/08 18:14:54
4463dnl --------------------
4464dnl Allow user to pass additional libtool options into the library creation
4465dnl and link steps.  The main use for this is to do something like
4466dnl	./configure --with-libtool-opts=-static
4467dnl to get the same behavior as automake-flavored
4468dnl	./configure --enable-static
4469AC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
4470AC_MSG_CHECKING(for additional libtool options)
4471AC_ARG_WITH(libtool-opts,
4472	[  --with-libtool-opts=XXX specify additional libtool options],
4473	[with_libtool_opts=$withval],
4474	[with_libtool_opts=no])
4475AC_MSG_RESULT($with_libtool_opts)
4476
4477case .$with_libtool_opts in
4478.yes|.no|.)
4479	;;
4480*)
4481	LIBTOOL_OPTS=$with_libtool_opts
4482	;;
4483esac
4484
4485AC_SUBST(LIBTOOL_OPTS)
4486])dnl
4487dnl ---------------------------------------------------------------------------
4488dnl CF_WITH_NO_LEAKS version: 2 updated: 2012/10/06 08:57:51
4489dnl ----------------
4490AC_DEFUN([CF_WITH_NO_LEAKS],[
4491
4492AC_REQUIRE([CF_WITH_DMALLOC])
4493AC_REQUIRE([CF_WITH_DBMALLOC])
4494AC_REQUIRE([CF_WITH_PURIFY])
4495AC_REQUIRE([CF_WITH_VALGRIND])
4496
4497AC_MSG_CHECKING(if you want to perform memory-leak testing)
4498AC_ARG_WITH(no-leaks,
4499	[  --with-no-leaks         test: free permanent memory, analyze leaks],
4500	[AC_DEFINE(NO_LEAKS,1,[Define to 1 to enable leak-checking])
4501	 cf_doalloc=".${with_dmalloc}${with_dbmalloc}${with_purify}${with_valgrind}"
4502	 case ${cf_doalloc} in #(vi
4503	 *yes*) ;;
4504	 *) AC_DEFINE(DOALLOC,10000,[Define to size of malloc-array]) ;;
4505	 esac
4506	 with_no_leaks=yes],
4507	[with_no_leaks=])
4508AC_MSG_RESULT($with_no_leaks)
4509])dnl
4510dnl ---------------------------------------------------------------------------
4511dnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
4512dnl --------------
4513AC_DEFUN([CF_WITH_PURIFY],[
4514CF_NO_LEAKS_OPTION(purify,
4515	[  --with-purify           test: use Purify],
4516	[USE_PURIFY],
4517	[LINK_PREFIX="$LINK_PREFIX purify"])
4518AC_SUBST(LINK_PREFIX)
4519])dnl
4520dnl ---------------------------------------------------------------------------
4521dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
4522dnl -------------------
4523dnl Allow library's release-version to be overridden.  Generally this happens when a
4524dnl packager has incremented the release-version past that used in the original package,
4525dnl and wishes to keep doing this.
4526dnl
4527dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
4528dnl and {package}_MINOR symbols
4529dnl symbol.
4530AC_DEFUN([CF_WITH_REL_VERSION],[
4531test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
4532AC_ARG_WITH(rel-version,
4533[  --with-rel-version=XXX  override derived release version],
4534[AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
4535 cf_cv_rel_version=$withval])
4536ifelse($1,,[
4537 CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
4538],[
4539 $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
4540 $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
4541 CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
4542 CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
4543])
4544])dnl
4545dnl ---------------------------------------------------------------------------
4546dnl CF_WITH_SHARED_OR_LIBTOOL version: 5 updated: 2013/09/02 09:17:44
4547dnl -------------------------
4548dnl Provide shared libraries using either autoconf macros (--with-shared) or
4549dnl using the external libtool script (--with-libtool).
4550dnl
4551dnl $1 = program name (all caps preferred)
4552dnl $1 = release version
4553dnl $2 = ABI version
4554define([CF_WITH_SHARED_OR_LIBTOOL],[
4555
4556REL_VERSION=$2
4557ABI_VERSION=$3
4558cf_cv_rel_version=$REL_VERSION
4559AC_SUBST(ABI_VERSION)
4560AC_SUBST(REL_VERSION)
4561
4562CF_WITH_REL_VERSION($1)
4563CF_WITH_ABI_VERSION
4564
4565LIB_MODEL=static
4566DFT_LWR_MODEL=$LIB_MODEL
4567LIBTOOL_MAKE="#"
4568
4569# use to comment-out makefile lines
4570MAKE_NORMAL=
4571MAKE_STATIC=
4572MAKE_SHARED="#"
4573
4574CF_WITH_LIBTOOL
4575
4576LIB_CREATE="$LIB_CREATE \[$]@"
4577
4578if test "$with_libtool" = "yes" ; then
4579	OBJEXT="lo"
4580	LIB_MODEL=libtool
4581	DFT_LWR_MODEL=$LIB_MODEL
4582	LIBTOOL_MAKE=
4583	CF_WITH_LIBTOOL_OPTS
4584	MAKE_NORMAL="#"
4585	MAKE_STATIC="#"
4586	MAKE_SHARED=
4587else
4588	AC_MSG_CHECKING(if you want to build shared libraries)
4589	AC_ARG_WITH(shared,
4590		[  --with-shared           generate shared-libraries],
4591		[with_shared=$withval],
4592		[with_shared=no])
4593	AC_MSG_RESULT($with_shared)
4594	if test "$with_shared" = "yes" ; then
4595		LIB_MODEL=shared
4596		DFT_LWR_MODEL=$LIB_MODEL
4597		CF_SHARED_OPTS
4598		LIB_PREP=:
4599		LIB_CREATE="[$]MK_SHARED_LIB"
4600		CFLAGS="$CFLAGS $CC_SHARED_OPTS"
4601		MAKE_NORMAL="#"
4602		MAKE_STATIC="#"
4603		MAKE_SHARED=
4604	fi
4605fi
4606
4607LIB_SUFFIX=
4608CF_LIB_SUFFIX($LIB_MODEL, DFT_LIB_SUFFIX, DFT_DEP_SUFFIX)
4609LIB_SUFFIX=$DFT_LIB_SUFFIX
4610
4611AC_SUBST(DFT_LWR_MODEL)
4612AC_SUBST(DFT_LIB_SUFFIX)
4613AC_SUBST(DFT_DEP_SUFFIX)
4614AC_SUBST(LIB_MODEL)
4615
4616AC_SUBST(LIBTOOL_MAKE)
4617
4618AC_SUBST(MAKE_NORMAL)
4619AC_SUBST(MAKE_SHARED)
4620AC_SUBST(MAKE_STATIC)
4621])dnl
4622dnl ---------------------------------------------------------------------------
4623dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
4624dnl ----------------
4625AC_DEFUN([CF_WITH_VALGRIND],[
4626CF_NO_LEAKS_OPTION(valgrind,
4627	[  --with-valgrind         test: use valgrind],
4628	[USE_VALGRIND])
4629])dnl
4630dnl ---------------------------------------------------------------------------
4631dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
4632dnl ----------------
4633dnl Combine the checks for gcc features into a configure-script option
4634dnl
4635dnl Parameters:
4636dnl	$1 - see CF_GCC_WARNINGS
4637AC_DEFUN([CF_WITH_WARNINGS],
4638[
4639if ( test "$GCC" = yes || test "$GXX" = yes )
4640then
4641AC_MSG_CHECKING(if you want to check for gcc warnings)
4642AC_ARG_WITH(warnings,
4643	[  --with-warnings         test: turn on gcc warnings],
4644	[cf_opt_with_warnings=$withval],
4645	[cf_opt_with_warnings=no])
4646AC_MSG_RESULT($cf_opt_with_warnings)
4647if test "$cf_opt_with_warnings" != no ; then
4648	CF_GCC_ATTRIBUTES
4649	CF_GCC_WARNINGS([$1])
4650fi
4651fi
4652])dnl
4653dnl ---------------------------------------------------------------------------
4654dnl CF_XOPEN_CURSES version: 11 updated: 2011/01/18 18:15:30
4655dnl ---------------
4656dnl Test if we should define X/Open source for curses, needed on Digital Unix
4657dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
4658dnl
4659dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
4660dnl as getbegy().  The latter is better design, but the former is standard.
4661AC_DEFUN([CF_XOPEN_CURSES],
4662[
4663AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
4664AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
4665AC_TRY_LINK([
4666#include <stdlib.h>
4667#include <${cf_cv_ncurses_header:-curses.h}>],[
4668#if defined(NCURSES_VERSION_PATCH)
4669#if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
4670	make an error
4671#endif
4672#endif
4673	long x = winnstr(stdscr, "", 0);
4674	int x1, y1;
4675	getbegyx(stdscr, y1, x1)],
4676	[cf_cv_need_xopen_extension=no],
4677	[AC_TRY_LINK([
4678#define _XOPEN_SOURCE_EXTENDED
4679#include <stdlib.h>
4680#include <${cf_cv_ncurses_header:-curses.h}>],[
4681#ifdef NCURSES_VERSION
4682	cchar_t check;
4683	int check2 = curs_set((int)sizeof(check));
4684#endif
4685	long x = winnstr(stdscr, "", 0);
4686	int x1, y1;
4687	getbegyx(stdscr, y1, x1)],
4688	[cf_cv_need_xopen_extension=yes],
4689	[cf_cv_need_xopen_extension=unknown])])])
4690test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
4691])dnl
4692dnl ---------------------------------------------------------------------------
4693dnl CF_XOPEN_SOURCE version: 45 updated: 2013/09/07 14:06:25
4694dnl ---------------
4695dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
4696dnl or adapt to the vendor's definitions to get equivalent functionality,
4697dnl without losing the common non-POSIX features.
4698dnl
4699dnl Parameters:
4700dnl	$1 is the nominal value for _XOPEN_SOURCE
4701dnl	$2 is the nominal value for _POSIX_C_SOURCE
4702AC_DEFUN([CF_XOPEN_SOURCE],[
4703AC_REQUIRE([AC_CANONICAL_HOST])
4704
4705cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
4706cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
4707cf_xopen_source=
4708
4709case $host_os in #(vi
4710aix[[4-7]]*) #(vi
4711	cf_xopen_source="-D_ALL_SOURCE"
4712	;;
4713cygwin|msys) #(vi
4714	cf_XOPEN_SOURCE=600
4715	;;
4716darwin[[0-8]].*) #(vi
4717	cf_xopen_source="-D_APPLE_C_SOURCE"
4718	;;
4719darwin*) #(vi
4720	cf_xopen_source="-D_DARWIN_C_SOURCE"
4721	cf_XOPEN_SOURCE=
4722	;;
4723freebsd*|dragonfly*) #(vi
4724	# 5.x headers associate
4725	#	_XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
4726	#	_XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
4727	cf_POSIX_C_SOURCE=200112L
4728	cf_XOPEN_SOURCE=600
4729	cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
4730	;;
4731hpux11*) #(vi
4732	cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
4733	;;
4734hpux*) #(vi
4735	cf_xopen_source="-D_HPUX_SOURCE"
4736	;;
4737irix[[56]].*) #(vi
4738	cf_xopen_source="-D_SGI_SOURCE"
4739	cf_XOPEN_SOURCE=
4740	;;
4741linux*|gnu*|mint*|k*bsd*-gnu) #(vi
4742	CF_GNU_SOURCE
4743	;;
4744mirbsd*) #(vi
4745	# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
4746	cf_XOPEN_SOURCE=
4747	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4748	;;
4749netbsd*) #(vi
4750	cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
4751	;;
4752openbsd[[4-9]]*) #(vi
4753	# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
4754	cf_xopen_source="-D_BSD_SOURCE"
4755	cf_XOPEN_SOURCE=600
4756	;;
4757openbsd*) #(vi
4758	# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
4759	;;
4760osf[[45]]*) #(vi
4761	cf_xopen_source="-D_OSF_SOURCE"
4762	;;
4763nto-qnx*) #(vi
4764	cf_xopen_source="-D_QNX_SOURCE"
4765	;;
4766sco*) #(vi
4767	# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
4768	;;
4769solaris2.*) #(vi
4770	cf_xopen_source="-D__EXTENSIONS__"
4771	;;
4772*)
4773	CF_TRY_XOPEN_SOURCE
4774	CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4775	;;
4776esac
4777
4778if test -n "$cf_xopen_source" ; then
4779	CF_ADD_CFLAGS($cf_xopen_source)
4780fi
4781
4782dnl In anything but the default case, we may have system-specific setting
4783dnl which is still not guaranteed to provide all of the entrypoints that
4784dnl _XOPEN_SOURCE would yield.
4785if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
4786	AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
4787	AC_TRY_COMPILE([#include <stdlib.h>],[
4788#ifndef _XOPEN_SOURCE
4789make an error
4790#endif],
4791	[cf_XOPEN_SOURCE_set=yes],
4792	[cf_XOPEN_SOURCE_set=no])
4793	AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
4794	if test $cf_XOPEN_SOURCE_set = yes
4795	then
4796		AC_TRY_COMPILE([#include <stdlib.h>],[
4797#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
4798make an error
4799#endif],
4800		[cf_XOPEN_SOURCE_set_ok=yes],
4801		[cf_XOPEN_SOURCE_set_ok=no])
4802		if test $cf_XOPEN_SOURCE_set_ok = no
4803		then
4804			AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
4805		fi
4806	else
4807		CF_TRY_XOPEN_SOURCE
4808	fi
4809fi
4810])
4811dnl ---------------------------------------------------------------------------
4812dnl CF__ADD_SHLIB_RULES version: 4 updated: 2013/07/22 18:49:24
4813dnl -------------------
4814dnl Append rules for creating, installing, uninstalling and cleaning library.
4815dnl In particular, this is needed for shared libraries since there are symbolic
4816dnl links which depend on configuration choices.
4817dnl
4818dnl The logic is controlled by these cache variables:
4819dnl $cf_cv_do_symlinks
4820dnl $cf_cv_shlib_version
4821dnl
4822dnl The macro uses variables set by CF__DEFINE_SHLIB_VARS
4823dnl
4824dnl $1 = makefile to append to
4825dnl $2 = model (static, shared, libtool)
4826dnl $3 = objects (dependencies)
4827dnl $4 = additional libraries needed to link the shared library
4828define([CF__ADD_SHLIB_RULES],[
4829
4830CF__DEFINE_LIB_TARGET
4831
4832case x$2 in
4833xlibtool|xshared) #(vi
4834	cf_libdeps="ifelse($4,,,[$4])"
4835	;;
4836x*)
4837	cf_libdeps=
4838	;;
4839esac
4840
4841cat >>$1 <<CF_EOF
4842
4843# generated by CF__ADD_SHLIB_RULES
4844# libmodel: $2
4845# symlinks: $cf_cv_do_symlinks
4846# shlibver: $cf_cv_shlib_version
4847
4848CF_EOF
4849
4850cat >>$1 <<CF_EOF
4851$cf_libname :: \\
4852CF_EOF
4853
4854cat >>$1 <<CF_EOF
4855		$3
4856	@echo linking \[$]@
4857	\$(LIBTOOL_CREATE) $3 $cf_libdeps
4858CF_EOF
4859
4860if test "x$cf_cv_do_symlinks" = xyes
4861then
4862cat >>$1 <<CF_EOF
4863	\$(LN_S) $cf_libname $cf_liblink
4864	\$(LN_S) $cf_liblink $cf_libroot
4865CF_EOF
4866fi
4867
4868cat >>$1 <<CF_EOF
4869
4870install \\
4871install.libs :: \$(DESTDIR)\$(libdir)/$cf_libname
4872
4873\$(DESTDIR)\$(libdir)/$cf_libname :: \\
4874		\$(DESTDIR)\$(libdir) \\
4875		$3
4876	@echo linking \[$]@
4877	\$(LIBTOOL_CREATE) $3 $cf_libdeps
4878CF_EOF
4879
4880if test "x$cf_cv_do_symlinks" = xyes
4881then
4882cat >>$1 <<CF_EOF
4883	cd \$(DESTDIR)\$(libdir) && (\$(LN_S) $cf_libname $cf_liblink; \$(LN_S) $cf_liblink $cf_libroot; )
4884CF_EOF
4885fi
4886
4887if test x$2 = xshared
4888then
4889cat >>$1 <<CF_EOF
4890	- test -z "\$(DESTDIR)" && /sbin/ldconfig
4891CF_EOF
4892fi
4893
4894cat >>$1 <<CF_EOF
4895
4896uninstall \\
4897uninstall.libs ::
4898	@echo uninstalling \$(DESTDIR)\$(libdir)/$cf_libname
4899CF_EOF
4900
4901if test "x$cf_cv_do_symlinks" = xyes
4902then
4903cat >>$1 <<CF_EOF
4904	-rm -f \$(DESTDIR)\$(libdir)/$cf_libroot
4905	-rm -f \$(DESTDIR)\$(libdir)/$cf_liblink
4906CF_EOF
4907fi
4908
4909cat >>$1 <<CF_EOF
4910	-rm -f \$(DESTDIR)\$(libdir)/$cf_libname
4911
4912clean \\
4913clean.libs ::
4914CF_EOF
4915
4916if test "x$cf_cv_do_symlinks" = xyes
4917then
4918cat >>$1 <<CF_EOF
4919	-rm -f $cf_libroot
4920	-rm -f $cf_liblink
4921CF_EOF
4922fi
4923
4924cat >>$1 <<CF_EOF
4925	-rm -f $cf_libname
4926
4927mostlyclean::
4928	-rm -f $3
4929# end generated by CF__ADD_SHLIB_RULES
4930CF_EOF
4931])dnl
4932dnl ---------------------------------------------------------------------------
4933dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
4934dnl ---------------
4935dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
4936dnl are both available.
4937define([CF__CURSES_HEAD],[
4938#ifdef HAVE_XCURSES
4939#include <xcurses.h>
4940char * XCursesProgramName = "test";
4941#else
4942#include <${cf_cv_ncurses_header:-curses.h}>
4943#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
4944#include <ncursesw/term.h>
4945#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
4946#include <ncurses/term.h>
4947#elif defined(HAVE_TERM_H)
4948#include <term.h>
4949#endif
4950#endif
4951])
4952dnl ---------------------------------------------------------------------------
4953dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
4954dnl ---------------
4955dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
4956dnl are both available.
4957define([CF__CURSES_HEAD],[
4958#ifdef HAVE_XCURSES
4959#include <xcurses.h>
4960char * XCursesProgramName = "test";
4961#else
4962#include <${cf_cv_ncurses_header:-curses.h}>
4963#if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
4964#include <ncursesw/term.h>
4965#elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
4966#include <ncurses/term.h>
4967#elif defined(HAVE_TERM_H)
4968#include <term.h>
4969#endif
4970#endif
4971])
4972dnl ---------------------------------------------------------------------------
4973dnl CF__DEFINE_LIB_TARGET version: 1 updated: 2013/07/22 18:27:50
4974dnl ---------------------
4975define([CF__DEFINE_LIB_TARGET],[
4976cf_libname=\${LIB_BASENAME}
4977cf_liblink=$cf_libname
4978cf_libroot=$cf_libname
4979
4980if test "x$cf_cv_do_symlinks" = xyes
4981then
4982	case "x$cf_cv_shlib_version" in #(vi
4983	xrel) #(vi
4984		cf_liblink="\${LIB_ABI_NAME}"
4985		cf_libname="\${LIB_REL_NAME}"
4986		;;
4987	xabi)
4988		cf_liblink="\${LIB_REL_NAME}"
4989		cf_libname="\${LIB_ABI_NAME}"
4990		;;
4991	esac
4992fi
4993LIB_TARGET=$cf_libname
4994])dnl
4995dnl ---------------------------------------------------------------------------
4996dnl CF__DEFINE_SHLIB_VARS version: 2 updated: 2013/07/27 17:38:32
4997dnl ---------------------
4998dnl Substitute makefile variables useful for CF__ADD_SHLIB_RULES.
4999dnl
5000dnl The substitution requires these variables:
5001dnl		LIB_PREFI - "lib"
5002dnl		LIB_ROOTNAME - "foo"
5003dnl		LIB_SUFFIX - ".so"
5004dnl		REL_VERSION - "5.0"
5005dnl		ABI_VERSION - "4.2.4"
5006define([CF__DEFINE_SHLIB_VARS],[
5007CF__DEFINE_LIB_TARGET
5008SET_SHLIB_VARS="# begin CF__DEFINE_SHLIB_VARS\\
5009LIB_BASENAME	= ${LIB_PREFIX}\${LIB_ROOTNAME}\${LIB_SUFFIX}\\
5010LIB_REL_NAME	= \${LIB_BASENAME}.\${REL_VERSION}\\
5011LIB_ABI_NAME	= \${LIB_BASENAME}.\${ABI_VERSION}\\
5012LIB_TARGET	= $LIB_TARGET\\
5013RM_SHARED_OPTS	= $RM_SHARED_OPTS\\
5014# end CF__DEFINE_SHLIB_VARS"
5015AC_SUBST(SET_SHLIB_VARS)
5016AC_SUBST(LIB_TARGET)
5017])dnl
5018dnl ---------------------------------------------------------------------------
5019dnl CF__ICONV_BODY version: 2 updated: 2007/07/26 17:35:47
5020dnl --------------
5021dnl Test-code needed for iconv compile-checks
5022define([CF__ICONV_BODY],[
5023	iconv_t cd = iconv_open("","");
5024	iconv(cd,NULL,NULL,NULL,NULL);
5025	iconv_close(cd);]
5026)dnl
5027dnl ---------------------------------------------------------------------------
5028dnl CF__ICONV_HEAD version: 1 updated: 2007/07/26 15:57:03
5029dnl --------------
5030dnl Header-files needed for iconv compile-checks
5031define([CF__ICONV_HEAD],[
5032#include <stdlib.h>
5033#include <iconv.h>]
5034)dnl
5035dnl ---------------------------------------------------------------------------
5036dnl CF__INIT_SHLIB_RULES version: 2 updated: 2013/07/27 17:38:32
5037dnl --------------------
5038dnl The third parameter to AC_OUTPUT, used to pass variables needed for
5039dnl CF__ADD_SHLIB_RULES.
5040define([CF__INIT_SHLIB_RULES],[
5041ABI_VERSION="$ABI_VERSION"
5042REL_VERSION="$REL_VERSION"
5043LIB_MODEL="$LIB_MODEL"
5044LIB_PREFIX="$LIB_PREFIX"
5045LIB_ROOTNAME="$LIB_ROOTNAME"
5046DFT_DEP_SUFFIX="$DFT_DEP_SUFFIX"
5047RM_SHARED_OPTS="$RM_SHARED_OPTS"
5048cf_cv_do_symlinks="$cf_cv_do_symlinks"
5049cf_cv_shlib_version="$cf_cv_shlib_version"
5050])
5051dnl ---------------------------------------------------------------------------
5052dnl CF__INTL_BODY version: 1 updated: 2007/07/26 17:35:47
5053dnl -------------
5054dnl Test-code needed for libintl compile-checks
5055dnl $1 = parameter 2 from AM_WITH_NLS
5056define([CF__INTL_BODY],[
5057    bindtextdomain ("", "");
5058    return (int) gettext ("")
5059            ifelse([$1], need-ngettext, [ + (int) ngettext ("", "", 0)], [])
5060            [ + _nl_msg_cat_cntr]
5061])
5062dnl ---------------------------------------------------------------------------
5063dnl CF__INTL_HEAD version: 1 updated: 2007/07/26 17:35:47
5064dnl -------------
5065dnl Header-files needed for libintl compile-checks
5066define([CF__INTL_HEAD],[
5067#include <libintl.h>
5068extern int _nl_msg_cat_cntr;
5069])dnl
5070dnl ---------------------------------------------------------------------------
5071dnl jm_GLIBC21 version: 3 updated: 2002/10/27 23:21:42
5072dnl ----------
5073dnl Inserted as requested by gettext 0.10.40
5074dnl File from /usr/share/aclocal
5075dnl glibc21.m4
5076dnl ====================
5077dnl serial 2
5078dnl
5079dnl Test for the GNU C Library, version 2.1 or newer.
5080dnl From Bruno Haible.
5081AC_DEFUN([jm_GLIBC21],
5082  [
5083    AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer,
5084      ac_cv_gnu_library_2_1,
5085      [AC_EGREP_CPP([Lucky GNU user],
5086	[
5087#include <features.h>
5088#ifdef __GNU_LIBRARY__
5089 #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2)
5090  Lucky GNU user
5091 #endif
5092#endif
5093	],
5094	ac_cv_gnu_library_2_1=yes,
5095	ac_cv_gnu_library_2_1=no)
5096      ]
5097    )
5098    AC_SUBST(GLIBC21)
5099    GLIBC21="$ac_cv_gnu_library_2_1"
5100  ]
5101)
5102