1 dnl***************************************************************************
2 dnl Copyright (c) 1998-2000 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 Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,1998
31 dnl $Id: aclocal.m4,v 1.214 2000/07/07 15:11:34 tom Exp $
32 dnl Macros used in NCURSES auto-configuration script.
34 dnl ---------------------------------------------------------------------------
35 dnl ---------------------------------------------------------------------------
36 dnl Construct the list of include-options for the C programs in the Ada95
38 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
40 ACPPFLAGS="$ACPPFLAGS -I. -I../../include"
41 if test "$srcdir" != "."; then
42 ACPPFLAGS="$ACPPFLAGS -I\$(srcdir)/../../include"
44 if test -z "$GCC"; then
45 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
46 elif test "$includedir" != "/usr/include"; then
47 if test "$includedir" = '${prefix}/include' ; then
48 if test $prefix != /usr ; then
49 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
52 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
57 dnl ---------------------------------------------------------------------------
58 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
59 dnl in the sharutils 4.2 distribution.
60 AC_DEFUN([CF_ANSI_CC_CHECK],
62 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
63 AC_CACHE_VAL(cf_cv_ansi_cc,[
65 cf_save_CFLAGS="$CFLAGS"
66 # Don't try gcc -ansi; that turns off useful extensions and
67 # breaks some systems' header files.
69 # Ultrix and OSF/1 -std1
70 # HP-UX -Aa -D_HPUX_SOURCE
72 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
73 for cf_arg in "-DCC_HAS_PROTOS" \
78 "-Aa -D_HPUX_SOURCE" \
81 CFLAGS="$cf_save_CFLAGS $cf_arg"
85 #if !defined(__STDC__) || (__STDC__ != 1)
90 int test (int i, double x);
91 struct s1 {int (*f) (int a);};
92 struct s2 {int (*f) (double a);};],
93 [cf_cv_ansi_cc="$cf_arg"; break])
95 CFLAGS="$cf_save_CFLAGS"
97 AC_MSG_RESULT($cf_cv_ansi_cc)
99 if test "$cf_cv_ansi_cc" != "no"; then
100 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
101 CFLAGS="$CFLAGS $cf_cv_ansi_cc"
103 AC_DEFINE(CC_HAS_PROTOS)
107 dnl ---------------------------------------------------------------------------
108 dnl For programs that must use an ANSI compiler, obtain compiler options that
109 dnl will make it recognize prototypes. We'll do preprocessor checks in other
110 dnl macros, since tools such as unproto can fake prototypes, but only part of
111 dnl the preprocessor.
112 AC_DEFUN([CF_ANSI_CC_REQD],
113 [AC_REQUIRE([CF_ANSI_CC_CHECK])
114 if test "$cf_cv_ansi_cc" = "no"; then
116 [Your compiler does not appear to recognize prototypes.
117 You have the following choices:
118 a. adjust your compiler options
119 b. get an up-to-date compiler
120 c. use a wrapper such as unproto])
123 dnl ---------------------------------------------------------------------------
124 dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some
125 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
126 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
128 dnl Treat the configuration-variable specially here, since we're directly
129 dnl substituting its value (i.e., 1/0).
130 AC_DEFUN([CF_BOOL_DECL],
132 AC_MSG_CHECKING([for builtin ifelse(AC_LANG,[C],$CC,$CXX) bool type])
133 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
136 #include <sys/types.h>
138 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
139 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
141 if test $ifelse($1,,cf_cv_builtin_bool,[$1]) = 1
142 then AC_MSG_RESULT(yes)
143 else AC_MSG_RESULT(no)
146 dnl ---------------------------------------------------------------------------
147 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
148 dnl Don't bother looking for bool.h, since it's been deprecated.
149 AC_DEFUN([CF_BOOL_SIZE],
151 AC_MSG_CHECKING([for size of ifelse(AC_LANG,[C],$CC,$CXX) bool])
152 AC_CACHE_VAL(cf_cv_type_of_bool,[
157 #if HAVE_GXX_BUILTIN_H
158 #include <g++/builtin.h>
159 #elif HAVE_GPP_BUILTIN_H
160 #include <gpp/builtin.h>
166 FILE *fp = fopen("cf_test.out", "w");
170 fputs("unsigned ", fp);
171 if (sizeof(x) == sizeof(int)) fputs("int", fp);
172 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
173 else if (sizeof(x) == sizeof(short))fputs("short",fp);
174 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
180 [cf_cv_type_of_bool=`cat cf_test.out`],
181 [cf_cv_type_of_bool=unknown],
182 [cf_cv_type_of_bool=unknown])
185 AC_MSG_RESULT($cf_cv_type_of_bool)
186 if test "$cf_cv_type_of_bool" = unknown ; then
187 AC_MSG_WARN(Assuming unsigned for type of bool)
188 cf_cv_type_of_bool=unsigned
191 dnl ---------------------------------------------------------------------------
192 dnl Determine the default configuration into which we'll install ncurses. This
193 dnl can be overridden by the user's command-line options. There's two items to
195 dnl 1. the prefix (e.g., /usr)
196 dnl 2. the header files (e.g., /usr/include/ncurses)
197 dnl We'll look for a previous installation of ncurses and use the same defaults.
199 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
200 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
201 dnl programs from a vendor's.
202 AC_DEFUN([CF_CFG_DEFAULTS],
204 AC_MSG_CHECKING(for prefix)
205 if test "x$prefix" = "xNONE" ; then
206 case "$cf_cv_system_name" in
207 # non-vendor systems don't have a conflict
208 openbsd*|netbsd*|freebsd*|linux*)
211 *) prefix=$ac_default_prefix
215 AC_MSG_RESULT($prefix)
217 if test "x$prefix" = "xNONE" ; then
218 AC_MSG_CHECKING(for default include-directory)
219 test -n "$verbose" && echo 1>&AC_FD_MSG
222 $includedir/ncurses \
224 $prefix/include/ncurses \
226 /usr/local/include/ncurses \
230 cf_dir=`eval echo $cf_symbol`
231 if test -f $cf_dir/curses.h ; then
232 if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
233 includedir="$cf_symbol"
234 test -n "$verbose" && echo $ac_n " found " 1>&AC_FD_MSG
238 test -n "$verbose" && echo " tested $cf_dir" 1>&AC_FD_MSG
240 AC_MSG_RESULT($includedir)
243 dnl ---------------------------------------------------------------------------
244 dnl Check if the terminal-capability database functions are available. If not,
245 dnl ncurses has a much-reduced version.
246 AC_DEFUN([CF_CGETENT],[
247 AC_MSG_CHECKING(for terminal-capability database functions)
248 AC_CACHE_VAL(cf_cv_cgetent,[
250 #include <stdlib.h>],[
253 char *db_array = temp;
254 cgetent(&buf, /* int *, */ &db_array, "vt100");
255 cgetcap(buf, "tc", '=');
256 cgetmatch(buf, "tc");
261 AC_MSG_RESULT($cf_cv_cgetent)
262 test $cf_cv_cgetent = yes && AC_DEFINE(HAVE_BSD_CGETENT)
264 dnl ---------------------------------------------------------------------------
265 dnl Check if we're accidentally using a cache from a different machine.
266 dnl Derive the system name, as a check for reusing the autoconf cache.
268 dnl If we've packaged config.guess and config.sub, run that (since it does a
269 dnl better job than uname).
270 AC_DEFUN([CF_CHECK_CACHE],
272 if test -f $srcdir/config.guess ; then
274 system_name="$host_os"
276 system_name="`(uname -s -r) 2>/dev/null`"
277 if test -z "$system_name" ; then
278 system_name="`(hostname) 2>/dev/null`"
281 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
282 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
284 test -z "$system_name" && system_name="$cf_cv_system_name"
285 test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name")
287 if test ".$system_name" != ".$cf_cv_system_name" ; then
288 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
289 AC_ERROR("Please remove config.cache and try again.")
292 dnl ---------------------------------------------------------------------------
293 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
294 dnl the 'errno' variable. Define a DECL_xxx symbol if we must declare it
297 dnl (I would use AC_CACHE_CHECK here, but it will not work when called in a
298 dnl loop from CF_SYS_ERRLIST).
300 dnl $1 = the name to check
301 AC_DEFUN([CF_CHECK_ERRNO],
303 AC_MSG_CHECKING(if external $1 is declared)
304 AC_CACHE_VAL(cf_cv_dcl_$1,[
310 #include <sys/types.h>
311 #include <errno.h> ],
312 [long x = (long) $1],
313 [eval 'cf_cv_dcl_'$1'=yes'],
314 [eval 'cf_cv_dcl_'$1'=no'])
317 eval 'cf_result=$cf_cv_dcl_'$1
318 AC_MSG_RESULT($cf_result)
320 if test "$cf_result" = no ; then
321 eval 'cf_result=DECL_'$1
322 CF_UPPER(cf_result,$cf_result)
323 AC_DEFINE_UNQUOTED($cf_result)
326 # It's possible (for near-UNIX clones) that the data doesn't exist
327 CF_CHECK_EXTERN_DATA($1,int)
329 dnl ---------------------------------------------------------------------------
330 dnl Check for existence of external data in the current set of libraries. If
331 dnl we can modify it, it's real enough.
332 dnl $1 = the name to check
334 AC_DEFUN([CF_CHECK_EXTERN_DATA],
336 AC_MSG_CHECKING(if external $1 exists)
337 AC_CACHE_VAL(cf_cv_have_$1,[
343 [eval 'cf_cv_have_'$1'=yes'],
344 [eval 'cf_cv_have_'$1'=no'])])
346 eval 'cf_result=$cf_cv_have_'$1
347 AC_MSG_RESULT($cf_result)
349 if test "$cf_result" = yes ; then
350 eval 'cf_result=HAVE_'$1
351 CF_UPPER(cf_result,$cf_result)
352 AC_DEFINE_UNQUOTED($cf_result)
356 dnl ---------------------------------------------------------------------------
357 dnl Check if the C++ compiler accepts duplicate parameter initialization. This
358 dnl is a late feature for the standard and is not in some recent compilers
360 AC_DEFUN([CF_CPP_PARAM_INIT],
362 if test -n "$CXX" ; then
363 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
374 TEST::TEST(int x = 1) // some compilers do not like second initializer
380 [cf_cv_cpp_param_init=yes],
381 [cf_cv_cpp_param_init=no],
382 [cf_cv_cpp_param_init=unknown])
385 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
387 dnl ---------------------------------------------------------------------------
388 AC_DEFUN([CF_DIRS_TO_MAKE],
391 for cf_item in $cf_list_models
393 CF_OBJ_SUBDIR($cf_item,cf_subdir)
394 DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
396 for cf_dir in $DIRS_TO_MAKE
398 test ! -d $cf_dir && mkdir $cf_dir
400 AC_SUBST(DIRS_TO_MAKE)
402 dnl ---------------------------------------------------------------------------
403 dnl Check if 'errno' is declared in <errno.h>
406 CF_CHECK_ERRNO(errno)
408 dnl ---------------------------------------------------------------------------
409 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
410 dnl math.h and builtin.h, only for ncurses
411 AC_DEFUN([CF_ETIP_DEFINES],
413 AC_MSG_CHECKING(for special defines needed for etip.h)
414 cf_save_CXXFLAGS="$CXXFLAGS"
416 for cf_math in "" MATH_H
418 for cf_excp in "" MATH_EXCEPTION
420 CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu"
421 test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
422 test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
426 test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
427 test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
428 cf_result="$cf_math $cf_excp"
433 AC_MSG_RESULT($cf_result)
434 CXXFLAGS="$cf_save_CXXFLAGS"
436 dnl ---------------------------------------------------------------------------
437 dnl Check for memmove, or a bcopy that can handle overlapping copy. If neither
438 dnl is found, add our own version of memmove to the list of objects.
439 AC_DEFUN([CF_FUNC_MEMMOVE],
441 AC_CHECK_FUNC(memmove,,[
442 AC_CHECK_FUNC(bcopy,[
443 AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
446 static char data[] = "abcdefghijklmnopqrstuwwxyz";
448 bcopy(data, temp, sizeof(data));
449 bcopy(temp+10, temp, 15);
450 bcopy(temp+5, temp+15, 10);
451 exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
454 [cf_cv_good_bcopy=yes],
455 [cf_cv_good_bcopy=no],
456 [cf_cv_good_bcopy=unknown])
458 ],[cf_cv_good_bcopy=no])
459 if test $cf_cv_good_bcopy = yes ; then
460 AC_DEFINE(USE_OK_BCOPY)
462 AC_DEFINE(USE_MY_MEMMOVE)
465 dnl ---------------------------------------------------------------------------
466 dnl See if the poll function really works. Some platforms have poll(), but
467 dnl it does not work for terminals or files.
468 AC_DEFUN([CF_FUNC_POLL],[
469 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
475 #include <sys/poll.h>
482 myfds.events = POLLIN;
484 ret = poll(&myfds, 1, 100);
487 [cf_cv_working_poll=yes],
488 [cf_cv_working_poll=no],
489 [cf_cv_working_poll=unknown])])
490 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
492 dnl ---------------------------------------------------------------------------
493 dnl Test for availability of useful gcc __attribute__ directives to quiet
494 dnl compiler warnings. Though useful, not all are supported -- and contrary
495 dnl to documentation, unrecognized directives cause older compilers to barf.
496 AC_DEFUN([CF_GCC_ATTRIBUTES],
500 cat > conftest.i <<EOF
508 #define GCC_NORETURN /* nothing */
511 #define GCC_UNUSED /* nothing */
516 AC_CHECKING([for $CC __attribute__ directives])
518 cat > conftest.$ac_ext <<EOF
519 #line __oline__ "configure"
520 #include "confdefs.h"
521 #include "conftest.h"
522 #include "conftest.i"
524 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
526 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
529 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
531 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
533 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
534 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
535 extern void foo(void) GCC_NORETURN;
536 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
539 for cf_attribute in scanf printf unused noreturn
541 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
542 cf_directive="__attribute__(($cf_attribute))"
543 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
544 case $cf_attribute in
546 cat >conftest.h <<EOF
547 #define GCC_$CF_ATTRIBUTE 1
551 cat >conftest.h <<EOF
552 #define GCC_$CF_ATTRIBUTE $cf_directive
556 if AC_TRY_EVAL(ac_compile); then
557 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
558 cat conftest.h >>confdefs.h
560 # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
564 fgrep define conftest.i >>confdefs.h
569 dnl ---------------------------------------------------------------------------
570 dnl Check if the compiler supports useful warning options. There's a few that
571 dnl we don't use, simply because they're too noisy:
573 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
574 dnl -Wredundant-decls (system headers make this too noisy)
575 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
576 dnl -Wwrite-strings (too noisy, but should review occasionally)
579 AC_DEFUN([CF_GCC_WARNINGS],
584 cat > conftest.$ac_ext <<EOF
585 #line __oline__ "configure"
586 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
589 AC_CHECKING([for $CC warning options])
590 cf_save_CFLAGS="$CFLAGS"
591 EXTRA_CFLAGS="-W -Wall"
593 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
599 Wmissing-declarations \
600 Wmissing-prototypes \
604 Wstrict-prototypes $cf_warn_CONST
606 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
607 if AC_TRY_EVAL(ac_compile); then
608 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
609 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
610 test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
614 CFLAGS="$cf_save_CFLAGS"
616 AC_SUBST(EXTRA_CFLAGS)
618 dnl ---------------------------------------------------------------------------
619 dnl Verify that a test program compiles and runs with GNAT
620 dnl $cf_ada_make is set to the program that compiles/links
621 AC_DEFUN([CF_GNAT_TRY_RUN],
624 cat >>conftest.ads <<CF_EOF
627 cat >>conftest.adb <<CF_EOF
630 if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
631 if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
641 dnl ---------------------------------------------------------------------------
642 dnl Verify Version of GNAT.
643 AC_DEFUN([CF_GNAT_VERSION],
645 changequote(<<, >>)dnl
646 cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
647 sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'`
648 case $cf_cv_gnat_version in
649 3.1[1-9]*|3.[2-9]*|[4-9].*)
650 cf_cv_prog_gnat_correct=yes
652 *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
653 cf_cv_prog_gnat_correct=no
656 case $cf_cv_gnat_version in
658 cf_compile_generics=generics
659 cf_generic_objects="\$(GENOBJS)"
661 *) cf_compile_generics=
667 dnl ---------------------------------------------------------------------------
668 dnl If we're trying to use g++, test if libg++ is installed (a rather common
669 dnl problem :-). If we have the compiler but no library, we'll be able to
670 dnl configure, but won't be able to build the c++ demo program.
671 AC_DEFUN([CF_GPP_LIBRARY],
673 cf_cxx_library=unknown
674 case $cf_cv_system_name in #(vi
682 if test $ac_cv_prog_gxx = yes; then
683 AC_MSG_CHECKING([for lib$cf_gpp_libname])
685 LIBS="$LIBS -l$cf_gpp_libname"
687 #include <$cf_gpp_libname/builtin.h>
689 [two_arg_error_handler_t foo2 = lib_error_handler],
691 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
692 if test "$cf_gpp_libname" = cpp ; then
693 AC_DEFINE(HAVE_GPP_BUILTIN_H)
695 AC_DEFINE(HAVE_GXX_BUILTIN_H)
700 [two_arg_error_handler_t foo2 = lib_error_handler],
702 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
703 AC_DEFINE(HAVE_BUILTIN_H)],
704 [cf_cxx_library=no])])
706 AC_MSG_RESULT($cf_cxx_library)
709 dnl ---------------------------------------------------------------------------
710 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
711 AC_DEFUN([CF_HELP_MESSAGE],
712 [AC_DIVERT_HELP([$1])dnl
714 dnl ---------------------------------------------------------------------------
715 dnl Construct the list of include-options according to whether we're building
716 dnl in the source directory or using '--srcdir=DIR' option. If we're building
717 dnl with gcc, don't append the includedir if it happens to be /usr/include,
718 dnl since that usually breaks gcc's shadow-includes.
719 AC_DEFUN([CF_INCLUDE_DIRS],
721 CPPFLAGS="$CPPFLAGS -I. -I../include"
722 if test "$srcdir" != "."; then
723 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
725 if test -z "$GCC"; then
726 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
727 elif test "$includedir" != "/usr/include"; then
728 if test "$includedir" = '${prefix}/include' ; then
729 if test $prefix != /usr ; then
730 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
733 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
738 dnl ---------------------------------------------------------------------------
739 dnl Check if we have either a function or macro for 'isascii()'.
740 AC_DEFUN([CF_ISASCII],
742 AC_MSG_CHECKING(for isascii)
743 AC_CACHE_VAL(cf_cv_have_isascii,[
744 AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
745 [cf_cv_have_isascii=yes],
746 [cf_cv_have_isascii=no])
748 AC_MSG_RESULT($cf_cv_have_isascii)
749 test $cf_cv_have_isascii = yes && AC_DEFINE(HAVE_ISASCII)
751 dnl ---------------------------------------------------------------------------
752 dnl Compute the library-prefix for the given host system
753 dnl $1 = variable to set
754 AC_DEFUN([CF_LIB_PREFIX],
756 case $cf_cv_system_name in
757 os2) LIB_PREFIX='' ;;
758 *) LIB_PREFIX='lib' ;;
760 ifelse($1,,,[$1=$LIB_PREFIX])
763 dnl ---------------------------------------------------------------------------
764 dnl Append definitions and rules for the given models to the subdirectory
765 dnl Makefiles, and the recursion rule for the top-level Makefile. If the
766 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
767 dnl the corresponding makefile to list the models that we'll generate.
769 dnl For shared libraries, make a list of symbolic links to construct when
770 dnl generating each library. The convention used for Linux is the simplest
773 dnl lib<name>.so.<major> ->
774 dnl lib<name>.so.<maj>.<minor>
775 AC_DEFUN([CF_LIB_RULES],
777 CF_LIB_PREFIX(cf_prefix)
778 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
779 for cf_dir in $SRC_SUBDIRS
781 if test -f $srcdir/$cf_dir/modules; then
784 for cf_item in $CF_LIST_MODELS
786 CF_LIB_SUFFIX($cf_item,cf_suffix)
787 if test $cf_item = shared ; then
788 if test $cf_cv_do_symlinks = yes ; then
789 case "$cf_cv_shlib_version" in #(vi
790 rel) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;; #(vi
791 abi) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
795 cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
798 if test $cf_dir = ncurses ; then
799 case "$LIB_SUBSETS" in #(vi
803 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g`
804 cf_libs_to_make="$cf_item $cf_libs_to_make"
809 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \
810 $cf_dir/Makefile >$cf_dir/Makefile.out
811 mv $cf_dir/Makefile.out $cf_dir/Makefile
813 $AWK -f $srcdir/mk-0th.awk \
815 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
817 for cf_item in $CF_LIST_MODELS
819 echo 'Appending rules for '$cf_item' model ('$cf_dir')'
820 CF_UPPER(CF_ITEM,$cf_item)
821 CF_LIB_SUFFIX($cf_item,cf_suffix)
822 CF_OBJ_SUBDIR($cf_item,cf_subdir)
824 # These dependencies really are for development, not
825 # builds, but they are useful in porting, too.
826 cf_depend="../include/ncurses_cfg.h"
827 if test "$srcdir" = "."; then
830 cf_reldir="\$(srcdir)"
833 if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
834 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
835 elif test -f $srcdir/$cf_dir/curses.priv.h; then
836 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
839 for cf_subset in $LIB_SUBSETS
841 $AWK -f $srcdir/mk-1st.awk \
843 traces=$LIB_TRACING \
849 ShlibVer=$cf_cv_shlib_version \
850 DoLinks=$cf_cv_do_symlinks \
851 rmSoLocs=$cf_cv_rm_so_locs \
852 ldconfig="$LDCONFIG" \
853 overwrite=$WITH_OVERWRITE \
854 depend="$cf_depend" \
856 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
857 test $cf_dir = ncurses && WITH_OVERWRITE=no
858 $AWK -f $srcdir/mk-2nd.awk \
860 traces=$LIB_TRACING \
866 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
871 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
874 for cf_dir in $SRC_SUBDIRS
876 if test -f $cf_dir/Makefile ; then
879 echo 'libs \' >> Makefile
880 echo 'install.libs \' >> Makefile
881 echo 'uninstall.libs ::' >> Makefile
882 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
887 if test -f $srcdir/$cf_dir/modules; then
889 if test -f $srcdir/$cf_dir/headers; then
890 cat >> Makefile <<CF_EOF
892 uninstall.includes \\
895 if test "$cf_dir" != "c++" ; then
896 echo 'lint \' >> Makefile
898 cat >> Makefile <<CF_EOF
905 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
907 elif test -f $srcdir/$cf_dir/headers; then
908 cat >> Makefile <<CF_EOF
914 uninstall.includes ::
915 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
920 cat >> Makefile <<CF_EOF
924 cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
928 cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
931 rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
932 rm -f headers.sh headers.sed
933 rm -rf \$(DIRS_TO_MAKE)
936 dnl If we're installing into a subdirectory of /usr/include, etc., we should
937 dnl prepend the subdirectory's name to the "#include" paths. It won't hurt
938 dnl anything, and will make it more standardized. It's awkward to decide this
939 dnl at configuration because of quoting, so we'll simply make all headers
940 dnl installed via a script that can do the right thing.
942 rm -f headers.sed headers.sh
944 dnl ( generating this script makes the makefiles a little tidier :-)
945 echo creating headers.sh
946 cat >headers.sh <<CF_EOF
948 # This shell script is generated by the 'configure' script. It is invoked in a
949 # subdirectory of the build tree. It generates a sed-script in the parent
950 # directory that is used to adjust includes for header files that reside in a
951 # subdirectory of /usr/include, etc.
953 while test \[$]# != 3
955 PRG="\$PRG \[$]1"; shift
960 echo installing \$SRC in \$DST
963 TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
964 TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
965 END=\`basename \$DST\`
966 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
968 NAME=\`basename \$i\`
969 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
972 sed -f \$TMPSED \$SRC > \$TMPSRC
973 eval \$PRG \$TMPSRC \$DST/\$SRC
974 rm -f \$TMPSRC \$TMPSED
977 eval \$PRG \$SRC \$DST
982 chmod 0755 headers.sh
984 for cf_dir in $SRC_SUBDIRS
986 if test -f $srcdir/$cf_dir/headers; then
987 cat >>$cf_dir/Makefile <<CF_EOF
988 \$(INSTALL_PREFIX)\$(includedir) :
989 \$(srcdir)/../mkinstalldirs \[$]@
993 install.includes :: \$(INSTALL_PREFIX)\$(includedir) \\
996 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
998 test -n "$j" && echo " $j \\" >>$cf_dir/Makefile
1001 echo " $j" >>$cf_dir/Makefile
1002 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1004 echo " @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(INSTALL_PREFIX)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
1005 test $i = curses.h && echo " @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
1008 cat >>$cf_dir/Makefile <<CF_EOF
1012 uninstall.includes ::
1014 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1017 echo " -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
1018 test $i = curses.h && echo " -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
1024 dnl ---------------------------------------------------------------------------
1025 dnl Compute the library file-suffix from the given model name
1027 dnl $2 = variable to set
1028 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1029 AC_DEFUN([CF_LIB_SUFFIX],
1031 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1035 profile) $2='_p.a' ;;
1037 case $cf_cv_system_name in
1042 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1044 dnl ---------------------------------------------------------------------------
1045 dnl Compute the string to append to -library from the given model name
1047 dnl $2 = variable to set
1048 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1049 AC_DEFUN([CF_LIB_TYPE],
1057 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1059 dnl ---------------------------------------------------------------------------
1060 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1061 dnl only data (i.e., no functions), for example NeXT. On those systems we'll
1062 dnl have to provide wrappers for global tables to ensure they're linked
1064 AC_DEFUN([CF_LINK_DATAONLY],
1066 AC_MSG_CHECKING([if data-only library module links])
1067 AC_CACHE_VAL(cf_cv_link_dataonly,[
1070 cat >conftest.$ac_ext <<EOF
1071 #line __oline__ "configure"
1072 int testdata[3] = { 123, 456, 789 };
1075 if AC_TRY_EVAL(ac_compile) ; then
1076 mv conftest.o data.o && \
1077 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
1079 rm -f conftest.$ac_ext data.o
1081 cat >conftest.$ac_ext <<EOF
1082 #line __oline__ "configure"
1086 exit(1); /* I'm told this linker is broken */
1088 extern int testdata[3];
1089 return testdata[0] == 123
1090 && testdata[1] == 456
1091 && testdata[2] == 789;
1096 if AC_TRY_EVAL(ac_compile); then
1097 mv conftest.o func.o && \
1098 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
1100 rm -f conftest.$ac_ext func.o
1101 ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
1103 LIBS="conftest.a $LIBS"
1107 extern int testfunc();
1111 [cf_cv_link_dataonly=yes],
1112 [cf_cv_link_dataonly=no],
1113 [cf_cv_link_dataonly=unknown])
1116 AC_MSG_RESULT($cf_cv_link_dataonly)
1117 test $cf_cv_link_dataonly = no && AC_DEFINE(BROKEN_LINKER)
1119 dnl ---------------------------------------------------------------------------
1120 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1121 dnl A few non-Unix systems implement symlink, but not link.
1122 dnl A few non-systems implement neither (or have nonfunctional versions).
1123 AC_DEFUN([CF_LINK_FUNCS],
1129 if test "$ac_cv_prog_cc_cross" = yes ; then
1134 AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1136 for cf_func in link symlink ; do
1138 #include <sys/types.h>
1139 #include <sys/stat.h>
1140 #ifdef HAVE_UNISTD_H
1146 char *src = "config.log";
1147 char *dst = "conftest.chk";
1152 fail = ($cf_func("config.log", "conftest.chk") < 0)
1153 || (stat(dst, &dst_sb) < 0)
1154 || (dst_sb.st_mtime != src_sb.st_mtime);
1163 cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1164 eval 'ac_cv_func_'$cf_func'=yes'
1165 CF_UPPER(cf_FUNC,$cf_func)
1166 AC_DEFINE_UNQUOTED(HAVE_$cf_FUNC)],[
1167 eval 'ac_cv_func_'$cf_func'=no'],[
1168 eval 'ac_cv_func_'$cf_func'=error'])
1170 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1174 dnl ---------------------------------------------------------------------------
1175 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1176 dnl options to lower-levels. It's very useful for "make -n" -- if we have it.
1177 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1178 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1179 AC_DEFUN([CF_MAKEFLAGS],
1181 AC_MSG_CHECKING([for makeflags variable])
1182 AC_CACHE_VAL(cf_cv_makeflags,[
1184 for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1186 cat >cf_makeflags.tmp <<CF_EOF
1188 @ echo '.$cf_option'
1190 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1191 case "$cf_result" in
1193 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1194 case "$cf_result" in
1195 .*CC=*) cf_cv_makeflags=
1197 *) cf_cv_makeflags=$cf_option
1202 *) echo no match "$cf_result"
1206 rm -f cf_makeflags.tmp])
1207 AC_MSG_RESULT($cf_cv_makeflags)
1208 AC_SUBST(cf_cv_makeflags)
1210 dnl ---------------------------------------------------------------------------
1211 dnl Option to allow user to override automatic configuration of manpage format.
1212 dnl There are several special cases.
1213 AC_DEFUN([CF_MANPAGE_FORMAT],
1214 [ AC_MSG_CHECKING(format of man-pages)
1216 AC_ARG_WITH(manpage-format,
1217 [ --with-manpage-format specify manpage-format: gzip/compress/BSDI/normal and
1218 optionally formatted, e.g., gzip,formatted],
1219 [cf_manpage_form=$withval],
1220 [cf_manpage_form=unknown])
1222 case ".$cf_manpage_form" in
1223 .gzip|.compress|.BSDI|.normal|.formatted) # (vi
1226 if test -z "$MANPATH" ; then
1227 MANPATH="/usr/man:/usr/share/man"
1229 # look for the 'date' man-page (it's most likely to be installed!)
1230 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1231 cf_manpage_form=unknown
1232 for cf_dir in $MANPATH; do
1233 test -z "$cf_dir" && cf_dir=/usr/man
1234 changequote({{,}})dnl
1235 for cf_name in $cf_dir/*/date.[01]* $cf_dir/*/date
1238 cf_test=`echo $cf_name | sed -e 's/*//'`
1239 if test "x$cf_test" = "x$cf_name" ; then
1241 *.gz) cf_manpage_form=gzip;;
1242 *.Z) cf_manpage_form=compress;;
1243 *.0) cf_manpage_form=BSDI,formatted;;
1244 *) cf_manpage_form=normal;;
1249 if test "$cf_manpage_form" != "unknown" ; then
1256 AC_MSG_WARN(Unexpected manpage-format)
1260 AC_MSG_RESULT($cf_manpage_form)
1262 dnl ---------------------------------------------------------------------------
1263 dnl The Debian people have their own naming convention for manpages. This
1264 dnl option lets us override the name of the file containing renaming, or
1265 dnl disable it altogether.
1266 AC_DEFUN([CF_MANPAGE_RENAMES],
1268 AC_MSG_CHECKING(for manpage renaming)
1270 AC_ARG_WITH(manpage-renames,
1271 [ --with-manpage-renames specify manpage-renaming],
1272 [cf_manpage_renames=$withval],
1273 [cf_manpage_renames=yes])
1275 case ".$cf_manpage_renames" in #(vi
1279 # Debian 'man' program?
1280 if test -f /etc/debian_version ; then
1281 cf_manpage_renames=`cd $srcdir && pwd`/man/man_db.renames
1283 cf_manpage_renames=no
1288 if test "$cf_manpage_renames" != no ; then
1289 if test ! -f $cf_manpage_renames ; then
1290 AC_MSG_ERROR(not a filename: $cf_manpage_renames)
1293 test ! -d man && mkdir man
1295 # Construct a sed-script to perform renaming within man-pages
1296 if test -n "$cf_manpage_renames" ; then
1297 test ! -d man && mkdir man
1298 $srcdir/man/make_sed.sh $cf_manpage_renames >man/edit_man.sed
1302 AC_MSG_RESULT($cf_manpage_renames)
1304 dnl ---------------------------------------------------------------------------
1305 dnl Some people expect each tool to make all aliases for manpages in the
1306 dnl man-directory. This accommodates the older, less-capable implementations
1307 dnl of 'man', and is optional.
1308 AC_DEFUN([CF_MANPAGE_SYMLINKS],
1310 AC_MSG_CHECKING(for manpage symlinks)
1312 AC_ARG_WITH(manpage-symlinks,
1313 [ --with-manpage-symlinks specify manpage-symlinks],
1314 [cf_manpage_symlinks=$withval],
1315 [cf_manpage_symlinks=yes])
1317 AC_MSG_RESULT($cf_manpage_symlinks)
1319 dnl ---------------------------------------------------------------------------
1320 dnl Try to determine if the man-pages on the system are compressed, and if
1321 dnl so, what format is used. Use this information to construct a script that
1322 dnl will install man-pages.
1323 AC_DEFUN([CF_MAN_PAGES],
1325 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
1330 if test "$prefix" = "NONE" ; then
1331 cf_prefix="$ac_default_prefix"
1336 case "$cf_manpage_form" in # (vi
1338 cf_subdir='$mandir/cat'
1342 cf_subdir='$mandir/man'
1347 test ! -d man && mkdir man
1348 cat >man/edit_man.sh <<CF_EOF
1349 changequote({{,}})dnl
1351 # this script is generated by the configure-script
1354 MKDIRS="`cd $srcdir && pwd`/mkinstalldirs"
1356 INSTALL_DATA="$INSTALL_DATA"
1358 TMP=\${TMPDIR-/tmp}/man\$\$
1359 trap "rm -f \$TMP" 0 1 2 5 15
1370 for i in \{{$}}* ; do
1372 *.orig|*.rej) ;; #(vi
1374 section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
1375 if test \$verb = installing ; then
1376 if test ! -d $cf_subdir\${section} ; then
1377 \$MKDIRS $cf_subdir\$section
1381 source=\`basename \$i\`
1383 if test "$cf_manpage_symlinks" = yes ; then
1384 cat >>man/edit_man.sh <<CF_EOF
1385 aliases=\`sed -f \$srcdir/manlinks.sed \$source | sort -u\`
1388 if test "$cf_manpage_renames" = no ; then
1389 cat >>man/edit_man.sh <<CF_EOF
1390 target=$cf_subdir\${section}/\$source
1391 sed -e "s,@DATADIR@,\$datadir," < \$i >\$TMP
1394 cat >>man/edit_man.sh <<CF_EOF
1395 target=\`grep "^\$source" $cf_manpage_renames | $AWK '{print \{{$}}2}'\`
1396 if test -z "\$target" ; then
1397 echo '? missing rename for '\$source
1400 target="$cf_subdir\$section/\$target"
1401 test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP
1404 if test $cf_format = yes ; then
1405 cat >>man/edit_man.sh <<CF_EOF
1406 nroff -man \$TMP >\$TMP.out
1410 case "$cf_manpage_form" in #(vi
1412 cat >>man/edit_man.sh <<CF_EOF
1413 if test \$verb = installing ; then
1414 if ( compress -f \$TMP )
1423 cat >>man/edit_man.sh <<CF_EOF
1424 if test \$verb = installing ; then
1425 if ( gzip -f \$TMP )
1430 target="\$target.gz"
1434 cat >>man/edit_man.sh <<CF_EOF
1435 # BSDI installs only .0 suffixes in the cat directories
1436 target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`"
1440 cat >>man/edit_man.sh <<CF_EOF
1441 echo \$verb \$target
1442 suffix=\`basename \$target | sed -e 's/^[^.]*//'\`
1443 if test \$verb = installing ; then
1444 \$INSTALL_DATA \$TMP \$target
1445 test -n "\$aliases" && (
1446 cd $cf_subdir\${section} && (
1447 target=\`basename \$target\`
1448 for cf_alias in \$aliases
1450 if test -f \$cf_alias\${suffix} ; then
1451 if ( cmp -s \$target \$cf_alias\${suffix} )
1455 echo .. \$verb alias \$cf_alias\${suffix}
1456 rm -f \$cf_alias\${suffix}
1457 $LN_S \$target \$cf_alias\${suffix}
1460 echo .. \$verb alias \$cf_alias\${suffix}
1461 rm -f \$cf_alias\${suffix}
1462 $LN_S \$target \$cf_alias\${suffix}
1469 test -n "\$aliases" && (
1470 cd $cf_subdir\${section} && (
1471 for cf_alias in \$aliases
1473 echo .. \$verb alias \$cf_alias\${suffix}
1474 rm -f \$cf_alias\${suffix}
1485 chmod 755 man/edit_man.sh
1488 dnl ---------------------------------------------------------------------------
1489 dnl Checks for libraries. At least one UNIX system, Apple Macintosh
1490 dnl Rhapsody 5.5, does not have -lm. We cannot use the simpler
1491 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1492 AC_DEFUN([CF_MATH_LIB],
1494 AC_CACHE_CHECK(if -lm needed for math functions,
1500 [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
1501 [cf_cv_need_libm=no],
1502 [cf_cv_need_libm=yes])])
1503 if test "$cf_cv_need_libm" = yes
1510 dnl ---------------------------------------------------------------------------
1511 dnl Compute the object-directory name from the given model name
1512 AC_DEFUN([CF_OBJ_SUBDIR],
1515 normal) $2='objects' ;;
1516 debug) $2='obj_g' ;;
1517 profile) $2='obj_p' ;;
1518 shared) $2='obj_s' ;;
1521 dnl ---------------------------------------------------------------------------
1522 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1523 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1524 dnl result begins with 'NONE'. This is necessary to workaround autoconf's
1525 dnl delayed evaluation of those symbols.
1526 AC_DEFUN([CF_PATH_SYNTAX],[
1527 case ".[$]$1" in #(vi
1530 .[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
1532 .\[$]{*prefix}*) #(vi
1534 case ".[$]$1" in #(vi
1536 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1541 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1544 AC_ERROR(expected a pathname)
1548 dnl ---------------------------------------------------------------------------
1549 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1550 AC_DEFUN([CF_PROG_EXT],
1552 AC_REQUIRE([CF_CHECK_CACHE])
1554 case $cf_cv_system_name in
1556 # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@
1557 CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__"
1558 CXXFLAGS="$CXXFLAGS -Zmt -D__ST_MT_ERRNO__"
1559 LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"`
1568 dnl ---------------------------------------------------------------------------
1569 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
1570 dnl misc/tabset install won't work properly. Usually this happens only when
1571 dnl using the fallback mkinstalldirs script
1572 AC_DEFUN([CF_PROG_INSTALL],
1578 changequote({{,}})dnl
1579 cf_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
1580 test -z "$cf_dir" && cf_dir=.
1582 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
1586 dnl ---------------------------------------------------------------------------
1587 dnl Attempt to determine if we've got one of the flavors of regular-expression
1588 dnl code that we can support.
1589 AC_DEFUN([CF_REGEX],
1591 AC_MSG_CHECKING([for regular-expression headers])
1592 AC_CACHE_VAL(cf_cv_regex,[
1593 AC_TRY_LINK([#include <sys/types.h>
1594 #include <regex.h>],[
1596 int x = regcomp(p, "", 0);
1597 int y = regexec(p, "", 0, 0, 0);
1599 ],[cf_cv_regex="regex.h"],[
1600 AC_TRY_LINK([#include <regexp.h>],[
1601 char *p = compile("", "", "", 0);
1602 int x = step("", "");
1603 ],[cf_cv_regex="regexp.h"],[
1604 cf_save_LIBS="$LIBS"
1606 AC_TRY_LINK([#include <regexpr.h>],[
1607 char *p = compile("", "", "");
1608 int x = step("", "");
1609 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
1611 AC_MSG_RESULT($cf_cv_regex)
1612 case $cf_cv_regex in
1613 regex.h) AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
1614 regexp.h) AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
1615 regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1618 dnl ---------------------------------------------------------------------------
1619 dnl Attempt to determine the appropriate CC/LD options for creating a shared
1622 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
1623 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
1624 dnl We avoid compiling-in a ../lib path for the shared library since that can
1625 dnl lead to unexpected results at runtime.
1626 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
1627 dnl are compiled in ../../lib
1629 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
1630 dnl to install symbolic links to the rel/abi versions of shared libraries.
1632 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
1633 dnl version when making symbolic links.
1635 dnl Some loaders leave 'so_locations' lying around. It's nice to clean up.
1636 AC_DEFUN([CF_SHARED_OPTS],
1638 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1642 INSTALL_LIB="-m 644"
1644 cf_cv_do_symlinks=no
1646 AC_MSG_CHECKING(if release/abi version should be used for shared libs)
1647 AC_ARG_WITH(shlib-version,
1648 [ --with-shlib-version=X Specify rel or abi version for shared libs],
1649 [test -z "$withval" && withval=auto
1650 case $withval in #(vi
1652 cf_cv_shlib_version=auto
1654 rel|abi|auto|no) #(vi
1655 cf_cv_shlib_version=$withval
1658 AC_ERROR([option value must be one of: rel, abi, auto or no])
1661 ],[cf_cv_shlib_version=auto])
1662 AC_MSG_RESULT($cf_cv_shlib_version)
1666 # Some less-capable ports of gcc support only -fpic
1670 AC_MSG_CHECKING(which $CC option to use)
1671 cf_save_CFLAGS="$CFLAGS"
1672 for CC_SHARED_OPTS in -fPIC -fpic ''
1674 CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
1675 AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
1677 AC_MSG_RESULT($CC_SHARED_OPTS)
1678 CFLAGS="$cf_save_CFLAGS"
1681 case $cf_cv_system_name in
1683 MK_SHARED_LIB='$(CC) -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
1686 # (tested with gcc 2.7.2 -- I don't have c89)
1687 if test -n "$GCC"; then
1688 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1691 LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1693 MK_SHARED_LIB='$(LD) +b $(libdir) -b +h `basename $[@]` -o $[@]'
1694 # HP-UX shared libraries must be executable, and should be
1695 # readonly to exploit a quirk in the memory manager.
1696 INSTALL_LIB="-m 555"
1697 cf_cv_do_symlinks=reverse
1700 # (tested with gcc 2.7.2 -- I don't have c89)
1701 if test -n "$GCC"; then
1702 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1705 LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1707 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]'
1708 # HP-UX shared libraries must be executable, and should be
1709 # readonly to exploit a quirk in the memory manager.
1710 INSTALL_LIB="-m 555"
1713 # tested with IRIX 5.2 and 'cc'.
1714 if test -z "$GCC"; then
1715 CC_SHARED_OPTS='-KPIC'
1717 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
1718 cf_cv_rm_so_locs=yes
1721 # tested with Linux 2.0.29 and gcc 2.7.2 (ELF)
1722 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1723 if test $DFT_LWR_MODEL = "shared" ; then
1724 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1725 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1727 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1728 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION),-stats,-lc -o $[@]'
1731 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
1732 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
1735 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
1736 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1737 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1740 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
1741 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1742 if test $DFT_LWR_MODEL = "shared" && test $cf_cv_ld_rpath = yes ; then
1743 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1744 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1745 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
1746 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
1747 if test $cf_cv_shlib_version = auto; then
1748 if test ! -f /usr/libexec/ld.elf_so; then
1749 cf_cv_shlib_version=rel
1753 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1757 # tested with OSF/1 V3.2 and 'cc'
1758 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
1759 # link with shared libs).
1760 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`'
1761 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-rpath"
1764 MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
1767 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
1768 if test $DFT_LWR_MODEL = "shared" ; then
1769 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1770 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1772 cf_cv_rm_so_locs=yes
1774 sco3.2v5*) # (also uw2* and UW7) hops 13-Apr-98
1775 # tested with osr5.0.5
1776 if test $ac_cv_prog_gcc != yes; then
1777 CC_SHARED_OPTS='-belf -KPIC'
1779 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o [$]@'
1780 if test $cf_cv_ld_rpath = yes ; then
1781 # only way is to set LD_RUN_PATH but no switch for it
1784 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1785 LINK_PROGS='LD_RUN_PATH=$(libdir)'
1786 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
1789 # tested with SunOS 4.1.1 and gcc 2.7.0
1790 if test $ac_cv_prog_gcc != yes; then
1791 CC_SHARED_OPTS='-KPIC'
1793 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]'
1794 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1797 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
1798 if test $ac_cv_prog_gcc != yes; then
1799 CC_SHARED_OPTS='-KPIC'
1801 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
1802 if test $cf_cv_ld_rpath = yes ; then
1803 cf_ld_rpath_opt="-R"
1804 EXTRA_LDFLAGS="-R ../lib:\$(libdir) $EXTRA_LDFLAGS"
1806 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1809 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
1810 if test $ac_cv_prog_gcc != yes; then
1811 CC_SHARED_OPTS='-KPIC'
1813 MK_SHARED_LIB='$(LD) -d y -G -o [$]@'
1816 CC_SHARED_OPTS='unknown'
1817 MK_SHARED_LIB='echo unknown'
1821 # This works if the last tokens in $MK_SHARED_LIB are the -o target.
1822 case "$cf_cv_shlib_version" in #(vi
1824 case "$MK_SHARED_LIB" in #(vi
1826 test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
1829 AC_MSG_WARN(ignored --with-shlib-version)
1835 if test -n "$cf_ld_rpath_opt" ; then
1836 AC_MSG_CHECKING(if we need a space after rpath option)
1837 cf_save_LIBS="$LIBS"
1838 LIBS="$LIBS ${cf_ld_rpath_opt}/usr/lib"
1839 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1840 LIBS="$cf_save_LIBS"
1841 AC_MSG_RESULT($cf_rpath_space)
1842 test $cf_rpath_space = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
1843 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
1846 AC_SUBST(CC_SHARED_OPTS)
1847 AC_SUBST(LD_SHARED_OPTS)
1848 AC_SUBST(MK_SHARED_LIB)
1849 AC_SUBST(LINK_PROGS)
1850 AC_SUBST(LINK_TESTS)
1851 AC_SUBST(EXTRA_LDFLAGS)
1852 AC_SUBST(LOCAL_LDFLAGS)
1853 AC_SUBST(LOCAL_LDFLAGS2)
1854 AC_SUBST(INSTALL_LIB)
1856 dnl ---------------------------------------------------------------------------
1857 dnl Check for definitions & structures needed for window size-changing
1858 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
1859 AC_DEFUN([CF_SIZECHANGE],
1861 AC_MSG_CHECKING([declaration of size-change])
1862 AC_CACHE_VAL(cf_cv_sizechange,[
1863 cf_cv_sizechange=unknown
1864 cf_save_CFLAGS="$CFLAGS"
1866 for cf_opts in "" "NEED_PTEM_H"
1869 CFLAGS="$cf_save_CFLAGS"
1870 test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts"
1871 AC_TRY_COMPILE([#include <sys/types.h>
1873 #include <termios.h>
1880 /* This is a workaround for SCO: they neglected to define struct winsize in
1881 * termios.h -- it's only in termio.h and ptem.h
1883 #include <sys/stream.h>
1884 #include <sys/ptem.h>
1886 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
1887 #include <sys/ioctl.h>
1891 struct ttysize win; /* FIXME: what system is this? */
1892 int y = win.ts_lines;
1893 int x = win.ts_cols;
1900 no TIOCGSIZE or TIOCGWINSZ
1901 #endif /* TIOCGWINSZ */
1902 #endif /* TIOCGSIZE */
1904 [cf_cv_sizechange=yes],
1905 [cf_cv_sizechange=no])
1907 CFLAGS="$cf_save_CFLAGS"
1908 if test "$cf_cv_sizechange" = yes ; then
1909 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
1910 test -n "$cf_opts" && AC_DEFINE_UNQUOTED($cf_opts)
1915 AC_MSG_RESULT($cf_cv_sizechange)
1916 test $cf_cv_sizechange != no && AC_DEFINE(HAVE_SIZECHANGE)
1918 dnl ---------------------------------------------------------------------------
1919 dnl Check for datatype 'speed_t', which is normally declared via either
1920 dnl sys/types.h or termios.h
1921 AC_DEFUN([CF_SPEED_TYPE],
1923 AC_MSG_CHECKING(for speed_t)
1925 AC_TRY_COMPILE([#include <sys/types.h>],
1926 [speed_t some_variable = 0],
1927 [OSPEED_TYPE=speed_t],
1928 [OSPEED_TYPE=unsigned])
1929 AC_TRY_COMPILE([#include <termios.h>],
1930 [speed_t some_variable = 0],
1931 [OSPEED_TYPE=speed_t
1932 OSPEED_INCLUDES="#include <termios.h>"],[])
1933 AC_SUBST(OSPEED_TYPE)
1934 AC_SUBST(OSPEED_INCLUDES)
1935 if test "$OSPEED_TYPE" = "unsigned" ; then
1937 AC_DEFINE(speed_t,unsigned)
1942 dnl ---------------------------------------------------------------------------
1943 dnl For each parameter, test if the source-directory exists, and if it contains
1944 dnl a 'modules' file. If so, add to the list $cf_cv_src_modules which we'll
1945 dnl use in CF_LIB_RULES.
1947 dnl This uses the configured value to make the lists SRC_SUBDIRS and
1948 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
1949 AC_DEFUN([CF_SRC_MODULES],
1951 AC_MSG_CHECKING(for src modules)
1953 # dependencies and linker-arguments for test-programs
1954 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
1955 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
1957 # dependencies and linker-arguments for utility-programs
1958 PROG_ARGS="$TEST_ARGS"
1963 if test -f $srcdir/$cf_dir/modules; then
1965 # We may/may not have tack in the distribution, though the
1967 if test $cf_dir = tack ; then
1968 if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
1973 if test -z "$cf_cv_src_modules"; then
1974 cf_cv_src_modules=$cf_dir
1976 cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
1979 # Make the ncurses_cfg.h file record the library interface files as
1980 # well. These are header files that are the same name as their
1981 # directory. Ncurses is the only library that does not follow
1983 if test $cf_dir = tack ; then
1985 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
1986 CF_UPPER(cf_have_include,$cf_dir)
1987 AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
1988 AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
1989 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
1990 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
1994 AC_MSG_RESULT($cf_cv_src_modules)
1995 TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS"
1999 PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS"
2002 SRC_SUBDIRS="man include"
2003 for cf_dir in $cf_cv_src_modules
2005 SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
2007 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
2008 test $cf_with_cxx_binding != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
2011 if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
2012 SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
2013 ADA_SUBDIRS="gen src samples"
2017 for cf_dir in $SRC_SUBDIRS
2019 SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
2022 if test -n "$ADA_SUBDIRS"; then
2023 for cf_dir in $ADA_SUBDIRS
2025 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
2027 AC_SUBST(ADA_SUBDIRS)
2030 dnl ---------------------------------------------------------------------------
2031 dnl Check for -lstdc++, which is GNU's standard C++ library.
2032 AC_DEFUN([CF_STDCPP_LIBRARY],
2034 if test -n "$GXX" ; then
2035 case $cf_cv_system_name in #(vi
2037 cf_stdcpp_libname=stdcpp
2040 cf_stdcpp_libname=stdc++
2043 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
2045 LIBS="$LIBS -l$cf_stdcpp_libname"
2047 #include <strstream.h>],[
2049 strstreambuf foo(buf, sizeof(buf))
2051 [cf_cv_libstdcpp=yes],
2052 [cf_cv_libstdcpp=no])
2055 test $cf_cv_libstdcpp = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
2058 dnl ---------------------------------------------------------------------------
2059 dnl Remove "-g" option from the compiler options
2060 AC_DEFUN([CF_STRIP_G_OPT],
2061 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
2062 dnl ---------------------------------------------------------------------------
2063 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction. We'll only
2064 dnl do this if we've found the sigaction function.
2066 dnl If needed, define SVR4_ACTION.
2067 AC_DEFUN([CF_STRUCT_SIGACTION],[
2068 if test $ac_cv_func_sigaction = yes; then
2069 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
2071 #include <sys/types.h>
2072 #include <signal.h>],
2073 [struct sigaction act],
2077 #define _POSIX_SOURCE
2078 #include <sys/types.h>
2079 #include <signal.h>],
2080 [struct sigaction act],
2082 AC_DEFINE(SVR4_ACTION)],
2083 [sigact_bad=unknown])])
2084 AC_MSG_RESULT($sigact_bad)
2087 dnl ---------------------------------------------------------------------------
2088 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
2089 dnl If so, define SVR4_TERMIO
2090 AC_DEFUN([CF_STRUCT_TERMIOS],[
2091 if test $ac_cv_header_termios_h = yes ; then
2094 termios_bad=dunno ;;
2095 *) termios_bad=maybe ;;
2097 if test $termios_bad = maybe ; then
2098 AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
2099 AC_TRY_COMPILE([#include <termios.h>],
2100 [struct termios foo; int x = foo.c_iflag],
2103 #define _POSIX_SOURCE
2104 #include <termios.h>],
2105 [struct termios foo; int x = foo.c_iflag],
2106 termios_bad=unknown,
2107 termios_bad=yes AC_DEFINE(SVR4_TERMIO))
2109 AC_MSG_RESULT($termios_bad)
2113 dnl ---------------------------------------------------------------------------
2114 dnl Shorthand macro for substituting things that the user may override
2115 dnl with an environment variable.
2117 dnl $1 = long/descriptive name
2118 dnl $2 = environment variable
2119 dnl $3 = default value
2120 AC_DEFUN([CF_SUBST],
2121 [AC_CACHE_VAL(cf_cv_subst_$2,[
2122 AC_MSG_CHECKING(for $1 (symbol $2))
2123 test -z "[$]$2" && $2=$3
2124 AC_MSG_RESULT([$]$2)
2126 cf_cv_subst_$2=[$]$2])
2127 $2=${cf_cv_subst_$2}
2129 dnl ---------------------------------------------------------------------------
2130 dnl Get the version-number for use in shared-library naming, etc.
2131 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
2134 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2135 NCURSES_MINOR="`egrep '^NCURSES_MINOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2136 NCURSES_PATCH="`egrep '^NCURSES_PATCH[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2138 cf_cv_abi_version=${NCURSES_MAJOR}
2139 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
2140 dnl Show the computed version, for logging
2141 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`))
2142 dnl We need these values in the generated headers
2143 AC_SUBST(NCURSES_MAJOR)
2144 AC_SUBST(NCURSES_MINOR)
2145 AC_SUBST(NCURSES_PATCH)
2146 dnl We need these values in the generated makefiles
2147 AC_SUBST(cf_cv_rel_version)
2148 AC_SUBST(cf_cv_abi_version)
2149 AC_SUBST(cf_cv_cc_bool_type)
2150 AC_SUBST(cf_cv_builtin_bool)
2151 AC_SUBST(cf_cv_type_of_bool)dnl
2153 dnl ---------------------------------------------------------------------------
2154 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2155 dnl older SCO configurations.
2156 AC_DEFUN([CF_SYS_TIME_SELECT],
2158 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2159 AC_CACHE_VAL(cf_cv_sys_time_select,[
2161 #include <sys/types.h>
2163 #include <sys/time.h>
2165 #if HAVE_SYS_SELECT_H
2166 #include <sys/select.h>
2168 ],[],[cf_cv_sys_time_select=yes],
2169 [cf_cv_sys_time_select=no])
2171 AC_MSG_RESULT($cf_cv_sys_time_select)
2172 test $cf_cv_sys_time_select = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2174 dnl ---------------------------------------------------------------------------
2175 dnl Determine the type we should use for chtype (and attr_t, which is treated
2176 dnl as the same thing). We want around 32 bits, so on most machines want a
2177 dnl long, but on newer 64-bit machines, probably want an int. If we're using
2178 dnl wide characters, we have to have a type compatible with that, as well.
2179 AC_DEFUN([CF_TYPEOF_CHTYPE],
2181 AC_REQUIRE([CF_UNSIGNED_LITERALS])
2182 AC_MSG_CHECKING([for type of chtype])
2183 AC_CACHE_VAL(cf_cv_typeof_chtype,[
2185 #if USE_WIDEC_SUPPORT
2186 #include <stddef.h> /* we want wchar_t */
2187 #define WANT_BITS 39
2189 #define WANT_BITS 31
2194 FILE *fp = fopen("cf_test.out", "w");
2196 char *result = "long";
2197 #if USE_WIDEC_SUPPORT
2199 * If wchar_t is smaller than a long, it must be an int or a
2200 * short. We prefer not to use a short anyway.
2202 if (sizeof(unsigned long) > sizeof(wchar_t))
2205 if (sizeof(unsigned long) > sizeof(unsigned int)) {
2208 for (n = 0; n < WANT_BITS; n++) {
2209 unsigned int y = (x >> n);
2210 if (y != 1 || x == 0) {
2216 * If x is nonzero, an int is big enough for the bits
2219 result = (x != 0) ? "int" : "long";
2227 [cf_cv_typeof_chtype=`cat cf_test.out`],
2228 [cf_cv_typeof_chtype=long],
2229 [cf_cv_typeof_chtype=long])
2232 AC_MSG_RESULT($cf_cv_typeof_chtype)
2234 AC_SUBST(cf_cv_typeof_chtype)
2235 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
2238 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
2239 test "$cf_cv_typeof_chtype" = long && cf_cv_1UL="${cf_cv_1UL}L"
2243 dnl ---------------------------------------------------------------------------
2245 AC_DEFUN([CF_TYPE_SIGACTION],
2247 AC_MSG_CHECKING([for type sigaction_t])
2248 AC_CACHE_VAL(cf_cv_type_sigaction,[
2250 #include <signal.h>],
2252 [cf_cv_type_sigaction=yes],
2253 [cf_cv_type_sigaction=no])])
2254 AC_MSG_RESULT($cf_cv_type_sigaction)
2255 test $cf_cv_type_sigaction = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
2257 dnl ---------------------------------------------------------------------------
2258 dnl Test if the compiler supports 'U' and 'L' suffixes. Only old compilers
2259 dnl won't, but they're still there.
2260 AC_DEFUN([CF_UNSIGNED_LITERALS],
2262 AC_MSG_CHECKING([if unsigned literals are legal])
2263 AC_CACHE_VAL(cf_cv_unsigned_literals,[
2264 AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
2265 [cf_cv_unsigned_literals=yes],
2266 [cf_cv_unsigned_literals=no])
2268 AC_MSG_RESULT($cf_cv_unsigned_literals)
2270 dnl ---------------------------------------------------------------------------
2271 dnl Make an uppercase version of a variable
2272 dnl $1=uppercase($2)
2273 AC_DEFUN([CF_UPPER],
2276 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
2279 dnl ---------------------------------------------------------------------------
2280 dnl Compute the shift-mask that we'll use for wide-character indices. We use
2281 dnl all but the index portion of chtype for storing attributes.
2282 AC_DEFUN([CF_WIDEC_SHIFT],
2284 AC_REQUIRE([CF_TYPEOF_CHTYPE])
2285 AC_MSG_CHECKING([for number of bits in chtype])
2286 AC_CACHE_VAL(cf_cv_shift_limit,[
2291 FILE *fp = fopen("cf_test.out", "w");
2294 unsigned TYPEOF_CHTYPE x = 1L;
2295 for (n = 0; ; n++) {
2296 unsigned long y = (x >> n);
2297 if (y != 1 || x == 0)
2301 fprintf(fp, "%d", n);
2307 [cf_cv_shift_limit=`cat cf_test.out`],
2308 [cf_cv_shift_limit=32],
2309 [cf_cv_shift_limit=32])
2312 AC_MSG_RESULT($cf_cv_shift_limit)
2313 AC_SUBST(cf_cv_shift_limit)
2315 AC_MSG_CHECKING([for width of character-index])
2316 AC_CACHE_VAL(cf_cv_widec_shift,[
2317 if test ".$with_widec" = ".yes" ; then
2319 if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
2321 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
2323 cf_cv_widec_shift=16
2329 AC_MSG_RESULT($cf_cv_widec_shift)
2330 AC_SUBST(cf_cv_widec_shift)
2332 dnl ---------------------------------------------------------------------------
2333 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2334 dnl defaulting to yes/no.
2336 dnl $1 = option name
2338 dnl $3 = environment variable to set
2339 dnl $4 = default value, shown in the help-message, must be a constant
2340 dnl $5 = default value, if it's an expression & cannot be in the help-message
2342 AC_DEFUN([CF_WITH_PATH],
2343 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2344 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2345 CF_PATH_SYNTAX(withval)
2349 dnl ---------------------------------------------------------------------------
2350 dnl Process an option specifying a list of colon-separated paths.
2352 dnl $1 = option name
2354 dnl $3 = environment variable to set
2355 dnl $4 = default value, shown in the help-message, must be a constant
2356 dnl $5 = default value, if it's an expression & cannot be in the help-message
2358 AC_DEFUN([CF_WITH_PATHLIST],[
2359 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2360 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2362 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2364 for cf_src_path in $withval
2366 CF_PATH_SYNTAX(cf_src_path)
2367 test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
2368 cf_dst_path="${cf_dst_path}${cf_src_path}"
2372 eval $3="$cf_dst_path"