1 dnl***************************************************************************
2 dnl Copyright (c) 1998 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.121 1998/02/11 12:13:40 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 Test if 'bool' is a builtin type in the configured C++ compiler. Some
59 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
60 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
62 dnl Treat the configuration-variable specially here, since we're directly
63 dnl substituting its value (i.e., 1/0).
64 AC_DEFUN([CF_BOOL_DECL],
66 AC_MSG_CHECKING([for builtin c++ bool type])
67 AC_CACHE_VAL(cf_cv_builtin_bool,[
68 AC_TRY_COMPILE([],[bool x = false],
69 [cf_cv_builtin_bool=1],
70 [cf_cv_builtin_bool=0])
72 if test $cf_cv_builtin_bool = 1
73 then AC_MSG_RESULT(yes)
74 else AC_MSG_RESULT(no)
77 dnl ---------------------------------------------------------------------------
78 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
79 dnl Don't bother looking for bool.h, since it's been deprecated.
80 AC_DEFUN([CF_BOOL_SIZE],
82 AC_MSG_CHECKING([for size of c++ bool])
83 AC_CACHE_VAL(cf_cv_type_of_bool,[
93 FILE *fp = fopen("cf_test.out", "w");
97 fputs("unsigned ", fp);
98 if (sizeof(x) == sizeof(int)) fputs("int", fp);
99 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
100 else if (sizeof(x) == sizeof(short))fputs("short",fp);
101 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
107 [cf_cv_type_of_bool=`cat cf_test.out`],
108 [cf_cv_type_of_bool=unknown],
109 [cf_cv_type_of_bool=unknown])
112 AC_MSG_RESULT($cf_cv_type_of_bool)
113 if test "$cf_cv_type_of_bool" = unknown ; then
114 AC_MSG_WARN(Assuming unsigned for type of bool)
115 cf_cv_type_of_bool=unsigned
118 dnl ---------------------------------------------------------------------------
119 dnl Determine the default configuration into which we'll install ncurses. This
120 dnl can be overridden by the user's command-line options. There's two items to
122 dnl 1. the prefix (e.g., /usr)
123 dnl 2. the header files (e.g., /usr/include/ncurses)
124 dnl We'll look for a previous installation of ncurses and use the same defaults.
126 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
127 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
128 dnl programs from a vendor's.
129 AC_DEFUN([CF_CFG_DEFAULTS],
131 AC_MSG_CHECKING(for prefix)
132 if test "x$prefix" = "xNONE" ; then
133 case "$cf_cv_system_name" in
134 # non-vendor systems don't have a conflict
135 openbsd*|netbsd*|freebsd*|linux*)
138 *) prefix=$ac_default_prefix
142 AC_MSG_RESULT($prefix)
144 if test "x$prefix" = "xNONE" ; then
145 AC_MSG_CHECKING(for default include-directory)
146 test -n "$verbose" && echo 1>&AC_FD_MSG
149 $includedir/ncurses \
151 $prefix/include/ncurses \
153 /usr/local/include/ncurses \
157 cf_dir=`eval echo $cf_symbol`
158 if test -f $cf_dir/curses.h ; then
159 if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
160 includedir="$cf_symbol"
161 test -n "$verbose" && echo $ac_n " found " 1>&AC_FD_MSG
165 test -n "$verbose" && echo " tested $cf_dir" 1>&AC_FD_MSG
167 AC_MSG_RESULT($includedir)
170 dnl ---------------------------------------------------------------------------
171 dnl Check for data that is usually declared in <stdio.h> or <errno.h>
172 dnl $1 = the name to check
173 AC_DEFUN([CF_CHECK_ERRNO],
175 AC_MSG_CHECKING([declaration of $1])
176 AC_CACHE_VAL(cf_cv_dcl_$1,[
179 #include <sys/types.h>
180 #include <errno.h> ],
181 [long x = (long) $1],
182 [eval 'cf_cv_dcl_'$1'=yes'],
183 [eval 'cf_cv_dcl_'$1'=no]')])
184 eval 'cf_result=$cf_cv_dcl_'$1
185 AC_MSG_RESULT($cf_result)
187 # It's possible (for near-UNIX clones) that the data doesn't exist
188 AC_CACHE_VAL(cf_cv_have_$1,[
189 if test $cf_result = no ; then
190 eval 'cf_result=DECL_'$1
191 CF_UPPER(cf_result,$cf_result)
192 AC_DEFINE_UNQUOTED($cf_result)
193 AC_MSG_CHECKING([existence of $1])
199 [eval 'cf_cv_have_'$1'=yes'],
200 [eval 'cf_cv_have_'$1'=no'])
201 eval 'cf_result=$cf_cv_have_'$1
202 AC_MSG_RESULT($cf_result)
204 eval 'cf_cv_have_'$1'=yes'
207 eval 'cf_result=HAVE_'$1
208 CF_UPPER(cf_result,$cf_result)
209 eval 'test $cf_cv_have_'$1' = yes && AC_DEFINE_UNQUOTED($cf_result)'
211 dnl ---------------------------------------------------------------------------
212 dnl Check if the terminal-capability database functions are available. If not,
213 dnl ncurses has a much-reduced version.
214 AC_DEFUN([CF_CGETENT],[
215 AC_MSG_CHECKING(for terminal-capability database functions)
216 AC_CACHE_VAL(cf_cv_cgetent,[
218 #include <stdlib.h>],[
221 char *db_array = temp;
222 cgetent(&buf, /* int *, */ &db_array, "vt100");
223 cgetcap(buf, "tc", '=');
224 cgetmatch(buf, "tc");
229 AC_MSG_RESULT($cf_cv_cgetent)
230 test $cf_cv_cgetent = yes && AC_DEFINE(HAVE_BSD_CGETENT)
232 dnl ---------------------------------------------------------------------------
233 dnl Check if we're accidentally using a cache from a different machine.
234 dnl Derive the system name, as a check for reusing the autoconf cache.
236 dnl If we've packaged config.guess and config.sub, run that (since it does a
237 dnl better job than uname).
238 AC_DEFUN([CF_CHECK_CACHE],
240 if test -f $srcdir/config.guess ; then
242 system_name="$host_os"
244 system_name="`(uname -s -r) 2>/dev/null`"
245 if test -z "$system_name" ; then
246 system_name="`(hostname) 2>/dev/null`"
249 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
250 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
252 test -z "$system_name" && system_name="$cf_cv_system_name"
253 test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name")
255 if test ".$system_name" != ".$cf_cv_system_name" ; then
256 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
257 AC_ERROR("Please remove config.cache and try again.")
260 dnl ---------------------------------------------------------------------------
261 dnl If we're trying to use g++, test if libg++ is installed (a rather common
262 dnl problem :-). If we have the compiler but no library, we'll be able to
263 dnl configure, but won't be able to build the c++ demo program.
264 AC_DEFUN([CF_CXX_LIBRARY],
266 cf_cxx_library=unknown
267 if test $ac_cv_prog_gxx = yes; then
268 AC_MSG_CHECKING([for libg++])
270 LIBS="$LIBS -lg++ -lm"
274 [float foo=abs(1.0)],
276 CXXLIBS="$CXXLIBS -lg++ -lm"],
279 AC_MSG_RESULT($cf_cxx_library)
282 dnl ---------------------------------------------------------------------------
283 AC_DEFUN([CF_DIRS_TO_MAKE],
286 for cf_item in $cf_list_models
288 CF_OBJ_SUBDIR($cf_item,cf_subdir)
289 DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
291 for cf_dir in $DIRS_TO_MAKE
293 test ! -d $cf_dir && mkdir $cf_dir
295 AC_SUBST(DIRS_TO_MAKE)
297 dnl ---------------------------------------------------------------------------
298 dnl Check if 'errno' is declared in <errno.h>
301 CF_CHECK_ERRNO(errno)
303 dnl ---------------------------------------------------------------------------
304 dnl Test for availability of useful gcc __attribute__ directives to quiet
305 dnl compiler warnings. Though useful, not all are supported -- and contrary
306 dnl to documentation, unrecognized directives cause older compilers to barf.
307 AC_DEFUN([CF_GCC_ATTRIBUTES],
311 cat > conftest.i <<EOF
319 #define GCC_NORETURN /* nothing */
322 #define GCC_UNUSED /* nothing */
327 AC_CHECKING([for gcc __attribute__ directives])
329 cat > conftest.$ac_ext <<EOF
330 #line __oline__ "configure"
331 #include "confdefs.h"
332 #include "conftest.h"
333 #include "conftest.i"
335 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
337 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
340 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
342 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
344 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
345 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
346 extern void foo(void) GCC_NORETURN;
347 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
350 for cf_attribute in scanf printf unused noreturn
352 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
353 cf_directive="__attribute__(($cf_attribute))"
354 echo "checking for gcc $cf_directive" 1>&AC_FD_CC
355 case $cf_attribute in
357 cat >conftest.h <<EOF
358 #define GCC_$CF_ATTRIBUTE 1
362 cat >conftest.h <<EOF
363 #define GCC_$CF_ATTRIBUTE $cf_directive
367 if AC_TRY_EVAL(ac_compile); then
368 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
369 cat conftest.h >>confdefs.h
371 # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
375 fgrep define conftest.i >>confdefs.h
380 dnl ---------------------------------------------------------------------------
381 dnl Check if the compiler supports useful warning options. There's a few that
382 dnl we don't use, simply because they're too noisy:
384 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
385 dnl -Wredundant-decls (system headers make this too noisy)
386 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
387 dnl -Wwrite-strings (too noisy, but should review occasionally)
390 AC_DEFUN([CF_GCC_WARNINGS],
395 cat > conftest.$ac_ext <<EOF
396 #line __oline__ "configure"
397 int main(int argc, char *argv[]) { return argv[argc-1] == 0; }
400 AC_CHECKING([for gcc warning options])
401 cf_save_CFLAGS="$CFLAGS"
402 EXTRA_CFLAGS="-W -Wall"
404 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
410 Wmissing-declarations \
411 Wmissing-prototypes \
415 Wstrict-prototypes $cf_warn_CONST
417 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
418 if AC_TRY_EVAL(ac_compile); then
419 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
420 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
421 test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
425 CFLAGS="$cf_save_CFLAGS"
427 AC_SUBST(EXTRA_CFLAGS)
429 dnl ---------------------------------------------------------------------------
430 dnl Verify Version of GNAT.
431 AC_DEFUN([CF_GNAT_VERSION],
433 changequote(<<, >>)dnl
434 cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
435 sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'`
436 case $cf_cv_gnat_version in
438 ac_cv_prog_gnat_correct=yes
440 *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.10 or better. Disabling Ada95 binding.
441 ac_cv_prog_gnat_correct=no
444 case $cf_cv_gnat_version in
446 cf_compile_generics=generics
448 *) cf_compile_generics=
453 dnl ---------------------------------------------------------------------------
454 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
455 AC_DEFUN([CF_HELP_MESSAGE],
456 [AC_DIVERT_HELP([$1])dnl
458 dnl ---------------------------------------------------------------------------
459 dnl Construct the list of include-options according to whether we're building
460 dnl in the source directory or using '--srcdir=DIR' option. If we're building
461 dnl with gcc, don't append the includedir if it happens to be /usr/include,
462 dnl since that usually breaks gcc's shadow-includes.
463 AC_DEFUN([CF_INCLUDE_DIRS],
465 CPPFLAGS="$CPPFLAGS -I. -I../include"
466 if test "$srcdir" != "."; then
467 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
469 if test -z "$GCC"; then
470 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
471 elif test "$includedir" != "/usr/include"; then
472 if test "$includedir" = '${prefix}/include' ; then
473 if test $prefix != /usr ; then
474 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
477 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
482 dnl ---------------------------------------------------------------------------
483 dnl Check if we have either a function or macro for 'isascii()'.
484 AC_DEFUN([CF_ISASCII],
486 AC_MSG_CHECKING(for isascii)
487 AC_CACHE_VAL(cf_cv_have_isascii,[
488 AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
489 [cf_cv_have_isascii=yes],
490 [cf_cv_have_isascii=no])
492 AC_MSG_RESULT($cf_cv_have_isascii)
493 test $cf_cv_have_isascii = yes && AC_DEFINE(HAVE_ISASCII)
495 dnl ---------------------------------------------------------------------------
496 dnl Append definitions and rules for the given models to the subdirectory
497 dnl Makefiles, and the recursion rule for the top-level Makefile. If the
498 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
499 dnl the corresponding makefile to list the models that we'll generate.
501 dnl For shared libraries, make a list of symbolic links to construct when
502 dnl generating each library. The convention used for Linux is the simplest
505 dnl lib<name>.so.<major> ->
506 dnl lib<name>.so.<maj>.<minor>
507 AC_DEFUN([CF_LIB_RULES],
509 CF_LIB_PREFIX(cf_prefix)
510 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
511 for cf_dir in $SRC_SUBDIRS
513 if test -f $srcdir/$cf_dir/modules; then
516 for cf_item in $CF_LIST_MODELS
518 CF_LIB_SUFFIX($cf_item,cf_suffix)
519 cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
522 if test $cf_dir = ncurses ; then
523 case "$LIB_SUBSETS" in
527 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g`
528 cf_libs_to_make="$cf_libs_to_make $cf_item"
533 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \
534 $cf_dir/Makefile >$cf_dir/Makefile.out
535 mv $cf_dir/Makefile.out $cf_dir/Makefile
537 $AWK -f $srcdir/mk-0th.awk \
539 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
541 for cf_item in $CF_LIST_MODELS
543 echo 'Appending rules for '$cf_item' model ('$cf_dir')'
544 CF_UPPER(CF_ITEM,$cf_item)
545 CF_LIB_SUFFIX($cf_item,cf_suffix)
546 CF_OBJ_SUBDIR($cf_item,cf_subdir)
548 # These dependencies really are for development, not
549 # builds, but they are useful in porting, too.
550 cf_depend="../include/ncurses_cfg.h"
551 if test "$srcdir" = "."; then
554 cf_reldir="\$(srcdir)"
557 if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
558 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
559 elif test -f $srcdir/$cf_dir/curses.priv.h; then
560 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
563 for cf_subset in $LIB_SUBSETS
565 $AWK -f $srcdir/mk-1st.awk \
572 DoLinks=$cf_cv_do_symlinks \
573 rmSoLocs=$cf_cv_rm_so_locs \
574 ldconfig="$LDCONFIG" \
575 overwrite=$WITH_OVERWRITE \
576 depend="$cf_depend" \
578 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
579 test $cf_dir = ncurses && WITH_OVERWRITE=no
580 $AWK -f $srcdir/mk-2nd.awk \
587 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
592 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
595 for cf_dir in $SRC_SUBDIRS
597 if test -f $cf_dir/Makefile ; then
600 echo 'install.libs \' >> Makefile
601 echo 'uninstall.libs ::' >> Makefile
602 echo ' cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
607 if test -f $srcdir/$cf_dir/modules; then
609 if test -f $srcdir/$cf_dir/headers; then
610 cat >> Makefile <<CF_EOF
612 uninstall.includes \\
615 if test "$cf_dir" != "c++" ; then
616 echo 'lint \' >> Makefile
618 cat >> Makefile <<CF_EOF
624 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
626 elif test -f $srcdir/$cf_dir/headers; then
627 cat >> Makefile <<CF_EOF
632 uninstall.includes ::
633 cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
638 cat >> Makefile <<CF_EOF
641 cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
644 cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
647 rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
648 rm -f headers.sh headers.sed
649 rm -rf \$(DIRS_TO_MAKE)
652 dnl If we're installing into a subdirectory of /usr/include, etc., we should
653 dnl prepend the subdirectory's name to the "#include" paths. It won't hurt
654 dnl anything, and will make it more standardized. It's awkward to decide this
655 dnl at configuration because of quoting, so we'll simply make all headers
656 dnl installed via a script that can do the right thing.
658 rm -f headers.sed headers.sh
660 dnl ( generating this script makes the makefiles a little tidier :-)
661 echo creating headers.sh
662 cat >headers.sh <<CF_EOF
664 # This shell script is generated by the 'configure' script. It is invoked in a
665 # subdirectory of the build tree. It generates a sed-script in the parent
666 # directory that is used to adjust includes for header files that reside in a
667 # subdirectory of /usr/include, etc.
669 while test \[$]# != 3
671 PRG="\$PRG \[$]1"; shift
676 echo installing \$SRC in \$DST
679 TMP=\${TMPDIR-/tmp}/\`basename \$SRC\`
680 if test ! -f ../headers.sed ; then
681 END=\`basename \$DST\`
682 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
684 NAME=\`basename \$i\`
685 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> ../headers.sed
689 sed -f ../headers.sed \$SRC > \$TMP
690 eval \$PRG \$TMP \$DST
694 eval \$PRG \$SRC \$DST
699 chmod 0755 headers.sh
701 for cf_dir in $SRC_SUBDIRS
703 if test -f $srcdir/$cf_dir/headers; then
704 cat >>$cf_dir/Makefile <<CF_EOF
705 \$(INSTALL_PREFIX)\$(includedir) :
706 \$(srcdir)/../mkinstalldirs \[$]@
710 install.includes :: \$(INSTALL_PREFIX)\$(includedir) \\
713 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
715 test -n "$j" && echo " $j \\" >>$cf_dir/Makefile
718 echo " $j" >>$cf_dir/Makefile
719 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
721 echo " @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(INSTALL_PREFIX)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
722 test $i = curses.h && echo " @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
725 cat >>$cf_dir/Makefile <<CF_EOF
729 uninstall.includes ::
731 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
734 echo " -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
735 test $i = curses.h && echo " -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
741 dnl ---------------------------------------------------------------------------
742 dnl Compute the library-prefix for the given host system
743 dnl $1 = variable to set
744 AC_DEFUN([CF_LIB_PREFIX],
746 case $cf_cv_system_name in
751 dnl ---------------------------------------------------------------------------
752 dnl Compute the library-suffix from the given model name
754 dnl $2 = variable to set
755 AC_DEFUN([CF_LIB_SUFFIX],
757 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
761 profile) $2='_p.a' ;;
763 case $cf_cv_system_name in
764 openbsd*|netbsd*|freebsd*)
765 $2='.so.$(REL_VERSION)' ;;
771 dnl ---------------------------------------------------------------------------
772 dnl Compute the string to append to -library from the given model name
773 AC_DEFUN([CF_LIB_TYPE],
782 dnl ---------------------------------------------------------------------------
783 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
784 dnl only data (i.e., no functions), for example NeXT. On those systems we'll
785 dnl have to provide wrappers for global tables to ensure they're linked
787 AC_DEFUN([CF_LINK_DATAONLY],
789 AC_MSG_CHECKING([if data-only library module links])
790 AC_CACHE_VAL(cf_cv_link_dataonly,[
793 cat >conftest.$ac_ext <<EOF
794 #line __oline__ "configure"
795 int testdata[3] = { 123, 456, 789 };
798 if AC_TRY_EVAL(ac_compile) ; then
799 mv conftest.o data.o && \
800 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
802 rm -f conftest.$ac_ext data.o
804 cat >conftest.$ac_ext <<EOF
805 #line __oline__ "configure"
809 exit(1); /* I'm told this linker is broken */
811 extern int testdata[3];
812 return testdata[0] == 123
813 && testdata[1] == 456
814 && testdata[2] == 789;
819 if AC_TRY_EVAL(ac_compile); then
820 mv conftest.o func.o && \
821 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
823 rm -f conftest.$ac_ext func.o
824 ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
826 LIBS="conftest.a $LIBS"
830 extern int testfunc();
834 [cf_cv_link_dataonly=yes],
835 [cf_cv_link_dataonly=no],
836 [cf_cv_link_dataonly=unknown])
839 AC_MSG_RESULT($cf_cv_link_dataonly)
840 test $cf_cv_link_dataonly = no && AC_DEFINE(BROKEN_LINKER)
842 dnl ---------------------------------------------------------------------------
843 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
844 dnl options to lower-levels. It's very useful for "make -n" -- if we have it.
845 dnl (GNU 'make' does both :-)
846 AC_DEFUN([CF_MAKEFLAGS],
848 AC_MSG_CHECKING([for makeflags variable])
849 AC_CACHE_VAL(cf_cv_makeflags,[
851 for cf_option in '$(MFLAGS)' '-$(MAKEFLAGS)'
853 cat >cf_makeflags.tmp <<CF_EOF
857 set cf_result=`${MAKE-make} -f cf_makeflags.tmp 2>/dev/null`
858 if test "$cf_result" != "."
860 cf_cv_makeflags=$cf_option
864 rm -f cf_makeflags.tmp])
865 AC_MSG_RESULT($cf_cv_makeflags)
866 AC_SUBST(cf_cv_makeflags)
868 dnl ---------------------------------------------------------------------------
869 dnl Try to determine if the man-pages on the system are compressed, and if
870 dnl so, what format is used. Use this information to construct a script that
871 dnl will install man-pages.
872 AC_DEFUN([CF_MAN_PAGES],
873 [AC_MSG_CHECKING(format of man-pages)
874 if test -z "$MANPATH" ; then
875 MANPATH="/usr/man:/usr/share/man"
877 # look for the 'date' man-page (it's most likely to be installed!)
878 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
880 for cf_dir in $MANPATH; do
881 test -z "$cf_dir" && cf_dir=/usr/man
884 changequote({{,}})dnl
885 for cf_name in $cf_dir/*/date.[01]* $cf_dir/*/date
888 cf_test=`echo $cf_name | sed -e 's/*//'`
889 if test "x$cf_test" = "x$cf_name" ; then
891 *.gz) cf_form=gzip; cf_name=`basename $cf_name .gz`;;
892 *.Z) cf_form=compress; cf_name=`basename $cf_name .Z`;;
893 *.0) cf_form=BSDI; cf_format=yes;;
899 if test "$cf_form" != "unknown" ; then
904 if test "$prefix" = "NONE" ; then
905 cf_prefix="$ac_default_prefix"
910 # Debian 'man' program?
911 test -f /etc/debian_version && \
912 cf_rename=`cd $srcdir && pwd`/man/man_db.renames
914 test ! -d man && mkdir man
916 # Construct a sed-script to perform renaming within man-pages
917 if test -n "$cf_rename" ; then
918 $srcdir/man/make_sed.sh $cf_rename >man/edit_man.sed
920 if test $cf_format = yes ; then
921 cf_subdir='$mandir/cat'
923 cf_subdir='$mandir/man'
926 cat >man/edit_man.sh <<CF_EOF
927 changequote({{,}})dnl
929 # this script is generated by the configure-script
932 MKDIRS="`cd $srcdir && pwd`/mkinstalldirs"
934 INSTALL_DATA="$INSTALL_DATA"
935 TMP=\${TMPDIR-/tmp}/man\$\$
936 trap "rm -f \$TMP" 0 1 2 5 15
948 section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
949 if test \$verb = installing ; then
950 if test ! -d $cf_subdir\${section} ; then
951 \$MKDIRS $cf_subdir\$section
954 source=\`basename \$i\`
956 if test -z "$cf_rename" ; then
957 cat >>man/edit_man.sh <<CF_EOF
958 target=$cf_subdir\${section}/\$source
959 sed -e "s,@DATADIR@,\$datadir," < \$i >\$TMP
962 cat >>man/edit_man.sh <<CF_EOF
963 target=\`grep "^\$source" $cf_rename | $AWK '{print \{{$}}2}'\`
964 if test -z "\$target" ; then
965 echo '? missing rename for '\$source
968 target="$cf_subdir\$section/\$target"
969 test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP
972 if test \$verb = installing ; then
973 if test $cf_format = yes ; then
974 cat >>man/edit_man.sh <<CF_EOF
975 nroff -man \$TMP >\$TMP.out
982 cat >>man/edit_man.sh <<CF_EOF
983 if test \$verb = installing ; then
984 if ( compress -f \$TMP )
993 cat >>man/edit_man.sh <<CF_EOF
994 if test \$verb = installing ; then
1000 target="\$target.gz"
1004 cat >>man/edit_man.sh <<CF_EOF
1005 # BSDI installs only .0 suffixes in the cat directories
1006 target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`"
1010 cat >>man/edit_man.sh <<CF_EOF
1011 echo \$verb \$target
1012 if test \$verb = installing ; then
1013 \$INSTALL_DATA \$TMP \$target
1022 chmod 755 man/edit_man.sh
1023 AC_MSG_RESULT($cf_form)
1025 dnl ---------------------------------------------------------------------------
1026 dnl Compute the object-directory name from the given model name
1027 AC_DEFUN([CF_OBJ_SUBDIR],
1030 normal) $2='objects' ;;
1031 debug) $2='obj_g' ;;
1032 profile) $2='obj_p' ;;
1033 shared) $2='obj_s' ;;
1036 dnl ---------------------------------------------------------------------------
1037 dnl Within AC_OUTPUT, check if the given file differs from the target, and
1038 dnl update it if so. Otherwise, remove the generated file.
1041 dnl $1 = input, which configure has done substitutions upon
1042 dnl $2 = target file
1044 AC_DEFUN([CF_OUTPUT_IF_CHANGED],[
1045 if ( cmp -s $1 $2 2>/dev/null )
1047 echo "$2 is unchanged"
1055 dnl ---------------------------------------------------------------------------
1056 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
1057 dnl misc/tabset install won't work properly. Usually this happens only when
1058 dnl using the fallback mkinstalldirs script
1059 AC_DEFUN([CF_PROG_INSTALL],
1065 changequote({{,}})dnl
1066 cf_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
1067 test -z "$cf_dir" && cf_dir=.
1069 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
1073 dnl ---------------------------------------------------------------------------
1074 dnl Attempt to determine if we've got one of the flavors of regular-expression
1075 dnl code that we can support.
1076 AC_DEFUN([CF_REGEX],
1078 AC_MSG_CHECKING([for regular-expression headers])
1079 AC_CACHE_VAL(cf_cv_regex,[
1080 AC_TRY_LINK([#include <sys/types.h>
1081 #include <regex.h>],[
1083 int x = regcomp(p, "", 0);
1084 int y = regexec(p, "", 0, 0, 0);
1086 ],[cf_cv_regex="regex.h"],[
1087 AC_TRY_LINK([#include <regexp.h>],[
1088 char *p = compile("", "", "", 0);
1089 int x = step("", "");
1090 ],[cf_cv_regex="regexp.h"],[
1091 cf_save_LIBS="$LIBS"
1093 AC_TRY_LINK([#include <regexpr.h>],[
1094 char *p = compile("", "", "");
1095 int x = step("", "");
1096 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
1098 AC_MSG_RESULT($cf_cv_regex)
1099 case $cf_cv_regex in
1100 regex.h) AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
1101 regexp.h) AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
1102 regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1105 dnl ---------------------------------------------------------------------------
1106 dnl This bypasses the normal autoconf process because we're generating an
1107 dnl arbitrary number of NEED_xxxx definitions with the CF_HAVE_FUNCS macro.
1108 dnl Rather than populate an aclocal.h file with all of those definitions, we do
1112 dnl $1 = input, which configure has done substitutions upon (will delete)
1113 dnl $2 = target file
1114 dnl $3 = preamble, if any (a 'here' document)
1115 dnl $4 = trailer, if any (a 'here' document)
1117 AC_DEFUN([CF_SED_CONFIG_H],[
1122 echo '/* generated by configure-script */' >$cf_config_h
1123 ],[cat >$cf_config_h <<CF_EOF
1127 if test -n "$ac_cv_path_TD_CONFIG" ; then
1128 $ac_cv_path_TD_CONFIG $1 |egrep -v '^#' >$cf_config_h
1129 $ac_cv_path_TD_CONFIG $1 |egrep '^#' | sort >>$cf_config_h
1131 grep -v '^ -D' $1 >>$cf_config_h
1137 -e 's/\(#define [A-Za-z_][A-Za-z0-9_]*\)=/\1 /g' \
1139 $1 | sort >>$cf_config_h
1144 [cat >>$cf_config_h <<CF_EOF
1147 CF_OUTPUT_IF_CHANGED($cf_config_h,$2)
1148 rm -f $1 $cf_config_h
1150 dnl ---------------------------------------------------------------------------
1151 dnl Attempt to determine the appropriate CC/LD options for creating a shared
1154 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
1155 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
1156 dnl We avoid compiling-in a ../lib path for the shared library since that can
1157 dnl lead to unexpected results at runtime.
1158 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
1159 dnl are compiled in ../../lib
1161 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
1162 dnl to install symbolic links to the rel/abi versions of shared libraries.
1164 dnl Some loaders leave 'so_locations' lying around. It's nice to clean up.
1165 AC_DEFUN([CF_SHARED_OPTS],
1167 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1171 INSTALL_LIB="-m 644"
1173 cf_cv_do_symlinks=no
1176 case $cf_cv_system_name in
1178 # (tested with gcc 2.7.2 -- I don't have c89)
1179 if test "${CC}" = "gcc"; then
1180 CC_SHARED_OPTS='-fPIC'
1181 LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1184 LD_SHARED_OPTS='+b $(libdir)'
1186 MK_SHARED_LIB='$(LD) -b -o $[@]'
1187 # HP-UX shared libraries must be executable, and should be
1188 # readonly to exploit a quirk in the memory manager.
1189 INSTALL_LIB="-m 555"
1192 # tested with IRIX 5.2 and 'cc'.
1193 if test "${CC}" = "gcc"; then
1194 CC_SHARED_OPTS='-fPIC'
1196 CC_SHARED_OPTS='-KPIC'
1198 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
1199 cf_cv_rm_so_locs=yes
1202 # tested with Linux 2.0.29 and gcc 2.7.2 (ELF)
1203 CC_SHARED_OPTS='-fPIC'
1204 MK_SHARED_LIB='gcc -o $[@].$(REL_VERSION) -L../lib -L\$(libdir) -shared -Wl,-soname,`basename $[@].$(ABI_VERSION)`,-stats,$(SHLIB_LIST)-lc'
1205 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1206 if test $DFT_LWR_MODEL = "shared" ; then
1207 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1208 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1210 cf_cv_do_symlinks=yes
1212 openbsd*|netbsd*|freebsd*)
1213 CC_SHARED_OPTS='-fpic -DPIC'
1214 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1217 # tested with OSF/1 V3.2 and 'cc'
1218 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
1219 # link with shared libs).
1221 MK_SHARED_LIB='$(LD) -o $[@].$(REL_VERSION) -set_version $(ABI_VERSION):$(REL_VERSION) -expect_unresolved "*" -shared -soname `basename $[@].$(ABI_VERSION)`'
1222 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-rpath"
1225 MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
1228 if test $DFT_LWR_MODEL = "shared" ; then
1229 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1230 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1232 cf_cv_do_symlinks=yes
1233 cf_cv_rm_so_locs=yes
1236 # tested with SunOS 4.1.1 and gcc 2.7.0
1237 if test $ac_cv_prog_gcc = yes; then
1238 CC_SHARED_OPTS='-fpic'
1240 CC_SHARED_OPTS='-KPIC'
1242 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@].$(REL_VERSION)'
1243 cf_cv_do_symlinks=yes
1246 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
1247 if test $ac_cv_prog_gcc = yes; then
1248 CC_SHARED_OPTS='-fpic'
1250 CC_SHARED_OPTS='-KPIC'
1252 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@].$(ABI_VERSION)` -o $[@].$(REL_VERSION)'
1253 if test $cf_cv_ld_rpath = yes ; then
1254 cf_ld_rpath_opt="-R"
1255 EXTRA_LDFLAGS="-R ../lib:\$(libdir) $EXTRA_LDFLAGS"
1257 cf_cv_do_symlinks=yes
1260 # tested with UnixWare 1.1.2
1261 CC_SHARED_OPTS='-KPIC'
1262 MK_SHARED_LIB='$(LD) -d y -G -o $[@]'
1265 CC_SHARED_OPTS='unknown'
1266 MK_SHARED_LIB='echo unknown'
1270 if test -n "$cf_ld_rpath_opt" ; then
1271 AC_MSG_CHECKING(if we need a space after rpath option)
1272 cf_save_LIBS="$LIBS"
1273 LIBS="$LIBS ${cf_ld_rpath_opt}/usr/lib"
1274 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1275 LIBS="$cf_save_LIBS"
1276 AC_MSG_RESULT($cf_rpath_space)
1277 test $cf_rpath_space = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
1278 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
1281 AC_SUBST(CC_SHARED_OPTS)
1282 AC_SUBST(LD_SHARED_OPTS)
1283 AC_SUBST(MK_SHARED_LIB)
1284 AC_SUBST(EXTRA_LDFLAGS)
1285 AC_SUBST(LOCAL_LDFLAGS)
1286 AC_SUBST(LOCAL_LDFLAGS2)
1287 AC_SUBST(INSTALL_LIB)
1289 dnl ---------------------------------------------------------------------------
1290 dnl Check for definitions & structures needed for window size-changing
1291 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
1292 AC_DEFUN([CF_SIZECHANGE],
1294 AC_MSG_CHECKING([declaration of size-change])
1295 AC_CACHE_VAL(cf_cv_sizechange,[
1296 cf_cv_sizechange=unknown
1297 cf_save_CFLAGS="$CFLAGS"
1299 for cf_opts in "" "NEED_PTEM_H"
1302 CFLAGS="$cf_save_CFLAGS"
1303 test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts"
1304 AC_TRY_COMPILE([#include <sys/types.h>
1306 #include <termios.h>
1313 /* This is a workaround for SCO: they neglected to define struct winsize in
1314 * termios.h -- it's only in termio.h and ptem.h
1316 #include <sys/stream.h>
1317 #include <sys/ptem.h>
1319 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
1320 #include <sys/ioctl.h>
1324 struct ttysize win; /* FIXME: what system is this? */
1325 int y = win.ts_lines;
1326 int x = win.ts_cols;
1333 no TIOCGSIZE or TIOCGWINSZ
1334 #endif /* TIOCGWINSZ */
1335 #endif /* TIOCGSIZE */
1337 [cf_cv_sizechange=yes],
1338 [cf_cv_sizechange=no])
1340 CFLAGS="$cf_save_CFLAGS"
1341 if test "$cf_cv_sizechange" = yes ; then
1342 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
1343 test -n "$cf_opts" && AC_DEFINE_UNQUOTED($cf_opts)
1348 AC_MSG_RESULT($cf_cv_sizechange)
1349 test $cf_cv_sizechange != no && AC_DEFINE(HAVE_SIZECHANGE)
1351 dnl ---------------------------------------------------------------------------
1352 dnl Check for datatype 'speed_t', which is normally declared via either
1353 dnl sys/types.h or termios.h
1354 AC_DEFUN([CF_SPEED_TYPE],
1356 AC_MSG_CHECKING([for speed_t])
1357 AC_CACHE_VAL(cf_cv_type_speed_t,[
1359 #include <sys/types.h>
1361 #include <termios.h>
1364 [cf_cv_type_speed_t=yes],
1365 [cf_cv_type_speed_t=no])
1367 AC_MSG_RESULT($cf_cv_type_speed_t)
1368 test $cf_cv_type_speed_t != yes && AC_DEFINE(speed_t,unsigned)
1370 dnl ---------------------------------------------------------------------------
1371 dnl For each parameter, test if the source-directory exists, and if it contains
1372 dnl a 'modules' file. If so, add to the list $cf_cv_src_modules which we'll
1373 dnl use in CF_LIB_RULES.
1375 dnl This uses the configured value to make the lists SRC_SUBDIRS and
1376 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
1377 AC_DEFUN([CF_SRC_MODULES],
1379 AC_MSG_CHECKING(for src modules)
1381 # dependencies and linker-arguments for test-programs
1382 TEST_DEPS="${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
1383 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
1385 # dependencies and linker-arguments for utility-programs
1386 PROG_ARGS="$TEST_ARGS"
1391 if test -f $srcdir/$cf_dir/modules; then
1393 # We may/may not have tack in the distribution, though the
1395 if test $cf_dir = tack ; then
1396 if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
1401 if test -z "$cf_cv_src_modules"; then
1402 cf_cv_src_modules=$cf_dir
1404 cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
1407 # Make the ncurses_cfg.h file record the library interface files as
1408 # well. These are header files that are the same name as their
1409 # directory. Ncurses is the only library that does not follow
1411 if test $cf_dir = tack ; then
1413 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
1414 CF_UPPER(cf_have_include,$cf_dir)
1415 AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
1416 AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
1417 TEST_DEPS="${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
1418 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
1422 AC_MSG_RESULT($cf_cv_src_modules)
1423 TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS"
1427 PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS"
1430 SRC_SUBDIRS="man include"
1431 for cf_dir in $cf_cv_src_modules
1433 SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
1435 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
1436 test $cf_cxx_library != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
1439 if test "$ac_cv_prog_gnat_correct" = yes && test -d $srcdir/Ada95; then
1440 SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
1441 ADA_SUBDIRS="gen ada_include samples"
1445 for cf_dir in $SRC_SUBDIRS
1447 SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
1450 if test -n "$ADA_SUBDIRS"; then
1451 for cf_dir in $ADA_SUBDIRS
1453 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
1455 AC_SUBST(ADA_SUBDIRS)
1458 dnl ---------------------------------------------------------------------------
1459 dnl Remove "-g" option from the compiler options
1460 AC_DEFUN([CF_STRIP_G_OPT],
1461 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
1462 dnl ---------------------------------------------------------------------------
1463 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction. We'll only
1464 dnl do this if we've found the sigaction function.
1466 dnl If needed, define SVR4_ACTION.
1467 AC_DEFUN([CF_STRUCT_SIGACTION],[
1468 if test $ac_cv_func_sigaction = yes; then
1469 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
1471 #include <sys/types.h>
1472 #include <signal.h>],
1473 [struct sigaction act],
1477 #define _POSIX_SOURCE
1478 #include <sys/types.h>
1479 #include <signal.h>],
1480 [struct sigaction act],
1482 AC_DEFINE(SVR4_ACTION)],
1483 [sigact_bad=unknown])])
1484 AC_MSG_RESULT($sigact_bad)
1487 dnl ---------------------------------------------------------------------------
1488 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
1489 dnl If so, define SVR4_TERMIO
1490 AC_DEFUN([CF_STRUCT_TERMIOS],[
1491 if test $ac_cv_header_termios_h = yes ; then
1494 termios_bad=dunno ;;
1495 *) termios_bad=maybe ;;
1497 if test $termios_bad = maybe ; then
1498 AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
1499 AC_TRY_COMPILE([#include <termios.h>],
1500 [struct termios foo; int x = foo.c_iflag],
1503 #define _POSIX_SOURCE
1504 #include <termios.h>],
1505 [struct termios foo; int x = foo.c_iflag],
1506 termios_bad=unknown,
1507 termios_bad=yes AC_DEFINE(SVR4_TERMIO))
1509 AC_MSG_RESULT($termios_bad)
1513 dnl ---------------------------------------------------------------------------
1514 dnl Shorthand macro for substituting things that the user may override
1515 dnl with an environment variable.
1517 dnl $1 = long/descriptive name
1518 dnl $2 = environment variable
1519 dnl $3 = default value
1520 AC_DEFUN([CF_SUBST],
1521 [AC_CACHE_VAL(cf_cv_subst_$2,[
1522 AC_MSG_CHECKING(for $1 (symbol $2))
1523 test -z "[$]$2" && $2=$3
1524 AC_MSG_RESULT([$]$2)
1526 cf_cv_subst_$2=[$]$2])
1527 $2=${cf_cv_subst_$2}
1529 dnl ---------------------------------------------------------------------------
1530 dnl Get the version-number for use in shared-library naming, etc.
1531 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
1534 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1535 NCURSES_MINOR="`egrep '^NCURSES_MINOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1536 NCURSES_PATCH="`egrep '^NCURSES_PATCH[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1538 cf_cv_abi_version=${NCURSES_MAJOR}
1539 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
1540 dnl Show the computed version, for logging
1541 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`))
1542 dnl We need these values in the generated headers
1543 AC_SUBST(NCURSES_MAJOR)
1544 AC_SUBST(NCURSES_MINOR)
1545 AC_SUBST(NCURSES_PATCH)
1546 dnl We need these values in the generated makefiles
1547 AC_SUBST(cf_cv_rel_version)
1548 AC_SUBST(cf_cv_abi_version)
1549 AC_SUBST(cf_cv_builtin_bool)
1550 AC_SUBST(cf_cv_type_of_bool)
1552 dnl ---------------------------------------------------------------------------
1553 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1554 dnl older SCO configurations.
1555 AC_DEFUN([CF_SYS_TIME_SELECT],
1557 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1558 AC_CACHE_VAL(cf_cv_sys_time_select,[
1560 #include <sys/types.h>
1562 #include <sys/time.h>
1564 #if HAVE_SYS_SELECT_H
1565 #include <sys/select.h>
1567 ],[],[cf_cv_sys_time_select=yes],
1568 [cf_cv_sys_time_select=no])
1570 AC_MSG_RESULT($cf_cv_sys_time_select)
1571 test $cf_cv_sys_time_select = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1573 dnl ---------------------------------------------------------------------------
1574 dnl Determine the type we should use for chtype (and attr_t, which is treated
1575 dnl as the same thing). We want around 32 bits, so on most machines want a
1576 dnl long, but on newer 64-bit machines, probably want an int. If we're using
1577 dnl wide characters, we have to have a type compatible with that, as well.
1578 AC_DEFUN([CF_TYPEOF_CHTYPE],
1580 AC_REQUIRE([CF_UNSIGNED_LITERALS])
1581 AC_MSG_CHECKING([for type of chtype])
1582 AC_CACHE_VAL(cf_cv_typeof_chtype,[
1584 #if USE_WIDEC_SUPPORT
1585 #include <stddef.h> /* we want wchar_t */
1586 #define WANT_BITS 39
1588 #define WANT_BITS 31
1593 FILE *fp = fopen("cf_test.out", "w");
1595 char *result = "long";
1596 #if USE_WIDEC_SUPPORT
1598 * If wchar_t is smaller than a long, it must be an int or a
1599 * short. We prefer not to use a short anyway.
1601 if (sizeof(unsigned long) > sizeof(wchar_t))
1604 if (sizeof(unsigned long) > sizeof(unsigned int)) {
1607 for (n = 0; n < WANT_BITS; n++) {
1608 unsigned int y = (x >> n);
1609 if (y != 1 || x == 0) {
1615 * If x is nonzero, an int is big enough for the bits
1618 result = (x != 0) ? "int" : "long";
1626 [cf_cv_typeof_chtype=`cat cf_test.out`],
1627 [cf_cv_typeof_chtype=long],
1628 [cf_cv_typeof_chtype=long])
1631 AC_MSG_RESULT($cf_cv_typeof_chtype)
1633 AC_SUBST(cf_cv_typeof_chtype)
1634 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
1637 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
1638 test "$cf_cv_typeof_chtype" = long && cf_cv_1UL="${cf_cv_1UL}L"
1642 dnl ---------------------------------------------------------------------------
1644 AC_DEFUN([CF_TYPE_SIGACTION],
1646 AC_MSG_CHECKING([for type sigaction_t])
1647 AC_CACHE_VAL(cf_cv_type_sigaction,[
1649 #include <signal.h>],
1651 [cf_cv_type_sigaction=yes],
1652 [cf_cv_type_sigaction=no])])
1653 AC_MSG_RESULT($cf_cv_type_sigaction)
1654 test $cf_cv_type_sigaction = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
1656 dnl ---------------------------------------------------------------------------
1657 dnl Test if the compiler supports 'U' and 'L' suffixes. Only old compilers
1658 dnl won't, but they're still there.
1659 AC_DEFUN([CF_UNSIGNED_LITERALS],
1661 AC_MSG_CHECKING([if unsigned literals are legal])
1662 AC_CACHE_VAL(cf_cv_unsigned_literals,[
1663 AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
1664 [cf_cv_unsigned_literals=yes],
1665 [cf_cv_unsigned_literals=no])
1667 AC_MSG_RESULT($cf_cv_unsigned_literals)
1669 dnl ---------------------------------------------------------------------------
1670 dnl Make an uppercase version of a variable
1671 dnl $1=uppercase($2)
1672 AC_DEFUN([CF_UPPER],
1675 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
1678 dnl ---------------------------------------------------------------------------
1679 dnl Compute the shift-mask that we'll use for wide-character indices. We use
1680 dnl all but the index portion of chtype for storing attributes.
1681 AC_DEFUN([CF_WIDEC_SHIFT],
1683 AC_REQUIRE([CF_TYPEOF_CHTYPE])
1684 AC_MSG_CHECKING([for number of bits in chtype])
1685 AC_CACHE_VAL(cf_cv_shift_limit,[
1690 FILE *fp = fopen("cf_test.out", "w");
1693 unsigned TYPEOF_CHTYPE x = 1L;
1694 for (n = 0; ; n++) {
1695 unsigned long y = (x >> n);
1696 if (y != 1 || x == 0)
1700 fprintf(fp, "%d", n);
1706 [cf_cv_shift_limit=`cat cf_test.out`],
1707 [cf_cv_shift_limit=32],
1708 [cf_cv_shift_limit=32])
1711 AC_MSG_RESULT($cf_cv_shift_limit)
1712 AC_SUBST(cf_cv_shift_limit)
1714 AC_MSG_CHECKING([for width of character-index])
1715 AC_CACHE_VAL(cf_cv_widec_shift,[
1716 if test ".$with_widec" = ".yes" ; then
1718 if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
1720 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
1722 cf_cv_widec_shift=16
1728 AC_MSG_RESULT($cf_cv_widec_shift)
1729 AC_SUBST(cf_cv_widec_shift)
1731 dnl ---------------------------------------------------------------------------
1732 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
1733 dnl defaulting to yes/no.
1735 dnl $1 = option name
1737 dnl $3 = environment variable to set
1738 dnl $4 = default value, shown in the help-message, must be a constant
1739 dnl $5 = default value, if it's an expression & cannot be in the help-message
1741 AC_DEFUN([CF_WITH_PATH],
1742 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
1743 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
1744 case ".$withval" in #(vi
1747 .\[$]{*prefix}*) #(vi
1748 eval withval="$withval"
1749 case ".$withval" in #(vi
1751 withval=`echo $withval | sed -e s@NONE@$ac_default_prefix@`
1756 withval=`echo $withval | sed -e s@NONE@$ac_default_prefix@`
1759 AC_ERROR(expected a pathname for $1)