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 1996,1997,1998,1999,2000
31 dnl $Id: aclocal.m4,v 1.235 2000/10/08 01:01:40 tom Exp $
32 dnl Macros used in NCURSES auto-configuration script.
34 dnl See http://dickey.his.com/autoconf/ for additional information.
36 dnl ---------------------------------------------------------------------------
37 dnl ---------------------------------------------------------------------------
38 dnl Construct the list of include-options for the C programs in the Ada95
40 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
42 ACPPFLAGS="$ACPPFLAGS -I. -I../../include"
43 if test "$srcdir" != "."; then
44 ACPPFLAGS="$ACPPFLAGS -I\$(srcdir)/../../include"
46 if test "$GCC" != yes; then
47 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
48 elif test "$includedir" != "/usr/include"; then
49 if test "$includedir" = '${prefix}/include' ; then
50 if test $prefix != /usr ; then
51 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
54 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
59 dnl ---------------------------------------------------------------------------
60 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
61 dnl in the sharutils 4.2 distribution.
62 AC_DEFUN([CF_ANSI_CC_CHECK],
64 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
65 AC_CACHE_VAL(cf_cv_ansi_cc,[
67 cf_save_CFLAGS="$CFLAGS"
68 # Don't try gcc -ansi; that turns off useful extensions and
69 # breaks some systems' header files.
71 # Ultrix and OSF/1 -std1
72 # HP-UX -Aa -D_HPUX_SOURCE
74 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
75 for cf_arg in "-DCC_HAS_PROTOS" \
80 "-Aa -D_HPUX_SOURCE" \
83 CFLAGS="$cf_save_CFLAGS $cf_arg"
87 #if !defined(__STDC__) || (__STDC__ != 1)
92 int test (int i, double x);
93 struct s1 {int (*f) (int a);};
94 struct s2 {int (*f) (double a);};],
95 [cf_cv_ansi_cc="$cf_arg"; break])
97 CFLAGS="$cf_save_CFLAGS"
99 AC_MSG_RESULT($cf_cv_ansi_cc)
101 if test "$cf_cv_ansi_cc" != "no"; then
102 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
103 CFLAGS="$CFLAGS $cf_cv_ansi_cc"
105 AC_DEFINE(CC_HAS_PROTOS)
109 dnl ---------------------------------------------------------------------------
110 dnl For programs that must use an ANSI compiler, obtain compiler options that
111 dnl will make it recognize prototypes. We'll do preprocessor checks in other
112 dnl macros, since tools such as unproto can fake prototypes, but only part of
113 dnl the preprocessor.
114 AC_DEFUN([CF_ANSI_CC_REQD],
115 [AC_REQUIRE([CF_ANSI_CC_CHECK])
116 if test "$cf_cv_ansi_cc" = "no"; then
118 [Your compiler does not appear to recognize prototypes.
119 You have the following choices:
120 a. adjust your compiler options
121 b. get an up-to-date compiler
122 c. use a wrapper such as unproto])
125 dnl ---------------------------------------------------------------------------
126 dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some
127 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
128 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
130 dnl Treat the configuration-variable specially here, since we're directly
131 dnl substituting its value (i.e., 1/0).
132 AC_DEFUN([CF_BOOL_DECL],
134 AC_MSG_CHECKING([for builtin bool type])
135 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
138 #include <sys/types.h>
140 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
141 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
143 if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
144 then AC_MSG_RESULT(yes)
145 else AC_MSG_RESULT(no)
148 dnl ---------------------------------------------------------------------------
149 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
150 dnl Don't bother looking for bool.h, since it's been deprecated.
151 AC_DEFUN([CF_BOOL_SIZE],
153 AC_MSG_CHECKING([for size of bool])
154 AC_CACHE_VAL(cf_cv_type_of_bool,[
159 #ifdef HAVE_GXX_BUILTIN_H
160 #include <g++/builtin.h>
161 #elif HAVE_GPP_BUILTIN_H
162 #include <gpp/builtin.h>
168 FILE *fp = fopen("cf_test.out", "w");
172 fputs("unsigned ", fp);
173 if (sizeof(x) == sizeof(int)) fputs("int", fp);
174 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
175 else if (sizeof(x) == sizeof(short))fputs("short",fp);
176 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
182 [cf_cv_type_of_bool=`cat cf_test.out`],
183 [cf_cv_type_of_bool=unknown],
184 [cf_cv_type_of_bool=unknown])
187 AC_MSG_RESULT($cf_cv_type_of_bool)
188 if test "$cf_cv_type_of_bool" = unknown ; then
189 AC_MSG_WARN(Assuming unsigned for type of bool)
190 cf_cv_type_of_bool=unsigned
193 dnl ---------------------------------------------------------------------------
194 dnl Determine the default configuration into which we'll install ncurses. This
195 dnl can be overridden by the user's command-line options. There's two items to
197 dnl 1. the prefix (e.g., /usr)
198 dnl 2. the header files (e.g., /usr/include/ncurses)
199 dnl We'll look for a previous installation of ncurses and use the same defaults.
201 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
202 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
203 dnl programs from a vendor's.
204 AC_DEFUN([CF_CFG_DEFAULTS],
206 AC_MSG_CHECKING(for prefix)
207 if test "x$prefix" = "xNONE" ; then
208 case "$cf_cv_system_name" in
209 # non-vendor systems don't have a conflict
210 openbsd*|netbsd*|freebsd*|linux*)
213 *) prefix=$ac_default_prefix
217 AC_MSG_RESULT($prefix)
219 if test "x$prefix" = "xNONE" ; then
220 AC_MSG_CHECKING(for default include-directory)
221 test -n "$verbose" && echo 1>&AC_FD_MSG
224 $includedir/ncurses \
226 $prefix/include/ncurses \
228 /usr/local/include/ncurses \
232 cf_dir=`eval echo $cf_symbol`
233 if test -f $cf_dir/curses.h ; then
234 if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
235 includedir="$cf_symbol"
236 test -n "$verbose" && echo $ac_n " found " 1>&AC_FD_MSG
240 test -n "$verbose" && echo " tested $cf_dir" 1>&AC_FD_MSG
242 AC_MSG_RESULT($includedir)
245 dnl ---------------------------------------------------------------------------
246 dnl Check if the terminal-capability database functions are available. If not,
247 dnl ncurses has a much-reduced version.
248 AC_DEFUN([CF_CGETENT],[
249 AC_MSG_CHECKING(for terminal-capability database functions)
250 AC_CACHE_VAL(cf_cv_cgetent,[
252 #include <stdlib.h>],[
255 char *db_array = temp;
256 cgetent(&buf, /* int *, */ &db_array, "vt100");
257 cgetcap(buf, "tc", '=');
258 cgetmatch(buf, "tc");
263 AC_MSG_RESULT($cf_cv_cgetent)
264 test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT)
266 dnl ---------------------------------------------------------------------------
267 dnl Check if we're accidentally using a cache from a different machine.
268 dnl Derive the system name, as a check for reusing the autoconf cache.
270 dnl If we've packaged config.guess and config.sub, run that (since it does a
271 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
272 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
273 dnl which is useful in cross-compiles.
274 AC_DEFUN([CF_CHECK_CACHE],
276 if test -f $srcdir/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 Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
298 dnl the 'errno' variable. Define a DECL_xxx symbol if we must declare it
301 dnl (I would use AC_CACHE_CHECK here, but it will not work when called in a
302 dnl loop from CF_SYS_ERRLIST).
304 dnl $1 = the name to check
305 AC_DEFUN([CF_CHECK_ERRNO],
307 AC_MSG_CHECKING(if external $1 is declared)
308 AC_CACHE_VAL(cf_cv_dcl_$1,[
314 #include <sys/types.h>
315 #include <errno.h> ],
316 [long x = (long) $1],
317 [eval 'cf_cv_dcl_'$1'=yes'],
318 [eval 'cf_cv_dcl_'$1'=no'])
321 eval 'cf_result=$cf_cv_dcl_'$1
322 AC_MSG_RESULT($cf_result)
324 if test "$cf_result" = no ; then
325 eval 'cf_result=DECL_'$1
326 CF_UPPER(cf_result,$cf_result)
327 AC_DEFINE_UNQUOTED($cf_result)
330 # It's possible (for near-UNIX clones) that the data doesn't exist
331 CF_CHECK_EXTERN_DATA($1,int)
333 dnl ---------------------------------------------------------------------------
334 dnl Check for existence of external data in the current set of libraries. If
335 dnl we can modify it, it's real enough.
336 dnl $1 = the name to check
338 AC_DEFUN([CF_CHECK_EXTERN_DATA],
340 AC_MSG_CHECKING(if external $1 exists)
341 AC_CACHE_VAL(cf_cv_have_$1,[
347 [eval 'cf_cv_have_'$1'=yes'],
348 [eval 'cf_cv_have_'$1'=no'])])
350 eval 'cf_result=$cf_cv_have_'$1
351 AC_MSG_RESULT($cf_result)
353 if test "$cf_result" = yes ; then
354 eval 'cf_result=HAVE_'$1
355 CF_UPPER(cf_result,$cf_result)
356 AC_DEFINE_UNQUOTED($cf_result)
360 dnl ---------------------------------------------------------------------------
361 dnl Check if the C++ compiler accepts duplicate parameter initialization. This
362 dnl is a late feature for the standard and is not in some recent compilers
364 AC_DEFUN([CF_CPP_PARAM_INIT],
366 if test "$CXX" = yes ; then
367 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
378 TEST::TEST(int x = 1) // some compilers do not like second initializer
384 [cf_cv_cpp_param_init=yes],
385 [cf_cv_cpp_param_init=no],
386 [cf_cv_cpp_param_init=unknown])
389 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
391 dnl ---------------------------------------------------------------------------
392 AC_DEFUN([CF_DIRS_TO_MAKE],
395 for cf_item in $cf_list_models
397 CF_OBJ_SUBDIR($cf_item,cf_subdir)
398 DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
400 for cf_dir in $DIRS_TO_MAKE
402 test ! -d $cf_dir && mkdir $cf_dir
404 AC_SUBST(DIRS_TO_MAKE)
406 dnl ---------------------------------------------------------------------------
407 dnl Check if 'errno' is declared in <errno.h>
410 CF_CHECK_ERRNO(errno)
412 dnl ---------------------------------------------------------------------------
413 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
414 dnl math.h and builtin.h, only for ncurses
415 AC_DEFUN([CF_ETIP_DEFINES],
417 AC_MSG_CHECKING(for special defines needed for etip.h)
418 cf_save_CXXFLAGS="$CXXFLAGS"
420 for cf_math in "" MATH_H
422 for cf_excp in "" MATH_EXCEPTION
424 CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu"
425 test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
426 test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
430 test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
431 test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
432 cf_result="$cf_math $cf_excp"
437 AC_MSG_RESULT($cf_result)
438 CXXFLAGS="$cf_save_CXXFLAGS"
440 dnl ---------------------------------------------------------------------------
441 dnl Check for memmove, or a bcopy that can handle overlapping copy. If neither
442 dnl is found, add our own version of memmove to the list of objects.
443 AC_DEFUN([CF_FUNC_MEMMOVE],
445 AC_CHECK_FUNC(memmove,,[
446 AC_CHECK_FUNC(bcopy,[
447 AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
450 static char data[] = "abcdefghijklmnopqrstuwwxyz";
452 bcopy(data, temp, sizeof(data));
453 bcopy(temp+10, temp, 15);
454 bcopy(temp+5, temp+15, 10);
455 exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
458 [cf_cv_good_bcopy=yes],
459 [cf_cv_good_bcopy=no],
460 [cf_cv_good_bcopy=unknown])
462 ],[cf_cv_good_bcopy=no])
463 if test "$cf_cv_good_bcopy" = yes ; then
464 AC_DEFINE(USE_OK_BCOPY)
466 AC_DEFINE(USE_MY_MEMMOVE)
469 dnl ---------------------------------------------------------------------------
470 dnl See if the poll function really works. Some platforms have poll(), but
471 dnl it does not work for terminals or files.
472 AC_DEFUN([CF_FUNC_POLL],[
473 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
479 #include <sys/poll.h>
486 myfds.events = POLLIN;
488 ret = poll(&myfds, 1, 100);
491 [cf_cv_working_poll=yes],
492 [cf_cv_working_poll=no],
493 [cf_cv_working_poll=unknown])])
494 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
496 dnl ---------------------------------------------------------------------------
497 dnl Some old/broken variations define tcgetattr() only as a macro in
499 AC_DEFUN([CF_FUNC_TERMIOS],[
500 AC_REQUIRE([CF_STRUCT_TERMIOS])
501 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
503 #include <sys/types.h>
507 #ifdef HAVE_TERMIOS_H
509 #define TTY struct termios
513 #define TTY struct termio
518 tcgetattr(1, &foo);],
519 [cf_cv_have_tcgetattr=yes],
520 [cf_cv_have_tcgetattr=no])])
521 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR)
523 dnl ---------------------------------------------------------------------------
524 dnl Test for availability of useful gcc __attribute__ directives to quiet
525 dnl compiler warnings. Though useful, not all are supported -- and contrary
526 dnl to documentation, unrecognized directives cause older compilers to barf.
527 AC_DEFUN([CF_GCC_ATTRIBUTES],
531 cat > conftest.i <<EOF
539 #define GCC_NORETURN /* nothing */
542 #define GCC_UNUSED /* nothing */
547 AC_CHECKING([for $CC __attribute__ directives])
549 cat > conftest.$ac_ext <<EOF
550 #line __oline__ "configure"
551 #include "confdefs.h"
552 #include "conftest.h"
553 #include "conftest.i"
555 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
557 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
560 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
562 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
564 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
565 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
566 extern void foo(void) GCC_NORETURN;
567 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
570 for cf_attribute in scanf printf unused noreturn
572 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
573 cf_directive="__attribute__(($cf_attribute))"
574 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
575 case $cf_attribute in
577 cat >conftest.h <<EOF
578 #define GCC_$CF_ATTRIBUTE 1
582 cat >conftest.h <<EOF
583 #define GCC_$CF_ATTRIBUTE $cf_directive
587 if AC_TRY_EVAL(ac_compile); then
588 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
589 cat conftest.h >>confdefs.h
591 # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
595 fgrep define conftest.i >>confdefs.h
600 dnl ---------------------------------------------------------------------------
601 dnl Check if the compiler supports useful warning options. There's a few that
602 dnl we don't use, simply because they're too noisy:
604 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
605 dnl -Wredundant-decls (system headers make this too noisy)
606 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
607 dnl -Wwrite-strings (too noisy, but should review occasionally)
610 AC_DEFUN([CF_GCC_WARNINGS],
615 cat > conftest.$ac_ext <<EOF
616 #line __oline__ "configure"
617 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
620 AC_CHECKING([for $CC warning options])
621 cf_save_CFLAGS="$CFLAGS"
622 EXTRA_CFLAGS="-W -Wall"
624 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
630 Wmissing-declarations \
631 Wmissing-prototypes \
635 Wstrict-prototypes $cf_warn_CONST
637 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
638 if AC_TRY_EVAL(ac_compile); then
639 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
640 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
641 test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
645 CFLAGS="$cf_save_CFLAGS"
647 AC_SUBST(EXTRA_CFLAGS)
649 dnl ---------------------------------------------------------------------------
650 dnl Verify that a test program compiles and runs with GNAT
651 dnl $cf_ada_make is set to the program that compiles/links
652 AC_DEFUN([CF_GNAT_TRY_RUN],
655 cat >>conftest.ads <<CF_EOF
658 cat >>conftest.adb <<CF_EOF
661 if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
662 if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
672 dnl ---------------------------------------------------------------------------
673 dnl Verify Version of GNAT.
674 AC_DEFUN([CF_GNAT_VERSION],
676 changequote(<<, >>)dnl
677 cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
678 sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'`
679 case $cf_cv_gnat_version in
680 3.1[1-9]*|3.[2-9]*|[4-9].*)
681 cf_cv_prog_gnat_correct=yes
683 *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
684 cf_cv_prog_gnat_correct=no
687 case $cf_cv_gnat_version in
689 cf_compile_generics=generics
690 cf_generic_objects="\$(GENOBJS)"
692 *) cf_compile_generics=
698 dnl ---------------------------------------------------------------------------
699 dnl If we're trying to use g++, test if libg++ is installed (a rather common
700 dnl problem :-). If we have the compiler but no library, we'll be able to
701 dnl configure, but won't be able to build the c++ demo program.
702 AC_DEFUN([CF_GPP_LIBRARY],
704 cf_cxx_library=unknown
705 case $cf_cv_system_name in #(vi
713 if test "$ac_cv_prog_gxx" = yes; then
714 AC_MSG_CHECKING([for lib$cf_gpp_libname])
716 LIBS="$LIBS -l$cf_gpp_libname"
718 #include <$cf_gpp_libname/builtin.h>
720 [two_arg_error_handler_t foo2 = lib_error_handler],
722 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
723 if test "$cf_gpp_libname" = cpp ; then
724 AC_DEFINE(HAVE_GPP_BUILTIN_H)
726 AC_DEFINE(HAVE_GXX_BUILTIN_H)
731 [two_arg_error_handler_t foo2 = lib_error_handler],
733 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
734 AC_DEFINE(HAVE_BUILTIN_H)],
735 [cf_cxx_library=no])])
737 AC_MSG_RESULT($cf_cxx_library)
740 dnl ---------------------------------------------------------------------------
741 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
742 AC_DEFUN([CF_HELP_MESSAGE],
743 [AC_DIVERT_HELP([$1])dnl
745 dnl ---------------------------------------------------------------------------
746 dnl Construct the list of include-options according to whether we're building
747 dnl in the source directory or using '--srcdir=DIR' option. If we're building
748 dnl with gcc, don't append the includedir if it happens to be /usr/include,
749 dnl since that usually breaks gcc's shadow-includes.
750 AC_DEFUN([CF_INCLUDE_DIRS],
752 CPPFLAGS="$CPPFLAGS -I. -I../include"
753 if test "$srcdir" != "."; then
754 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
756 if test "$GCC" != yes; then
757 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
758 elif test "$includedir" != "/usr/include"; then
759 if test "$includedir" = '${prefix}/include' ; then
760 if test $prefix != /usr ; then
761 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
764 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
769 dnl ---------------------------------------------------------------------------
770 dnl Check if we have either a function or macro for 'isascii()'.
771 AC_DEFUN([CF_ISASCII],
773 AC_MSG_CHECKING(for isascii)
774 AC_CACHE_VAL(cf_cv_have_isascii,[
775 AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
776 [cf_cv_have_isascii=yes],
777 [cf_cv_have_isascii=no])
779 AC_MSG_RESULT($cf_cv_have_isascii)
780 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII)
782 dnl ---------------------------------------------------------------------------
783 dnl Compute the library-prefix for the given host system
784 dnl $1 = variable to set
785 AC_DEFUN([CF_LIB_PREFIX],
787 case $cf_cv_system_name in
788 os2) LIB_PREFIX='' ;;
789 *) LIB_PREFIX='lib' ;;
791 ifelse($1,,,[$1=$LIB_PREFIX])
794 dnl ---------------------------------------------------------------------------
795 dnl Append definitions and rules for the given models to the subdirectory
796 dnl Makefiles, and the recursion rule for the top-level Makefile. If the
797 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
798 dnl the corresponding makefile to list the models that we'll generate.
800 dnl For shared libraries, make a list of symbolic links to construct when
801 dnl generating each library. The convention used for Linux is the simplest
804 dnl lib<name>.so.<major> ->
805 dnl lib<name>.so.<maj>.<minor>
806 AC_DEFUN([CF_LIB_RULES],
808 CF_LIB_PREFIX(cf_prefix)
809 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
810 for cf_dir in $SRC_SUBDIRS
812 if test -f $srcdir/$cf_dir/modules; then
815 for cf_item in $CF_LIST_MODELS
817 CF_LIB_SUFFIX($cf_item,cf_suffix)
818 if test $cf_item = shared ; then
819 if test "$cf_cv_do_symlinks" = yes ; then
820 case "$cf_cv_shlib_version" in #(vi
821 rel) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;; #(vi
822 abi) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
826 cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
829 if test $cf_dir = ncurses ; then
830 case "$LIB_SUBSETS" in #(vi
834 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g`
835 cf_libs_to_make="$cf_item $cf_libs_to_make"
840 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \
841 $cf_dir/Makefile >$cf_dir/Makefile.out
842 mv $cf_dir/Makefile.out $cf_dir/Makefile
844 $AWK -f $srcdir/mk-0th.awk \
846 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
848 for cf_item in $CF_LIST_MODELS
850 echo 'Appending rules for '$cf_item' model ('$cf_dir')'
851 CF_UPPER(CF_ITEM,$cf_item)
852 CF_LIB_SUFFIX($cf_item,cf_suffix)
853 CF_OBJ_SUBDIR($cf_item,cf_subdir)
855 # These dependencies really are for development, not
856 # builds, but they are useful in porting, too.
857 cf_depend="../include/ncurses_cfg.h"
858 if test "$srcdir" = "."; then
861 cf_reldir="\$(srcdir)"
864 if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
865 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
866 elif test -f $srcdir/$cf_dir/curses.priv.h; then
867 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
870 for cf_subset in $LIB_SUBSETS
872 $AWK -f $srcdir/mk-1st.awk \
874 traces=$LIB_TRACING \
880 ShlibVer=$cf_cv_shlib_version \
881 DoLinks=$cf_cv_do_symlinks \
882 rmSoLocs=$cf_cv_rm_so_locs \
883 ldconfig="$LDCONFIG" \
884 overwrite=$WITH_OVERWRITE \
885 depend="$cf_depend" \
887 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
888 test $cf_dir = ncurses && WITH_OVERWRITE=no
889 $AWK -f $srcdir/mk-2nd.awk \
891 traces=$LIB_TRACING \
897 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
902 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
905 for cf_dir in $SRC_SUBDIRS
907 if test -f $cf_dir/Makefile ; then
910 echo 'libs \' >> Makefile
911 echo 'install.libs \' >> Makefile
912 echo 'uninstall.libs ::' >> Makefile
913 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
918 if test -f $srcdir/$cf_dir/modules; then
920 if test -f $srcdir/$cf_dir/headers; then
921 cat >> Makefile <<CF_EOF
923 uninstall.includes \\
926 if test "$cf_dir" != "c++" ; then
927 echo 'lint \' >> Makefile
929 cat >> Makefile <<CF_EOF
936 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
938 elif test -f $srcdir/$cf_dir/headers; then
939 cat >> Makefile <<CF_EOF
945 uninstall.includes ::
946 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
951 cat >> Makefile <<CF_EOF
955 cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
959 cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
962 rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
963 rm -f headers.sh headers.sed
964 rm -rf \$(DIRS_TO_MAKE)
967 # Special case: tack's manpage lives in its own directory.
968 if test -d tack ; then
969 if test -f $srcdir/$tack.h; then
970 cat >> Makefile <<CF_EOF
974 cd tack && \$(MAKE) \$(CF_MFLAGS) \[$]@
979 dnl If we're installing into a subdirectory of /usr/include, etc., we should
980 dnl prepend the subdirectory's name to the "#include" paths. It won't hurt
981 dnl anything, and will make it more standardized. It's awkward to decide this
982 dnl at configuration because of quoting, so we'll simply make all headers
983 dnl installed via a script that can do the right thing.
985 rm -f headers.sed headers.sh
987 dnl ( generating this script makes the makefiles a little tidier :-)
988 echo creating headers.sh
989 cat >headers.sh <<CF_EOF
991 # This shell script is generated by the 'configure' script. It is invoked in a
992 # subdirectory of the build tree. It generates a sed-script in the parent
993 # directory that is used to adjust includes for header files that reside in a
994 # subdirectory of /usr/include, etc.
996 while test \[$]# != 3
998 PRG="\$PRG \[$]1"; shift
1003 echo installing \$SRC in \$DST
1006 TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
1007 TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
1008 END=\`basename \$DST\`
1009 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
1011 NAME=\`basename \$i\`
1012 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
1015 sed -f \$TMPSED \$SRC > \$TMPSRC
1016 eval \$PRG \$TMPSRC \$DST/\`basename \$SRC\`
1017 rm -f \$TMPSRC \$TMPSED
1020 eval \$PRG \$SRC \$DST
1025 chmod 0755 headers.sh
1027 for cf_dir in $SRC_SUBDIRS
1029 if test -f $srcdir/$cf_dir/headers; then
1030 cat >>$cf_dir/Makefile <<CF_EOF
1031 \$(DESTDIR)\$(includedir) :
1032 \$(srcdir)/../mkinstalldirs \[$]@
1036 install.includes :: \$(AUTO_SRC) \$(DESTDIR)\$(includedir) \\
1039 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1041 test -n "$j" && echo " $j \\" >>$cf_dir/Makefile
1044 echo " $j" >>$cf_dir/Makefile
1045 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1047 echo " @ (cd \$(DESTDIR)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(DESTDIR)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
1048 test $i = curses.h && echo " @ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
1051 cat >>$cf_dir/Makefile <<CF_EOF
1055 uninstall.includes ::
1057 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1060 echo " -@ (cd \$(DESTDIR)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
1061 test $i = curses.h && echo " -@ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
1067 dnl ---------------------------------------------------------------------------
1068 dnl Compute the library file-suffix from the given model name
1070 dnl $2 = variable to set
1071 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1072 AC_DEFUN([CF_LIB_SUFFIX],
1074 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1078 profile) $2='_p.a' ;;
1080 case $cf_cv_system_name in
1085 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1087 dnl ---------------------------------------------------------------------------
1088 dnl Compute the string to append to -library from the given model name
1090 dnl $2 = variable to set
1091 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1092 AC_DEFUN([CF_LIB_TYPE],
1100 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1102 dnl ---------------------------------------------------------------------------
1103 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1104 dnl only data (i.e., no functions), for example NeXT. On those systems we'll
1105 dnl have to provide wrappers for global tables to ensure they're linked
1107 AC_DEFUN([CF_LINK_DATAONLY],
1109 AC_MSG_CHECKING([if data-only library module links])
1110 AC_CACHE_VAL(cf_cv_link_dataonly,[
1113 cat >conftest.$ac_ext <<EOF
1114 #line __oline__ "configure"
1115 int testdata[3] = { 123, 456, 789 };
1118 if AC_TRY_EVAL(ac_compile) ; then
1119 mv conftest.o data.o && \
1120 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
1122 rm -f conftest.$ac_ext data.o
1124 cat >conftest.$ac_ext <<EOF
1125 #line __oline__ "configure"
1129 exit(1); /* I'm told this linker is broken */
1131 extern int testdata[3];
1132 return testdata[0] == 123
1133 && testdata[1] == 456
1134 && testdata[2] == 789;
1139 if AC_TRY_EVAL(ac_compile); then
1140 mv conftest.o func.o && \
1141 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
1143 rm -f conftest.$ac_ext func.o
1144 ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
1146 LIBS="conftest.a $LIBS"
1150 extern int testfunc();
1154 [cf_cv_link_dataonly=yes],
1155 [cf_cv_link_dataonly=no],
1156 [cf_cv_link_dataonly=unknown])
1159 AC_MSG_RESULT($cf_cv_link_dataonly)
1160 test "$cf_cv_link_dataonly" = no && AC_DEFINE(BROKEN_LINKER)
1162 dnl ---------------------------------------------------------------------------
1163 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1164 dnl A few non-Unix systems implement symlink, but not link.
1165 dnl A few non-systems implement neither (or have nonfunctional versions).
1166 AC_DEFUN([CF_LINK_FUNCS],
1172 if test "$ac_cv_prog_cc_cross" = yes ; then
1177 AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1179 for cf_func in link symlink ; do
1181 #include <sys/types.h>
1182 #include <sys/stat.h>
1183 #ifdef HAVE_UNISTD_H
1189 char *src = "config.log";
1190 char *dst = "conftest.chk";
1195 fail = ($cf_func("config.log", "conftest.chk") < 0)
1196 || (stat(dst, &dst_sb) < 0)
1197 || (dst_sb.st_mtime != src_sb.st_mtime);
1206 cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1207 eval 'ac_cv_func_'$cf_func'=yes'],[
1208 eval 'ac_cv_func_'$cf_func'=no'],[
1209 eval 'ac_cv_func_'$cf_func'=error'])
1211 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1213 test "$ac_cv_func_link" = yes && AC_DEFINE(HAVE_LINK)
1214 test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
1217 dnl ---------------------------------------------------------------------------
1218 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1219 dnl options to lower-levels. It's very useful for "make -n" -- if we have it.
1220 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1221 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1222 AC_DEFUN([CF_MAKEFLAGS],
1224 AC_MSG_CHECKING([for makeflags variable])
1225 AC_CACHE_VAL(cf_cv_makeflags,[
1227 for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1229 cat >cf_makeflags.tmp <<CF_EOF
1231 @ echo '.$cf_option'
1233 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1234 case "$cf_result" in
1236 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1237 case "$cf_result" in
1238 .*CC=*) cf_cv_makeflags=
1240 *) cf_cv_makeflags=$cf_option
1245 *) echo no match "$cf_result"
1249 rm -f cf_makeflags.tmp])
1250 AC_MSG_RESULT($cf_cv_makeflags)
1251 AC_SUBST(cf_cv_makeflags)
1253 dnl ---------------------------------------------------------------------------
1254 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
1255 dnl a monocase filesystem.
1256 AC_DEFUN([CF_MAKE_TAGS],[
1257 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1258 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
1260 if test "$cf_cv_mixedcase" = yes ; then
1261 AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
1266 if test "$MAKE_UPPER_TAGS" = yes ; then
1271 AC_SUBST(MAKE_UPPER_TAGS)
1273 if test "$MAKE_LOWER_TAGS" = yes ; then
1278 AC_SUBST(MAKE_LOWER_TAGS)
1280 dnl ---------------------------------------------------------------------------
1281 dnl Option to allow user to override automatic configuration of manpage format.
1282 dnl There are several special cases.
1283 AC_DEFUN([CF_MANPAGE_FORMAT],
1284 [ AC_MSG_CHECKING(format of man-pages)
1286 AC_ARG_WITH(manpage-format,
1287 [ --with-manpage-format specify manpage-format: gzip/compress/BSDI/normal and
1288 optionally formatted, e.g., gzip,formatted],
1289 [cf_manpage_form=$withval],
1290 [cf_manpage_form=unknown])
1292 case ".$cf_manpage_form" in
1293 .gzip|.compress|.BSDI|.normal|.formatted) # (vi
1296 if test -z "$MANPATH" ; then
1297 MANPATH="/usr/man:/usr/share/man"
1299 # look for the 'date' man-page (it's most likely to be installed!)
1300 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1301 cf_manpage_form=unknown
1302 for cf_dir in $MANPATH; do
1303 test -z "$cf_dir" && cf_dir=/usr/man
1304 changequote({{,}})dnl
1305 for cf_name in $cf_dir/*/date.[01]* $cf_dir/*/date
1308 cf_test=`echo $cf_name | sed -e 's/*//'`
1309 if test "x$cf_test" = "x$cf_name" ; then
1311 *.gz) cf_manpage_form=gzip;;
1312 *.Z) cf_manpage_form=compress;;
1313 *.0) cf_manpage_form=BSDI,formatted;;
1314 *) cf_manpage_form=normal;;
1319 if test "$cf_manpage_form" != "unknown" ; then
1326 AC_MSG_WARN(Unexpected manpage-format)
1330 AC_MSG_RESULT($cf_manpage_form)
1332 dnl ---------------------------------------------------------------------------
1333 dnl The Debian people have their own naming convention for manpages. This
1334 dnl option lets us override the name of the file containing renaming, or
1335 dnl disable it altogether.
1336 AC_DEFUN([CF_MANPAGE_RENAMES],
1338 AC_MSG_CHECKING(for manpage renaming)
1340 AC_ARG_WITH(manpage-renames,
1341 [ --with-manpage-renames specify manpage-renaming],
1342 [cf_manpage_renames=$withval],
1343 [cf_manpage_renames=yes])
1345 case ".$cf_manpage_renames" in #(vi
1349 # Debian 'man' program?
1350 if test -f /etc/debian_version ; then
1351 cf_manpage_renames=`cd $srcdir && pwd`/man/man_db.renames
1353 cf_manpage_renames=no
1358 if test "$cf_manpage_renames" != no ; then
1359 if test ! -f $cf_manpage_renames ; then
1360 AC_MSG_ERROR(not a filename: $cf_manpage_renames)
1363 test ! -d man && mkdir man
1365 # Construct a sed-script to perform renaming within man-pages
1366 if test -n "$cf_manpage_renames" ; then
1367 test ! -d man && mkdir man
1368 $srcdir/man/make_sed.sh $cf_manpage_renames >man/edit_man.sed
1372 AC_MSG_RESULT($cf_manpage_renames)
1374 dnl ---------------------------------------------------------------------------
1375 dnl Some people expect each tool to make all aliases for manpages in the
1376 dnl man-directory. This accommodates the older, less-capable implementations
1377 dnl of 'man', and is optional.
1378 AC_DEFUN([CF_MANPAGE_SYMLINKS],
1380 AC_MSG_CHECKING(for manpage symlinks)
1382 AC_ARG_WITH(manpage-symlinks,
1383 [ --with-manpage-symlinks specify manpage-symlinks],
1384 [cf_manpage_symlinks=$withval],
1385 [cf_manpage_symlinks=yes])
1387 AC_MSG_RESULT($cf_manpage_symlinks)
1389 dnl ---------------------------------------------------------------------------
1390 dnl Try to determine if the man-pages on the system are compressed, and if
1391 dnl so, what format is used. Use this information to construct a script that
1392 dnl will install man-pages.
1393 AC_DEFUN([CF_MAN_PAGES],
1395 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
1400 if test "$prefix" = "NONE" ; then
1401 cf_prefix="$ac_default_prefix"
1406 case "$cf_manpage_form" in # (vi
1408 cf_subdir='$mandir/cat'
1412 cf_subdir='$mandir/man'
1417 test ! -d man && mkdir man
1418 cat >man/edit_man.sh <<CF_EOF
1419 changequote({{,}})dnl
1421 # this script is generated by the configure-script
1424 TERMINFO="$TERMINFO"
1425 MKDIRS="`cd $srcdir && pwd`/mkinstalldirs"
1427 INSTALL_DATA="$INSTALL_DATA"
1428 transform="$program_transform_name"
1430 TMP=\${TMPDIR-/tmp}/man\$\$
1431 trap "rm -f \$TMP" 0 1 2 5 15
1442 for i in \{{$}}* ; do
1444 *.orig|*.rej) ;; #(vi
1446 section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
1447 if test \$verb = installing ; then
1448 if test ! -d $cf_subdir\${section} ; then
1449 \$MKDIRS $cf_subdir\$section
1453 source=\`basename \$i\`
1455 test ! -f \$inalias && inalias="\$srcdir/\$inalias"
1456 if test ! -f \$inalias ; then
1457 echo .. skipped \$source
1461 if test "$cf_manpage_symlinks" = yes ; then
1462 cat >>man/edit_man.sh <<CF_EOF
1463 aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\`
1466 if test "$cf_manpage_renames" = no ; then
1467 cat >>man/edit_man.sh <<CF_EOF
1468 # perform program transformations for section 1 man pages
1469 if test \$section = 1 ; then
1470 target=$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\`
1472 target=$cf_subdir\${section}/\$source
1475 # replace variables in man page
1480 cat >>man/edit_man.sh <<CF_EOF
1481 prog_$cf_name=\`echo $cf_name|sed "\${transform}"\`
1485 cat >>man/edit_man.sh <<CF_EOF
1486 sed -e "s,@DATADIR@,\$datadir," \\
1487 -e "s,@TERMINFO@,\$TERMINFO," \\
1492 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1493 cat >>man/edit_man.sh <<CF_EOF
1494 -e "s,@$cf_NAME@,\$prog_$cf_name," \\
1498 cat >>man/edit_man.sh <<CF_EOF
1502 cat >>man/edit_man.sh <<CF_EOF
1503 target=\`grep "^\$source" $cf_manpage_renames | $AWK '{print \{{$}}2}'\`
1504 if test -z "\$target" ; then
1505 echo '? missing rename for '\$source
1508 target="$cf_subdir\$section/\$target"
1509 test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP
1512 if test $cf_format = yes ; then
1513 cat >>man/edit_man.sh <<CF_EOF
1514 nroff -man \$TMP >\$TMP.out
1518 case "$cf_manpage_form" in #(vi
1520 cat >>man/edit_man.sh <<CF_EOF
1521 if test \$verb = installing ; then
1522 if ( compress -f \$TMP )
1531 cat >>man/edit_man.sh <<CF_EOF
1532 if test \$verb = installing ; then
1533 if ( gzip -f \$TMP )
1538 target="\$target.gz"
1542 cat >>man/edit_man.sh <<CF_EOF
1543 # BSDI installs only .0 suffixes in the cat directories
1544 target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`"
1548 cat >>man/edit_man.sh <<CF_EOF
1549 echo \$verb \$target
1550 suffix=\`basename \$target | sed -e 's/^[^.]*//'\`
1551 if test \$verb = installing ; then
1552 \$INSTALL_DATA \$TMP \$target
1553 test -n "\$aliases" && (
1554 cd $cf_subdir\${section} && (
1555 target=\`basename \$target\`
1556 for cf_alias in \$aliases
1558 if test \$section = 1 ; then
1559 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
1562 if test -f \$cf_alias\${suffix} ; then
1563 if ( cmp -s \$target \$cf_alias\${suffix} )
1567 echo .. \$verb alias \$cf_alias\${suffix}
1568 rm -f \$cf_alias\${suffix}
1569 $LN_S \$target \$cf_alias\${suffix}
1572 echo .. \$verb alias \$cf_alias\${suffix}
1573 rm -f \$cf_alias\${suffix}
1574 $LN_S \$target \$cf_alias\${suffix}
1581 test -n "\$aliases" && (
1582 cd $cf_subdir\${section} && (
1583 for cf_alias in \$aliases
1585 if test \$section = 1 ; then
1586 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
1589 echo .. \$verb alias \$cf_alias\${suffix}
1590 rm -f \$cf_alias\${suffix}
1601 chmod 755 man/edit_man.sh
1604 dnl ---------------------------------------------------------------------------
1605 dnl Checks for libraries. At least one UNIX system, Apple Macintosh
1606 dnl Rhapsody 5.5, does not have -lm. We cannot use the simpler
1607 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1608 AC_DEFUN([CF_MATH_LIB],
1610 AC_CACHE_CHECK(if -lm needed for math functions,
1616 [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
1617 [cf_cv_need_libm=no],
1618 [cf_cv_need_libm=yes])])
1619 if test "$cf_cv_need_libm" = yes
1626 dnl ---------------------------------------------------------------------------
1627 dnl Check if the file-system supports mixed-case filenames. If we're able to
1628 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1629 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1631 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1632 rm -f conftest CONFTEST
1634 if test -f CONFTEST ; then
1639 rm -f conftest CONFTEST
1641 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1643 dnl ---------------------------------------------------------------------------
1644 dnl Compute the object-directory name from the given model name
1645 AC_DEFUN([CF_OBJ_SUBDIR],
1648 normal) $2='objects' ;;
1649 debug) $2='obj_g' ;;
1650 profile) $2='obj_p' ;;
1651 shared) $2='obj_s' ;;
1654 dnl ---------------------------------------------------------------------------
1655 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1656 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1657 dnl result begins with 'NONE'. This is necessary to workaround autoconf's
1658 dnl delayed evaluation of those symbols.
1659 AC_DEFUN([CF_PATH_SYNTAX],[
1660 case ".[$]$1" in #(vi
1663 .[a-zA-Z]:[\\/]*) #(vi OS/2 EMX
1665 .\[$]{*prefix}*) #(vi
1667 case ".[$]$1" in #(vi
1669 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1674 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1677 AC_ERROR(expected a pathname)
1681 dnl ---------------------------------------------------------------------------
1682 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1683 AC_DEFUN([CF_PROG_EXT],
1685 AC_REQUIRE([CF_CHECK_CACHE])
1687 case $cf_cv_system_name in
1689 # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@
1690 CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__"
1691 CXXFLAGS="$CXXFLAGS -Zmt -D__ST_MT_ERRNO__"
1692 LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"`
1701 dnl ---------------------------------------------------------------------------
1702 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
1703 dnl misc/tabset install won't work properly. Usually this happens only when
1704 dnl using the fallback mkinstalldirs script
1705 AC_DEFUN([CF_PROG_INSTALL],
1711 changequote({{,}})dnl
1712 cf_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
1713 test -z "$cf_dir" && cf_dir=.
1715 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
1719 dnl ---------------------------------------------------------------------------
1720 dnl Attempt to determine if we've got one of the flavors of regular-expression
1721 dnl code that we can support.
1722 AC_DEFUN([CF_REGEX],
1724 AC_MSG_CHECKING([for regular-expression headers])
1725 AC_CACHE_VAL(cf_cv_regex,[
1726 AC_TRY_LINK([#include <sys/types.h>
1727 #include <regex.h>],[
1729 int x = regcomp(p, "", 0);
1730 int y = regexec(p, "", 0, 0, 0);
1732 ],[cf_cv_regex="regex.h"],[
1733 AC_TRY_LINK([#include <regexp.h>],[
1734 char *p = compile("", "", "", 0);
1735 int x = step("", "");
1736 ],[cf_cv_regex="regexp.h"],[
1737 cf_save_LIBS="$LIBS"
1739 AC_TRY_LINK([#include <regexpr.h>],[
1740 char *p = compile("", "", "");
1741 int x = step("", "");
1742 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
1744 AC_MSG_RESULT($cf_cv_regex)
1745 case $cf_cv_regex in
1746 regex.h) AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
1747 regexp.h) AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
1748 regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1751 dnl ---------------------------------------------------------------------------
1752 dnl Attempt to determine the appropriate CC/LD options for creating a shared
1755 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
1756 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
1757 dnl We avoid compiling-in a ../lib path for the shared library since that can
1758 dnl lead to unexpected results at runtime.
1759 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
1760 dnl are compiled in ../../lib
1762 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
1763 dnl to install symbolic links to the rel/abi versions of shared libraries.
1765 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
1766 dnl version when making symbolic links.
1768 dnl Some loaders leave 'so_locations' lying around. It's nice to clean up.
1769 AC_DEFUN([CF_SHARED_OPTS],
1771 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1775 INSTALL_LIB="-m 644"
1777 cf_cv_do_symlinks=no
1779 AC_MSG_CHECKING(if release/abi version should be used for shared libs)
1780 AC_ARG_WITH(shlib-version,
1781 [ --with-shlib-version=X Specify rel or abi version for shared libs],
1782 [test -z "$withval" && withval=auto
1783 case $withval in #(vi
1785 cf_cv_shlib_version=auto
1787 rel|abi|auto|no) #(vi
1788 cf_cv_shlib_version=$withval
1791 AC_ERROR([option value must be one of: rel, abi, auto or no])
1794 ],[cf_cv_shlib_version=auto])
1795 AC_MSG_RESULT($cf_cv_shlib_version)
1799 # Some less-capable ports of gcc support only -fpic
1801 if test "$GCC" = yes
1803 AC_MSG_CHECKING(which $CC option to use)
1804 cf_save_CFLAGS="$CFLAGS"
1805 for CC_SHARED_OPTS in -fPIC -fpic ''
1807 CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
1808 AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
1810 AC_MSG_RESULT($CC_SHARED_OPTS)
1811 CFLAGS="$cf_save_CFLAGS"
1814 case $cf_cv_system_name in
1816 MK_SHARED_LIB='$(CC) -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
1819 # (tested with gcc 2.7.2 -- I don't have c89)
1820 if test "$GCC" = yes; then
1821 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1824 LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1826 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]'
1827 # HP-UX shared libraries must be executable, and should be
1828 # readonly to exploit a quirk in the memory manager.
1829 INSTALL_LIB="-m 555"
1832 if test "$cf_cv_ld_rpath" = yes ; then
1833 cf_ld_rpath_opt="-Wl,-rpath,"
1834 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
1836 # tested with IRIX 5.2 and 'cc'.
1837 if test "$GCC" != yes; then
1838 CC_SHARED_OPTS='-KPIC'
1840 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
1841 cf_cv_rm_so_locs=yes
1844 if test "$DFT_LWR_MODEL" = "shared" ; then
1845 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
1846 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
1848 if test "$cf_cv_ld_rpath" = yes ; then
1849 cf_ld_rpath_opt="-Wl,-rpath,"
1850 EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
1852 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
1853 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION),-stats,-lc -o $[@]'
1856 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
1857 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
1860 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
1861 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1862 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
1865 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
1866 test "$cf_cv_ld_rpath" = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1867 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
1868 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
1869 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
1870 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
1871 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
1872 if test "$cf_cv_shlib_version" = auto; then
1873 if test ! -f /usr/libexec/ld.elf_so; then
1874 cf_cv_shlib_version=rel
1878 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1882 # tested with OSF/1 V3.2 and 'cc'
1883 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
1884 # link with shared libs).
1885 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`'
1888 MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
1891 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
1892 if test "$DFT_LWR_MODEL" = "shared" ; then
1893 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
1894 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
1896 if test "$cf_cv_ld_rpath" = yes ; then
1897 cf_ld_rpath_opt="-rpath"
1898 # EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
1900 cf_cv_rm_so_locs=yes
1902 sco3.2v5*) # (also uw2* and UW7) hops 13-Apr-98
1903 # tested with osr5.0.5
1904 if test "$ac_cv_prog_gcc" != yes; then
1905 CC_SHARED_OPTS='-belf -KPIC'
1907 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o [$]@'
1908 if test "$cf_cv_ld_rpath" = yes ; then
1909 # only way is to set LD_RUN_PATH but no switch for it
1912 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
1913 LINK_PROGS='LD_RUN_PATH=$(libdir)'
1914 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
1917 # tested with SunOS 4.1.1 and gcc 2.7.0
1918 if test "$ac_cv_prog_gcc" != yes; then
1919 CC_SHARED_OPTS='-KPIC'
1921 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]'
1922 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
1925 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
1926 if test "$ac_cv_prog_gcc" != yes; then
1927 CC_SHARED_OPTS='-KPIC'
1929 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
1930 if test "$DFT_LWR_MODEL" = "shared" ; then
1931 LOCAL_LDFLAGS="-R `pwd`/lib:\$(libdir)"
1932 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
1934 if test "$cf_cv_ld_rpath" = yes ; then
1935 cf_ld_rpath_opt="-R"
1936 EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
1938 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
1941 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
1942 if test "$ac_cv_prog_gcc" != yes; then
1943 CC_SHARED_OPTS='-KPIC'
1945 MK_SHARED_LIB='$(LD) -d y -G -o [$]@'
1948 CC_SHARED_OPTS='unknown'
1949 MK_SHARED_LIB='echo unknown'
1953 # This works if the last tokens in $MK_SHARED_LIB are the -o target.
1954 case "$cf_cv_shlib_version" in #(vi
1956 case "$MK_SHARED_LIB" in #(vi
1958 test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
1961 AC_MSG_WARN(ignored --with-shlib-version)
1967 if test -n "$cf_ld_rpath_opt" ; then
1968 AC_MSG_CHECKING(if we need a space after rpath option)
1969 cf_save_LIBS="$LIBS"
1970 LIBS="$LIBS ${cf_ld_rpath_opt}$libdir"
1971 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1972 LIBS="$cf_save_LIBS"
1973 AC_MSG_RESULT($cf_rpath_space)
1974 test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
1975 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
1978 AC_SUBST(CC_SHARED_OPTS)
1979 AC_SUBST(LD_SHARED_OPTS)
1980 AC_SUBST(MK_SHARED_LIB)
1981 AC_SUBST(LINK_PROGS)
1982 AC_SUBST(LINK_TESTS)
1983 AC_SUBST(EXTRA_LDFLAGS)
1984 AC_SUBST(LOCAL_LDFLAGS)
1985 AC_SUBST(LOCAL_LDFLAGS2)
1986 AC_SUBST(INSTALL_LIB)
1988 dnl ---------------------------------------------------------------------------
1989 dnl Check for definitions & structures needed for window size-changing
1990 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
1991 AC_DEFUN([CF_SIZECHANGE],
1993 AC_REQUIRE([CF_STRUCT_TERMIOS])
1994 AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
1995 cf_cv_sizechange=unknown
1996 cf_save_CFLAGS="$CFLAGS"
1998 for cf_opts in "" "NEED_PTEM_H"
2001 CFLAGS="$cf_save_CFLAGS"
2002 test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts"
2003 AC_TRY_COMPILE([#include <sys/types.h>
2004 #ifdef HAVE_TERMIOS_H
2005 #include <termios.h>
2007 #ifdef HAVE_TERMIO_H
2012 /* This is a workaround for SCO: they neglected to define struct winsize in
2013 * termios.h -- it's only in termio.h and ptem.h
2015 #include <sys/stream.h>
2016 #include <sys/ptem.h>
2018 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
2019 #include <sys/ioctl.h>
2023 struct ttysize win; /* FIXME: what system is this? */
2024 int y = win.ts_lines;
2025 int x = win.ts_cols;
2032 no TIOCGSIZE or TIOCGWINSZ
2033 #endif /* TIOCGWINSZ */
2034 #endif /* TIOCGSIZE */
2036 [cf_cv_sizechange=yes],
2037 [cf_cv_sizechange=no])
2039 CFLAGS="$cf_save_CFLAGS"
2040 if test "$cf_cv_sizechange" = yes ; then
2041 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
2042 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
2047 if test "$cf_cv_sizechange" != no ; then
2048 AC_DEFINE(HAVE_SIZECHANGE)
2049 case $cf_cv_sizechange in #(vi
2051 AC_DEFINE_UNQUOTED($cf_cv_sizechange )
2056 dnl ---------------------------------------------------------------------------
2057 dnl For each parameter, test if the source-directory exists, and if it contains
2058 dnl a 'modules' file. If so, add to the list $cf_cv_src_modules which we'll
2059 dnl use in CF_LIB_RULES.
2061 dnl This uses the configured value to make the lists SRC_SUBDIRS and
2062 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
2063 AC_DEFUN([CF_SRC_MODULES],
2065 AC_MSG_CHECKING(for src modules)
2067 # dependencies and linker-arguments for test-programs
2068 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
2069 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
2071 # dependencies and linker-arguments for utility-programs
2072 PROG_ARGS="$TEST_ARGS"
2077 if test -f $srcdir/$cf_dir/modules; then
2079 # We may/may not have tack in the distribution, though the
2081 if test $cf_dir = tack ; then
2082 if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
2087 if test -z "$cf_cv_src_modules"; then
2088 cf_cv_src_modules=$cf_dir
2090 cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
2093 # Make the ncurses_cfg.h file record the library interface files as
2094 # well. These are header files that are the same name as their
2095 # directory. Ncurses is the only library that does not follow
2097 if test $cf_dir = tack ; then
2099 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
2100 CF_UPPER(cf_have_include,$cf_dir)
2101 AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
2102 AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
2103 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
2104 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
2108 AC_MSG_RESULT($cf_cv_src_modules)
2109 TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS"
2113 PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS"
2116 SRC_SUBDIRS="man include"
2117 for cf_dir in $cf_cv_src_modules
2119 SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
2121 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
2122 test "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
2125 if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
2126 SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
2127 ADA_SUBDIRS="gen src samples"
2131 for cf_dir in $SRC_SUBDIRS
2133 SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
2136 if test -n "$ADA_SUBDIRS"; then
2137 for cf_dir in $ADA_SUBDIRS
2139 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
2141 AC_SUBST(ADA_SUBDIRS)
2144 dnl ---------------------------------------------------------------------------
2145 dnl Check for -lstdc++, which is GNU's standard C++ library.
2146 AC_DEFUN([CF_STDCPP_LIBRARY],
2148 if test -n "$GXX" ; then
2149 case $cf_cv_system_name in #(vi
2151 cf_stdcpp_libname=stdcpp
2154 cf_stdcpp_libname=stdc++
2157 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
2159 LIBS="$LIBS -l$cf_stdcpp_libname"
2161 #include <strstream.h>],[
2163 strstreambuf foo(buf, sizeof(buf))
2165 [cf_cv_libstdcpp=yes],
2166 [cf_cv_libstdcpp=no])
2169 test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
2172 dnl ---------------------------------------------------------------------------
2173 dnl Remove "-g" option from the compiler options
2174 AC_DEFUN([CF_STRIP_G_OPT],
2175 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
2176 dnl ---------------------------------------------------------------------------
2177 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction. We'll only
2178 dnl do this if we've found the sigaction function.
2180 dnl If needed, define SVR4_ACTION.
2181 AC_DEFUN([CF_STRUCT_SIGACTION],[
2182 if test "$ac_cv_func_sigaction" = yes; then
2183 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
2185 #include <sys/types.h>
2186 #include <signal.h>],
2187 [struct sigaction act],
2191 #define _POSIX_SOURCE
2192 #include <sys/types.h>
2193 #include <signal.h>],
2194 [struct sigaction act],
2196 AC_DEFINE(SVR4_ACTION)],
2197 [sigact_bad=unknown])])
2198 AC_MSG_RESULT($sigact_bad)
2201 dnl ---------------------------------------------------------------------------
2202 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
2203 dnl If so, define SVR4_TERMIO
2204 AC_DEFUN([CF_STRUCT_TERMIOS],[
2210 if test "$ISC" = yes ; then
2211 AC_CHECK_HEADERS( sys/termio.h )
2213 if test "$ac_cv_header_termios_h" = yes ; then
2216 termios_bad=dunno ;;
2217 *) termios_bad=maybe ;;
2219 if test "$termios_bad" = maybe ; then
2220 AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
2221 AC_TRY_COMPILE([#include <termios.h>],
2222 [struct termios foo; int x = foo.c_iflag],
2225 #define _POSIX_SOURCE
2226 #include <termios.h>],
2227 [struct termios foo; int x = foo.c_iflag],
2228 termios_bad=unknown,
2229 termios_bad=yes AC_DEFINE(SVR4_TERMIO))
2231 AC_MSG_RESULT($termios_bad)
2235 dnl ---------------------------------------------------------------------------
2236 dnl Shorthand macro for substituting things that the user may override
2237 dnl with an environment variable.
2239 dnl $1 = long/descriptive name
2240 dnl $2 = environment variable
2241 dnl $3 = default value
2242 AC_DEFUN([CF_SUBST],
2243 [AC_CACHE_VAL(cf_cv_subst_$2,[
2244 AC_MSG_CHECKING(for $1 (symbol $2))
2245 test -z "[$]$2" && $2=$3
2246 AC_MSG_RESULT([$]$2)
2248 cf_cv_subst_$2=[$]$2])
2249 $2=${cf_cv_subst_$2}
2251 dnl ---------------------------------------------------------------------------
2252 dnl Get the version-number for use in shared-library naming, etc.
2253 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
2256 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2257 NCURSES_MINOR="`egrep '^NCURSES_MINOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2258 NCURSES_PATCH="`egrep '^NCURSES_PATCH[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2260 cf_cv_abi_version=${NCURSES_MAJOR}
2261 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
2262 dnl Show the computed version, for logging
2263 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`))
2264 dnl We need these values in the generated headers
2265 AC_SUBST(NCURSES_MAJOR)
2266 AC_SUBST(NCURSES_MINOR)
2267 AC_SUBST(NCURSES_PATCH)
2268 dnl We need these values in the generated makefiles
2269 AC_SUBST(cf_cv_rel_version)
2270 AC_SUBST(cf_cv_abi_version)
2271 AC_SUBST(cf_cv_cc_bool_type)
2272 AC_SUBST(cf_cv_builtin_bool)
2273 AC_SUBST(cf_cv_type_of_bool)dnl
2275 dnl ---------------------------------------------------------------------------
2276 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2277 dnl older SCO configurations.
2278 AC_DEFUN([CF_SYS_TIME_SELECT],
2280 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2281 AC_CACHE_VAL(cf_cv_sys_time_select,[
2283 #include <sys/types.h>
2284 #ifdef HAVE_SYS_TIME_H
2285 #include <sys/time.h>
2287 #ifdef HAVE_SYS_SELECT_H
2288 #include <sys/select.h>
2290 ],[],[cf_cv_sys_time_select=yes],
2291 [cf_cv_sys_time_select=no])
2293 AC_MSG_RESULT($cf_cv_sys_time_select)
2294 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2296 dnl ---------------------------------------------------------------------------
2297 dnl Determine the type we should use for chtype (and attr_t, which is treated
2298 dnl as the same thing). We want around 32 bits, so on most machines want a
2299 dnl long, but on newer 64-bit machines, probably want an int. If we're using
2300 dnl wide characters, we have to have a type compatible with that, as well.
2301 AC_DEFUN([CF_TYPEOF_CHTYPE],
2303 AC_REQUIRE([CF_UNSIGNED_LITERALS])
2304 AC_MSG_CHECKING([for type of chtype])
2305 AC_CACHE_VAL(cf_cv_typeof_chtype,[
2307 #ifdef USE_WIDEC_SUPPORT
2308 #include <stddef.h> /* we want wchar_t */
2309 #define WANT_BITS 39
2311 #define WANT_BITS 31
2316 FILE *fp = fopen("cf_test.out", "w");
2318 char *result = "long";
2319 #ifdef USE_WIDEC_SUPPORT
2321 * If wchar_t is smaller than a long, it must be an int or a
2322 * short. We prefer not to use a short anyway.
2324 if (sizeof(unsigned long) > sizeof(wchar_t))
2327 if (sizeof(unsigned long) > sizeof(unsigned int)) {
2330 for (n = 0; n < WANT_BITS; n++) {
2331 unsigned int y = (x >> n);
2332 if (y != 1 || x == 0) {
2338 * If x is nonzero, an int is big enough for the bits
2341 result = (x != 0) ? "int" : "long";
2349 [cf_cv_typeof_chtype=`cat cf_test.out`],
2350 [cf_cv_typeof_chtype=long],
2351 [cf_cv_typeof_chtype=long])
2354 AC_MSG_RESULT($cf_cv_typeof_chtype)
2356 AC_SUBST(cf_cv_typeof_chtype)
2357 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
2360 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
2361 test "$cf_cv_typeof_chtype" = long && cf_cv_1UL="${cf_cv_1UL}L"
2365 dnl ---------------------------------------------------------------------------
2367 AC_DEFUN([CF_TYPE_SIGACTION],
2369 AC_MSG_CHECKING([for type sigaction_t])
2370 AC_CACHE_VAL(cf_cv_type_sigaction,[
2372 #include <signal.h>],
2374 [cf_cv_type_sigaction=yes],
2375 [cf_cv_type_sigaction=no])])
2376 AC_MSG_RESULT($cf_cv_type_sigaction)
2377 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
2379 dnl ---------------------------------------------------------------------------
2380 dnl Test if the compiler supports 'U' and 'L' suffixes. Only old compilers
2381 dnl won't, but they're still there.
2382 AC_DEFUN([CF_UNSIGNED_LITERALS],
2384 AC_MSG_CHECKING([if unsigned literals are legal])
2385 AC_CACHE_VAL(cf_cv_unsigned_literals,[
2386 AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
2387 [cf_cv_unsigned_literals=yes],
2388 [cf_cv_unsigned_literals=no])
2390 AC_MSG_RESULT($cf_cv_unsigned_literals)
2392 dnl ---------------------------------------------------------------------------
2393 dnl Make an uppercase version of a variable
2394 dnl $1=uppercase($2)
2395 AC_DEFUN([CF_UPPER],
2398 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2401 dnl ---------------------------------------------------------------------------
2402 dnl Compute the shift-mask that we'll use for wide-character indices. We use
2403 dnl all but the index portion of chtype for storing attributes.
2404 AC_DEFUN([CF_WIDEC_SHIFT],
2406 AC_REQUIRE([CF_TYPEOF_CHTYPE])
2407 AC_MSG_CHECKING([for number of bits in chtype])
2408 AC_CACHE_VAL(cf_cv_shift_limit,[
2413 FILE *fp = fopen("cf_test.out", "w");
2416 unsigned TYPEOF_CHTYPE x = 1L;
2417 for (n = 0; ; n++) {
2418 unsigned long y = (x >> n);
2419 if (y != 1 || x == 0)
2423 fprintf(fp, "%d", n);
2429 [cf_cv_shift_limit=`cat cf_test.out`],
2430 [cf_cv_shift_limit=32],
2431 [cf_cv_shift_limit=32])
2434 AC_MSG_RESULT($cf_cv_shift_limit)
2435 AC_SUBST(cf_cv_shift_limit)
2437 AC_MSG_CHECKING([for width of character-index])
2438 AC_CACHE_VAL(cf_cv_widec_shift,[
2439 if test ".$with_widec" = ".yes" ; then
2441 if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
2443 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
2445 cf_cv_widec_shift=16
2451 AC_MSG_RESULT($cf_cv_widec_shift)
2452 AC_SUBST(cf_cv_widec_shift)
2454 dnl ---------------------------------------------------------------------------
2455 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2456 dnl defaulting to yes/no.
2458 dnl $1 = option name
2460 dnl $3 = environment variable to set
2461 dnl $4 = default value, shown in the help-message, must be a constant
2462 dnl $5 = default value, if it's an expression & cannot be in the help-message
2464 AC_DEFUN([CF_WITH_PATH],
2465 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2466 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2467 CF_PATH_SYNTAX(withval)
2471 dnl ---------------------------------------------------------------------------
2472 dnl Process an option specifying a list of colon-separated paths.
2474 dnl $1 = option name
2476 dnl $3 = environment variable to set
2477 dnl $4 = default value, shown in the help-message, must be a constant
2478 dnl $5 = default value, if it's an expression & cannot be in the help-message
2480 AC_DEFUN([CF_WITH_PATHLIST],[
2481 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2482 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2484 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2486 for cf_src_path in $withval
2488 CF_PATH_SYNTAX(cf_src_path)
2489 test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
2490 cf_dst_path="${cf_dst_path}${cf_src_path}"
2494 eval $3="$cf_dst_path"