1 dnl***************************************************************************
2 dnl Copyright (c) 1998,1999 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.179 1999/10/23 21:49:25 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" \
77 "-Aa -D_HPUX_SOURCE +e" \
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 Test for availability of useful gcc __attribute__ directives to quiet
467 dnl compiler warnings. Though useful, not all are supported -- and contrary
468 dnl to documentation, unrecognized directives cause older compilers to barf.
469 AC_DEFUN([CF_GCC_ATTRIBUTES],
473 cat > conftest.i <<EOF
481 #define GCC_NORETURN /* nothing */
484 #define GCC_UNUSED /* nothing */
489 AC_CHECKING([for $CC __attribute__ directives])
491 cat > conftest.$ac_ext <<EOF
492 #line __oline__ "configure"
493 #include "confdefs.h"
494 #include "conftest.h"
495 #include "conftest.i"
497 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
499 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
502 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
504 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
506 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
507 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
508 extern void foo(void) GCC_NORETURN;
509 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
512 for cf_attribute in scanf printf unused noreturn
514 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
515 cf_directive="__attribute__(($cf_attribute))"
516 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
517 case $cf_attribute in
519 cat >conftest.h <<EOF
520 #define GCC_$CF_ATTRIBUTE 1
524 cat >conftest.h <<EOF
525 #define GCC_$CF_ATTRIBUTE $cf_directive
529 if AC_TRY_EVAL(ac_compile); then
530 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
531 cat conftest.h >>confdefs.h
533 # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
537 fgrep define conftest.i >>confdefs.h
542 dnl ---------------------------------------------------------------------------
543 dnl Check if the compiler supports useful warning options. There's a few that
544 dnl we don't use, simply because they're too noisy:
546 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
547 dnl -Wredundant-decls (system headers make this too noisy)
548 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
549 dnl -Wwrite-strings (too noisy, but should review occasionally)
552 AC_DEFUN([CF_GCC_WARNINGS],
557 cat > conftest.$ac_ext <<EOF
558 #line __oline__ "configure"
559 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
562 AC_CHECKING([for $CC warning options])
563 cf_save_CFLAGS="$CFLAGS"
564 EXTRA_CFLAGS="-W -Wall"
566 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
572 Wmissing-declarations \
573 Wmissing-prototypes \
577 Wstrict-prototypes $cf_warn_CONST
579 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
580 if AC_TRY_EVAL(ac_compile); then
581 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
582 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
583 test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
587 CFLAGS="$cf_save_CFLAGS"
589 AC_SUBST(EXTRA_CFLAGS)
591 dnl ---------------------------------------------------------------------------
592 dnl Verify that a test program compiles and runs with GNAT
593 dnl $cf_ada_make is set to the program that compiles/links
594 AC_DEFUN([CF_GNAT_TRY_RUN],
597 cat >>conftest.ads <<CF_EOF
600 cat >>conftest.adb <<CF_EOF
603 if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
604 if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
614 dnl ---------------------------------------------------------------------------
615 dnl Verify Version of GNAT.
616 AC_DEFUN([CF_GNAT_VERSION],
618 changequote(<<, >>)dnl
619 cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
620 sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'`
621 case $cf_cv_gnat_version in
623 cf_cv_prog_gnat_correct=yes
625 *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.10 or better. Disabling Ada95 binding.
626 cf_cv_prog_gnat_correct=no
629 case $cf_cv_gnat_version in
631 cf_compile_generics=generics
632 cf_generic_objects="\$(GENOBJS)"
634 *) cf_compile_generics=
640 dnl ---------------------------------------------------------------------------
641 dnl If we're trying to use g++, test if libg++ is installed (a rather common
642 dnl problem :-). If we have the compiler but no library, we'll be able to
643 dnl configure, but won't be able to build the c++ demo program.
644 AC_DEFUN([CF_GPP_LIBRARY],
646 cf_cxx_library=unknown
647 case $cf_cv_system_name in #(vi
655 if test $ac_cv_prog_gxx = yes; then
656 AC_MSG_CHECKING([for lib$cf_gpp_libname])
658 LIBS="$LIBS -l$cf_gpp_libname -lm"
660 #include <$cf_gpp_libname/builtin.h>
662 [//float foo=abs(1.0);
663 two_arg_error_handler_t foo2 = lib_error_handler],
665 CXXLIBS="$CXXLIBS -l$cf_gpp_libname -lm"
666 if test "$cf_gpp_libname" = cpp ; then
667 AC_DEFINE(HAVE_GPP_BUILTIN_H)
669 AC_DEFINE(HAVE_GXX_BUILTIN_H)
674 [//float foo=abs(1.0);
675 two_arg_error_handler_t foo2 = lib_error_handler],
677 CXXLIBS="$CXXLIBS -l$cf_gpp_libname -lm"
678 AC_DEFINE(HAVE_BUILTIN_H)],
679 [cf_cxx_library=no])])
681 AC_MSG_RESULT($cf_cxx_library)
684 dnl ---------------------------------------------------------------------------
685 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
686 AC_DEFUN([CF_HELP_MESSAGE],
687 [AC_DIVERT_HELP([$1])dnl
689 dnl ---------------------------------------------------------------------------
690 dnl Construct the list of include-options according to whether we're building
691 dnl in the source directory or using '--srcdir=DIR' option. If we're building
692 dnl with gcc, don't append the includedir if it happens to be /usr/include,
693 dnl since that usually breaks gcc's shadow-includes.
694 AC_DEFUN([CF_INCLUDE_DIRS],
696 CPPFLAGS="$CPPFLAGS -I. -I../include"
697 if test "$srcdir" != "."; then
698 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
700 if test -z "$GCC"; then
701 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
702 elif test "$includedir" != "/usr/include"; then
703 if test "$includedir" = '${prefix}/include' ; then
704 if test $prefix != /usr ; then
705 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
708 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
713 dnl ---------------------------------------------------------------------------
714 dnl Check if we have either a function or macro for 'isascii()'.
715 AC_DEFUN([CF_ISASCII],
717 AC_MSG_CHECKING(for isascii)
718 AC_CACHE_VAL(cf_cv_have_isascii,[
719 AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
720 [cf_cv_have_isascii=yes],
721 [cf_cv_have_isascii=no])
723 AC_MSG_RESULT($cf_cv_have_isascii)
724 test $cf_cv_have_isascii = yes && AC_DEFINE(HAVE_ISASCII)
726 dnl ---------------------------------------------------------------------------
727 dnl Compute the library-prefix for the given host system
728 dnl $1 = variable to set
729 AC_DEFUN([CF_LIB_PREFIX],
731 case $cf_cv_system_name in
738 dnl ---------------------------------------------------------------------------
739 dnl Append definitions and rules for the given models to the subdirectory
740 dnl Makefiles, and the recursion rule for the top-level Makefile. If the
741 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
742 dnl the corresponding makefile to list the models that we'll generate.
744 dnl For shared libraries, make a list of symbolic links to construct when
745 dnl generating each library. The convention used for Linux is the simplest
748 dnl lib<name>.so.<major> ->
749 dnl lib<name>.so.<maj>.<minor>
750 AC_DEFUN([CF_LIB_RULES],
752 CF_LIB_PREFIX(cf_prefix)
753 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
754 for cf_dir in $SRC_SUBDIRS
756 if test -f $srcdir/$cf_dir/modules; then
759 for cf_item in $CF_LIST_MODELS
761 CF_LIB_SUFFIX($cf_item,cf_suffix)
762 cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
765 if test $cf_dir = ncurses ; then
766 case "$LIB_SUBSETS" in
770 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g`
771 cf_libs_to_make="$cf_item $cf_libs_to_make"
776 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \
777 $cf_dir/Makefile >$cf_dir/Makefile.out
778 mv $cf_dir/Makefile.out $cf_dir/Makefile
780 $AWK -f $srcdir/mk-0th.awk \
782 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
784 for cf_item in $CF_LIST_MODELS
786 echo 'Appending rules for '$cf_item' model ('$cf_dir')'
787 CF_UPPER(CF_ITEM,$cf_item)
788 CF_LIB_SUFFIX($cf_item,cf_suffix)
789 CF_OBJ_SUBDIR($cf_item,cf_subdir)
791 # These dependencies really are for development, not
792 # builds, but they are useful in porting, too.
793 cf_depend="../include/ncurses_cfg.h"
794 if test "$srcdir" = "."; then
797 cf_reldir="\$(srcdir)"
800 if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
801 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
802 elif test -f $srcdir/$cf_dir/curses.priv.h; then
803 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
806 for cf_subset in $LIB_SUBSETS
808 $AWK -f $srcdir/mk-1st.awk \
815 DoLinks=$cf_cv_do_symlinks \
816 rmSoLocs=$cf_cv_rm_so_locs \
817 ldconfig="$LDCONFIG" \
818 overwrite=$WITH_OVERWRITE \
819 depend="$cf_depend" \
821 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
822 test $cf_dir = ncurses && WITH_OVERWRITE=no
823 $AWK -f $srcdir/mk-2nd.awk \
830 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
835 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
838 for cf_dir in $SRC_SUBDIRS
840 if test -f $cf_dir/Makefile ; then
843 echo 'install.libs \' >> Makefile
844 echo 'uninstall.libs ::' >> Makefile
845 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
850 if test -f $srcdir/$cf_dir/modules; then
852 if test -f $srcdir/$cf_dir/headers; then
853 cat >> Makefile <<CF_EOF
855 uninstall.includes \\
858 if test "$cf_dir" != "c++" ; then
859 echo 'lint \' >> Makefile
861 cat >> Makefile <<CF_EOF
867 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
869 elif test -f $srcdir/$cf_dir/headers; then
870 cat >> Makefile <<CF_EOF
875 uninstall.includes ::
876 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
881 cat >> Makefile <<CF_EOF
885 cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
889 cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
892 rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
893 rm -f headers.sh headers.sed
894 rm -rf \$(DIRS_TO_MAKE)
897 dnl If we're installing into a subdirectory of /usr/include, etc., we should
898 dnl prepend the subdirectory's name to the "#include" paths. It won't hurt
899 dnl anything, and will make it more standardized. It's awkward to decide this
900 dnl at configuration because of quoting, so we'll simply make all headers
901 dnl installed via a script that can do the right thing.
903 rm -f headers.sed headers.sh
905 dnl ( generating this script makes the makefiles a little tidier :-)
906 echo creating headers.sh
907 cat >headers.sh <<CF_EOF
909 # This shell script is generated by the 'configure' script. It is invoked in a
910 # subdirectory of the build tree. It generates a sed-script in the parent
911 # directory that is used to adjust includes for header files that reside in a
912 # subdirectory of /usr/include, etc.
914 while test \[$]# != 3
916 PRG="\$PRG \[$]1"; shift
921 echo installing \$SRC in \$DST
924 TMP=\${TMPDIR-/tmp}/\`basename \$SRC\`
925 if test ! -f ../headers.sed ; then
926 END=\`basename \$DST\`
927 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
929 NAME=\`basename \$i\`
930 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> ../headers.sed
934 sed -f ../headers.sed \$SRC > \$TMP
935 eval \$PRG \$TMP \$DST
939 eval \$PRG \$SRC \$DST
944 chmod 0755 headers.sh
946 for cf_dir in $SRC_SUBDIRS
948 if test -f $srcdir/$cf_dir/headers; then
949 cat >>$cf_dir/Makefile <<CF_EOF
950 \$(INSTALL_PREFIX)\$(includedir) :
951 \$(srcdir)/../mkinstalldirs \[$]@
955 install.includes :: \$(INSTALL_PREFIX)\$(includedir) \\
958 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
960 test -n "$j" && echo " $j \\" >>$cf_dir/Makefile
963 echo " $j" >>$cf_dir/Makefile
964 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
966 echo " @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(INSTALL_PREFIX)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
967 test $i = curses.h && echo " @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
970 cat >>$cf_dir/Makefile <<CF_EOF
974 uninstall.includes ::
976 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
979 echo " -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
980 test $i = curses.h && echo " -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
986 dnl ---------------------------------------------------------------------------
987 dnl Compute the library-suffix from the given model name
989 dnl $2 = variable to set
990 AC_DEFUN([CF_LIB_SUFFIX],
992 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
996 profile) $2='_p.a' ;;
998 case $cf_cv_system_name in
1000 $2='.so.$(REL_VERSION)' ;;
1002 if test -f /usr/libexec/ld.elf_so; then
1005 $2='.so.$(REL_VERSION)'
1013 dnl ---------------------------------------------------------------------------
1014 dnl Compute the string to append to -library from the given model name
1015 AC_DEFUN([CF_LIB_TYPE],
1024 dnl ---------------------------------------------------------------------------
1025 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1026 dnl only data (i.e., no functions), for example NeXT. On those systems we'll
1027 dnl have to provide wrappers for global tables to ensure they're linked
1029 AC_DEFUN([CF_LINK_DATAONLY],
1031 AC_MSG_CHECKING([if data-only library module links])
1032 AC_CACHE_VAL(cf_cv_link_dataonly,[
1035 cat >conftest.$ac_ext <<EOF
1036 #line __oline__ "configure"
1037 int testdata[3] = { 123, 456, 789 };
1040 if AC_TRY_EVAL(ac_compile) ; then
1041 mv conftest.o data.o && \
1042 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
1044 rm -f conftest.$ac_ext data.o
1046 cat >conftest.$ac_ext <<EOF
1047 #line __oline__ "configure"
1051 exit(1); /* I'm told this linker is broken */
1053 extern int testdata[3];
1054 return testdata[0] == 123
1055 && testdata[1] == 456
1056 && testdata[2] == 789;
1061 if AC_TRY_EVAL(ac_compile); then
1062 mv conftest.o func.o && \
1063 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
1065 rm -f conftest.$ac_ext func.o
1066 ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
1068 LIBS="conftest.a $LIBS"
1072 extern int testfunc();
1076 [cf_cv_link_dataonly=yes],
1077 [cf_cv_link_dataonly=no],
1078 [cf_cv_link_dataonly=unknown])
1081 AC_MSG_RESULT($cf_cv_link_dataonly)
1082 test $cf_cv_link_dataonly = no && AC_DEFINE(BROKEN_LINKER)
1084 dnl ---------------------------------------------------------------------------
1085 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1086 dnl A few non-Unix systems implement symlink, but not link.
1087 dnl A few non-systems implement neither (or have nonfunctional versions).
1088 AC_DEFUN([CF_LINK_FUNCS],
1094 if test "$ac_cv_prog_cc_cross" = yes ; then
1099 AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1101 for cf_func in link symlink ; do
1103 #include <sys/types.h>
1104 #include <sys/stat.h>
1105 #ifdef HAVE_UNISTD_H
1111 char *src = "config.log";
1112 char *dst = "conftest.chk";
1117 fail = ($cf_func("config.log", "conftest.chk") < 0)
1118 || (stat(dst, &dst_sb) < 0)
1119 || (dst_sb.st_mtime != src_sb.st_mtime);
1128 cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1129 eval 'ac_cv_func_'$cf_func'=yes'
1130 CF_UPPER(cf_FUNC,$cf_func)
1131 AC_DEFINE_UNQUOTED(HAVE_$cf_FUNC)],[
1132 eval 'ac_cv_func_'$cf_func'=no'],[
1133 eval 'ac_cv_func_'$cf_func'=error'])
1135 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1139 dnl ---------------------------------------------------------------------------
1140 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1141 dnl options to lower-levels. It's very useful for "make -n" -- if we have it.
1142 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1143 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1144 AC_DEFUN([CF_MAKEFLAGS],
1146 AC_MSG_CHECKING([for makeflags variable])
1147 AC_CACHE_VAL(cf_cv_makeflags,[
1149 for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1151 cat >cf_makeflags.tmp <<CF_EOF
1153 @ echo '.$cf_option'
1155 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1156 case "$cf_result" in
1158 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1159 case "$cf_result" in
1160 .*CC=*) cf_cv_makeflags=
1162 *) cf_cv_makeflags=$cf_option
1167 *) echo no match "$cf_result"
1171 rm -f cf_makeflags.tmp])
1172 AC_MSG_RESULT($cf_cv_makeflags)
1173 AC_SUBST(cf_cv_makeflags)
1175 dnl ---------------------------------------------------------------------------
1176 dnl Option to allow user to override automatic configuration of manpage format.
1177 dnl There are several special cases.
1178 AC_DEFUN([CF_MANPAGE_FORMAT],
1179 [ AC_MSG_CHECKING(format of man-pages)
1181 AC_ARG_WITH(manpage-format,
1182 [ --with-manpage-format specify manpage-format: gzip/compress/BSDI/normal and
1183 optionally formatted, e.g., gzip,formatted],
1184 [cf_manpage_form=$withval],
1185 [cf_manpage_form=unknown])
1187 case ".$cf_manpage_form" in
1188 .gzip|.compress|.BSDI|.normal|.formatted) # (vi
1191 if test -z "$MANPATH" ; then
1192 MANPATH="/usr/man:/usr/share/man"
1194 # look for the 'date' man-page (it's most likely to be installed!)
1195 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1196 cf_manpage_form=unknown
1197 for cf_dir in $MANPATH; do
1198 test -z "$cf_dir" && cf_dir=/usr/man
1199 changequote({{,}})dnl
1200 for cf_name in $cf_dir/*/date.[01]* $cf_dir/*/date
1203 cf_test=`echo $cf_name | sed -e 's/*//'`
1204 if test "x$cf_test" = "x$cf_name" ; then
1206 *.gz) cf_manpage_form=gzip;;
1207 *.Z) cf_manpage_form=compress;;
1208 *.0) cf_manpage_form=BSDI,formatted;;
1209 *) cf_manpage_form=normal;;
1214 if test "$cf_manpage_form" != "unknown" ; then
1221 AC_MSG_WARN(Unexpected manpage-format)
1225 AC_MSG_RESULT($cf_manpage_form)
1227 dnl ---------------------------------------------------------------------------
1228 dnl The Debian people have their own naming convention for manpages. This
1229 dnl option lets us override the name of the file containing renaming, or
1230 dnl disable it altogether.
1231 AC_DEFUN([CF_MANPAGE_RENAMES],
1233 AC_MSG_CHECKING(for manpage renaming)
1235 AC_ARG_WITH(manpage-renames,
1236 [ --with-manpage-renames specify manpage-renaming],
1237 [cf_manpage_renames=$withval],
1238 [cf_manpage_renames=yes])
1240 case ".$cf_manpage_renames" in #(vi
1244 # Debian 'man' program?
1245 if test -f /etc/debian_version ; then
1246 cf_manpage_renames=`cd $srcdir && pwd`/man/man_db.renames
1248 cf_manpage_renames=no
1253 if test "$cf_manpage_renames" != no ; then
1254 if test ! -f $cf_manpage_renames ; then
1255 AC_MSG_ERROR(not a filename: $cf_manpage_renames)
1258 test ! -d man && mkdir man
1260 # Construct a sed-script to perform renaming within man-pages
1261 if test -n "$cf_manpage_renames" ; then
1262 test ! -d man && mkdir man
1263 $srcdir/man/make_sed.sh $cf_manpage_renames >man/edit_man.sed
1267 AC_MSG_RESULT($cf_manpage_renames)
1269 dnl ---------------------------------------------------------------------------
1270 dnl Try to determine if the man-pages on the system are compressed, and if
1271 dnl so, what format is used. Use this information to construct a script that
1272 dnl will install man-pages.
1273 AC_DEFUN([CF_MAN_PAGES],
1275 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
1279 if test "$prefix" = "NONE" ; then
1280 cf_prefix="$ac_default_prefix"
1285 case "$cf_manpage_form" in # (vi
1287 cf_subdir='$mandir/cat'
1291 cf_subdir='$mandir/man'
1296 test ! -d man && mkdir man
1297 cat >man/edit_man.sh <<CF_EOF
1298 changequote({{,}})dnl
1300 # this script is generated by the configure-script
1303 MKDIRS="`cd $srcdir && pwd`/mkinstalldirs"
1305 INSTALL_DATA="$INSTALL_DATA"
1306 TMP=\${TMPDIR-/tmp}/man\$\$
1307 trap "rm -f \$TMP" 0 1 2 5 15
1315 for i in \{{$}}* ; do
1317 *.orig|*.rej) ;; #(vi
1319 section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
1320 if test \$verb = installing ; then
1321 if test ! -d $cf_subdir\${section} ; then
1322 \$MKDIRS $cf_subdir\$section
1325 source=\`basename \$i\`
1327 if test "$cf_manpage_renames" = no ; then
1328 cat >>man/edit_man.sh <<CF_EOF
1329 target=$cf_subdir\${section}/\$source
1330 sed -e "s,@DATADIR@,\$datadir," < \$i >\$TMP
1333 cat >>man/edit_man.sh <<CF_EOF
1334 target=\`grep "^\$source" $cf_manpage_renames | $AWK '{print \{{$}}2}'\`
1335 if test -z "\$target" ; then
1336 echo '? missing rename for '\$source
1339 target="$cf_subdir\$section/\$target"
1340 test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP
1343 if test $cf_format = yes ; then
1344 cat >>man/edit_man.sh <<CF_EOF
1345 nroff -man \$TMP >\$TMP.out
1349 case "$cf_manpage_form" in #(vi
1351 cat >>man/edit_man.sh <<CF_EOF
1352 if test \$verb = installing ; then
1353 if ( compress -f \$TMP )
1362 cat >>man/edit_man.sh <<CF_EOF
1363 if test \$verb = installing ; then
1364 if ( gzip -f \$TMP )
1369 target="\$target.gz"
1373 cat >>man/edit_man.sh <<CF_EOF
1374 # BSDI installs only .0 suffixes in the cat directories
1375 target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`"
1379 cat >>man/edit_man.sh <<CF_EOF
1380 echo \$verb \$target
1381 if test \$verb = installing ; then
1382 \$INSTALL_DATA \$TMP \$target
1391 chmod 755 man/edit_man.sh
1394 dnl ---------------------------------------------------------------------------
1395 dnl Compute the object-directory name from the given model name
1396 AC_DEFUN([CF_OBJ_SUBDIR],
1399 normal) $2='objects' ;;
1400 debug) $2='obj_g' ;;
1401 profile) $2='obj_p' ;;
1402 shared) $2='obj_s' ;;
1405 dnl ---------------------------------------------------------------------------
1406 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1407 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1408 dnl result begins with 'NONE'. This is necessary to workaround autoconf's
1409 dnl delayed evaluation of those symbols.
1410 AC_DEFUN([CF_PATH_SYNTAX],[
1411 case ".[$]$1" in #(vi
1414 .\[$]{*prefix}*) #(vi
1416 case ".[$]$1" in #(vi
1418 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1423 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1426 AC_ERROR(expected a pathname)
1430 dnl ---------------------------------------------------------------------------
1431 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1432 AC_DEFUN([CF_PROG_EXT],
1434 AC_REQUIRE([CF_CHECK_CACHE])
1436 case $cf_cv_system_name in
1438 # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@
1439 CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__"
1440 CXXFLAGS="$CXXFLAGS -Zmt -D__ST_MT_ERRNO__"
1441 LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"`
1450 dnl ---------------------------------------------------------------------------
1451 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
1452 dnl misc/tabset install won't work properly. Usually this happens only when
1453 dnl using the fallback mkinstalldirs script
1454 AC_DEFUN([CF_PROG_INSTALL],
1460 changequote({{,}})dnl
1461 cf_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
1462 test -z "$cf_dir" && cf_dir=.
1464 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
1468 dnl ---------------------------------------------------------------------------
1469 dnl Attempt to determine if we've got one of the flavors of regular-expression
1470 dnl code that we can support.
1471 AC_DEFUN([CF_REGEX],
1473 AC_MSG_CHECKING([for regular-expression headers])
1474 AC_CACHE_VAL(cf_cv_regex,[
1475 AC_TRY_LINK([#include <sys/types.h>
1476 #include <regex.h>],[
1478 int x = regcomp(p, "", 0);
1479 int y = regexec(p, "", 0, 0, 0);
1481 ],[cf_cv_regex="regex.h"],[
1482 AC_TRY_LINK([#include <regexp.h>],[
1483 char *p = compile("", "", "", 0);
1484 int x = step("", "");
1485 ],[cf_cv_regex="regexp.h"],[
1486 cf_save_LIBS="$LIBS"
1488 AC_TRY_LINK([#include <regexpr.h>],[
1489 char *p = compile("", "", "");
1490 int x = step("", "");
1491 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
1493 AC_MSG_RESULT($cf_cv_regex)
1494 case $cf_cv_regex in
1495 regex.h) AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
1496 regexp.h) AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
1497 regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1500 dnl ---------------------------------------------------------------------------
1501 dnl Attempt to determine the appropriate CC/LD options for creating a shared
1504 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
1505 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
1506 dnl We avoid compiling-in a ../lib path for the shared library since that can
1507 dnl lead to unexpected results at runtime.
1508 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
1509 dnl are compiled in ../../lib
1511 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
1512 dnl to install symbolic links to the rel/abi versions of shared libraries.
1514 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
1515 dnl version when making symbolic links.
1517 dnl Some loaders leave 'so_locations' lying around. It's nice to clean up.
1518 AC_DEFUN([CF_SHARED_OPTS],
1520 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1524 INSTALL_LIB="-m 644"
1526 cf_cv_do_symlinks=no
1528 AC_MSG_CHECKING(if release/abi version should be used for shared libs)
1529 AC_ARG_WITH(shlib-version,
1530 [ --with-shlib-version=X Specify rel or abi version for shared libs],
1531 [test -z "$withval" && withval=auto
1532 case $withval in #(vi
1534 cf_cv_shlib_version=auto
1536 rel|abi|auto|no) #(vi
1537 cf_cv_shlib_version=$withval
1540 AC_ERROR([option value must be one of: rel, abi, auto or no])
1543 ],[cf_cv_shlib_version=auto])
1544 AC_MSG_RESULT($cf_cv_shlib_version)
1548 case $cf_cv_system_name in
1550 # (tested with gcc 2.7.2 -- I don't have c89)
1551 if test -n "$GCC"; then
1552 CC_SHARED_OPTS='-fPIC'
1553 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1556 LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1558 MK_SHARED_LIB='$(LD) +b $(libdir) -b +h `basename $[@]` -o $[@]'
1559 # HP-UX shared libraries must be executable, and should be
1560 # readonly to exploit a quirk in the memory manager.
1561 INSTALL_LIB="-m 555"
1562 cf_cv_do_symlinks=reverse
1565 # (tested with gcc 2.7.2 -- I don't have c89)
1566 if test -n "$GCC"; then
1567 CC_SHARED_OPTS='-fPIC'
1568 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1571 LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1573 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]'
1574 # HP-UX shared libraries must be executable, and should be
1575 # readonly to exploit a quirk in the memory manager.
1576 INSTALL_LIB="-m 555"
1579 # tested with IRIX 5.2 and 'cc'.
1580 if test -n "$GCC"; then
1581 CC_SHARED_OPTS='-fPIC'
1583 CC_SHARED_OPTS='-KPIC'
1585 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
1586 cf_cv_rm_so_locs=yes
1589 # tested with Linux 2.0.29 and gcc 2.7.2 (ELF)
1590 CC_SHARED_OPTS='-fpic'
1591 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1592 if test $DFT_LWR_MODEL = "shared" ; then
1593 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1594 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1596 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1597 if test $cf_cv_shlib_version = no ; then
1598 MK_SHARED_LIB='$(CC) -shared -Wl,-stats,-lc -o $[@]'
1600 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@].$(ABI_VERSION)`,-stats,-lc -o $[@]'
1604 CC_SHARED_OPTS='-fpic -DPIC'
1605 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
1608 CC_SHARED_OPTS='-fpic -DPIC'
1609 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1610 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1613 CC_SHARED_OPTS='-fpic -DPIC'
1614 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1615 if test $DFT_LWR_MODEL = "shared" && test $cf_cv_ld_rpath = yes ; then
1616 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1617 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1618 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
1619 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
1620 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1622 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1626 # tested with OSF/1 V3.2 and 'cc'
1627 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
1628 # link with shared libs).
1630 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`'
1631 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-rpath"
1634 MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
1637 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
1638 if test $DFT_LWR_MODEL = "shared" ; then
1639 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1640 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1642 cf_cv_rm_so_locs=yes
1644 sco3.2v5*) # (also uw2* and UW7) hops 13-Apr-98
1645 # tested with osr5.0.5
1646 if test $ac_cv_prog_gcc = yes; then
1647 CC_SHARED_OPTS='-fpic'
1649 CC_SHARED_OPTS='-belf -KPIC'
1651 MK_SHARED_LIB='$(LD) -dy -G -h `basename [$]@.$(ABI_VERSION)` -o [$]@'
1652 if test $cf_cv_ld_rpath = yes ; then
1653 # only way is to set LD_RUN_PATH but no switch for it
1656 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1657 LINK_PROGS='LD_RUN_PATH=$(libdir)'
1658 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
1661 # tested with SunOS 4.1.1 and gcc 2.7.0
1662 if test $ac_cv_prog_gcc = yes; then
1663 CC_SHARED_OPTS='-fpic'
1665 CC_SHARED_OPTS='-KPIC'
1667 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]'
1668 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1671 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
1672 if test $ac_cv_prog_gcc = yes; then
1673 CC_SHARED_OPTS='-fpic'
1675 CC_SHARED_OPTS='-KPIC'
1677 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@].$(ABI_VERSION)` -o $[@]'
1678 if test $cf_cv_ld_rpath = yes ; then
1679 cf_ld_rpath_opt="-R"
1680 EXTRA_LDFLAGS="-R ../lib:\$(libdir) $EXTRA_LDFLAGS"
1682 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1685 # tested with UnixWare 1.1.2
1686 CC_SHARED_OPTS='-KPIC'
1687 MK_SHARED_LIB='$(LD) -d y -G -o $[@]'
1690 CC_SHARED_OPTS='unknown'
1691 MK_SHARED_LIB='echo unknown'
1695 # This works if the last tokens in $MK_SHARED_LIB are the -o target.
1696 case "$cf_cv_shlib_version" in #(vi
1698 case "$MK_SHARED_LIB" in #(vi
1700 if test "$cf_cv_do_symlinks" = reverse ; then
1701 AC_ERROR(cannot use --with-shlib-version with this platform)
1703 if test "$cf_cv_shlib_version" = rel ; then
1704 MK_SHARED_LIB="$MK_SHARED_LIB"'.$(REL_VERSION)'
1706 MK_SHARED_LIB="$MK_SHARED_LIB"'.$(ABI_VERSION)'
1708 cf_cv_do_symlinks=yes
1711 AC_MSG_WARN(ignored --with-shlib-version)
1717 if test -n "$cf_ld_rpath_opt" ; then
1718 AC_MSG_CHECKING(if we need a space after rpath option)
1719 cf_save_LIBS="$LIBS"
1720 LIBS="$LIBS ${cf_ld_rpath_opt}/usr/lib"
1721 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1722 LIBS="$cf_save_LIBS"
1723 AC_MSG_RESULT($cf_rpath_space)
1724 test $cf_rpath_space = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
1725 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
1728 AC_SUBST(CC_SHARED_OPTS)
1729 AC_SUBST(LD_SHARED_OPTS)
1730 AC_SUBST(MK_SHARED_LIB)
1731 AC_SUBST(LINK_PROGS)
1732 AC_SUBST(LINK_TESTS)
1733 AC_SUBST(EXTRA_LDFLAGS)
1734 AC_SUBST(LOCAL_LDFLAGS)
1735 AC_SUBST(LOCAL_LDFLAGS2)
1736 AC_SUBST(INSTALL_LIB)
1738 dnl ---------------------------------------------------------------------------
1739 dnl Check for definitions & structures needed for window size-changing
1740 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
1741 AC_DEFUN([CF_SIZECHANGE],
1743 AC_MSG_CHECKING([declaration of size-change])
1744 AC_CACHE_VAL(cf_cv_sizechange,[
1745 cf_cv_sizechange=unknown
1746 cf_save_CFLAGS="$CFLAGS"
1748 for cf_opts in "" "NEED_PTEM_H"
1751 CFLAGS="$cf_save_CFLAGS"
1752 test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts"
1753 AC_TRY_COMPILE([#include <sys/types.h>
1755 #include <termios.h>
1762 /* This is a workaround for SCO: they neglected to define struct winsize in
1763 * termios.h -- it's only in termio.h and ptem.h
1765 #include <sys/stream.h>
1766 #include <sys/ptem.h>
1768 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
1769 #include <sys/ioctl.h>
1773 struct ttysize win; /* FIXME: what system is this? */
1774 int y = win.ts_lines;
1775 int x = win.ts_cols;
1782 no TIOCGSIZE or TIOCGWINSZ
1783 #endif /* TIOCGWINSZ */
1784 #endif /* TIOCGSIZE */
1786 [cf_cv_sizechange=yes],
1787 [cf_cv_sizechange=no])
1789 CFLAGS="$cf_save_CFLAGS"
1790 if test "$cf_cv_sizechange" = yes ; then
1791 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
1792 test -n "$cf_opts" && AC_DEFINE_UNQUOTED($cf_opts)
1797 AC_MSG_RESULT($cf_cv_sizechange)
1798 test $cf_cv_sizechange != no && AC_DEFINE(HAVE_SIZECHANGE)
1800 dnl ---------------------------------------------------------------------------
1801 dnl Check for datatype 'speed_t', which is normally declared via either
1802 dnl sys/types.h or termios.h
1803 AC_DEFUN([CF_SPEED_TYPE],
1805 AC_MSG_CHECKING(for speed_t)
1807 AC_TRY_COMPILE([#include <sys/types.h>],
1808 [speed_t some_variable = 0],
1809 [OSPEED_TYPE=speed_t],
1810 [OSPEED_TYPE=unsigned])
1811 AC_TRY_COMPILE([#include <termios.h>],
1812 [speed_t some_variable = 0],
1813 [OSPEED_TYPE=speed_t
1814 OSPEED_INCLUDES="#include <termios.h>"],[])
1815 AC_SUBST(OSPEED_TYPE)
1816 AC_SUBST(OSPEED_INCLUDES)
1817 if test "$OSPEED_TYPE" = "unsigned" ; then
1819 AC_DEFINE(speed_t,unsigned)
1824 dnl ---------------------------------------------------------------------------
1825 dnl For each parameter, test if the source-directory exists, and if it contains
1826 dnl a 'modules' file. If so, add to the list $cf_cv_src_modules which we'll
1827 dnl use in CF_LIB_RULES.
1829 dnl This uses the configured value to make the lists SRC_SUBDIRS and
1830 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
1831 AC_DEFUN([CF_SRC_MODULES],
1833 AC_MSG_CHECKING(for src modules)
1835 # dependencies and linker-arguments for test-programs
1836 TEST_DEPS="${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
1837 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
1839 # dependencies and linker-arguments for utility-programs
1840 PROG_ARGS="$TEST_ARGS"
1845 if test -f $srcdir/$cf_dir/modules; then
1847 # We may/may not have tack in the distribution, though the
1849 if test $cf_dir = tack ; then
1850 if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
1855 if test -z "$cf_cv_src_modules"; then
1856 cf_cv_src_modules=$cf_dir
1858 cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
1861 # Make the ncurses_cfg.h file record the library interface files as
1862 # well. These are header files that are the same name as their
1863 # directory. Ncurses is the only library that does not follow
1865 if test $cf_dir = tack ; then
1867 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
1868 CF_UPPER(cf_have_include,$cf_dir)
1869 AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
1870 AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
1871 TEST_DEPS="${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
1872 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
1876 AC_MSG_RESULT($cf_cv_src_modules)
1877 TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS"
1881 PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS"
1884 SRC_SUBDIRS="man include"
1885 for cf_dir in $cf_cv_src_modules
1887 SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
1889 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
1890 test $cf_with_cxx_binding != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
1893 if test "$cf_cv_prog_gnat_correct" = yes && test -d $srcdir/Ada95; then
1894 SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
1895 ADA_SUBDIRS="gen src samples"
1899 for cf_dir in $SRC_SUBDIRS
1901 SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
1904 if test -n "$ADA_SUBDIRS"; then
1905 for cf_dir in $ADA_SUBDIRS
1907 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
1909 AC_SUBST(ADA_SUBDIRS)
1912 dnl ---------------------------------------------------------------------------
1913 dnl Check for -lstdc++, which is GNU's standard C++ library.
1914 AC_DEFUN([CF_STDCPP_LIBRARY],
1916 if test -n "$GXX" ; then
1917 case $cf_cv_system_name in #(vi
1919 cf_stdcpp_libname=stdcpp
1922 cf_stdcpp_libname=stdc++
1925 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
1927 LIBS="$LIBS -l$cf_stdcpp_libname -lm"
1929 #include <strstream.h>],[
1931 strstreambuf foo(buf, sizeof(buf))
1934 [cf_cv_libstdcpp=yes],
1935 [cf_cv_libstdcpp=no])
1938 test $cf_cv_libstdcpp = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
1941 dnl ---------------------------------------------------------------------------
1942 dnl Remove "-g" option from the compiler options
1943 AC_DEFUN([CF_STRIP_G_OPT],
1944 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
1945 dnl ---------------------------------------------------------------------------
1946 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction. We'll only
1947 dnl do this if we've found the sigaction function.
1949 dnl If needed, define SVR4_ACTION.
1950 AC_DEFUN([CF_STRUCT_SIGACTION],[
1951 if test $ac_cv_func_sigaction = yes; then
1952 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
1954 #include <sys/types.h>
1955 #include <signal.h>],
1956 [struct sigaction act],
1960 #define _POSIX_SOURCE
1961 #include <sys/types.h>
1962 #include <signal.h>],
1963 [struct sigaction act],
1965 AC_DEFINE(SVR4_ACTION)],
1966 [sigact_bad=unknown])])
1967 AC_MSG_RESULT($sigact_bad)
1970 dnl ---------------------------------------------------------------------------
1971 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
1972 dnl If so, define SVR4_TERMIO
1973 AC_DEFUN([CF_STRUCT_TERMIOS],[
1974 if test $ac_cv_header_termios_h = yes ; then
1977 termios_bad=dunno ;;
1978 *) termios_bad=maybe ;;
1980 if test $termios_bad = maybe ; then
1981 AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
1982 AC_TRY_COMPILE([#include <termios.h>],
1983 [struct termios foo; int x = foo.c_iflag],
1986 #define _POSIX_SOURCE
1987 #include <termios.h>],
1988 [struct termios foo; int x = foo.c_iflag],
1989 termios_bad=unknown,
1990 termios_bad=yes AC_DEFINE(SVR4_TERMIO))
1992 AC_MSG_RESULT($termios_bad)
1996 dnl ---------------------------------------------------------------------------
1997 dnl Shorthand macro for substituting things that the user may override
1998 dnl with an environment variable.
2000 dnl $1 = long/descriptive name
2001 dnl $2 = environment variable
2002 dnl $3 = default value
2003 AC_DEFUN([CF_SUBST],
2004 [AC_CACHE_VAL(cf_cv_subst_$2,[
2005 AC_MSG_CHECKING(for $1 (symbol $2))
2006 test -z "[$]$2" && $2=$3
2007 AC_MSG_RESULT([$]$2)
2009 cf_cv_subst_$2=[$]$2])
2010 $2=${cf_cv_subst_$2}
2012 dnl ---------------------------------------------------------------------------
2013 dnl Get the version-number for use in shared-library naming, etc.
2014 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
2017 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2018 NCURSES_MINOR="`egrep '^NCURSES_MINOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2019 NCURSES_PATCH="`egrep '^NCURSES_PATCH[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
2021 cf_cv_abi_version=${NCURSES_MAJOR}
2022 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
2023 dnl Show the computed version, for logging
2024 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`))
2025 dnl We need these values in the generated headers
2026 AC_SUBST(NCURSES_MAJOR)
2027 AC_SUBST(NCURSES_MINOR)
2028 AC_SUBST(NCURSES_PATCH)
2029 dnl We need these values in the generated makefiles
2030 AC_SUBST(cf_cv_rel_version)
2031 AC_SUBST(cf_cv_abi_version)
2032 AC_SUBST(cf_cv_cc_bool_type)
2033 AC_SUBST(cf_cv_builtin_bool)
2034 AC_SUBST(cf_cv_type_of_bool)dnl
2036 dnl ---------------------------------------------------------------------------
2037 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2038 dnl older SCO configurations.
2039 AC_DEFUN([CF_SYS_TIME_SELECT],
2041 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2042 AC_CACHE_VAL(cf_cv_sys_time_select,[
2044 #include <sys/types.h>
2046 #include <sys/time.h>
2048 #if HAVE_SYS_SELECT_H
2049 #include <sys/select.h>
2051 ],[],[cf_cv_sys_time_select=yes],
2052 [cf_cv_sys_time_select=no])
2054 AC_MSG_RESULT($cf_cv_sys_time_select)
2055 test $cf_cv_sys_time_select = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2057 dnl ---------------------------------------------------------------------------
2058 dnl Determine the type we should use for chtype (and attr_t, which is treated
2059 dnl as the same thing). We want around 32 bits, so on most machines want a
2060 dnl long, but on newer 64-bit machines, probably want an int. If we're using
2061 dnl wide characters, we have to have a type compatible with that, as well.
2062 AC_DEFUN([CF_TYPEOF_CHTYPE],
2064 AC_REQUIRE([CF_UNSIGNED_LITERALS])
2065 AC_MSG_CHECKING([for type of chtype])
2066 AC_CACHE_VAL(cf_cv_typeof_chtype,[
2068 #if USE_WIDEC_SUPPORT
2069 #include <stddef.h> /* we want wchar_t */
2070 #define WANT_BITS 39
2072 #define WANT_BITS 31
2077 FILE *fp = fopen("cf_test.out", "w");
2079 char *result = "long";
2080 #if USE_WIDEC_SUPPORT
2082 * If wchar_t is smaller than a long, it must be an int or a
2083 * short. We prefer not to use a short anyway.
2085 if (sizeof(unsigned long) > sizeof(wchar_t))
2088 if (sizeof(unsigned long) > sizeof(unsigned int)) {
2091 for (n = 0; n < WANT_BITS; n++) {
2092 unsigned int y = (x >> n);
2093 if (y != 1 || x == 0) {
2099 * If x is nonzero, an int is big enough for the bits
2102 result = (x != 0) ? "int" : "long";
2110 [cf_cv_typeof_chtype=`cat cf_test.out`],
2111 [cf_cv_typeof_chtype=long],
2112 [cf_cv_typeof_chtype=long])
2115 AC_MSG_RESULT($cf_cv_typeof_chtype)
2117 AC_SUBST(cf_cv_typeof_chtype)
2118 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
2121 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
2122 test "$cf_cv_typeof_chtype" = long && cf_cv_1UL="${cf_cv_1UL}L"
2126 dnl ---------------------------------------------------------------------------
2128 AC_DEFUN([CF_TYPE_SIGACTION],
2130 AC_MSG_CHECKING([for type sigaction_t])
2131 AC_CACHE_VAL(cf_cv_type_sigaction,[
2133 #include <signal.h>],
2135 [cf_cv_type_sigaction=yes],
2136 [cf_cv_type_sigaction=no])])
2137 AC_MSG_RESULT($cf_cv_type_sigaction)
2138 test $cf_cv_type_sigaction = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
2140 dnl ---------------------------------------------------------------------------
2141 dnl Test if the compiler supports 'U' and 'L' suffixes. Only old compilers
2142 dnl won't, but they're still there.
2143 AC_DEFUN([CF_UNSIGNED_LITERALS],
2145 AC_MSG_CHECKING([if unsigned literals are legal])
2146 AC_CACHE_VAL(cf_cv_unsigned_literals,[
2147 AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
2148 [cf_cv_unsigned_literals=yes],
2149 [cf_cv_unsigned_literals=no])
2151 AC_MSG_RESULT($cf_cv_unsigned_literals)
2153 dnl ---------------------------------------------------------------------------
2154 dnl Make an uppercase version of a variable
2155 dnl $1=uppercase($2)
2156 AC_DEFUN([CF_UPPER],
2159 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
2162 dnl ---------------------------------------------------------------------------
2163 dnl Compute the shift-mask that we'll use for wide-character indices. We use
2164 dnl all but the index portion of chtype for storing attributes.
2165 AC_DEFUN([CF_WIDEC_SHIFT],
2167 AC_REQUIRE([CF_TYPEOF_CHTYPE])
2168 AC_MSG_CHECKING([for number of bits in chtype])
2169 AC_CACHE_VAL(cf_cv_shift_limit,[
2174 FILE *fp = fopen("cf_test.out", "w");
2177 unsigned TYPEOF_CHTYPE x = 1L;
2178 for (n = 0; ; n++) {
2179 unsigned long y = (x >> n);
2180 if (y != 1 || x == 0)
2184 fprintf(fp, "%d", n);
2190 [cf_cv_shift_limit=`cat cf_test.out`],
2191 [cf_cv_shift_limit=32],
2192 [cf_cv_shift_limit=32])
2195 AC_MSG_RESULT($cf_cv_shift_limit)
2196 AC_SUBST(cf_cv_shift_limit)
2198 AC_MSG_CHECKING([for width of character-index])
2199 AC_CACHE_VAL(cf_cv_widec_shift,[
2200 if test ".$with_widec" = ".yes" ; then
2202 if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
2204 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
2206 cf_cv_widec_shift=16
2212 AC_MSG_RESULT($cf_cv_widec_shift)
2213 AC_SUBST(cf_cv_widec_shift)
2215 dnl ---------------------------------------------------------------------------
2216 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2217 dnl defaulting to yes/no.
2219 dnl $1 = option name
2221 dnl $3 = environment variable to set
2222 dnl $4 = default value, shown in the help-message, must be a constant
2223 dnl $5 = default value, if it's an expression & cannot be in the help-message
2225 AC_DEFUN([CF_WITH_PATH],
2226 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2227 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2228 CF_PATH_SYNTAX(withval)
2232 dnl ---------------------------------------------------------------------------
2233 dnl Process an option specifying a list of colon-separated paths.
2235 dnl $1 = option name
2237 dnl $3 = environment variable to set
2238 dnl $4 = default value, shown in the help-message, must be a constant
2239 dnl $5 = default value, if it's an expression & cannot be in the help-message
2241 AC_DEFUN([CF_WITH_PATHLIST],[
2242 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2243 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2245 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2247 for cf_src_path in $withval
2249 CF_PATH_SYNTAX(cf_src_path)
2250 test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
2251 cf_dst_path="${cf_dst_path}${cf_src_path}"
2255 eval $3="$cf_dst_path"