1 dnl $Id: aclocal.m4,v 1.6 2003/10/19 00:09:23 tom Exp $
2 dnl ---------------------------------------------------------------------------
3 dnl ---------------------------------------------------------------------------
4 dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52
6 dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's
7 dnl redundant. We don't normally need to add -I/usr/local/include for gcc,
8 dnl but old versions (and some misinstalled ones) need that. To make things
9 dnl worse, gcc 3.x gives error messages if -I/usr/local/include is added to
10 dnl the include-path).
11 AC_DEFUN([CF_ADD_INCDIR],
13 for cf_add_incdir in $1
17 case $cf_add_incdir in
20 /usr/local/include) # (vi
23 cf_save_CPPFLAGS="$CPPFLAGS"
24 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
25 AC_TRY_COMPILE([#include <stdio.h>],
28 [CPPFLAGS="$cf_save_CPPFLAGS"])
32 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
35 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
36 test "$cf_top_incdir" = "$cf_add_incdir" && break
37 cf_add_incdir="$cf_top_incdir"
41 dnl ---------------------------------------------------------------------------
42 dnl CF_CHECK_CACHE version: 7 updated: 2001/12/19 00:50:10
44 dnl Check if we're accidentally using a cache from a different machine.
45 dnl Derive the system name, as a check for reusing the autoconf cache.
47 dnl If we've packaged config.guess and config.sub, run that (since it does a
48 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
49 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
50 dnl which is useful in cross-compiles.
51 AC_DEFUN([CF_CHECK_CACHE],
53 if test -f $srcdir/config.guess ; then
54 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
55 system_name="$host_os"
57 system_name="`(uname -s -r) 2>/dev/null`"
58 if test -z "$system_name" ; then
59 system_name="`(hostname) 2>/dev/null`"
62 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
63 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
65 test -z "$system_name" && system_name="$cf_cv_system_name"
66 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
68 if test ".$system_name" != ".$cf_cv_system_name" ; then
69 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
70 AC_ERROR("Please remove config.cache and try again.")
73 dnl ---------------------------------------------------------------------------
74 dnl CF_CURSES_ACS_MAP version: 3 updated: 2003/05/17 22:19:02
76 dnl Check for likely values of acs_map[]:
77 AC_DEFUN([CF_CURSES_ACS_MAP],
79 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
80 cf_cv_curses_acs_map=unknown
81 for name in acs_map _acs_map __acs_map _nc_acs_map
84 #include <${cf_cv_ncurses_header-curses.h}>
87 ],[cf_cv_curses_acs_map=$name; break])
91 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
93 dnl ---------------------------------------------------------------------------
94 dnl CF_CURSES_CHECK_TYPE version: 2 updated: 2003/03/01 23:40:33
95 dnl --------------------
96 dnl Check if curses.h defines the given type
97 AC_DEFUN([CF_CURSES_CHECK_TYPE],
99 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header-curses.h})
101 #ifndef _XOPEN_SOURCE_EXTENDED
102 #define _XOPEN_SOURCE_EXTENDED
104 #include <${cf_cv_ncurses_header-curses.h}>],[
106 ],cf_result=yes,cf_result=no)
107 AC_MSG_RESULT($cf_result)
108 if test $cf_result = yes ; then
109 CF_UPPER(cf_result,have_type_$1)
110 AC_DEFINE_UNQUOTED($cf_result)
112 AC_DEFINE_UNQUOTED($1,$2)
115 dnl ---------------------------------------------------------------------------
116 dnl CF_CURSES_CPPFLAGS version: 7 updated: 2003/06/06 00:48:41
117 dnl ------------------
118 dnl Look for the curses headers.
119 AC_DEFUN([CF_CURSES_CPPFLAGS],[
121 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
122 cf_cv_curses_incdir=no
123 case $host_os in #(vi
124 hpux10.*|hpux11.*) #(vi
125 test -d /usr/include/curses_colr && \
126 cf_cv_curses_incdir="-I/usr/include/curses_colr"
129 test -d /usr/5lib && \
130 test -d /usr/5include && \
131 cf_cv_curses_incdir="-I/usr/5include"
135 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
137 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
138 cf_cv_ncurses_header=none
145 AC_TRY_COMPILE([#include <${cf_header}>],
146 [initscr(); tgoto("?", 0,0)],
147 [cf_cv_ncurses_header=$cf_header; break],[])
151 if test "$cf_cv_ncurses_header" = none ; then
152 AC_MSG_ERROR(No curses header-files found)
155 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
156 AC_CHECK_HEADERS($cf_cv_ncurses_header)
159 dnl ---------------------------------------------------------------------------
160 dnl CF_CURSES_LIBS version: 22 updated: 2002/10/27 18:21:42
162 dnl Look for the curses libraries. Older curses implementations may require
163 dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
164 AC_DEFUN([CF_CURSES_LIBS],[
166 AC_MSG_CHECKING(if we have identified curses libraries)
167 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
168 [initscr(); tgoto("?", 0,0)],
171 AC_MSG_RESULT($cf_result)
173 if test "$cf_result" = no ; then
174 case $host_os in #(vi
176 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
178 hpux10.*|hpux11.*) #(vi
179 AC_CHECK_LIB(cur_colr,initscr,[
180 LIBS="-lcur_colr $LIBS"
181 ac_cv_func_initscr=yes
183 AC_CHECK_LIB(Hcurses,initscr,[
184 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
185 LIBS="-lHcurses $LIBS"
186 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
187 ac_cv_func_initscr=yes
190 linux*) # Suse Linux does not follow /usr/lib convention
194 test -d /usr/5lib && \
195 LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap"
196 ac_cv_func_initscr=yes
200 if test ".$ac_cv_func_initscr" != .yes ; then
205 if test ".${cf_cv_ncurses_version-no}" != .no
207 cf_check_list="ncurses curses cursesX"
209 cf_check_list="cursesX curses ncurses"
212 # Check for library containing tgoto. Do this before curses library
213 # because it may be needed to link the test-case for initscr.
214 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
215 for cf_term_lib in $cf_check_list termcap termlib unknown
217 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
221 # Check for library containing initscr
222 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
223 for cf_curs_lib in $cf_check_list xcurses jcurses unknown
225 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
227 test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
229 LIBS="-l$cf_curs_lib $cf_save_LIBS"
230 if test "$cf_term_lib" = unknown ; then
231 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
232 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
236 AC_MSG_RESULT($cf_result)
237 test $cf_result = no && AC_ERROR(Cannot link curses library)
238 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
240 elif test "$cf_term_lib" != predefined ; then
241 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
242 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
243 [initscr(); tgoto((char *)0, 0, 0);],
246 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
247 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
252 AC_MSG_RESULT($cf_result)
258 dnl ---------------------------------------------------------------------------
259 dnl CF_CURSES_WACS_MAP version: 3 updated: 2003/05/17 22:19:02
260 dnl ------------------
261 dnl Check for likely values of wacs_map[]:
262 AC_DEFUN([CF_CURSES_WACS_MAP],
264 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
265 cf_cv_curses_wacs_map=unknown
266 for name in wacs_map _wacs_map __wacs_map _nc_wacs
269 #ifndef _XOPEN_SOURCE_EXTENDED
270 #define _XOPEN_SOURCE_EXTENDED
272 #include <${cf_cv_ncurses_header-curses.h}>],
273 [$name['k'] = *WACS_PLUS],
274 [cf_cv_curses_wacs_map=$name
278 dnl ---------------------------------------------------------------------------
279 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
281 dnl "dirname" is not portable, so we fake it with a shell script.
282 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
283 dnl ---------------------------------------------------------------------------
284 dnl CF_FIND_LIBRARY version: 7 updated: 2000/04/13 21:38:04
286 dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
287 dnl prefer a standard location, and use -L options only if we do not find the
288 dnl library in the standard library location(s).
289 dnl $1 = library name
290 dnl $2 = library class, usually the same as library name
292 dnl $4 = code fragment to compile/link
293 dnl $5 = corresponding function-name
294 dnl $6 = flag, nonnull if failure causes an error-exit
296 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
297 dnl to use a -L option.
298 AC_DEFUN([CF_FIND_LIBRARY],
300 eval 'cf_cv_have_lib_'$1'=no'
303 eval 'cf_cv_have_lib_'$1'=yes',[
305 AC_MSG_CHECKING(for $5 in -l$1)
307 AC_TRY_LINK([$3],[$4],
309 eval 'cf_cv_have_lib_'$1'=yes'
312 CF_LIBRARY_PATH(cf_search,$2)
313 for cf_libdir in $cf_search
315 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
316 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
317 AC_TRY_LINK([$3],[$4],
319 eval 'cf_cv_have_lib_'$1'=yes'
322 LIBS="$cf_save_LIBS"])
326 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
328 if test $cf_found_library = no ; then
329 AC_ERROR(Cannot link $1 library)
333 dnl ---------------------------------------------------------------------------
334 dnl CF_FUNC_CURSES_VERSION version: 3 updated: 2003/05/17 22:19:02
335 dnl ----------------------
336 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
337 dnl It's a character string "SVR4", not documented.
338 AC_DEFUN([CF_FUNC_CURSES_VERSION],
340 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
342 #include <${cf_cv_ncurses_header-curses.h}>
346 sprintf(temp, "%s\n", curses_version());
349 ,[cf_cv_func_curses_version=yes]
350 ,[cf_cv_func_curses_version=no]
351 ,[cf_cv_func_curses_version=unknown])
353 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
355 dnl ---------------------------------------------------------------------------
356 dnl CF_GNU_SOURCE version: 3 updated: 2000/10/29 23:30:53
358 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
359 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
360 dnl (or misfeature) of glibc2, which breaks portability of many applications,
361 dnl since it is interwoven with GNU extensions.
363 dnl Well, yes we could work around it...
364 AC_DEFUN([CF_GNU_SOURCE],
366 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
367 AC_TRY_COMPILE([#include <sys/types.h>],[
368 #ifndef _XOPEN_SOURCE
371 [cf_cv_gnu_source=no],
373 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
374 AC_TRY_COMPILE([#include <sys/types.h>],[
378 [cf_cv_gnu_source=no],
379 [cf_cv_gnu_source=yes])
383 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
385 dnl ---------------------------------------------------------------------------
386 dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
388 dnl Construct a search-list for a nonstandard header-file
389 AC_DEFUN([CF_HEADER_PATH],
390 [CF_SUBDIR_PATH($1,$2,include)
391 test "$includedir" != NONE && \
392 test "$includedir" != "/usr/include" && \
393 test -d "$includedir" && {
394 test -d $includedir && $1="[$]$1 $includedir"
395 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
398 test "$oldincludedir" != NONE && \
399 test "$oldincludedir" != "/usr/include" && \
400 test -d "$oldincludedir" && {
401 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
402 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
406 dnl ---------------------------------------------------------------------------
407 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
408 dnl -----------------
409 dnl If we do not have a given script, look for it in the parent directory.
410 AC_DEFUN([CF_INHERIT_SCRIPT],
412 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
414 dnl ---------------------------------------------------------------------------
415 dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
417 dnl Construct a search-list for a nonstandard library-file
418 AC_DEFUN([CF_LIBRARY_PATH],
419 [CF_SUBDIR_PATH($1,$2,lib)])dnl
420 dnl ---------------------------------------------------------------------------
421 dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
422 dnl -------------------
423 dnl Check if we can compile with ncurses' header file
424 dnl $1 is the cache variable to set
425 dnl $2 is the header-file to include
426 dnl $3 is the root name (ncurses or ncursesw)
427 AC_DEFUN([CF_NCURSES_CC_CHECK],[
429 ]ifelse($3,ncursesw,[
430 #define _XOPEN_SOURCE_EXTENDED
431 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
432 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
435 #ifdef NCURSES_VERSION
436 ]ifelse($3,ncursesw,[
441 printf("%s\n", NCURSES_VERSION);
453 dnl ---------------------------------------------------------------------------
454 dnl CF_NCURSES_CPPFLAGS version: 16 updated: 2002/12/29 18:30:46
455 dnl -------------------
456 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
457 dnl the CPPFLAGS variable so we can include its header.
459 dnl The header files may be installed as either curses.h, or ncurses.h (would
460 dnl be obsolete, except that some packagers prefer this name to distinguish it
461 dnl from a "native" curses implementation). If not installed for overwrite,
462 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
463 dnl /usr/include/ncurses), but someone may have installed overwriting the
464 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
465 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
468 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
469 dnl is already in the include-path, don't even bother with this, since we cannot
470 dnl easily determine which file it is. In this case, it has to be <curses.h>.
472 dnl The optional parameter gives the root name of the library, in case it is
473 dnl not installed as the default curses library. That is how the
474 dnl wide-character version of ncurses is installed.
475 AC_DEFUN([CF_NCURSES_CPPFLAGS],
476 [AC_REQUIRE([CF_WITH_CURSES_DIR])
478 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
480 test -n "$cf_cv_curses_dir" && \
481 test "$cf_cv_curses_dir" != "no" && \
482 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
484 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
485 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
486 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
487 for cf_header in $cf_header_list
489 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
490 test "$cf_cv_ncurses_h" != no && break
494 if test "$cf_cv_ncurses_h" != no ; then
495 cf_cv_ncurses_header=$cf_cv_ncurses_h
497 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
498 test -n "$verbose" && echo
499 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
500 test -n "$verbose" && echo search path $cf_search
501 cf_save2_CPPFLAGS="$CPPFLAGS"
502 for cf_incdir in $cf_search
504 CF_ADD_INCDIR($cf_incdir)
509 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
510 if test "$cf_cv_ncurses_h2" != no ; then
511 cf_cv_ncurses_h2=$cf_incdir/$cf_header
512 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
515 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
517 CPPFLAGS="$cf_save2_CPPFLAGS"
518 test "$cf_cv_ncurses_h2" != no && break
520 test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found)
523 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
524 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
525 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
526 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
528 CF_ADD_INCDIR($cf_1st_incdir)
534 case $cf_cv_ncurses_header in # (vi
536 AC_DEFINE(HAVE_NCURSES_H)
540 case $cf_cv_ncurses_header in # (vi
541 ncurses/curses.h|ncurses/ncurses.h)
542 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
544 ncursesw/curses.h|ncursesw/ncurses.h)
545 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
551 dnl ---------------------------------------------------------------------------
552 dnl CF_NCURSES_LIBS version: 11 updated: 2002/12/22 14:22:25
554 dnl Look for the ncurses library. This is a little complicated on Linux,
555 dnl because it may be linked with the gpm (general purpose mouse) library.
556 dnl Some distributions have gpm linked with (bsd) curses, which makes it
557 dnl unusable with ncurses. However, we don't want to link with gpm unless
558 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
559 dnl and the linker will record a dependency.
561 dnl The optional parameter gives the root name of the library, in case it is
562 dnl not installed as the default curses library. That is how the
563 dnl wide-character version of ncurses is installed.
564 AC_DEFUN([CF_NCURSES_LIBS],
565 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
567 cf_nculib_root=ifelse($1,,ncurses,$1)
568 # This works, except for the special case where we find gpm, but
569 # ncurses is in a nonstandard location via $LIBS, and we really want
572 cf_ncurses_SAVE="$LIBS"
573 AC_CHECK_LIB(gpm,Gpm_Open,
574 [AC_CHECK_LIB(gpm,initscr,
575 [LIBS="$cf_ncurses_SAVE"],
576 [cf_ncurses_LIBS="-lgpm"])])
578 case $host_os in #(vi
580 # This is only necessary if you are linking against an obsolete
581 # version of ncurses (but it should do no harm, since it's static).
582 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
586 LIBS="$cf_ncurses_LIBS $LIBS"
588 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
590 LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
592 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
593 [#include <${cf_cv_ncurses_header-curses.h}>],
598 if test -n "$cf_ncurses_LIBS" ; then
599 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
600 cf_ncurses_SAVE="$LIBS"
601 for p in $cf_ncurses_LIBS ; do
602 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
603 if test "$q" != "$LIBS" ; then
607 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
608 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
609 [AC_MSG_RESULT(yes)],
611 LIBS="$cf_ncurses_SAVE"])
614 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
615 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
617 dnl ---------------------------------------------------------------------------
618 dnl CF_NCURSES_VERSION version: 10 updated: 2002/10/27 18:21:42
619 dnl ------------------
620 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
621 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
622 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
623 AC_DEFUN([CF_NCURSES_VERSION],
625 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
626 cf_cv_ncurses_version=no
630 #include <${cf_cv_ncurses_header-curses.h}>
634 FILE *fp = fopen("$cf_tempfile", "w");
635 #ifdef NCURSES_VERSION
636 # ifdef NCURSES_VERSION_PATCH
637 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
639 fprintf(fp, "%s\n", NCURSES_VERSION);
643 fprintf(fp, "old\n");
650 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
652 # This will not work if the preprocessor splits the line after the
653 # Autoconf token. The 'unproto' program does that.
654 cat > conftest.$ac_ext <<EOF
655 #include <${cf_cv_ncurses_header-curses.h}>
657 #ifdef NCURSES_VERSION
658 Autoconf NCURSES_VERSION
666 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
668 if test -f conftest.out ; then
669 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
670 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
676 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
678 dnl ---------------------------------------------------------------------------
679 dnl CF_PATH_SYNTAX version: 9 updated: 2002/09/17 23:03:38
681 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
682 dnl begins with one of the prefix/exec_prefix variables, and then again if the
683 dnl result begins with 'NONE'. This is necessary to work around autoconf's
684 dnl delayed evaluation of those symbols.
685 AC_DEFUN([CF_PATH_SYNTAX],[
686 case ".[$]$1" in #(vi
687 .\[$]\(*\)*|.\'*\'*) #(vi
691 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
693 .\[$]{*prefix}*) #(vi
695 case ".[$]$1" in #(vi
697 $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
702 $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
705 ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
709 dnl ---------------------------------------------------------------------------
710 dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
712 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
714 dnl $1 = symbol to test
715 dnl $2 = value (if any) to use for a predefinition
716 AC_DEFUN([CF_PREDEFINE],
718 AC_MSG_CHECKING(if we must define $1)
719 AC_TRY_COMPILE([#include <sys/types.h>
723 #endif],[cf_result=no],[cf_result=yes])
724 AC_MSG_RESULT($cf_result)
726 if test "$cf_result" = yes ; then
727 CPPFLAGS="$CPPFLAGS ifelse($2,,-D$1,[-D$1=$2])"
728 elif test "x$2" != "x" ; then
729 AC_MSG_CHECKING(checking for compatible value versus $2)
730 AC_TRY_COMPILE([#include <sys/types.h>
734 #endif],[cf_result=yes],[cf_result=no])
735 AC_MSG_RESULT($cf_result)
736 if test "$cf_result" = no ; then
737 # perhaps we can override it - try...
738 CPPFLAGS="$CPPFLAGS -D$1=$2"
742 dnl ---------------------------------------------------------------------------
743 dnl CF_SUBDIR_PATH version: 3 updated: 2002/12/29 18:30:46
745 dnl Construct a search-list for a nonstandard header/lib-file
746 dnl $1 = the variable to return as result
747 dnl $2 = the package name
748 dnl $3 = the subdirectory, e.g., bin, include or lib
749 AC_DEFUN([CF_SUBDIR_PATH],
753 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME"
754 test -d [$]HOME/$3 && $1="[$]$1 [$]HOME/$3"
755 test -d [$]HOME/$3/$2 && $1="[$]$1 [$]HOME/$3/$2"
756 test -d [$]HOME/$3/$2/$3 && $1="[$]$1 [$]HOME/$3/$2/$3"
759 # For other stuff under the home directory, it should be sufficient to put
760 # a symbolic link for $HOME/$2 to the actual package location:
761 test -d [$]HOME/$2 && {
762 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME/$2"
763 test -d [$]HOME/$2/$3 && $1="[$]$1 [$]HOME/$2/$3"
764 test -d [$]HOME/$2/$3/$2 && $1="[$]$1 [$]HOME/$2/$3/$2"
767 test "$prefix" != /usr/local && \
768 test -d /usr/local && {
769 test -n "$verbose" && echo " ... testing $3-directories under /usr/local"
770 test -d /usr/local/$3 && $1="[$]$1 /usr/local/$3"
771 test -d /usr/local/$3/$2 && $1="[$]$1 /usr/local/$3/$2"
772 test -d /usr/local/$3/$2/$3 && $1="[$]$1 /usr/local/$3/$2/$3"
773 test -d /usr/local/$2/$3 && $1="[$]$1 /usr/local/$2/$3"
774 test -d /usr/local/$2/$3/$2 && $1="[$]$1 /usr/local/$2/$3/$2"
777 test "$prefix" != NONE && \
779 test -n "$verbose" && echo " ... testing $3-directories under $prefix"
780 test -d $prefix/$3 && $1="[$]$1 $prefix/$3"
781 test -d $prefix/$3/$2 && $1="[$]$1 $prefix/$3/$2"
782 test -d $prefix/$3/$2/$3 && $1="[$]$1 $prefix/$3/$2/$3"
783 test -d $prefix/$2/$3 && $1="[$]$1 $prefix/$2/$3"
784 test -d $prefix/$2/$3/$2 && $1="[$]$1 $prefix/$2/$3/$2"
787 test "$prefix" != /opt && \
789 test -n "$verbose" && echo " ... testing $3-directories under /opt"
790 test -d /opt/$3 && $1="[$]$1 /opt/$3"
791 test -d /opt/$3/$2 && $1="[$]$1 /opt/$3/$2"
792 test -d /opt/$3/$2/$3 && $1="[$]$1 /opt/$3/$2/$3"
793 test -d /opt/$2/$3 && $1="[$]$1 /opt/$2/$3"
794 test -d /opt/$2/$3/$2 && $1="[$]$1 /opt/$2/$3/$2"
797 test "$prefix" != /usr && \
799 test -n "$verbose" && echo " ... testing $3-directories under /usr"
800 test -d /usr/$3 && $1="[$]$1 /usr/$3"
801 test -d /usr/$3/$2 && $1="[$]$1 /usr/$3/$2"
802 test -d /usr/$3/$2/$3 && $1="[$]$1 /usr/$3/$2/$3"
803 test -d /usr/$2/$3 && $1="[$]$1 /usr/$2/$3"
806 dnl ---------------------------------------------------------------------------
807 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
808 dnl ------------------
809 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
810 dnl older SCO configurations.
811 AC_DEFUN([CF_SYS_TIME_SELECT],
813 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
814 AC_CACHE_VAL(cf_cv_sys_time_select,[
816 #include <sys/types.h>
817 #ifdef HAVE_SYS_TIME_H
818 #include <sys/time.h>
820 #ifdef HAVE_SYS_SELECT_H
821 #include <sys/select.h>
823 ],[],[cf_cv_sys_time_select=yes],
824 [cf_cv_sys_time_select=no])
826 AC_MSG_RESULT($cf_cv_sys_time_select)
827 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
829 dnl ---------------------------------------------------------------------------
830 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
832 dnl Make an uppercase version of a variable
836 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
838 dnl ---------------------------------------------------------------------------
839 dnl CF_UTF8_LIB version: 4 updated: 2003/03/01 18:36:42
841 dnl Check for multibyte support, and if not found, utf8 compatibility library
842 AC_DEFUN([CF_UTF8_LIB],
844 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
847 #include <stdlib.h>],[putwc(0,0);],
848 [cf_cv_utf8_lib=yes],
851 #include <libutf8.h>],[putwc(0,0);],
852 [cf_cv_utf8_lib=add-on],
857 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
859 if test "$cf_cv_utf8_lib" = "add-on" ; then
860 AC_DEFINE(HAVE_LIBUTF8_H)
864 dnl ---------------------------------------------------------------------------
865 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
866 dnl ------------------
867 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
869 AC_DEFUN([CF_WITH_CURSES_DIR],[
870 AC_ARG_WITH(curses-dir,
871 [ --with-curses-dir=DIR directory in which (n)curses is installed],
872 [CF_PATH_SYNTAX(withval)
873 cf_cv_curses_dir=$withval],
874 [cf_cv_curses_dir=no])