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.248 2001/04/21 19:40:04 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 Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
61 AC_DEFUN([CF_ADD_CFLAGS],
63 for cf_add_cflags in $1
65 case $cf_add_cflags in #(vi
66 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
71 CPPFLAGS="$CPPFLAGS $cf_add_cflags"
76 CFLAGS="$CFLAGS $cf_add_cflags"
81 dnl ---------------------------------------------------------------------------
82 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
83 dnl in the sharutils 4.2 distribution.
84 AC_DEFUN([CF_ANSI_CC_CHECK],
86 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
87 AC_CACHE_VAL(cf_cv_ansi_cc,[
89 cf_save_CFLAGS="$CFLAGS"
90 cf_save_CPPFLAGS="$CPPFLAGS"
91 # Don't try gcc -ansi; that turns off useful extensions and
92 # breaks some systems' header files.
94 # Ultrix and OSF/1 -std1
95 # HP-UX -Aa -D_HPUX_SOURCE
97 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
98 for cf_arg in "-DCC_HAS_PROTOS" \
103 "-Aa -D_HPUX_SOURCE" \
106 CF_ADD_CFLAGS($cf_arg)
109 #ifndef CC_HAS_PROTOS
110 #if !defined(__STDC__) || (__STDC__ != 1)
115 int test (int i, double x);
116 struct s1 {int (*f) (int a);};
117 struct s2 {int (*f) (double a);};],
118 [cf_cv_ansi_cc="$cf_arg"; break])
120 CFLAGS="$cf_save_CFLAGS"
121 CPPFLAGS="$cf_save_CPPFLAGS"
123 AC_MSG_RESULT($cf_cv_ansi_cc)
125 if test "$cf_cv_ansi_cc" != "no"; then
126 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
127 CF_ADD_CFLAGS($cf_cv_ansi_cc)
129 AC_DEFINE(CC_HAS_PROTOS)
133 dnl ---------------------------------------------------------------------------
134 dnl For programs that must use an ANSI compiler, obtain compiler options that
135 dnl will make it recognize prototypes. We'll do preprocessor checks in other
136 dnl macros, since tools such as unproto can fake prototypes, but only part of
137 dnl the preprocessor.
138 AC_DEFUN([CF_ANSI_CC_REQD],
139 [AC_REQUIRE([CF_ANSI_CC_CHECK])
140 if test "$cf_cv_ansi_cc" = "no"; then
142 [Your compiler does not appear to recognize prototypes.
143 You have the following choices:
144 a. adjust your compiler options
145 b. get an up-to-date compiler
146 c. use a wrapper such as unproto])
149 dnl ---------------------------------------------------------------------------
150 dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some
151 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
152 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
154 dnl Treat the configuration-variable specially here, since we're directly
155 dnl substituting its value (i.e., 1/0).
156 AC_DEFUN([CF_BOOL_DECL],
158 AC_MSG_CHECKING([for builtin bool type])
159 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
162 #include <sys/types.h>
164 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
165 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
167 if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
168 then AC_MSG_RESULT(yes)
169 else AC_MSG_RESULT(no)
172 dnl ---------------------------------------------------------------------------
173 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
174 dnl Don't bother looking for bool.h, since it's been deprecated.
175 AC_DEFUN([CF_BOOL_SIZE],
177 AC_MSG_CHECKING([for size of bool])
178 AC_CACHE_VAL(cf_cv_type_of_bool,[
183 #ifdef HAVE_GXX_BUILTIN_H
184 #include <g++/builtin.h>
185 #elif HAVE_GPP_BUILTIN_H
186 #include <gpp/builtin.h>
192 FILE *fp = fopen("cf_test.out", "w");
196 fputs("unsigned ", fp);
197 if (sizeof(x) == sizeof(int)) fputs("int", fp);
198 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
199 else if (sizeof(x) == sizeof(short))fputs("short",fp);
200 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
206 [cf_cv_type_of_bool=`cat cf_test.out`],
207 [cf_cv_type_of_bool=unknown],
208 [cf_cv_type_of_bool=unknown])
211 AC_MSG_RESULT($cf_cv_type_of_bool)
212 if test "$cf_cv_type_of_bool" = unknown ; then
213 AC_MSG_WARN(Assuming unsigned for type of bool)
214 cf_cv_type_of_bool=unsigned
217 dnl ---------------------------------------------------------------------------
218 dnl Determine the default configuration into which we'll install ncurses. This
219 dnl can be overridden by the user's command-line options. There's two items to
221 dnl 1. the prefix (e.g., /usr)
222 dnl 2. the header files (e.g., /usr/include/ncurses)
223 dnl We'll look for a previous installation of ncurses and use the same defaults.
225 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
226 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
227 dnl programs from a vendor's.
228 AC_DEFUN([CF_CFG_DEFAULTS],
230 AC_MSG_CHECKING(for prefix)
231 if test "x$prefix" = "xNONE" ; then
232 case "$cf_cv_system_name" in
233 # non-vendor systems don't have a conflict
234 openbsd*|netbsd*|freebsd*|linux*|cygwin*)
237 *) prefix=$ac_default_prefix
241 AC_MSG_RESULT($prefix)
243 if test "x$prefix" = "xNONE" ; then
244 AC_MSG_CHECKING(for default include-directory)
245 test -n "$verbose" && echo 1>&AC_FD_MSG
248 $includedir/ncurses \
250 $prefix/include/ncurses \
252 /usr/local/include/ncurses \
256 cf_dir=`eval echo $cf_symbol`
257 if test -f $cf_dir/curses.h ; then
258 if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
259 includedir="$cf_symbol"
260 test -n "$verbose" && echo $ac_n " found " 1>&AC_FD_MSG
264 test -n "$verbose" && echo " tested $cf_dir" 1>&AC_FD_MSG
266 AC_MSG_RESULT($includedir)
269 dnl ---------------------------------------------------------------------------
270 dnl Check if the terminal-capability database functions are available. If not,
271 dnl ncurses has a much-reduced version.
272 AC_DEFUN([CF_CGETENT],[
273 AC_MSG_CHECKING(for terminal-capability database functions)
274 AC_CACHE_VAL(cf_cv_cgetent,[
276 #include <stdlib.h>],[
279 char *db_array = temp;
280 cgetent(&buf, /* int *, */ &db_array, "vt100");
281 cgetcap(buf, "tc", '=');
282 cgetmatch(buf, "tc");
287 AC_MSG_RESULT($cf_cv_cgetent)
288 test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT)
290 dnl ---------------------------------------------------------------------------
291 dnl Check if we're accidentally using a cache from a different machine.
292 dnl Derive the system name, as a check for reusing the autoconf cache.
294 dnl If we've packaged config.guess and config.sub, run that (since it does a
295 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
296 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
297 dnl which is useful in cross-compiles.
298 AC_DEFUN([CF_CHECK_CACHE],
300 if test -f $srcdir/config.guess ; then
301 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
302 system_name="$host_os"
304 system_name="`(uname -s -r) 2>/dev/null`"
305 if test -z "$system_name" ; then
306 system_name="`(hostname) 2>/dev/null`"
309 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
310 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
312 test -z "$system_name" && system_name="$cf_cv_system_name"
313 test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name")
315 if test ".$system_name" != ".$cf_cv_system_name" ; then
316 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
317 AC_ERROR("Please remove config.cache and try again.")
320 dnl ---------------------------------------------------------------------------
321 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
322 dnl the 'errno' variable. Define a DECL_xxx symbol if we must declare it
325 dnl (I would use AC_CACHE_CHECK here, but it will not work when called in a
326 dnl loop from CF_SYS_ERRLIST).
328 dnl $1 = the name to check
329 AC_DEFUN([CF_CHECK_ERRNO],
331 AC_MSG_CHECKING(if external $1 is declared)
332 AC_CACHE_VAL(cf_cv_dcl_$1,[
338 #include <sys/types.h>
339 #include <errno.h> ],
340 [long x = (long) $1],
341 [eval 'cf_cv_dcl_'$1'=yes'],
342 [eval 'cf_cv_dcl_'$1'=no'])
345 eval 'cf_result=$cf_cv_dcl_'$1
346 AC_MSG_RESULT($cf_result)
348 if test "$cf_result" = no ; then
349 eval 'cf_result=DECL_'$1
350 CF_UPPER(cf_result,$cf_result)
351 AC_DEFINE_UNQUOTED($cf_result)
354 # It's possible (for near-UNIX clones) that the data doesn't exist
355 CF_CHECK_EXTERN_DATA($1,int)
357 dnl ---------------------------------------------------------------------------
358 dnl Check for existence of external data in the current set of libraries. If
359 dnl we can modify it, it's real enough.
360 dnl $1 = the name to check
362 AC_DEFUN([CF_CHECK_EXTERN_DATA],
364 AC_MSG_CHECKING(if external $1 exists)
365 AC_CACHE_VAL(cf_cv_have_$1,[
371 [eval 'cf_cv_have_'$1'=yes'],
372 [eval 'cf_cv_have_'$1'=no'])])
374 eval 'cf_result=$cf_cv_have_'$1
375 AC_MSG_RESULT($cf_result)
377 if test "$cf_result" = yes ; then
378 eval 'cf_result=HAVE_'$1
379 CF_UPPER(cf_result,$cf_result)
380 AC_DEFINE_UNQUOTED($cf_result)
384 dnl ---------------------------------------------------------------------------
385 dnl Check if the C++ compiler accepts duplicate parameter initialization. This
386 dnl is a late feature for the standard and is not in some recent compilers
388 AC_DEFUN([CF_CPP_PARAM_INIT],
390 if test -n "$CXX"; then
391 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
403 TEST::TEST(int x = 1) // some compilers do not like second initializer
409 [cf_cv_cpp_param_init=yes],
410 [cf_cv_cpp_param_init=no],
411 [cf_cv_cpp_param_init=unknown])
415 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
417 dnl ---------------------------------------------------------------------------
418 dnl Check if the g++ compiler supports vscan function (not a standard feature).
419 AC_DEFUN([CF_CPP_VSCAN_FUNC],
421 if test -n "$CXX"; then
425 AC_CHECK_HEADERS(strstream.h)
427 AC_CACHE_CHECK(if $CXX supports vscan function,cf_cv_cpp_vscan_func,[
428 for cf_vscan_func in strstream stdio
430 case $cf_vscan_func in #(vi
431 stdio) cf_vscan_defs=USE_STDIO_VSCAN ;; #(vi
432 strstream) cf_vscan_defs=USE_STRSTREAM_VSCAN ;;
437 #define $cf_vscan_defs 1
438 #if defined(USE_STDIO_VSCAN)
439 #elif defined(HAVE_STRSTREAM_H) && defined(USE_STRSTREAM_VSCAN)
440 #include <strstream.h>
443 int scanw(const char* fmt, ...)
446 #if defined(__GNUG__)
451 #if defined(USE_STDIO_VSCAN)
452 if (::vscanf(fmt, args) != -1)
454 #elif defined(USE_STRSTREAM_VSCAN)
455 strstreambuf ss(buf, sizeof(buf));
456 if (ss.vscan(fmt, (_IO_va_list)args) != -1)
459 #error case $cf_vscan_func failed
463 #error sorry, we only know about the GNU compiler case
467 ],[int tmp, foo = scanw("%d", &tmp)],
468 [cf_cv_cpp_vscan_func=$cf_vscan_func; break],
469 [cf_cv_cpp_vscan_func=no])
470 test "$cf_cv_cpp_vscan_func" != no && break
477 case $cf_cv_cpp_vscan_func in #(vi
479 AC_DEFINE(CPP_HAS_VSCAN_FUNC)
480 AC_DEFINE(USE_STDIO_VSCAN)
483 AC_DEFINE(CPP_HAS_VSCAN_FUNC)
484 AC_DEFINE(USE_STRSTREAM_VSCAN)
488 dnl ---------------------------------------------------------------------------
489 dnl "dirname" is not portable, so we fake it with a shell script.
490 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's:/[[^/]]*$::'`])dnl
491 dnl ---------------------------------------------------------------------------
492 AC_DEFUN([CF_DIRS_TO_MAKE],
495 for cf_item in $cf_list_models
497 CF_OBJ_SUBDIR($cf_item,cf_subdir)
498 DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
500 for cf_dir in $DIRS_TO_MAKE
502 test ! -d $cf_dir && mkdir $cf_dir
504 AC_SUBST(DIRS_TO_MAKE)
506 dnl ---------------------------------------------------------------------------
507 dnl Check if 'errno' is declared in <errno.h>
510 CF_CHECK_ERRNO(errno)
512 dnl ---------------------------------------------------------------------------
513 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
514 dnl math.h and builtin.h, only for ncurses
515 AC_DEFUN([CF_ETIP_DEFINES],
517 AC_MSG_CHECKING(for special defines needed for etip.h)
518 cf_save_CXXFLAGS="$CXXFLAGS"
520 for cf_math in "" MATH_H
522 for cf_excp in "" MATH_EXCEPTION
524 CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu"
525 test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
526 test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
530 test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
531 test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
532 cf_result="$cf_math $cf_excp"
537 AC_MSG_RESULT($cf_result)
538 CXXFLAGS="$cf_save_CXXFLAGS"
540 dnl ---------------------------------------------------------------------------
541 dnl Check for memmove, or a bcopy that can handle overlapping copy. If neither
542 dnl is found, add our own version of memmove to the list of objects.
543 AC_DEFUN([CF_FUNC_MEMMOVE],
545 AC_CHECK_FUNC(memmove,,[
546 AC_CHECK_FUNC(bcopy,[
547 AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
550 static char data[] = "abcdefghijklmnopqrstuwwxyz";
552 bcopy(data, temp, sizeof(data));
553 bcopy(temp+10, temp, 15);
554 bcopy(temp+5, temp+15, 10);
555 exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
558 [cf_cv_good_bcopy=yes],
559 [cf_cv_good_bcopy=no],
560 [cf_cv_good_bcopy=unknown])
562 ],[cf_cv_good_bcopy=no])
563 if test "$cf_cv_good_bcopy" = yes ; then
564 AC_DEFINE(USE_OK_BCOPY)
566 AC_DEFINE(USE_MY_MEMMOVE)
569 dnl ---------------------------------------------------------------------------
570 dnl See if the poll function really works. Some platforms have poll(), but
571 dnl it does not work for terminals or files.
572 AC_DEFUN([CF_FUNC_POLL],[
573 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
579 #include <sys/poll.h>
586 myfds.events = POLLIN;
588 ret = poll(&myfds, 1, 100);
591 [cf_cv_working_poll=yes],
592 [cf_cv_working_poll=no],
593 [cf_cv_working_poll=unknown])])
594 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
596 dnl ---------------------------------------------------------------------------
597 dnl Some old/broken variations define tcgetattr() only as a macro in
599 AC_DEFUN([CF_FUNC_TERMIOS],[
600 AC_REQUIRE([CF_STRUCT_TERMIOS])
601 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
603 #include <sys/types.h>
607 #ifdef HAVE_TERMIOS_H
609 #define TTY struct termios
613 #define TTY struct termio
618 tcgetattr(1, &foo);],
619 [cf_cv_have_tcgetattr=yes],
620 [cf_cv_have_tcgetattr=no])])
621 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR)
623 dnl ---------------------------------------------------------------------------
624 dnl Test for availability of useful gcc __attribute__ directives to quiet
625 dnl compiler warnings. Though useful, not all are supported -- and contrary
626 dnl to documentation, unrecognized directives cause older compilers to barf.
627 AC_DEFUN([CF_GCC_ATTRIBUTES],
631 cat > conftest.i <<EOF
639 #define GCC_NORETURN /* nothing */
642 #define GCC_UNUSED /* nothing */
647 AC_CHECKING([for $CC __attribute__ directives])
648 cat > conftest.$ac_ext <<EOF
649 #line __oline__ "configure"
650 #include "confdefs.h"
651 #include "conftest.h"
652 #include "conftest.i"
654 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
656 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
659 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
661 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
663 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
664 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
665 extern void foo(void) GCC_NORETURN;
666 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
668 for cf_attribute in scanf printf unused noreturn
670 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
671 cf_directive="__attribute__(($cf_attribute))"
672 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
673 case $cf_attribute in
675 cat >conftest.h <<EOF
676 #define GCC_$CF_ATTRIBUTE 1
680 cat >conftest.h <<EOF
681 #define GCC_$CF_ATTRIBUTE $cf_directive
685 if AC_TRY_EVAL(ac_compile); then
686 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
687 cat conftest.h >>confdefs.h
689 # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
693 fgrep define conftest.i >>confdefs.h
698 dnl ---------------------------------------------------------------------------
699 dnl Check if the compiler supports useful warning options. There's a few that
700 dnl we don't use, simply because they're too noisy:
702 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
703 dnl -Wredundant-decls (system headers make this too noisy)
704 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
705 dnl -Wwrite-strings (too noisy, but should review occasionally)
708 AC_DEFUN([CF_GCC_WARNINGS],
712 cat > conftest.$ac_ext <<EOF
713 #line __oline__ "configure"
714 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
716 AC_CHECKING([for $CC warning options])
717 cf_save_CFLAGS="$CFLAGS"
718 EXTRA_CFLAGS="-W -Wall"
720 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
726 Wmissing-declarations \
727 Wmissing-prototypes \
731 Wstrict-prototypes $cf_warn_CONST
733 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
734 if AC_TRY_EVAL(ac_compile); then
735 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
736 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
737 test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
741 CFLAGS="$cf_save_CFLAGS"
743 AC_SUBST(EXTRA_CFLAGS)
745 dnl ---------------------------------------------------------------------------
746 dnl Verify that a test program compiles and runs with GNAT
747 dnl $cf_ada_make is set to the program that compiles/links
748 AC_DEFUN([CF_GNAT_TRY_RUN],
751 cat >>conftest.ads <<CF_EOF
754 cat >>conftest.adb <<CF_EOF
757 if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
758 if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
768 dnl ---------------------------------------------------------------------------
769 dnl Verify Version of GNAT.
770 AC_DEFUN([CF_GNAT_VERSION],
772 cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[[0-9]].[[0-9]][[0-9]]*' |\
773 sed -e 's/[[^0-9 \.]]//g' | $AWK '{print $[1];}'`
774 case $cf_cv_gnat_version in
775 3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*)
776 cf_cv_prog_gnat_correct=yes
778 *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
779 cf_cv_prog_gnat_correct=no
782 case $cf_cv_gnat_version in
784 cf_compile_generics=generics
785 cf_generic_objects="\$(GENOBJS)"
787 *) cf_compile_generics=
792 dnl ---------------------------------------------------------------------------
793 dnl If we're trying to use g++, test if libg++ is installed (a rather common
794 dnl problem :-). If we have the compiler but no library, we'll be able to
795 dnl configure, but won't be able to build the c++ demo program.
796 AC_DEFUN([CF_GPP_LIBRARY],
798 cf_cxx_library=unknown
799 case $cf_cv_system_name in #(vi
807 if test "$ac_cv_prog_gxx" = yes; then
808 AC_MSG_CHECKING([for lib$cf_gpp_libname])
810 LIBS="$LIBS -l$cf_gpp_libname"
812 #include <$cf_gpp_libname/builtin.h>
814 [two_arg_error_handler_t foo2 = lib_error_handler],
816 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
817 if test "$cf_gpp_libname" = cpp ; then
818 AC_DEFINE(HAVE_GPP_BUILTIN_H)
820 AC_DEFINE(HAVE_GXX_BUILTIN_H)
825 [two_arg_error_handler_t foo2 = lib_error_handler],
827 CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
828 AC_DEFINE(HAVE_BUILTIN_H)],
829 [cf_cxx_library=no])])
831 AC_MSG_RESULT($cf_cxx_library)
834 dnl ---------------------------------------------------------------------------
835 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
836 AC_DEFUN([CF_HELP_MESSAGE],
837 [AC_DIVERT_HELP([$1])dnl
839 dnl ---------------------------------------------------------------------------
840 dnl Construct the list of include-options according to whether we're building
841 dnl in the source directory or using '--srcdir=DIR' option. If we're building
842 dnl with gcc, don't append the includedir if it happens to be /usr/include,
843 dnl since that usually breaks gcc's shadow-includes.
844 AC_DEFUN([CF_INCLUDE_DIRS],
846 CPPFLAGS="$CPPFLAGS -I. -I../include"
847 if test "$srcdir" != "."; then
848 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
850 if test "$GCC" != yes; then
851 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
852 elif test "$includedir" != "/usr/include"; then
853 if test "$includedir" = '${prefix}/include' ; then
854 if test $prefix != /usr ; then
855 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
858 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
863 dnl ---------------------------------------------------------------------------
864 dnl Check if we have either a function or macro for 'isascii()'.
865 AC_DEFUN([CF_ISASCII],
867 AC_MSG_CHECKING(for isascii)
868 AC_CACHE_VAL(cf_cv_have_isascii,[
869 AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
870 [cf_cv_have_isascii=yes],
871 [cf_cv_have_isascii=no])
873 AC_MSG_RESULT($cf_cv_have_isascii)
874 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII)
876 dnl ---------------------------------------------------------------------------
877 dnl Compute the library-prefix for the given host system
878 dnl $1 = variable to set
879 AC_DEFUN([CF_LIB_PREFIX],
881 case $cf_cv_system_name in
882 OS/2*) LIB_PREFIX='' ;;
883 os2*) LIB_PREFIX='' ;;
884 *) LIB_PREFIX='lib' ;;
886 ifelse($1,,,[$1=$LIB_PREFIX])
889 dnl ---------------------------------------------------------------------------
890 dnl Append definitions and rules for the given models to the subdirectory
891 dnl Makefiles, and the recursion rule for the top-level Makefile. If the
892 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
893 dnl the corresponding makefile to list the models that we'll generate.
895 dnl For shared libraries, make a list of symbolic links to construct when
896 dnl generating each library. The convention used for Linux is the simplest
899 dnl lib<name>.so.<major> ->
900 dnl lib<name>.so.<maj>.<minor>
901 AC_DEFUN([CF_LIB_RULES],
903 CF_LIB_PREFIX(cf_prefix)
904 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
905 for cf_dir in $SRC_SUBDIRS
907 if test -f $srcdir/$cf_dir/modules; then
910 for cf_item in $CF_LIST_MODELS
912 CF_LIB_SUFFIX($cf_item,cf_suffix)
913 if test $cf_item = shared ; then
914 if test "$cf_cv_do_symlinks" = yes ; then
915 case "$cf_cv_shlib_version" in #(vi
916 rel) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;; #(vi
917 abi) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
921 cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
924 if test $cf_dir = ncurses ; then
925 case "$LIB_SUBSETS" in #(vi
929 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g`
930 cf_libs_to_make="$cf_item $cf_libs_to_make"
935 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \
936 $cf_dir/Makefile >$cf_dir/Makefile.out
937 mv $cf_dir/Makefile.out $cf_dir/Makefile
939 $AWK -f $srcdir/mk-0th.awk \
941 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
943 for cf_item in $CF_LIST_MODELS
945 echo 'Appending rules for '$cf_item' model ('$cf_dir')'
946 CF_UPPER(CF_ITEM,$cf_item)
947 CF_LIB_SUFFIX($cf_item,cf_suffix)
948 CF_OBJ_SUBDIR($cf_item,cf_subdir)
950 # These dependencies really are for development, not
951 # builds, but they are useful in porting, too.
952 cf_depend="../include/ncurses_cfg.h"
953 if test "$srcdir" = "."; then
956 cf_reldir="\$(srcdir)"
959 if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
960 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
961 elif test -f $srcdir/$cf_dir/curses.priv.h; then
962 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
965 for cf_subset in $LIB_SUBSETS
967 $AWK -f $srcdir/mk-1st.awk \
969 traces=$LIB_TRACING \
975 ShlibVer=$cf_cv_shlib_version \
976 DoLinks=$cf_cv_do_symlinks \
977 rmSoLocs=$cf_cv_rm_so_locs \
978 ldconfig="$LDCONFIG" \
979 overwrite=$WITH_OVERWRITE \
980 depend="$cf_depend" \
982 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
983 test $cf_dir = ncurses && WITH_OVERWRITE=no
984 $AWK -f $srcdir/mk-2nd.awk \
986 traces=$LIB_TRACING \
992 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
997 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
1000 for cf_dir in $SRC_SUBDIRS
1002 if test -f $cf_dir/Makefile ; then
1005 echo 'libs \' >> Makefile
1006 echo 'install.libs \' >> Makefile
1007 echo 'uninstall.libs ::' >> Makefile
1008 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
1013 if test -f $srcdir/$cf_dir/modules; then
1015 if test -f $srcdir/$cf_dir/headers; then
1016 cat >> Makefile <<CF_EOF
1018 uninstall.includes \\
1021 if test "$cf_dir" != "c++" ; then
1022 echo 'lint \' >> Makefile
1024 cat >> Makefile <<CF_EOF
1030 uninstall.$cf_dir ::
1031 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
1033 elif test -f $srcdir/$cf_dir/headers; then
1034 cat >> Makefile <<CF_EOF
1040 uninstall.includes ::
1041 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
1046 cat >> Makefile <<CF_EOF
1050 cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
1054 cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
1057 rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
1058 rm -f headers.sh headers.sed
1059 rm -rf \$(DIRS_TO_MAKE)
1062 # Special case: tack's manpage lives in its own directory.
1063 if test -d tack ; then
1064 if test -f $srcdir/$tack.h; then
1065 cat >> Makefile <<CF_EOF
1069 cd tack && \$(MAKE) \$(CF_MFLAGS) \[$]@
1074 dnl If we're installing into a subdirectory of /usr/include, etc., we should
1075 dnl prepend the subdirectory's name to the "#include" paths. It won't hurt
1076 dnl anything, and will make it more standardized. It's awkward to decide this
1077 dnl at configuration because of quoting, so we'll simply make all headers
1078 dnl installed via a script that can do the right thing.
1080 rm -f headers.sed headers.sh
1082 dnl ( generating this script makes the makefiles a little tidier :-)
1083 echo creating headers.sh
1084 cat >headers.sh <<CF_EOF
1086 # This shell script is generated by the 'configure' script. It is invoked in a
1087 # subdirectory of the build tree. It generates a sed-script in the parent
1088 # directory that is used to adjust includes for header files that reside in a
1089 # subdirectory of /usr/include, etc.
1091 while test \[$]# != 3
1093 PRG="\$PRG \[$]1"; shift
1098 TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
1099 TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
1100 echo installing \$SRC in \$DST
1102 if test $WITH_CURSES_H = yes; then
1103 cat >>headers.sh <<CF_EOF
1106 END=\`basename \$DST\`
1107 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
1109 NAME=\`basename \$i\`
1110 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
1119 cat >>headers.sh <<CF_EOF
1122 END=\`basename \$DST\`
1123 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
1125 NAME=\`basename \$i\`
1126 if test "\$NAME" = "curses.h"
1128 echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
1131 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
1135 echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
1140 cat >>headers.sh <<CF_EOF
1142 sed -f \$TMPSED \$SRC > \$TMPSRC
1143 NAME=\`basename \$SRC\`
1145 if test $WITH_CURSES_H != yes; then
1146 cat >>headers.sh <<CF_EOF
1147 test "\$NAME" = "curses.h" && NAME=ncurses.h
1150 cat >>headers.sh <<CF_EOF
1151 eval \$PRG \$TMPSRC \$DST/\$NAME
1152 rm -f \$TMPSRC \$TMPSED
1155 chmod 0755 headers.sh
1157 for cf_dir in $SRC_SUBDIRS
1159 if test -f $srcdir/$cf_dir/headers; then
1160 cat >>$cf_dir/Makefile <<CF_EOF
1161 \$(DESTDIR)\$(includedir) :
1162 \$(srcdir)/../mkinstalldirs \[$]@
1166 install.includes :: \$(AUTO_SRC) \$(DESTDIR)\$(includedir) \\
1169 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1171 test -n "$j" && echo " $j \\" >>$cf_dir/Makefile
1174 echo " $j" >>$cf_dir/Makefile
1175 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1177 echo " @ (cd \$(DESTDIR)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(DESTDIR)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
1178 test $i = curses.h && test $WITH_CURSES_H = yes && echo " @ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
1181 cat >>$cf_dir/Makefile <<CF_EOF
1185 uninstall.includes ::
1187 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1190 echo " -@ (cd \$(DESTDIR)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
1191 test $i = curses.h && echo " -@ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
1197 dnl ---------------------------------------------------------------------------
1198 dnl Compute the library file-suffix from the given model name
1200 dnl $2 = variable to set
1201 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1202 AC_DEFUN([CF_LIB_SUFFIX],
1204 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1206 libtool) $2='.la' ;;
1209 profile) $2='_p.a' ;;
1211 case $cf_cv_system_name in
1216 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1218 dnl ---------------------------------------------------------------------------
1219 dnl Compute the string to append to -library from the given model name
1221 dnl $2 = variable to set
1222 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1223 AC_DEFUN([CF_LIB_TYPE],
1232 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1234 dnl ---------------------------------------------------------------------------
1235 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1236 dnl only data (i.e., no functions), for example NeXT. On those systems we'll
1237 dnl have to provide wrappers for global tables to ensure they're linked
1239 AC_DEFUN([CF_LINK_DATAONLY],
1241 AC_MSG_CHECKING([if data-only library module links])
1242 AC_CACHE_VAL(cf_cv_link_dataonly,[
1244 cat >conftest.$ac_ext <<EOF
1245 #line __oline__ "configure"
1246 int testdata[[3]] = { 123, 456, 789 };
1248 if AC_TRY_EVAL(ac_compile) ; then
1249 mv conftest.o data.o && \
1250 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
1252 rm -f conftest.$ac_ext data.o
1253 cat >conftest.$ac_ext <<EOF
1254 #line __oline__ "configure"
1258 exit(1); /* I'm told this linker is broken */
1260 extern int testdata[[3]];
1261 return testdata[[0]] == 123
1262 && testdata[[1]] == 456
1263 && testdata[[2]] == 789;
1267 if AC_TRY_EVAL(ac_compile); then
1268 mv conftest.o func.o && \
1269 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
1271 rm -f conftest.$ac_ext func.o
1272 ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
1274 LIBS="conftest.a $LIBS"
1278 extern int testfunc();
1282 [cf_cv_link_dataonly=yes],
1283 [cf_cv_link_dataonly=no],
1284 [cf_cv_link_dataonly=unknown])
1287 AC_MSG_RESULT($cf_cv_link_dataonly)
1288 test "$cf_cv_link_dataonly" = no && AC_DEFINE(BROKEN_LINKER)
1290 dnl ---------------------------------------------------------------------------
1291 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1292 dnl A few non-Unix systems implement symlink, but not link.
1293 dnl A few non-systems implement neither (or have nonfunctional versions).
1294 AC_DEFUN([CF_LINK_FUNCS],
1300 if test "$ac_cv_prog_cc_cross" = yes ; then
1305 AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1307 for cf_func in link symlink ; do
1309 #include <sys/types.h>
1310 #include <sys/stat.h>
1311 #ifdef HAVE_UNISTD_H
1317 char *src = "config.log";
1318 char *dst = "conftest.chk";
1323 fail = ($cf_func("config.log", "conftest.chk") < 0)
1324 || (stat(dst, &dst_sb) < 0)
1325 || (dst_sb.st_mtime != src_sb.st_mtime);
1334 cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1335 eval 'ac_cv_func_'$cf_func'=yes'],[
1336 eval 'ac_cv_func_'$cf_func'=no'],[
1337 eval 'ac_cv_func_'$cf_func'=error'])
1339 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1341 test "$ac_cv_func_link" = yes && AC_DEFINE(HAVE_LINK)
1342 test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
1345 dnl ---------------------------------------------------------------------------
1346 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1347 dnl options to lower-levels. It's very useful for "make -n" -- if we have it.
1348 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1349 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1350 AC_DEFUN([CF_MAKEFLAGS],
1352 AC_MSG_CHECKING([for makeflags variable])
1353 AC_CACHE_VAL(cf_cv_makeflags,[
1355 for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1357 cat >cf_makeflags.tmp <<CF_EOF
1359 @ echo '.$cf_option'
1361 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1362 case "$cf_result" in
1364 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1365 case "$cf_result" in
1366 .*CC=*) cf_cv_makeflags=
1368 *) cf_cv_makeflags=$cf_option
1373 *) echo no match "$cf_result"
1377 rm -f cf_makeflags.tmp])
1378 AC_MSG_RESULT($cf_cv_makeflags)
1379 AC_SUBST(cf_cv_makeflags)
1381 dnl ---------------------------------------------------------------------------
1382 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
1383 dnl a monocase filesystem.
1384 AC_DEFUN([CF_MAKE_TAGS],[
1385 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1386 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
1388 if test "$cf_cv_mixedcase" = yes ; then
1389 AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
1394 if test "$MAKE_UPPER_TAGS" = yes ; then
1399 AC_SUBST(MAKE_UPPER_TAGS)
1401 if test "$MAKE_LOWER_TAGS" = yes ; then
1406 AC_SUBST(MAKE_LOWER_TAGS)
1408 dnl ---------------------------------------------------------------------------
1409 dnl Option to allow user to override automatic configuration of manpage format.
1410 dnl There are several special cases.
1411 AC_DEFUN([CF_MANPAGE_FORMAT],
1413 AC_REQUIRE([CF_PATHSEP])
1414 AC_MSG_CHECKING(format of man-pages)
1416 AC_ARG_WITH(manpage-format,
1417 [ --with-manpage-format specify manpage-format: gzip/compress/BSDI/normal and
1418 optionally formatted, e.g., gzip,formatted],
1419 [cf_manpage_form=$withval],
1420 [cf_manpage_form=unknown])
1422 case ".$cf_manpage_form" in
1423 .gzip|.compress|.BSDI|.normal|.formatted) # (vi
1426 if test -z "$MANPATH" ; then
1427 MANPATH="/usr/man:/usr/share/man"
1429 # look for the 'date' man-page (it's most likely to be installed!)
1430 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
1431 cf_manpage_form=unknown
1432 for cf_dir in $MANPATH; do
1433 test -z "$cf_dir" && cf_dir=/usr/man
1434 for cf_name in $cf_dir/*/date.[[01]]* $cf_dir/*/date
1436 cf_test=`echo $cf_name | sed -e 's/*//'`
1437 if test "x$cf_test" = "x$cf_name" ; then
1439 *.gz) cf_manpage_form=gzip;;
1440 *.Z) cf_manpage_form=compress;;
1441 *.0) cf_manpage_form=BSDI,formatted;;
1442 *) cf_manpage_form=normal;;
1447 if test "$cf_manpage_form" != "unknown" ; then
1454 AC_MSG_WARN(Unexpected manpage-format)
1458 AC_MSG_RESULT($cf_manpage_form)
1460 dnl ---------------------------------------------------------------------------
1461 dnl The Debian people have their own naming convention for manpages. This
1462 dnl option lets us override the name of the file containing renaming, or
1463 dnl disable it altogether.
1464 AC_DEFUN([CF_MANPAGE_RENAMES],
1466 AC_MSG_CHECKING(for manpage renaming)
1468 AC_ARG_WITH(manpage-renames,
1469 [ --with-manpage-renames specify manpage-renaming],
1470 [cf_manpage_renames=$withval],
1471 [cf_manpage_renames=yes])
1473 case ".$cf_manpage_renames" in #(vi
1477 # Debian 'man' program?
1478 if test -f /etc/debian_version ; then
1479 cf_manpage_renames=`cd $srcdir && pwd`/man/man_db.renames
1481 cf_manpage_renames=no
1486 if test "$cf_manpage_renames" != no ; then
1487 if test ! -f $cf_manpage_renames ; then
1488 AC_MSG_ERROR(not a filename: $cf_manpage_renames)
1491 test ! -d man && mkdir man
1493 # Construct a sed-script to perform renaming within man-pages
1494 if test -n "$cf_manpage_renames" ; then
1495 test ! -d man && mkdir man
1496 $srcdir/man/make_sed.sh $cf_manpage_renames >man/edit_man.sed
1500 AC_MSG_RESULT($cf_manpage_renames)
1502 dnl ---------------------------------------------------------------------------
1503 dnl Some people expect each tool to make all aliases for manpages in the
1504 dnl man-directory. This accommodates the older, less-capable implementations
1505 dnl of 'man', and is optional.
1506 AC_DEFUN([CF_MANPAGE_SYMLINKS],
1508 AC_MSG_CHECKING(for manpage symlinks)
1510 AC_ARG_WITH(manpage-symlinks,
1511 [ --with-manpage-symlinks specify manpage-symlinks],
1512 [cf_manpage_symlinks=$withval],
1513 [cf_manpage_symlinks=yes])
1515 AC_MSG_RESULT($cf_manpage_symlinks)
1517 dnl ---------------------------------------------------------------------------
1518 dnl This option causes manpages to be run through tbl(1) to generate tables
1520 AC_DEFUN([CF_MANPAGE_TBL],
1522 AC_MSG_CHECKING(for manpage tbl)
1524 AC_ARG_WITH(manpage-tbl,
1525 [ --with-manpage-tbl specify manpage processing with tbl],
1526 [cf_manpage_tbl=$withval],
1527 [cf_manpage_tbl=no])
1529 AC_MSG_RESULT($cf_manpage_tbl)
1531 dnl ---------------------------------------------------------------------------
1532 dnl Try to determine if the man-pages on the system are compressed, and if
1533 dnl so, what format is used. Use this information to construct a script that
1534 dnl will install man-pages.
1535 AC_DEFUN([CF_MAN_PAGES],
1537 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
1543 if test "$prefix" = "NONE" ; then
1544 cf_prefix="$ac_default_prefix"
1549 case "$cf_manpage_form" in # (vi
1551 cf_subdir='$mandir/cat'
1555 cf_subdir='$mandir/man'
1560 test ! -d man && mkdir man
1561 cat >man/edit_man.sh <<CF_EOF
1563 # this script is generated by the configure-script
1566 TERMINFO="$TERMINFO"
1567 MKDIRS="`cd $srcdir && pwd`/mkinstalldirs"
1569 INSTALL_DATA="$INSTALL_DATA"
1570 transform="$program_transform_name"
1572 TMP=\${TMPDIR-/tmp}/man\$\$
1573 trap "rm -f \$TMP" 0 1 2 5 15
1586 *.orig|*.rej) ;; #(vi
1588 section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
1589 if test \$verb = installing ; then
1590 if test ! -d $cf_subdir\${section} ; then
1591 \$MKDIRS $cf_subdir\$section
1595 source=\`basename \$i\`
1597 test ! -f \$inalias && inalias="\$srcdir/\$inalias"
1598 if test ! -f \$inalias ; then
1599 echo .. skipped \$source
1603 if test "$cf_manpage_symlinks" = yes ; then
1604 cat >>man/edit_man.sh <<CF_EOF
1605 aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\`
1609 if test "$cf_manpage_renames" = no ; then
1610 cat >>man/edit_man.sh <<CF_EOF
1611 # perform program transformations for section 1 man pages
1612 if test \$section = 1 ; then
1613 target=$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\`
1615 target=$cf_subdir\${section}/\$source
1619 cat >>man/edit_man.sh <<CF_EOF
1620 target=\`grep "^\$source" $cf_manpage_renames | $AWK '{print \[$]2}'\`
1621 if test -z "\$target" ; then
1622 echo '? missing rename for '\$source
1625 target="$cf_subdir\${section}/\${target}"
1629 # replace variables in man page
1633 cat >>man/edit_man.sh <<CF_EOF
1634 prog_$cf_name=\`echo $cf_name|sed "\${transform}"\`
1638 cat >>man/edit_man.sh <<CF_EOF
1639 sed -e "s,@DATADIR@,\$datadir," \\
1640 -e "s,@TERMINFO@,\$TERMINFO," \\
1645 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
1646 cat >>man/edit_man.sh <<CF_EOF
1647 -e "s,@$cf_NAME@,\$prog_$cf_name," \\
1651 cat >>man/edit_man.sh <<CF_EOF
1654 if test $cf_manpage_tbl = yes ; then
1655 cat >>man/edit_man.sh <<CF_EOF
1656 tbl \$TMP >\$TMP.out
1660 if test $with_curses_h != yes ; then
1661 cat >>man/edit_man.sh <<CF_EOF
1662 sed -e "/\#[ ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
1666 if test $cf_format = yes ; then
1667 cat >>man/edit_man.sh <<CF_EOF
1668 nroff -man \$TMP >\$TMP.out
1672 case "$cf_manpage_form" in #(vi
1674 cat >>man/edit_man.sh <<CF_EOF
1675 if test \$verb = installing ; then
1676 if ( compress -f \$TMP )
1685 cat >>man/edit_man.sh <<CF_EOF
1686 if test \$verb = installing ; then
1687 if ( gzip -f \$TMP )
1692 target="\$target.gz"
1696 cat >>man/edit_man.sh <<CF_EOF
1697 # BSDI installs only .0 suffixes in the cat directories
1698 target="\`echo \$target|sed -e 's/\.[[1-9]]\+.\?/.0/'\`"
1702 cat >>man/edit_man.sh <<CF_EOF
1703 suffix=\`basename \$target | sed -e 's/^[[^.]]*//'\`
1704 if test \$verb = installing ; then
1705 echo \$verb \$target
1706 \$INSTALL_DATA \$TMP \$target
1707 test -n "\$aliases" && (
1708 cd $cf_subdir\${section} && (
1709 target=\`basename \$target\`
1710 for cf_alias in \$aliases
1712 if test \$section = 1 ; then
1713 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
1716 if test -f \$cf_alias\${suffix} ; then
1717 if ( cmp -s \$target \$cf_alias\${suffix} )
1721 echo .. \$verb alias \$cf_alias\${suffix}
1722 rm -f \$cf_alias\${suffix}
1723 $LN_S \$target \$cf_alias\${suffix}
1726 echo .. \$verb alias \$cf_alias\${suffix}
1727 rm -f \$cf_alias\${suffix}
1728 $LN_S \$target \$cf_alias\${suffix}
1733 elif test \$verb = removing ; then
1734 echo \$verb \$target
1736 test -n "\$aliases" && (
1737 cd $cf_subdir\${section} && (
1738 for cf_alias in \$aliases
1740 if test \$section = 1 ; then
1741 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
1744 echo .. \$verb alias \$cf_alias\${suffix}
1745 rm -f \$cf_alias\${suffix}
1758 chmod 755 man/edit_man.sh
1761 dnl ---------------------------------------------------------------------------
1762 dnl Checks for libraries. At least one UNIX system, Apple Macintosh
1763 dnl Rhapsody 5.5, does not have -lm. We cannot use the simpler
1764 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1765 AC_DEFUN([CF_MATH_LIB],
1767 AC_CACHE_CHECK(if -lm needed for math functions,
1773 [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
1774 [cf_cv_need_libm=no],
1775 [cf_cv_need_libm=yes])])
1776 if test "$cf_cv_need_libm" = yes
1783 dnl ---------------------------------------------------------------------------
1784 dnl Check if the file-system supports mixed-case filenames. If we're able to
1785 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1786 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1788 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1789 rm -f conftest CONFTEST
1791 if test -f CONFTEST ; then
1796 rm -f conftest CONFTEST
1798 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1800 dnl ---------------------------------------------------------------------------
1801 dnl Compute the object-directory name from the given model name
1802 AC_DEFUN([CF_OBJ_SUBDIR],
1805 libtool) $2='obj_lo' ;;
1806 normal) $2='objects' ;;
1807 debug) $2='obj_g' ;;
1808 profile) $2='obj_p' ;;
1809 shared) $2='obj_s' ;;
1812 dnl ---------------------------------------------------------------------------
1813 dnl Provide a value for the $PATH and similar separator
1814 AC_DEFUN([CF_PATHSEP],
1816 case $cf_cv_system_name in
1817 os2*) PATHSEP=';' ;;
1820 ifelse($1,,,[$1=$PATHSEP])
1823 dnl ---------------------------------------------------------------------------
1824 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
1825 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1826 dnl result begins with 'NONE'. This is necessary to workaround autoconf's
1827 dnl delayed evaluation of those symbols.
1828 AC_DEFUN([CF_PATH_SYNTAX],[
1829 case ".[$]$1" in #(vi
1832 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
1834 .\[$]{*prefix}*) #(vi
1836 case ".[$]$1" in #(vi
1838 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1843 $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1846 AC_ERROR(expected a pathname, not "[$]$1")
1850 dnl ---------------------------------------------------------------------------
1851 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1852 AC_DEFUN([CF_PROG_EXT],
1854 AC_REQUIRE([CF_CHECK_CACHE])
1856 case $cf_cv_system_name in
1858 # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@
1859 CFLAGS="$CFLAGS -Zmt"
1860 CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
1861 CXXFLAGS="$CXXFLAGS -Zmt"
1862 LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"`
1871 dnl ---------------------------------------------------------------------------
1872 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
1873 dnl misc/tabset install won't work properly. Usually this happens only when
1874 dnl using the fallback mkinstalldirs script
1875 AC_DEFUN([CF_PROG_INSTALL],
1881 CF_DIRNAME(cf_dir,$INSTALL)
1882 test -z "$cf_dir" && cf_dir=.
1883 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
1887 dnl ---------------------------------------------------------------------------
1888 dnl Attempt to determine if we've got one of the flavors of regular-expression
1889 dnl code that we can support.
1890 AC_DEFUN([CF_REGEX],
1892 AC_MSG_CHECKING([for regular-expression headers])
1893 AC_CACHE_VAL(cf_cv_regex,[
1894 AC_TRY_LINK([#include <sys/types.h>
1895 #include <regex.h>],[
1897 int x = regcomp(p, "", 0);
1898 int y = regexec(p, "", 0, 0, 0);
1900 ],[cf_cv_regex="regex.h"],[
1901 AC_TRY_LINK([#include <regexp.h>],[
1902 char *p = compile("", "", "", 0);
1903 int x = step("", "");
1904 ],[cf_cv_regex="regexp.h"],[
1905 cf_save_LIBS="$LIBS"
1907 AC_TRY_LINK([#include <regexpr.h>],[
1908 char *p = compile("", "", "");
1909 int x = step("", "");
1910 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
1912 AC_MSG_RESULT($cf_cv_regex)
1913 case $cf_cv_regex in
1914 regex.h) AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
1915 regexp.h) AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
1916 regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1919 dnl ---------------------------------------------------------------------------
1920 dnl Attempt to determine the appropriate CC/LD options for creating a shared
1923 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
1924 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
1925 dnl We avoid compiling-in a ../lib path for the shared library since that can
1926 dnl lead to unexpected results at runtime.
1927 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
1928 dnl are compiled in ../../lib
1930 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
1931 dnl to install symbolic links to the rel/abi versions of shared libraries.
1933 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
1934 dnl version when making symbolic links.
1936 dnl Some loaders leave 'so_locations' lying around. It's nice to clean up.
1937 AC_DEFUN([CF_SHARED_OPTS],
1939 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1943 INSTALL_LIB="-m 644"
1945 cf_cv_do_symlinks=no
1947 AC_MSG_CHECKING(if release/abi version should be used for shared libs)
1948 AC_ARG_WITH(shlib-version,
1949 [ --with-shlib-version=X Specify rel or abi version for shared libs],
1950 [test -z "$withval" && withval=auto
1951 case $withval in #(vi
1953 cf_cv_shlib_version=auto
1955 rel|abi|auto|no) #(vi
1956 cf_cv_shlib_version=$withval
1959 AC_ERROR([option value must be one of: rel, abi, auto or no])
1962 ],[cf_cv_shlib_version=auto])
1963 AC_MSG_RESULT($cf_cv_shlib_version)
1967 # Some less-capable ports of gcc support only -fpic
1969 if test "$GCC" = yes
1971 AC_MSG_CHECKING(which $CC option to use)
1972 cf_save_CFLAGS="$CFLAGS"
1973 for CC_SHARED_OPTS in -fPIC -fpic ''
1975 CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
1976 AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
1978 AC_MSG_RESULT($CC_SHARED_OPTS)
1979 CFLAGS="$cf_save_CFLAGS"
1982 case $cf_cv_system_name in
1984 MK_SHARED_LIB='$(CC) -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
1987 # (tested with gcc 2.7.2 -- I don't have c89)
1988 if test "$GCC" = yes; then
1989 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1992 LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1994 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]'
1995 # HP-UX shared libraries must be executable, and should be
1996 # readonly to exploit a quirk in the memory manager.
1997 INSTALL_LIB="-m 555"
2000 if test "$cf_cv_ld_rpath" = yes ; then
2001 cf_ld_rpath_opt="-Wl,-rpath,"
2002 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
2004 # tested with IRIX 5.2 and 'cc'.
2005 if test "$GCC" != yes; then
2006 CC_SHARED_OPTS='-KPIC'
2008 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
2009 cf_cv_rm_so_locs=yes
2012 if test "$DFT_LWR_MODEL" = "shared" ; then
2013 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
2014 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2016 if test "$cf_cv_ld_rpath" = yes ; then
2017 cf_ld_rpath_opt="-Wl,-rpath,"
2018 EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2020 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2021 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION),-stats,-lc -o $[@]'
2024 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2025 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
2028 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2029 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
2030 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2033 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2034 test "$cf_cv_ld_rpath" = yes && cf_ld_rpath_opt="-Wl,-rpath,"
2035 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
2036 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
2037 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2038 EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
2039 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
2040 if test "$cf_cv_shlib_version" = auto; then
2041 if test ! -f /usr/libexec/ld.elf_so; then
2042 cf_cv_shlib_version=rel
2046 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
2050 # tested with OSF/1 V3.2 and 'cc'
2051 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
2052 # link with shared libs).
2053 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`'
2056 MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
2059 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
2060 if test "$DFT_LWR_MODEL" = "shared" ; then
2061 LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
2062 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2064 if test "$cf_cv_ld_rpath" = yes ; then
2065 cf_ld_rpath_opt="-rpath"
2066 # EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2068 cf_cv_rm_so_locs=yes
2070 sco3.2v5*) # (also uw2* and UW7) hops 13-Apr-98
2071 # tested with osr5.0.5
2072 if test "$ac_cv_prog_gcc" != yes; then
2073 CC_SHARED_OPTS='-belf -KPIC'
2075 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o [$]@'
2076 if test "$cf_cv_ld_rpath" = yes ; then
2077 # only way is to set LD_RUN_PATH but no switch for it
2080 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2081 LINK_PROGS='LD_RUN_PATH=$(libdir)'
2082 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
2085 # tested with SunOS 4.1.1 and gcc 2.7.0
2086 if test "$ac_cv_prog_gcc" != yes; then
2087 CC_SHARED_OPTS='-KPIC'
2089 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]'
2090 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2093 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
2094 if test "$ac_cv_prog_gcc" != yes; then
2095 CC_SHARED_OPTS='-KPIC'
2097 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
2098 if test "$DFT_LWR_MODEL" = "shared" ; then
2099 LOCAL_LDFLAGS="-R `pwd`/lib:\$(libdir)"
2100 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2102 if test "$cf_cv_ld_rpath" = yes ; then
2103 cf_ld_rpath_opt="-R"
2104 EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2106 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2109 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
2110 if test "$ac_cv_prog_gcc" != yes; then
2111 CC_SHARED_OPTS='-KPIC'
2113 MK_SHARED_LIB='$(LD) -d y -G -o [$]@'
2116 CC_SHARED_OPTS='unknown'
2117 MK_SHARED_LIB='echo unknown'
2121 # This works if the last tokens in $MK_SHARED_LIB are the -o target.
2122 case "$cf_cv_shlib_version" in #(vi
2124 case "$MK_SHARED_LIB" in #(vi
2126 test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
2129 AC_MSG_WARN(ignored --with-shlib-version)
2135 if test -n "$cf_ld_rpath_opt" ; then
2136 AC_MSG_CHECKING(if we need a space after rpath option)
2137 cf_save_LIBS="$LIBS"
2138 LIBS="$LIBS ${cf_ld_rpath_opt}$libdir"
2139 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2140 LIBS="$cf_save_LIBS"
2141 AC_MSG_RESULT($cf_rpath_space)
2142 test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
2143 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
2146 AC_SUBST(CC_SHARED_OPTS)
2147 AC_SUBST(LD_SHARED_OPTS)
2148 AC_SUBST(MK_SHARED_LIB)
2149 AC_SUBST(LINK_PROGS)
2150 AC_SUBST(LINK_TESTS)
2151 AC_SUBST(EXTRA_LDFLAGS)
2152 AC_SUBST(LOCAL_LDFLAGS)
2153 AC_SUBST(LOCAL_LDFLAGS2)
2154 AC_SUBST(INSTALL_LIB)
2156 dnl ---------------------------------------------------------------------------
2157 dnl Check for definitions & structures needed for window size-changing
2158 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
2159 AC_DEFUN([CF_SIZECHANGE],
2161 AC_REQUIRE([CF_STRUCT_TERMIOS])
2162 AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
2163 cf_cv_sizechange=unknown
2164 cf_save_CPPFLAGS="$CPPFLAGS"
2166 for cf_opts in "" "NEED_PTEM_H"
2169 CPPFLAGS="$cf_save_CPPFLAGS"
2170 test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
2171 AC_TRY_COMPILE([#include <sys/types.h>
2172 #ifdef HAVE_TERMIOS_H
2173 #include <termios.h>
2175 #ifdef HAVE_TERMIO_H
2180 /* This is a workaround for SCO: they neglected to define struct winsize in
2181 * termios.h -- it's only in termio.h and ptem.h
2183 #include <sys/stream.h>
2184 #include <sys/ptem.h>
2186 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
2187 #include <sys/ioctl.h>
2191 struct ttysize win; /* FIXME: what system is this? */
2192 int y = win.ts_lines;
2193 int x = win.ts_cols;
2200 no TIOCGSIZE or TIOCGWINSZ
2201 #endif /* TIOCGWINSZ */
2202 #endif /* TIOCGSIZE */
2204 [cf_cv_sizechange=yes],
2205 [cf_cv_sizechange=no])
2207 CPPFLAGS="$cf_save_CPPFLAGS"
2208 if test "$cf_cv_sizechange" = yes ; then
2209 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
2210 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
2215 if test "$cf_cv_sizechange" != no ; then
2216 AC_DEFINE(HAVE_SIZECHANGE)
2217 case $cf_cv_sizechange in #(vi
2219 AC_DEFINE_UNQUOTED($cf_cv_sizechange )
2224 dnl ---------------------------------------------------------------------------
2225 dnl For each parameter, test if the source-directory exists, and if it contains
2226 dnl a 'modules' file. If so, add to the list $cf_cv_src_modules which we'll
2227 dnl use in CF_LIB_RULES.
2229 dnl This uses the configured value to make the lists SRC_SUBDIRS and
2230 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
2231 AC_DEFUN([CF_SRC_MODULES],
2233 AC_MSG_CHECKING(for src modules)
2235 # dependencies and linker-arguments for test-programs
2236 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
2237 if test "$DFT_LWR_MODEL" = "libtool"; then
2238 TEST_ARGS="${TEST_DEPS}"
2240 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
2243 # dependencies and linker-arguments for utility-programs
2244 PROG_ARGS="$TEST_ARGS"
2249 if test -f $srcdir/$cf_dir/modules; then
2251 # We may/may not have tack in the distribution, though the
2253 if test $cf_dir = tack ; then
2254 if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
2259 if test -z "$cf_cv_src_modules"; then
2260 cf_cv_src_modules=$cf_dir
2262 cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
2265 # Make the ncurses_cfg.h file record the library interface files as
2266 # well. These are header files that are the same name as their
2267 # directory. Ncurses is the only library that does not follow
2269 if test $cf_dir = tack ; then
2271 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
2272 CF_UPPER(cf_have_include,$cf_dir)
2273 AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
2274 AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
2275 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
2276 if test "$DFT_LWR_MODEL" = "libtool"; then
2277 TEST_ARGS="${TEST_DEPS}"
2279 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
2284 AC_MSG_RESULT($cf_cv_src_modules)
2285 TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS"
2289 PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS"
2292 SRC_SUBDIRS="man include"
2293 for cf_dir in $cf_cv_src_modules
2295 SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
2297 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
2298 test "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
2301 if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
2302 SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
2303 ADA_SUBDIRS="gen src samples"
2307 for cf_dir in $SRC_SUBDIRS
2309 SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
2312 if test -n "$ADA_SUBDIRS"; then
2313 for cf_dir in $ADA_SUBDIRS
2315 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
2317 AC_SUBST(ADA_SUBDIRS)
2320 dnl ---------------------------------------------------------------------------
2321 dnl Check for -lstdc++, which is GNU's standard C++ library.
2322 AC_DEFUN([CF_STDCPP_LIBRARY],
2324 if test -n "$GXX" ; then
2325 case $cf_cv_system_name in #(vi
2327 cf_stdcpp_libname=stdcpp
2330 cf_stdcpp_libname=stdc++
2333 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
2335 LIBS="$LIBS -l$cf_stdcpp_libname"
2337 #include <strstream.h>],[
2339 strstreambuf foo(buf, sizeof(buf))
2341 [cf_cv_libstdcpp=yes],
2342 [cf_cv_libstdcpp=no])
2345 test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
2348 dnl ---------------------------------------------------------------------------
2349 dnl Remove "-g" option from the compiler options
2350 AC_DEFUN([CF_STRIP_G_OPT],
2351 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
2352 dnl ---------------------------------------------------------------------------
2353 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction. We'll only
2354 dnl do this if we've found the sigaction function.
2356 dnl If needed, define SVR4_ACTION.
2357 AC_DEFUN([CF_STRUCT_SIGACTION],[
2358 if test "$ac_cv_func_sigaction" = yes; then
2359 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
2361 #include <sys/types.h>
2362 #include <signal.h>],
2363 [struct sigaction act],
2367 #define _POSIX_SOURCE
2368 #include <sys/types.h>
2369 #include <signal.h>],
2370 [struct sigaction act],
2372 AC_DEFINE(SVR4_ACTION)],
2373 [sigact_bad=unknown])])
2374 AC_MSG_RESULT($sigact_bad)
2377 dnl ---------------------------------------------------------------------------
2378 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
2379 dnl If so, define SVR4_TERMIO
2380 AC_DEFUN([CF_STRUCT_TERMIOS],[
2386 if test "$ISC" = yes ; then
2387 AC_CHECK_HEADERS( sys/termio.h )
2389 if test "$ac_cv_header_termios_h" = yes ; then
2390 case "$CFLAGS $CPPFLAGS" in
2392 termios_bad=dunno ;;
2393 *) termios_bad=maybe ;;
2395 if test "$termios_bad" = maybe ; then
2396 AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
2397 AC_TRY_COMPILE([#include <termios.h>],
2398 [struct termios foo; int x = foo.c_iflag],
2401 #define _POSIX_SOURCE
2402 #include <termios.h>],
2403 [struct termios foo; int x = foo.c_iflag],
2404 termios_bad=unknown,
2405 termios_bad=yes AC_DEFINE(SVR4_TERMIO))
2407 AC_MSG_RESULT($termios_bad)
2411 dnl ---------------------------------------------------------------------------
2412 dnl Shorthand macro for substituting things that the user may override
2413 dnl with an environment variable.
2415 dnl $1 = long/descriptive name
2416 dnl $2 = environment variable
2417 dnl $3 = default value
2418 AC_DEFUN([CF_SUBST],
2419 [AC_CACHE_VAL(cf_cv_subst_$2,[
2420 AC_MSG_CHECKING(for $1 (symbol $2))
2421 test -z "[$]$2" && $2=$3
2422 AC_MSG_RESULT([$]$2)
2424 cf_cv_subst_$2=[$]$2])
2425 $2=${cf_cv_subst_$2}
2427 dnl ---------------------------------------------------------------------------
2428 dnl Get the version-number for use in shared-library naming, etc.
2429 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
2431 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[[ ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
2432 NCURSES_MINOR="`egrep '^NCURSES_MINOR[[ ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
2433 NCURSES_PATCH="`egrep '^NCURSES_PATCH[[ ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
2434 cf_cv_abi_version=${NCURSES_MAJOR}
2435 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
2436 dnl Show the computed version, for logging
2437 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`))
2438 dnl We need these values in the generated headers
2439 AC_SUBST(NCURSES_MAJOR)
2440 AC_SUBST(NCURSES_MINOR)
2441 AC_SUBST(NCURSES_PATCH)
2442 dnl We need these values in the generated makefiles
2443 AC_SUBST(cf_cv_rel_version)
2444 AC_SUBST(cf_cv_abi_version)
2445 AC_SUBST(cf_cv_cc_bool_type)
2446 AC_SUBST(cf_cv_builtin_bool)
2447 AC_SUBST(cf_cv_type_of_bool)dnl
2449 dnl ---------------------------------------------------------------------------
2450 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2451 dnl older SCO configurations.
2452 AC_DEFUN([CF_SYS_TIME_SELECT],
2454 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2455 AC_CACHE_VAL(cf_cv_sys_time_select,[
2457 #include <sys/types.h>
2458 #ifdef HAVE_SYS_TIME_H
2459 #include <sys/time.h>
2461 #ifdef HAVE_SYS_SELECT_H
2462 #include <sys/select.h>
2464 ],[],[cf_cv_sys_time_select=yes],
2465 [cf_cv_sys_time_select=no])
2467 AC_MSG_RESULT($cf_cv_sys_time_select)
2468 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
2470 dnl ---------------------------------------------------------------------------
2471 dnl Determine the type we should use for chtype (and attr_t, which is treated
2472 dnl as the same thing). We want around 32 bits, so on most machines want a
2473 dnl long, but on newer 64-bit machines, probably want an int. If we're using
2474 dnl wide characters, we have to have a type compatible with that, as well.
2475 AC_DEFUN([CF_TYPEOF_CHTYPE],
2477 AC_REQUIRE([CF_UNSIGNED_LITERALS])
2478 AC_MSG_CHECKING([for type of chtype])
2479 AC_CACHE_VAL(cf_cv_typeof_chtype,[
2481 #ifdef USE_WIDEC_SUPPORT
2482 #include <stddef.h> /* we want wchar_t */
2483 #define WANT_BITS 39
2485 #define WANT_BITS 31
2490 FILE *fp = fopen("cf_test.out", "w");
2492 char *result = "long";
2493 #ifdef USE_WIDEC_SUPPORT
2495 * If wchar_t is smaller than a long, it must be an int or a
2496 * short. We prefer not to use a short anyway.
2498 if (sizeof(unsigned long) > sizeof(wchar_t))
2501 if (sizeof(unsigned long) > sizeof(unsigned int)) {
2504 for (n = 0; n < WANT_BITS; n++) {
2505 unsigned int y = (x >> n);
2506 if (y != 1 || x == 0) {
2512 * If x is nonzero, an int is big enough for the bits
2515 result = (x != 0) ? "int" : "long";
2523 [cf_cv_typeof_chtype=`cat cf_test.out`],
2524 [cf_cv_typeof_chtype=long],
2525 [cf_cv_typeof_chtype=long])
2528 AC_MSG_RESULT($cf_cv_typeof_chtype)
2530 AC_SUBST(cf_cv_typeof_chtype)
2531 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
2534 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
2535 test "$cf_cv_typeof_chtype" = long && cf_cv_1UL="${cf_cv_1UL}L"
2539 dnl ---------------------------------------------------------------------------
2541 AC_DEFUN([CF_TYPE_SIGACTION],
2543 AC_MSG_CHECKING([for type sigaction_t])
2544 AC_CACHE_VAL(cf_cv_type_sigaction,[
2546 #include <signal.h>],
2548 [cf_cv_type_sigaction=yes],
2549 [cf_cv_type_sigaction=no])])
2550 AC_MSG_RESULT($cf_cv_type_sigaction)
2551 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
2553 dnl ---------------------------------------------------------------------------
2554 dnl Test if the compiler supports 'U' and 'L' suffixes. Only old compilers
2555 dnl won't, but they're still there.
2556 AC_DEFUN([CF_UNSIGNED_LITERALS],
2558 AC_MSG_CHECKING([if unsigned literals are legal])
2559 AC_CACHE_VAL(cf_cv_unsigned_literals,[
2560 AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
2561 [cf_cv_unsigned_literals=yes],
2562 [cf_cv_unsigned_literals=no])
2564 AC_MSG_RESULT($cf_cv_unsigned_literals)
2566 dnl ---------------------------------------------------------------------------
2567 dnl Make an uppercase version of a variable
2568 dnl $1=uppercase($2)
2569 AC_DEFUN([CF_UPPER],
2571 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2573 dnl ---------------------------------------------------------------------------
2574 dnl Compute the shift-mask that we'll use for wide-character indices. We use
2575 dnl all but the index portion of chtype for storing attributes.
2576 AC_DEFUN([CF_WIDEC_SHIFT],
2578 AC_REQUIRE([CF_TYPEOF_CHTYPE])
2579 AC_MSG_CHECKING([for number of bits in chtype])
2580 AC_CACHE_VAL(cf_cv_shift_limit,[
2585 FILE *fp = fopen("cf_test.out", "w");
2588 unsigned TYPEOF_CHTYPE x = 1L;
2589 for (n = 0; ; n++) {
2590 unsigned long y = (x >> n);
2591 if (y != 1 || x == 0)
2595 fprintf(fp, "%d", n);
2601 [cf_cv_shift_limit=`cat cf_test.out`],
2602 [cf_cv_shift_limit=32],
2603 [cf_cv_shift_limit=32])
2606 AC_MSG_RESULT($cf_cv_shift_limit)
2607 AC_SUBST(cf_cv_shift_limit)
2609 AC_MSG_CHECKING([for width of character-index])
2610 AC_CACHE_VAL(cf_cv_widec_shift,[
2611 if test ".$with_widec" = ".yes" ; then
2613 if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
2615 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
2617 cf_cv_widec_shift=16
2623 AC_MSG_RESULT($cf_cv_widec_shift)
2624 AC_SUBST(cf_cv_widec_shift)
2626 dnl ---------------------------------------------------------------------------
2627 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2628 dnl defaulting to yes/no.
2630 dnl $1 = option name
2632 dnl $3 = environment variable to set
2633 dnl $4 = default value, shown in the help-message, must be a constant
2634 dnl $5 = default value, if it's an expression & cannot be in the help-message
2636 AC_DEFUN([CF_WITH_PATH],
2637 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2638 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2639 CF_PATH_SYNTAX(withval)
2643 dnl ---------------------------------------------------------------------------
2644 dnl Process an option specifying a list of colon-separated paths.
2646 dnl $1 = option name
2648 dnl $3 = environment variable to set
2649 dnl $4 = default value, shown in the help-message, must be a constant
2650 dnl $5 = default value, if it's an expression & cannot be in the help-message
2652 AC_DEFUN([CF_WITH_PATHLIST],[
2653 AC_REQUIRE([CF_PATHSEP])
2654 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2655 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2657 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
2659 for cf_src_path in $withval
2661 CF_PATH_SYNTAX(cf_src_path)
2662 test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
2663 cf_dst_path="${cf_dst_path}${cf_src_path}"
2667 eval $3="$cf_dst_path"