]> ncurses.scripts.mit.edu Git - ncurses.git/blob - aclocal.m4
efaa3949c2195223706f4e6737b84bb7c3cf6fd0
[ncurses.git] / aclocal.m4
1 dnl*****************************************************************************
2 dnl Copyright 1996,1997 by Thomas E. Dickey <dickey@clark.net>                 *
3 dnl All Rights Reserved.                                                       *
4 dnl                                                                            *
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.
22 dnl
23 dnl ---------------------------------------------------------------------------
24 dnl Construct the list of include-options for the C programs in the Ada95
25 dnl binding.
26 AC_DEFUN([NC_ADA_INCLUDE_DIRS],
27 [
28 ACPPFLAGS="$ACPPFLAGS -I. -I../../include"
29 if test "$srcdir" != "."; then
30         ACPPFLAGS="$ACPPFLAGS -I\$(srcdir)/../../include"
31 fi
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)"
38                 fi
39         else
40                 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
41         fi
42 fi
43 AC_SUBST(ACPPFLAGS)
44 ])dnl
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.
49 dnl
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],
53 [
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])
59         ])
60 if test $nc_cv_builtin_bool = 1
61 then    AC_MSG_RESULT(yes)
62 else    AC_MSG_RESULT(no)
63 fi
64 ])dnl
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],
69 [
70 AC_MSG_CHECKING([for size of c++ bool])
71 AC_CACHE_VAL(nc_cv_type_of_bool,[
72         rm -f nc_test.out
73         AC_TRY_RUN([
74 #include <stdlib.h>
75 #include <stdio.h>
76 #if HAVE_BUILTIN_H
77 #include <builtin.h>
78 #endif
79 main()
80 {
81         FILE *fp = fopen("nc_test.out", "w");
82         if (fp != 0) {
83                 bool x = false;
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);
88                 fclose(fp);
89         }
90         exit(0);
91 }
92                 ],
93                 [nc_cv_type_of_bool=`cat nc_test.out`],
94                 [nc_cv_type_of_bool=unknown],
95                 [nc_cv_type_of_bool=unknown])
96         ])
97         rm -f nc_test.out
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
102 fi
103 ])dnl
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
107 dnl look for:
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.
111 dnl
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],
116 [
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
122                 ;;
123         *)      prefix=$ac_default_prefix
124                 ;;
125         esac
126 fi
127 AC_MSG_RESULT($prefix)
128 AC_MSG_CHECKING(for default include-directory)
129 test -n "$verbose" && echo 1>&6
130 for nc_symbol in \
131         $includedir \
132         $includedir/ncurses \
133         $prefix/include \
134         $prefix/include/ncurses \
135         /usr/local/include \
136         /usr/local/include/ncurses \
137         /usr/include \
138         /usr/include/ncurses
139 do
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
145                 break
146         fi
147         fi
148         test -n "$verbose"  && echo "   tested $nc_dir" 1>&6
149 done
150 AC_MSG_RESULT($includedir)
151 ])dnl
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],
157 [
158 nc_cxx_library=unknown
159 if test $ac_cv_prog_gxx = yes; then
160         AC_MSG_CHECKING([for libg++])
161         nc_save="$LIBS"
162         LIBS="$LIBS -lg++ -lm"
163         AC_TRY_LINK([
164 #include <builtin.h>
165         ],
166         [float foo=abs(1.0)],
167         [nc_cxx_library=yes
168          CXXLIBS="$CXXLIBS -lg++ -lm"],
169         [nc_cxx_library=no])
170         LIBS="$nc_save"
171         AC_MSG_RESULT($nc_cxx_library)
172 fi
173 ])dnl
174 dnl ---------------------------------------------------------------------------
175 AC_DEFUN([NC_DIRS_TO_MAKE],
176 [
177 DIRS_TO_MAKE="lib"
178 for nc_item in $nc_list_models
179 do
180         NC_OBJ_SUBDIR($nc_item,nc_subdir)
181         DIRS_TO_MAKE="$DIRS_TO_MAKE $nc_subdir"
182 done
183 for nc_dir in $DIRS_TO_MAKE
184 do
185         test ! -d $nc_dir && mkdir $nc_dir
186 done
187 AC_SUBST(DIRS_TO_MAKE)
188 ])dnl
189 dnl ---------------------------------------------------------------------------
190 dnl
191 AC_DEFUN([NC_ERRNO],
192 [
193 AC_MSG_CHECKING([for errno external decl])
194 AC_CACHE_VAL(nc_cv_extern_errno,[
195         AC_TRY_COMPILE([
196 #include <errno.h>],
197                 [int x = errno],
198                 [nc_cv_extern_errno=yes],
199                 [nc_cv_extern_errno=no])
200         ])
201 AC_MSG_RESULT($nc_cv_extern_errno)
202 test $nc_cv_extern_errno = yes && AC_DEFINE(HAVE_EXTERN_ERRNO)
203 ])dnl
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
210 #ifndef GCC_PRINTF
211 #define GCC_PRINTF 0
212 #endif
213 #ifndef GCC_SCANF
214 #define GCC_SCANF 0
215 #endif
216 #ifndef GCC_NORETURN
217 #define GCC_NORETURN /* nothing */
218 #endif
219 #ifndef GCC_UNUSED
220 #define GCC_UNUSED /* nothing */
221 #endif
222 EOF
223 if test -n "$GCC"
224 then
225         AC_CHECKING([for gcc __attribute__ directives])
226         changequote(,)dnl
227 cat > conftest.$ac_ext <<EOF
228 #line __oline__ "configure"
229 #include "confdefs.h"
230 #include "conftest.h"
231 #include "conftest.i"
232 #if     GCC_PRINTF
233 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
234 #else
235 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
236 #endif
237 #if     GCC_SCANF
238 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
239 #else
240 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
241 #endif
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; }
246 EOF
247         changequote([,])dnl
248         for nc_attribute in scanf printf unused noreturn
249         do
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
254                 scanf|printf)
255                 cat >conftest.h <<EOF
256 #define GCC_$NC_ATTRIBUTE 1
257 EOF
258                         ;;
259                 *)
260                 cat >conftest.h <<EOF
261 #define GCC_$NC_ATTRIBUTE $nc_directive
262 EOF
263                         ;;
264                 esac
265                 if AC_TRY_EVAL(ac_compile); then
266                         test -n "$verbose" && AC_MSG_RESULT(... $nc_attribute)
267                         cat conftest.h >>confdefs.h
268 #               else
269 #                       sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
270                 fi
271         done
272 else
273         fgrep define conftest.i >>confdefs.h
274 fi
275 rm -rf conftest*
276
277 ])dnl
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:
281 dnl
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)
285 dnl
286 AC_DEFUN([NC_GCC_WARNINGS],
287 [nc_warn_CFLAGS=""
288 if test -n "$GCC"
289 then
290         changequote(,)dnl
291         cat > conftest.$ac_ext <<EOF
292 #line __oline__ "configure"
293 int main(int argc, char *argv[]) { return argv[argc-1] == 0; }
294 EOF
295         changequote([,])dnl
296         AC_CHECKING([for gcc warning options])
297         nc_save_CFLAGS="$CFLAGS"
298         nc_warn_CFLAGS="-W -Wall"
299         nc_warn_CONST=""
300         test "$with_ext_const" = yes && nc_warn_CONST="Wwrite-strings"
301         for nc_opt in \
302                 Wbad-function-cast \
303                 Wcast-align \
304                 Wcast-qual \
305                 Winline \
306                 Wmissing-declarations \
307                 Wmissing-prototypes \
308                 Wnested-externs \
309                 Wpointer-arith \
310                 Wshadow \
311                 Wstrict-prototypes $nc_warn_CONST
312         do
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"
317                 fi
318         done
319         rm -f conftest*
320         CFLAGS="$nc_save_CFLAGS"
321 fi
322 ])dnl
323 dnl ---------------------------------------------------------------------------
324 dnl Verify Version of GNAT.
325 AC_DEFUN([NC_GNAT_VERSION],
326 [
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
333     ;;
334   *) echo Unsupported GNAT version $nc_cv_gnat_version. Disabling Ada95 binding.
335      ac_cv_prog_gnat_correct=no
336      ;;
337 esac
338 changequote([, ])dnl
339 ])
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],
346 [
347 CPPFLAGS="$CPPFLAGS -I. -I../include"
348 if test "$srcdir" != "."; then
349         CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
350 fi
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)"
357                 fi
358         else
359                 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
360         fi
361 fi
362 AC_SUBST(CPPFLAGS)
363 ])dnl
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.
369 dnl
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
372 dnl one:
373 dnl     lib<name>.so    ->
374 dnl     lib<name>.so.<major>    ->
375 dnl     lib<name>.so.<maj>.<minor>
376 AC_DEFUN([NC_LIB_RULES],
377 [
378 AC_REQUIRE([NC_SYSTYPE])
379 AC_REQUIRE([NC_VERSION])
380 for nc_dir in $SRC_SUBDIRS
381 do
382         if test -f $srcdir/$nc_dir/modules; then
383
384                 nc_libs_to_make=
385                 for nc_item in $NC_LIST_MODELS
386                 do
387                         NC_LIB_SUFFIX($nc_item,nc_suffix)
388                         nc_libs_to_make="$nc_libs_to_make ../lib/lib${nc_dir}${nc_suffix}"
389                 done
390
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
394
395                 $AWK -f $srcdir/mk-0th.awk \
396                         name=$nc_dir \
397                         $srcdir/$nc_dir/modules >>$nc_dir/Makefile
398
399                 for nc_item in $NC_LIST_MODELS
400                 do
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)
405
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
410                                 nc_reldir="."
411                         else
412                                 nc_reldir="\$(srcdir)"
413                         fi
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"
418                         fi
419                         $AWK -f $srcdir/mk-1st.awk \
420                                 name=$nc_dir \
421                                 MODEL=$NC_ITEM \
422                                 model=$nc_subdir \
423                                 suffix=$nc_suffix \
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 \
431                                 name=$nc_dir \
432                                 MODEL=$NC_ITEM \
433                                 model=$nc_subdir \
434                                 srcdir=$srcdir \
435                                 echo=$WITH_ECHO \
436                                 $srcdir/$nc_dir/modules >>$nc_dir/Makefile
437                 done
438         fi
439
440         echo '  cd '$nc_dir'; $(MAKE) $(NC_MFLAGS) [$]@' >>Makefile
441 done
442
443 for nc_dir in $SRC_SUBDIRS
444 do
445         if test -f $srcdir/$nc_dir/modules; then
446                 echo >> Makefile
447                 if test -f $srcdir/$nc_dir/headers; then
448 cat >> Makefile <<NC_EOF
449 install.includes \\
450 NC_EOF
451                 fi
452 if test "$nc_dir" != "c++" ; then
453 echo 'lint \' >> Makefile
454 fi
455 cat >> Makefile <<NC_EOF
456 lintlib \\
457 install.libs \\
458 install.$nc_dir ::
459         cd $nc_dir; \$(MAKE) \$(NC_MFLAGS) \[$]@
460 NC_EOF
461         elif test -f $srcdir/$nc_dir/headers; then
462 cat >> Makefile <<NC_EOF
463
464 install.libs \\
465 install.includes ::
466         cd $nc_dir; \$(MAKE) \$(NC_MFLAGS) \[$]@
467 NC_EOF
468 fi
469 done
470
471 cat >> Makefile <<NC_EOF
472
473 install.data ::
474         cd misc; \$(MAKE) \$(NC_MFLAGS) \[$]@
475
476 install.man ::
477         cd man; \$(MAKE) \$(NC_MFLAGS) \[$]@
478
479 distclean ::
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)
483 NC_EOF
484
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.
490
491 rm -f headers.sed headers.sh
492
493 dnl ( generating this script makes the makefiles a little tidier :-)
494 echo creating headers.sh
495 cat >headers.sh <<NC_EOF
496 #!/bin/sh
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.
501 PRG=""
502 while test \[$]# != 3
503 do
504 PRG="\$PRG \[$]1"; shift
505 done
506 DST=\[$]1
507 REF=\[$]2
508 SRC=\[$]3
509 echo installing \$SRC in \$DST
510 case \$DST in
511 /*/include/*)
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 "#"\`
516                 do
517                         NAME=\`basename \$i\`
518                         echo "s/<\$NAME>/<\$END\/\$NAME>/" >> ../headers.sed
519                 done
520         fi
521         rm -f \$TMP
522         sed -f ../headers.sed \$SRC > \$TMP
523         eval \$PRG \$TMP \$DST
524         rm -f \$TMP
525         ;;
526 *)
527         eval \$PRG \$SRC \$DST
528         ;;
529 esac
530 NC_EOF
531
532 chmod 0755 headers.sh
533
534 for nc_dir in $SRC_SUBDIRS
535 do
536         if test -f $srcdir/$nc_dir/headers; then
537         cat >>$nc_dir/Makefile <<NC_EOF
538 \$(INSTALL_PREFIX)\$(includedir) :
539         \$(srcdir)/../mkinstalldirs \[$]@
540
541 install \\
542 install.libs \\
543 install.includes :: \$(INSTALL_PREFIX)\$(includedir) \\
544 NC_EOF
545                 j=""
546                 for i in `cat $srcdir/$nc_dir/headers |fgrep -v "#"`
547                 do
548                         test -n "$j" && echo "          $j \\" >>$nc_dir/Makefile
549                         j=$i
550                 done
551                 echo "          $j" >>$nc_dir/Makefile
552                 for i in `cat $srcdir/$nc_dir/headers |fgrep -v "#"`
553                 do
554                         echo "  @ ../headers.sh \$(INSTALL_DATA) \$(INSTALL_PREFIX)\$(includedir) \$(srcdir) $i" >>$nc_dir/Makefile
555                 done
556         fi
557 done
558
559 ])dnl
560 dnl ---------------------------------------------------------------------------
561 dnl Compute the library-suffix from the given model name
562 AC_DEFUN([NC_LIB_SUFFIX],
563 [
564         AC_REQUIRE([NC_SYSTYPE])
565         AC_REQUIRE([NC_VERSION])
566         case $1 in
567         normal)  $2='.a'   ;;
568         debug)   $2='_g.a' ;;
569         profile) $2='_p.a' ;;
570         shared)
571                 case $nc_cv_systype in
572                 NetBSD|FreeBSD)
573                         $2='.so.$(ABI_VERSION)' ;;
574                 HP_UX)  $2='.sl'  ;;
575                 *)      $2='.so'  ;;
576                 esac
577         esac
578 ])dnl
579 dnl ---------------------------------------------------------------------------
580 dnl Compute the string to append to -library from the given model name
581 AC_DEFUN([NC_LIB_TYPE],
582 [
583         case $1 in
584         normal)  $2=''   ;;
585         debug)   $2='_g' ;;
586         profile) $2='_p' ;;
587         shared)  $2=''   ;;
588         esac
589 ])dnl
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
594 dnl properly.
595 AC_DEFUN([NC_LINK_DATAONLY],
596 [
597 AC_MSG_CHECKING([if data-only library module links])
598 AC_CACHE_VAL(nc_cv_link_dataonly,[
599         rm -f conftest.a
600         changequote(,)dnl
601         cat >conftest.$ac_ext <<EOF
602 #line __oline__ "configure"
603 int     testdata[3] = { 123, 456, 789 };
604 EOF
605         changequote([,])dnl
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
609         fi
610         rm -f conftest.$ac_ext data.o
611         changequote(,)dnl
612         cat >conftest.$ac_ext <<EOF
613 #line __oline__ "configure"
614 int     testfunc()
615 {
616 #if defined(NeXT)
617         exit(1);        /* I'm told this linker is broken */
618 #else
619         extern int testdata[3];
620         return testdata[0] == 123
621            &&  testdata[1] == 456
622            &&  testdata[2] == 789;
623 #endif
624 }
625 EOF
626         changequote([,])dnl
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
630         fi
631         rm -f conftest.$ac_ext func.o
632         ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
633         nc_saveLIBS="$LIBS"
634         LIBS="conftest.a $LIBS"
635         AC_TRY_RUN([
636         int main()
637         {
638                 extern int testfunc();
639                 exit (!testfunc());
640         }
641         ],
642         [nc_cv_link_dataonly=yes],
643         [nc_cv_link_dataonly=no],
644         [nc_cv_link_dataonly=unknown])
645         LIBS="$nc_saveLIBS"
646         ])
647 AC_MSG_RESULT($nc_cv_link_dataonly)
648 test $nc_cv_link_dataonly = no && AC_DEFINE(BROKEN_LINKER)
649 ])dnl
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],
655 [
656 AC_MSG_CHECKING([for makeflags variable])
657 AC_CACHE_VAL(nc_cv_makeflags,[
658         nc_cv_makeflags=''
659         for nc_option in '$(MFLAGS)' '-$(MAKEFLAGS)'
660         do
661                 cat >ncurses.tmp <<NC_EOF
662 all :
663         echo '.$nc_option'
664 NC_EOF
665                 set nc_result=`${MAKE-make} -f ncurses.tmp 2>/dev/null`
666                 if test "$nc_result" != "."
667                 then
668                         nc_cv_makeflags=$nc_option
669                         break
670                 fi
671         done
672         rm -f ncurses.tmp
673         ])
674 AC_MSG_RESULT($nc_cv_makeflags)
675 AC_SUBST(nc_cv_makeflags)
676 ])dnl
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"
685   fi
686   # look for the 'date' man-page (it's most likely to be installed!)
687   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
688   nc_form=unknown
689   for nc_dir in $MANPATH; do
690     test -z "$nc_dir" && nc_dir=/usr/man
691     nc_rename=""
692     nc_format=no
693 changequote({{,}})dnl
694     for nc_name in $nc_dir/*/date.[01]* $nc_dir/*/date
695 changequote([,])dnl
696     do
697        nc_test=`echo $nc_name | sed -e 's/*//'`
698        if test "x$nc_test" = "x$nc_name" ; then
699           case "$nc_name" in
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;;
703           *)    nc_form=cat;;
704           esac
705           break
706        fi
707     done
708     if test "$nc_form" != "unknown" ; then
709        break
710     fi
711   done
712   IFS="$ac_save_ifs"
713   if test "$prefix" = "NONE" ; then
714      nc_prefix="$ac_default_prefix"
715   else
716      nc_prefix="$prefix"
717   fi
718
719   # Debian 'man' program?
720   test -f /etc/debian_version && \
721   nc_rename=`cd $srcdir;pwd`/man/man_db.renames
722
723   test ! -d man && mkdir man
724
725   # Construct a sed-script to perform renaming within man-pages
726   if test -n "$nc_rename" ; then
727     fgrep -v \# $nc_rename | \
728     sed -e 's/^/s\//' \
729         -e 's/\./\\./' \
730         -e 's/  / /g' \
731         -e 's/[ ]\+/\//' \
732         -e s/\$/\\\/g/ >man/edit_man.sed
733   fi
734   if test $nc_format = yes ; then
735     nc_subdir='$mandir/cat'
736   else
737     nc_subdir='$mandir/man'
738   fi
739
740 cat >man/edit_man.sh <<NC_EOF
741 changequote({{,}})dnl
742 #!/bin/sh
743 # this script is generated by the configure-script
744 prefix="$nc_prefix"
745 datadir="$datadir"
746 MKDIRS="`cd $srcdir;pwd`/mkinstalldirs"
747 INSTALL="$INSTALL"
748 INSTALL_DATA="$INSTALL_DATA"
749 TMP=\${TMPDIR-/tmp}/man\$\$
750 trap "rm -f \$TMP" 0 1 2 5 15
751
752 mandir=\{{$}}1
753 shift
754
755 for i in \{{$}}*
756 do
757 case \$i in
758 *.[0-9]*)
759         section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
760         if [ ! -d $nc_subdir\${section} ]; then
761                 \$MKDIRS $nc_subdir\$section
762         fi
763         source=\`basename \$i\`
764 NC_EOF
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
769 NC_EOF
770 else
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
775                 target="\$source"
776         fi
777         target="$nc_subdir\$section/\$target"
778         sed -e 's,@DATADIR@,\$datadir,' < \$i | sed -f edit_man.sed >\$TMP
779 NC_EOF
780 fi
781 if test $nc_format = yes ; then
782 cat >>man/edit_man.sh <<NC_EOF
783         nroff -man \$TMP >\$TMP.out
784         mv \$TMP.out \$TMP
785 NC_EOF
786 fi
787 case "$nc_form" in
788 compress)
789 cat >>man/edit_man.sh <<NC_EOF
790         if ( compress -f \$TMP )
791         then
792                 mv \$TMP.Z \$TMP
793                 target="\$target.Z"
794         fi
795 NC_EOF
796   ;;
797 gzip)
798 cat >>man/edit_man.sh <<NC_EOF
799         if ( gzip -f \$TMP )
800         then
801                 mv \$TMP.gz \$TMP
802                 target="\$target.gz"
803         fi
804 NC_EOF
805   ;;
806 BSDI)
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/'\`"
810 NC_EOF
811   ;;
812 esac
813 cat >>man/edit_man.sh <<NC_EOF
814         echo installing \$target
815         \$INSTALL_DATA \$TMP \$target
816         ;;
817 esac
818 done 
819 NC_EOF
820 changequote([,])dnl
821 chmod 755 man/edit_man.sh
822 AC_MSG_RESULT($nc_form)
823 ])dnl
824 dnl ---------------------------------------------------------------------------
825 dnl Compute the object-directory name from the given model name
826 AC_DEFUN([NC_OBJ_SUBDIR],
827 [
828         case $1 in
829         normal)  $2='objects' ;;
830         debug)   $2='obj_g' ;;
831         profile) $2='obj_p' ;;
832         shared)  $2='obj_s' ;;
833         esac
834 ])dnl
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],
840 [AC_PROG_INSTALL
841 case $INSTALL in
842 /*)
843   ;;
844 *)
845 changequote({{,}})dnl
846   nc_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
847   test -z "$nc_dir" && nc_dir=.
848 changequote([,])dnl
849   INSTALL=`cd $nc_dir;pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
850   ;;
851 esac
852 ])dnl
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.
856 AC_DEFUN([NC_REGEX],
857 [
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>],[
862         regex_t *p;
863         int x = regcomp(p, "", 0);
864         int y = regexec(p, "", 0, 0, 0);
865         regfree(p);
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"])])])
875 ])
876 AC_MSG_RESULT($nc_cv_regex)
877 case $nc_cv_regex in
878         regex.h)   AC_DEFINE(HAVE_REGEX_H) ;;
879         regexp.h)  AC_DEFINE(HAVE_REGEXP_H) ;;
880         regexpr.h) AC_DEFINE(HAVE_REGEXPR_H) ;;
881 esac
882 ])dnl
883 dnl ---------------------------------------------------------------------------
884 dnl Attempt to determine the appropriate CC/LD options for creating a shared
885 dnl library.
886 dnl
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
893 dnl
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.
896 dnl
897 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
898 AC_DEFUN([NC_SHARED_OPTS],
899 [
900         AC_REQUIRE([NC_SYSTYPE])
901         AC_REQUIRE([NC_VERSION])
902         LOCAL_LDFLAGS=
903         LOCAL_LDFLAGS2=
904
905         nc_cv_do_symlinks=no
906         nc_cv_rm_so_locs=no
907
908         case $nc_cv_systype in
909         HP_UX)
910                 # (tested with gcc 2.7.2 -- I don't have c89)
911                 if test "${CC}" = "gcc"; then
912                         CC_SHARED_OPTS='-fPIC'
913                 else
914                         CC_SHARED_OPTS='+Z'
915                 fi
916                 MK_SHARED_LIB='$(LD) -b -o $[@]'
917                 ;;
918         IRIX*)
919                 # tested with IRIX 5.2 and 'cc'.
920                 if test "${CC}" = "gcc"; then
921                         CC_SHARED_OPTS='-fPIC'
922                 else
923                         CC_SHARED_OPTS='-KPIC'
924                 fi
925                 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
926                 nc_cv_rm_so_locs=yes
927                 ;;
928         Linux)
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'
935                 fi
936                 nc_cv_do_symlinks=yes
937                 ;;
938         NetBSD|FreeBSD)
939                 CC_SHARED_OPTS='-fpic -DPIC'
940                 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
941                 ;;
942         OSF1|MLS+)
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).
946                 CC_SHARED_OPTS=''
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'
951                 fi
952                 nc_cv_do_symlinks=yes
953                 nc_cv_rm_so_locs=yes
954                 ;;
955         SunOS)
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'
960                 else
961                         CC_SHARED_OPTS='-KPIC'
962                 fi
963                 case `uname -r` in
964                 4.*)
965                         MK_SHARED_LIB='$(LD) -assert pure-text -o $[@].$(REL_VERSION)'
966                         ;;
967                 5.*)
968                         MK_SHARED_LIB='$(LD) -d y -G -h `basename $[@].$(ABI_VERSION)` -o $[@].$(REL_VERSION)'
969                         ;;
970                 esac
971                 nc_cv_do_symlinks=yes
972                 ;;
973         UNIX_SV)
974                 # tested with UnixWare 1.1.2
975                 CC_SHARED_OPTS='-KPIC'
976                 MK_SHARED_LIB='$(LD) -d y -G -o $[@]'
977                 ;;
978         *)
979                 CC_SHARED_OPTS='unknown'
980                 MK_SHARED_LIB='echo unknown'
981                 ;;
982         esac
983         AC_SUBST(CC_SHARED_OPTS)
984         AC_SUBST(MK_SHARED_LIB)
985         AC_SUBST(LOCAL_LDFLAGS)
986         AC_SUBST(LOCAL_LDFLAGS2)
987 ])dnl
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],
992 [
993 AC_MSG_CHECKING([for speed_t])
994 AC_CACHE_VAL(nc_cv_type_speed_t,[
995         AC_TRY_COMPILE([
996 #include <sys/types.h>
997 #if HAVE_TERMIOS_H
998 #include <termios.h>
999 #endif],
1000         [speed_t x = 0],
1001         [nc_cv_type_speed_t=yes],
1002         [nc_cv_type_speed_t=no])
1003         ])
1004 AC_MSG_RESULT($nc_cv_type_speed_t)
1005 test $nc_cv_type_speed_t != yes && AC_DEFINE(speed_t,unsigned)
1006 ])dnl
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.
1011 dnl
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],
1015 [
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}"
1019 nc_cv_src_modules=
1020 for nc_dir in $1
1021 do
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
1025                 else
1026                         nc_cv_src_modules="$nc_cv_src_modules $nc_dir"
1027                 fi
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
1031                 # that pattern.
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"
1038                 fi
1039         fi
1040 done
1041 AC_MSG_RESULT($nc_cv_src_modules)
1042 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
1043 AC_SUBST(TEST_DEPS)
1044 AC_SUBST(TEST_ARGS)
1045
1046 SRC_SUBDIRS="man include"
1047 for nc_dir in $nc_cv_src_modules
1048 do
1049         SRC_SUBDIRS="$SRC_SUBDIRS $nc_dir"
1050 done
1051 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
1052 test $nc_cxx_library != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
1053
1054 ADA_SUBDIRS=
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"
1058 fi
1059
1060 SUB_MAKEFILES=
1061 for nc_dir in $SRC_SUBDIRS
1062 do
1063         SUB_MAKEFILES="$SUB_MAKEFILES $nc_dir/Makefile"
1064 done
1065
1066 if test -n "$ADA_SUBDIRS"; then
1067    for nc_dir in $ADA_SUBDIRS
1068    do   
1069       SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$nc_dir/Makefile"
1070    done
1071    AC_SUBST(ADA_SUBDIRS)
1072 fi
1073 ])dnl
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.
1081 dnl
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)
1090 AC_SUBST($2)
1091 nc_cv_subst_$2=[$]$2])
1092 $2=${nc_cv_subst_$2}
1093 ])dnl
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],
1099 [
1100 AC_MSG_CHECKING([declaration of sys_errlist])
1101 AC_CACHE_VAL(nc_cv_dcl_sys_errlist,[
1102         AC_TRY_COMPILE([
1103 #include <stdio.h>
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])
1109         ])
1110 AC_MSG_RESULT($nc_cv_dcl_sys_errlist)
1111 test $nc_cv_dcl_sys_errlist = yes && AC_DEFINE(HAVE_EXTERN_SYS_ERRLIST)
1112 ])dnl
1113 dnl ---------------------------------------------------------------------------
1114 dnl Derive the system-type (our main clue to the method of building shared
1115 dnl libraries).
1116 AC_DEFUN([NC_SYSTYPE],
1117 [
1118 AC_CACHE_VAL(nc_cv_systype,[
1119 changequote(,)dnl
1120 nc_cv_systype="`(uname -s || hostname || echo unknown) 2>/dev/null |sed -e s'/[:\/.-]/_/'g  | sed 1q`"
1121 changequote([,])dnl
1122 if test -z "$nc_cv_systype"; then nc_cv_systype=unknown;fi
1123 ])
1124 AC_MSG_RESULT(System type is $nc_cv_systype)
1125 ])dnl
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
1129 dnl screen.
1130 dnl
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.
1134 dnl
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],
1138 [
1139 AC_MSG_CHECKING([for working TIOCGWINSZ])
1140 AC_CACHE_VAL(nc_cv_use_tiocgwinsz,[
1141         AC_TRY_RUN([
1142 #if HAVE_TERMIOS_H
1143 #include <termios.h>
1144 #endif
1145 #if SYSTEM_LOOKS_LIKE_SCO
1146 /* they neglected to define struct winsize in termios.h -- it's only
1147    in termio.h  */
1148 #include        <sys/stream.h>
1149 #include        <sys/ptem.h>
1150 #endif
1151 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
1152 #include <sys/ioctl.h>
1153 #endif
1154 int main()
1155 {
1156         static  struct winsize size;
1157         int fd;
1158         for (fd = 0; fd <= 2; fd++) {   /* try in/out/err in case redirected */
1159                 if (ioctl(0, TIOCGWINSZ, &size) == 0
1160                  && size.ws_row > 0
1161                  && size.ws_col > 0)
1162                         exit(0);
1163         }
1164         exit(0);        /* in either case, it compiles & links ... */
1165 }
1166                 ],
1167                 [nc_cv_use_tiocgwinsz=yes],
1168                 [nc_cv_use_tiocgwinsz=no],
1169                 [nc_cv_use_tiocgwinsz=unknown])
1170         ])
1171 AC_MSG_RESULT($nc_cv_use_tiocgwinsz)
1172 test $nc_cv_use_tiocgwinsz != yes && AC_DEFINE(BROKEN_TIOCGWINSZ)
1173 ])dnl
1174 dnl ---------------------------------------------------------------------------
1175 dnl
1176 AC_DEFUN([NC_TYPE_SIGACTION],
1177 [
1178 AC_MSG_CHECKING([for type sigaction_t])
1179 AC_CACHE_VAL(nc_cv_type_sigaction,[
1180         AC_TRY_COMPILE([
1181 #include <signal.h>],
1182                 [sigaction_t x],
1183                 [nc_cv_type_sigaction=yes],
1184                 [nc_cv_type_sigaction=no])
1185         ])
1186 AC_MSG_RESULT($nc_cv_type_sigaction)
1187 test $nc_cv_type_sigaction = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
1188 ])
1189 dnl ---------------------------------------------------------------------------
1190 dnl Make an uppercase version of a given name
1191 AC_DEFUN([NC_UPPERCASE],
1192 [
1193 changequote(,)dnl
1194 $2=`echo $1 |tr '[a-z]' '[A-Z]'`
1195 changequote([,])dnl
1196 ])dnl
1197 dnl ---------------------------------------------------------------------------
1198 dnl Get the version-number for use in shared-library naming, etc.
1199 AC_DEFUN([NC_VERSION],
1200 [
1201 changequote(,)dnl
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]*//'`"
1205 changequote([,])dnl
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)
1219 ])dnl