1 dnl***************************************************************************
2 dnl Copyright (c) 2007 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.2 2007/01/13 23:57:11 tom Exp $
31 dnl Author: Thomas E. Dickey
33 dnl Macros used in TACK test program 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: 7 updated: 2004/04/25 17:48: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="$cf_new_cppflags $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: 4 updated: 2002/12/21 14:25:52
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 gives error messages if -I/usr/local/include is added to
131 dnl the include-path).
132 AC_DEFUN([CF_ADD_INCDIR],
134 for cf_add_incdir in $1
138 case $cf_add_incdir in
141 /usr/local/include) # (vi
144 cf_save_CPPFLAGS="$CPPFLAGS"
145 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
146 AC_TRY_COMPILE([#include <stdio.h>],
149 [CPPFLAGS="$cf_save_CPPFLAGS"])
153 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
156 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
157 test "$cf_top_incdir" = "$cf_add_incdir" && break
158 cf_add_incdir="$cf_top_incdir"
162 dnl ---------------------------------------------------------------------------
163 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
165 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
166 dnl in the sharutils 4.2 distribution.
167 AC_DEFUN([CF_ANSI_CC_CHECK],
169 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
171 cf_save_CFLAGS="$CFLAGS"
172 cf_save_CPPFLAGS="$CPPFLAGS"
173 # Don't try gcc -ansi; that turns off useful extensions and
174 # breaks some systems' header files.
176 # Ultrix and OSF/1 -std1
177 # HP-UX -Aa -D_HPUX_SOURCE
179 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
180 for cf_arg in "-DCC_HAS_PROTOS" \
185 "-Aa -D_HPUX_SOURCE" \
188 CF_ADD_CFLAGS($cf_arg)
191 #ifndef CC_HAS_PROTOS
192 #if !defined(__STDC__) || (__STDC__ != 1)
197 int test (int i, double x);
198 struct s1 {int (*f) (int a);};
199 struct s2 {int (*f) (double a);};],
200 [cf_cv_ansi_cc="$cf_arg"; break])
202 CFLAGS="$cf_save_CFLAGS"
203 CPPFLAGS="$cf_save_CPPFLAGS"
206 if test "$cf_cv_ansi_cc" != "no"; then
207 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
208 CF_ADD_CFLAGS($cf_cv_ansi_cc)
210 AC_DEFINE(CC_HAS_PROTOS)
214 dnl ---------------------------------------------------------------------------
215 dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
217 dnl For programs that must use an ANSI compiler, obtain compiler options that
218 dnl will make it recognize prototypes. We'll do preprocessor checks in other
219 dnl macros, since tools such as unproto can fake prototypes, but only part of
220 dnl the preprocessor.
221 AC_DEFUN([CF_ANSI_CC_REQD],
222 [AC_REQUIRE([CF_ANSI_CC_CHECK])
223 if test "$cf_cv_ansi_cc" = "no"; then
225 [Your compiler does not appear to recognize prototypes.
226 You have the following choices:
227 a. adjust your compiler options
228 b. get an up-to-date compiler
229 c. use a wrapper such as unproto])
232 dnl ---------------------------------------------------------------------------
233 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
235 dnl Allow user to enable a normally-off option.
236 AC_DEFUN([CF_ARG_ENABLE],
237 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
238 dnl ---------------------------------------------------------------------------
239 dnl CF_ARG_OPTION version: 3 updated: 1997/10/18 14:42:41
241 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
247 dnl $3 = action to perform if option is not default
248 dnl $4 = action if perform if option is default
249 dnl $5 = default option value (either 'yes' or 'no')
250 AC_DEFUN([CF_ARG_OPTION],
251 [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
252 if test "$enableval" != "$5" ; then
254 ,[ $3]) ifelse($4,,,[
257 fi],[enableval=$5 ifelse($4,,,[
261 dnl ---------------------------------------------------------------------------
262 dnl CF_CHECK_CACHE version: 10 updated: 2004/05/23 13:03:31
264 dnl Check if we're accidentally using a cache from a different machine.
265 dnl Derive the system name, as a check for reusing the autoconf cache.
267 dnl If we've packaged config.guess and config.sub, run that (since it does a
268 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
269 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
270 dnl which is useful in cross-compiles.
272 dnl Note: we would use $ac_config_sub, but that is one of the places where
273 dnl autoconf 2.5x broke compatibility with autoconf 2.13
274 AC_DEFUN([CF_CHECK_CACHE],
276 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
277 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
278 system_name="$host_os"
280 system_name="`(uname -s -r) 2>/dev/null`"
281 if test -z "$system_name" ; then
282 system_name="`(hostname) 2>/dev/null`"
285 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
286 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
288 test -z "$system_name" && system_name="$cf_cv_system_name"
289 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
291 if test ".$system_name" != ".$cf_cv_system_name" ; then
292 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
293 AC_ERROR("Please remove config.cache and try again.")
296 dnl ---------------------------------------------------------------------------
297 dnl CF_CHECK_CFLAGS version: 2 updated: 2001/12/30 19:09:58
299 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
300 dnl a build-configuration such as imake. These have the pitfall that they
301 dnl often contain compiler-specific options which we cannot use, mixed with
302 dnl preprocessor options that we usually can.
303 AC_DEFUN([CF_CHECK_CFLAGS],
305 CF_VERBOSE(checking additions to CFLAGS)
306 cf_check_cflags="$CFLAGS"
307 cf_check_cppflags="$CPPFLAGS"
308 CF_ADD_CFLAGS($1,yes)
309 if test "$cf_check_cflags" != "$CFLAGS" ; then
310 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
311 [CF_VERBOSE(test-compile failed. Undoing change to \$CFLAGS)
312 if test "$cf_check_cppflags" != "$CPPFLAGS" ; then
313 CF_VERBOSE(but keeping change to \$CPPFLAGS)
315 CFLAGS="$cf_check_flags"])
318 dnl ---------------------------------------------------------------------------
319 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
321 dnl Tie together the configure-script macros for curses. It may be ncurses,
322 dnl but unless asked, we do not make a special search for ncurses. However,
323 dnl still check for the ncurses version number, for use in other macros.
324 AC_DEFUN([CF_CURSES_CONFIG],
330 dnl ---------------------------------------------------------------------------
331 dnl CF_CURSES_CPPFLAGS version: 9 updated: 2006/02/04 19:44:43
332 dnl ------------------
333 dnl Look for the curses headers.
334 AC_DEFUN([CF_CURSES_CPPFLAGS],[
336 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
337 cf_cv_curses_incdir=no
338 case $host_os in #(vi
340 test -d /usr/include/curses_colr && \
341 cf_cv_curses_incdir="-I/usr/include/curses_colr"
344 test -d /usr/5lib && \
345 test -d /usr/5include && \
346 cf_cv_curses_incdir="-I/usr/5include"
350 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$cf_cv_curses_incdir $CPPFLAGS"
355 dnl ---------------------------------------------------------------------------
356 dnl CF_CURSES_HEADER version: 1 updated: 2005/12/31 13:28:25
358 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
359 dnl variations of ncurses' installs.
361 dnl See also CF_NCURSES_HEADER, which sets the same cache variable.
362 AC_DEFUN([CF_CURSES_HEADER],[
363 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
364 cf_cv_ncurses_header=none
371 AC_TRY_COMPILE([#include <${cf_header}>],
372 [initscr(); tgoto("?", 0,0)],
373 [cf_cv_ncurses_header=$cf_header; break],[])
377 if test "$cf_cv_ncurses_header" = none ; then
378 AC_MSG_ERROR(No curses header-files found)
381 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
382 AC_CHECK_HEADERS($cf_cv_ncurses_header)
384 dnl ---------------------------------------------------------------------------
385 dnl CF_CURSES_LIBS version: 24 updated: 2006/02/04 19:44:43
387 dnl Look for the curses libraries. Older curses implementations may require
388 dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
389 AC_DEFUN([CF_CURSES_LIBS],[
391 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
392 AC_MSG_CHECKING(if we have identified curses libraries)
393 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
394 [initscr(); tgoto("?", 0,0)],
397 AC_MSG_RESULT($cf_result)
399 if test "$cf_result" = no ; then
400 case $host_os in #(vi
402 AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"])
405 AC_CHECK_LIB(cur_colr,initscr,[
406 LIBS="-lcur_colr $LIBS"
407 ac_cv_func_initscr=yes
409 AC_CHECK_LIB(Hcurses,initscr,[
410 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
411 LIBS="-lHcurses $LIBS"
412 CPPFLAGS="-D__HP_CURSES -D_HP_CURSES $CPPFLAGS"
413 ac_cv_func_initscr=yes
416 linux*) # Suse Linux does not follow /usr/lib convention
420 test -d /usr/5lib && \
421 LIBS="$LIBS -L/usr/5lib -lcurses -ltermcap"
422 ac_cv_func_initscr=yes
426 if test ".$ac_cv_func_initscr" != .yes ; then
431 if test ".${cf_cv_ncurses_version-no}" != .no
433 cf_check_list="ncurses curses cursesX"
435 cf_check_list="cursesX curses ncurses"
438 # Check for library containing tgoto. Do this before curses library
439 # because it may be needed to link the test-case for initscr.
440 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
441 for cf_term_lib in $cf_check_list termcap termlib unknown
443 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
447 # Check for library containing initscr
448 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
449 for cf_curs_lib in $cf_check_list xcurses jcurses unknown
451 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
453 test $cf_curs_lib = unknown && AC_ERROR(no curses library found)
455 LIBS="-l$cf_curs_lib $cf_save_LIBS"
456 if test "$cf_term_lib" = unknown ; then
457 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
458 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
462 AC_MSG_RESULT($cf_result)
463 test $cf_result = no && AC_ERROR(Cannot link curses library)
464 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
466 elif test "$cf_term_lib" != predefined ; then
467 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
468 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
469 [initscr(); tgoto((char *)0, 0, 0);],
472 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
473 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
478 AC_MSG_RESULT($cf_result)
484 dnl ---------------------------------------------------------------------------
485 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
487 dnl "dirname" is not portable, so we fake it with a shell script.
488 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
489 dnl ---------------------------------------------------------------------------
490 dnl CF_ENABLE_WARNINGS version: 3 updated: 2003/05/24 14:24:29
491 dnl ------------------
492 dnl Configure-option to enable gcc warnings
493 AC_DEFUN([CF_ENABLE_WARNINGS],[
494 if ( test "$GCC" = yes || test "$GXX" = yes )
496 AC_MSG_CHECKING(if you want to turn on gcc warnings)
497 CF_ARG_ENABLE(warnings,
498 [ --enable-warnings test: turn on gcc compiler warnings],
501 AC_MSG_RESULT($with_warnings)
502 if test "$with_warnings" = "yes"
508 dnl ---------------------------------------------------------------------------
509 dnl CF_FIND_LIBRARY version: 8 updated: 2004/11/23 20:14:58
511 dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
512 dnl prefer a standard location, and use -L options only if we do not find the
513 dnl library in the standard library location(s).
514 dnl $1 = library name
515 dnl $2 = library class, usually the same as library name
517 dnl $4 = code fragment to compile/link
518 dnl $5 = corresponding function-name
519 dnl $6 = flag, nonnull if failure should not cause an error-exit
521 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
522 dnl to use a -L option.
523 AC_DEFUN([CF_FIND_LIBRARY],
525 eval 'cf_cv_have_lib_'$1'=no'
528 eval 'cf_cv_have_lib_'$1'=yes',[
530 AC_MSG_CHECKING(for $5 in -l$1)
532 AC_TRY_LINK([$3],[$4],
534 eval 'cf_cv_have_lib_'$1'=yes'
537 CF_LIBRARY_PATH(cf_search,$2)
538 for cf_libdir in $cf_search
540 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
541 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
542 AC_TRY_LINK([$3],[$4],
544 eval 'cf_cv_have_lib_'$1'=yes'
547 LIBS="$cf_save_LIBS"])
551 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
553 if test $cf_found_library = no ; then
554 AC_ERROR(Cannot link $1 library)
558 dnl ---------------------------------------------------------------------------
559 dnl CF_GCC_ATTRIBUTES version: 10 updated: 2005/05/28 13:16:28
560 dnl -----------------
561 dnl Test for availability of useful gcc __attribute__ directives to quiet
562 dnl compiler warnings. Though useful, not all are supported -- and contrary
563 dnl to documentation, unrecognized directives cause older compilers to barf.
564 AC_DEFUN([CF_GCC_ATTRIBUTES],
568 cat > conftest.i <<EOF
576 #define GCC_NORETURN /* nothing */
579 #define GCC_UNUSED /* nothing */
584 AC_CHECKING([for $CC __attribute__ directives])
585 cat > conftest.$ac_ext <<EOF
586 #line __oline__ "configure"
587 #include "confdefs.h"
588 #include "conftest.h"
589 #include "conftest.i"
591 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
593 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
596 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
598 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
600 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
601 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
602 extern void foo(void) GCC_NORETURN;
603 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
605 for cf_attribute in scanf printf unused noreturn
607 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
608 cf_directive="__attribute__(($cf_attribute))"
609 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
610 case $cf_attribute in
612 cat >conftest.h <<EOF
613 #define GCC_$cf_ATTRIBUTE 1
617 cat >conftest.h <<EOF
618 #define GCC_$cf_ATTRIBUTE $cf_directive
622 if AC_TRY_EVAL(ac_compile); then
623 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
624 cat conftest.h >>confdefs.h
628 fgrep define conftest.i >>confdefs.h
633 dnl ---------------------------------------------------------------------------
634 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
636 dnl Find version of gcc
637 AC_DEFUN([CF_GCC_VERSION],[
638 AC_REQUIRE([AC_PROG_CC])
640 if test "$GCC" = yes ; then
641 AC_MSG_CHECKING(version of $CC)
642 GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
643 test -z "$GCC_VERSION" && GCC_VERSION=unknown
644 AC_MSG_RESULT($GCC_VERSION)
647 dnl ---------------------------------------------------------------------------
648 dnl CF_GCC_WARNINGS version: 20 updated: 2005/08/06 18:37:29
650 dnl Check if the compiler supports useful warning options. There's a few that
651 dnl we don't use, simply because they're too noisy:
653 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
654 dnl -Wredundant-decls (system headers make this too noisy)
655 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
656 dnl -Wwrite-strings (too noisy, but should review occasionally). This
657 dnl is enabled for ncurses using "--enable-const".
661 dnl $1 is an optional list of gcc warning flags that a particular
662 dnl application might want to use, e.g., "no-unused" for
665 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
667 AC_DEFUN([CF_GCC_WARNINGS],
669 AC_REQUIRE([CF_GCC_VERSION])
670 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
672 cat > conftest.$ac_ext <<EOF
673 #line __oline__ "configure"
674 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
677 if test "$INTEL_COMPILER" = yes
679 # The "-wdXXX" options suppress warnings:
680 # remark #1419: external declaration in primary source file
681 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
682 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
683 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
684 # remark #193: zero used for undefined preprocessing identifier
685 # remark #593: variable "curs_sb_left_arrow" was set but never used
686 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
687 # remark #869: parameter "tw" was never referenced
688 # remark #981: operands are evaluated in unspecified order
689 # warning #269: invalid format string conversion
691 AC_CHECKING([for $CC warning options])
692 cf_save_CFLAGS="$CFLAGS"
706 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
707 if AC_TRY_EVAL(ac_compile); then
708 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
709 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
712 CFLAGS="$cf_save_CFLAGS"
714 elif test "$GCC" = yes
716 AC_CHECKING([for $CC warning options])
717 cf_save_CFLAGS="$CFLAGS"
718 EXTRA_CFLAGS="-W -Wall"
720 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
726 Wmissing-declarations \
727 Wmissing-prototypes \
732 Wundef $cf_warn_CONST $1
734 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
735 if AC_TRY_EVAL(ac_compile); then
736 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
739 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
744 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
749 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
752 CFLAGS="$cf_save_CFLAGS"
756 AC_SUBST(EXTRA_CFLAGS)
758 dnl ---------------------------------------------------------------------------
759 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
761 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
762 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
763 dnl (or misfeature) of glibc2, which breaks portability of many applications,
764 dnl since it is interwoven with GNU extensions.
766 dnl Well, yes we could work around it...
767 AC_DEFUN([CF_GNU_SOURCE],
769 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
770 AC_TRY_COMPILE([#include <sys/types.h>],[
771 #ifndef _XOPEN_SOURCE
774 [cf_cv_gnu_source=no],
776 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
777 AC_TRY_COMPILE([#include <sys/types.h>],[
781 [cf_cv_gnu_source=no],
782 [cf_cv_gnu_source=yes])
786 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
788 dnl ---------------------------------------------------------------------------
789 dnl CF_HEADER_PATH version: 8 updated: 2002/11/10 14:46:59
791 dnl Construct a search-list for a nonstandard header-file
792 AC_DEFUN([CF_HEADER_PATH],
793 [CF_SUBDIR_PATH($1,$2,include)
794 test "$includedir" != NONE && \
795 test "$includedir" != "/usr/include" && \
796 test -d "$includedir" && {
797 test -d $includedir && $1="[$]$1 $includedir"
798 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
801 test "$oldincludedir" != NONE && \
802 test "$oldincludedir" != "/usr/include" && \
803 test -d "$oldincludedir" && {
804 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
805 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
809 dnl ---------------------------------------------------------------------------
810 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
811 dnl -----------------
812 dnl If we do not have a given script, look for it in the parent directory.
813 AC_DEFUN([CF_INHERIT_SCRIPT],
815 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
817 dnl ---------------------------------------------------------------------------
818 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
819 dnl -----------------
820 dnl Check if the given compiler is really the Intel compiler for Linux. It
821 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
822 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
824 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
825 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
826 dnl the wrappers for gcc and g++ warnings.
828 dnl $1 = GCC (default) or GXX
829 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
830 dnl $3 = CFLAGS (default) or CXXFLAGS
831 AC_DEFUN([CF_INTEL_COMPILER],[
832 ifelse($2,,INTEL_COMPILER,[$2])=no
834 if test "$ifelse($1,,[$1],GCC)" = yes ; then
837 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
838 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
839 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
841 #ifdef __INTEL_COMPILER
845 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
846 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
848 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
849 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
854 dnl ---------------------------------------------------------------------------
855 dnl CF_LIBRARY_PATH version: 7 updated: 2002/11/10 14:46:59
857 dnl Construct a search-list for a nonstandard library-file
858 AC_DEFUN([CF_LIBRARY_PATH],
859 [CF_SUBDIR_PATH($1,$2,lib)])dnl
860 dnl ---------------------------------------------------------------------------
861 dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
863 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
864 dnl a monocase filesystem.
865 AC_DEFUN([CF_MAKE_TAGS],[
866 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
867 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
869 if test "$cf_cv_mixedcase" = yes ; then
870 AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
875 if test "$MAKE_UPPER_TAGS" = yes ; then
880 AC_SUBST(MAKE_UPPER_TAGS)
882 if test "$MAKE_LOWER_TAGS" = yes ; then
887 AC_SUBST(MAKE_LOWER_TAGS)
889 dnl ---------------------------------------------------------------------------
890 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
891 dnl ----------------------
892 dnl Check if the file-system supports mixed-case filenames. If we're able to
893 dnl create a lowercase name and see it as uppercase, it doesn't support that.
894 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
896 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
897 if test "$cross_compiling" = yes ; then
898 case $target_alias in #(vi
899 *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
907 rm -f conftest CONFTEST
909 if test -f CONFTEST ; then
914 rm -f conftest CONFTEST
917 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
919 dnl ---------------------------------------------------------------------------
920 dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
922 dnl Write a debug message to config.log, along with the line number in the
923 dnl configure script.
924 AC_DEFUN([CF_MSG_LOG],[
925 echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
927 dnl ---------------------------------------------------------------------------
928 dnl CF_NCURSES_CC_CHECK version: 3 updated: 2003/01/12 18:59:28
929 dnl -------------------
930 dnl Check if we can compile with ncurses' header file
931 dnl $1 is the cache variable to set
932 dnl $2 is the header-file to include
933 dnl $3 is the root name (ncurses or ncursesw)
934 AC_DEFUN([CF_NCURSES_CC_CHECK],[
936 ]ifelse($3,ncursesw,[
937 #define _XOPEN_SOURCE_EXTENDED
938 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
939 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
942 #ifdef NCURSES_VERSION
943 ]ifelse($3,ncursesw,[
948 printf("%s\n", NCURSES_VERSION);
960 dnl ---------------------------------------------------------------------------
961 dnl CF_NCURSES_CONFIG version: 4 updated: 2006/10/28 14:36:12
962 dnl -----------------
963 dnl Tie together the configure-script macros for ncurses.
964 dnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
965 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
967 dnl $1 is the root library name (default: "ncurses")
968 AC_DEFUN([CF_NCURSES_CONFIG],
970 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
972 echo "Looking for ${cf_ncuconfig_root}-config"
973 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
975 if test "$NCURSES_CONFIG" != none ; then
977 cf_cv_ncurses_header=curses.h
979 CPPFLAGS="`$NCURSES_CONFIG --cflags` $CPPFLAGS"
980 LIBS="`$NCURSES_CONFIG --libs` $LIBS"
982 dnl like CF_NCURSES_CPPFLAGS
985 dnl like CF_NCURSES_LIBS
986 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
987 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
989 dnl like CF_NCURSES_VERSION
990 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
994 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
995 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
999 dnl ---------------------------------------------------------------------------
1000 dnl CF_NCURSES_CPPFLAGS version: 18 updated: 2005/12/31 13:26:39
1001 dnl -------------------
1002 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1003 dnl the CPPFLAGS variable so we can include its header.
1005 dnl The header files may be installed as either curses.h, or ncurses.h (would
1006 dnl be obsolete, except that some packagers prefer this name to distinguish it
1007 dnl from a "native" curses implementation). If not installed for overwrite,
1008 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1009 dnl /usr/include/ncurses), but someone may have installed overwriting the
1010 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
1011 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1014 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1015 dnl is already in the include-path, don't even bother with this, since we cannot
1016 dnl easily determine which file it is. In this case, it has to be <curses.h>.
1018 dnl The optional parameter gives the root name of the library, in case it is
1019 dnl not installed as the default curses library. That is how the
1020 dnl wide-character version of ncurses is installed.
1021 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1022 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1024 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1025 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1027 test -n "$cf_cv_curses_dir" && \
1028 test "$cf_cv_curses_dir" != "no" && \
1029 CPPFLAGS="-I$cf_cv_curses_dir/include -I$cf_cv_curses_dir/include/$cf_ncuhdr_root $CPPFLAGS"
1031 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
1032 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
1033 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
1034 for cf_header in $cf_header_list
1036 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1037 test "$cf_cv_ncurses_h" != no && break
1044 # some applications need this, but should check for NCURSES_VERSION
1049 dnl ---------------------------------------------------------------------------
1050 dnl CF_NCURSES_HEADER version: 1 updated: 2005/12/31 13:28:37
1051 dnl -----------------
1052 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
1053 dnl variations of ncurses' installs.
1055 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1056 AC_DEFUN([CF_NCURSES_HEADER],[
1058 if test "$cf_cv_ncurses_h" != no ; then
1059 cf_cv_ncurses_header=$cf_cv_ncurses_h
1062 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
1063 test -n "$verbose" && echo
1064 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
1065 test -n "$verbose" && echo search path $cf_search
1066 cf_save2_CPPFLAGS="$CPPFLAGS"
1067 for cf_incdir in $cf_search
1069 CF_ADD_INCDIR($cf_incdir)
1074 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
1075 if test "$cf_cv_ncurses_h2" != no ; then
1076 cf_cv_ncurses_h2=$cf_incdir/$cf_header
1077 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
1080 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1082 CPPFLAGS="$cf_save2_CPPFLAGS"
1083 test "$cf_cv_ncurses_h2" != no && break
1085 test "$cf_cv_ncurses_h2" = no && AC_ERROR(not found)
1088 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
1089 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
1090 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
1091 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
1093 CF_ADD_INCDIR($cf_1st_incdir)
1097 # Set definitions to allow ifdef'ing for ncurses.h
1099 case $cf_cv_ncurses_header in # (vi
1101 AC_DEFINE(HAVE_NCURSES_H)
1105 case $cf_cv_ncurses_header in # (vi
1106 ncurses/curses.h|ncurses/ncurses.h)
1107 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1109 ncursesw/curses.h|ncursesw/ncurses.h)
1110 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1115 dnl ---------------------------------------------------------------------------
1116 dnl CF_NCURSES_LIBS version: 12 updated: 2004/04/27 16:26:05
1118 dnl Look for the ncurses library. This is a little complicated on Linux,
1119 dnl because it may be linked with the gpm (general purpose mouse) library.
1120 dnl Some distributions have gpm linked with (bsd) curses, which makes it
1121 dnl unusable with ncurses. However, we don't want to link with gpm unless
1122 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
1123 dnl and the linker will record a dependency.
1125 dnl The optional parameter gives the root name of the library, in case it is
1126 dnl not installed as the default curses library. That is how the
1127 dnl wide-character version of ncurses is installed.
1128 AC_DEFUN([CF_NCURSES_LIBS],
1129 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
1131 cf_nculib_root=ifelse($1,,ncurses,$1)
1132 # This works, except for the special case where we find gpm, but
1133 # ncurses is in a nonstandard location via $LIBS, and we really want
1136 cf_ncurses_SAVE="$LIBS"
1137 AC_CHECK_LIB(gpm,Gpm_Open,
1138 [AC_CHECK_LIB(gpm,initscr,
1139 [LIBS="$cf_ncurses_SAVE"],
1140 [cf_ncurses_LIBS="-lgpm"])])
1142 case $host_os in #(vi
1144 # This is only necessary if you are linking against an obsolete
1145 # version of ncurses (but it should do no harm, since it's static).
1146 if test "$cf_nculib_root" = ncurses ; then
1147 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
1152 LIBS="$cf_ncurses_LIBS $LIBS"
1154 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1156 LIBS="-L$cf_cv_curses_dir/lib -l$cf_nculib_root $LIBS"
1158 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1159 [#include <${cf_cv_ncurses_header-curses.h}>],
1164 if test -n "$cf_ncurses_LIBS" ; then
1165 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
1166 cf_ncurses_SAVE="$LIBS"
1167 for p in $cf_ncurses_LIBS ; do
1168 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
1169 if test "$q" != "$LIBS" ; then
1173 AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
1174 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1175 [AC_MSG_RESULT(yes)],
1177 LIBS="$cf_ncurses_SAVE"])
1180 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
1181 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1183 dnl ---------------------------------------------------------------------------
1184 dnl CF_NCURSES_VERSION version: 11 updated: 2003/11/06 19:59:57
1185 dnl ------------------
1186 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
1187 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
1188 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
1189 AC_DEFUN([CF_NCURSES_VERSION],
1191 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
1192 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
1193 cf_cv_ncurses_version=no
1197 #include <${cf_cv_ncurses_header-curses.h}>
1201 FILE *fp = fopen("$cf_tempfile", "w");
1202 #ifdef NCURSES_VERSION
1203 # ifdef NCURSES_VERSION_PATCH
1204 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
1206 fprintf(fp, "%s\n", NCURSES_VERSION);
1210 fprintf(fp, "old\n");
1217 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
1219 # This will not work if the preprocessor splits the line after the
1220 # Autoconf token. The 'unproto' program does that.
1221 cat > conftest.$ac_ext <<EOF
1222 #include <${cf_cv_ncurses_header-curses.h}>
1224 #ifdef NCURSES_VERSION
1225 Autoconf NCURSES_VERSION
1233 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
1235 if test -f conftest.out ; then
1236 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
1237 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
1243 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
1245 dnl ---------------------------------------------------------------------------
1246 dnl CF_PATH_SYNTAX version: 11 updated: 2006/09/02 08:55:46
1248 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1249 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1250 dnl result begins with 'NONE'. This is necessary to work around autoconf's
1251 dnl delayed evaluation of those symbols.
1252 AC_DEFUN([CF_PATH_SYNTAX],[
1253 if test "x$prefix" != xNONE; then
1254 cf_path_syntax="$prefix"
1256 cf_path_syntax="$ac_default_prefix"
1259 case ".[$]$1" in #(vi
1260 .\[$]\(*\)*|.\'*\'*) #(vi
1264 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1266 .\[$]{*prefix}*) #(vi
1268 case ".[$]$1" in #(vi
1270 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1275 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
1278 ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
1282 dnl ---------------------------------------------------------------------------
1283 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
1284 dnl -----------------
1285 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
1287 dnl POSIX.1-1990 _POSIX_SOURCE
1288 dnl POSIX.1-1990 and _POSIX_SOURCE and
1289 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
1291 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
1292 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
1293 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
1296 dnl $1 is the nominal value for _POSIX_C_SOURCE
1297 AC_DEFUN([CF_POSIX_C_SOURCE],
1299 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
1301 cf_save_CFLAGS="$CFLAGS"
1302 cf_save_CPPFLAGS="$CPPFLAGS"
1304 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
1305 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
1307 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
1308 CF_MSG_LOG(if the symbol is already defined go no further)
1309 AC_TRY_COMPILE([#include <sys/types.h>],[
1310 #ifndef _POSIX_C_SOURCE
1313 [cf_cv_posix_c_source=no],
1314 [cf_want_posix_source=no
1315 case .$cf_POSIX_C_SOURCE in #(vi
1317 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1320 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
1321 cf_want_posix_source=yes
1324 cf_want_posix_source=yes
1327 if test "$cf_want_posix_source" = yes ; then
1328 AC_TRY_COMPILE([#include <sys/types.h>],[
1329 #ifdef _POSIX_SOURCE
1332 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
1334 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
1335 CFLAGS="$cf_trim_CFLAGS"
1336 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
1337 CF_MSG_LOG(if the second compile does not leave our definition intact error)
1338 AC_TRY_COMPILE([#include <sys/types.h>],[
1339 #ifndef _POSIX_C_SOURCE
1342 [cf_cv_posix_c_source=no])
1343 CFLAGS="$cf_save_CFLAGS"
1344 CPPFLAGS="$cf_save_CPPFLAGS"
1348 if test "$cf_cv_posix_c_source" != no ; then
1349 CFLAGS="$cf_trim_CFLAGS"
1350 CPPFLAGS="$cf_trim_CPPFLAGS"
1351 if test "$cf_cv_cc_u_d_options" = yes ; then
1352 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
1353 sed -e 's/-D/-U/g' -e 's/=[[^ ]]*//g'`
1354 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
1356 CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
1360 dnl ---------------------------------------------------------------------------
1361 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
1363 dnl Append definitions and rules for the given programs to the subdirectory
1364 dnl Makefiles, and the recursion rule for the top-level Makefile.
1367 dnl $1 = script to run
1368 dnl $2 = list of subdirectories
1372 AC_DEFUN([CF_PRG_RULES],
1376 if test ! -d $srcdir/$cf_dir; then
1378 elif test -f $srcdir/$cf_dir/programs; then
1379 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
1384 dnl ---------------------------------------------------------------------------
1385 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
1387 dnl Check if C (preprocessor) -U and -D options are processed in the order
1388 dnl given rather than by type of option. Some compilers insist on apply all
1389 dnl of the -U options after all of the -D options. Others allow mixing them,
1390 dnl and may predefine symbols that conflict with those we define.
1391 AC_DEFUN([CF_PROG_CC_U_D],
1393 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
1394 cf_save_CPPFLAGS="$CPPFLAGS"
1395 CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
1398 make an undefined-error
1401 make a defined-error
1404 cf_cv_cc_u_d_options=yes],[
1405 cf_cv_cc_u_d_options=no])
1406 CPPFLAGS="$cf_save_CPPFLAGS"
1409 dnl ---------------------------------------------------------------------------
1410 dnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
1412 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
1413 dnl misc/tabset install won't work properly. Usually this happens only when
1414 dnl using the fallback mkinstalldirs script
1415 AC_DEFUN([CF_PROG_INSTALL],
1421 CF_DIRNAME(cf_dir,$INSTALL)
1422 test -z "$cf_dir" && cf_dir=.
1423 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
1427 dnl ---------------------------------------------------------------------------
1428 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
1429 dnl ----------------
1430 dnl Remove all -U and -D options that refer to the given symbol from a list
1431 dnl of C compiler options. This works around the problem that not all
1432 dnl compilers process -U and -D options from left-to-right, so a -U option
1433 dnl cannot be used to cancel the effect of a preceding -D option.
1435 dnl $1 = target (which could be the same as the source variable)
1436 dnl $2 = source (including '$')
1437 dnl $3 = symbol to remove
1438 define([CF_REMOVE_DEFINE],
1440 # remove $3 symbol from $2
1442 sed -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[[ ]]/ /g' \
1443 -e 's/-[[UD]]$3\(=[[^ ]]*\)\?[$]//g'`
1445 dnl ---------------------------------------------------------------------------
1446 dnl CF_SUBDIR_PATH version: 4 updated: 2006/11/18 17:13:19
1448 dnl Construct a search-list for a nonstandard header/lib-file
1449 dnl $1 = the variable to return as result
1450 dnl $2 = the package name
1451 dnl $3 = the subdirectory, e.g., bin, include or lib
1452 AC_DEFUN([CF_SUBDIR_PATH],
1455 test -d "[$]HOME" && {
1456 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME"
1457 test -d "[$]HOME/$3" && $1="[$]$1 [$]HOME/$3"
1458 test -d "[$]HOME/$3/$2" && $1="[$]$1 [$]HOME/$3/$2"
1459 test -d "[$]HOME/$3/$2/$3" && $1="[$]$1 [$]HOME/$3/$2/$3"
1462 # For other stuff under the home directory, it should be sufficient to put
1463 # a symbolic link for $HOME/$2 to the actual package location:
1464 test -d "[$]HOME/$2" && {
1465 test -n "$verbose" && echo " ... testing $3-directories under [$]HOME/$2"
1466 test -d "[$]HOME/$2/$3" && $1="[$]$1 [$]HOME/$2/$3"
1467 test -d "[$]HOME/$2/$3/$2" && $1="[$]$1 [$]HOME/$2/$3/$2"
1470 test "$prefix" != /usr/local && \
1471 test -d /usr/local && {
1472 test -n "$verbose" && echo " ... testing $3-directories under /usr/local"
1473 test -d /usr/local/$3 && $1="[$]$1 /usr/local/$3"
1474 test -d /usr/local/$3/$2 && $1="[$]$1 /usr/local/$3/$2"
1475 test -d /usr/local/$3/$2/$3 && $1="[$]$1 /usr/local/$3/$2/$3"
1476 test -d /usr/local/$2/$3 && $1="[$]$1 /usr/local/$2/$3"
1477 test -d /usr/local/$2/$3/$2 && $1="[$]$1 /usr/local/$2/$3/$2"
1480 test "$prefix" != NONE && \
1481 test -d $prefix && {
1482 test -n "$verbose" && echo " ... testing $3-directories under $prefix"
1483 test -d $prefix/$3 && $1="[$]$1 $prefix/$3"
1484 test -d $prefix/$3/$2 && $1="[$]$1 $prefix/$3/$2"
1485 test -d $prefix/$3/$2/$3 && $1="[$]$1 $prefix/$3/$2/$3"
1486 test -d $prefix/$2/$3 && $1="[$]$1 $prefix/$2/$3"
1487 test -d $prefix/$2/$3/$2 && $1="[$]$1 $prefix/$2/$3/$2"
1490 test "$prefix" != /opt && \
1492 test -n "$verbose" && echo " ... testing $3-directories under /opt"
1493 test -d /opt/$3 && $1="[$]$1 /opt/$3"
1494 test -d /opt/$3/$2 && $1="[$]$1 /opt/$3/$2"
1495 test -d /opt/$3/$2/$3 && $1="[$]$1 /opt/$3/$2/$3"
1496 test -d /opt/$2/$3 && $1="[$]$1 /opt/$2/$3"
1497 test -d /opt/$2/$3/$2 && $1="[$]$1 /opt/$2/$3/$2"
1500 test "$prefix" != /usr && \
1502 test -n "$verbose" && echo " ... testing $3-directories under /usr"
1503 test -d /usr/$3 && $1="[$]$1 /usr/$3"
1504 test -d /usr/$3/$2 && $1="[$]$1 /usr/$3/$2"
1505 test -d /usr/$3/$2/$3 && $1="[$]$1 /usr/$3/$2/$3"
1506 test -d /usr/$2/$3 && $1="[$]$1 /usr/$2/$3"
1509 dnl ---------------------------------------------------------------------------
1510 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
1511 dnl ------------------
1512 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1513 dnl older SCO configurations.
1514 AC_DEFUN([CF_SYS_TIME_SELECT],
1516 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1517 AC_CACHE_VAL(cf_cv_sys_time_select,[
1519 #include <sys/types.h>
1520 #ifdef HAVE_SYS_TIME_H
1521 #include <sys/time.h>
1523 #ifdef HAVE_SYS_SELECT_H
1524 #include <sys/select.h>
1526 ],[],[cf_cv_sys_time_select=yes],
1527 [cf_cv_sys_time_select=no])
1529 AC_MSG_RESULT($cf_cv_sys_time_select)
1530 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1532 dnl ---------------------------------------------------------------------------
1533 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
1535 dnl Look for term.h, which is part of X/Open curses. It defines the interface
1536 dnl to terminfo database. Usually it is in the same include-path as curses.h,
1537 dnl but some packagers change this, breaking various applications.
1538 AC_DEFUN([CF_TERM_HEADER],[
1539 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
1540 case ${cf_cv_ncurses_header} in #(vi
1541 */ncurses.h|*/ncursesw.h) #(vi
1542 cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
1545 cf_term_header=term.h
1549 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
1551 AC_TRY_COMPILE([#include <stdio.h>
1552 #include <${cf_cv_ncurses_header-curses.h}>
1554 ],[int x = auto_left_margin],[
1555 cf_cv_term_header="$cf_test"],[
1556 cf_cv_term_header=unknown
1558 test "$cf_cv_term_header" != unknown && break
1562 # Set definitions to allow ifdef'ing to accommodate subdirectories
1564 case $cf_cv_term_header in # (vi
1566 AC_DEFINE(HAVE_TERM_H)
1570 case $cf_cv_term_header in # (vi
1571 ncurses/term.h) #(vi
1572 AC_DEFINE(HAVE_NCURSES_TERM_H)
1575 AC_DEFINE(HAVE_NCURSESW_TERM_H)
1579 dnl ---------------------------------------------------------------------------
1580 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
1582 dnl Make an uppercase version of a variable
1583 dnl $1=uppercase($2)
1584 AC_DEFUN([CF_UPPER],
1586 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1588 dnl ---------------------------------------------------------------------------
1589 dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
1591 dnl Use AC_VERBOSE w/o the warnings
1592 AC_DEFUN([CF_VERBOSE],
1593 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
1595 dnl ---------------------------------------------------------------------------
1596 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
1597 dnl ------------------
1598 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
1600 AC_DEFUN([CF_WITH_CURSES_DIR],[
1601 AC_ARG_WITH(curses-dir,
1602 [ --with-curses-dir=DIR directory in which (n)curses is installed],
1603 [CF_PATH_SYNTAX(withval)
1604 cf_cv_curses_dir=$withval],
1605 [cf_cv_curses_dir=no])
1607 dnl ---------------------------------------------------------------------------
1608 dnl CF_XOPEN_SOURCE version: 24 updated: 2006/04/02 16:41:09
1610 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
1611 dnl or adapt to the vendor's definitions to get equivalent functionality,
1612 dnl without losing the common non-POSIX features.
1615 dnl $1 is the nominal value for _XOPEN_SOURCE
1616 dnl $2 is the nominal value for _POSIX_C_SOURCE
1617 AC_DEFUN([CF_XOPEN_SOURCE],[
1619 AC_REQUIRE([CF_PROG_CC_U_D])
1621 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
1622 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
1624 case $host_os in #(vi
1626 CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
1629 # 5.x headers associate
1630 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
1631 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
1632 cf_POSIX_C_SOURCE=200112L
1634 CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1637 CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
1640 CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
1646 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
1649 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
1652 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
1655 CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
1658 CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
1661 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
1664 CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
1667 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
1668 AC_TRY_COMPILE([#include <sys/types.h>],[
1669 #ifndef _XOPEN_SOURCE
1672 [cf_cv_xopen_source=no],
1673 [cf_save="$CPPFLAGS"
1674 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
1675 AC_TRY_COMPILE([#include <sys/types.h>],[
1676 #ifdef _XOPEN_SOURCE
1679 [cf_cv_xopen_source=no],
1680 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
1684 if test "$cf_cv_xopen_source" != no ; then
1685 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
1686 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
1687 test "$cf_cv_cc_u_d_options" = yes && \
1688 CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
1689 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
1691 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)