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