1 dnl $Id: aclocal.m4,v 1.8 2005/02/27 00:02:01 tom Exp $
2 dnl ---------------------------------------------------------------------------
3 dnl ---------------------------------------------------------------------------
4 dnl CF_ADD_CFLAGS version: 7 updated: 2004/04/25 17:48:30
6 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
7 dnl The second parameter if given makes this macro verbose.
9 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
10 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
11 dnl confused by the quotes (which require backslashes to keep them usable).
12 AC_DEFUN([CF_ADD_CFLAGS],
17 cf_new_extra_cppflags=
19 for cf_add_cflags in $1
21 case $cf_fix_cppflags in
23 case $cf_add_cflags in #(vi
24 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
25 case $cf_add_cflags in
27 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
29 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
30 && test -z "${cf_tst_cflags}" \
31 && cf_fix_cppflags=yes
33 if test $cf_fix_cppflags = yes ; then
34 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
36 elif test "${cf_tst_cflags}" = "\"'" ; then
37 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
46 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
51 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
56 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
58 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
60 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
61 && test -z "${cf_tst_cflags}" \
67 if test -n "$cf_new_cflags" ; then
68 ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
69 CFLAGS="$CFLAGS $cf_new_cflags"
72 if test -n "$cf_new_cppflags" ; then
73 ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
74 CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
77 if test -n "$cf_new_extra_cppflags" ; then
78 ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
79 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
82 AC_SUBST(EXTRA_CPPFLAGS)
85 dnl ---------------------------------------------------------------------------
86 dnl CF_ADD_INCDIR version: 4 updated: 2002/12/21 14:25:52
88 dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's
89 dnl redundant. We don't normally need to add -I/usr/local/include for gcc,
90 dnl but old versions (and some misinstalled ones) need that. To make things
91 dnl worse, gcc 3.x gives error messages if -I/usr/local/include is added to
92 dnl the include-path).
93 AC_DEFUN([CF_ADD_INCDIR],
95 for cf_add_incdir in $1
99 case $cf_add_incdir in
102 /usr/local/include) # (vi
105 cf_save_CPPFLAGS="$CPPFLAGS"
106 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
107 AC_TRY_COMPILE([#include <stdio.h>],
110 [CPPFLAGS="$cf_save_CPPFLAGS"])
114 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
117 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
118 test "$cf_top_incdir" = "$cf_add_incdir" && break
119 cf_add_incdir="$cf_top_incdir"
123 dnl ---------------------------------------------------------------------------
124 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
126 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
127 dnl in the sharutils 4.2 distribution.
128 AC_DEFUN([CF_ANSI_CC_CHECK],
130 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
132 cf_save_CFLAGS="$CFLAGS"
133 cf_save_CPPFLAGS="$CPPFLAGS"
134 # Don't try gcc -ansi; that turns off useful extensions and
135 # breaks some systems' header files.
137 # Ultrix and OSF/1 -std1
138 # HP-UX -Aa -D_HPUX_SOURCE
140 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
141 for cf_arg in "-DCC_HAS_PROTOS" \
146 "-Aa -D_HPUX_SOURCE" \
149 CF_ADD_CFLAGS($cf_arg)
152 #ifndef CC_HAS_PROTOS
153 #if !defined(__STDC__) || (__STDC__ != 1)
158 int test (int i, double x);
159 struct s1 {int (*f) (int a);};
160 struct s2 {int (*f) (double a);};],
161 [cf_cv_ansi_cc="$cf_arg"; break])
163 CFLAGS="$cf_save_CFLAGS"
164 CPPFLAGS="$cf_save_CPPFLAGS"
167 if test "$cf_cv_ansi_cc" != "no"; then
168 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
169 CF_ADD_CFLAGS($cf_cv_ansi_cc)
171 AC_DEFINE(CC_HAS_PROTOS)
175 dnl ---------------------------------------------------------------------------
176 dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
178 dnl For programs that must use an ANSI compiler, obtain compiler options that
179 dnl will make it recognize prototypes. We'll do preprocessor checks in other
180 dnl macros, since tools such as unproto can fake prototypes, but only part of
181 dnl the preprocessor.
182 AC_DEFUN([CF_ANSI_CC_REQD],
183 [AC_REQUIRE([CF_ANSI_CC_CHECK])
184 if test "$cf_cv_ansi_cc" = "no"; then
186 [Your compiler does not appear to recognize prototypes.
187 You have the following choices:
188 a. adjust your compiler options
189 b. get an up-to-date compiler
190 c. use a wrapper such as unproto])
193 dnl ---------------------------------------------------------------------------
194 dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
196 dnl Check if we're accidentally using a cache from a different machine.
197 dnl Derive the system name, as a check for reusing the autoconf cache.
199 dnl If we've packaged config.guess and config.sub, run that (since it does a
200 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
201 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
202 dnl which is useful in cross-compiles.
204 dnl Note: we would use $ac_config_sub, but that is one of the places where
205 dnl autoconf 2.5x broke compatibility with autoconf 2.13
206 AC_DEFUN([CF_CHECK_CACHE],
208 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
209 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
210 system_name="$host_os"
212 system_name="`(uname -s -r) 2>/dev/null`"
213 if test -z "$system_name" ; then
214 system_name="`(hostname) 2>/dev/null`"
217 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
218 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
220 test -z "$system_name" && system_name="$cf_cv_system_name"
221 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
223 if test ".$system_name" != ".$cf_cv_system_name" ; then
224 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
225 AC_ERROR("Please remove config.cache and try again.")
228 dnl ---------------------------------------------------------------------------
229 dnl CF_CURSES_ACS_MAP version: 3 updated: 2003/05/17 22:19:02
230 dnl -----------------
231 dnl Check for likely values of acs_map[]:
232 AC_DEFUN([CF_CURSES_ACS_MAP],
234 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
235 cf_cv_curses_acs_map=unknown
236 for name in acs_map _acs_map __acs_map _nc_acs_map
239 #include <${cf_cv_ncurses_header-curses.h}>
241 $name['k'] = ACS_PLUS
242 ],[cf_cv_curses_acs_map=$name; break])
246 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
248 dnl ---------------------------------------------------------------------------
249 dnl CF_CURSES_CHECK_TYPE version: 2 updated: 2003/03/01 23:40:33
250 dnl --------------------
251 dnl Check if curses.h defines the given type
252 AC_DEFUN([CF_CURSES_CHECK_TYPE],
254 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header-curses.h})
256 #ifndef _XOPEN_SOURCE_EXTENDED
257 #define _XOPEN_SOURCE_EXTENDED
259 #include <${cf_cv_ncurses_header-curses.h}>],[
261 ],cf_result=yes,cf_result=no)
262 AC_MSG_RESULT($cf_result)
263 if test $cf_result = yes ; then
264 CF_UPPER(cf_result,have_type_$1)
265 AC_DEFINE_UNQUOTED($cf_result)
267 AC_DEFINE_UNQUOTED($1,$2)
270 dnl ---------------------------------------------------------------------------
271 dnl CF_CURSES_CPPFLAGS version: 7 updated: 2003/06/06 00:48:41
272 dnl ------------------
273 dnl Look for the curses headers.
274 AC_DEFUN([CF_CURSES_CPPFLAGS],[
276 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
277 cf_cv_curses_incdir=no
278 case $host_os in #(vi
279 hpux10.*|hpux11.*) #(vi
280 test -d /usr/include/curses_colr && \
281 cf_cv_curses_incdir="-I/usr/include/curses_colr"
284 test -d /usr/5lib && \
285 test -d /usr/5include && \
286 cf_cv_curses_incdir="-I/usr/5include"
290 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
292 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
293 cf_cv_ncurses_header=none
300 AC_TRY_COMPILE([#include <${cf_header}>],
301 [initscr(); tgoto("?", 0,0)],
302 [cf_cv_ncurses_header=$cf_header; break],[])
306 if test "$cf_cv_ncurses_header" = none ; then
307 AC_MSG_ERROR(No curses header-files found)
310 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
311 AC_CHECK_HEADERS($cf_cv_ncurses_header)
314 dnl ---------------------------------------------------------------------------
315 dnl CF_CURSES_LIBS version: 23 updated: 2003/11/06 19:59:57
317 dnl Look for the curses libraries. Older curses implementations may require
318 dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
319 AC_DEFUN([CF_CURSES_LIBS],[
321 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
322 AC_MSG_CHECKING(if we have identified curses libraries)
323 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
324 [initscr(); tgoto("?", 0,0)],
327 AC_MSG_RESULT($cf_result)
329 if test "$cf_result" = no ; then
330 case $host_os in #(vi
332 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
334 hpux10.*|hpux11.*) #(vi
335 AC_CHECK_LIB(cur_colr,initscr,[
336 LIBS="-lcur_colr $LIBS"
337 ac_cv_func_initscr=yes
339 AC_CHECK_LIB(Hcurses,initscr,[
340 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
341 LIBS="-lHcurses $LIBS"
342 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
343 ac_cv_func_initscr=yes
346 linux*) # Suse Linux does not follow /usr/lib convention
350 test -d /usr/5lib && \
351 LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap"
352 ac_cv_func_initscr=yes
356 if test ".$ac_cv_func_initscr" != .yes ; then
361 if test ".${cf_cv_ncurses_version-no}" != .no
363 cf_check_list="ncurses curses cursesX"
365 cf_check_list="cursesX curses ncurses"
368 # Check for library containing tgoto. Do this before curses library
369 # because it may be needed to link the test-case for initscr.
370 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
371 for cf_term_lib in $cf_check_list termcap termlib unknown
373 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
377 # Check for library containing initscr
378 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
379 for cf_curs_lib in $cf_check_list xcurses jcurses unknown
381 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
383 test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
385 LIBS="-l$cf_curs_lib $cf_save_LIBS"
386 if test "$cf_term_lib" = unknown ; then
387 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
388 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
392 AC_MSG_RESULT($cf_result)
393 test $cf_result = no && AC_ERROR(Cannot link curses library)
394 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
396 elif test "$cf_term_lib" != predefined ; then
397 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
398 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
399 [initscr(); tgoto((char *)0, 0, 0);],
402 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
403 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
408 AC_MSG_RESULT($cf_result)
414 dnl ---------------------------------------------------------------------------
415 dnl CF_CURSES_WACS_MAP version: 3 updated: 2003/05/17 22:19:02
416 dnl ------------------
417 dnl Check for likely values of wacs_map[]:
418 AC_DEFUN([CF_CURSES_WACS_MAP],
420 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
421 cf_cv_curses_wacs_map=unknown
422 for name in wacs_map _wacs_map __wacs_map _nc_wacs
425 #ifndef _XOPEN_SOURCE_EXTENDED
426 #define _XOPEN_SOURCE_EXTENDED
428 #include <${cf_cv_ncurses_header-curses.h}>],
429 [$name['k'] = *WACS_PLUS],
430 [cf_cv_curses_wacs_map=$name
434 dnl ---------------------------------------------------------------------------
435 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
437 dnl "dirname" is not portable, so we fake it with a shell script.
438 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
439 dnl ---------------------------------------------------------------------------
440 dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
442 dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
443 dnl prefer a standard location, and use -L options only if we do not find the
444 dnl library in the standard library location(s).
445 dnl $1 = library name
446 dnl $2 = library class, usually the same as library name
448 dnl $4 = code fragment to compile/link
449 dnl $5 = corresponding function-name
450 dnl $6 = flag, nonnull if failure should not cause an error-exit
452 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
453 dnl to use a -L option.
454 AC_DEFUN([CF_FIND_LIBRARY],
456 eval 'cf_cv_have_lib_'$1'=no'
459 eval 'cf_cv_have_lib_'$1'=yes',[
461 AC_MSG_CHECKING(for $5 in -l$1)
463 AC_TRY_LINK([$3],[$4],
465 eval 'cf_cv_have_lib_'$1'=yes'
468 CF_LIBRARY_PATH(cf_search,$2)
469 for cf_libdir in $cf_search
471 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
472 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
473 AC_TRY_LINK([$3],[$4],
475 eval 'cf_cv_have_lib_'$1'=yes'
478 LIBS="$cf_save_LIBS"])
482 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
484 if test $cf_found_library = no ; then
485 AC_ERROR(Cannot link $1 library)
489 dnl ---------------------------------------------------------------------------
490 dnl CF_FUNC_CURSES_VERSION version: 3 updated: 2003/05/17 22:19:02
491 dnl ----------------------
492 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
493 dnl It's a character string "SVR4", not documented.
494 AC_DEFUN([CF_FUNC_CURSES_VERSION],
496 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
498 #include <${cf_cv_ncurses_header-curses.h}>
502 sprintf(temp, "%s\n", curses_version());
505 ,[cf_cv_func_curses_version=yes]
506 ,[cf_cv_func_curses_version=no]
507 ,[cf_cv_func_curses_version=unknown])
509 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
511 dnl ---------------------------------------------------------------------------
512 dnl CF_GNU_SOURCE version: 4 updated: 2004/12/03 20:43:00
514 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
515 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
516 dnl (or misfeature) of glibc2, which breaks portability of many applications,
517 dnl since it is interwoven with GNU extensions.
519 dnl Well, yes we could work around it...
520 AC_DEFUN([CF_GNU_SOURCE],
522 AC_REQUIRE([CF_INTEL_COMPILER])
524 if test "$INTEL_COMPILER" = no ; then
525 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
526 AC_TRY_COMPILE([#include <sys/types.h>],[
527 #ifndef _XOPEN_SOURCE
530 [cf_cv_gnu_source=no],
532 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
533 AC_TRY_COMPILE([#include <sys/types.h>],[
537 [cf_cv_gnu_source=no],
538 [cf_cv_gnu_source=yes])
542 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
545 dnl ---------------------------------------------------------------------------
546 dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
548 dnl Construct a search-list for a nonstandard header-file
549 AC_DEFUN([CF_HEADER_PATH],
550 [CF_SUBDIR_PATH($1,$2,include)
551 test "$includedir" != NONE && \
552 test "$includedir" != "/usr/include" && \
553 test -d "$includedir" && {
554 test -d $includedir && $1="[$]$1 $includedir"
555 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
558 test "$oldincludedir" != NONE && \
559 test "$oldincludedir" != "/usr/include" && \
560 test -d "$oldincludedir" && {
561 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
562 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
566 dnl ---------------------------------------------------------------------------
567 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
568 dnl -----------------
569 dnl If we do not have a given script, look for it in the parent directory.
570 AC_DEFUN([CF_INHERIT_SCRIPT],
572 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
574 dnl ---------------------------------------------------------------------------
575 dnl CF_INTEL_COMPILER version: 1 updated: 2004/12/03 20:27:48
576 dnl -----------------
577 dnl Check if the given compiler is really the Intel compiler for Linux.
578 dnl It tries to imitate gcc, but does not return an error when it finds a
579 dnl mismatch between prototypes, e.g., as exercised by CF_MISSING_CHECK.
581 dnl This macro should be run "soon" after AC_PROG_CC, to ensure that it is
582 dnl not mistaken for gcc.
583 AC_DEFUN([CF_INTEL_COMPILER],[
584 AC_REQUIRE([AC_PROG_CC])
588 if test "$GCC" = yes ; then
591 AC_MSG_CHECKING(if this is really Intel compiler)
592 cf_save_CFLAGS="$CFLAGS"
593 CFLAGS="$CFLAGS -no-gcc"
595 #ifdef __INTEL_COMPILER
599 ],[INTEL_COMPILER=yes
600 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
602 CFLAGS="$cf_save_CFLAGS"
603 AC_MSG_RESULT($INTEL_COMPILER)
608 dnl ---------------------------------------------------------------------------
609 dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
611 dnl Construct a search-list for a nonstandard library-file
612 AC_DEFUN([CF_LIBRARY_PATH],
613 [CF_SUBDIR_PATH($1,$2,lib)])dnl
614 dnl ---------------------------------------------------------------------------
615 dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
617 dnl Write a debug message to config.log, along with the line number in the
618 dnl configure script.
619 AC_DEFUN([CF_MSG_LOG],[
620 echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
622 dnl ---------------------------------------------------------------------------
623 dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
624 dnl -------------------
625 dnl Check if we can compile with ncurses' header file
626 dnl $1 is the cache variable to set
627 dnl $2 is the header-file to include
628 dnl $3 is the root name (ncurses or ncursesw)
629 AC_DEFUN([CF_NCURSES_CC_CHECK],[
631 ]ifelse($3,ncursesw,[
632 #define _XOPEN_SOURCE_EXTENDED
633 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
634 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
637 #ifdef NCURSES_VERSION
638 ]ifelse($3,ncursesw,[
643 printf("%s\n", NCURSES_VERSION);
655 dnl ---------------------------------------------------------------------------
656 dnl CF_NCURSES_CPPFLAGS version: 17 updated: 2003/11/06 19:59:57
657 dnl -------------------
658 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
659 dnl the CPPFLAGS variable so we can include its header.
661 dnl The header files may be installed as either curses.h, or ncurses.h (would
662 dnl be obsolete, except that some packagers prefer this name to distinguish it
663 dnl from a "native" curses implementation). If not installed for overwrite,
664 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
665 dnl /usr/include/ncurses), but someone may have installed overwriting the
666 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
667 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
670 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
671 dnl is already in the include-path, don't even bother with this, since we cannot
672 dnl easily determine which file it is. In this case, it has to be <curses.h>.
674 dnl The optional parameter gives the root name of the library, in case it is
675 dnl not installed as the default curses library. That is how the
676 dnl wide-character version of ncurses is installed.
677 AC_DEFUN([CF_NCURSES_CPPFLAGS],
678 [AC_REQUIRE([CF_WITH_CURSES_DIR])
680 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
681 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
683 test -n "$cf_cv_curses_dir" && \
684 test "$cf_cv_curses_dir" != "no" && \
685 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
687 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
688 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
689 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
690 for cf_header in $cf_header_list
692 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
693 test "$cf_cv_ncurses_h" != no && break
697 if test "$cf_cv_ncurses_h" != no ; then
698 cf_cv_ncurses_header=$cf_cv_ncurses_h
700 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
701 test -n "$verbose" && echo
702 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
703 test -n "$verbose" && echo search path $cf_search
704 cf_save2_CPPFLAGS="$CPPFLAGS"
705 for cf_incdir in $cf_search
707 CF_ADD_INCDIR($cf_incdir)
712 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
713 if test "$cf_cv_ncurses_h2" != no ; then
714 cf_cv_ncurses_h2=$cf_incdir/$cf_header
715 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
718 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
720 CPPFLAGS="$cf_save2_CPPFLAGS"
721 test "$cf_cv_ncurses_h2" != no && break
723 test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found)
726 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
727 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
728 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
729 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
731 CF_ADD_INCDIR($cf_1st_incdir)
737 case $cf_cv_ncurses_header in # (vi
739 AC_DEFINE(HAVE_NCURSES_H)
743 case $cf_cv_ncurses_header in # (vi
744 ncurses/curses.h|ncurses/ncurses.h)
745 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
747 ncursesw/curses.h|ncursesw/ncurses.h)
748 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
754 dnl ---------------------------------------------------------------------------
755 dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05
757 dnl Look for the ncurses library. This is a little complicated on Linux,
758 dnl because it may be linked with the gpm (general purpose mouse) library.
759 dnl Some distributions have gpm linked with (bsd) curses, which makes it
760 dnl unusable with ncurses. However, we don't want to link with gpm unless
761 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
762 dnl and the linker will record a dependency.
764 dnl The optional parameter gives the root name of the library, in case it is
765 dnl not installed as the default curses library. That is how the
766 dnl wide-character version of ncurses is installed.
767 AC_DEFUN([CF_NCURSES_LIBS],
768 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
770 cf_nculib_root=ifelse($1,,ncurses,$1)
771 # This works, except for the special case where we find gpm, but
772 # ncurses is in a nonstandard location via $LIBS, and we really want
775 cf_ncurses_SAVE="$LIBS"
776 AC_CHECK_LIB(gpm,Gpm_Open,
777 [AC_CHECK_LIB(gpm,initscr,
778 [LIBS="$cf_ncurses_SAVE"],
779 [cf_ncurses_LIBS="-lgpm"])])
781 case $host_os in #(vi
783 # This is only necessary if you are linking against an obsolete
784 # version of ncurses (but it should do no harm, since it's static).
785 if test "$cf_nculib_root" = ncurses ; then
786 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
791 LIBS="$cf_ncurses_LIBS $LIBS"
793 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
795 LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
797 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
798 [#include <${cf_cv_ncurses_header-curses.h}>],
803 if test -n "$cf_ncurses_LIBS" ; then
804 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
805 cf_ncurses_SAVE="$LIBS"
806 for p in $cf_ncurses_LIBS ; do
807 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
808 if test "$q" != "$LIBS" ; then
812 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
813 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
814 [AC_MSG_RESULT(yes)],
816 LIBS="$cf_ncurses_SAVE"])
819 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
820 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
822 dnl ---------------------------------------------------------------------------
823 dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57
824 dnl ------------------
825 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
826 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
827 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
828 AC_DEFUN([CF_NCURSES_VERSION],
830 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
831 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
832 cf_cv_ncurses_version=no
836 #include <${cf_cv_ncurses_header-curses.h}>
840 FILE *fp = fopen("$cf_tempfile", "w");
841 #ifdef NCURSES_VERSION
842 # ifdef NCURSES_VERSION_PATCH
843 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
845 fprintf(fp, "%s\n", NCURSES_VERSION);
849 fprintf(fp, "old\n");
856 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
858 # This will not work if the preprocessor splits the line after the
859 # Autoconf token. The 'unproto' program does that.
860 cat > conftest.$ac_ext <<EOF
861 #include <${cf_cv_ncurses_header-curses.h}>
863 #ifdef NCURSES_VERSION
864 Autoconf NCURSES_VERSION
872 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
874 if test -f conftest.out ; then
875 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
876 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
882 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
884 dnl ---------------------------------------------------------------------------
885 dnl CF_PATH_SYNTAX version: 9 updated: 2002/09/17 23:03:38
887 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
888 dnl begins with one of the prefix/exec_prefix variables, and then again if the
889 dnl result begins with 'NONE'. This is necessary to work around autoconf's
890 dnl delayed evaluation of those symbols.
891 AC_DEFUN([CF_PATH_SYNTAX],[
892 case ".[$]$1" in #(vi
893 .\[$]\(*\)*|.\'*\'*) #(vi
897 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
899 .\[$]{*prefix}*) #(vi
901 case ".[$]$1" in #(vi
903 $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
908 $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
911 ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
915 dnl ---------------------------------------------------------------------------
916 dnl CF_POSIX_C_SOURCE version: 3 updated: 2005/02/04 06:56:22
917 dnl -----------------
918 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
920 dnl POSIX.1-1990 _POSIX_SOURCE
921 dnl POSIX.1-1990 and _POSIX_SOURCE and
922 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
924 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
925 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
926 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
929 dnl $1 is the nominal value for _POSIX_C_SOURCE
930 AC_DEFUN([CF_POSIX_C_SOURCE],
932 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
933 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
934 CF_MSG_LOG(if the symbol is already defined go no further)
935 AC_TRY_COMPILE([#include <sys/types.h>],[
936 #ifndef _POSIX_C_SOURCE
939 [cf_cv_posix_c_source=no],
940 [cf_want_posix_source=no
941 case .$cf_POSIX_C_SOURCE in
943 cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
946 cf_cv_posix_c_source="-U_POSIX_C_SOURCE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
947 cf_want_posix_source=yes
950 cf_want_posix_source=yes
953 if test "$cf_want_posix_source" = yes ; then
954 AC_TRY_COMPILE([#include <sys/types.h>],[
958 cf_cv_posix_c_source="$cf_cv_posix_c_source -U_POSIX_SOURCE -D_POSIX_SOURCE")
960 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
962 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
963 CF_MSG_LOG(if the second compile does not leave our definition intact error)
964 AC_TRY_COMPILE([#include <sys/types.h>],[
965 #ifndef _POSIX_C_SOURCE
968 [cf_cv_posix_c_source=no])
972 test "$cf_cv_posix_c_source" != no && CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
974 dnl ---------------------------------------------------------------------------
975 dnl CF_SUBDIR_PATH version: 3 updated: 2002/12/29 18:30:46
977 dnl Construct a search-list for a nonstandard header/lib-file
978 dnl $1 = the variable to return as result
979 dnl $2 = the package name
980 dnl $3 = the subdirectory, e.g., bin, include or lib
981 AC_DEFUN([CF_SUBDIR_PATH],
985 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME"
986 test -d [$]HOME/$3 && $1="[$]$1 [$]HOME/$3"
987 test -d [$]HOME/$3/$2 && $1="[$]$1 [$]HOME/$3/$2"
988 test -d [$]HOME/$3/$2/$3 && $1="[$]$1 [$]HOME/$3/$2/$3"
991 # For other stuff under the home directory, it should be sufficient to put
992 # a symbolic link for $HOME/$2 to the actual package location:
993 test -d [$]HOME/$2 && {
994 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME/$2"
995 test -d [$]HOME/$2/$3 && $1="[$]$1 [$]HOME/$2/$3"
996 test -d [$]HOME/$2/$3/$2 && $1="[$]$1 [$]HOME/$2/$3/$2"
999 test "$prefix" != /usr/local && \
1000 test -d /usr/local && {
1001 test -n "$verbose" && echo " ... testing $3-directories under /usr/local"
1002 test -d /usr/local/$3 && $1="[$]$1 /usr/local/$3"
1003 test -d /usr/local/$3/$2 && $1="[$]$1 /usr/local/$3/$2"
1004 test -d /usr/local/$3/$2/$3 && $1="[$]$1 /usr/local/$3/$2/$3"
1005 test -d /usr/local/$2/$3 && $1="[$]$1 /usr/local/$2/$3"
1006 test -d /usr/local/$2/$3/$2 && $1="[$]$1 /usr/local/$2/$3/$2"
1009 test "$prefix" != NONE && \
1010 test -d $prefix && {
1011 test -n "$verbose" && echo " ... testing $3-directories under $prefix"
1012 test -d $prefix/$3 && $1="[$]$1 $prefix/$3"
1013 test -d $prefix/$3/$2 && $1="[$]$1 $prefix/$3/$2"
1014 test -d $prefix/$3/$2/$3 && $1="[$]$1 $prefix/$3/$2/$3"
1015 test -d $prefix/$2/$3 && $1="[$]$1 $prefix/$2/$3"
1016 test -d $prefix/$2/$3/$2 && $1="[$]$1 $prefix/$2/$3/$2"
1019 test "$prefix" != /opt && \
1021 test -n "$verbose" && echo " ... testing $3-directories under /opt"
1022 test -d /opt/$3 && $1="[$]$1 /opt/$3"
1023 test -d /opt/$3/$2 && $1="[$]$1 /opt/$3/$2"
1024 test -d /opt/$3/$2/$3 && $1="[$]$1 /opt/$3/$2/$3"
1025 test -d /opt/$2/$3 && $1="[$]$1 /opt/$2/$3"
1026 test -d /opt/$2/$3/$2 && $1="[$]$1 /opt/$2/$3/$2"
1029 test "$prefix" != /usr && \
1031 test -n "$verbose" && echo " ... testing $3-directories under /usr"
1032 test -d /usr/$3 && $1="[$]$1 /usr/$3"
1033 test -d /usr/$3/$2 && $1="[$]$1 /usr/$3/$2"
1034 test -d /usr/$3/$2/$3 && $1="[$]$1 /usr/$3/$2/$3"
1035 test -d /usr/$2/$3 && $1="[$]$1 /usr/$2/$3"
1038 dnl ---------------------------------------------------------------------------
1039 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1040 dnl ------------------
1041 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1042 dnl older SCO configurations.
1043 AC_DEFUN([CF_SYS_TIME_SELECT],
1045 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1046 AC_CACHE_VAL(cf_cv_sys_time_select,[
1048 #include <sys/types.h>
1049 #ifdef HAVE_SYS_TIME_H
1050 #include <sys/time.h>
1052 #ifdef HAVE_SYS_SELECT_H
1053 #include <sys/select.h>
1055 ],[],[cf_cv_sys_time_select=yes],
1056 [cf_cv_sys_time_select=no])
1058 AC_MSG_RESULT($cf_cv_sys_time_select)
1059 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1061 dnl ---------------------------------------------------------------------------
1062 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1064 dnl Make an uppercase version of a variable
1065 dnl $1=uppercase($2)
1066 AC_DEFUN([CF_UPPER],
1068 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1070 dnl ---------------------------------------------------------------------------
1071 dnl CF_UTF8_LIB version: 4 updated: 2003/03/01 18:36:42
1073 dnl Check for multibyte support, and if not found, utf8 compatibility library
1074 AC_DEFUN([CF_UTF8_LIB],
1076 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
1077 cf_save_LIBS="$LIBS"
1079 #include <stdlib.h>],[putwc(0,0);],
1080 [cf_cv_utf8_lib=yes],
1081 [LIBS="-lutf8 $LIBS"
1083 #include <libutf8.h>],[putwc(0,0);],
1084 [cf_cv_utf8_lib=add-on],
1085 [cf_cv_utf8_lib=no])
1086 LIBS="$cf_save_LIBS"
1089 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
1091 if test "$cf_cv_utf8_lib" = "add-on" ; then
1092 AC_DEFINE(HAVE_LIBUTF8_H)
1096 dnl ---------------------------------------------------------------------------
1097 dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
1099 dnl Use AC_VERBOSE w/o the warnings
1100 AC_DEFUN([CF_VERBOSE],
1101 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1103 dnl ---------------------------------------------------------------------------
1104 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
1105 dnl ------------------
1106 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
1108 AC_DEFUN([CF_WITH_CURSES_DIR],[
1109 AC_ARG_WITH(curses-dir,
1110 [ --with-curses-dir=DIR directory in which (n)curses is installed],
1111 [CF_PATH_SYNTAX(withval)
1112 cf_cv_curses_dir=$withval],
1113 [cf_cv_curses_dir=no])
1115 dnl ---------------------------------------------------------------------------
1116 dnl CF_XOPEN_SOURCE version: 17 updated: 2005/02/06 12:07:45
1118 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1119 dnl or adapt to the vendor's definitions to get equivalent functionality.
1122 dnl $1 is the nominal value for _XOPEN_SOURCE
1123 dnl $2 is the nominal value for _POSIX_C_SOURCE
1124 AC_DEFUN([CF_XOPEN_SOURCE],[
1126 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
1127 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
1129 case $host_os in #(vi
1131 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
1134 # 5.x headers associate
1135 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1136 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1137 cf_POSIX_C_SOURCE=200112L
1139 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1142 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
1145 CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
1151 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
1154 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1157 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1160 CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
1163 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1166 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1169 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1170 AC_TRY_COMPILE([#include <sys/types.h>],[
1171 #ifndef _XOPEN_SOURCE
1174 [cf_cv_xopen_source=no],
1175 [cf_save="$CPPFLAGS"
1176 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1177 AC_TRY_COMPILE([#include <sys/types.h>],[
1178 #ifdef _XOPEN_SOURCE
1181 [cf_cv_xopen_source=no],
1182 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1186 test "$cf_cv_xopen_source" != no && CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE -D_XOPEN_SOURCE=$cf_cv_xopen_source"
1187 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)