1 dnl***************************************************************************
2 dnl Copyright (c) 2003-2008,2009 Free Software Foundation, Inc. *
4 dnl Permission is hereby granted, free of charge, to any person obtaining a *
5 dnl copy of this software and associated documentation files (the *
6 dnl "Software"), to deal in the Software without restriction, including *
7 dnl without limitation the rights to use, copy, modify, merge, publish, *
8 dnl distribute, distribute with modifications, sublicense, and/or sell *
9 dnl copies of the Software, and to permit persons to whom the Software is *
10 dnl furnished to do so, subject to the following conditions: *
12 dnl The above copyright notice and this permission notice shall be included *
13 dnl in all copies or substantial portions of the Software. *
15 dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
23 dnl Except as contained in this notice, the name(s) of the above copyright *
24 dnl holders shall not be used in advertising or otherwise to promote the *
25 dnl sale, use or other dealings in this Software without prior written *
27 dnl***************************************************************************
29 dnl $Id: aclocal.m4,v 1.29 2009/07/17 01:07:50 tom Exp $
31 dnl Author: Thomas E. Dickey
33 dnl Macros used in NCURSES test programs auto-configuration script.
35 dnl These macros are maintained separately from NCURSES. The copyright on
36 dnl this file applies to the aggregation of macros and does not affect use of
37 dnl these macros in other applications.
39 dnl See http://invisible-island.net/autoconf/ for additional information.
41 dnl ---------------------------------------------------------------------------
42 dnl ---------------------------------------------------------------------------
43 dnl CF_ADD_CFLAGS version: 8 updated: 2009/01/06 19:33:30
45 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
46 dnl The second parameter if given makes this macro verbose.
48 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
49 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
50 dnl confused by the quotes (which require backslashes to keep them usable).
51 AC_DEFUN([CF_ADD_CFLAGS],
56 cf_new_extra_cppflags=
58 for cf_add_cflags in $1
60 case $cf_fix_cppflags in
62 case $cf_add_cflags in #(vi
63 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
64 case $cf_add_cflags in
66 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
68 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
69 && test -z "${cf_tst_cflags}" \
70 && cf_fix_cppflags=yes
72 if test $cf_fix_cppflags = yes ; then
73 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
75 elif test "${cf_tst_cflags}" = "\"'" ; then
76 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
85 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
90 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
95 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
97 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
99 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
100 && test -z "${cf_tst_cflags}" \
101 && cf_fix_cppflags=no
106 if test -n "$cf_new_cflags" ; then
107 ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
108 CFLAGS="$CFLAGS $cf_new_cflags"
111 if test -n "$cf_new_cppflags" ; then
112 ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
113 CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
116 if test -n "$cf_new_extra_cppflags" ; then
117 ifelse($2,,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
118 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
121 AC_SUBST(EXTRA_CPPFLAGS)
124 dnl ---------------------------------------------------------------------------
125 dnl CF_ADD_INCDIR version: 12 updated: 2009/01/18 10:00:47
127 dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's
128 dnl redundant. We don't normally need to add -I/usr/local/include for gcc,
129 dnl but old versions (and some misinstalled ones) need that. To make things
130 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
131 dnl the include-path).
132 AC_DEFUN([CF_ADD_INCDIR],
134 if test -n "$1" ; then
135 for cf_add_incdir in $1
137 while test $cf_add_incdir != /usr/include
139 if test -d $cf_add_incdir
142 if test -n "$CFLAGS$CPPFLAGS" ; then
143 # a loop is needed to ensure we can add subdirs of existing dirs
144 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
145 if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
146 cf_have_incdir=yes; break
151 if test "$cf_have_incdir" = no ; then
152 if test "$cf_add_incdir" = /usr/local/include ; then
155 cf_save_CPPFLAGS=$CPPFLAGS
156 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
157 AC_TRY_COMPILE([#include <stdio.h>],
160 [cf_have_incdir=yes])
161 CPPFLAGS=$cf_save_CPPFLAGS
166 if test "$cf_have_incdir" = no ; then
167 CF_VERBOSE(adding $cf_add_incdir to include-path)
168 ifelse($2,,CPPFLAGS,$2)="$ifelse($2,,CPPFLAGS,$2) -I$cf_add_incdir"
170 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
171 test "$cf_top_incdir" = "$cf_add_incdir" && break
172 cf_add_incdir="$cf_top_incdir"
181 dnl ---------------------------------------------------------------------------
182 dnl CF_ADD_LIBDIR version: 8 updated: 2009/01/18 10:01:08
184 dnl Adds to the library-path
186 dnl Some machines have trouble with multiple -L options.
188 dnl $1 is the (list of) directory(s) to add
189 dnl $2 is the optional name of the variable to update (default LDFLAGS)
191 AC_DEFUN([CF_ADD_LIBDIR],
193 if test -n "$1" ; then
194 for cf_add_libdir in $1
196 if test $cf_add_libdir = /usr/lib ; then
198 elif test -d $cf_add_libdir
201 if test -n "$LDFLAGS$LIBS" ; then
202 # a loop is needed to ensure we can add subdirs of existing dirs
203 for cf_test_libdir in $LDFLAGS $LIBS ; do
204 if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
205 cf_have_libdir=yes; break
209 if test "$cf_have_libdir" = no ; then
210 CF_VERBOSE(adding $cf_add_libdir to library-path)
211 ifelse($2,,LDFLAGS,$2)="-L$cf_add_libdir $ifelse($2,,LDFLAGS,$2)"
217 dnl ---------------------------------------------------------------------------
218 dnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
219 dnl ------------------
220 dnl Append to a search-list for a nonstandard header/lib-file
221 dnl $1 = the variable to return as result
222 dnl $2 = the package name
223 dnl $3 = the subdirectory, e.g., bin, include or lib
224 dnl $4 = the directory under which we will test for subdirectories
225 dnl $5 = a directory that we do not want $4 to match
226 AC_DEFUN([CF_ADD_SUBDIR_PATH],
228 test "$4" != "$5" && \
230 ifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
231 test -n "$verbose" && echo " ... testing for $3-directories under $4"
232 test -d $4/$3 && $1="[$]$1 $4/$3"
233 test -d $4/$3/$2 && $1="[$]$1 $4/$3/$2"
234 test -d $4/$3/$2/$3 && $1="[$]$1 $4/$3/$2/$3"
235 test -d $4/$2/$3 && $1="[$]$1 $4/$2/$3"
236 test -d $4/$2/$3/$2 && $1="[$]$1 $4/$2/$3/$2"
239 dnl ---------------------------------------------------------------------------
240 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
242 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
243 dnl in the sharutils 4.2 distribution.
244 AC_DEFUN([CF_ANSI_CC_CHECK],
246 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
248 cf_save_CFLAGS="$CFLAGS"
249 cf_save_CPPFLAGS="$CPPFLAGS"
250 # Don't try gcc -ansi; that turns off useful extensions and
251 # breaks some systems' header files.
253 # Ultrix and OSF/1 -std1
254 # HP-UX -Aa -D_HPUX_SOURCE
256 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
257 for cf_arg in "-DCC_HAS_PROTOS" \
262 "-Aa -D_HPUX_SOURCE" \
265 CF_ADD_CFLAGS($cf_arg)
268 #ifndef CC_HAS_PROTOS
269 #if !defined(__STDC__) || (__STDC__ != 1)
274 int test (int i, double x);
275 struct s1 {int (*f) (int a);};
276 struct s2 {int (*f) (double a);};],
277 [cf_cv_ansi_cc="$cf_arg"; break])
279 CFLAGS="$cf_save_CFLAGS"
280 CPPFLAGS="$cf_save_CPPFLAGS"
283 if test "$cf_cv_ansi_cc" != "no"; then
284 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
285 CF_ADD_CFLAGS($cf_cv_ansi_cc)
287 AC_DEFINE(CC_HAS_PROTOS)
291 dnl ---------------------------------------------------------------------------
292 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
294 dnl For programs that must use an ANSI compiler, obtain compiler options that
295 dnl will make it recognize prototypes. We'll do preprocessor checks in other
296 dnl macros, since tools such as unproto can fake prototypes, but only part of
297 dnl the preprocessor.
298 AC_DEFUN([CF_ANSI_CC_REQD],
299 [AC_REQUIRE([CF_ANSI_CC_CHECK])
300 if test "$cf_cv_ansi_cc" = "no"; then
302 [Your compiler does not appear to recognize prototypes.
303 You have the following choices:
304 a. adjust your compiler options
305 b. get an up-to-date compiler
306 c. use a wrapper such as unproto])
309 dnl ---------------------------------------------------------------------------
310 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
312 dnl Allow user to disable a normally-on option.
313 AC_DEFUN([CF_ARG_DISABLE],
314 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
315 dnl ---------------------------------------------------------------------------
316 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
318 dnl Allow user to enable a normally-off option.
319 AC_DEFUN([CF_ARG_ENABLE],
320 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
321 dnl ---------------------------------------------------------------------------
322 dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
324 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
330 dnl $3 = action to perform if option is not default
331 dnl $4 = action if perform if option is default
332 dnl $5 = default option value (either 'yes' or 'no')
333 AC_DEFUN([CF_ARG_OPTION],
334 [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
335 if test "$enableval" != "$5" ; then
337 ,[ $3]) ifelse($4,,,[
340 fi],[enableval=$5 ifelse($4,,,[
344 dnl ---------------------------------------------------------------------------
345 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
347 dnl Check if we're accidentally using a cache from a different machine.
348 dnl Derive the system name, as a check for reusing the autoconf cache.
350 dnl If we've packaged config.guess and config.sub, run that (since it does a
351 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
352 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
353 dnl which is useful in cross-compiles.
355 dnl Note: we would use $ac_config_sub, but that is one of the places where
356 dnl autoconf 2.5x broke compatibility with autoconf 2.13
357 AC_DEFUN([CF_CHECK_CACHE],
359 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
360 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
361 system_name="$host_os"
363 system_name="`(uname -s -r) 2>/dev/null`"
364 if test -z "$system_name" ; then
365 system_name="`(hostname) 2>/dev/null`"
368 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
369 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
371 test -z "$system_name" && system_name="$cf_cv_system_name"
372 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
374 if test ".$system_name" != ".$cf_cv_system_name" ; then
375 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
376 AC_MSG_ERROR("Please remove config.cache and try again.")
379 dnl ---------------------------------------------------------------------------
380 dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
382 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
383 dnl a build-configuration such as imake. These have the pitfall that they
384 dnl often contain compiler-specific options which we cannot use, mixed with
385 dnl preprocessor options that we usually can.
386 AC_DEFUN([CF_CHECK_CFLAGS],
388 CF_VERBOSE(checking additions to CFLAGS)
389 cf_check_cflags="$CFLAGS"
390 cf_check_cppflags="$CPPFLAGS"
391 CF_ADD_CFLAGS($1,yes)
392 if test "$cf_check_cflags" != "$CFLAGS" ; then
393 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
394 [CF_VERBOSE(test-compile failed. Undoing change to \$CFLAGS)
395 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
396 CF_VERBOSE(but keeping change to \$CPPFLAGS)
398 CFLAGS="$cf_check_flags"])
401 dnl ---------------------------------------------------------------------------
402 dnl CF_CURSES_ACS_MAP version: 5 updated: 2009/03/28 16:08:10
403 dnl -----------------
404 dnl Check for likely values of acs_map[]:
405 AC_DEFUN([CF_CURSES_ACS_MAP],
407 AC_REQUIRE([CF_NCURSES_WRAP_PREFIX])dnl
408 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
409 cf_cv_curses_acs_map=unknown
410 for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
413 #include <${cf_cv_ncurses_header-curses.h}>
415 $name['k'] = ACS_PLUS
416 ],[cf_cv_curses_acs_map=$name; break])
420 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map)
422 dnl ---------------------------------------------------------------------------
423 dnl CF_CURSES_CHECK_DATA version: 2 updated: 2009/07/16 21:03:10
424 dnl --------------------
425 dnl Check if curses.h defines the given data/variable.
426 dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
427 AC_DEFUN([CF_CURSES_CHECK_DATA],
429 AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header-curses.h})
430 AC_TRY_COMPILE(CF__CURSES_HEAD,[
432 ],cf_result=yes,cf_result=no)
433 AC_MSG_RESULT($cf_result)
434 if test $cf_result = yes ; then
435 CF_UPPER(cf_result,have_curses_data_$1)
436 AC_DEFINE_UNQUOTED($cf_result)
438 AC_MSG_CHECKING(for data $1 in library)
439 AC_TRY_LINK(CF__CURSES_HEAD
443 ${cf_cv_main_return-return}(foo == 0);
445 ],[cf_result=yes],[cf_result=no])
446 AC_MSG_RESULT($cf_result)
447 if test $cf_result = yes ; then
448 CF_UPPER(cf_result,decl_curses_data_$1)
449 AC_DEFINE_UNQUOTED($cf_result)
453 dnl ---------------------------------------------------------------------------
454 dnl CF_CURSES_CHECK_TYPE version: 2 updated: 2003/03/01 23:40:33
455 dnl --------------------
456 dnl Check if curses.h defines the given type
457 AC_DEFUN([CF_CURSES_CHECK_TYPE],
459 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header-curses.h})
461 #ifndef _XOPEN_SOURCE_EXTENDED
462 #define _XOPEN_SOURCE_EXTENDED
464 #include <${cf_cv_ncurses_header-curses.h}>],[
466 ],cf_result=yes,cf_result=no)
467 AC_MSG_RESULT($cf_result)
468 if test $cf_result = yes ; then
469 CF_UPPER(cf_result,have_type_$1)
470 AC_DEFINE_UNQUOTED($cf_result)
472 AC_DEFINE_UNQUOTED($1,$2)
475 dnl ---------------------------------------------------------------------------
476 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
478 dnl Tie together the configure-script macros for curses. It may be ncurses,
479 dnl but unless asked, we do not make a special search for ncurses. However,
480 dnl still check for the ncurses version number, for use in other macros.
481 AC_DEFUN([CF_CURSES_CONFIG],
487 dnl ---------------------------------------------------------------------------
488 dnl CF_CURSES_CPPFLAGS version: 10 updated: 2009/01/06 19:34:11
489 dnl ------------------
490 dnl Look for the curses headers.
491 AC_DEFUN([CF_CURSES_CPPFLAGS],[
493 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
494 cf_cv_curses_incdir=no
495 case $host_os in #(vi
497 test -d /usr/include/curses_colr && \
498 cf_cv_curses_incdir="-I/usr/include/curses_colr"
501 test -d /usr/5lib && \
502 test -d /usr/5include && \
503 cf_cv_curses_incdir="-I/usr/5include"
507 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
512 dnl ---------------------------------------------------------------------------
513 dnl CF_CURSES_FUNCS version: 14 updated: 2009/07/16 19:34:55
515 dnl Curses-functions are a little complicated, since a lot of them are macros.
516 AC_DEFUN([CF_CURSES_FUNCS],
518 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
519 AC_REQUIRE([CF_XOPEN_CURSES])
520 AC_REQUIRE([CF_CURSES_TERM_H])
523 CF_UPPER(cf_tr_func,$cf_func)
524 AC_MSG_CHECKING(for ${cf_func})
525 CF_MSG_LOG(${cf_func})
526 AC_CACHE_VAL(cf_cv_func_$cf_func,[
527 eval cf_result='$ac_cv_func_'$cf_func
528 if test ".$cf_result" != ".no"; then
529 AC_TRY_LINK(CF__CURSES_HEAD,
532 long foo = (long)(&${cf_func});
533 ${cf_cv_main_return-return}(foo == 0);
539 eval 'cf_cv_func_'$cf_func'=$cf_result'
541 # use the computed/retrieved cache-value:
542 eval 'cf_result=$cf_cv_func_'$cf_func
543 AC_MSG_RESULT($cf_result)
544 if test $cf_result != no; then
545 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
549 dnl ---------------------------------------------------------------------------
550 dnl CF_CURSES_HEADER version: 1 updated: 2005/12/31 13:28:25
552 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
553 dnl variations of ncurses' installs.
555 dnl See also CF_NCURSES_HEADER, which sets the same cache variable.
556 AC_DEFUN([CF_CURSES_HEADER],[
557 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
558 cf_cv_ncurses_header=none
565 AC_TRY_COMPILE([#include <${cf_header}>],
566 [initscr(); tgoto("?", 0,0)],
567 [cf_cv_ncurses_header=$cf_header; break],[])
571 if test "$cf_cv_ncurses_header" = none ; then
572 AC_MSG_ERROR(No curses header-files found)
575 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
576 AC_CHECK_HEADERS($cf_cv_ncurses_header)
578 dnl ---------------------------------------------------------------------------
579 dnl CF_CURSES_LIBS version: 29 updated: 2009/01/06 19:34:57
581 dnl Look for the curses libraries. Older curses implementations may require
582 dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
583 AC_DEFUN([CF_CURSES_LIBS],[
585 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
586 AC_MSG_CHECKING(if we have identified curses libraries)
587 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
588 [initscr(); tgoto("?", 0,0)],
591 AC_MSG_RESULT($cf_result)
593 if test "$cf_result" = no ; then
594 case $host_os in #(vi
596 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
599 AC_CHECK_LIB(cur_colr,initscr,[
600 LIBS="-lcur_colr $LIBS"
601 ac_cv_func_initscr=yes
603 AC_CHECK_LIB(Hcurses,initscr,[
604 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
605 LIBS="-lHcurses $LIBS"
606 CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
607 ac_cv_func_initscr=yes
610 linux*) # Suse Linux does not follow /usr/lib convention
614 if test -d /usr/5lib ; then
615 CF_ADD_LIBDIR(/usr/5lib)
616 LIBS="$LIBS -lcurses -ltermcap"
618 ac_cv_func_initscr=yes
622 if test ".$ac_cv_func_initscr" != .yes ; then
627 if test ".${cf_cv_ncurses_version-no}" != .no
629 cf_check_list="ncurses curses cursesX"
631 cf_check_list="cursesX curses ncurses"
634 # Check for library containing tgoto. Do this before curses library
635 # because it may be needed to link the test-case for initscr.
636 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
637 for cf_term_lib in $cf_check_list termcap termlib unknown
639 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
643 # Check for library containing initscr
644 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
645 for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
647 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
649 test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
651 LIBS="-l$cf_curs_lib $cf_save_LIBS"
652 if test "$cf_term_lib" = unknown ; then
653 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
654 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
658 AC_MSG_RESULT($cf_result)
659 test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
660 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
662 elif test "$cf_term_lib" != predefined ; then
663 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
664 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
665 [initscr(); tgoto((char *)0, 0, 0);],
668 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
669 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
674 AC_MSG_RESULT($cf_result)
680 dnl ---------------------------------------------------------------------------
681 dnl CF_CURSES_TERM_H version: 6 updated: 2003/11/06 19:59:57
683 dnl SVr4 curses should have term.h as well (where it puts the definitions of
684 dnl the low-level interface). This may not be true in old/broken implementations,
685 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
686 dnl running with Solaris 2.5.1).
687 AC_DEFUN([CF_CURSES_TERM_H],
689 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
691 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
692 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
693 # for <term.h> if we do not find the variant.
695 `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
699 #include <${cf_cv_ncurses_header-curses.h}>
700 #include <${cf_header}>],
702 [cf_cv_term_header=$cf_header
704 [cf_cv_term_header=no])
708 case $cf_cv_term_header in #(vi
710 AC_DEFINE(HAVE_TERM_H)
713 AC_DEFINE(HAVE_NCURSES_TERM_H)
716 AC_DEFINE(HAVE_NCURSESW_TERM_H)
720 dnl ---------------------------------------------------------------------------
721 dnl CF_CURSES_WACS_MAP version: 3 updated: 2003/05/17 22:19:02
722 dnl ------------------
723 dnl Check for likely values of wacs_map[]:
724 AC_DEFUN([CF_CURSES_WACS_MAP],
726 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
727 cf_cv_curses_wacs_map=unknown
728 for name in wacs_map _wacs_map __wacs_map _nc_wacs
731 #ifndef _XOPEN_SOURCE_EXTENDED
732 #define _XOPEN_SOURCE_EXTENDED
734 #include <${cf_cv_ncurses_header-curses.h}>],
735 [$name['k'] = *WACS_PLUS],
736 [cf_cv_curses_wacs_map=$name
740 dnl ---------------------------------------------------------------------------
741 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
743 dnl "dirname" is not portable, so we fake it with a shell script.
744 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
745 dnl ---------------------------------------------------------------------------
746 dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11
748 dnl You can always use "make -n" to see the actual options, but it's hard to
749 dnl pick out/analyze warning messages when the compile-line is long.
752 dnl ECHO_LT - symbol to control if libtool is verbose
753 dnl ECHO_LD - symbol to prefix "cc -o" lines
754 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
755 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
756 dnl ECHO_CC - symbol to put before any "cc" line
758 AC_DEFUN([CF_DISABLE_ECHO],[
759 AC_MSG_CHECKING(if you want to see long compiling messages)
761 [ --disable-echo display "compiling" commands],
764 ECHO_LD='@echo linking [$]@;'
765 RULE_CC=' @echo compiling [$]<'
766 SHOW_CC=' @echo compiling [$]@'
771 RULE_CC='# compiling'
772 SHOW_CC='# compiling'
775 AC_MSG_RESULT($enableval)
782 dnl ---------------------------------------------------------------------------
783 dnl CF_ENABLE_WARNINGS version: 3 updated: 2003/05/24 14:24:29
784 dnl ------------------
785 dnl Configure-option to enable gcc warnings
786 AC_DEFUN([CF_ENABLE_WARNINGS],[
787 if ( test "$GCC" = yes || test "$GXX" = yes )
789 AC_MSG_CHECKING(if you want to turn on gcc warnings)
790 CF_ARG_ENABLE(warnings,
791 [ --enable-warnings test: turn on gcc compiler warnings],
794 AC_MSG_RESULT($with_warnings)
795 if test "$with_warnings" = "yes"
801 dnl ---------------------------------------------------------------------------
802 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
804 dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
805 dnl prefer a standard location, and use -L options only if we do not find the
806 dnl library in the standard library location(s).
807 dnl $1 = library name
808 dnl $2 = library class, usually the same as library name
810 dnl $4 = code fragment to compile/link
811 dnl $5 = corresponding function-name
812 dnl $6 = flag, nonnull if failure should not cause an error-exit
814 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
815 dnl to use a -L option.
816 AC_DEFUN([CF_FIND_LIBRARY],
818 eval 'cf_cv_have_lib_'$1'=no'
821 eval 'cf_cv_have_lib_'$1'=yes',[
823 AC_MSG_CHECKING(for $5 in -l$1)
825 AC_TRY_LINK([$3],[$4],
827 eval 'cf_cv_have_lib_'$1'=yes'
830 CF_LIBRARY_PATH(cf_search,$2)
831 for cf_libdir in $cf_search
833 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
834 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
835 AC_TRY_LINK([$3],[$4],
837 eval 'cf_cv_have_lib_'$1'=yes'
840 LIBS="$cf_save_LIBS"])
844 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
846 if test $cf_found_library = no ; then
847 AC_MSG_ERROR(Cannot link $1 library)
851 dnl ---------------------------------------------------------------------------
852 dnl CF_FIND_LINKAGE version: 13 updated: 2008/12/24 07:59:55
854 dnl Find a library (specifically the linkage used in the code fragment),
855 dnl searching for it if it is not already in the library path.
856 dnl See also CF_ADD_SEARCHPATH.
858 dnl Parameters (4-on are optional):
859 dnl $1 = headers for library entrypoint
860 dnl $2 = code fragment for library entrypoint
861 dnl $3 = the library name without the "-l" option or ".so" suffix.
862 dnl $4 = action to perform if successful (default: update CPPFLAGS, etc)
863 dnl $5 = action to perform if not successful
864 dnl $6 = module name, if not the same as the library name
865 dnl $7 = extra libraries
867 dnl Sets these variables:
868 dnl $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
869 dnl $cf_cv_header_path_$3 - include-directory if needed
870 dnl $cf_cv_library_path_$3 - library-directory if needed
871 dnl $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
872 AC_DEFUN([CF_FIND_LINKAGE],[
874 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
875 # will be set on completion of the AC_TRY_LINK below.
876 cf_cv_header_path_$3=
877 cf_cv_library_path_$3=
879 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
881 AC_TRY_LINK([$1],[$2],
882 cf_cv_find_linkage_$3=yes,[
883 cf_cv_find_linkage_$3=no
885 CF_VERBOSE(find linkage for $3 library)
886 CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
888 cf_save_CPPFLAGS="$CPPFLAGS"
889 cf_test_CPPFLAGS="$CPPFLAGS"
891 CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
892 for cf_cv_header_path_$3 in $cf_search
894 if test -d $cf_cv_header_path_$3 ; then
895 CF_VERBOSE(... testing $cf_cv_header_path_$3)
896 CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
897 AC_TRY_COMPILE([$1],[$2],[
898 CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
899 cf_cv_find_linkage_$3=maybe
900 cf_test_CPPFLAGS="$CPPFLAGS"
902 CPPFLAGS="$cf_save_CPPFLAGS"
907 if test "$cf_cv_find_linkage_$3" = maybe ; then
909 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
912 cf_save_LDFLAGS="$LDFLAGS"
915 CPPFLAGS="$cf_test_CPPFLAGS"
916 LIBS="-l$3 $7 $cf_save_LIBS"
917 AC_TRY_LINK([$1],[$2],[
918 CF_VERBOSE(... found $3 library in system)
919 cf_cv_find_linkage_$3=yes])
920 CPPFLAGS="$cf_save_CPPFLAGS"
924 if test "$cf_cv_find_linkage_$3" != yes ; then
925 CF_LIBRARY_PATH(cf_search,$3)
926 for cf_cv_library_path_$3 in $cf_search
928 if test -d $cf_cv_library_path_$3 ; then
929 CF_VERBOSE(... testing $cf_cv_library_path_$3)
930 CPPFLAGS="$cf_test_CPPFLAGS"
931 LIBS="-l$3 $7 $cf_save_LIBS"
932 LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
933 AC_TRY_LINK([$1],[$2],[
934 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
935 cf_cv_find_linkage_$3=yes
936 cf_cv_library_file_$3="-l$3"
938 CPPFLAGS="$cf_save_CPPFLAGS"
940 LDFLAGS="$cf_save_LDFLAGS"
945 CPPFLAGS="$cf_save_CPPFLAGS"
946 LDFLAGS="$cf_save_LDFLAGS"
950 cf_cv_find_linkage_$3=no
954 if test "$cf_cv_find_linkage_$3" = yes ; then
956 CF_ADD_INCDIR($cf_cv_header_path_$3)
957 CF_ADD_LIBDIR($cf_cv_library_path_$3)
961 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
964 dnl ---------------------------------------------------------------------------
965 dnl CF_FUNC_CURSES_VERSION version: 4 updated: 2007/04/28 09:15:55
966 dnl ----------------------
967 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
968 dnl It's a character string "SVR4", not documented.
969 AC_DEFUN([CF_FUNC_CURSES_VERSION],
971 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
973 #include <${cf_cv_ncurses_header-curses.h}>
977 sprintf(temp, "%s\n", curses_version());
978 ${cf_cv_main_return-return}(0);
980 ,[cf_cv_func_curses_version=yes]
981 ,[cf_cv_func_curses_version=no]
982 ,[cf_cv_func_curses_version=unknown])
984 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
986 dnl ---------------------------------------------------------------------------
987 dnl CF_GCC_ATTRIBUTES version: 11 updated: 2007/07/29 09:55:12
988 dnl -----------------
989 dnl Test for availability of useful gcc __attribute__ directives to quiet
990 dnl compiler warnings. Though useful, not all are supported -- and contrary
991 dnl to documentation, unrecognized directives cause older compilers to barf.
992 AC_DEFUN([CF_GCC_ATTRIBUTES],
996 cat > conftest.i <<EOF
1003 #ifndef GCC_NORETURN
1004 #define GCC_NORETURN /* nothing */
1007 #define GCC_UNUSED /* nothing */
1010 if test "$GCC" = yes
1012 AC_CHECKING([for $CC __attribute__ directives])
1013 cat > conftest.$ac_ext <<EOF
1014 #line __oline__ "${as_me-configure}"
1015 #include "confdefs.h"
1016 #include "conftest.h"
1017 #include "conftest.i"
1019 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1021 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1024 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
1026 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
1028 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1029 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1030 extern void foo(void) GCC_NORETURN;
1031 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1033 for cf_attribute in scanf printf unused noreturn
1035 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1036 cf_directive="__attribute__(($cf_attribute))"
1037 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1038 case $cf_attribute in
1040 cat >conftest.h <<EOF
1041 #define GCC_$cf_ATTRIBUTE 1
1045 cat >conftest.h <<EOF
1046 #define GCC_$cf_ATTRIBUTE $cf_directive
1050 if AC_TRY_EVAL(ac_compile); then
1051 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1052 cat conftest.h >>confdefs.h
1056 fgrep define conftest.i >>confdefs.h
1061 dnl ---------------------------------------------------------------------------
1062 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
1064 dnl Find version of gcc
1065 AC_DEFUN([CF_GCC_VERSION],[
1066 AC_REQUIRE([AC_PROG_CC])
1068 if test "$GCC" = yes ; then
1069 AC_MSG_CHECKING(version of $CC)
1070 GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1071 test -z "$GCC_VERSION" && GCC_VERSION=unknown
1072 AC_MSG_RESULT($GCC_VERSION)
1075 dnl ---------------------------------------------------------------------------
1076 dnl CF_GCC_WARNINGS version: 24 updated: 2009/02/01 15:21:00
1078 dnl Check if the compiler supports useful warning options. There's a few that
1079 dnl we don't use, simply because they're too noisy:
1081 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1082 dnl -Wredundant-decls (system headers make this too noisy)
1083 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
1084 dnl -Wwrite-strings (too noisy, but should review occasionally). This
1085 dnl is enabled for ncurses using "--enable-const".
1089 dnl $1 is an optional list of gcc warning flags that a particular
1090 dnl application might want to use, e.g., "no-unused" for
1093 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
1095 AC_DEFUN([CF_GCC_WARNINGS],
1097 AC_REQUIRE([CF_GCC_VERSION])
1098 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1100 cat > conftest.$ac_ext <<EOF
1101 #line __oline__ "${as_me-configure}"
1102 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1105 if test "$INTEL_COMPILER" = yes
1107 # The "-wdXXX" options suppress warnings:
1108 # remark #1419: external declaration in primary source file
1109 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1110 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1111 # remark #193: zero used for undefined preprocessing identifier
1112 # remark #593: variable "curs_sb_left_arrow" was set but never used
1113 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1114 # remark #869: parameter "tw" was never referenced
1115 # remark #981: operands are evaluated in unspecified order
1116 # warning #279: controlling expression is constant
1118 AC_CHECKING([for $CC warning options])
1119 cf_save_CFLAGS="$CFLAGS"
1120 EXTRA_CFLAGS="-Wall"
1132 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1133 if AC_TRY_EVAL(ac_compile); then
1134 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1135 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1138 CFLAGS="$cf_save_CFLAGS"
1140 elif test "$GCC" = yes
1142 AC_CHECKING([for $CC warning options])
1143 cf_save_CFLAGS="$CFLAGS"
1144 EXTRA_CFLAGS="-W -Wall"
1146 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1148 Wbad-function-cast \
1152 Wmissing-declarations \
1153 Wmissing-prototypes \
1157 Wstrict-prototypes \
1158 Wundef $cf_warn_CONST $1
1160 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1161 if AC_TRY_EVAL(ac_compile); then
1162 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1163 case $cf_opt in #(vi
1165 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1168 case $GCC_VERSION in
1170 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1175 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1178 CFLAGS="$cf_save_CFLAGS"
1182 AC_SUBST(EXTRA_CFLAGS)
1184 dnl ---------------------------------------------------------------------------
1185 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1187 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1188 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
1189 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1190 dnl since it is interwoven with GNU extensions.
1192 dnl Well, yes we could work around it...
1193 AC_DEFUN([CF_GNU_SOURCE],
1195 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1196 AC_TRY_COMPILE([#include <sys/types.h>],[
1197 #ifndef _XOPEN_SOURCE
1200 [cf_cv_gnu_source=no],
1201 [cf_save="$CPPFLAGS"
1202 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1203 AC_TRY_COMPILE([#include <sys/types.h>],[
1204 #ifdef _XOPEN_SOURCE
1207 [cf_cv_gnu_source=no],
1208 [cf_cv_gnu_source=yes])
1212 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1214 dnl ---------------------------------------------------------------------------
1215 dnl CF_HEADER_PATH version: 9 updated: 2008/12/07 19:38:31
1217 dnl Construct a search-list of directories for a nonstandard header-file
1220 dnl $1 = the variable to return as result
1221 dnl $2 = the package name
1222 AC_DEFUN([CF_HEADER_PATH],
1224 cf_header_path_list=""
1225 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1226 for cf_header_path in $CPPFLAGS $CFLAGS
1228 case $cf_header_path in #(vi
1230 cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1231 CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1232 cf_header_path_list="$cf_header_path_list [$]$1"
1238 CF_SUBDIR_PATH($1,$2,include)
1240 test "$includedir" != NONE && \
1241 test "$includedir" != "/usr/include" && \
1242 test -d "$includedir" && {
1243 test -d $includedir && $1="[$]$1 $includedir"
1244 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1247 test "$oldincludedir" != NONE && \
1248 test "$oldincludedir" != "/usr/include" && \
1249 test -d "$oldincludedir" && {
1250 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
1251 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1254 $1="$cf_header_path_list [$]$1"
1256 dnl ---------------------------------------------------------------------------
1257 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
1258 dnl -----------------
1259 dnl If we do not have a given script, look for it in the parent directory.
1260 AC_DEFUN([CF_INHERIT_SCRIPT],
1262 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1264 dnl ---------------------------------------------------------------------------
1265 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
1266 dnl -----------------
1267 dnl Check if the given compiler is really the Intel compiler for Linux. It
1268 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1269 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1271 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1272 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
1273 dnl the wrappers for gcc and g++ warnings.
1275 dnl $1 = GCC (default) or GXX
1276 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1277 dnl $3 = CFLAGS (default) or CXXFLAGS
1278 AC_DEFUN([CF_INTEL_COMPILER],[
1279 ifelse($2,,INTEL_COMPILER,[$2])=no
1281 if test "$ifelse($1,,[$1],GCC)" = yes ; then
1284 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
1285 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
1286 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
1288 #ifdef __INTEL_COMPILER
1292 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
1293 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1295 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
1296 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
1301 dnl ---------------------------------------------------------------------------
1302 dnl CF_LIBRARY_PATH version: 8 updated: 2008/12/07 19:38:31
1304 dnl Construct a search-list of directories for a nonstandard library-file
1307 dnl $1 = the variable to return as result
1308 dnl $2 = the package name
1309 AC_DEFUN([CF_LIBRARY_PATH],
1311 cf_library_path_list=""
1312 if test -n "${LDFLAGS}${LIBS}" ; then
1313 for cf_library_path in $LDFLAGS $LIBS
1315 case $cf_library_path in #(vi
1317 cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1318 CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1319 cf_library_path_list="$cf_library_path_list [$]$1"
1325 CF_SUBDIR_PATH($1,$2,lib)
1327 $1="$cf_library_path_list [$]$1"
1329 dnl ---------------------------------------------------------------------------
1330 dnl CF_MIN_GETCCHAR version: 2 updated: 2009/07/16 21:03:10
1333 dnl Check whether getcchar's return value counts the trailing null in a wchar_t
1334 dnl string, or not. X/Open says it does, but Tru64 and Solaris do not do this.
1335 AC_DEFUN([CF_MIN_GETCCHAR],[
1336 AC_CACHE_CHECK(if getcchar counts trailing null,cf_cv_min_getcchar,[
1340 #include <${cf_cv_ncurses_header-curses.h}>
1348 setcchar(temp, data, 0, 0, (void *)0);
1349 count = getcchar(temp, (wchar_t *)0, (attr_t *)0, (short *)0, (void *)0);
1350 ${cf_cv_main_return-return}(count != 0);
1352 [cf_cv_min_getcchar=no],
1353 [cf_cv_min_getcchar=yes],
1354 [cf_cv_min_getcchar=yes])
1356 if test "$cf_cv_min_getcchar" = yes ; then
1357 AC_DEFINE(MIN_GETCCHAR,1)
1360 dnl ---------------------------------------------------------------------------
1361 dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
1363 dnl Write a debug message to config.log, along with the line number in the
1364 dnl configure script.
1365 AC_DEFUN([CF_MSG_LOG],[
1366 echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1368 dnl ---------------------------------------------------------------------------
1369 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1370 dnl -------------------
1371 dnl Check if we can compile with ncurses' header file
1372 dnl $1 is the cache variable to set
1373 dnl $2 is the header-file to include
1374 dnl $3 is the root name (ncurses or ncursesw)
1375 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1377 ]ifelse($3,ncursesw,[
1378 #define _XOPEN_SOURCE_EXTENDED
1379 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
1380 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
1383 #ifdef NCURSES_VERSION
1384 ]ifelse($3,ncursesw,[
1389 printf("%s\n", NCURSES_VERSION);
1401 dnl ---------------------------------------------------------------------------
1402 dnl CF_NCURSES_CONFIG version: 5 updated: 2009/01/11 15:31:22
1403 dnl -----------------
1404 dnl Tie together the configure-script macros for ncurses.
1405 dnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
1406 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
1408 dnl $1 is the root library name (default: "ncurses")
1409 AC_DEFUN([CF_NCURSES_CONFIG],
1411 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1413 echo "Looking for ${cf_ncuconfig_root}-config"
1414 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
1416 if test "$NCURSES_CONFIG" != none ; then
1418 cf_cv_ncurses_header=curses.h
1420 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1421 LIBS="`$NCURSES_CONFIG --libs` $LIBS"
1423 dnl like CF_NCURSES_CPPFLAGS
1426 dnl like CF_NCURSES_LIBS
1427 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1428 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1430 dnl like CF_NCURSES_VERSION
1431 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1435 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1436 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1440 dnl ---------------------------------------------------------------------------
1441 dnl CF_NCURSES_CPPFLAGS version: 19 updated: 2007/07/29 13:35:20
1442 dnl -------------------
1443 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1444 dnl the CPPFLAGS variable so we can include its header.
1446 dnl The header files may be installed as either curses.h, or ncurses.h (would
1447 dnl be obsolete, except that some packagers prefer this name to distinguish it
1448 dnl from a "native" curses implementation). If not installed for overwrite,
1449 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1450 dnl /usr/include/ncurses), but someone may have installed overwriting the
1451 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
1452 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1455 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1456 dnl is already in the include-path, don't even bother with this, since we cannot
1457 dnl easily determine which file it is. In this case, it has to be <curses.h>.
1459 dnl The optional parameter gives the root name of the library, in case it is
1460 dnl not installed as the default curses library. That is how the
1461 dnl wide-character version of ncurses is installed.
1462 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1463 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1465 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1466 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1468 test -n "$cf_cv_curses_dir" && \
1469 test "$cf_cv_curses_dir" != "no" && { \
1470 CF_ADD_INCDIR($cf_cv_curses_dir/include $cf_cv_curses_dir/include/$cf_ncuhdr_root)
1473 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1474 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1475 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1476 for cf_header in $cf_header_list
1478 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1479 test "$cf_cv_ncurses_h" != no && break
1486 # some applications need this, but should check for NCURSES_VERSION
1491 dnl ---------------------------------------------------------------------------
1492 dnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
1493 dnl -----------------
1494 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1495 dnl variations of ncurses' installs.
1497 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1498 AC_DEFUN([CF_NCURSES_HEADER],[
1500 if test "$cf_cv_ncurses_h" != no ; then
1501 cf_cv_ncurses_header=$cf_cv_ncurses_h
1504 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1505 test -n "$verbose" && echo
1506 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1507 test -n "$verbose" && echo search path $cf_search
1508 cf_save2_CPPFLAGS="$CPPFLAGS"
1509 for cf_incdir in $cf_search
1511 CF_ADD_INCDIR($cf_incdir)
1516 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1517 if test "$cf_cv_ncurses_h2" != no ; then
1518 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1519 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
1522 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1524 CPPFLAGS="$cf_save2_CPPFLAGS"
1525 test "$cf_cv_ncurses_h2" != no && break
1527 test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
1530 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1531 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1532 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1533 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1535 CF_ADD_INCDIR($cf_1st_incdir)
1539 # Set definitions to allow ifdef'ing for ncurses.h
1541 case $cf_cv_ncurses_header in # (vi
1543 AC_DEFINE(HAVE_NCURSES_H)
1547 case $cf_cv_ncurses_header in # (vi
1548 ncurses/curses.h|ncurses/ncurses.h)
1549 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1551 ncursesw/curses.h|ncursesw/ncurses.h)
1552 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1557 dnl ---------------------------------------------------------------------------
1558 dnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
1560 dnl Look for the ncurses library. This is a little complicated on Linux,
1561 dnl because it may be linked with the gpm (general purpose mouse) library.
1562 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1563 dnl unusable with ncurses. However, we don't want to link with gpm unless
1564 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1565 dnl and the linker will record a dependency.
1567 dnl The optional parameter gives the root name of the library, in case it is
1568 dnl not installed as the default curses library. That is how the
1569 dnl wide-character version of ncurses is installed.
1570 AC_DEFUN([CF_NCURSES_LIBS],
1571 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1573 cf_nculib_root=ifelse($1,,ncurses,$1)
1574 # This works, except for the special case where we find gpm, but
1575 # ncurses is in a nonstandard location via $LIBS, and we really want
1578 cf_ncurses_SAVE="$LIBS"
1579 AC_CHECK_LIB(gpm,Gpm_Open,
1580 [AC_CHECK_LIB(gpm,initscr,
1581 [LIBS="$cf_ncurses_SAVE"],
1582 [cf_ncurses_LIBS="-lgpm"])])
1584 case $host_os in #(vi
1586 # This is only necessary if you are linking against an obsolete
1587 # version of ncurses (but it should do no harm, since it's static).
1588 if test "$cf_nculib_root" = ncurses ; then
1589 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1594 LIBS="$cf_ncurses_LIBS $LIBS"
1596 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1598 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
1599 LIBS="-l$cf_nculib_root $LIBS"
1601 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1602 [#include <${cf_cv_ncurses_header-curses.h}>],
1607 if test -n "$cf_ncurses_LIBS" ; then
1608 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1609 cf_ncurses_SAVE="$LIBS"
1610 for p in $cf_ncurses_LIBS ; do
1611 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1612 if test "$q" != "$LIBS" ; then
1616 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1617 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1618 [AC_MSG_RESULT(yes)],
1620 LIBS="$cf_ncurses_SAVE"])
1623 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1624 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1626 dnl ---------------------------------------------------------------------------
1627 dnl CF_NCURSES_VERSION version: 12 updated: 2007/04/28 09:15:55
1628 dnl ------------------
1629 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1630 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
1631 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1632 AC_DEFUN([CF_NCURSES_VERSION],
1634 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1635 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1636 cf_cv_ncurses_version=no
1640 #include <${cf_cv_ncurses_header-curses.h}>
1644 FILE *fp = fopen("$cf_tempfile", "w");
1645 #ifdef NCURSES_VERSION
1646 # ifdef NCURSES_VERSION_PATCH
1647 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1649 fprintf(fp, "%s\n", NCURSES_VERSION);
1653 fprintf(fp, "old\n");
1658 ${cf_cv_main_return-return}(0);
1660 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1662 # This will not work if the preprocessor splits the line after the
1663 # Autoconf token. The 'unproto' program does that.
1664 cat > conftest.$ac_ext <<EOF
1665 #include <${cf_cv_ncurses_header-curses.h}>
1667 #ifdef NCURSES_VERSION
1668 Autoconf NCURSES_VERSION
1676 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1678 if test -f conftest.out ; then
1679 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1680 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1686 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1688 dnl ---------------------------------------------------------------------------
1689 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
1690 dnl ----------------------
1691 dnl Check for ncurses "wrap-prefix" used for public variables which have been
1692 dnl wrapped with a function to help with concurrency control.
1693 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
1695 AC_MSG_CHECKING(for ncurses wrap-prefix)
1696 AC_ARG_WITH(ncurses-wrap-prefix,
1697 [ --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
1698 [NCURSES_WRAP_PREFIX=$withval],
1699 [NCURSES_WRAP_PREFIX=_nc_])
1700 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
1702 AC_SUBST(NCURSES_WRAP_PREFIX)
1704 dnl ---------------------------------------------------------------------------
1705 dnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
1707 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1708 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1709 dnl result begins with 'NONE'. This is necessary to work around autoconf's
1710 dnl delayed evaluation of those symbols.
1711 AC_DEFUN([CF_PATH_SYNTAX],[
1712 if test "x$prefix" != xNONE; then
1713 cf_path_syntax="$prefix"
1715 cf_path_syntax="$ac_default_prefix"
1718 case ".[$]$1" in #(vi
1719 .\[$]\(*\)*|.\'*\'*) #(vi
1723 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1725 .\[$]{*prefix}*) #(vi
1727 case ".[$]$1" in #(vi
1729 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1734 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1737 ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1741 dnl ---------------------------------------------------------------------------
1742 dnl CF_PDCURSES_X11 version: 9 updated: 2009/01/11 15:31:37
1744 dnl Configure for PDCurses' X11 library
1745 AC_DEFUN([CF_PDCURSES_X11],[
1746 AC_REQUIRE([CF_X_ATHENA])
1748 AC_PATH_PROGS(XCURSES_CONFIG,xcurses-config,none)
1750 if test "$XCURSES_CONFIG" != none ; then
1752 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
1753 LIBS="`$XCURSES_CONFIG --libs` $LIBS"
1755 cf_cv_lib_XCurses=yes
1759 LDFLAGS="$LDFLAGS $X_LIBS"
1760 CF_CHECK_CFLAGS($X_CFLAGS)
1761 AC_CHECK_LIB(X11,XOpenDisplay,
1762 [LIBS="-lX11 $LIBS"],,
1763 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
1764 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
1765 LIBS="-lXCurses $LIBS"
1767 #include <xcurses.h>
1768 char *XCursesProgramName = "test";
1770 [cf_cv_lib_XCurses=yes],
1771 [cf_cv_lib_XCurses=no])
1776 if test $cf_cv_lib_XCurses = yes ; then
1779 AC_DEFINE(HAVE_XCURSES)
1781 AC_MSG_ERROR(Cannot link with XCurses)
1784 dnl ---------------------------------------------------------------------------
1785 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1786 dnl -----------------
1787 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1789 dnl POSIX.1-1990 _POSIX_SOURCE
1790 dnl POSIX.1-1990 and _POSIX_SOURCE and
1791 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1793 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1794 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1795 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1798 dnl $1 is the nominal value for _POSIX_C_SOURCE
1799 AC_DEFUN([CF_POSIX_C_SOURCE],
1801 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1803 cf_save_CFLAGS="$CFLAGS"
1804 cf_save_CPPFLAGS="$CPPFLAGS"
1806 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1807 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1809 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1810 CF_MSG_LOG(if the symbol is already defined go no further)
1811 AC_TRY_COMPILE([#include <sys/types.h>],[
1812 #ifndef _POSIX_C_SOURCE
1815 [cf_cv_posix_c_source=no],
1816 [cf_want_posix_source=no
1817 case .$cf_POSIX_C_SOURCE in #(vi
1819 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1822 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1823 cf_want_posix_source=yes
1826 cf_want_posix_source=yes
1829 if test "$cf_want_posix_source" = yes ; then
1830 AC_TRY_COMPILE([#include <sys/types.h>],[
1831 #ifdef _POSIX_SOURCE
1834 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1836 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1837 CFLAGS="$cf_trim_CFLAGS"
1838 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1839 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1840 AC_TRY_COMPILE([#include <sys/types.h>],[
1841 #ifndef _POSIX_C_SOURCE
1844 [cf_cv_posix_c_source=no])
1845 CFLAGS="$cf_save_CFLAGS"
1846 CPPFLAGS="$cf_save_CPPFLAGS"
1850 if test "$cf_cv_posix_c_source" != no ; then
1851 CFLAGS="$cf_trim_CFLAGS"
1852 CPPFLAGS="$cf_trim_CPPFLAGS"
1853 if test "$cf_cv_cc_u_d_options" = yes ; then
1854 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1855 sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'`
1856 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1858 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1862 dnl ---------------------------------------------------------------------------
1863 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
1865 dnl Append definitions and rules for the given programs to the subdirectory
1866 dnl Makefiles, and the recursion rule for the top-level Makefile.
1869 dnl $1 = script to run
1870 dnl $2 = list of subdirectories
1874 AC_DEFUN([CF_PRG_RULES],
1878 if test ! -d $srcdir/$cf_dir; then
1880 elif test -f $srcdir/$cf_dir/programs; then
1881 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
1886 dnl ---------------------------------------------------------------------------
1887 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1889 dnl Check if C (preprocessor) -U and -D options are processed in the order
1890 dnl given rather than by type of option. Some compilers insist on apply all
1891 dnl of the -U options after all of the -D options. Others allow mixing them,
1892 dnl and may predefine symbols that conflict with those we define.
1893 AC_DEFUN([CF_PROG_CC_U_D],
1895 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1896 cf_save_CPPFLAGS="$CPPFLAGS"
1897 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1900 make an undefined-error
1903 make a defined-error
1906 cf_cv_cc_u_d_options=yes],[
1907 cf_cv_cc_u_d_options=no])
1908 CPPFLAGS="$cf_save_CPPFLAGS"
1911 dnl ---------------------------------------------------------------------------
1912 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1913 dnl ----------------
1914 dnl Remove all -U and -D options that refer to the given symbol from a list
1915 dnl of C compiler options. This works around the problem that not all
1916 dnl compilers process -U and -D options from left-to-right, so a -U option
1917 dnl cannot be used to cancel the effect of a preceding -D option.
1919 dnl $1 = target (which could be the same as the source variable)
1920 dnl $2 = source (including '$')
1921 dnl $3 = symbol to remove
1922 define([CF_REMOVE_DEFINE],
1924 # remove $3 symbol from $2
1926 sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \
1927 -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'`
1929 dnl ---------------------------------------------------------------------------
1930 dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
1932 dnl signal handler, but there are some gcc depedencies in that recommendation.
1934 AC_DEFUN([CF_SIG_ATOMIC_T],
1936 AC_MSG_CHECKING(for signal global datatype)
1937 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
1939 "volatile sig_atomic_t" \
1944 #include <sys/types.h>
1950 static void handler(int sig)
1954 [signal(SIGINT, handler);
1956 [cf_cv_sig_atomic_t=$cf_type],
1957 [cf_cv_sig_atomic_t=no])
1958 test "$cf_cv_sig_atomic_t" != no && break
1961 AC_MSG_RESULT($cf_cv_sig_atomic_t)
1962 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
1964 dnl ---------------------------------------------------------------------------
1965 dnl CF_SUBDIR_PATH version: 5 updated: 2007/07/29 09:55:12
1967 dnl Construct a search-list for a nonstandard header/lib-file
1968 dnl $1 = the variable to return as result
1969 dnl $2 = the package name
1970 dnl $3 = the subdirectory, e.g., bin, include or lib
1971 AC_DEFUN([CF_SUBDIR_PATH],
1974 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
1975 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
1976 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
1977 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
1978 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
1980 dnl ---------------------------------------------------------------------------
1981 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1982 dnl ------------------
1983 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1984 dnl older SCO configurations.
1985 AC_DEFUN([CF_SYS_TIME_SELECT],
1987 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1988 AC_CACHE_VAL(cf_cv_sys_time_select,[
1990 #include <sys/types.h>
1991 #ifdef HAVE_SYS_TIME_H
1992 #include <sys/time.h>
1994 #ifdef HAVE_SYS_SELECT_H
1995 #include <sys/select.h>
1997 ],[],[cf_cv_sys_time_select=yes],
1998 [cf_cv_sys_time_select=no])
2000 AC_MSG_RESULT($cf_cv_sys_time_select)
2001 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2003 dnl ---------------------------------------------------------------------------
2004 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
2006 dnl Look for term.h, which is part of X/Open curses. It defines the interface
2007 dnl to terminfo database. Usually it is in the same include-path as curses.h,
2008 dnl but some packagers change this, breaking various applications.
2009 AC_DEFUN([CF_TERM_HEADER],[
2010 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2011 case ${cf_cv_ncurses_header} in #(vi
2012 */ncurses.h|*/ncursesw.h) #(vi
2013 cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2016 cf_term_header=term.h
2020 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2022 AC_TRY_COMPILE([#include <stdio.h>
2023 #include <${cf_cv_ncurses_header-curses.h}>
2025 ],[int x = auto_left_margin],[
2026 cf_cv_term_header="$cf_test"],[
2027 cf_cv_term_header=unknown
2029 test "$cf_cv_term_header" != unknown && break
2033 # Set definitions to allow ifdef'ing to accommodate subdirectories
2035 case $cf_cv_term_header in # (vi
2037 AC_DEFINE(HAVE_TERM_H)
2041 case $cf_cv_term_header in # (vi
2042 ncurses/term.h) #(vi
2043 AC_DEFINE(HAVE_NCURSES_TERM_H)
2046 AC_DEFINE(HAVE_NCURSESW_TERM_H)
2050 dnl ---------------------------------------------------------------------------
2051 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2053 dnl Make an uppercase version of a variable
2054 dnl $1=uppercase($2)
2055 AC_DEFUN([CF_UPPER],
2057 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2059 dnl ---------------------------------------------------------------------------
2060 dnl CF_UTF8_LIB version: 5 updated: 2008/10/17 19:37:52
2062 dnl Check for multibyte support, and if not found, utf8 compatibility library
2063 AC_DEFUN([CF_UTF8_LIB],
2065 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
2066 cf_save_LIBS="$LIBS"
2068 #include <stdlib.h>],[putwc(0,0);],
2069 [cf_cv_utf8_lib=yes],
2071 #include <libutf8.h>],[putwc(0,0);],utf8,
2072 [cf_cv_utf8_lib=add-on],
2073 [cf_cv_utf8_lib=no])
2076 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
2078 if test "$cf_cv_utf8_lib" = "add-on" ; then
2079 AC_DEFINE(HAVE_LIBUTF8_H)
2080 CF_ADD_INCDIR($cf_cv_header_path_utf8)
2081 CF_ADD_LIBDIR($cf_cv_library_path_utf8)
2085 dnl ---------------------------------------------------------------------------
2086 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2088 dnl Use AC_VERBOSE w/o the warnings
2089 AC_DEFUN([CF_VERBOSE],
2090 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
2093 dnl ---------------------------------------------------------------------------
2094 dnl CF_WCHAR_TYPE version: 2 updated: 2004/01/17 19:18:20
2096 dnl Check if type wide-character type $1 is declared, and if so, which header
2097 dnl file is needed. The second parameter is used to set a shell variable when
2098 dnl the type is not found. The first parameter sets a shell variable for the
2100 AC_DEFUN([CF_WCHAR_TYPE],
2102 # This is needed on Tru64 5.0 to declare $1
2103 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
2108 #ifdef HAVE_LIBUTF8_H
2109 #include <libutf8.h>
2118 #ifdef HAVE_LIBUTF8_H
2119 #include <libutf8.h>
2123 [cf_cv_$1=unknown])])])
2125 if test "$cf_cv_$1" = yes ; then
2126 AC_DEFINE(NEED_WCHAR_H)
2131 # if we do not find $1 in either place, use substitution to provide a fallback.
2132 if test "$cf_cv_$1" = unknown ; then
2137 # if we find $1 in either place, use substitution to provide a fallback.
2138 if test "$cf_cv_$1" != unknown ; then
2143 dnl ---------------------------------------------------------------------------
2144 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
2145 dnl ------------------
2146 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
2148 AC_DEFUN([CF_WITH_CURSES_DIR],[
2149 AC_ARG_WITH(curses-dir,
2150 [ --with-curses-dir=DIR directory in which (n)curses is installed],
2151 [CF_PATH_SYNTAX(withval)
2152 cf_cv_curses_dir=$withval],
2153 [cf_cv_curses_dir=no])
2155 dnl ---------------------------------------------------------------------------
2156 dnl CF_XOPEN_CURSES version: 8 updated: 2003/11/07 19:47:46
2158 dnl Test if we should define X/Open source for curses, needed on Digital Unix
2159 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
2161 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
2162 dnl as getbegy(). The latter is better design, but the former is standard.
2163 AC_DEFUN([CF_XOPEN_CURSES],
2165 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2166 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
2169 #include <${cf_cv_ncurses_header-curses.h}>],[
2170 long x = winnstr(stdscr, "", 0);
2172 getbegyx(stdscr, y1, x1)],
2173 [cf_cv_need_xopen_extension=no],
2175 #define _XOPEN_SOURCE_EXTENDED
2177 #include <${cf_cv_ncurses_header-curses.h}>],[
2178 long x = winnstr(stdscr, "", 0);
2180 getbegyx(stdscr, y1, x1)],
2181 [cf_cv_need_xopen_extension=yes],
2182 [cf_cv_need_xopen_extension=unknown])])])
2183 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
2185 dnl ---------------------------------------------------------------------------
2186 dnl CF_XOPEN_SOURCE version: 29 updated: 2009/07/16 21:07:04
2188 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2189 dnl or adapt to the vendor's definitions to get equivalent functionality,
2190 dnl without losing the common non-POSIX features.
2193 dnl $1 is the nominal value for _XOPEN_SOURCE
2194 dnl $2 is the nominal value for _POSIX_C_SOURCE
2195 AC_DEFUN([CF_XOPEN_SOURCE],[
2197 AC_REQUIRE([CF_PROG_CC_U_D])
2199 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
2200 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
2202 case $host_os in #(vi
2204 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
2206 freebsd*|dragonfly*) #(vi
2207 # 5.x headers associate
2208 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2209 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2210 cf_POSIX_C_SOURCE=200112L
2212 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2215 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
2218 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
2221 CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
2223 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
2227 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
2230 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2233 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2236 CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
2239 CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
2242 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2245 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
2248 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2249 AC_TRY_COMPILE([#include <sys/types.h>],[
2250 #ifndef _XOPEN_SOURCE
2253 [cf_cv_xopen_source=no],
2254 [cf_save="$CPPFLAGS"
2255 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2256 AC_TRY_COMPILE([#include <sys/types.h>],[
2257 #ifdef _XOPEN_SOURCE
2260 [cf_cv_xopen_source=no],
2261 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2265 if test "$cf_cv_xopen_source" != no ; then
2266 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2267 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2268 test "$cf_cv_cc_u_d_options" = yes && \
2269 CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
2270 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
2272 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2276 dnl ---------------------------------------------------------------------------
2277 dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41
2279 dnl Check for Xaw (Athena) libraries
2281 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
2282 AC_DEFUN([CF_X_ATHENA],
2283 [AC_REQUIRE([CF_X_TOOLKIT])
2284 cf_x_athena=${cf_x_athena-Xaw}
2286 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
2289 [ --with-Xaw3d link with Xaw 3d library])
2290 if test "$withval" = yes ; then
2297 AC_MSG_CHECKING(if you want to link with neXT Athena library)
2300 [ --with-neXtaw link with neXT Athena library])
2301 if test "$withval" = yes ; then
2308 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
2310 AC_ARG_WITH(XawPlus,
2311 [ --with-XawPlus link with Athena-Plus library])
2312 if test "$withval" = yes ; then
2319 AC_CHECK_LIB(Xext,XextCreateExtension,
2320 [LIBS="-lXext $LIBS"])
2324 CF_X_ATHENA_CPPFLAGS($cf_x_athena)
2325 CF_X_ATHENA_LIBS($cf_x_athena)
2327 dnl ---------------------------------------------------------------------------
2328 dnl CF_X_ATHENA_CPPFLAGS version: 3 updated: 2009/01/11 15:33:39
2329 dnl --------------------
2330 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2331 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2332 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
2334 cf_x_athena_root=ifelse($1,,Xaw,$1)
2335 cf_x_athena_include=""
2337 for cf_path in default \
2338 /usr/contrib/X11R6 \
2339 /usr/contrib/X11R5 \
2343 if test -z "$cf_x_athena_include" ; then
2345 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
2346 if test $cf_path != default ; then
2347 CPPFLAGS="$cf_save -I$cf_path/include"
2348 AC_MSG_CHECKING(for $cf_test in $cf_path)
2350 AC_MSG_CHECKING(for $cf_test)
2353 #include <X11/Intrinsic.h>
2354 #include <$cf_test>],[],
2357 AC_MSG_RESULT($cf_result)
2358 if test "$cf_result" = yes ; then
2359 cf_x_athena_include=$cf_path
2367 if test -z "$cf_x_athena_include" ; then
2369 [Unable to successfully find Athena header files with test program])
2370 elif test "$cf_x_athena_include" != default ; then
2371 CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include"
2374 dnl ---------------------------------------------------------------------------
2375 dnl CF_X_ATHENA_LIBS version: 7 updated: 2008/03/23 14:46:03
2376 dnl ----------------
2377 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2378 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2379 AC_DEFUN([CF_X_ATHENA_LIBS],
2380 [AC_REQUIRE([CF_X_TOOLKIT])
2381 cf_x_athena_root=ifelse($1,,Xaw,$1)
2384 for cf_path in default \
2385 /usr/contrib/X11R6 \
2386 /usr/contrib/X11R5 \
2391 "-l$cf_x_athena_root -lXmu" \
2392 "-l$cf_x_athena_root -lXpm -lXmu" \
2393 "-l${cf_x_athena_root}_s -lXmu_s"
2395 if test -z "$cf_x_athena_lib" ; then
2397 cf_test=XawSimpleMenuAddGlobalActions
2398 if test $cf_path != default ; then
2399 LIBS="-L$cf_path/lib $cf_lib $LIBS"
2400 AC_MSG_CHECKING(for $cf_lib in $cf_path)
2402 LIBS="$cf_lib $LIBS"
2403 AC_MSG_CHECKING(for $cf_test in $cf_lib)
2405 AC_TRY_LINK([],[$cf_test()],
2408 AC_MSG_RESULT($cf_result)
2409 if test "$cf_result" = yes ; then
2410 cf_x_athena_lib="$cf_lib"
2418 if test -z "$cf_x_athena_lib" ; then
2420 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
2423 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2424 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2426 dnl ---------------------------------------------------------------------------
2427 dnl CF_X_TOOLKIT version: 12 updated: 2008/03/23 15:04:54
2429 dnl Check for X Toolkit libraries
2431 AC_DEFUN([CF_X_TOOLKIT],
2433 AC_REQUIRE([AC_PATH_XTRA])
2434 AC_REQUIRE([CF_CHECK_CACHE])
2436 # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
2440 LDFLAGS="$X_LIBS $LDFLAGS"
2441 CF_CHECK_CFLAGS($X_CFLAGS)
2443 AC_CHECK_FUNC(XOpenDisplay,,[
2444 AC_CHECK_LIB(X11,XOpenDisplay,
2445 [LIBS="-lX11 $LIBS"],,
2446 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2448 AC_CHECK_FUNC(XtAppInitialize,,[
2449 AC_CHECK_LIB(Xt, XtAppInitialize,
2450 [AC_DEFINE(HAVE_LIBXT)
2452 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
2453 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2455 if test $cf_have_X_LIBS = no ; then
2457 [Unable to successfully link X Toolkit library (-lXt) with
2458 test program. You will have to check and add the proper libraries by hand
2462 dnl ---------------------------------------------------------------------------
2463 dnl CF__CURSES_HEAD version: 1 updated: 2009/07/16 19:32:31
2465 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
2466 dnl are both available.
2467 define([CF__CURSES_HEAD],[
2469 #include <xcurses.h>
2470 char * XCursesProgramName = "test";
2472 #include <${cf_cv_ncurses_header-curses.h}>
2473 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
2474 #include <ncursesw/term.h>
2475 #elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
2476 #include <ncurses/term.h>
2477 #elif defined(HAVE_TERM_H)