1 dnl*****************************************************************************
2 dnl Copyright 1996,1997 by Thomas E. Dickey <dickey@clark.net> *
3 dnl All Rights Reserved. *
5 dnl Permission to use, copy, modify, and distribute this software and its *
6 dnl documentation for any purpose and without fee is hereby granted, provided *
7 dnl that the above copyright notice appear in all copies and that both that *
8 dnl copyright notice and this permission notice appear in supporting *
9 dnl documentation, and that the name of the above listed copyright holder(s) *
10 dnl not be used in advertising or publicity pertaining to distribution of the *
11 dnl software without specific, written prior permission. THE ABOVE LISTED *
12 dnl COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, *
13 dnl INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO *
14 dnl EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY *
15 dnl SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER *
16 dnl RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF *
17 dnl CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN *
18 dnl CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
19 dnl*****************************************************************************
20 dnl $Id: aclocal.m4,v 1.60 1997/05/10 15:56:16 tom Exp $
21 dnl Macros used in NCURSES auto-configuration script.
23 dnl ---------------------------------------------------------------------------
24 dnl Construct the list of include-options for the C programs in the Ada95
26 AC_DEFUN([NC_ADA_INCLUDE_DIRS],
28 ACPPFLAGS="$ACPPFLAGS -I. -I../../include"
29 if test "$srcdir" != "."; then
30 ACPPFLAGS="$ACPPFLAGS -I\$(srcdir)/../../include"
32 if test -z "$GCC"; then
33 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
34 elif test "$includedir" != "/usr/include"; then
35 if test "$includedir" = '${prefix}/include' ; then
36 if test $prefix != /usr ; then
37 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
40 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
45 dnl ---------------------------------------------------------------------------
46 dnl Test if 'bool' is a builtin type in the configured C++ compiler. Some
47 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
48 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
50 dnl Treat the configuration-variable specially here, since we're directly
51 dnl substituting its value (i.e., 1/0).
52 AC_DEFUN([NC_BOOL_DECL],
54 AC_MSG_CHECKING([for builtin c++ bool type])
55 AC_CACHE_VAL(nc_cv_builtin_bool,[
56 AC_TRY_COMPILE([],[bool x = false],
57 [nc_cv_builtin_bool=1],
58 [nc_cv_builtin_bool=0])
60 if test $nc_cv_builtin_bool = 1
61 then AC_MSG_RESULT(yes)
62 else AC_MSG_RESULT(no)
65 dnl ---------------------------------------------------------------------------
66 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
67 dnl Don't bother looking for bool.h, since it's been deprecated.
68 AC_DEFUN([NC_BOOL_SIZE],
70 AC_MSG_CHECKING([for size of c++ bool])
71 AC_CACHE_VAL(nc_cv_type_of_bool,[
81 FILE *fp = fopen("nc_test.out", "w");
84 if (sizeof(x) == sizeof(int)) fputs("int", fp);
85 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
86 else if (sizeof(x) == sizeof(short))fputs("short",fp);
87 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
93 [nc_cv_type_of_bool=`cat nc_test.out`],
94 [nc_cv_type_of_bool=unknown],
95 [nc_cv_type_of_bool=unknown])
98 AC_MSG_RESULT($nc_cv_type_of_bool)
99 if test $nc_cv_type_of_bool = unknown ; then
100 AC_MSG_WARN(Assuming unsigned for type of bool)
101 nc_cv_type_of_bool=unsigned
104 dnl ---------------------------------------------------------------------------
105 dnl Determine the default configuration into which we'll install ncurses. This
106 dnl can be overridden by the user's command-line options. There's two items to
108 dnl 1. the prefix (e.g., /usr)
109 dnl 2. the header files (e.g., /usr/include/ncurses)
110 dnl We'll look for a previous installation of ncurses and use the same defaults.
112 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
113 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
114 dnl programs from a vendor's.
115 AC_DEFUN([NC_CFG_DEFAULTS],
117 AC_MSG_CHECKING(for prefix)
118 if test "x$prefix" = "xNONE" ; then
119 case "$nc_cv_systype" in
120 # non-vendor systems don't have a conflict
121 NetBSD|FreeBSD|Linux) prefix=/usr
123 *) prefix=$ac_default_prefix
127 AC_MSG_RESULT($prefix)
128 AC_MSG_CHECKING(for default include-directory)
129 test -n "$verbose" && echo 1>&6
132 $includedir/ncurses \
134 $prefix/include/ncurses \
136 /usr/local/include/ncurses \
140 nc_dir=`eval echo $nc_symbol`
141 if test -f $nc_dir/curses.h ; then
142 if ( fgrep NCURSES_VERSION $nc_dir/curses.h 2>&1 >/dev/null ) ; then
143 includedir="$nc_symbol"
144 test -n "$verbose" && echo $ac_n " found " 1>&6
148 test -n "$verbose" && echo " tested $nc_dir" 1>&6
150 AC_MSG_RESULT($includedir)
152 dnl ---------------------------------------------------------------------------
153 dnl If we're trying to use g++, test if libg++ is installed (a rather common
154 dnl problem :-). If we have the compiler but no library, we'll be able to
155 dnl configure, but won't be able to build the c++ demo program.
156 AC_DEFUN([NC_CXX_LIBRARY],
158 nc_cxx_library=unknown
159 if test $ac_cv_prog_gxx = yes; then
160 AC_MSG_CHECKING([for libg++])
162 LIBS="$LIBS -lg++ -lm"
166 [float foo=abs(1.0)],
168 CXXLIBS="$CXXLIBS -lg++ -lm"],
171 AC_MSG_RESULT($nc_cxx_library)
174 dnl ---------------------------------------------------------------------------
175 AC_DEFUN([NC_DIRS_TO_MAKE],
178 for nc_item in $nc_list_models
180 NC_OBJ_SUBDIR($nc_item,nc_subdir)
181 DIRS_TO_MAKE="$DIRS_TO_MAKE $nc_subdir"
183 for nc_dir in $DIRS_TO_MAKE
185 test ! -d $nc_dir && mkdir $nc_dir
187 AC_SUBST(DIRS_TO_MAKE)
189 dnl ---------------------------------------------------------------------------
193 AC_MSG_CHECKING([for errno external decl])
194 AC_CACHE_VAL(nc_cv_extern_errno,[
198 [nc_cv_extern_errno=yes],
199 [nc_cv_extern_errno=no])
201 AC_MSG_RESULT($nc_cv_extern_errno)
202 test $nc_cv_extern_errno = yes && AC_DEFINE(HAVE_EXTERN_ERRNO)
204 dnl ---------------------------------------------------------------------------
205 dnl Test for availability of useful gcc __attribute__ directives to quiet
206 dnl compiler warnings. Though useful, not all are supported -- and contrary
207 dnl to documentation, unrecognized directives cause older compilers to barf.
208 AC_DEFUN([NC_GCC_ATTRIBUTES],
209 [cat > conftest.i <<EOF
217 #define GCC_NORETURN /* nothing */
220 #define GCC_UNUSED /* nothing */
225 AC_CHECKING([for gcc __attribute__ directives])
227 cat > conftest.$ac_ext <<EOF
228 #line __oline__ "configure"
229 #include "confdefs.h"
230 #include "conftest.h"
231 #include "conftest.i"
233 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
235 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
238 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
240 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
242 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
243 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
244 extern void foo(void) GCC_NORETURN;
245 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
248 for nc_attribute in scanf printf unused noreturn
250 NC_UPPERCASE($nc_attribute,NC_ATTRIBUTE)
251 nc_directive="__attribute__(($nc_attribute))"
252 echo "checking for gcc $nc_directive" 1>&AC_FD_CC
253 case $nc_attribute in
255 cat >conftest.h <<EOF
256 #define GCC_$NC_ATTRIBUTE 1
260 cat >conftest.h <<EOF
261 #define GCC_$NC_ATTRIBUTE $nc_directive
265 if AC_TRY_EVAL(ac_compile); then
266 test -n "$verbose" && AC_MSG_RESULT(... $nc_attribute)
267 cat conftest.h >>confdefs.h
269 # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
273 fgrep define conftest.i >>confdefs.h
278 dnl ---------------------------------------------------------------------------
279 dnl Check if the compiler supports useful warning options. There's a few that
280 dnl we don't use, simply because they're too noisy:
282 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
283 dnl -Wredundant-decls (system headers make this too noisy)
284 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
286 AC_DEFUN([NC_GCC_WARNINGS],
291 cat > conftest.$ac_ext <<EOF
292 #line __oline__ "configure"
293 int main(int argc, char *argv[]) { return argv[argc-1] == 0; }
296 AC_CHECKING([for gcc warning options])
297 nc_save_CFLAGS="$CFLAGS"
298 nc_warn_CFLAGS="-W -Wall"
300 test "$with_ext_const" = yes && nc_warn_CONST="Wwrite-strings"
306 Wmissing-declarations \
307 Wmissing-prototypes \
311 Wstrict-prototypes $nc_warn_CONST
313 CFLAGS="$nc_save_CFLAGS $nc_warn_CFLAGS -$nc_opt"
314 if AC_TRY_EVAL(ac_compile); then
315 test -n "$verbose" && AC_MSG_RESULT(... -$nc_opt)
316 nc_warn_CFLAGS="$nc_warn_CFLAGS -$nc_opt"
320 CFLAGS="$nc_save_CFLAGS"
323 dnl ---------------------------------------------------------------------------
324 dnl Verify Version of GNAT.
325 AC_DEFUN([NC_GNAT_VERSION],
327 changequote(<<, >>)dnl
328 nc_cv_gnat_version=`$nc_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
329 sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'`
330 case $nc_cv_gnat_version in
331 3.0[5-9]|3.[1-9]*|[4-9].*)
332 ac_cv_prog_gnat_correct=yes
334 *) echo Unsupported GNAT version $nc_cv_gnat_version. Disabling Ada95 binding.
335 ac_cv_prog_gnat_correct=no
340 dnl ---------------------------------------------------------------------------
341 dnl Construct the list of include-options according to whether we're building
342 dnl in the source directory or using '--srcdir=DIR' option. If we're building
343 dnl with gcc, don't append the includedir if it happens to be /usr/include,
344 dnl since that usually breaks gcc's shadow-includes.
345 AC_DEFUN([NC_INCLUDE_DIRS],
347 CPPFLAGS="$CPPFLAGS -I. -I../include"
348 if test "$srcdir" != "."; then
349 CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
351 if test -z "$GCC"; then
352 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
353 elif test "$includedir" != "/usr/include"; then
354 if test "$includedir" = '${prefix}/include' ; then
355 if test $prefix != /usr ; then
356 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
359 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
364 dnl ---------------------------------------------------------------------------
365 dnl Append definitions and rules for the given models to the subdirectory
366 dnl Makefiles, and the recursion rule for the top-level Makefile. If the
367 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
368 dnl the corresponding makefile to list the models that we'll generate.
370 dnl For shared libraries, make a list of symbolic links to construct when
371 dnl generating each library. The convention used for Linux is the simplest
374 dnl lib<name>.so.<major> ->
375 dnl lib<name>.so.<maj>.<minor>
376 AC_DEFUN([NC_LIB_RULES],
378 AC_REQUIRE([NC_SYSTYPE])
379 AC_REQUIRE([NC_VERSION])
380 for nc_dir in $SRC_SUBDIRS
382 if test -f $srcdir/$nc_dir/modules; then
385 for nc_item in $NC_LIST_MODELS
387 NC_LIB_SUFFIX($nc_item,nc_suffix)
388 nc_libs_to_make="$nc_libs_to_make ../lib/lib${nc_dir}${nc_suffix}"
391 sed -e "s@\@LIBS_TO_MAKE\@@$nc_libs_to_make@" \
392 $nc_dir/Makefile >$nc_dir/Makefile.out
393 mv $nc_dir/Makefile.out $nc_dir/Makefile
395 $AWK -f $srcdir/mk-0th.awk \
397 $srcdir/$nc_dir/modules >>$nc_dir/Makefile
399 for nc_item in $NC_LIST_MODELS
401 echo 'Appending rules for '$nc_item' model ('$nc_dir')'
402 NC_UPPERCASE($nc_item,NC_ITEM)
403 NC_LIB_SUFFIX($nc_item,nc_suffix)
404 NC_OBJ_SUBDIR($nc_item,nc_subdir)
406 # These dependencies really are for development, not
407 # builds, but they are useful in porting, too.
408 nc_depend="../include/ncurses_cfg.h"
409 if test "$srcdir" = "."; then
412 nc_reldir="\$(srcdir)"
414 if test -f $srcdir/$nc_dir/$nc_dir.priv.h; then
415 nc_depend="$nc_depend $nc_reldir/$nc_dir.priv.h"
416 elif test -f $srcdir/$nc_dir/curses.priv.h; then
417 nc_depend="$nc_depend $nc_reldir/curses.priv.h"
419 $AWK -f $srcdir/mk-1st.awk \
424 DoLinks=$nc_cv_do_symlinks \
425 rmSoLocs=$nc_cv_rm_so_locs \
426 overwrite=$WITH_OVERWRITE \
427 depend="$nc_depend" \
428 $srcdir/$nc_dir/modules >>$nc_dir/Makefile
429 test $nc_dir = ncurses && WITH_OVERWRITE=no
430 $AWK -f $srcdir/mk-2nd.awk \
436 $srcdir/$nc_dir/modules >>$nc_dir/Makefile
440 echo ' cd '$nc_dir'; $(MAKE) $(NC_MFLAGS) [$]@' >>Makefile
443 for nc_dir in $SRC_SUBDIRS
445 if test -f $srcdir/$nc_dir/modules; then
447 if test -f $srcdir/$nc_dir/headers; then
448 cat >> Makefile <<NC_EOF
452 if test "$nc_dir" != "c++" ; then
453 echo 'lint \' >> Makefile
455 cat >> Makefile <<NC_EOF
459 cd $nc_dir; \$(MAKE) \$(NC_MFLAGS) \[$]@
461 elif test -f $srcdir/$nc_dir/headers; then
462 cat >> Makefile <<NC_EOF
466 cd $nc_dir; \$(MAKE) \$(NC_MFLAGS) \[$]@
471 cat >> Makefile <<NC_EOF
474 cd misc; \$(MAKE) \$(NC_MFLAGS) \[$]@
477 cd man; \$(MAKE) \$(NC_MFLAGS) \[$]@
480 rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
481 rm -f headers.sh headers.sed
482 rm -rf \$(DIRS_TO_MAKE)
485 dnl If we're installing into a subdirectory of /usr/include, etc., we should
486 dnl prepend the subdirectory's name to the "#include" paths. It won't hurt
487 dnl anything, and will make it more standardized. It's awkward to decide this
488 dnl at configuration because of quoting, so we'll simply make all headers
489 dnl installed via a script that can do the right thing.
491 rm -f headers.sed headers.sh
493 dnl ( generating this script makes the makefiles a little tidier :-)
494 echo creating headers.sh
495 cat >headers.sh <<NC_EOF
497 # This shell script is generated by the 'configure' script. It is invoked in a
498 # subdirectory of the build tree. It generates a sed-script in the parent
499 # directory that is used to adjust includes for header files that reside in a
500 # subdirectory of /usr/include, etc.
502 while test \[$]# != 3
504 PRG="\$PRG \[$]1"; shift
509 echo installing \$SRC in \$DST
512 TMP=\${TMPDIR-/tmp}/\`basename \$SRC\`
513 if test ! -f ../headers.sed ; then
514 END=\`basename \$DST\`
515 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
517 NAME=\`basename \$i\`
518 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> ../headers.sed
522 sed -f ../headers.sed \$SRC > \$TMP
523 eval \$PRG \$TMP \$DST
527 eval \$PRG \$SRC \$DST
532 chmod 0755 headers.sh
534 for nc_dir in $SRC_SUBDIRS
536 if test -f $srcdir/$nc_dir/headers; then
537 cat >>$nc_dir/Makefile <<NC_EOF
538 \$(INSTALL_PREFIX)\$(includedir) :
539 \$(srcdir)/../mkinstalldirs \[$]@
543 install.includes :: \$(INSTALL_PREFIX)\$(includedir) \\
546 for i in `cat $srcdir/$nc_dir/headers |fgrep -v "#"`
548 test -n "$j" && echo " $j \\" >>$nc_dir/Makefile
551 echo " $j" >>$nc_dir/Makefile
552 for i in `cat $srcdir/$nc_dir/headers |fgrep -v "#"`
554 echo " @ ../headers.sh \$(INSTALL_DATA) \$(INSTALL_PREFIX)\$(includedir) \$(srcdir) $i" >>$nc_dir/Makefile
560 dnl ---------------------------------------------------------------------------
561 dnl Compute the library-suffix from the given model name
562 AC_DEFUN([NC_LIB_SUFFIX],
564 AC_REQUIRE([NC_SYSTYPE])
565 AC_REQUIRE([NC_VERSION])
569 profile) $2='_p.a' ;;
571 case $nc_cv_systype in
573 $2='.so.$(ABI_VERSION)' ;;
579 dnl ---------------------------------------------------------------------------
580 dnl Compute the string to append to -library from the given model name
581 AC_DEFUN([NC_LIB_TYPE],
590 dnl ---------------------------------------------------------------------------
591 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
592 dnl only data (i.e., no functions), for example NeXT. On those systems we'll
593 dnl have to provide wrappers for global tables to ensure they're linked
595 AC_DEFUN([NC_LINK_DATAONLY],
597 AC_MSG_CHECKING([if data-only library module links])
598 AC_CACHE_VAL(nc_cv_link_dataonly,[
601 cat >conftest.$ac_ext <<EOF
602 #line __oline__ "configure"
603 int testdata[3] = { 123, 456, 789 };
606 if AC_TRY_EVAL(ac_compile) ; then
607 mv conftest.o data.o && \
608 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
610 rm -f conftest.$ac_ext data.o
612 cat >conftest.$ac_ext <<EOF
613 #line __oline__ "configure"
617 exit(1); /* I'm told this linker is broken */
619 extern int testdata[3];
620 return testdata[0] == 123
621 && testdata[1] == 456
622 && testdata[2] == 789;
627 if AC_TRY_EVAL(ac_compile); then
628 mv conftest.o func.o && \
629 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
631 rm -f conftest.$ac_ext func.o
632 ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
634 LIBS="conftest.a $LIBS"
638 extern int testfunc();
642 [nc_cv_link_dataonly=yes],
643 [nc_cv_link_dataonly=no],
644 [nc_cv_link_dataonly=unknown])
647 AC_MSG_RESULT($nc_cv_link_dataonly)
648 test $nc_cv_link_dataonly = no && AC_DEFINE(BROKEN_LINKER)
650 dnl ---------------------------------------------------------------------------
651 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
652 dnl options to lower-levels. It's very useful for "make -n" -- if we have it.
653 dnl (GNU 'make' does both :-)
654 AC_DEFUN([NC_MAKEFLAGS],
656 AC_MSG_CHECKING([for makeflags variable])
657 AC_CACHE_VAL(nc_cv_makeflags,[
659 for nc_option in '$(MFLAGS)' '-$(MAKEFLAGS)'
661 cat >ncurses.tmp <<NC_EOF
665 set nc_result=`${MAKE-make} -f ncurses.tmp 2>/dev/null`
666 if test "$nc_result" != "."
668 nc_cv_makeflags=$nc_option
674 AC_MSG_RESULT($nc_cv_makeflags)
675 AC_SUBST(nc_cv_makeflags)
677 dnl ---------------------------------------------------------------------------
678 dnl Try to determine if the man-pages on the system are compressed, and if
679 dnl so, what format is used. Use this information to construct a script that
680 dnl will install man-pages.
681 AC_DEFUN([NC_MAN_PAGES],
682 [AC_MSG_CHECKING(format of man-pages)
683 if test -z "$MANPATH" ; then
684 MANPATH="/usr/man:/usr/share/man"
686 # look for the 'date' man-page (it's most likely to be installed!)
687 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
689 for nc_dir in $MANPATH; do
690 test -z "$nc_dir" && nc_dir=/usr/man
693 changequote({{,}})dnl
694 for nc_name in $nc_dir/*/date.[01]* $nc_dir/*/date
697 nc_test=`echo $nc_name | sed -e 's/*//'`
698 if test "x$nc_test" = "x$nc_name" ; then
700 *.gz) nc_form=gzip; nc_name=`basename $nc_name .gz`;;
701 *.Z) nc_form=compress; nc_name=`basename $nc_name .Z`;;
702 *.0) nc_form=BSDI; nc_format=yes;;
708 if test "$nc_form" != "unknown" ; then
713 if test "$prefix" = "NONE" ; then
714 nc_prefix="$ac_default_prefix"
719 # Debian 'man' program?
720 test -f /etc/debian_version && \
721 nc_rename=`cd $srcdir;pwd`/man/man_db.renames
723 test ! -d man && mkdir man
725 # Construct a sed-script to perform renaming within man-pages
726 if test -n "$nc_rename" ; then
727 fgrep -v \# $nc_rename | \
732 -e s/\$/\\\/g/ >man/edit_man.sed
734 if test $nc_format = yes ; then
735 nc_subdir='$mandir/cat'
737 nc_subdir='$mandir/man'
740 cat >man/edit_man.sh <<NC_EOF
741 changequote({{,}})dnl
743 # this script is generated by the configure-script
746 MKDIRS="`cd $srcdir;pwd`/mkinstalldirs"
748 INSTALL_DATA="$INSTALL_DATA"
749 TMP=\${TMPDIR-/tmp}/man\$\$
750 trap "rm -f \$TMP" 0 1 2 5 15
759 section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
760 if [ ! -d $nc_subdir\${section} ]; then
761 \$MKDIRS $nc_subdir\$section
763 source=\`basename \$i\`
765 if test -z "$nc_rename" ; then
766 cat >>man/edit_man.sh <<NC_EOF
767 target=$nc_subdir\${section}/\$source
768 sed -e "s,@DATADIR@,\$datadir," < \$i >\$TMP
771 cat >>man/edit_man.sh <<NC_EOF
772 target=\`grep "^\$source" $nc_rename | $AWK '{print \{{$}}2}'\`
773 if test -z "\$target" ; then
774 echo '? missing rename for '\$source
777 target="$nc_subdir\$section/\$target"
778 sed -e 's,@DATADIR@,\$datadir,' < \$i | sed -f edit_man.sed >\$TMP
781 if test $nc_format = yes ; then
782 cat >>man/edit_man.sh <<NC_EOF
783 nroff -man \$TMP >\$TMP.out
789 cat >>man/edit_man.sh <<NC_EOF
790 if ( compress -f \$TMP )
798 cat >>man/edit_man.sh <<NC_EOF
807 cat >>man/edit_man.sh <<NC_EOF
808 # BSDI installs only .0 suffixes in the cat directories
809 target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`"
813 cat >>man/edit_man.sh <<NC_EOF
814 echo installing \$target
815 \$INSTALL_DATA \$TMP \$target
821 chmod 755 man/edit_man.sh
822 AC_MSG_RESULT($nc_form)
824 dnl ---------------------------------------------------------------------------
825 dnl Compute the object-directory name from the given model name
826 AC_DEFUN([NC_OBJ_SUBDIR],
829 normal) $2='objects' ;;
831 profile) $2='obj_p' ;;
832 shared) $2='obj_s' ;;
835 dnl ---------------------------------------------------------------------------
836 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
837 dnl misc/tabset install won't work properly. Usually this happens only when
838 dnl using the fallback mkinstalldirs script
839 AC_DEFUN([NC_PROG_INSTALL],
845 changequote({{,}})dnl
846 nc_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
847 test -z "$nc_dir" && nc_dir=.
849 INSTALL=`cd $nc_dir;pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
853 dnl ---------------------------------------------------------------------------
854 dnl Attempt to determine if we've got one of the flavors of regular-expression
855 dnl code that we can support.
858 AC_MSG_CHECKING([for regular-expression headers])
859 AC_CACHE_VAL(nc_cv_regex,[
860 AC_TRY_LINK([#include <sys/types.h>
861 #include <regex.h>],[
863 int x = regcomp(p, "", 0);
864 int y = regexec(p, "", 0, 0, 0);
866 ],[nc_cv_regex="regex.h"],[
867 AC_TRY_LINK([#include <regexp.h>],[
868 char *p = compile("", "", "", 0);
869 int x = step("", "");
870 ],[nc_cv_regex="regexp.h"],[
871 AC_TRY_LINK([#include <regexpr.h>],[
872 char *p = compile("", "", "");
873 int x = step("", "");
874 ],[nc_cv_regex="regexpr.h"])])])
876 AC_MSG_RESULT($nc_cv_regex)
878 regex.h) AC_DEFINE(HAVE_REGEX_H) ;;
879 regexp.h) AC_DEFINE(HAVE_REGEXP_H) ;;
880 regexpr.h) AC_DEFINE(HAVE_REGEXPR_H) ;;
883 dnl ---------------------------------------------------------------------------
884 dnl Attempt to determine the appropriate CC/LD options for creating a shared
887 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
888 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
889 dnl We avoid compiling-in a ../lib path for the shared library since that can
890 dnl lead to unexpected results at runtime.
891 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
892 dnl are compiled in ../../lib
894 dnl The variable 'nc_cv_do_symlinks' is used to control whether we configure
895 dnl to install symbolic links to the rel/abi versions of shared libraries.
897 dnl Some loaders leave 'so_locations' lying around. It's nice to clean up.
898 AC_DEFUN([NC_SHARED_OPTS],
900 AC_REQUIRE([NC_SYSTYPE])
901 AC_REQUIRE([NC_VERSION])
908 case $nc_cv_systype in
910 # (tested with gcc 2.7.2 -- I don't have c89)
911 if test "${CC}" = "gcc"; then
912 CC_SHARED_OPTS='-fPIC'
916 MK_SHARED_LIB='$(LD) -b -o $[@]'
919 # tested with IRIX 5.2 and 'cc'.
920 if test "${CC}" = "gcc"; then
921 CC_SHARED_OPTS='-fPIC'
923 CC_SHARED_OPTS='-KPIC'
925 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
929 # tested with Linux 1.2.8 and gcc 2.7.0 (ELF)
930 CC_SHARED_OPTS='-fPIC'
931 MK_SHARED_LIB='gcc -o $[@].$(REL_VERSION) -shared -Wl,-soname,`basename $[@].$(ABI_VERSION)`,-stats'
932 if test $DFT_LWR_MODEL = "shared" ; then
933 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
934 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
936 nc_cv_do_symlinks=yes
939 CC_SHARED_OPTS='-fpic -DPIC'
940 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
943 # tested with OSF/1 V3.2 and 'cc'
944 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
945 # link with shared libs).
947 MK_SHARED_LIB='$(LD) -o $[@].$(REL_VERSION) -shared -soname `basename $[@].$(ABI_VERSION)`'
948 if test $DFT_LWR_MODEL = "shared" ; then
949 LOCAL_LDFLAGS='-Wl,-rpath,../lib'
950 LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
952 nc_cv_do_symlinks=yes
956 # tested with SunOS 4.1.1 and gcc 2.7.0
957 # tested with SunOS 5.3 (solaris 2.3) and gcc 2.7.0
958 if test $ac_cv_prog_gcc = yes; then
959 CC_SHARED_OPTS='-fpic'
961 CC_SHARED_OPTS='-KPIC'
965 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@].$(REL_VERSION)'
968 MK_SHARED_LIB='$(LD) -d y -G -h `basename $[@].$(ABI_VERSION)` -o $[@].$(REL_VERSION)'
971 nc_cv_do_symlinks=yes
974 # tested with UnixWare 1.1.2
975 CC_SHARED_OPTS='-KPIC'
976 MK_SHARED_LIB='$(LD) -d y -G -o $[@]'
979 CC_SHARED_OPTS='unknown'
980 MK_SHARED_LIB='echo unknown'
983 AC_SUBST(CC_SHARED_OPTS)
984 AC_SUBST(MK_SHARED_LIB)
985 AC_SUBST(LOCAL_LDFLAGS)
986 AC_SUBST(LOCAL_LDFLAGS2)
988 dnl ---------------------------------------------------------------------------
989 dnl Check for datatype 'speed_t', which is normally declared via either
990 dnl sys/types.h or termios.h
991 AC_DEFUN([NC_SPEED_TYPE],
993 AC_MSG_CHECKING([for speed_t])
994 AC_CACHE_VAL(nc_cv_type_speed_t,[
996 #include <sys/types.h>
1001 [nc_cv_type_speed_t=yes],
1002 [nc_cv_type_speed_t=no])
1004 AC_MSG_RESULT($nc_cv_type_speed_t)
1005 test $nc_cv_type_speed_t != yes && AC_DEFINE(speed_t,unsigned)
1007 dnl ---------------------------------------------------------------------------
1008 dnl For each parameter, test if the source-directory exists, and if it contains
1009 dnl a 'modules' file. If so, add to the list $nc_cv_src_modules which we'll
1010 dnl use in NC_LIB_RULES.
1012 dnl This uses the configured value to make the lists SRC_SUBDIRS and
1013 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
1014 AC_DEFUN([NC_SRC_MODULES],
1016 AC_MSG_CHECKING(for src modules)
1017 TEST_DEPS="${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX}"
1018 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX}"
1022 if test -f $srcdir/$nc_dir/modules; then
1023 if test -z "$nc_cv_src_modules"; then
1024 nc_cv_src_modules=$nc_dir
1026 nc_cv_src_modules="$nc_cv_src_modules $nc_dir"
1028 # Make the ncurses_cfg.h file record the library interface files as
1029 # well. These are header files that are the same name as their
1030 # directory. Ncurses is the only library that does not follow
1032 if test -f $srcdir/${nc_dir}/${nc_dir}.h; then
1033 NC_UPPERCASE($nc_dir,nc_have_include)
1034 AC_DEFINE_UNQUOTED(HAVE_${nc_have_include}_H)
1035 AC_DEFINE_UNQUOTED(HAVE_LIB${nc_have_include})
1036 TEST_DEPS="${LIB_PREFIX}${nc_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
1037 TEST_ARGS="-l${nc_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
1041 AC_MSG_RESULT($nc_cv_src_modules)
1042 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
1046 SRC_SUBDIRS="man include"
1047 for nc_dir in $nc_cv_src_modules
1049 SRC_SUBDIRS="$SRC_SUBDIRS $nc_dir"
1051 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
1052 test $nc_cxx_library != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
1055 if test "$ac_cv_prog_gnat_correct" = yes && test -d $srcdir/Ada95; then
1056 SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
1057 ADA_SUBDIRS="gen ada_include samples"
1061 for nc_dir in $SRC_SUBDIRS
1063 SUB_MAKEFILES="$SUB_MAKEFILES $nc_dir/Makefile"
1066 if test -n "$ADA_SUBDIRS"; then
1067 for nc_dir in $ADA_SUBDIRS
1069 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$nc_dir/Makefile"
1071 AC_SUBST(ADA_SUBDIRS)
1074 dnl ---------------------------------------------------------------------------
1075 dnl Remove "-g" option from the compiler options
1076 AC_DEFUN([NC_STRIP_G_OPT],
1077 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
1078 dnl ---------------------------------------------------------------------------
1079 dnl Shorthand macro for substituting things that the user may override
1080 dnl with an environment variable.
1082 dnl $1 = long/descriptive name
1083 dnl $2 = environment variable
1084 dnl $3 = default value
1085 AC_DEFUN([NC_SUBST],
1086 [AC_CACHE_VAL(nc_cv_subst_$2,[
1087 AC_MSG_CHECKING(for $1 (symbol $2))
1088 test -z "[$]$2" && $2=$3
1089 AC_MSG_RESULT([$]$2)
1091 nc_cv_subst_$2=[$]$2])
1092 $2=${nc_cv_subst_$2}
1094 dnl ---------------------------------------------------------------------------
1095 dnl Check for declarion of sys_errlist in one of stdio.h and errno.h.
1096 dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
1097 dnl Reported by Keith Bostic.
1098 AC_DEFUN([NC_SYS_ERRLIST],
1100 AC_MSG_CHECKING([declaration of sys_errlist])
1101 AC_CACHE_VAL(nc_cv_dcl_sys_errlist,[
1104 #include <sys/types.h>
1105 #include <errno.h> ],
1106 [ char *c = (char *) *sys_errlist; ],
1107 [nc_cv_dcl_sys_errlist=yes],
1108 [nc_cv_dcl_sys_errlist=no])
1110 AC_MSG_RESULT($nc_cv_dcl_sys_errlist)
1111 test $nc_cv_dcl_sys_errlist = yes && AC_DEFINE(HAVE_EXTERN_SYS_ERRLIST)
1113 dnl ---------------------------------------------------------------------------
1114 dnl Derive the system-type (our main clue to the method of building shared
1116 AC_DEFUN([NC_SYSTYPE],
1118 AC_CACHE_VAL(nc_cv_systype,[
1120 nc_cv_systype="`(uname -s || hostname || echo unknown) 2>/dev/null |sed -e s'/[:\/.-]/_/'g | sed 1q`"
1122 if test -z "$nc_cv_systype"; then nc_cv_systype=unknown;fi
1124 AC_MSG_RESULT(System type is $nc_cv_systype)
1126 dnl ---------------------------------------------------------------------------
1127 dnl On some systems ioctl(fd, TIOCGWINSZ, &size) will always return {0,0} until
1128 dnl ioctl(fd, TIOCSWINSZ, &size) is called to explicitly set the size of the
1131 dnl Attempt to determine if we're on such a system by running a test-program.
1132 dnl This won't work, of course, if the configure script is run in batch mode,
1133 dnl since we've got to have access to the terminal.
1135 dnl 1996/4/26 - Converted this into a simple test for able-to-compile, since
1136 dnl we're reminded that _nc_get_screensize() does the same functional test.
1137 AC_DEFUN([NC_TIOCGWINSZ],
1139 AC_MSG_CHECKING([for working TIOCGWINSZ])
1140 AC_CACHE_VAL(nc_cv_use_tiocgwinsz,[
1143 #include <termios.h>
1145 #if SYSTEM_LOOKS_LIKE_SCO
1146 /* they neglected to define struct winsize in termios.h -- it's only
1148 #include <sys/stream.h>
1149 #include <sys/ptem.h>
1151 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
1152 #include <sys/ioctl.h>
1156 static struct winsize size;
1158 for (fd = 0; fd <= 2; fd++) { /* try in/out/err in case redirected */
1159 if (ioctl(0, TIOCGWINSZ, &size) == 0
1164 exit(0); /* in either case, it compiles & links ... */
1167 [nc_cv_use_tiocgwinsz=yes],
1168 [nc_cv_use_tiocgwinsz=no],
1169 [nc_cv_use_tiocgwinsz=unknown])
1171 AC_MSG_RESULT($nc_cv_use_tiocgwinsz)
1172 test $nc_cv_use_tiocgwinsz != yes && AC_DEFINE(BROKEN_TIOCGWINSZ)
1174 dnl ---------------------------------------------------------------------------
1176 AC_DEFUN([NC_TYPE_SIGACTION],
1178 AC_MSG_CHECKING([for type sigaction_t])
1179 AC_CACHE_VAL(nc_cv_type_sigaction,[
1181 #include <signal.h>],
1183 [nc_cv_type_sigaction=yes],
1184 [nc_cv_type_sigaction=no])
1186 AC_MSG_RESULT($nc_cv_type_sigaction)
1187 test $nc_cv_type_sigaction = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
1189 dnl ---------------------------------------------------------------------------
1190 dnl Make an uppercase version of a given name
1191 AC_DEFUN([NC_UPPERCASE],
1194 $2=`echo $1 |tr '[a-z]' '[A-Z]'`
1197 dnl ---------------------------------------------------------------------------
1198 dnl Get the version-number for use in shared-library naming, etc.
1199 AC_DEFUN([NC_VERSION],
1202 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1203 NCURSES_MINOR="`egrep '^NCURSES_MINOR[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1204 NCURSES_PATCH="`egrep '^NCURSES_PATCH[ ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1206 nc_cv_abi_version=${NCURSES_MAJOR}
1207 nc_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
1208 dnl Show the computed version, for logging
1209 AC_MSG_RESULT(Configuring NCURSES $nc_cv_rel_version ABI $nc_cv_abi_version (`date`))
1210 dnl We need these values in the generated headers
1211 AC_SUBST(NCURSES_MAJOR)
1212 AC_SUBST(NCURSES_MINOR)
1213 AC_SUBST(NCURSES_PATCH)
1214 dnl We need these values in the generated makefiles
1215 AC_SUBST(nc_cv_rel_version)
1216 AC_SUBST(nc_cv_abi_version)
1217 AC_SUBST(nc_cv_builtin_bool)
1218 AC_SUBST(nc_cv_type_of_bool)