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