]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/dialog/aclocal.m4
Upgrade to 6.3p1.
[FreeBSD/FreeBSD.git] / contrib / dialog / aclocal.m4
1 dnl macros used for DIALOG configure script
2 dnl $Id: aclocal.m4,v 1.90 2012/12/02 20:07:30 tom Exp $
3 dnl ---------------------------------------------------------------------------
4 dnl Copyright 1999-2011,2012 -- Thomas E. Dickey
5 dnl
6 dnl Permission is hereby granted, free of charge, to any person obtaining a
7 dnl copy of this software and associated documentation files (the
8 dnl "Software"), to deal in the Software without restriction, including
9 dnl without limitation the rights to use, copy, modify, merge, publish,
10 dnl distribute, distribute with modifications, sublicense, and/or sell
11 dnl copies of the Software, and to permit persons to whom the Software is
12 dnl furnished to do so, subject to the following conditions:
13 dnl 
14 dnl The above copyright notice and this permission notice shall be included
15 dnl in all copies or portions of the Software.
16 dnl 
17 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
21 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
23 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 dnl 
25 dnl Except as contained in this notice, the name(s) of the above copyright
26 dnl holders shall not be used in advertising or otherwise to promote the
27 dnl sale, use or other dealings in this Software without prior written
28 dnl authorization.
29 dnl
30 dnl see
31 dnl http://invisible-island.net/autoconf/ 
32 dnl ---------------------------------------------------------------------------
33 dnl ---------------------------------------------------------------------------
34 dnl AM_GNU_GETTEXT version: 13 updated: 2012/11/09 05:47:26
35 dnl --------------
36 dnl Usage: Just like AM_WITH_NLS, which see.
37 AC_DEFUN([AM_GNU_GETTEXT],
38   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
39    AC_REQUIRE([AC_CANONICAL_HOST])dnl
40    AC_REQUIRE([AC_PROG_RANLIB])dnl
41    AC_REQUIRE([AC_HEADER_STDC])dnl
42    AC_REQUIRE([AC_C_INLINE])dnl
43    AC_REQUIRE([AC_TYPE_OFF_T])dnl
44    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
45    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
46    AC_REQUIRE([AC_FUNC_MMAP])dnl
47    AC_REQUIRE([jm_GLIBC21])dnl
48    AC_REQUIRE([CF_PROG_CC])dnl
49
50    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
51 stdlib.h string.h unistd.h sys/param.h])
52    AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getcwd getegid geteuid \
53 getgid getuid mempcpy munmap putenv setenv setlocale stpcpy strchr strcasecmp \
54 strdup strtoul tsearch __argz_count __argz_stringify __argz_next])
55
56    AM_ICONV
57    AM_LANGINFO_CODESET
58    AM_LC_MESSAGES
59    AM_WITH_NLS([$1],[$2],[$3],[$4])
60
61    if test "x$CATOBJEXT" != "x"; then
62      if test "x$ALL_LINGUAS" = "x"; then
63        LINGUAS=
64      else
65        AC_MSG_CHECKING(for catalogs to be installed)
66        NEW_LINGUAS=
67        for presentlang in $ALL_LINGUAS; do
68          useit=no
69          for desiredlang in ${LINGUAS-$ALL_LINGUAS}; do
70            # Use the presentlang catalog if desiredlang is
71            #   a. equal to presentlang, or
72            #   b. a variant of presentlang (because in this case,
73            #      presentlang can be used as a fallback for messages
74            #      which are not translated in the desiredlang catalog).
75            case "$desiredlang" in
76              "$presentlang"*) useit=yes;;
77            esac
78          done
79          if test $useit = yes; then
80            NEW_LINGUAS="$NEW_LINGUAS $presentlang"
81          fi
82        done
83        LINGUAS=$NEW_LINGUAS
84        AC_MSG_RESULT($LINGUAS)
85      fi
86
87      dnl Construct list of names of catalog files to be constructed.
88      if test -n "$LINGUAS"; then
89        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
90      fi
91    fi
92
93    dnl Enable libtool support if the surrounding package wishes it.
94    INTL_LIBTOOL_SUFFIX_PREFIX=ifelse([$1], use-libtool, [l], [])
95    AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
96 ])dnl
97 dnl ---------------------------------------------------------------------------
98 dnl AM_ICONV version: 12 updated: 2007/07/30 19:12:03
99 dnl --------
100 dnl Inserted as requested by gettext 0.10.40
101 dnl File from /usr/share/aclocal
102 dnl iconv.m4
103 dnl ====================
104 dnl serial AM2
105 dnl
106 dnl From Bruno Haible.
107 dnl
108 dnl ====================
109 dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
110 dnl range of locations searched.  Retain the same cache-variable naming to
111 dnl allow reuse with the other gettext macros -Thomas E Dickey
112 AC_DEFUN([AM_ICONV],
113 [
114   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
115   dnl those with the standalone portable GNU libiconv installed).
116
117   AC_ARG_WITH([libiconv-prefix],
118 [  --with-libiconv-prefix=DIR
119                           search for libiconv in DIR/include and DIR/lib], [
120     CF_ADD_OPTIONAL_PATH($withval, libiconv)
121    ])
122
123   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
124     CF_FIND_LINKAGE(CF__ICONV_HEAD,
125       CF__ICONV_BODY,
126       iconv,
127       am_cv_func_iconv=yes,
128       am_cv_func_iconv=["no, consider installing GNU libiconv"])])
129
130   if test "$am_cv_func_iconv" = yes; then
131     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
132
133     AC_CACHE_CHECK([if the declaration of iconv() needs const.],
134                    am_cv_proto_iconv_const,[
135       AC_TRY_COMPILE(CF__ICONV_HEAD [
136 extern
137 #ifdef __cplusplus
138 "C"
139 #endif
140 #if defined(__STDC__) || defined(__cplusplus)
141 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
142 #else
143 size_t iconv();
144 #endif
145 ],[], am_cv_proto_iconv_const=no,
146       am_cv_proto_iconv_const=yes)])
147
148     if test "$am_cv_proto_iconv_const" = yes ; then
149       am_cv_proto_iconv_arg1="const"
150     else
151       am_cv_proto_iconv_arg1=""
152     fi
153
154     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
155       [Define as const if the declaration of iconv() needs const.])
156   fi
157
158   LIBICONV=
159   if test "$cf_cv_find_linkage_iconv" = yes; then
160     CF_ADD_INCDIR($cf_cv_header_path_iconv)
161     if test -n "$cf_cv_library_file_iconv" ; then
162       LIBICONV="-liconv"
163       CF_ADD_LIBDIR($cf_cv_library_path_iconv)
164     fi
165   fi
166
167   AC_SUBST(LIBICONV)
168 ])dnl
169 dnl ---------------------------------------------------------------------------
170 dnl AM_LANGINFO_CODESET version: 3 updated: 2002/10/27 23:21:42
171 dnl -------------------
172 dnl Inserted as requested by gettext 0.10.40
173 dnl File from /usr/share/aclocal
174 dnl codeset.m4
175 dnl ====================
176 dnl serial AM1
177 dnl
178 dnl From Bruno Haible.
179 AC_DEFUN([AM_LANGINFO_CODESET],
180 [
181   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
182     [AC_TRY_LINK([#include <langinfo.h>],
183       [char* cs = nl_langinfo(CODESET);],
184       am_cv_langinfo_codeset=yes,
185       am_cv_langinfo_codeset=no)
186     ])
187   if test $am_cv_langinfo_codeset = yes; then
188     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
189       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
190   fi
191 ])dnl
192 dnl ---------------------------------------------------------------------------
193 dnl AM_LC_MESSAGES version: 4 updated: 2002/10/27 23:21:42
194 dnl --------------
195 dnl Inserted as requested by gettext 0.10.40
196 dnl File from /usr/share/aclocal
197 dnl lcmessage.m4
198 dnl ====================
199 dnl Check whether LC_MESSAGES is available in <locale.h>.
200 dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
201 dnl
202 dnl This file can be copied and used freely without restrictions.  It can
203 dnl be used in projects which are not available under the GNU General Public
204 dnl License or the GNU Library General Public License but which still want
205 dnl to provide support for the GNU gettext functionality.
206 dnl Please note that the actual code of the GNU gettext library is covered
207 dnl by the GNU Library General Public License, and the rest of the GNU
208 dnl gettext package package is covered by the GNU General Public License.
209 dnl They are *not* in the public domain.
210 dnl
211 dnl serial 2
212 dnl
213 AC_DEFUN([AM_LC_MESSAGES],
214   [if test $ac_cv_header_locale_h = yes; then
215     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
216       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
217        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
218     if test $am_cv_val_LC_MESSAGES = yes; then
219       AC_DEFINE(HAVE_LC_MESSAGES, 1,
220         [Define if your <locale.h> file defines LC_MESSAGES.])
221     fi
222   fi])dnl
223 dnl ---------------------------------------------------------------------------
224 dnl AM_PATH_PROG_WITH_TEST version: 8 updated: 2009/01/11 20:31:12
225 dnl ----------------------
226 dnl Inserted as requested by gettext 0.10.40
227 dnl File from /usr/share/aclocal
228 dnl progtest.m4
229 dnl ====================
230 dnl Search path for a program which passes the given test.
231 dnl Ulrich Drepper <drepper@cygnus.com>, 1996.
232 dnl
233 dnl This file can be copied and used freely without restrictions.  It can
234 dnl be used in projects which are not available under the GNU General Public
235 dnl License or the GNU Library General Public License but which still want
236 dnl to provide support for the GNU gettext functionality.
237 dnl Please note that the actual code of the GNU gettext library is covered
238 dnl by the GNU Library General Public License, and the rest of the GNU
239 dnl gettext package package is covered by the GNU General Public License.
240 dnl They are *not* in the public domain.
241 dnl
242 dnl serial 2
243 dnl
244 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
245 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
246 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
247 [# Extract the first word of "$2", so it can be a program name with args.
248 AC_REQUIRE([CF_PATHSEP])
249 set dummy $2; ac_word=[$]2
250 AC_MSG_CHECKING([for $ac_word])
251 AC_CACHE_VAL(ac_cv_path_$1,
252 [case "[$]$1" in
253   [[\\/]*|?:[\\/]]*)
254   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
255   ;;
256   *)
257   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
258   for ac_dir in ifelse([$5], , $PATH, [$5]); do
259     test -z "$ac_dir" && ac_dir=.
260     if test -f $ac_dir/$ac_word$ac_exeext; then
261       if [$3]; then
262         ac_cv_path_$1="$ac_dir/$ac_word$ac_exeext"
263         break
264       fi
265     fi
266   done
267   IFS="$ac_save_ifs"
268 dnl If no 4th arg is given, leave the cache variable unset,
269 dnl so AC_PATH_PROGS will keep looking.
270 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
271 ])dnl
272   ;;
273 esac])dnl
274 $1="$ac_cv_path_$1"
275 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
276   AC_MSG_RESULT([$]$1)
277 else
278   AC_MSG_RESULT(no)
279 fi
280 AC_SUBST($1)dnl
281 ])dnl
282 dnl ---------------------------------------------------------------------------
283 dnl AM_WITH_NLS version: 25 updated: 2012/10/06 08:57:51
284 dnl -----------
285 dnl Inserted as requested by gettext 0.10.40
286 dnl File from /usr/share/aclocal
287 dnl gettext.m4
288 dnl ====================
289 dnl Macro to add for using GNU gettext.
290 dnl Ulrich Drepper <drepper@cygnus.com>, 1995.
291 dnl ====================
292 dnl Modified to use CF_FIND_LINKAGE and CF_ADD_SEARCHPATH, to broaden the
293 dnl range of locations searched.  Retain the same cache-variable naming to
294 dnl allow reuse with the other gettext macros -Thomas E Dickey
295 dnl ====================
296 dnl
297 dnl This file can be copied and used freely without restrictions.  It can
298 dnl be used in projects which are not available under the GNU General Public
299 dnl License or the GNU Library General Public License but which still want
300 dnl to provide support for the GNU gettext functionality.
301 dnl Please note that the actual code of the GNU gettext library is covered
302 dnl by the GNU Library General Public License, and the rest of the GNU
303 dnl gettext package package is covered by the GNU General Public License.
304 dnl They are *not* in the public domain.
305 dnl
306 dnl serial 10
307 dnl
308 dnl Usage: AM_WITH_NLS([TOOLSYMBOL], [NEEDSYMBOL], [LIBDIR], [ENABLED]).
309 dnl If TOOLSYMBOL is specified and is 'use-libtool', then a libtool library
310 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
311 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
312 dnl    AM-DISABLE-SHARED). Otherwise, a static library
313 dnl    $(top_builddir)/intl/libintl.a will be created.
314 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
315 dnl    implementations (in libc or libintl) without the ngettext() function
316 dnl    will be ignored.
317 dnl LIBDIR is used to find the intl libraries.  If empty,
318 dnl    the value `$(top_builddir)/intl/' is used.
319 dnl ENABLED is used to control the default for the related --enable-nls, since
320 dnl    not all application developers want this feature by default, e.g., lynx.
321 dnl
322 dnl The result of the configuration is one of three cases:
323 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
324 dnl    and used.
325 dnl    Catalog format: GNU --> install in $(datadir)
326 dnl    Catalog extension: .mo after installation, .gmo in source tree
327 dnl 2) GNU gettext has been found in the system's C library.
328 dnl    Catalog format: GNU --> install in $(datadir)
329 dnl    Catalog extension: .mo after installation, .gmo in source tree
330 dnl 3) No internationalization, always use English msgid.
331 dnl    Catalog format: none
332 dnl    Catalog extension: none
333 dnl The use of .gmo is historical (it was needed to avoid overwriting the
334 dnl GNU format catalogs when building on a platform with an X/Open gettext),
335 dnl but we keep it in order not to force irrelevant filename changes on the
336 dnl maintainers.
337 dnl
338 AC_DEFUN([AM_WITH_NLS],
339 [AC_MSG_CHECKING([whether NLS is requested])
340   dnl Default is enabled NLS
341   ifelse([$4],,[
342   AC_ARG_ENABLE(nls,
343     [  --disable-nls           do not use Native Language Support],
344     USE_NLS=$enableval, USE_NLS=yes)],[
345   AC_ARG_ENABLE(nls,
346     [  --enable-nls            use Native Language Support],
347     USE_NLS=$enableval, USE_NLS=no)])
348   AC_MSG_RESULT($USE_NLS)
349   AC_SUBST(USE_NLS)
350
351   BUILD_INCLUDED_LIBINTL=no
352   USE_INCLUDED_LIBINTL=no
353   INTLLIBS=
354
355   dnl If we use NLS figure out what method
356   if test "$USE_NLS" = "yes"; then
357     AC_DEFINE(ENABLE_NLS, 1,
358       [Define to 1 if translation of program messages to the user's native language
359  is requested.])
360     AC_MSG_CHECKING([whether included gettext is requested])
361     AC_ARG_WITH(included-gettext,
362       [  --with-included-gettext use the GNU gettext library included here],
363       nls_cv_force_use_gnu_gettext=$withval,
364       nls_cv_force_use_gnu_gettext=no)
365     AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
366
367     nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
368     if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
369       dnl User does not insist on using GNU NLS library.  Figure out what
370       dnl to use.  If GNU gettext is available we use this.  Else we have
371       dnl to fall back to GNU NLS library.
372       CATOBJEXT=NONE
373
374       cf_save_LIBS_1="$LIBS"
375       CF_ADD_LIBS($LIBICONV)
376       AC_CACHE_CHECK([for libintl.h and gettext()], cf_cv_func_gettext,[
377         CF_FIND_LINKAGE(CF__INTL_HEAD,
378         CF__INTL_BODY,
379         intl,
380         cf_cv_func_gettext=yes,
381         cf_cv_func_gettext=no)
382       ])
383       LIBS="$cf_save_LIBS_1"
384
385       if test "$cf_cv_func_gettext" = yes ; then
386         AC_DEFINE(HAVE_LIBINTL_H,1,[Define to 1 if we have libintl.h])
387
388         dnl If an already present or preinstalled GNU gettext() is found,
389         dnl use it.  But if this macro is used in GNU gettext, and GNU
390         dnl gettext is already preinstalled in libintl, we update this
391         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
392         if test "$PACKAGE" != gettext; then
393           AC_DEFINE(HAVE_GETTEXT, 1,
394               [Define if the GNU gettext() function is already present or preinstalled.])
395
396           CF_ADD_INCDIR($cf_cv_header_path_intl)
397
398           if test -n "$cf_cv_library_file_intl" ; then
399             dnl If iconv() is in a separate libiconv library, then anyone
400             dnl linking with libintl{.a,.so} also needs to link with
401             dnl libiconv.
402             INTLLIBS="$cf_cv_library_file_intl $LIBICONV"
403             CF_ADD_LIBDIR($cf_cv_library_path_intl,INTLLIBS)
404           fi
405
406           gt_save_LIBS="$LIBS"
407           LIBS="$LIBS $INTLLIBS"
408           AC_CHECK_FUNCS(dcgettext)
409           LIBS="$gt_save_LIBS"
410
411           dnl Search for GNU msgfmt in the PATH.
412           AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
413               [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
414           AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
415
416           dnl Search for GNU xgettext in the PATH.
417           AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
418               [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
419
420           CATOBJEXT=.gmo
421         fi
422       fi
423
424       if test "$CATOBJEXT" = "NONE"; then
425         dnl GNU gettext is not found in the C library.
426         dnl Fall back on GNU gettext library.
427         nls_cv_use_gnu_gettext=yes
428       fi
429     fi
430
431     if test "$nls_cv_use_gnu_gettext" = "yes"; then
432       if test ! -d $srcdir/intl ; then
433         AC_MSG_ERROR(no NLS library is packaged with this application)
434       fi
435       dnl Mark actions used to generate GNU NLS library.
436       INTLOBJS="\$(GETTOBJS)"
437       AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
438           [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1], :)
439       AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
440       AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
441           [$ac_dir/$ac_word --omit-header /dev/null >/dev/null 2>&1], :)
442       AC_SUBST(MSGFMT)
443       BUILD_INCLUDED_LIBINTL=yes
444       USE_INCLUDED_LIBINTL=yes
445       CATOBJEXT=.gmo
446       INTLLIBS="ifelse([$3],[],\$(top_builddir)/intl,[$3])/libintl.ifelse([$1], use-libtool, [l], [])a $LIBICONV"
447       LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
448     fi
449
450     dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
451     dnl Test whether we really found GNU msgfmt.
452     if test "$GMSGFMT" != ":"; then
453       dnl If it is no GNU msgfmt we define it as : so that the
454       dnl Makefiles still can work.
455       if $GMSGFMT --statistics /dev/null >/dev/null 2>&1; then
456         : ;
457       else
458         AC_MSG_RESULT(
459           [found msgfmt program is not GNU msgfmt; ignore it])
460         GMSGFMT=":"
461       fi
462     fi
463
464     dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
465     dnl Test whether we really found GNU xgettext.
466     if test "$XGETTEXT" != ":"; then
467         dnl If it is no GNU xgettext we define it as : so that the
468         dnl Makefiles still can work.
469       if $XGETTEXT --omit-header /dev/null >/dev/null 2>&1; then
470         : ;
471       else
472         AC_MSG_RESULT(
473           [found xgettext program is not GNU xgettext; ignore it])
474         XGETTEXT=":"
475       fi
476     fi
477
478     dnl We need to process the po/ directory.
479     POSUB=po
480   fi
481
482   AC_OUTPUT_COMMANDS(
483    [for ac_file in $CONFIG_FILES; do
484
485       # Support "outfile[:infile[:infile...]]"
486       case "$ac_file" in
487         *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
488       esac
489
490       # PO directories have a Makefile.in generated from Makefile.inn.
491       case "$ac_file" in */[Mm]akefile.in)
492         # Adjust a relative srcdir.
493         ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
494         ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
495         ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
496         ac_base=`basename $ac_file .in`
497         # In autoconf-2.13 it is called $ac_given_srcdir.
498         # In autoconf-2.50 it is called $srcdir.
499         test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
500
501         case "$ac_given_srcdir" in
502           .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
503           /*) top_srcdir="$ac_given_srcdir" ;;
504           *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
505         esac
506
507         if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
508           rm -f "$ac_dir/POTFILES"
509           test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
510           sed -e "/^#/d" -e "/^[        ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," -e "\$s/\(.*\) \\\\/\1/" < "$ac_given_srcdir/$ac_dir/POTFILES.in" > "$ac_dir/POTFILES"
511           test -n "$as_me" && echo "$as_me: creating $ac_dir/$ac_base" || echo "creating $ac_dir/$ac_base"
512           sed -e "/POTFILES =/r $ac_dir/POTFILES" "$ac_dir/$ac_base.in" > "$ac_dir/$ac_base"
513         fi
514         ;;
515       esac
516     done])
517
518   dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
519   dnl to 'yes' because some of the testsuite requires it.
520   if test "$PACKAGE" = gettext; then
521     BUILD_INCLUDED_LIBINTL=yes
522   fi
523
524   dnl intl/plural.c is generated from intl/plural.y. It requires bison,
525   dnl because plural.y uses bison specific features. It requires at least
526   dnl bison-1.26 because earlier versions generate a plural.c that doesn't
527   dnl compile.
528   dnl bison is only needed for the maintainer (who touches plural.y). But in
529   dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
530   dnl the rule in general Makefile. Now, some people carelessly touch the
531   dnl files or have a broken "make" program, hence the plural.c rule will
532   dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
533   dnl present or too old.
534   if test "$nls_cv_use_gnu_gettext" = "yes"; then
535     AC_CHECK_PROGS([INTLBISON], [bison])
536     if test -z "$INTLBISON"; then
537       ac_verc_fail=yes
538     else
539       dnl Found it, now check the version.
540       AC_MSG_CHECKING([version of bison])
541 changequote(<<,>>)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].*)
546 changequote([,])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
592 dnl ---------------------------------------------------------------------------
593 dnl CF_ACVERSION_CHECK version: 3 updated: 2012/10/03 18:39:53
594 dnl ------------------
595 dnl Conditionally generate script according to whether we're using a given autoconf.
596 dnl
597 dnl $1 = version to compare against
598 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
599 dnl $3 = code to use if AC_ACVERSION is older than $1.
600 define([CF_ACVERSION_CHECK],
601 [
602 ifdef([m4_version_compare],
603 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
604 [CF_ACVERSION_COMPARE(
605 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
606 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
607 dnl ---------------------------------------------------------------------------
608 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
609 dnl --------------------
610 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
611 dnl                      MAJOR2, MINOR2, TERNARY2,
612 dnl                      PRINTABLE2, not FOUND, FOUND)
613 define([CF_ACVERSION_COMPARE],
614 [ifelse(builtin([eval], [$2 < $5]), 1,
615 [ifelse([$8], , ,[$8])],
616 [ifelse([$9], , ,[$9])])])dnl
617 dnl ---------------------------------------------------------------------------
618 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
619 dnl -------------
620 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
621 dnl The second parameter if given makes this macro verbose.
622 dnl
623 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
624 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
625 dnl confused by the quotes (which require backslashes to keep them usable).
626 AC_DEFUN([CF_ADD_CFLAGS],
627 [
628 cf_fix_cppflags=no
629 cf_new_cflags=
630 cf_new_cppflags=
631 cf_new_extra_cppflags=
632
633 for cf_add_cflags in $1
634 do
635 case $cf_fix_cppflags in
636 no)
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         ;;
675 yes)
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         ;;
684 esac
685 done
686
687 if test -n "$cf_new_cflags" ; then
688         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
689         CFLAGS="$CFLAGS $cf_new_cflags"
690 fi
691
692 if test -n "$cf_new_cppflags" ; then
693         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
694         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
695 fi
696
697 if 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"
700 fi
701
702 AC_SUBST(EXTRA_CPPFLAGS)
703
704 ])dnl
705 dnl ---------------------------------------------------------------------------
706 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
707 dnl -------------
708 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
709 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
710 dnl but old versions (and some misinstalled ones) need that.  To make things
711 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
712 dnl the include-path).
713 AC_DEFUN([CF_ADD_INCDIR],
714 [
715 if 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
760 fi
761 ])dnl
762 dnl ---------------------------------------------------------------------------
763 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
764 dnl ----------
765 dnl Add a library, used to enforce consistency.
766 dnl
767 dnl $1 = library to add, without the "-l"
768 dnl $2 = variable to update (default $LIBS)
769 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
770 dnl ---------------------------------------------------------------------------
771 dnl CF_ADD_LIBDIR version: 9 updated: 2010/05/26 16:44:57
772 dnl -------------
773 dnl     Adds to the library-path
774 dnl
775 dnl     Some machines have trouble with multiple -L options.
776 dnl
777 dnl $1 is the (list of) directory(s) to add
778 dnl $2 is the optional name of the variable to update (default LDFLAGS)
779 dnl
780 AC_DEFUN([CF_ADD_LIBDIR],
781 [
782 if 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
804 fi
805 ])dnl
806 dnl ---------------------------------------------------------------------------
807 dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
808 dnl -----------
809 dnl Add one or more libraries, used to enforce consistency.
810 dnl
811 dnl $1 = libraries to add, with the "-l", etc.
812 dnl $2 = variable to update (default $LIBS)
813 AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
814 dnl ---------------------------------------------------------------------------
815 dnl CF_ADD_OPTIONAL_PATH version: 1 updated: 2007/07/29 12:33:33
816 dnl --------------------
817 dnl Add an optional search-path to the compile/link variables.
818 dnl See CF_WITH_PATH
819 dnl
820 dnl $1 = shell variable containing the result of --with-XXX=[DIR]
821 dnl $2 = module to look for.
822 AC_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
833 dnl ---------------------------------------------------------------------------
834 dnl CF_ADD_SEARCHPATH version: 5 updated: 2009/01/11 20:40:21
835 dnl -----------------
836 dnl Set $CPPFLAGS and $LDFLAGS with the directories given via the parameter.
837 dnl They can be either the common root of include- and lib-directories, or the
838 dnl lib-directory (to allow for things like lib64 directories).
839 dnl See also CF_FIND_LINKAGE.
840 dnl
841 dnl $1 is the list of colon-separated directory names to search.
842 dnl $2 is the action to take if a parameter does not yield a directory.
843 AC_DEFUN([CF_ADD_SEARCHPATH],
844 [
845 AC_REQUIRE([CF_PATHSEP])
846 for 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
861 done
862 ])
863 dnl ---------------------------------------------------------------------------
864 dnl CF_ADD_SUBDIR_PATH version: 3 updated: 2010/07/03 20:58:12
865 dnl ------------------
866 dnl Append to a search-list for a nonstandard header/lib-file
867 dnl     $1 = the variable to return as result
868 dnl     $2 = the package name
869 dnl     $3 = the subdirectory, e.g., bin, include or lib
870 dnl $4 = the directory under which we will test for subdirectories
871 dnl $5 = a directory that we do not want $4 to match
872 AC_DEFUN([CF_ADD_SUBDIR_PATH],
873 [
874 test "$4" != "$5" && \
875 test -d "$4" && \
876 ifelse([$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
885 dnl ---------------------------------------------------------------------------
886 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
887 dnl --------------
888 dnl Allow user to disable a normally-on option.
889 AC_DEFUN([CF_ARG_DISABLE],
890 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
891 dnl ---------------------------------------------------------------------------
892 dnl CF_ARG_MSG_ENABLE version: 2 updated: 2000/07/29 19:32:03
893 dnl -----------------
894 dnl Verbose form of AC_ARG_ENABLE:
895 dnl
896 dnl Parameters:
897 dnl $1 = message
898 dnl $2 = option name
899 dnl $3 = help-string
900 dnl $4 = action to perform if option is enabled
901 dnl $5 = action if perform if option is disabled
902 dnl $6 = default option value (either 'yes' or 'no')
903 AC_DEFUN([CF_ARG_MSG_ENABLE],[
904 AC_MSG_CHECKING($1)
905 AC_ARG_ENABLE($2,[$3],,enableval=ifelse($6,,no,$6))
906 AC_MSG_RESULT($enableval)
907 if test "$enableval" != no ; then
908 ifelse($4,,[    :],$4)
909 else
910 ifelse($5,,[    :],$5)
911 fi
912 ])dnl
913 dnl ---------------------------------------------------------------------------
914 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
915 dnl -------------
916 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
917 dnl values.
918 dnl
919 dnl Parameters:
920 dnl $1 = option name
921 dnl $2 = help-string
922 dnl $3 = action to perform if option is not default
923 dnl $4 = action if perform if option is default
924 dnl $5 = default option value (either 'yes' or 'no')
925 AC_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
928 ifelse([$3],,[    :]dnl
929 ,[    $3]) ifelse([$4],,,[
930   else
931     $4])
932   fi],[enableval=$5 ifelse([$4],,,[
933   $4
934 ])dnl
935   ])])dnl
936 dnl ---------------------------------------------------------------------------
937 dnl CF_BUNDLED_INTL version: 17 updated: 2012/10/06 08:57:51
938 dnl ---------------
939 dnl Top-level macro for configuring an application with a bundled copy of
940 dnl the intl and po directories for gettext.
941 dnl
942 dnl $1 specifies either Makefile or makefile, defaulting to the former.
943 dnl $2 if nonempty sets the option to --enable-nls rather than to --disable-nls
944 dnl
945 dnl Sets variables which can be used to substitute in makefiles:
946 dnl     GT_YES       - "#" comment unless building intl library, otherwise empty
947 dnl     GT_NO        - "#" comment if building intl library, otherwise empty
948 dnl     INTLDIR_MAKE - to make ./intl directory
949 dnl     MSG_DIR_MAKE - to make ./po directory
950 dnl     SUB_MAKEFILE - list of makefiles in ./intl, ./po directories
951 dnl
952 dnl Defines:
953 dnl     HAVE_LIBGETTEXT_H if we're using ./intl
954 dnl     NLS_TEXTDOMAIN
955 dnl
956 dnl Environment:
957 dnl     ALL_LINGUAS if set, lists the root names of the ".po" files.
958 dnl     CONFIG_H assumed to be "config.h"
959 dnl     PACKAGE must be set, used as default for textdomain
960 dnl     VERSION may be set, otherwise extract from "VERSION" file.
961 dnl
962 AC_DEFUN([CF_BUNDLED_INTL],[
963 cf_makefile=ifelse($1,,Makefile,$1)
964
965 dnl Set of available languages (based on source distribution).  Note that
966 dnl setting $LINGUAS overrides $ALL_LINGUAS.  Some environments set $LINGUAS
967 dnl rather than $LC_ALL
968 test -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}
972 AC_SUBST(CONFIG_H)
973
974 if test -z "$PACKAGE" ; then
975         AC_MSG_ERROR([[CF_BUNDLED_INTL] used without setting [PACKAGE] variable])
976 fi
977
978 if test -z "$VERSION" ; then
979 if test -f $srcdir/VERSION ; then
980         VERSION=`sed -e '2,$d' $srcdir/VERSION|cut -f1`
981 else
982         VERSION=unknown
983 fi
984 fi
985 AC_SUBST(VERSION)
986
987 AM_GNU_GETTEXT(,,,[$2])
988
989 if 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)
996 fi
997
998 INTLDIR_MAKE=
999 MSG_DIR_MAKE=
1000 SUB_MAKEFILE=
1001
1002 dnl this updates SUB_MAKEFILE and MSG_DIR_MAKE:
1003 CF_OUR_MESSAGES($1)
1004
1005 if 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
1025 else
1026         INTLDIR_MAKE="#"
1027         if test "$USE_NLS" = yes ; then
1028                 AC_CHECK_HEADERS(libintl.h)
1029         fi
1030 fi
1031
1032 if test -z "$INTLDIR_MAKE" ; then
1033         CPPFLAGS="$CPPFLAGS -I../intl"
1034 fi
1035
1036 dnl FIXME:  we use this in lynx (the alternative is a spurious dependency upon
1037 dnl GNU make)
1038 if test "$BUILD_INCLUDED_LIBINTL" = yes ; then
1039         GT_YES="#"
1040         GT_NO=
1041 else
1042         GT_YES=
1043         GT_NO="#"
1044 fi
1045
1046 AC_SUBST(INTLDIR_MAKE)
1047 AC_SUBST(MSG_DIR_MAKE)
1048 AC_SUBST(GT_YES)
1049 AC_SUBST(GT_NO)
1050
1051 dnl FIXME:  the underlying AM_GNU_GETTEXT macro either needs some fixes or a
1052 dnl little documentation.  It doesn't define anything so that we can ifdef our
1053 dnl own code, except ENABLE_NLS, which is too vague to be of any use.
1054
1055 if 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
1064 fi
1065 ])dnl
1066 dnl ---------------------------------------------------------------------------
1067 dnl CF_CC_ENV_FLAGS version: 1 updated: 2012/10/03 05:25:49
1068 dnl ---------------
1069 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
1070 dnl into CC.  This will not help with broken scripts that wrap the compiler with
1071 dnl options, but eliminates a more common category of user confusion.
1072 AC_DEFUN([CF_CC_ENV_FLAGS],
1073 [
1074 # This should have been defined by AC_PROG_CC
1075 : ${CC:=cc}
1076
1077 AC_MSG_CHECKING(\$CC variable)
1078 case "$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         ;;
1090 esac
1091 ])dnl
1092 dnl ---------------------------------------------------------------------------
1093 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
1094 dnl --------------
1095 dnl Check if we're accidentally using a cache from a different machine.
1096 dnl Derive the system name, as a check for reusing the autoconf cache.
1097 dnl
1098 dnl If we've packaged config.guess and config.sub, run that (since it does a
1099 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
1100 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
1101 dnl which is useful in cross-compiles.
1102 dnl
1103 dnl Note: we would use $ac_config_sub, but that is one of the places where
1104 dnl autoconf 2.5x broke compatibility with autoconf 2.13
1105 AC_DEFUN([CF_CHECK_CACHE],
1106 [
1107 if 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"
1110 else
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
1115 fi
1116 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
1117 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
1118
1119 test -z "$system_name" && system_name="$cf_cv_system_name"
1120 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
1121
1122 if 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.")
1125 fi
1126 ])dnl
1127 dnl ---------------------------------------------------------------------------
1128 dnl CF_CLANG_COMPILER version: 1 updated: 2012/06/16 14:55:39
1129 dnl -----------------
1130 dnl Check if the given compiler is really clang.  clang's C driver defines
1131 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
1132 dnl not ignore some gcc options.
1133 dnl
1134 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1135 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1136 dnl the wrappers for gcc and g++ warnings.
1137 dnl
1138 dnl $1 = GCC (default) or GXX
1139 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1140 dnl $3 = CFLAGS (default) or CXXFLAGS
1141 AC_DEFUN([CF_CLANG_COMPILER],[
1142 ifelse([$2],,CLANG_COMPILER,[$2])=no
1143
1144 if 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
1151 make an error
1152 #endif
1153 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
1154 cf_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]))
1158 fi
1159 ])
1160 dnl ---------------------------------------------------------------------------
1161 dnl CF_CURSES_CHTYPE version: 8 updated: 2012/10/06 08:57:51
1162 dnl ----------------
1163 dnl Test if curses defines 'chtype' (usually a 'long' type for SysV curses).
1164 AC_DEFUN([CF_CURSES_CHTYPE],
1165 [
1166 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1167 AC_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])])
1172 if 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
1182 fi
1183 ])dnl
1184 dnl ---------------------------------------------------------------------------
1185 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
1186 dnl ----------------
1187 dnl Tie together the configure-script macros for curses.  It may be ncurses,
1188 dnl but unless asked, we do not make a special search for ncurses.  However,
1189 dnl still check for the ncurses version number, for use in other macros.
1190 AC_DEFUN([CF_CURSES_CONFIG],
1191 [
1192 CF_CURSES_CPPFLAGS
1193 CF_NCURSES_VERSION
1194 CF_CURSES_LIBS
1195 ])dnl
1196 dnl ---------------------------------------------------------------------------
1197 dnl CF_CURSES_CPPFLAGS version: 11 updated: 2011/04/09 14:51:08
1198 dnl ------------------
1199 dnl Look for the curses headers.
1200 AC_DEFUN([CF_CURSES_CPPFLAGS],[
1201
1202 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
1203 cf_cv_curses_incdir=no
1204 case $host_os in #(vi
1205 hpux10.*) #(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         ;;
1212 sunos3*|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         ;;
1220 esac
1221 ])
1222 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
1223
1224 CF_CURSES_HEADER
1225 CF_TERM_HEADER
1226 ])dnl
1227 dnl ---------------------------------------------------------------------------
1228 dnl CF_CURSES_FUNCS version: 17 updated: 2011/05/14 16:07:29
1229 dnl ---------------
1230 dnl Curses-functions are a little complicated, since a lot of them are macros.
1231 AC_DEFUN([CF_CURSES_FUNCS],
1232 [
1233 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1234 AC_REQUIRE([CF_XOPEN_CURSES])
1235 AC_REQUIRE([CF_CURSES_TERM_H])
1236 AC_REQUIRE([CF_CURSES_UNCTRL_H])
1237 for cf_func in $1
1238 do
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}
1248 long foo = (long)(&${cf_func});
1249 if (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
1264 done
1265 ])dnl
1266 dnl ---------------------------------------------------------------------------
1267 dnl CF_CURSES_HEADER version: 3 updated: 2011/05/01 19:47:45
1268 dnl ----------------
1269 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1270 dnl variations of ncurses' installs.
1271 dnl
1272 dnl $1 = ncurses when looking for ncurses, or is empty
1273 AC_DEFUN([CF_CURSES_HEADER],[
1274 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
1275 cf_cv_ncurses_header=none
1276 for 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])
1281 do
1282 AC_TRY_COMPILE([#include <${cf_header}>],
1283         [initscr(); tgoto("?", 0,0)],
1284         [cf_cv_ncurses_header=$cf_header; break],[])
1285 done
1286 ])
1287
1288 if test "$cf_cv_ncurses_header" = none ; then
1289         AC_MSG_ERROR(No curses header-files found)
1290 fi
1291
1292 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
1293 AC_CHECK_HEADERS($cf_cv_ncurses_header)
1294 ])dnl
1295 dnl ---------------------------------------------------------------------------
1296 dnl CF_CURSES_LIBS version: 36 updated: 2012/07/07 21:02:48
1297 dnl --------------
1298 dnl Look for the curses libraries.  Older curses implementations may require
1299 dnl termcap/termlib to be linked as well.  Call CF_CURSES_CPPFLAGS first.
1300 AC_DEFUN([CF_CURSES_LIBS],[
1301
1302 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1303 AC_MSG_CHECKING(if we have identified curses libraries)
1304 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1305     [initscr(); tgoto("?", 0,0)],
1306     cf_result=yes,
1307     cf_result=no)
1308 AC_MSG_RESULT($cf_result)
1309
1310 if test "$cf_result" = no ; then
1311 case $host_os in #(vi
1312 freebsd*) #(vi
1313     AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
1314     ;;
1315 hpux10.*) #(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     ;;
1334 linux*)
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     ;;
1349 sunos3*|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     ;;
1359 esac
1360
1361 if 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
1415 fi
1416 fi
1417
1418 ])dnl
1419 dnl ---------------------------------------------------------------------------
1420 dnl CF_CURSES_TERM_H version: 10 updated: 2012/10/06 08:57:51
1421 dnl ----------------
1422 dnl SVr4 curses should have term.h as well (where it puts the definitions of
1423 dnl the low-level interface).  This may not be true in old/broken implementations,
1424 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
1425 dnl running with Solaris 2.5.1).
1426 AC_DEFUN([CF_CURSES_TERM_H],
1427 [
1428 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1429
1430 AC_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
1435 cf_header_list="term.h ncurses/term.h ncursesw/term.h"
1436
1437 case ${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         ;;
1442 esac
1443
1444 for cf_header in $cf_header_list
1445 do
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])
1453 done
1454
1455 case $cf_cv_term_header in #(vi
1456 no)
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
1466 make 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         ;;
1474 esac
1475 ])
1476
1477 case $cf_cv_term_header in #(vi
1478 term.h) #(vi
1479         AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
1480         ;;
1481 ncurses/term.h) #(vi
1482         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
1483         ;;
1484 ncursesw/term.h)
1485         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
1486         ;;
1487 esac
1488 ])dnl
1489 dnl ---------------------------------------------------------------------------
1490 dnl CF_CURSES_UNCTRL_H version: 2 updated: 2012/10/06 08:57:51
1491 dnl ------------------
1492 dnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
1493 dnl may put it in a subdirectory (along with ncurses' other headers, of
1494 dnl course).  Packages which put the headers in inconsistent locations are
1495 dnl broken).
1496 AC_DEFUN([CF_CURSES_UNCTRL_H],
1497 [
1498 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1499
1500 AC_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
1505 cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
1506
1507 case ${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         ;;
1512 esac
1513
1514 for cf_header in $cf_header_list
1515 do
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])
1523 done
1524
1525 case $cf_cv_unctrl_header in #(vi
1526 no)
1527         AC_MSG_WARN(unctrl.h header not found)
1528         ;;
1529 esac
1530 ])
1531
1532 case $cf_cv_unctrl_header in #(vi
1533 unctrl.h) #(vi
1534         AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
1535         ;;
1536 ncurses/unctrl.h) #(vi
1537         AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
1538         ;;
1539 ncursesw/unctrl.h)
1540         AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
1541         ;;
1542 esac
1543 ])dnl
1544 dnl ---------------------------------------------------------------------------
1545 dnl CF_CURSES_WACS_MAP version: 6 updated: 2012/10/06 08:57:51
1546 dnl ------------------
1547 dnl Check for likely values of wacs_map[].
1548 AC_DEFUN([CF_CURSES_WACS_MAP],
1549 [
1550 AC_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
1564 test "$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
1566 dnl ---------------------------------------------------------------------------
1567 dnl CF_CURSES_WACS_SYMBOLS version: 2 updated: 2012/10/06 08:57:51
1568 dnl ----------------------
1569 dnl Do a check to see if the WACS_xxx constants are defined compatibly with
1570 dnl X/Open Curses.  In particular, NetBSD's implementation of the WACS_xxx
1571 dnl constants is broken since those constants do not point to cchar_t's.
1572 AC_DEFUN([CF_CURSES_WACS_SYMBOLS],
1573 [
1574 AC_REQUIRE([CF_CURSES_WACS_MAP])
1575
1576 AC_CACHE_CHECK(for wide alternate character constants, cf_cv_curses_wacs_symbols,[
1577 cf_cv_curses_wacs_symbols=no
1578 if test "$cf_cv_curses_wacs_map" != unknown
1579 then
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])
1588 else
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])
1596 fi
1597 ])
1598
1599 test "$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
1601 dnl ---------------------------------------------------------------------------
1602 dnl CF_CURSES_WGETPARENT version: 3 updated: 2012/10/06 08:57:51
1603 dnl --------------------
1604 dnl Check for curses support for directly determining the parent of a given
1605 dnl window.  Some implementations make this difficult, so we provide for
1606 dnl defining an application-specific function that gives this functionality.
1607 dnl
1608 dnl $1 = name of function to use if the feature is missing
1609 AC_DEFUN([CF_CURSES_WGETPARENT],[
1610 CF_CURSES_FUNCS(wgetparent)
1611 if test "x$cf_cv_func_wgetparent" != xyes
1612 then
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
1623 fi
1624 ])dnl
1625 dnl ---------------------------------------------------------------------------
1626 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
1627 dnl ----------
1628 dnl "dirname" is not portable, so we fake it with a shell script.
1629 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
1630 dnl ---------------------------------------------------------------------------
1631 dnl CF_DISABLE_ECHO version: 12 updated: 2012/10/06 16:30:28
1632 dnl ---------------
1633 dnl You can always use "make -n" to see the actual options, but it's hard to
1634 dnl pick out/analyze warning messages when the compile-line is long.
1635 dnl
1636 dnl Sets:
1637 dnl     ECHO_LT - symbol to control if libtool is verbose
1638 dnl     ECHO_LD - symbol to prefix "cc -o" lines
1639 dnl     RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1640 dnl     SHOW_CC - symbol to put before explicit "cc -c" lines
1641 dnl     ECHO_CC - symbol to put before any "cc" line
1642 dnl
1643 AC_DEFUN([CF_DISABLE_ECHO],[
1644 AC_MSG_CHECKING(if you want to see long compiling messages)
1645 CF_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 ])
1660 AC_MSG_RESULT($enableval)
1661 AC_SUBST(ECHO_LT)
1662 AC_SUBST(ECHO_LD)
1663 AC_SUBST(RULE_CC)
1664 AC_SUBST(SHOW_CC)
1665 AC_SUBST(ECHO_CC)
1666 ])dnl
1667 dnl ---------------------------------------------------------------------------
1668 dnl CF_DISABLE_LIBTOOL_VERSION version: 1 updated: 2010/05/15 15:45:59
1669 dnl --------------------------
1670 dnl Check if we should use the libtool 1.5 feature "-version-number" instead of
1671 dnl the older "-version-info" feature.  The newer feature allows us to use
1672 dnl version numbering on shared libraries which make them compatible with
1673 dnl various systems.
1674 AC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
1675 [
1676 AC_MSG_CHECKING(if libtool -version-number should be used)
1677 CF_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])
1681 AC_MSG_RESULT($cf_libtool_version)
1682
1683 if test "$cf_libtool_version" = yes ; then
1684         LIBTOOL_VERSION="-version-number"
1685 else
1686         LIBTOOL_VERSION="-version-info"
1687 fi
1688
1689 AC_SUBST(LIBTOOL_VERSION)
1690 ])dnl
1691 dnl ---------------------------------------------------------------------------
1692 dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
1693 dnl ---------------------
1694 dnl The rpath-hack makes it simpler to build programs, particularly with the
1695 dnl *BSD ports which may have essential libraries in unusual places.  But it
1696 dnl can interfere with building an executable for the base system.  Use this
1697 dnl option in that case.
1698 AC_DEFUN([CF_DISABLE_RPATH_HACK],
1699 [
1700 AC_MSG_CHECKING(if rpath-hack should be disabled)
1701 CF_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])
1705 AC_MSG_RESULT($cf_disable_rpath_hack)
1706 if test "$cf_disable_rpath_hack" = no ; then
1707         CF_RPATH_HACK
1708 fi
1709 ])
1710 dnl ---------------------------------------------------------------------------
1711 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
1712 dnl ---------------
1713 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
1714 dnl prefer a standard location, and use -L options only if we do not find the
1715 dnl library in the standard library location(s).
1716 dnl     $1 = library name
1717 dnl     $2 = library class, usually the same as library name
1718 dnl     $3 = includes
1719 dnl     $4 = code fragment to compile/link
1720 dnl     $5 = corresponding function-name
1721 dnl     $6 = flag, nonnull if failure should not cause an error-exit
1722 dnl
1723 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
1724 dnl to use a -L option.
1725 AC_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                 ])
1753 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
1754 ifelse($6,,[
1755 if test $cf_found_library = no ; then
1756         AC_MSG_ERROR(Cannot link $1 library)
1757 fi
1758 ])
1759 ])dnl
1760 dnl ---------------------------------------------------------------------------
1761 dnl CF_FIND_LINKAGE version: 19 updated: 2010/05/29 16:31:02
1762 dnl ---------------
1763 dnl Find a library (specifically the linkage used in the code fragment),
1764 dnl searching for it if it is not already in the library path.
1765 dnl See also CF_ADD_SEARCHPATH.
1766 dnl
1767 dnl Parameters (4-on are optional):
1768 dnl     $1 = headers for library entrypoint
1769 dnl     $2 = code fragment for library entrypoint
1770 dnl     $3 = the library name without the "-l" option or ".so" suffix.
1771 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1772 dnl     $5 = action to perform if not successful
1773 dnl     $6 = module name, if not the same as the library name
1774 dnl     $7 = extra libraries
1775 dnl
1776 dnl Sets these variables:
1777 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1778 dnl     $cf_cv_header_path_$3 - include-directory if needed
1779 dnl     $cf_cv_library_path_$3 - library-directory if needed
1780 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1781 AC_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.
1785 cf_cv_header_path_$3=
1786 cf_cv_library_path_$3=
1787
1788 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1789
1790 cf_save_LIBS="$LIBS"
1791
1792 AC_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
1798 LIBS="-l$3 $7 $cf_save_LIBS"
1799
1800 AC_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
1878 LIBS="$cf_save_LIBS"
1879
1880 if test "$cf_cv_find_linkage_$3" = yes ; then
1881 ifelse([$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])
1886 else
1887 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1888 fi
1889 ])dnl
1890 dnl ---------------------------------------------------------------------------
1891 dnl CF_FUNC_WAIT version: 3 updated: 2012/10/06 08:57:51
1892 dnl ------------
1893 dnl Test for the presence of <sys/wait.h>, 'union wait', arg-type of 'wait()'
1894 dnl and/or 'waitpid()'.
1895 dnl
1896 dnl Note that we cannot simply grep for 'union wait' in the wait.h file,
1897 dnl because some Posix systems turn this on only when a BSD variable is
1898 dnl defined.
1899 dnl
1900 dnl I don't use AC_HEADER_SYS_WAIT, because it defines HAVE_SYS_WAIT_H, which
1901 dnl would conflict with an attempt to test that header directly.
1902 dnl
1903 AC_DEFUN([CF_FUNC_WAIT],
1904 [
1905 AC_REQUIRE([CF_UNION_WAIT])
1906 if 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
1928 fi
1929 ])dnl
1930 dnl ---------------------------------------------------------------------------
1931 dnl CF_GCC_ATTRIBUTES version: 16 updated: 2012/10/02 20:55:03
1932 dnl -----------------
1933 dnl Test for availability of useful gcc __attribute__ directives to quiet
1934 dnl compiler warnings.  Though useful, not all are supported -- and contrary
1935 dnl to documentation, unrecognized directives cause older compilers to barf.
1936 AC_DEFUN([CF_GCC_ATTRIBUTES],
1937 [
1938 if test "$GCC" = yes
1939 then
1940 cat > 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
1953 EOF
1954 if test "$GCC" = yes
1955 then
1956         AC_CHECKING([for $CC __attribute__ directives])
1957 cat > 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
1972 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1973 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1974 extern void foo(void) GCC_NORETURN;
1975 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1976 EOF
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
1990 EOF
1991                         ;;
1992                 scanf) #(vi
1993                         cf_scanf_attribute=yes
1994                         cat >conftest.h <<EOF
1995 #define GCC_$cf_ATTRIBUTE 1
1996 EOF
1997                         ;;
1998                 *) #(vi
1999                         cat >conftest.h <<EOF
2000 #define GCC_$cf_ATTRIBUTE $cf_directive
2001 EOF
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
2034 else
2035         fgrep define conftest.i >>confdefs.h
2036 fi
2037 rm -rf conftest*
2038 fi
2039 ])dnl
2040 dnl ---------------------------------------------------------------------------
2041 dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
2042 dnl --------------
2043 dnl Find version of gcc
2044 AC_DEFUN([CF_GCC_VERSION],[
2045 AC_REQUIRE([AC_PROG_CC])
2046 GCC_VERSION=none
2047 if 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)
2052 fi
2053 ])dnl
2054 dnl ---------------------------------------------------------------------------
2055 dnl CF_GCC_WARNINGS version: 29 updated: 2012/06/16 14:55:39
2056 dnl ---------------
2057 dnl Check if the compiler supports useful warning options.  There's a few that
2058 dnl we don't use, simply because they're too noisy:
2059 dnl
2060 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
2061 dnl     -Wredundant-decls (system headers make this too noisy)
2062 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
2063 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
2064 dnl             is enabled for ncurses using "--enable-const".
2065 dnl     -pedantic
2066 dnl
2067 dnl Parameter:
2068 dnl     $1 is an optional list of gcc warning flags that a particular
2069 dnl             application might want to use, e.g., "no-unused" for
2070 dnl             -Wno-unused
2071 dnl Special:
2072 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
2073 dnl
2074 AC_DEFUN([CF_GCC_WARNINGS],
2075 [
2076 AC_REQUIRE([CF_GCC_VERSION])
2077 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
2078 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
2079
2080 cat > conftest.$ac_ext <<EOF
2081 #line __oline__ "${as_me:-configure}"
2082 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
2083 EOF
2084
2085 if test "$INTEL_COMPILER" = yes
2086 then
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
2120 elif test "$GCC" = yes
2121 then
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"
2166 fi
2167 rm -rf conftest*
2168
2169 AC_SUBST(EXTRA_CFLAGS)
2170 ])dnl
2171 dnl ---------------------------------------------------------------------------
2172 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
2173 dnl -------------
2174 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
2175 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
2176 dnl (or misfeature) of glibc2, which breaks portability of many applications,
2177 dnl since it is interwoven with GNU extensions.
2178 dnl
2179 dnl Well, yes we could work around it...
2180 AC_DEFUN([CF_GNU_SOURCE],
2181 [
2182 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
2183 AC_TRY_COMPILE([#include <sys/types.h>],[
2184 #ifndef _XOPEN_SOURCE
2185 make 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
2192 make an error
2193 #endif],
2194         [cf_cv_gnu_source=no],
2195         [cf_cv_gnu_source=yes])
2196         CPPFLAGS="$cf_save"
2197         ])
2198 ])
2199 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
2200 ])dnl
2201 dnl ---------------------------------------------------------------------------
2202 dnl CF_HEADERS_SH version: 1 updated: 2007/07/04 15:37:05
2203 dnl -------------
2204 dnl Setup variables needed to construct headers-sh
2205 AC_DEFUN([CF_HEADERS_SH],[
2206 PACKAGE_PREFIX=$1
2207 PACKAGE_CONFIG=$2
2208 AC_SUBST(PACKAGE_PREFIX)
2209 AC_SUBST(PACKAGE_CONFIG)
2210 EXTRA_OUTPUT="$EXTRA_OUTPUT headers-sh:$srcdir/headers-sh.in"
2211 ])
2212 dnl ---------------------------------------------------------------------------
2213 dnl CF_HEADER_PATH version: 12 updated: 2010/05/05 05:22:40
2214 dnl --------------
2215 dnl Construct a search-list of directories for a nonstandard header-file
2216 dnl
2217 dnl Parameters
2218 dnl     $1 = the variable to return as result
2219 dnl     $2 = the package name
2220 AC_DEFUN([CF_HEADER_PATH],
2221 [
2222 $1=
2223
2224 # collect the current set of include-directories from compiler flags
2225 cf_header_path_list=""
2226 if 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
2237 fi
2238
2239 # add the variations for the package we are looking for
2240 CF_SUBDIR_PATH($1,$2,include)
2241
2242 test "$includedir" != NONE && \
2243 test "$includedir" != "/usr/include" && \
2244 test -d "$includedir" && {
2245         test -d $includedir &&    $1="[$]$1 $includedir"
2246         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
2247 }
2248
2249 test "$oldincludedir" != NONE && \
2250 test "$oldincludedir" != "/usr/include" && \
2251 test -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
2258 dnl ---------------------------------------------------------------------------
2259 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
2260 dnl -----------------
2261 dnl Check if the given compiler is really the Intel compiler for Linux.  It
2262 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
2263 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2264 dnl
2265 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2266 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2267 dnl the wrappers for gcc and g++ warnings.
2268 dnl
2269 dnl $1 = GCC (default) or GXX
2270 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2271 dnl $3 = CFLAGS (default) or CXXFLAGS
2272 AC_DEFUN([CF_INTEL_COMPILER],[
2273 ifelse([$2],,INTEL_COMPILER,[$2])=no
2274
2275 if 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
2284 make an error
2285 #endif
2286 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
2287 cf_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
2293 fi
2294 ])dnl
2295 dnl ---------------------------------------------------------------------------
2296 dnl CF_LARGEFILE version: 8 updated: 2012/10/06 08:57:51
2297 dnl ------------
2298 dnl Add checks for large file support.
2299 AC_DEFUN([CF_LARGEFILE],[
2300 ifdef([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 ])
2334 dnl ---------------------------------------------------------------------------
2335 dnl CF_LD_RPATH_OPT version: 5 updated: 2011/07/17 14:48:41
2336 dnl ---------------
2337 dnl For the given system and compiler, find the compiler flags to pass to the
2338 dnl loader to use the "rpath" feature.
2339 AC_DEFUN([CF_LD_RPATH_OPT],
2340 [
2341 AC_REQUIRE([CF_CHECK_CACHE])
2342
2343 LD_RPATH_OPT=
2344 AC_MSG_CHECKING(for an rpath option)
2345 case $cf_cv_system_name in #(vi
2346 irix*) #(vi
2347         if test "$GCC" = yes; then
2348                 LD_RPATH_OPT="-Wl,-rpath,"
2349         else
2350                 LD_RPATH_OPT="-rpath "
2351         fi
2352         ;;
2353 linux*|gnu*|k*bsd*-gnu) #(vi
2354         LD_RPATH_OPT="-Wl,-rpath,"
2355         ;;
2356 openbsd[[2-9]].*|mirbsd*) #(vi
2357         LD_RPATH_OPT="-Wl,-rpath,"
2358         ;;
2359 dragonfly*|freebsd*) #(vi
2360         LD_RPATH_OPT="-rpath "
2361         ;;
2362 netbsd*) #(vi
2363         LD_RPATH_OPT="-Wl,-rpath,"
2364         ;;
2365 osf*|mls+*) #(vi
2366         LD_RPATH_OPT="-rpath "
2367         ;;
2368 solaris2*) #(vi
2369         LD_RPATH_OPT="-R"
2370         ;;
2371 *)
2372         ;;
2373 esac
2374 AC_MSG_RESULT($LD_RPATH_OPT)
2375
2376 case "x$LD_RPATH_OPT" in #(vi
2377 x-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         ;;
2386 esac
2387 ])dnl
2388 dnl ---------------------------------------------------------------------------
2389 dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
2390 dnl ---------------
2391 dnl Construct a search-list of directories for a nonstandard library-file
2392 dnl
2393 dnl Parameters
2394 dnl     $1 = the variable to return as result
2395 dnl     $2 = the package name
2396 AC_DEFUN([CF_LIBRARY_PATH],
2397 [
2398 $1=
2399 cf_library_path_list=""
2400 if 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
2411 fi
2412
2413 CF_SUBDIR_PATH($1,$2,lib)
2414
2415 $1="$cf_library_path_list [$]$1"
2416 ])dnl
2417 dnl ---------------------------------------------------------------------------
2418 dnl CF_LIB_PREFIX version: 9 updated: 2012/01/21 19:28:10
2419 dnl -------------
2420 dnl Compute the library-prefix for the given host system
2421 dnl $1 = variable to set
2422 define([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
2431 ifelse($1,,,[$1=$LIB_PREFIX])
2432         AC_SUBST(LIB_PREFIX)
2433 ])dnl
2434 dnl ---------------------------------------------------------------------------
2435 dnl CF_MAKEFLAGS version: 14 updated: 2011/03/31 19:29:46
2436 dnl ------------
2437 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
2438 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
2439 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
2440 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
2441 AC_DEFUN([CF_MAKEFLAGS],
2442 [
2443 AC_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
2448 SHELL = /bin/sh
2449 all :
2450         @ echo '.$cf_option'
2451 CF_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
2472 AC_SUBST(cf_cv_makeflags)
2473 ])dnl
2474 dnl ---------------------------------------------------------------------------
2475 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
2476 dnl ------------
2477 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
2478 dnl a monocase filesystem.
2479 AC_DEFUN([CF_MAKE_TAGS],[
2480 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
2481
2482 AC_CHECK_PROGS(CTAGS, exctags ctags)
2483 AC_CHECK_PROGS(ETAGS, exetags etags)
2484
2485 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
2486
2487 if test "$cf_cv_mixedcase" = yes ; then
2488         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
2489 else
2490         MAKE_UPPER_TAGS=no
2491 fi
2492
2493 if test "$MAKE_UPPER_TAGS" = yes ; then
2494         MAKE_UPPER_TAGS=
2495 else
2496         MAKE_UPPER_TAGS="#"
2497 fi
2498
2499 if test "$MAKE_LOWER_TAGS" = yes ; then
2500         MAKE_LOWER_TAGS=
2501 else
2502         MAKE_LOWER_TAGS="#"
2503 fi
2504
2505 AC_SUBST(CTAGS)
2506 AC_SUBST(ETAGS)
2507
2508 AC_SUBST(MAKE_UPPER_TAGS)
2509 AC_SUBST(MAKE_LOWER_TAGS)
2510 ])dnl
2511 dnl ---------------------------------------------------------------------------
2512 dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
2513 dnl -----------
2514 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
2515 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
2516 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
2517 AC_DEFUN([CF_MATH_LIB],
2518 [
2519 AC_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])])
2528 if test "$cf_cv_need_libm" = yes
2529 then
2530 ifelse($1,,[
2531         CF_ADD_LIB(m)
2532 ],[$1=-lm])
2533 fi
2534 ])
2535 dnl ---------------------------------------------------------------------------
2536 dnl CF_MBSTATE_T version: 4 updated: 2012/10/06 08:57:51
2537 dnl ------------
2538 dnl Check if mbstate_t is declared, and if so, which header file.
2539 dnl This (including wchar.h) is needed on Tru64 5.0 to declare mbstate_t,
2540 dnl as well as include stdio.h to work around a misuse of varargs in wchar.h
2541 AC_DEFUN([CF_MBSTATE_T],
2542 [
2543 AC_CACHE_CHECK(if we must include wchar.h to declare mbstate_t,cf_cv_mbstate_t,[
2544 AC_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
2563 if test "$cf_cv_mbstate_t" = yes ; then
2564         AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
2565 fi
2566
2567 if test "$cf_cv_mbstate_t" != unknown ; then
2568         AC_DEFINE(HAVE_MBSTATE_T,1,[Define to 1 if mbstate_t is declared])
2569 fi
2570 ])dnl
2571 dnl ---------------------------------------------------------------------------
2572 dnl CF_MIXEDCASE_FILENAMES version: 4 updated: 2012/10/02 20:55:03
2573 dnl ----------------------
2574 dnl Check if the file-system supports mixed-case filenames.  If we're able to
2575 dnl create a lowercase name and see it as uppercase, it doesn't support that.
2576 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
2577 [
2578 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
2579 if 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
2588 else
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
2597 fi
2598 ])
2599 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
2600 ])dnl
2601 dnl ---------------------------------------------------------------------------
2602 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
2603 dnl ----------
2604 dnl Write a debug message to config.log, along with the line number in the
2605 dnl configure script.
2606 AC_DEFUN([CF_MSG_LOG],[
2607 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
2608 ])dnl
2609 dnl ---------------------------------------------------------------------------
2610 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
2611 dnl -------------------
2612 dnl Check if we can compile with ncurses' header file
2613 dnl $1 is the cache variable to set
2614 dnl $2 is the header-file to include
2615 dnl $3 is the root name (ncurses or ncursesw)
2616 AC_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 ])[
2630 printf("%s\n", NCURSES_VERSION);
2631 #else
2632 #ifdef __NCURSES_H
2633 printf("old\n");
2634 #else
2635         make an error
2636 #endif
2637 #endif
2638         ]
2639         ,[$1=$2]
2640         ,[$1=no])
2641 ])dnl
2642 dnl ---------------------------------------------------------------------------
2643 dnl CF_NCURSES_CONFIG version: 10 updated: 2012/10/06 08:57:51
2644 dnl -----------------
2645 dnl Tie together the configure-script macros for ncurses.
2646 dnl Prefer the "-config" script from ncurses 6.x, to simplify analysis.
2647 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
2648 dnl
2649 dnl $1 is the root library name (default: "ncurses")
2650 AC_DEFUN([CF_NCURSES_CONFIG],
2651 [
2652 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
2653
2654 echo "Looking for ${cf_ncuconfig_root}-config"
2655
2656 CF_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
2660 if test "$NCURSES_CONFIG" != none ; then
2661
2662 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
2663 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
2664
2665 # even with config script, some packages use no-override for curses.h
2666 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
2667
2668 dnl like CF_NCURSES_CPPFLAGS
2669 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2670
2671 dnl like CF_NCURSES_LIBS
2672 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
2673 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2674
2675 dnl like CF_NCURSES_VERSION
2676 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
2677
2678 else
2679
2680 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
2681 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
2682
2683 fi
2684 ])dnl
2685 dnl ---------------------------------------------------------------------------
2686 dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
2687 dnl -------------------
2688 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
2689 dnl the CPPFLAGS variable so we can include its header.
2690 dnl
2691 dnl The header files may be installed as either curses.h, or ncurses.h (would
2692 dnl be obsolete, except that some packagers prefer this name to distinguish it
2693 dnl from a "native" curses implementation).  If not installed for overwrite,
2694 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2695 dnl /usr/include/ncurses), but someone may have installed overwriting the
2696 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
2697 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2698 dnl the header.
2699 dnl
2700 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2701 dnl is already in the include-path, don't even bother with this, since we cannot
2702 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
2703 dnl
2704 dnl The optional parameter gives the root name of the library, in case it is
2705 dnl not installed as the default curses library.  That is how the
2706 dnl wide-character version of ncurses is installed.
2707 AC_DEFUN([CF_NCURSES_CPPFLAGS],
2708 [AC_REQUIRE([CF_WITH_CURSES_DIR])
2709
2710 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2711 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2712
2713 test -n "$cf_cv_curses_dir" && \
2714 test "$cf_cv_curses_dir" != "no" && { \
2715   CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2716 }
2717
2718 AC_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
2728 CF_NCURSES_HEADER
2729 CF_TERM_HEADER
2730
2731 # some applications need this, but should check for NCURSES_VERSION
2732 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2733
2734 CF_NCURSES_VERSION
2735 ])dnl
2736 dnl ---------------------------------------------------------------------------
2737 dnl CF_NCURSES_HEADER version: 3 updated: 2012/10/06 08:57:51
2738 dnl -----------------
2739 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2740 dnl variations of ncurses' installs.
2741 dnl
2742 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2743 AC_DEFUN([CF_NCURSES_HEADER],[
2744
2745 if test "$cf_cv_ncurses_h" != no ; then
2746         cf_cv_ncurses_header=$cf_cv_ncurses_h
2747 else
2748
2749 AC_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
2782 fi
2783
2784 # Set definitions to allow ifdef'ing for ncurses.h
2785
2786 case $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         ;;
2790 esac
2791
2792 case $cf_cv_ncurses_header in # (vi
2793 ncurses/curses.h|ncurses/ncurses.h)
2794         AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
2795         ;;
2796 ncursesw/curses.h|ncursesw/ncurses.h)
2797         AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2798         ;;
2799 esac
2800
2801 ])dnl
2802 dnl ---------------------------------------------------------------------------
2803 dnl CF_NCURSES_LIBS version: 16 updated: 2010/11/20 17:02:38
2804 dnl ---------------
2805 dnl Look for the ncurses library.  This is a little complicated on Linux,
2806 dnl because it may be linked with the gpm (general purpose mouse) library.
2807 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2808 dnl unusable with ncurses.  However, we don't want to link with gpm unless
2809 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2810 dnl and the linker will record a dependency.
2811 dnl
2812 dnl The optional parameter gives the root name of the library, in case it is
2813 dnl not installed as the default curses library.  That is how the
2814 dnl wide-character version of ncurses is installed.
2815 AC_DEFUN([CF_NCURSES_LIBS],
2816 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2817
2818 cf_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.
2822 cf_ncurses_LIBS=""
2823 cf_ncurses_SAVE="$LIBS"
2824 AC_CHECK_LIB(gpm,Gpm_Open,
2825         [AC_CHECK_LIB(gpm,initscr,
2826                 [LIBS="$cf_ncurses_SAVE"],
2827                 [cf_ncurses_LIBS="-lgpm"])])
2828
2829 case $host_os in #(vi
2830 freebsd*)
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         ;;
2837 esac
2838
2839 CF_ADD_LIBS($cf_ncurses_LIBS)
2840
2841 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2842 then
2843         CF_ADD_LIBS(-l$cf_nculib_root)
2844 else
2845         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2846                 [#include <${cf_cv_ncurses_header:-curses.h}>],
2847                 [initscr()],
2848                 initscr)
2849 fi
2850
2851 if 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"])
2865 fi
2866
2867 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2868 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2869 ])dnl
2870 dnl ---------------------------------------------------------------------------
2871 dnl CF_NCURSES_VERSION version: 14 updated: 2012/10/06 08:57:51
2872 dnl ------------------
2873 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2874 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2875 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2876 AC_DEFUN([CF_NCURSES_VERSION],
2877 [
2878 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2879 AC_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>
2886 int 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
2912 Autoconf NCURSES_VERSION
2913 #else
2914 #ifdef __NCURSES_H
2915 Autoconf "old"
2916 #endif
2917 ;
2918 #endif
2919 EOF
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 ])
2930 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2931 ])dnl
2932 dnl ---------------------------------------------------------------------------
2933 dnl CF_NO_LEAKS_OPTION version: 5 updated: 2012/10/02 20:55:03
2934 dnl ------------------
2935 dnl see CF_WITH_NO_LEAKS
2936 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2937 AC_MSG_CHECKING(if you want to use $1 for testing)
2938 AC_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=])
2947 AC_MSG_RESULT(${with_$1:-no})
2948
2949 case .$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         ;;
2959 esac
2960 ])dnl
2961 dnl ---------------------------------------------------------------------------
2962 dnl CF_OUR_MESSAGES version: 7 updated: 2004/09/12 19:45:55
2963 dnl ---------------
2964 dnl Check if we use the messages included with this program
2965 dnl
2966 dnl $1 specifies either Makefile or makefile, defaulting to the former.
2967 dnl
2968 dnl Sets variables which can be used to substitute in makefiles:
2969 dnl     MSG_DIR_MAKE - to make ./po directory
2970 dnl     SUB_MAKEFILE - makefile in ./po directory (see CF_BUNDLED_INTL)
2971 dnl
2972 AC_DEFUN([CF_OUR_MESSAGES],
2973 [
2974 cf_makefile=ifelse($1,,Makefile,$1)
2975
2976 use_our_messages=no
2977 if test "$USE_NLS" = yes ; then
2978 if test -d $srcdir/po ; then
2979 AC_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])
2984 fi
2985 AC_MSG_RESULT($use_our_messages)
2986 fi
2987
2988 MSG_DIR_MAKE="#"
2989 if test "$use_our_messages" = yes
2990 then
2991         SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:$srcdir/po/$cf_makefile.inn"
2992         MSG_DIR_MAKE=
2993 fi
2994
2995 AC_SUBST(MSG_DIR_MAKE)
2996 AC_SUBST(SUB_MAKEFILE)
2997 ])dnl
2998 dnl ---------------------------------------------------------------------------
2999 dnl CF_PATHSEP version: 6 updated: 2012/09/29 18:38:12
3000 dnl ----------
3001 dnl Provide a value for the $PATH and similar separator (or amend the value
3002 dnl as provided in autoconf 2.5x).
3003 AC_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
3010 ifelse([$1],,,[$1=$PATH_SEPARATOR])
3011         AC_SUBST(PATH_SEPARATOR)
3012         AC_MSG_RESULT($PATH_SEPARATOR)
3013 ])dnl
3014 dnl ---------------------------------------------------------------------------
3015 dnl CF_PATH_SYNTAX version: 14 updated: 2012/06/19 20:58:54
3016 dnl --------------
3017 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
3018 dnl begins with one of the prefix/exec_prefix variables, and then again if the
3019 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
3020 dnl delayed evaluation of those symbols.
3021 AC_DEFUN([CF_PATH_SYNTAX],[
3022 if test "x$prefix" != xNONE; then
3023   cf_path_syntax="$prefix"
3024 else
3025   cf_path_syntax="$ac_default_prefix"
3026 fi
3027
3028 case ".[$]$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   ;;
3049 esac
3050 ])dnl
3051 dnl ---------------------------------------------------------------------------
3052 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
3053 dnl -----------------
3054 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
3055 dnl
3056 dnl     POSIX.1-1990                            _POSIX_SOURCE
3057 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
3058 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
3059 dnl             Bindings Option
3060 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
3061 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
3062 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
3063 dnl
3064 dnl Parameters:
3065 dnl     $1 is the nominal value for _POSIX_C_SOURCE
3066 AC_DEFUN([CF_POSIX_C_SOURCE],
3067 [
3068 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
3069
3070 cf_save_CFLAGS="$CFLAGS"
3071 cf_save_CPPFLAGS="$CPPFLAGS"
3072
3073 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
3074 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
3075
3076 AC_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
3080 make 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
3099 make 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
3109 make an error
3110 #endif],,
3111          [cf_cv_posix_c_source=no])
3112          CFLAGS="$cf_save_CFLAGS"
3113          CPPFLAGS="$cf_save_CPPFLAGS"
3114         ])
3115 ])
3116
3117 if 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)
3121 fi
3122
3123 ])dnl
3124 dnl ---------------------------------------------------------------------------
3125 dnl CF_PROG_CC version: 3 updated: 2012/10/06 15:31:55
3126 dnl ----------
3127 dnl standard check for CC, plus followup sanity checks
3128 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
3129 AC_DEFUN([CF_PROG_CC],[
3130 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
3131 CF_GCC_VERSION
3132 CF_ACVERSION_CHECK(2.52,
3133         [AC_PROG_CC_STDC],
3134         [CF_ANSI_CC_REQD])
3135 CF_CC_ENV_FLAGS 
3136 ])dnl
3137 dnl ---------------------------------------------------------------------------
3138 dnl CF_PROG_EXT version: 11 updated: 2012/10/06 08:57:51
3139 dnl -----------
3140 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
3141 AC_DEFUN([CF_PROG_EXT],
3142 [
3143 AC_REQUIRE([CF_CHECK_CACHE])
3144 case $cf_cv_system_name in
3145 os2*)
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     ;;
3153 esac
3154
3155 AC_EXEEXT
3156 AC_OBJEXT
3157
3158 PROG_EXT="$EXEEXT"
3159 AC_SUBST(PROG_EXT)
3160 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT",[Define to the program extension (normally blank)])
3161 ])dnl
3162 dnl ---------------------------------------------------------------------------
3163 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
3164 dnl ------------
3165 AC_DEFUN([CF_PROG_LINT],
3166 [
3167 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
3168 AC_SUBST(LINT_OPTS)
3169 ])dnl
3170 dnl ---------------------------------------------------------------------------
3171 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
3172 dnl ----------------
3173 dnl Remove all -U and -D options that refer to the given symbol from a list
3174 dnl of C compiler options.  This works around the problem that not all
3175 dnl compilers process -U and -D options from left-to-right, so a -U option
3176 dnl cannot be used to cancel the effect of a preceding -D option.
3177 dnl
3178 dnl $1 = target (which could be the same as the source variable)
3179 dnl $2 = source (including '$')
3180 dnl $3 = symbol to remove
3181 define([CF_REMOVE_DEFINE],
3182 [
3183 $1=`echo "$2" | \
3184         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
3185                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
3186 ])dnl
3187 dnl ---------------------------------------------------------------------------
3188 dnl CF_RPATH_HACK version: 9 updated: 2011/02/13 13:31:33
3189 dnl -------------
3190 AC_DEFUN([CF_RPATH_HACK],
3191 [
3192 AC_REQUIRE([CF_LD_RPATH_OPT])
3193 AC_MSG_CHECKING(for updated LDFLAGS)
3194 if 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
3203 AC_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)
3239 fi
3240 AC_SUBST(EXTRA_LDFLAGS)
3241 ])dnl
3242 dnl ---------------------------------------------------------------------------
3243 dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
3244 dnl ---------------
3245 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
3246 dnl EXTRA_LDFLAGS for each -L option found.
3247 dnl
3248 dnl $cf_rpath_list contains a list of directories to ignore.
3249 dnl
3250 dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
3251 dnl      but LIBS often has misplaced -L options.
3252 AC_DEFUN([CF_RPATH_HACK_2],
3253 [
3254 CF_VERBOSE(...checking $1 [$]$1)
3255
3256 cf_rpath_dst=
3257 for cf_rpath_src in [$]$1
3258 do
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"
3296 done
3297 $1=$cf_rpath_dst
3298
3299 CF_VERBOSE(...checked $1 [$]$1)
3300 AC_SUBST(EXTRA_LDFLAGS)
3301 ])dnl
3302 dnl ---------------------------------------------------------------------------
3303 dnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
3304 dnl --------------
3305 dnl Construct a search-list for a nonstandard header/lib-file
3306 dnl     $1 = the variable to return as result
3307 dnl     $2 = the package name
3308 dnl     $3 = the subdirectory, e.g., bin, include or lib
3309 AC_DEFUN([CF_SUBDIR_PATH],
3310 [
3311 $1=
3312
3313 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
3314 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
3315 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
3316 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
3317 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
3318 ])dnl
3319 dnl ---------------------------------------------------------------------------
3320 dnl CF_TERM_HEADER version: 3 updated: 2012/10/06 08:57:51
3321 dnl --------------
3322 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
3323 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
3324 dnl but some packagers change this, breaking various applications.
3325 AC_DEFUN([CF_TERM_HEADER],[
3326 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
3327 case ${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         ;;
3334 esac
3335
3336 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
3337 do
3338 AC_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
3346 done
3347 ])
3348
3349 # Set definitions to allow ifdef'ing to accommodate subdirectories
3350
3351 case $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         ;;
3355 esac
3356
3357 case $cf_cv_term_header in # (vi
3358 ncurses/term.h) #(vi
3359         AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
3360         ;;
3361 ncursesw/term.h)
3362         AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
3363         ;;
3364 esac
3365 ])dnl
3366 dnl ---------------------------------------------------------------------------
3367 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
3368 dnl -------------------
3369 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
3370 dnl can define it successfully.
3371 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
3372 AC_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
3379 make 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
3390 make 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
3398 if 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)
3403 fi
3404 ])
3405 dnl ---------------------------------------------------------------------------
3406 dnl CF_UNION_WAIT version: 6 updated: 2012/10/06 08:57:51
3407 dnl -------------
3408 dnl Check to see if the BSD-style union wait is declared.  Some platforms may
3409 dnl use this, though it is deprecated in favor of the 'int' type in Posix.
3410 dnl Some vendors provide a bogus implementation that declares union wait, but
3411 dnl uses the 'int' type instead; we try to spot these by checking for the
3412 dnl associated macros.
3413 dnl
3414 dnl Ahem.  Some implementers cast the status value to an int*, as an attempt to
3415 dnl use the macros for either union wait or int.  So we do a check compile to
3416 dnl see if the macros are defined and apply to an int.
3417 dnl
3418 dnl Sets: $cf_cv_type_unionwait
3419 dnl Defines: HAVE_TYPE_UNIONWAIT
3420 AC_DEFUN([CF_UNION_WAIT],
3421 [
3422 AC_REQUIRE([CF_WAIT_HEADERS])
3423 AC_MSG_CHECKING([for union wait])
3424 AC_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])])])
3448 AC_MSG_RESULT($cf_cv_type_unionwait)
3449 test $cf_cv_type_unionwait = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT,1,[Define to 1 if type unionwait is declared])
3450 ])dnl
3451 dnl ---------------------------------------------------------------------------
3452 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3453 dnl --------
3454 dnl Make an uppercase version of a variable
3455 dnl $1=uppercase($2)
3456 AC_DEFUN([CF_UPPER],
3457 [
3458 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3459 ])dnl
3460 dnl ---------------------------------------------------------------------------
3461 dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
3462 dnl -----------
3463 dnl Check for multibyte support, and if not found, utf8 compatibility library
3464 AC_DEFUN([CF_UTF8_LIB],
3465 [
3466 AC_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:
3479 if 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)
3484 fi
3485 ])dnl
3486 dnl ---------------------------------------------------------------------------
3487 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3488 dnl ----------
3489 dnl Use AC_VERBOSE w/o the warnings
3490 AC_DEFUN([CF_VERBOSE],
3491 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
3492 CF_MSG_LOG([$1])
3493 ])dnl
3494 dnl ---------------------------------------------------------------------------
3495 dnl CF_VERSION_INFO version: 5 updated: 2012/10/06 08:57:51
3496 dnl ---------------
3497 dnl Define several useful symbols derived from the VERSION file.  A separate
3498 dnl file is preferred to embedding the version numbers in various scripts.
3499 dnl (automake is a textbook-example of why the latter is a bad idea, but there
3500 dnl are others).
3501 dnl
3502 dnl The file contents are:
3503 dnl     libtool-version release-version patch-version
3504 dnl or
3505 dnl     release-version
3506 dnl where
3507 dnl     libtool-version (see ?) consists of 3 integers separated by '.'
3508 dnl     release-version consists of a major version and minor version
3509 dnl             separated by '.', optionally followed by a patch-version
3510 dnl             separated by '-'.  The minor version need not be an
3511 dnl             integer (but it is preferred).
3512 dnl     patch-version is an integer in the form yyyymmdd, so ifdef's and
3513 dnl             scripts can easily compare versions.
3514 dnl
3515 dnl If libtool is used, the first form is required, since CF_WITH_LIBTOOL
3516 dnl simply extracts the first field using 'cut -f1'.
3517 dnl
3518 dnl Optional parameters:
3519 dnl $1 = internal name for package
3520 dnl $2 = external name for package
3521 AC_DEFUN([CF_VERSION_INFO],
3522 [
3523 if 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)
3555 else
3556         AC_MSG_ERROR(did not find $srcdir/VERSION)
3557 fi
3558
3559 # show the actual data that we have for versions:
3560 CF_VERBOSE(VERSION $VERSION)
3561 CF_VERBOSE(VERSION_MAJOR $VERSION_MAJOR)
3562 CF_VERBOSE(VERSION_MINOR $VERSION_MINOR)
3563 CF_VERBOSE(VERSION_PATCH $VERSION_PATCH)
3564
3565 AC_SUBST(VERSION)
3566 AC_SUBST(VERSION_MAJOR)
3567 AC_SUBST(VERSION_MINOR)
3568 AC_SUBST(VERSION_PATCH)
3569
3570 dnl if a package name is given, define its corresponding version info.  We
3571 dnl need the package name to ensure that the defined symbols are unique.
3572 ifelse($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
3582 dnl ---------------------------------------------------------------------------
3583 dnl CF_WAIT_HEADERS version: 2 updated: 1997/10/21 19:45:33
3584 dnl ---------------
3585 dnl Build up an expression $cf_wait_headers with the header files needed to
3586 dnl compile against the prototypes for 'wait()', 'waitpid()', etc.  Assume it's
3587 dnl Posix, which uses <sys/types.h> and <sys/wait.h>, but allow SVr4 variation
3588 dnl with <wait.h>.
3589 AC_DEFUN([CF_WAIT_HEADERS],
3590 [
3591 AC_HAVE_HEADERS(sys/wait.h)
3592 cf_wait_headers="#include <sys/types.h>
3593 "
3594 if test $ac_cv_header_sys_wait_h = yes; then
3595 cf_wait_headers="$cf_wait_headers
3596 #include <sys/wait.h>
3597 "
3598 else
3599 AC_HAVE_HEADERS(wait.h)
3600 AC_HAVE_HEADERS(waitstatus.h)
3601 if test $ac_cv_header_wait_h = yes; then
3602 cf_wait_headers="$cf_wait_headers
3603 #include <wait.h>
3604 "
3605 fi
3606 if test $ac_cv_header_waitstatus_h = yes; then
3607 cf_wait_headers="$cf_wait_headers
3608 #include <waitstatus.h>
3609 "
3610 fi
3611 fi
3612 ])dnl
3613 dnl ---------------------------------------------------------------------------
3614 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
3615 dnl ------------------
3616 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3617 dnl libraries.
3618 AC_DEFUN([CF_WITH_CURSES_DIR],[
3619
3620 AC_MSG_CHECKING(for specific curses-directory)
3621 AC_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])
3625 AC_MSG_RESULT($cf_cv_curses_dir)
3626
3627 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
3628 then
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
3635 fi
3636 ])dnl
3637 dnl ---------------------------------------------------------------------------
3638 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3639 dnl ----------------
3640 dnl Configure-option for dbmalloc.  The optional parameter is used to override
3641 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3642 AC_DEFUN([CF_WITH_DBMALLOC],[
3643 CF_NO_LEAKS_OPTION(dbmalloc,
3644         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3645         [USE_DBMALLOC])
3646
3647 if test "$with_dbmalloc" = yes ; then
3648         AC_CHECK_HEADER(dbmalloc.h,
3649                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3650 fi
3651 ])dnl
3652 dnl ---------------------------------------------------------------------------
3653 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3654 dnl ---------------
3655 dnl Configure-option for dmalloc.  The optional parameter is used to override
3656 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3657 AC_DEFUN([CF_WITH_DMALLOC],[
3658 CF_NO_LEAKS_OPTION(dmalloc,
3659         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
3660         [USE_DMALLOC])
3661
3662 if test "$with_dmalloc" = yes ; then
3663         AC_CHECK_HEADER(dmalloc.h,
3664                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3665 fi
3666 ])dnl
3667 dnl ---------------------------------------------------------------------------
3668 dnl CF_WITH_LIBTOOL version: 28 updated: 2011/07/02 15:40:32
3669 dnl ---------------
3670 dnl Provide a configure option to incorporate libtool.  Define several useful
3671 dnl symbols for the makefile rules.
3672 dnl
3673 dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
3674 dnl macros from libtool.m4 which is in the aclocal directory of automake.
3675 dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
3676 dnl But that still does not work properly since the macro is expanded outside
3677 dnl the CF_WITH_LIBTOOL macro:
3678 dnl
3679 dnl     #!/bin/sh
3680 dnl     ACLOCAL=`aclocal --print-ac-dir`
3681 dnl     if test -z "$ACLOCAL" ; then
3682 dnl             echo cannot find aclocal directory
3683 dnl             exit 1
3684 dnl     elif test ! -f $ACLOCAL/libtool.m4 ; then
3685 dnl             echo cannot find libtool.m4 file
3686 dnl             exit 1
3687 dnl     fi
3688 dnl
3689 dnl     LOCAL=aclocal.m4
3690 dnl     ORIG=aclocal.m4.orig
3691 dnl
3692 dnl     trap "mv $ORIG $LOCAL" 0 1 2 5 15
3693 dnl     rm -f $ORIG
3694 dnl     mv $LOCAL $ORIG
3695 dnl
3696 dnl     # sed the LIBTOOL= assignment to omit the current directory?
3697 dnl     sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL:-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
3698 dnl     cat $ORIG >>$LOCAL
3699 dnl
3700 dnl     autoconf-257 $*
3701 dnl
3702 AC_DEFUN([CF_WITH_LIBTOOL],
3703 [
3704 AC_REQUIRE([CF_DISABLE_LIBTOOL_VERSION])
3705 ifdef([AC_PROG_LIBTOOL],,[
3706 LIBTOOL=
3707 ])
3708 # common library maintenance symbols that are convenient for libtool scripts:
3709 LIB_CREATE='${AR} -cr'
3710 LIB_OBJECT='${OBJECTS}'
3711 LIB_SUFFIX=.a
3712 LIB_PREP="$RANLIB"
3713
3714 # symbols used to prop libtool up to enable it to determine what it should be
3715 # doing:
3716 LIB_CLEAN=
3717 LIB_COMPILE=
3718 LIB_LINK='${CC}'
3719 LIB_INSTALL=
3720 LIB_UNINSTALL=
3721
3722 AC_MSG_CHECKING(if you want to build libraries with libtool)
3723 AC_ARG_WITH(libtool,
3724         [  --with-libtool          generate libraries with libtool],
3725         [with_libtool=$withval],
3726         [with_libtool=no])
3727 AC_MSG_RESULT($with_libtool)
3728 if test "$with_libtool" != "no"; then
3729 ifdef([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
3785 else
3786         LIBTOOL=""
3787         LIBTOOL_CXX=""
3788 fi
3789
3790 test -z "$LIBTOOL" && ECHO_LT=
3791
3792 AC_SUBST(LIBTOOL)
3793 AC_SUBST(LIBTOOL_CXX)
3794 AC_SUBST(LIBTOOL_OPTS)
3795
3796 AC_SUBST(LIB_CREATE)
3797 AC_SUBST(LIB_OBJECT)
3798 AC_SUBST(LIB_SUFFIX)
3799 AC_SUBST(LIB_PREP)
3800
3801 AC_SUBST(LIB_CLEAN)
3802 AC_SUBST(LIB_COMPILE)
3803 AC_SUBST(LIB_LINK)
3804 AC_SUBST(LIB_INSTALL)
3805 AC_SUBST(LIB_UNINSTALL)
3806
3807 ])dnl
3808 dnl ---------------------------------------------------------------------------
3809 dnl CF_WITH_LIBTOOL_OPTS version: 2 updated: 2007/04/08 18:14:54
3810 dnl --------------------
3811 dnl Allow user to pass additional libtool options into the library creation
3812 dnl and link steps.  The main use for this is to do something like
3813 dnl     ./configure --with-libtool-opts=-static
3814 dnl to get the same behavior as automake-flavored
3815 dnl     ./configure --enable-static
3816 AC_DEFUN([CF_WITH_LIBTOOL_OPTS],[
3817 AC_MSG_CHECKING(for additional libtool options)
3818 AC_ARG_WITH(libtool-opts,
3819         [  --with-libtool-opts=XXX specify additional libtool options],
3820         [with_libtool_opts=$withval],
3821         [with_libtool_opts=no])
3822 AC_MSG_RESULT($with_libtool_opts)
3823
3824 case .$with_libtool_opts in
3825 .yes|.no|.)
3826         ;;
3827 *)
3828         LIBTOOL_OPTS=$with_libtool_opts
3829         ;;
3830 esac
3831
3832 AC_SUBST(LIBTOOL_OPTS)
3833 ])dnl
3834 dnl ---------------------------------------------------------------------------
3835 dnl CF_WITH_NO_LEAKS version: 2 updated: 2012/10/06 08:57:51
3836 dnl ----------------
3837 AC_DEFUN([CF_WITH_NO_LEAKS],[
3838
3839 AC_REQUIRE([CF_WITH_DMALLOC])
3840 AC_REQUIRE([CF_WITH_DBMALLOC])
3841 AC_REQUIRE([CF_WITH_PURIFY])
3842 AC_REQUIRE([CF_WITH_VALGRIND])
3843
3844 AC_MSG_CHECKING(if you want to perform memory-leak testing)
3845 AC_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=])
3855 AC_MSG_RESULT($with_no_leaks)
3856 ])dnl
3857 dnl ---------------------------------------------------------------------------
3858 dnl CF_WITH_PURIFY version: 2 updated: 2006/12/14 18:43:43
3859 dnl --------------
3860 AC_DEFUN([CF_WITH_PURIFY],[
3861 CF_NO_LEAKS_OPTION(purify,
3862         [  --with-purify           test: use Purify],
3863         [USE_PURIFY],
3864         [LINK_PREFIX="$LINK_PREFIX purify"])
3865 AC_SUBST(LINK_PREFIX)
3866 ])dnl
3867 dnl ---------------------------------------------------------------------------
3868 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3869 dnl ----------------
3870 AC_DEFUN([CF_WITH_VALGRIND],[
3871 CF_NO_LEAKS_OPTION(valgrind,
3872         [  --with-valgrind         test: use valgrind],
3873         [USE_VALGRIND])
3874 ])dnl
3875 dnl ---------------------------------------------------------------------------
3876 dnl CF_WITH_WARNINGS version: 5 updated: 2004/07/23 14:40:34
3877 dnl ----------------
3878 dnl Combine the checks for gcc features into a configure-script option
3879 dnl
3880 dnl Parameters:
3881 dnl     $1 - see CF_GCC_WARNINGS
3882 AC_DEFUN([CF_WITH_WARNINGS],
3883 [
3884 if ( test "$GCC" = yes || test "$GXX" = yes )
3885 then
3886 AC_MSG_CHECKING(if you want to check for gcc warnings)
3887 AC_ARG_WITH(warnings,
3888         [  --with-warnings         test: turn on gcc warnings],
3889         [cf_opt_with_warnings=$withval],
3890         [cf_opt_with_warnings=no])
3891 AC_MSG_RESULT($cf_opt_with_warnings)
3892 if test "$cf_opt_with_warnings" != no ; then
3893         CF_GCC_ATTRIBUTES
3894         CF_GCC_WARNINGS([$1])
3895 fi
3896 fi
3897 ])dnl
3898 dnl ---------------------------------------------------------------------------
3899 dnl CF_XOPEN_CURSES version: 11 updated: 2011/01/18 18:15:30
3900 dnl ---------------
3901 dnl Test if we should define X/Open source for curses, needed on Digital Unix
3902 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
3903 dnl
3904 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
3905 dnl as getbegy().  The latter is better design, but the former is standard.
3906 AC_DEFUN([CF_XOPEN_CURSES],
3907 [
3908 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3909 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
3910 AC_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])])])
3935 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
3936 ])dnl
3937 dnl ---------------------------------------------------------------------------
3938 dnl CF_XOPEN_SOURCE version: 42 updated: 2012/01/07 08:26:49
3939 dnl ---------------
3940 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3941 dnl or adapt to the vendor's definitions to get equivalent functionality,
3942 dnl without losing the common non-POSIX features.
3943 dnl
3944 dnl Parameters:
3945 dnl     $1 is the nominal value for _XOPEN_SOURCE
3946 dnl     $2 is the nominal value for _POSIX_C_SOURCE
3947 AC_DEFUN([CF_XOPEN_SOURCE],[
3948
3949 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3950 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3951 cf_xopen_source=
3952
3953 case $host_os in #(vi
3954 aix[[4-7]]*) #(vi
3955         cf_xopen_source="-D_ALL_SOURCE"
3956         ;;
3957 cygwin) #(vi
3958         cf_XOPEN_SOURCE=600
3959         ;;
3960 darwin[[0-8]].*) #(vi
3961         cf_xopen_source="-D_APPLE_C_SOURCE"
3962         ;;
3963 darwin*) #(vi
3964         cf_xopen_source="-D_DARWIN_C_SOURCE"
3965         cf_XOPEN_SOURCE=
3966         ;;
3967 freebsd*|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         ;;
3975 hpux11*) #(vi
3976         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3977         ;;
3978 hpux*) #(vi
3979         cf_xopen_source="-D_HPUX_SOURCE"
3980         ;;
3981 irix[[56]].*) #(vi
3982         cf_xopen_source="-D_SGI_SOURCE"
3983         cf_XOPEN_SOURCE=
3984         ;;
3985 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
3986         CF_GNU_SOURCE
3987         ;;
3988 mirbsd*) #(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         ;;
3993 netbsd*) #(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         ;;
3996 openbsd[[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         ;;
4001 openbsd*) #(vi
4002         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
4003         ;;
4004 osf[[45]]*) #(vi
4005         cf_xopen_source="-D_OSF_SOURCE"
4006         ;;
4007 nto-qnx*) #(vi
4008         cf_xopen_source="-D_QNX_SOURCE"
4009         ;;
4010 sco*) #(vi
4011         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
4012         ;;
4013 solaris2.*) #(vi
4014         cf_xopen_source="-D__EXTENSIONS__"
4015         ;;
4016 *)
4017         CF_TRY_XOPEN_SOURCE
4018         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4019         ;;
4020 esac
4021
4022 if test -n "$cf_xopen_source" ; then
4023         CF_ADD_CFLAGS($cf_xopen_source)
4024 fi
4025
4026 dnl In anything but the default case, we may have system-specific setting
4027 dnl which is still not guaranteed to provide all of the entrypoints that
4028 dnl _XOPEN_SOURCE would yield.
4029 if 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
4033 make 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
4042 make 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
4053 fi
4054 ])
4055 dnl ---------------------------------------------------------------------------
4056 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
4057 dnl ---------------
4058 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
4059 dnl are both available.
4060 define([CF__CURSES_HEAD],[
4061 #ifdef HAVE_XCURSES
4062 #include <xcurses.h>
4063 char * 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 ])
4075 dnl ---------------------------------------------------------------------------
4076 dnl CF__ICONV_BODY version: 2 updated: 2007/07/26 17:35:47
4077 dnl --------------
4078 dnl Test-code needed for iconv compile-checks
4079 define([CF__ICONV_BODY],[
4080         iconv_t cd = iconv_open("","");
4081         iconv(cd,NULL,NULL,NULL,NULL);
4082         iconv_close(cd);]
4083 )dnl
4084 dnl ---------------------------------------------------------------------------
4085 dnl CF__ICONV_HEAD version: 1 updated: 2007/07/26 15:57:03
4086 dnl --------------
4087 dnl Header-files needed for iconv compile-checks
4088 define([CF__ICONV_HEAD],[
4089 #include <stdlib.h>
4090 #include <iconv.h>]
4091 )dnl
4092 dnl ---------------------------------------------------------------------------
4093 dnl CF__INTL_BODY version: 1 updated: 2007/07/26 17:35:47
4094 dnl -------------
4095 dnl Test-code needed for libintl compile-checks
4096 dnl $1 = parameter 2 from AM_WITH_NLS
4097 define([CF__INTL_BODY],[
4098     bindtextdomain ("", "");
4099     return (int) gettext ("")
4100             ifelse([$1], need-ngettext, [ + (int) ngettext ("", "", 0)], [])
4101             [ + _nl_msg_cat_cntr]
4102 ])
4103 dnl ---------------------------------------------------------------------------
4104 dnl CF__INTL_HEAD version: 1 updated: 2007/07/26 17:35:47
4105 dnl -------------
4106 dnl Header-files needed for libintl compile-checks
4107 define([CF__INTL_HEAD],[
4108 #include <libintl.h>
4109 extern int _nl_msg_cat_cntr;
4110 ])dnl
4111 dnl ---------------------------------------------------------------------------
4112 dnl jm_GLIBC21 version: 3 updated: 2002/10/27 23:21:42
4113 dnl ----------
4114 dnl Inserted as requested by gettext 0.10.40
4115 dnl File from /usr/share/aclocal
4116 dnl glibc21.m4
4117 dnl ====================
4118 dnl serial 2
4119 dnl
4120 dnl Test for the GNU C Library, version 2.1 or newer.
4121 dnl From Bruno Haible.
4122 AC_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 )