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