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.25 2009/03/28 20:09:37 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_TYPE version: 2 updated: 2003/03/01 23:40:33
424 dnl --------------------
425 dnl Check if curses.h defines the given type
426 AC_DEFUN([CF_CURSES_CHECK_TYPE],
428 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header-curses.h})
430 #ifndef _XOPEN_SOURCE_EXTENDED
431 #define _XOPEN_SOURCE_EXTENDED
433 #include <${cf_cv_ncurses_header-curses.h}>],[
435 ],cf_result=yes,cf_result=no)
436 AC_MSG_RESULT($cf_result)
437 if test $cf_result = yes ; then
438 CF_UPPER(cf_result,have_type_$1)
439 AC_DEFINE_UNQUOTED($cf_result)
441 AC_DEFINE_UNQUOTED($1,$2)
444 dnl ---------------------------------------------------------------------------
445 dnl CF_CURSES_CPPFLAGS version: 10 updated: 2009/01/06 19:34:11
446 dnl ------------------
447 dnl Look for the curses headers.
448 AC_DEFUN([CF_CURSES_CPPFLAGS],[
450 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
451 cf_cv_curses_incdir=no
452 case $host_os in #(vi
454 test -d /usr/include/curses_colr && \
455 cf_cv_curses_incdir="-I/usr/include/curses_colr"
458 test -d /usr/5lib && \
459 test -d /usr/5include && \
460 cf_cv_curses_incdir="-I/usr/5include"
464 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
469 dnl ---------------------------------------------------------------------------
470 dnl CF_CURSES_FUNCS version: 13 updated: 2007/04/28 09:15:55
472 dnl Curses-functions are a little complicated, since a lot of them are macros.
473 AC_DEFUN([CF_CURSES_FUNCS],
475 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
476 AC_REQUIRE([CF_XOPEN_CURSES])
477 AC_REQUIRE([CF_CURSES_TERM_H])
480 CF_UPPER(cf_tr_func,$cf_func)
481 AC_MSG_CHECKING(for ${cf_func})
482 CF_MSG_LOG(${cf_func})
483 AC_CACHE_VAL(cf_cv_func_$cf_func,[
484 eval cf_result='$ac_cv_func_'$cf_func
485 if test ".$cf_result" != ".no"; then
489 char * XCursesProgramName = "test";
491 #include <${cf_cv_ncurses_header-curses.h}>
492 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
493 #include <ncursesw/term.h>
495 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
496 #include <ncurses/term.h>
506 long foo = (long)(&${cf_func});
507 ${cf_cv_main_return-return}(foo == 0);
513 eval 'cf_cv_func_'$cf_func'=$cf_result'
515 # use the computed/retrieved cache-value:
516 eval 'cf_result=$cf_cv_func_'$cf_func
517 AC_MSG_RESULT($cf_result)
518 if test $cf_result != no; then
519 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
523 dnl ---------------------------------------------------------------------------
524 dnl CF_CURSES_HEADER version: 1 updated: 2005/12/31 13:28:25
526 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
527 dnl variations of ncurses' installs.
529 dnl See also CF_NCURSES_HEADER, which sets the same cache variable.
530 AC_DEFUN([CF_CURSES_HEADER],[
531 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
532 cf_cv_ncurses_header=none
539 AC_TRY_COMPILE([#include <${cf_header}>],
540 [initscr(); tgoto("?", 0,0)],
541 [cf_cv_ncurses_header=$cf_header; break],[])
545 if test "$cf_cv_ncurses_header" = none ; then
546 AC_MSG_ERROR(No curses header-files found)
549 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
550 AC_CHECK_HEADERS($cf_cv_ncurses_header)
552 dnl ---------------------------------------------------------------------------
553 dnl CF_CURSES_LIBS version: 29 updated: 2009/01/06 19:34:57
555 dnl Look for the curses libraries. Older curses implementations may require
556 dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
557 AC_DEFUN([CF_CURSES_LIBS],[
559 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
560 AC_MSG_CHECKING(if we have identified curses libraries)
561 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
562 [initscr(); tgoto("?", 0,0)],
565 AC_MSG_RESULT($cf_result)
567 if test "$cf_result" = no ; then
568 case $host_os in #(vi
570 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
573 AC_CHECK_LIB(cur_colr,initscr,[
574 LIBS="-lcur_colr $LIBS"
575 ac_cv_func_initscr=yes
577 AC_CHECK_LIB(Hcurses,initscr,[
578 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
579 LIBS="-lHcurses $LIBS"
580 CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
581 ac_cv_func_initscr=yes
584 linux*) # Suse Linux does not follow /usr/lib convention
588 if test -d /usr/5lib ; then
589 CF_ADD_LIBDIR(/usr/5lib)
590 LIBS="$LIBS -lcurses -ltermcap"
592 ac_cv_func_initscr=yes
596 if test ".$ac_cv_func_initscr" != .yes ; then
601 if test ".${cf_cv_ncurses_version-no}" != .no
603 cf_check_list="ncurses curses cursesX"
605 cf_check_list="cursesX curses ncurses"
608 # Check for library containing tgoto. Do this before curses library
609 # because it may be needed to link the test-case for initscr.
610 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
611 for cf_term_lib in $cf_check_list termcap termlib unknown
613 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
617 # Check for library containing initscr
618 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
619 for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
621 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
623 test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
625 LIBS="-l$cf_curs_lib $cf_save_LIBS"
626 if test "$cf_term_lib" = unknown ; then
627 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
628 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
632 AC_MSG_RESULT($cf_result)
633 test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
634 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
636 elif test "$cf_term_lib" != predefined ; then
637 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
638 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
639 [initscr(); tgoto((char *)0, 0, 0);],
642 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
643 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
648 AC_MSG_RESULT($cf_result)
654 dnl ---------------------------------------------------------------------------
655 dnl CF_CURSES_TERM_H version: 6 updated: 2003/11/06 19:59:57
657 dnl SVr4 curses should have term.h as well (where it puts the definitions of
658 dnl the low-level interface). This may not be true in old/broken implementations,
659 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
660 dnl running with Solaris 2.5.1).
661 AC_DEFUN([CF_CURSES_TERM_H],
663 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
665 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
666 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
667 # for <term.h> if we do not find the variant.
669 `echo ${cf_cv_ncurses_header-curses.h} | sed -e 's%/.*%/%'`term.h \
673 #include <${cf_cv_ncurses_header-curses.h}>
674 #include <${cf_header}>],
676 [cf_cv_term_header=$cf_header
678 [cf_cv_term_header=no])
682 case $cf_cv_term_header in #(vi
684 AC_DEFINE(HAVE_TERM_H)
687 AC_DEFINE(HAVE_NCURSES_TERM_H)
690 AC_DEFINE(HAVE_NCURSESW_TERM_H)
694 dnl ---------------------------------------------------------------------------
695 dnl CF_CURSES_WACS_MAP version: 3 updated: 2003/05/17 22:19:02
696 dnl ------------------
697 dnl Check for likely values of wacs_map[]:
698 AC_DEFUN([CF_CURSES_WACS_MAP],
700 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
701 cf_cv_curses_wacs_map=unknown
702 for name in wacs_map _wacs_map __wacs_map _nc_wacs
705 #ifndef _XOPEN_SOURCE_EXTENDED
706 #define _XOPEN_SOURCE_EXTENDED
708 #include <${cf_cv_ncurses_header-curses.h}>],
709 [$name['k'] = *WACS_PLUS],
710 [cf_cv_curses_wacs_map=$name
714 dnl ---------------------------------------------------------------------------
715 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
717 dnl "dirname" is not portable, so we fake it with a shell script.
718 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
719 dnl ---------------------------------------------------------------------------
720 dnl CF_DISABLE_ECHO version: 10 updated: 2003/04/17 22:27:11
722 dnl You can always use "make -n" to see the actual options, but it's hard to
723 dnl pick out/analyze warning messages when the compile-line is long.
726 dnl ECHO_LT - symbol to control if libtool is verbose
727 dnl ECHO_LD - symbol to prefix "cc -o" lines
728 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
729 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
730 dnl ECHO_CC - symbol to put before any "cc" line
732 AC_DEFUN([CF_DISABLE_ECHO],[
733 AC_MSG_CHECKING(if you want to see long compiling messages)
735 [ --disable-echo display "compiling" commands],
738 ECHO_LD='@echo linking [$]@;'
739 RULE_CC=' @echo compiling [$]<'
740 SHOW_CC=' @echo compiling [$]@'
745 RULE_CC='# compiling'
746 SHOW_CC='# compiling'
749 AC_MSG_RESULT($enableval)
756 dnl ---------------------------------------------------------------------------
757 dnl CF_ENABLE_WARNINGS version: 3 updated: 2003/05/24 14:24:29
758 dnl ------------------
759 dnl Configure-option to enable gcc warnings
760 AC_DEFUN([CF_ENABLE_WARNINGS],[
761 if ( test "$GCC" = yes || test "$GXX" = yes )
763 AC_MSG_CHECKING(if you want to turn on gcc warnings)
764 CF_ARG_ENABLE(warnings,
765 [ --enable-warnings test: turn on gcc compiler warnings],
768 AC_MSG_RESULT($with_warnings)
769 if test "$with_warnings" = "yes"
775 dnl ---------------------------------------------------------------------------
776 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
778 dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
779 dnl prefer a standard location, and use -L options only if we do not find the
780 dnl library in the standard library location(s).
781 dnl $1 = library name
782 dnl $2 = library class, usually the same as library name
784 dnl $4 = code fragment to compile/link
785 dnl $5 = corresponding function-name
786 dnl $6 = flag, nonnull if failure should not cause an error-exit
788 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
789 dnl to use a -L option.
790 AC_DEFUN([CF_FIND_LIBRARY],
792 eval 'cf_cv_have_lib_'$1'=no'
795 eval 'cf_cv_have_lib_'$1'=yes',[
797 AC_MSG_CHECKING(for $5 in -l$1)
799 AC_TRY_LINK([$3],[$4],
801 eval 'cf_cv_have_lib_'$1'=yes'
804 CF_LIBRARY_PATH(cf_search,$2)
805 for cf_libdir in $cf_search
807 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
808 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
809 AC_TRY_LINK([$3],[$4],
811 eval 'cf_cv_have_lib_'$1'=yes'
814 LIBS="$cf_save_LIBS"])
818 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
820 if test $cf_found_library = no ; then
821 AC_MSG_ERROR(Cannot link $1 library)
825 dnl ---------------------------------------------------------------------------
826 dnl CF_FIND_LINKAGE version: 13 updated: 2008/12/24 07:59:55
828 dnl Find a library (specifically the linkage used in the code fragment),
829 dnl searching for it if it is not already in the library path.
830 dnl See also CF_ADD_SEARCHPATH.
832 dnl Parameters (4-on are optional):
833 dnl $1 = headers for library entrypoint
834 dnl $2 = code fragment for library entrypoint
835 dnl $3 = the library name without the "-l" option or ".so" suffix.
836 dnl $4 = action to perform if successful (default: update CPPFLAGS, etc)
837 dnl $5 = action to perform if not successful
838 dnl $6 = module name, if not the same as the library name
839 dnl $7 = extra libraries
841 dnl Sets these variables:
842 dnl $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
843 dnl $cf_cv_header_path_$3 - include-directory if needed
844 dnl $cf_cv_library_path_$3 - library-directory if needed
845 dnl $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
846 AC_DEFUN([CF_FIND_LINKAGE],[
848 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
849 # will be set on completion of the AC_TRY_LINK below.
850 cf_cv_header_path_$3=
851 cf_cv_library_path_$3=
853 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
855 AC_TRY_LINK([$1],[$2],
856 cf_cv_find_linkage_$3=yes,[
857 cf_cv_find_linkage_$3=no
859 CF_VERBOSE(find linkage for $3 library)
860 CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
862 cf_save_CPPFLAGS="$CPPFLAGS"
863 cf_test_CPPFLAGS="$CPPFLAGS"
865 CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
866 for cf_cv_header_path_$3 in $cf_search
868 if test -d $cf_cv_header_path_$3 ; then
869 CF_VERBOSE(... testing $cf_cv_header_path_$3)
870 CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
871 AC_TRY_COMPILE([$1],[$2],[
872 CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
873 cf_cv_find_linkage_$3=maybe
874 cf_test_CPPFLAGS="$CPPFLAGS"
876 CPPFLAGS="$cf_save_CPPFLAGS"
881 if test "$cf_cv_find_linkage_$3" = maybe ; then
883 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
886 cf_save_LDFLAGS="$LDFLAGS"
889 CPPFLAGS="$cf_test_CPPFLAGS"
890 LIBS="-l$3 $7 $cf_save_LIBS"
891 AC_TRY_LINK([$1],[$2],[
892 CF_VERBOSE(... found $3 library in system)
893 cf_cv_find_linkage_$3=yes])
894 CPPFLAGS="$cf_save_CPPFLAGS"
898 if test "$cf_cv_find_linkage_$3" != yes ; then
899 CF_LIBRARY_PATH(cf_search,$3)
900 for cf_cv_library_path_$3 in $cf_search
902 if test -d $cf_cv_library_path_$3 ; then
903 CF_VERBOSE(... testing $cf_cv_library_path_$3)
904 CPPFLAGS="$cf_test_CPPFLAGS"
905 LIBS="-l$3 $7 $cf_save_LIBS"
906 LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
907 AC_TRY_LINK([$1],[$2],[
908 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
909 cf_cv_find_linkage_$3=yes
910 cf_cv_library_file_$3="-l$3"
912 CPPFLAGS="$cf_save_CPPFLAGS"
914 LDFLAGS="$cf_save_LDFLAGS"
919 CPPFLAGS="$cf_save_CPPFLAGS"
920 LDFLAGS="$cf_save_LDFLAGS"
924 cf_cv_find_linkage_$3=no
928 if test "$cf_cv_find_linkage_$3" = yes ; then
930 CF_ADD_INCDIR($cf_cv_header_path_$3)
931 CF_ADD_LIBDIR($cf_cv_library_path_$3)
935 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
938 dnl ---------------------------------------------------------------------------
939 dnl CF_FUNC_CURSES_VERSION version: 4 updated: 2007/04/28 09:15:55
940 dnl ----------------------
941 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
942 dnl It's a character string "SVR4", not documented.
943 AC_DEFUN([CF_FUNC_CURSES_VERSION],
945 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
947 #include <${cf_cv_ncurses_header-curses.h}>
951 sprintf(temp, "%s\n", curses_version());
952 ${cf_cv_main_return-return}(0);
954 ,[cf_cv_func_curses_version=yes]
955 ,[cf_cv_func_curses_version=no]
956 ,[cf_cv_func_curses_version=unknown])
958 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION)
960 dnl ---------------------------------------------------------------------------
961 dnl CF_GCC_ATTRIBUTES version: 11 updated: 2007/07/29 09:55:12
962 dnl -----------------
963 dnl Test for availability of useful gcc __attribute__ directives to quiet
964 dnl compiler warnings. Though useful, not all are supported -- and contrary
965 dnl to documentation, unrecognized directives cause older compilers to barf.
966 AC_DEFUN([CF_GCC_ATTRIBUTES],
970 cat > conftest.i <<EOF
978 #define GCC_NORETURN /* nothing */
981 #define GCC_UNUSED /* nothing */
986 AC_CHECKING([for $CC __attribute__ directives])
987 cat > conftest.$ac_ext <<EOF
988 #line __oline__ "${as_me-configure}"
989 #include "confdefs.h"
990 #include "conftest.h"
991 #include "conftest.i"
993 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
995 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
998 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
1000 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
1002 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1003 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1004 extern void foo(void) GCC_NORETURN;
1005 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1007 for cf_attribute in scanf printf unused noreturn
1009 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1010 cf_directive="__attribute__(($cf_attribute))"
1011 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1012 case $cf_attribute in
1014 cat >conftest.h <<EOF
1015 #define GCC_$cf_ATTRIBUTE 1
1019 cat >conftest.h <<EOF
1020 #define GCC_$cf_ATTRIBUTE $cf_directive
1024 if AC_TRY_EVAL(ac_compile); then
1025 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1026 cat conftest.h >>confdefs.h
1030 fgrep define conftest.i >>confdefs.h
1035 dnl ---------------------------------------------------------------------------
1036 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
1038 dnl Find version of gcc
1039 AC_DEFUN([CF_GCC_VERSION],[
1040 AC_REQUIRE([AC_PROG_CC])
1042 if test "$GCC" = yes ; then
1043 AC_MSG_CHECKING(version of $CC)
1044 GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1045 test -z "$GCC_VERSION" && GCC_VERSION=unknown
1046 AC_MSG_RESULT($GCC_VERSION)
1049 dnl ---------------------------------------------------------------------------
1050 dnl CF_GCC_WARNINGS version: 24 updated: 2009/02/01 15:21:00
1052 dnl Check if the compiler supports useful warning options. There's a few that
1053 dnl we don't use, simply because they're too noisy:
1055 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1056 dnl -Wredundant-decls (system headers make this too noisy)
1057 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
1058 dnl -Wwrite-strings (too noisy, but should review occasionally). This
1059 dnl is enabled for ncurses using "--enable-const".
1063 dnl $1 is an optional list of gcc warning flags that a particular
1064 dnl application might want to use, e.g., "no-unused" for
1067 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
1069 AC_DEFUN([CF_GCC_WARNINGS],
1071 AC_REQUIRE([CF_GCC_VERSION])
1072 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1074 cat > conftest.$ac_ext <<EOF
1075 #line __oline__ "${as_me-configure}"
1076 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1079 if test "$INTEL_COMPILER" = yes
1081 # The "-wdXXX" options suppress warnings:
1082 # remark #1419: external declaration in primary source file
1083 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1084 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1085 # remark #193: zero used for undefined preprocessing identifier
1086 # remark #593: variable "curs_sb_left_arrow" was set but never used
1087 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1088 # remark #869: parameter "tw" was never referenced
1089 # remark #981: operands are evaluated in unspecified order
1090 # warning #279: controlling expression is constant
1092 AC_CHECKING([for $CC warning options])
1093 cf_save_CFLAGS="$CFLAGS"
1094 EXTRA_CFLAGS="-Wall"
1106 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1107 if AC_TRY_EVAL(ac_compile); then
1108 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1109 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1112 CFLAGS="$cf_save_CFLAGS"
1114 elif test "$GCC" = yes
1116 AC_CHECKING([for $CC warning options])
1117 cf_save_CFLAGS="$CFLAGS"
1118 EXTRA_CFLAGS="-W -Wall"
1120 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1122 Wbad-function-cast \
1126 Wmissing-declarations \
1127 Wmissing-prototypes \
1131 Wstrict-prototypes \
1132 Wundef $cf_warn_CONST $1
1134 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1135 if AC_TRY_EVAL(ac_compile); then
1136 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1137 case $cf_opt in #(vi
1139 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1142 case $GCC_VERSION in
1144 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1149 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1152 CFLAGS="$cf_save_CFLAGS"
1156 AC_SUBST(EXTRA_CFLAGS)
1158 dnl ---------------------------------------------------------------------------
1159 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1161 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1162 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
1163 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1164 dnl since it is interwoven with GNU extensions.
1166 dnl Well, yes we could work around it...
1167 AC_DEFUN([CF_GNU_SOURCE],
1169 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1170 AC_TRY_COMPILE([#include <sys/types.h>],[
1171 #ifndef _XOPEN_SOURCE
1174 [cf_cv_gnu_source=no],
1175 [cf_save="$CPPFLAGS"
1176 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1177 AC_TRY_COMPILE([#include <sys/types.h>],[
1178 #ifdef _XOPEN_SOURCE
1181 [cf_cv_gnu_source=no],
1182 [cf_cv_gnu_source=yes])
1186 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1188 dnl ---------------------------------------------------------------------------
1189 dnl CF_HEADER_PATH version: 9 updated: 2008/12/07 19:38:31
1191 dnl Construct a search-list of directories for a nonstandard header-file
1194 dnl $1 = the variable to return as result
1195 dnl $2 = the package name
1196 AC_DEFUN([CF_HEADER_PATH],
1198 cf_header_path_list=""
1199 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1200 for cf_header_path in $CPPFLAGS $CFLAGS
1202 case $cf_header_path in #(vi
1204 cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1205 CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1206 cf_header_path_list="$cf_header_path_list [$]$1"
1212 CF_SUBDIR_PATH($1,$2,include)
1214 test "$includedir" != NONE && \
1215 test "$includedir" != "/usr/include" && \
1216 test -d "$includedir" && {
1217 test -d $includedir && $1="[$]$1 $includedir"
1218 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1221 test "$oldincludedir" != NONE && \
1222 test "$oldincludedir" != "/usr/include" && \
1223 test -d "$oldincludedir" && {
1224 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
1225 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1228 $1="$cf_header_path_list [$]$1"
1230 dnl ---------------------------------------------------------------------------
1231 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
1232 dnl -----------------
1233 dnl If we do not have a given script, look for it in the parent directory.
1234 AC_DEFUN([CF_INHERIT_SCRIPT],
1236 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1238 dnl ---------------------------------------------------------------------------
1239 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
1240 dnl -----------------
1241 dnl Check if the given compiler is really the Intel compiler for Linux. It
1242 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1243 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1245 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1246 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
1247 dnl the wrappers for gcc and g++ warnings.
1249 dnl $1 = GCC (default) or GXX
1250 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1251 dnl $3 = CFLAGS (default) or CXXFLAGS
1252 AC_DEFUN([CF_INTEL_COMPILER],[
1253 ifelse($2,,INTEL_COMPILER,[$2])=no
1255 if test "$ifelse($1,,[$1],GCC)" = yes ; then
1258 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
1259 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
1260 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
1262 #ifdef __INTEL_COMPILER
1266 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
1267 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1269 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
1270 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
1275 dnl ---------------------------------------------------------------------------
1276 dnl CF_LIBRARY_PATH version: 8 updated: 2008/12/07 19:38:31
1278 dnl Construct a search-list of directories for a nonstandard library-file
1281 dnl $1 = the variable to return as result
1282 dnl $2 = the package name
1283 AC_DEFUN([CF_LIBRARY_PATH],
1285 cf_library_path_list=""
1286 if test -n "${LDFLAGS}${LIBS}" ; then
1287 for cf_library_path in $LDFLAGS $LIBS
1289 case $cf_library_path in #(vi
1291 cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1292 CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1293 cf_library_path_list="$cf_library_path_list [$]$1"
1299 CF_SUBDIR_PATH($1,$2,lib)
1301 $1="$cf_library_path_list [$]$1"
1303 dnl ---------------------------------------------------------------------------
1304 dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
1306 dnl Write a debug message to config.log, along with the line number in the
1307 dnl configure script.
1308 AC_DEFUN([CF_MSG_LOG],[
1309 echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1311 dnl ---------------------------------------------------------------------------
1312 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1313 dnl -------------------
1314 dnl Check if we can compile with ncurses' header file
1315 dnl $1 is the cache variable to set
1316 dnl $2 is the header-file to include
1317 dnl $3 is the root name (ncurses or ncursesw)
1318 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1320 ]ifelse($3,ncursesw,[
1321 #define _XOPEN_SOURCE_EXTENDED
1322 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
1323 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
1326 #ifdef NCURSES_VERSION
1327 ]ifelse($3,ncursesw,[
1332 printf("%s\n", NCURSES_VERSION);
1344 dnl ---------------------------------------------------------------------------
1345 dnl CF_NCURSES_CONFIG version: 5 updated: 2009/01/11 15:31:22
1346 dnl -----------------
1347 dnl Tie together the configure-script macros for ncurses.
1348 dnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
1349 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
1351 dnl $1 is the root library name (default: "ncurses")
1352 AC_DEFUN([CF_NCURSES_CONFIG],
1354 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1356 echo "Looking for ${cf_ncuconfig_root}-config"
1357 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
1359 if test "$NCURSES_CONFIG" != none ; then
1361 cf_cv_ncurses_header=curses.h
1363 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1364 LIBS="`$NCURSES_CONFIG --libs` $LIBS"
1366 dnl like CF_NCURSES_CPPFLAGS
1369 dnl like CF_NCURSES_LIBS
1370 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1371 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1373 dnl like CF_NCURSES_VERSION
1374 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1378 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1379 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1383 dnl ---------------------------------------------------------------------------
1384 dnl CF_NCURSES_CPPFLAGS version: 19 updated: 2007/07/29 13:35:20
1385 dnl -------------------
1386 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1387 dnl the CPPFLAGS variable so we can include its header.
1389 dnl The header files may be installed as either curses.h, or ncurses.h (would
1390 dnl be obsolete, except that some packagers prefer this name to distinguish it
1391 dnl from a "native" curses implementation). If not installed for overwrite,
1392 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1393 dnl /usr/include/ncurses), but someone may have installed overwriting the
1394 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
1395 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1398 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1399 dnl is already in the include-path, don't even bother with this, since we cannot
1400 dnl easily determine which file it is. In this case, it has to be <curses.h>.
1402 dnl The optional parameter gives the root name of the library, in case it is
1403 dnl not installed as the default curses library. That is how the
1404 dnl wide-character version of ncurses is installed.
1405 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1406 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1408 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1409 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1411 test -n "$cf_cv_curses_dir" && \
1412 test "$cf_cv_curses_dir" != "no" && { \
1413 CF_ADD_INCDIR($cf_cv_curses_dir/include $cf_cv_curses_dir/include/$cf_ncuhdr_root)
1416 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1417 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1418 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1419 for cf_header in $cf_header_list
1421 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1422 test "$cf_cv_ncurses_h" != no && break
1429 # some applications need this, but should check for NCURSES_VERSION
1434 dnl ---------------------------------------------------------------------------
1435 dnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
1436 dnl -----------------
1437 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1438 dnl variations of ncurses' installs.
1440 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1441 AC_DEFUN([CF_NCURSES_HEADER],[
1443 if test "$cf_cv_ncurses_h" != no ; then
1444 cf_cv_ncurses_header=$cf_cv_ncurses_h
1447 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1448 test -n "$verbose" && echo
1449 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1450 test -n "$verbose" && echo search path $cf_search
1451 cf_save2_CPPFLAGS="$CPPFLAGS"
1452 for cf_incdir in $cf_search
1454 CF_ADD_INCDIR($cf_incdir)
1459 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1460 if test "$cf_cv_ncurses_h2" != no ; then
1461 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1462 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
1465 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1467 CPPFLAGS="$cf_save2_CPPFLAGS"
1468 test "$cf_cv_ncurses_h2" != no && break
1470 test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
1473 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1474 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1475 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1476 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1478 CF_ADD_INCDIR($cf_1st_incdir)
1482 # Set definitions to allow ifdef'ing for ncurses.h
1484 case $cf_cv_ncurses_header in # (vi
1486 AC_DEFINE(HAVE_NCURSES_H)
1490 case $cf_cv_ncurses_header in # (vi
1491 ncurses/curses.h|ncurses/ncurses.h)
1492 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1494 ncursesw/curses.h|ncursesw/ncurses.h)
1495 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1500 dnl ---------------------------------------------------------------------------
1501 dnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
1503 dnl Look for the ncurses library. This is a little complicated on Linux,
1504 dnl because it may be linked with the gpm (general purpose mouse) library.
1505 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1506 dnl unusable with ncurses. However, we don't want to link with gpm unless
1507 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1508 dnl and the linker will record a dependency.
1510 dnl The optional parameter gives the root name of the library, in case it is
1511 dnl not installed as the default curses library. That is how the
1512 dnl wide-character version of ncurses is installed.
1513 AC_DEFUN([CF_NCURSES_LIBS],
1514 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1516 cf_nculib_root=ifelse($1,,ncurses,$1)
1517 # This works, except for the special case where we find gpm, but
1518 # ncurses is in a nonstandard location via $LIBS, and we really want
1521 cf_ncurses_SAVE="$LIBS"
1522 AC_CHECK_LIB(gpm,Gpm_Open,
1523 [AC_CHECK_LIB(gpm,initscr,
1524 [LIBS="$cf_ncurses_SAVE"],
1525 [cf_ncurses_LIBS="-lgpm"])])
1527 case $host_os in #(vi
1529 # This is only necessary if you are linking against an obsolete
1530 # version of ncurses (but it should do no harm, since it's static).
1531 if test "$cf_nculib_root" = ncurses ; then
1532 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1537 LIBS="$cf_ncurses_LIBS $LIBS"
1539 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1541 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
1542 LIBS="-l$cf_nculib_root $LIBS"
1544 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1545 [#include <${cf_cv_ncurses_header-curses.h}>],
1550 if test -n "$cf_ncurses_LIBS" ; then
1551 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1552 cf_ncurses_SAVE="$LIBS"
1553 for p in $cf_ncurses_LIBS ; do
1554 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1555 if test "$q" != "$LIBS" ; then
1559 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1560 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1561 [AC_MSG_RESULT(yes)],
1563 LIBS="$cf_ncurses_SAVE"])
1566 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1567 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1569 dnl ---------------------------------------------------------------------------
1570 dnl CF_NCURSES_VERSION version: 12 updated: 2007/04/28 09:15:55
1571 dnl ------------------
1572 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1573 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
1574 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1575 AC_DEFUN([CF_NCURSES_VERSION],
1577 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1578 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1579 cf_cv_ncurses_version=no
1583 #include <${cf_cv_ncurses_header-curses.h}>
1587 FILE *fp = fopen("$cf_tempfile", "w");
1588 #ifdef NCURSES_VERSION
1589 # ifdef NCURSES_VERSION_PATCH
1590 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1592 fprintf(fp, "%s\n", NCURSES_VERSION);
1596 fprintf(fp, "old\n");
1601 ${cf_cv_main_return-return}(0);
1603 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1605 # This will not work if the preprocessor splits the line after the
1606 # Autoconf token. The 'unproto' program does that.
1607 cat > conftest.$ac_ext <<EOF
1608 #include <${cf_cv_ncurses_header-curses.h}>
1610 #ifdef NCURSES_VERSION
1611 Autoconf NCURSES_VERSION
1619 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1621 if test -f conftest.out ; then
1622 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1623 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1629 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1631 dnl ---------------------------------------------------------------------------
1632 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
1633 dnl ----------------------
1634 dnl Check for ncurses "wrap-prefix" used for public variables which have been
1635 dnl wrapped with a function to help with concurrency control.
1636 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
1638 AC_MSG_CHECKING(for ncurses wrap-prefix)
1639 AC_ARG_WITH(ncurses-wrap-prefix,
1640 [ --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
1641 [NCURSES_WRAP_PREFIX=$withval],
1642 [NCURSES_WRAP_PREFIX=_nc_])
1643 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
1645 AC_SUBST(NCURSES_WRAP_PREFIX)
1647 dnl ---------------------------------------------------------------------------
1648 dnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
1650 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1651 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1652 dnl result begins with 'NONE'. This is necessary to work around autoconf's
1653 dnl delayed evaluation of those symbols.
1654 AC_DEFUN([CF_PATH_SYNTAX],[
1655 if test "x$prefix" != xNONE; then
1656 cf_path_syntax="$prefix"
1658 cf_path_syntax="$ac_default_prefix"
1661 case ".[$]$1" in #(vi
1662 .\[$]\(*\)*|.\'*\'*) #(vi
1666 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1668 .\[$]{*prefix}*) #(vi
1670 case ".[$]$1" in #(vi
1672 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1677 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1680 ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1684 dnl ---------------------------------------------------------------------------
1685 dnl CF_PDCURSES_X11 version: 9 updated: 2009/01/11 15:31:37
1687 dnl Configure for PDCurses' X11 library
1688 AC_DEFUN([CF_PDCURSES_X11],[
1689 AC_REQUIRE([CF_X_ATHENA])
1691 AC_PATH_PROGS(XCURSES_CONFIG,xcurses-config,none)
1693 if test "$XCURSES_CONFIG" != none ; then
1695 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
1696 LIBS="`$XCURSES_CONFIG --libs` $LIBS"
1698 cf_cv_lib_XCurses=yes
1702 LDFLAGS="$LDFLAGS $X_LIBS"
1703 CF_CHECK_CFLAGS($X_CFLAGS)
1704 AC_CHECK_LIB(X11,XOpenDisplay,
1705 [LIBS="-lX11 $LIBS"],,
1706 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
1707 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
1708 LIBS="-lXCurses $LIBS"
1710 #include <xcurses.h>
1711 char *XCursesProgramName = "test";
1713 [cf_cv_lib_XCurses=yes],
1714 [cf_cv_lib_XCurses=no])
1719 if test $cf_cv_lib_XCurses = yes ; then
1722 AC_DEFINE(HAVE_XCURSES)
1724 AC_MSG_ERROR(Cannot link with XCurses)
1727 dnl ---------------------------------------------------------------------------
1728 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1729 dnl -----------------
1730 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1732 dnl POSIX.1-1990 _POSIX_SOURCE
1733 dnl POSIX.1-1990 and _POSIX_SOURCE and
1734 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1736 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1737 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1738 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1741 dnl $1 is the nominal value for _POSIX_C_SOURCE
1742 AC_DEFUN([CF_POSIX_C_SOURCE],
1744 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1746 cf_save_CFLAGS="$CFLAGS"
1747 cf_save_CPPFLAGS="$CPPFLAGS"
1749 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1750 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1752 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1753 CF_MSG_LOG(if the symbol is already defined go no further)
1754 AC_TRY_COMPILE([#include <sys/types.h>],[
1755 #ifndef _POSIX_C_SOURCE
1758 [cf_cv_posix_c_source=no],
1759 [cf_want_posix_source=no
1760 case .$cf_POSIX_C_SOURCE in #(vi
1762 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1765 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1766 cf_want_posix_source=yes
1769 cf_want_posix_source=yes
1772 if test "$cf_want_posix_source" = yes ; then
1773 AC_TRY_COMPILE([#include <sys/types.h>],[
1774 #ifdef _POSIX_SOURCE
1777 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1779 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1780 CFLAGS="$cf_trim_CFLAGS"
1781 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1782 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1783 AC_TRY_COMPILE([#include <sys/types.h>],[
1784 #ifndef _POSIX_C_SOURCE
1787 [cf_cv_posix_c_source=no])
1788 CFLAGS="$cf_save_CFLAGS"
1789 CPPFLAGS="$cf_save_CPPFLAGS"
1793 if test "$cf_cv_posix_c_source" != no ; then
1794 CFLAGS="$cf_trim_CFLAGS"
1795 CPPFLAGS="$cf_trim_CPPFLAGS"
1796 if test "$cf_cv_cc_u_d_options" = yes ; then
1797 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1798 sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'`
1799 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1801 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1805 dnl ---------------------------------------------------------------------------
1806 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
1808 dnl Append definitions and rules for the given programs to the subdirectory
1809 dnl Makefiles, and the recursion rule for the top-level Makefile.
1812 dnl $1 = script to run
1813 dnl $2 = list of subdirectories
1817 AC_DEFUN([CF_PRG_RULES],
1821 if test ! -d $srcdir/$cf_dir; then
1823 elif test -f $srcdir/$cf_dir/programs; then
1824 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
1829 dnl ---------------------------------------------------------------------------
1830 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1832 dnl Check if C (preprocessor) -U and -D options are processed in the order
1833 dnl given rather than by type of option. Some compilers insist on apply all
1834 dnl of the -U options after all of the -D options. Others allow mixing them,
1835 dnl and may predefine symbols that conflict with those we define.
1836 AC_DEFUN([CF_PROG_CC_U_D],
1838 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1839 cf_save_CPPFLAGS="$CPPFLAGS"
1840 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1843 make an undefined-error
1846 make a defined-error
1849 cf_cv_cc_u_d_options=yes],[
1850 cf_cv_cc_u_d_options=no])
1851 CPPFLAGS="$cf_save_CPPFLAGS"
1854 dnl ---------------------------------------------------------------------------
1855 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1856 dnl ----------------
1857 dnl Remove all -U and -D options that refer to the given symbol from a list
1858 dnl of C compiler options. This works around the problem that not all
1859 dnl compilers process -U and -D options from left-to-right, so a -U option
1860 dnl cannot be used to cancel the effect of a preceding -D option.
1862 dnl $1 = target (which could be the same as the source variable)
1863 dnl $2 = source (including '$')
1864 dnl $3 = symbol to remove
1865 define([CF_REMOVE_DEFINE],
1867 # remove $3 symbol from $2
1869 sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \
1870 -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'`
1872 dnl ---------------------------------------------------------------------------
1873 dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
1875 dnl signal handler, but there are some gcc depedencies in that recommendation.
1877 AC_DEFUN([CF_SIG_ATOMIC_T],
1879 AC_MSG_CHECKING(for signal global datatype)
1880 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
1882 "volatile sig_atomic_t" \
1887 #include <sys/types.h>
1893 static void handler(int sig)
1897 [signal(SIGINT, handler);
1899 [cf_cv_sig_atomic_t=$cf_type],
1900 [cf_cv_sig_atomic_t=no])
1901 test "$cf_cv_sig_atomic_t" != no && break
1904 AC_MSG_RESULT($cf_cv_sig_atomic_t)
1905 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
1907 dnl ---------------------------------------------------------------------------
1908 dnl CF_SUBDIR_PATH version: 5 updated: 2007/07/29 09:55:12
1910 dnl Construct a search-list for a nonstandard header/lib-file
1911 dnl $1 = the variable to return as result
1912 dnl $2 = the package name
1913 dnl $3 = the subdirectory, e.g., bin, include or lib
1914 AC_DEFUN([CF_SUBDIR_PATH],
1917 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
1918 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
1919 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
1920 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
1921 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
1923 dnl ---------------------------------------------------------------------------
1924 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1925 dnl ------------------
1926 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1927 dnl older SCO configurations.
1928 AC_DEFUN([CF_SYS_TIME_SELECT],
1930 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1931 AC_CACHE_VAL(cf_cv_sys_time_select,[
1933 #include <sys/types.h>
1934 #ifdef HAVE_SYS_TIME_H
1935 #include <sys/time.h>
1937 #ifdef HAVE_SYS_SELECT_H
1938 #include <sys/select.h>
1940 ],[],[cf_cv_sys_time_select=yes],
1941 [cf_cv_sys_time_select=no])
1943 AC_MSG_RESULT($cf_cv_sys_time_select)
1944 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1946 dnl ---------------------------------------------------------------------------
1947 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
1949 dnl Look for term.h, which is part of X/Open curses. It defines the interface
1950 dnl to terminfo database. Usually it is in the same include-path as curses.h,
1951 dnl but some packagers change this, breaking various applications.
1952 AC_DEFUN([CF_TERM_HEADER],[
1953 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
1954 case ${cf_cv_ncurses_header} in #(vi
1955 */ncurses.h|*/ncursesw.h) #(vi
1956 cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
1959 cf_term_header=term.h
1963 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
1965 AC_TRY_COMPILE([#include <stdio.h>
1966 #include <${cf_cv_ncurses_header-curses.h}>
1968 ],[int x = auto_left_margin],[
1969 cf_cv_term_header="$cf_test"],[
1970 cf_cv_term_header=unknown
1972 test "$cf_cv_term_header" != unknown && break
1976 # Set definitions to allow ifdef'ing to accommodate subdirectories
1978 case $cf_cv_term_header in # (vi
1980 AC_DEFINE(HAVE_TERM_H)
1984 case $cf_cv_term_header in # (vi
1985 ncurses/term.h) #(vi
1986 AC_DEFINE(HAVE_NCURSES_TERM_H)
1989 AC_DEFINE(HAVE_NCURSESW_TERM_H)
1993 dnl ---------------------------------------------------------------------------
1994 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1996 dnl Make an uppercase version of a variable
1997 dnl $1=uppercase($2)
1998 AC_DEFUN([CF_UPPER],
2000 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2002 dnl ---------------------------------------------------------------------------
2003 dnl CF_UTF8_LIB version: 5 updated: 2008/10/17 19:37:52
2005 dnl Check for multibyte support, and if not found, utf8 compatibility library
2006 AC_DEFUN([CF_UTF8_LIB],
2008 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
2009 cf_save_LIBS="$LIBS"
2011 #include <stdlib.h>],[putwc(0,0);],
2012 [cf_cv_utf8_lib=yes],
2014 #include <libutf8.h>],[putwc(0,0);],utf8,
2015 [cf_cv_utf8_lib=add-on],
2016 [cf_cv_utf8_lib=no])
2019 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
2021 if test "$cf_cv_utf8_lib" = "add-on" ; then
2022 AC_DEFINE(HAVE_LIBUTF8_H)
2023 CF_ADD_INCDIR($cf_cv_header_path_utf8)
2024 CF_ADD_LIBDIR($cf_cv_library_path_utf8)
2028 dnl ---------------------------------------------------------------------------
2029 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2031 dnl Use AC_VERBOSE w/o the warnings
2032 AC_DEFUN([CF_VERBOSE],
2033 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
2036 dnl ---------------------------------------------------------------------------
2037 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
2038 dnl ------------------
2039 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
2041 AC_DEFUN([CF_WITH_CURSES_DIR],[
2042 AC_ARG_WITH(curses-dir,
2043 [ --with-curses-dir=DIR directory in which (n)curses is installed],
2044 [CF_PATH_SYNTAX(withval)
2045 cf_cv_curses_dir=$withval],
2046 [cf_cv_curses_dir=no])
2048 dnl ---------------------------------------------------------------------------
2049 dnl CF_XOPEN_CURSES version: 8 updated: 2003/11/07 19:47:46
2051 dnl Test if we should define X/Open source for curses, needed on Digital Unix
2052 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
2054 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
2055 dnl as getbegy(). The latter is better design, but the former is standard.
2056 AC_DEFUN([CF_XOPEN_CURSES],
2058 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2059 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
2062 #include <${cf_cv_ncurses_header-curses.h}>],[
2063 long x = winnstr(stdscr, "", 0);
2065 getbegyx(stdscr, y1, x1)],
2066 [cf_cv_need_xopen_extension=no],
2068 #define _XOPEN_SOURCE_EXTENDED
2070 #include <${cf_cv_ncurses_header-curses.h}>],[
2071 long x = winnstr(stdscr, "", 0);
2073 getbegyx(stdscr, y1, x1)],
2074 [cf_cv_need_xopen_extension=yes],
2075 [cf_cv_need_xopen_extension=unknown])])])
2076 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
2078 dnl ---------------------------------------------------------------------------
2079 dnl CF_XOPEN_SOURCE version: 28 updated: 2008/12/27 12:30:03
2081 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
2082 dnl or adapt to the vendor's definitions to get equivalent functionality,
2083 dnl without losing the common non-POSIX features.
2086 dnl $1 is the nominal value for _XOPEN_SOURCE
2087 dnl $2 is the nominal value for _POSIX_C_SOURCE
2088 AC_DEFUN([CF_XOPEN_SOURCE],[
2090 AC_REQUIRE([CF_PROG_CC_U_D])
2092 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
2093 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
2095 case $host_os in #(vi
2097 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
2099 freebsd*|dragonfly*) #(vi
2100 # 5.x headers associate
2101 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
2102 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
2103 cf_POSIX_C_SOURCE=200112L
2105 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2108 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
2111 CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
2113 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
2117 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
2120 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
2123 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
2126 CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
2129 CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
2132 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
2135 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
2138 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2139 AC_TRY_COMPILE([#include <sys/types.h>],[
2140 #ifndef _XOPEN_SOURCE
2143 [cf_cv_xopen_source=no],
2144 [cf_save="$CPPFLAGS"
2145 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2146 AC_TRY_COMPILE([#include <sys/types.h>],[
2147 #ifdef _XOPEN_SOURCE
2150 [cf_cv_xopen_source=no],
2151 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
2155 if test "$cf_cv_xopen_source" != no ; then
2156 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
2157 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
2158 test "$cf_cv_cc_u_d_options" = yes && \
2159 CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
2160 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
2162 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
2166 dnl ---------------------------------------------------------------------------
2167 dnl CF_X_ATHENA version: 12 updated: 2004/06/15 21:14:41
2169 dnl Check for Xaw (Athena) libraries
2171 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
2172 AC_DEFUN([CF_X_ATHENA],
2173 [AC_REQUIRE([CF_X_TOOLKIT])
2174 cf_x_athena=${cf_x_athena-Xaw}
2176 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
2179 [ --with-Xaw3d link with Xaw 3d library])
2180 if test "$withval" = yes ; then
2187 AC_MSG_CHECKING(if you want to link with neXT Athena library)
2190 [ --with-neXtaw link with neXT Athena library])
2191 if test "$withval" = yes ; then
2198 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
2200 AC_ARG_WITH(XawPlus,
2201 [ --with-XawPlus link with Athena-Plus library])
2202 if test "$withval" = yes ; then
2209 AC_CHECK_LIB(Xext,XextCreateExtension,
2210 [LIBS="-lXext $LIBS"])
2214 CF_X_ATHENA_CPPFLAGS($cf_x_athena)
2215 CF_X_ATHENA_LIBS($cf_x_athena)
2217 dnl ---------------------------------------------------------------------------
2218 dnl CF_X_ATHENA_CPPFLAGS version: 3 updated: 2009/01/11 15:33:39
2219 dnl --------------------
2220 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2221 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2222 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
2224 cf_x_athena_root=ifelse($1,,Xaw,$1)
2225 cf_x_athena_include=""
2227 for cf_path in default \
2228 /usr/contrib/X11R6 \
2229 /usr/contrib/X11R5 \
2233 if test -z "$cf_x_athena_include" ; then
2235 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
2236 if test $cf_path != default ; then
2237 CPPFLAGS="$cf_save -I$cf_path/include"
2238 AC_MSG_CHECKING(for $cf_test in $cf_path)
2240 AC_MSG_CHECKING(for $cf_test)
2243 #include <X11/Intrinsic.h>
2244 #include <$cf_test>],[],
2247 AC_MSG_RESULT($cf_result)
2248 if test "$cf_result" = yes ; then
2249 cf_x_athena_include=$cf_path
2257 if test -z "$cf_x_athena_include" ; then
2259 [Unable to successfully find Athena header files with test program])
2260 elif test "$cf_x_athena_include" != default ; then
2261 CPPFLAGS="$CPPFLAGS -I$cf_x_athena_include"
2264 dnl ---------------------------------------------------------------------------
2265 dnl CF_X_ATHENA_LIBS version: 7 updated: 2008/03/23 14:46:03
2266 dnl ----------------
2267 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
2268 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
2269 AC_DEFUN([CF_X_ATHENA_LIBS],
2270 [AC_REQUIRE([CF_X_TOOLKIT])
2271 cf_x_athena_root=ifelse($1,,Xaw,$1)
2274 for cf_path in default \
2275 /usr/contrib/X11R6 \
2276 /usr/contrib/X11R5 \
2281 "-l$cf_x_athena_root -lXmu" \
2282 "-l$cf_x_athena_root -lXpm -lXmu" \
2283 "-l${cf_x_athena_root}_s -lXmu_s"
2285 if test -z "$cf_x_athena_lib" ; then
2287 cf_test=XawSimpleMenuAddGlobalActions
2288 if test $cf_path != default ; then
2289 LIBS="-L$cf_path/lib $cf_lib $LIBS"
2290 AC_MSG_CHECKING(for $cf_lib in $cf_path)
2292 LIBS="$cf_lib $LIBS"
2293 AC_MSG_CHECKING(for $cf_test in $cf_lib)
2295 AC_TRY_LINK([],[$cf_test()],
2298 AC_MSG_RESULT($cf_result)
2299 if test "$cf_result" = yes ; then
2300 cf_x_athena_lib="$cf_lib"
2308 if test -z "$cf_x_athena_lib" ; then
2310 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
2313 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
2314 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
2316 dnl ---------------------------------------------------------------------------
2317 dnl CF_X_TOOLKIT version: 12 updated: 2008/03/23 15:04:54
2319 dnl Check for X Toolkit libraries
2321 AC_DEFUN([CF_X_TOOLKIT],
2323 AC_REQUIRE([AC_PATH_XTRA])
2324 AC_REQUIRE([CF_CHECK_CACHE])
2326 # SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
2330 LDFLAGS="$X_LIBS $LDFLAGS"
2331 CF_CHECK_CFLAGS($X_CFLAGS)
2333 AC_CHECK_FUNC(XOpenDisplay,,[
2334 AC_CHECK_LIB(X11,XOpenDisplay,
2335 [LIBS="-lX11 $LIBS"],,
2336 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2338 AC_CHECK_FUNC(XtAppInitialize,,[
2339 AC_CHECK_LIB(Xt, XtAppInitialize,
2340 [AC_DEFINE(HAVE_LIBXT)
2342 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
2343 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
2345 if test $cf_have_X_LIBS = no ; then
2347 [Unable to successfully link X Toolkit library (-lXt) with
2348 test program. You will have to check and add the proper libraries by hand