]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ncurses/aclocal.m4
This commit was generated by cvs2svn to compensate for changes in r53469,
[FreeBSD/FreeBSD.git] / contrib / ncurses / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 1998 Free Software Foundation, Inc.                        *
3 dnl                                                                          *
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:                 *
11 dnl                                                                          *
12 dnl The above copyright notice and this permission notice shall be included  *
13 dnl in all copies or substantial portions of the Software.                   *
14 dnl                                                                          *
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.                               *
22 dnl                                                                          *
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       *
26 dnl authorization.                                                           *
27 dnl***************************************************************************
28 dnl
29 dnl Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,1998
30 dnl
31 dnl $Id: aclocal.m4,v 1.162 1999/08/22 00:13:21 tom Exp $
32 dnl Macros used in NCURSES auto-configuration script.
33 dnl
34 dnl ---------------------------------------------------------------------------
35 dnl ---------------------------------------------------------------------------
36 dnl Construct the list of include-options for the C programs in the Ada95
37 dnl binding.
38 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
39 [
40 ACPPFLAGS="$ACPPFLAGS -I. -I../../include"
41 if test "$srcdir" != "."; then
42         ACPPFLAGS="$ACPPFLAGS -I\$(srcdir)/../../include"
43 fi
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)"
50                 fi
51         else
52                 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
53         fi
54 fi
55 AC_SUBST(ACPPFLAGS)
56 ])dnl
57 dnl ---------------------------------------------------------------------------
58 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
59 dnl in the sharutils 4.2 distribution.
60 AC_DEFUN([CF_ANSI_CC_CHECK],
61 [
62 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
63 AC_CACHE_VAL(cf_cv_ansi_cc,[
64 cf_cv_ansi_cc=no
65 cf_save_CFLAGS="$CFLAGS"
66 # Don't try gcc -ansi; that turns off useful extensions and
67 # breaks some systems' header files.
68 # AIX                   -qlanglvl=ansi
69 # Ultrix and OSF/1      -std1
70 # HP-UX                 -Aa -D_HPUX_SOURCE
71 # SVR4                  -Xc
72 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
73 for cf_arg in "-DCC_HAS_PROTOS" \
74         "" \
75         -qlanglvl=ansi \
76         -std1 \
77         "-Aa -D_HPUX_SOURCE +e" \
78         "-Aa -D_HPUX_SOURCE" \
79         -Xc
80 do
81         CFLAGS="$cf_save_CFLAGS $cf_arg"
82         AC_TRY_COMPILE(
83 [
84 #ifndef CC_HAS_PROTOS
85 #if !defined(__STDC__) || (__STDC__ != 1)
86 choke me
87 #endif
88 #endif
89 ],[
90         int test (int i, double x);
91         struct s1 {int (*f) (int a);};
92         struct s2 {int (*f) (double a);};],
93         [cf_cv_ansi_cc="$cf_arg"; break])
94 done
95 CFLAGS="$cf_save_CFLAGS"
96 ])
97 AC_MSG_RESULT($cf_cv_ansi_cc)
98
99 if test "$cf_cv_ansi_cc" != "no"; then
100 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
101         CFLAGS="$CFLAGS $cf_cv_ansi_cc"
102 else
103         AC_DEFINE(CC_HAS_PROTOS)
104 fi
105 fi
106 ])dnl
107 dnl ---------------------------------------------------------------------------
108 dnl For programs that must use an ANSI compiler, obtain compiler options that
109 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
110 dnl macros, since tools such as unproto can fake prototypes, but only part of
111 dnl the preprocessor.
112 AC_DEFUN([CF_ANSI_CC_REQD],
113 [AC_REQUIRE([CF_ANSI_CC_CHECK])
114 if test "$cf_cv_ansi_cc" = "no"; then
115         AC_ERROR(
116 [Your compiler does not appear to recognize prototypes.
117 You have the following choices:
118         a. adjust your compiler options
119         b. get an up-to-date compiler
120         c. use a wrapper such as unproto])
121 fi
122 ])dnl
123 dnl ---------------------------------------------------------------------------
124 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
125 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
126 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
127 dnl
128 dnl Treat the configuration-variable specially here, since we're directly
129 dnl substituting its value (i.e., 1/0).
130 AC_DEFUN([CF_BOOL_DECL],
131 [
132 AC_MSG_CHECKING([for builtin ifelse(AC_LANG,[C],$CC,$CXX) bool type])
133 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
134         AC_TRY_COMPILE([
135 #include <stdio.h>
136 #include <sys/types.h>
137 ],[bool x = false],
138                 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
139                 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
140         ])
141 if test $ifelse($1,,cf_cv_builtin_bool,[$1]) = 1
142 then    AC_MSG_RESULT(yes)
143 else    AC_MSG_RESULT(no)
144 fi
145 ])dnl
146 dnl ---------------------------------------------------------------------------
147 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
148 dnl Don't bother looking for bool.h, since it's been deprecated.
149 AC_DEFUN([CF_BOOL_SIZE],
150 [
151 AC_MSG_CHECKING([for size of ifelse(AC_LANG,[C],$CC,$CXX) bool])
152 AC_CACHE_VAL(cf_cv_type_of_bool,[
153         rm -f cf_test.out
154         AC_TRY_RUN([
155 #include <stdlib.h>
156 #include <stdio.h>
157 #if HAVE_BUILTIN_H
158 #include <builtin.h>
159 #endif
160 main()
161 {
162         FILE *fp = fopen("cf_test.out", "w");
163         if (fp != 0) {
164                 bool x = true;
165                 if ((bool)(-x) >= 0)
166                         fputs("unsigned ", fp);
167                 if (sizeof(x) == sizeof(int))       fputs("int",  fp);
168                 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
169                 else if (sizeof(x) == sizeof(short))fputs("short",fp);
170                 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
171                 fclose(fp);
172         }
173         exit(0);
174 }
175                 ],
176                 [cf_cv_type_of_bool=`cat cf_test.out`],
177                 [cf_cv_type_of_bool=unknown],
178                 [cf_cv_type_of_bool=unknown])
179         ])
180         rm -f cf_test.out
181 AC_MSG_RESULT($cf_cv_type_of_bool)
182 if test "$cf_cv_type_of_bool" = unknown ; then
183         AC_MSG_WARN(Assuming unsigned for type of bool)
184         cf_cv_type_of_bool=unsigned
185 fi
186 ])dnl
187 dnl ---------------------------------------------------------------------------
188 dnl Determine the default configuration into which we'll install ncurses.  This
189 dnl can be overridden by the user's command-line options.  There's two items to
190 dnl look for:
191 dnl     1. the prefix (e.g., /usr)
192 dnl     2. the header files (e.g., /usr/include/ncurses)
193 dnl We'll look for a previous installation of ncurses and use the same defaults.
194 dnl
195 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
196 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
197 dnl programs from a vendor's.
198 AC_DEFUN([CF_CFG_DEFAULTS],
199 [
200 AC_MSG_CHECKING(for prefix)
201 if test "x$prefix" = "xNONE" ; then
202         case "$cf_cv_system_name" in
203                 # non-vendor systems don't have a conflict
204         openbsd*|netbsd*|freebsd*|linux*)
205                 prefix=/usr
206                 ;;
207         *)      prefix=$ac_default_prefix
208                 ;;
209         esac
210 fi
211 AC_MSG_RESULT($prefix)
212
213 if test "x$prefix" = "xNONE" ; then
214 AC_MSG_CHECKING(for default include-directory)
215 test -n "$verbose" && echo 1>&AC_FD_MSG
216 for cf_symbol in \
217         $includedir \
218         $includedir/ncurses \
219         $prefix/include \
220         $prefix/include/ncurses \
221         /usr/local/include \
222         /usr/local/include/ncurses \
223         /usr/include \
224         /usr/include/ncurses
225 do
226         cf_dir=`eval echo $cf_symbol`
227         if test -f $cf_dir/curses.h ; then
228         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
229                 includedir="$cf_symbol"
230                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
231                 break
232         fi
233         fi
234         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
235 done
236 AC_MSG_RESULT($includedir)
237 fi
238 ])dnl
239 dnl ---------------------------------------------------------------------------
240 dnl Check if the terminal-capability database functions are available.  If not,
241 dnl ncurses has a much-reduced version.
242 AC_DEFUN([CF_CGETENT],[
243 AC_MSG_CHECKING(for terminal-capability database functions)
244 AC_CACHE_VAL(cf_cv_cgetent,[
245 AC_TRY_LINK([
246 #include <stdlib.h>],[
247         char temp[128];
248         char *buf = temp;
249         char *db_array = temp;
250         cgetent(&buf, /* int *, */ &db_array, "vt100");
251         cgetcap(buf, "tc", '=');
252         cgetmatch(buf, "tc");
253         ],
254         [cf_cv_cgetent=yes],
255         [cf_cv_cgetent=no])
256 ])
257 AC_MSG_RESULT($cf_cv_cgetent)
258 test $cf_cv_cgetent = yes && AC_DEFINE(HAVE_BSD_CGETENT)
259 ])dnl
260 dnl ---------------------------------------------------------------------------
261 dnl Check if we're accidentally using a cache from a different machine.
262 dnl Derive the system name, as a check for reusing the autoconf cache.
263 dnl
264 dnl If we've packaged config.guess and config.sub, run that (since it does a
265 dnl better job than uname).
266 AC_DEFUN([CF_CHECK_CACHE],
267 [
268 if test -f $srcdir/config.guess ; then
269         AC_CANONICAL_HOST
270         system_name="$host_os"
271 else
272         system_name="`(uname -s -r) 2>/dev/null`"
273         if test -z "$system_name" ; then
274                 system_name="`(hostname) 2>/dev/null`"
275         fi
276 fi
277 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
278 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
279
280 test -z "$system_name" && system_name="$cf_cv_system_name"
281 test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name")
282
283 if test ".$system_name" != ".$cf_cv_system_name" ; then
284         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
285         AC_ERROR("Please remove config.cache and try again.")
286 fi
287 ])dnl
288 dnl ---------------------------------------------------------------------------
289 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
290 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
291 dnl ourselves.
292 dnl
293 dnl (I would use AC_CACHE_CHECK here, but it will not work when called in a
294 dnl loop from CF_SYS_ERRLIST).
295 dnl
296 dnl $1 = the name to check
297 AC_DEFUN([CF_CHECK_ERRNO],
298 [
299 AC_MSG_CHECKING(if external $1 is declared)
300 AC_CACHE_VAL(cf_cv_dcl_$1,[
301     AC_TRY_COMPILE([
302 #if HAVE_STDLIB_H
303 #include <stdlib.h>
304 #endif
305 #include <stdio.h>
306 #include <sys/types.h>
307 #include <errno.h> ],
308     [long x = (long) $1],
309     [eval 'cf_cv_dcl_'$1'=yes'],
310     [eval 'cf_cv_dcl_'$1'=no]')
311 ])
312
313 eval 'cf_result=$cf_cv_dcl_'$1
314 AC_MSG_RESULT($cf_result)
315
316 if test "$cf_result" = no ; then
317     eval 'cf_result=DECL_'$1
318     CF_UPPER(cf_result,$cf_result)
319     AC_DEFINE_UNQUOTED($cf_result)
320 fi
321
322 # It's possible (for near-UNIX clones) that the data doesn't exist
323 CF_CHECK_EXTERN_DATA($1,int)
324 ])dnl
325 dnl ---------------------------------------------------------------------------
326 dnl Check for existence of external data in the current set of libraries.  If
327 dnl we can modify it, it's real enough.
328 dnl $1 = the name to check
329 dnl $2 = its type
330 AC_DEFUN([CF_CHECK_EXTERN_DATA],
331 [
332 AC_MSG_CHECKING(if external $1 exists)
333 AC_CACHE_VAL(cf_cv_have_$1,[
334     AC_TRY_LINK([
335 #undef $1
336 extern $2 $1;
337 ],
338     [$1 = 2],
339     [eval 'cf_cv_have_'$1'=yes'],
340     [eval 'cf_cv_have_'$1'=no'])])
341
342 eval 'cf_result=$cf_cv_have_'$1
343 AC_MSG_RESULT($cf_result)
344
345 if test "$cf_result" = yes ; then
346     eval 'cf_result=HAVE_'$1
347     CF_UPPER(cf_result,$cf_result)
348     AC_DEFINE_UNQUOTED($cf_result)
349 fi
350
351 ])dnl
352 dnl ---------------------------------------------------------------------------
353 dnl If we're trying to use g++, test if libg++ is installed (a rather common
354 dnl problem :-).  If we have the compiler but no library, we'll be able to
355 dnl configure, but won't be able to build the c++ demo program.
356 AC_DEFUN([CF_CXX_LIBRARY],
357 [
358 cf_cxx_library=unknown
359 if test $ac_cv_prog_gxx = yes; then
360         AC_MSG_CHECKING([for libg++])
361         cf_save="$LIBS"
362         LIBS="$LIBS -lg++ -lm"
363         AC_TRY_LINK([
364 #include <builtin.h>
365         ],
366         [float foo=abs(1.0)],
367         [cf_cxx_library=yes
368          CXXLIBS="$CXXLIBS -lg++ -lm"],
369         [cf_cxx_library=no])
370         LIBS="$cf_save"
371         AC_MSG_RESULT($cf_cxx_library)
372 fi
373 ])dnl
374 dnl ---------------------------------------------------------------------------
375 AC_DEFUN([CF_DIRS_TO_MAKE],
376 [
377 DIRS_TO_MAKE="lib"
378 for cf_item in $cf_list_models
379 do
380         CF_OBJ_SUBDIR($cf_item,cf_subdir)
381         DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
382 done
383 for cf_dir in $DIRS_TO_MAKE
384 do
385         test ! -d $cf_dir && mkdir $cf_dir
386 done
387 AC_SUBST(DIRS_TO_MAKE)
388 ])dnl
389 dnl ---------------------------------------------------------------------------
390 dnl Check if 'errno' is declared in <errno.h>
391 AC_DEFUN([CF_ERRNO],
392 [
393 CF_CHECK_ERRNO(errno)
394 ])dnl
395 dnl ---------------------------------------------------------------------------
396 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
397 dnl math.h and builtin.h, only for ncurses
398 AC_DEFUN([CF_ETIP_DEFINES],
399 [
400 AC_MSG_CHECKING(for special defines needed for etip.h)
401 cf_save_CXXFLAGS="$CXXFLAGS"
402 cf_result="none"
403 for cf_math in "" MATH_H
404 do
405 for cf_excp in "" MATH_EXCEPTION
406 do
407         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu"
408         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
409         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
410 AC_TRY_COMPILE([
411 #include <etip.h.in>
412 ],[],[
413         test -n "$cf_math" && AC_DEFINE(ETIP_NEEDS_${cf_math})
414         test -n "$cf_excp" && AC_DEFINE(ETIP_NEEDS_${cf_excp})
415         cf_result="$cf_math $cf_excp"
416         break
417 ],[])
418 done
419 done
420 AC_MSG_RESULT($cf_result)
421 CXXFLAGS="$cf_save_CXXFLAGS"
422 ])
423 dnl ---------------------------------------------------------------------------
424 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
425 dnl is found, add our own version of memmove to the list of objects.
426 AC_DEFUN([CF_FUNC_MEMMOVE],
427 [
428 AC_CHECK_FUNC(memmove,,[
429 AC_CHECK_FUNC(bcopy,[
430         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
431                 AC_TRY_RUN([
432 int main() {
433         static char data[] = "abcdefghijklmnopqrstuwwxyz";
434         char temp[40];
435         bcopy(data, temp, sizeof(data));
436         bcopy(temp+10, temp, 15);
437         bcopy(temp+5, temp+15, 10);
438         exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
439 }
440                 ],
441                 [cf_cv_good_bcopy=yes],
442                 [cf_cv_good_bcopy=no],
443                 [cf_cv_good_bcopy=unknown])
444                 ])
445         ],[cf_cv_good_bcopy=no])
446         if test $cf_cv_good_bcopy = yes ; then
447                 AC_DEFINE(USE_OK_BCOPY)
448         else
449                 AC_DEFINE(USE_MY_MEMMOVE)
450         fi
451 ])])dnl
452 dnl ---------------------------------------------------------------------------
453 dnl Test for availability of useful gcc __attribute__ directives to quiet
454 dnl compiler warnings.  Though useful, not all are supported -- and contrary
455 dnl to documentation, unrecognized directives cause older compilers to barf.
456 AC_DEFUN([CF_GCC_ATTRIBUTES],
457 [
458 if test -n "$GCC"
459 then
460 cat > conftest.i <<EOF
461 #ifndef GCC_PRINTF
462 #define GCC_PRINTF 0
463 #endif
464 #ifndef GCC_SCANF
465 #define GCC_SCANF 0
466 #endif
467 #ifndef GCC_NORETURN
468 #define GCC_NORETURN /* nothing */
469 #endif
470 #ifndef GCC_UNUSED
471 #define GCC_UNUSED /* nothing */
472 #endif
473 EOF
474 if test -n "$GCC"
475 then
476         AC_CHECKING([for gcc __attribute__ directives])
477         changequote(,)dnl
478 cat > conftest.$ac_ext <<EOF
479 #line __oline__ "configure"
480 #include "confdefs.h"
481 #include "conftest.h"
482 #include "conftest.i"
483 #if     GCC_PRINTF
484 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
485 #else
486 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
487 #endif
488 #if     GCC_SCANF
489 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
490 #else
491 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
492 #endif
493 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
494 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
495 extern void foo(void) GCC_NORETURN;
496 int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
497 EOF
498         changequote([,])dnl
499         for cf_attribute in scanf printf unused noreturn
500         do
501                 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
502                 cf_directive="__attribute__(($cf_attribute))"
503                 echo "checking for gcc $cf_directive" 1>&AC_FD_CC
504                 case $cf_attribute in
505                 scanf|printf)
506                 cat >conftest.h <<EOF
507 #define GCC_$CF_ATTRIBUTE 1
508 EOF
509                         ;;
510                 *)
511                 cat >conftest.h <<EOF
512 #define GCC_$CF_ATTRIBUTE $cf_directive
513 EOF
514                         ;;
515                 esac
516                 if AC_TRY_EVAL(ac_compile); then
517                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
518                         cat conftest.h >>confdefs.h
519 #               else
520 #                       sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
521                 fi
522         done
523 else
524         fgrep define conftest.i >>confdefs.h
525 fi
526 rm -rf conftest*
527 fi
528 ])dnl
529 dnl ---------------------------------------------------------------------------
530 dnl Check if the compiler supports useful warning options.  There's a few that
531 dnl we don't use, simply because they're too noisy:
532 dnl
533 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
534 dnl     -Wredundant-decls (system headers make this too noisy)
535 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
536 dnl     -Wwrite-strings (too noisy, but should review occasionally)
537 dnl     -pedantic
538 dnl
539 AC_DEFUN([CF_GCC_WARNINGS],
540 [
541 if test -n "$GCC"
542 then
543         changequote(,)dnl
544         cat > conftest.$ac_ext <<EOF
545 #line __oline__ "configure"
546 int main(int argc, char *argv[]) { return (argv[argc-1] == 0) ; }
547 EOF
548         changequote([,])dnl
549         AC_CHECKING([for gcc warning options])
550         cf_save_CFLAGS="$CFLAGS"
551         EXTRA_CFLAGS="-W -Wall"
552         cf_warn_CONST=""
553         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
554         for cf_opt in \
555                 Wbad-function-cast \
556                 Wcast-align \
557                 Wcast-qual \
558                 Winline \
559                 Wmissing-declarations \
560                 Wmissing-prototypes \
561                 Wnested-externs \
562                 Wpointer-arith \
563                 Wshadow \
564                 Wstrict-prototypes $cf_warn_CONST
565         do
566                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
567                 if AC_TRY_EVAL(ac_compile); then
568                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
569                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
570                         test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
571                 fi
572         done
573         rm -f conftest*
574         CFLAGS="$cf_save_CFLAGS"
575 fi
576 AC_SUBST(EXTRA_CFLAGS)
577 ])dnl
578 dnl ---------------------------------------------------------------------------
579 dnl Verify that a test program compiles and runs with GNAT
580 dnl $cf_ada_make is set to the program that compiles/links
581 AC_DEFUN([CF_GNAT_TRY_RUN],
582 [
583 rm -f conftest*
584 cat >>conftest.ads <<CF_EOF
585 $1
586 CF_EOF
587 cat >>conftest.adb <<CF_EOF
588 $2
589 CF_EOF
590 if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
591    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
592 ifelse($3,,      :,[      $3])
593 ifelse($4,,,[   else
594       $4])
595    fi
596 ifelse($4,,,[else
597    $4])
598 fi
599 rm -f conftest*
600 ])dnl
601 dnl ---------------------------------------------------------------------------
602 dnl Verify Version of GNAT.
603 AC_DEFUN([CF_GNAT_VERSION],
604 [
605 changequote(<<, >>)dnl
606 cf_cv_gnat_version=`$cf_ada_make -v 2>&1 | grep '[0-9].[0-9][0-9]*' |\
607   sed -e 's/[^0-9 \.]//g' | $AWK '{print $<<1>>;}'`
608 case $cf_cv_gnat_version in
609   3.[1-9]*|[4-9].*)
610     cf_cv_prog_gnat_correct=yes
611     ;;
612   *) echo Unsupported GNAT version $cf_cv_gnat_version. Required is 3.10 or better. Disabling Ada95 binding.
613      cf_cv_prog_gnat_correct=no
614      ;;
615 esac
616 case $cf_cv_gnat_version in
617   3.1*|[4-9].*)
618       cf_compile_generics=generics
619       cf_generic_objects="\$(GENOBJS)"
620       ;;
621   *)  cf_compile_generics=
622       cf_generic_objects=
623       ;;
624 esac
625 changequote([, ])dnl
626 ])
627 dnl ---------------------------------------------------------------------------
628 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
629 AC_DEFUN([CF_HELP_MESSAGE],
630 [AC_DIVERT_HELP([$1])dnl
631 ])dnl
632 dnl ---------------------------------------------------------------------------
633 dnl Construct the list of include-options according to whether we're building
634 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
635 dnl with gcc, don't append the includedir if it happens to be /usr/include,
636 dnl since that usually breaks gcc's shadow-includes.
637 AC_DEFUN([CF_INCLUDE_DIRS],
638 [
639 CPPFLAGS="$CPPFLAGS -I. -I../include"
640 if test "$srcdir" != "."; then
641         CPPFLAGS="$CPPFLAGS -I\$(srcdir)/../include"
642 fi
643 if test -z "$GCC"; then
644         CPPFLAGS="$CPPFLAGS -I\$(includedir)"
645 elif test "$includedir" != "/usr/include"; then
646         if test "$includedir" = '${prefix}/include' ; then
647                 if test $prefix != /usr ; then
648                         CPPFLAGS="$CPPFLAGS -I\$(includedir)"
649                 fi
650         else
651                 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
652         fi
653 fi
654 AC_SUBST(CPPFLAGS)
655 ])dnl
656 dnl ---------------------------------------------------------------------------
657 dnl Check if we have either a function or macro for 'isascii()'.
658 AC_DEFUN([CF_ISASCII],
659 [
660 AC_MSG_CHECKING(for isascii)
661 AC_CACHE_VAL(cf_cv_have_isascii,[
662         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
663         [cf_cv_have_isascii=yes],
664         [cf_cv_have_isascii=no])
665 ])dnl
666 AC_MSG_RESULT($cf_cv_have_isascii)
667 test $cf_cv_have_isascii = yes && AC_DEFINE(HAVE_ISASCII)
668 ])dnl
669 dnl ---------------------------------------------------------------------------
670 dnl Compute the library-prefix for the given host system
671 dnl $1 = variable to set
672 AC_DEFUN([CF_LIB_PREFIX],
673 [
674         case $cf_cv_system_name in
675         os2)    $1=''     ;;
676         *)      $1='lib'  ;;
677         esac
678 ])dnl
679 dnl ---------------------------------------------------------------------------
680 dnl Append definitions and rules for the given models to the subdirectory
681 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
682 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
683 dnl the corresponding makefile to list the models that we'll generate.
684 dnl
685 dnl For shared libraries, make a list of symbolic links to construct when
686 dnl generating each library.  The convention used for Linux is the simplest
687 dnl one:
688 dnl     lib<name>.so    ->
689 dnl     lib<name>.so.<major>    ->
690 dnl     lib<name>.so.<maj>.<minor>
691 AC_DEFUN([CF_LIB_RULES],
692 [
693 CF_LIB_PREFIX(cf_prefix)
694 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
695 for cf_dir in $SRC_SUBDIRS
696 do
697         if test -f $srcdir/$cf_dir/modules; then
698
699                 cf_libs_to_make=
700                 for cf_item in $CF_LIST_MODELS
701                 do
702                         CF_LIB_SUFFIX($cf_item,cf_suffix)
703                         cf_libs_to_make="$cf_libs_to_make ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
704                 done
705
706                 if test $cf_dir = ncurses ; then
707                         case "$LIB_SUBSETS" in
708                         termlib+*) #(vi
709                                 ;;
710                         *) #(vi
711                                 cf_item=`echo $cf_libs_to_make |sed -e s/$LIB_NAME/$TINFO_NAME/g`
712                                 cf_libs_to_make="$cf_item $cf_libs_to_make"
713                                 ;;
714                         esac
715                 fi
716
717                 sed -e "s@\@LIBS_TO_MAKE\@@$cf_libs_to_make@" \
718                         $cf_dir/Makefile >$cf_dir/Makefile.out
719                 mv $cf_dir/Makefile.out $cf_dir/Makefile
720
721                 $AWK -f $srcdir/mk-0th.awk \
722                         name=$cf_dir \
723                         $srcdir/$cf_dir/modules >>$cf_dir/Makefile
724
725                 for cf_item in $CF_LIST_MODELS
726                 do
727                         echo 'Appending rules for '$cf_item' model ('$cf_dir')'
728                         CF_UPPER(CF_ITEM,$cf_item)
729                         CF_LIB_SUFFIX($cf_item,cf_suffix)
730                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
731
732                         # These dependencies really are for development, not
733                         # builds, but they are useful in porting, too.
734                         cf_depend="../include/ncurses_cfg.h"
735                         if test "$srcdir" = "."; then
736                                 cf_reldir="."
737                         else
738                                 cf_reldir="\$(srcdir)"
739                         fi
740
741                         if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
742                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
743                         elif test -f $srcdir/$cf_dir/curses.priv.h; then
744                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
745                         fi
746
747                         for cf_subset in $LIB_SUBSETS
748                         do
749                         $AWK -f $srcdir/mk-1st.awk \
750                                 name=$cf_dir \
751                                 MODEL=$CF_ITEM \
752                                 model=$cf_subdir \
753                                 prefix=$cf_prefix \
754                                 suffix=$cf_suffix \
755                                 subset=$cf_subset \
756                                 DoLinks=$cf_cv_do_symlinks \
757                                 rmSoLocs=$cf_cv_rm_so_locs \
758                                 ldconfig="$LDCONFIG" \
759                                 overwrite=$WITH_OVERWRITE \
760                                 depend="$cf_depend" \
761                                 target="$target" \
762                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
763                         test $cf_dir = ncurses && WITH_OVERWRITE=no
764                         $AWK -f $srcdir/mk-2nd.awk \
765                                 name=$cf_dir \
766                                 MODEL=$CF_ITEM \
767                                 model=$cf_subdir \
768                                 subset=$cf_subset \
769                                 srcdir=$srcdir \
770                                 echo=$WITH_ECHO \
771                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
772                         done
773                 done
774         fi
775
776         echo '  cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
777 done
778
779 for cf_dir in $SRC_SUBDIRS
780 do
781         if test -f $cf_dir/Makefile ; then
782                 case "$cf_dir" in
783                 Ada95) #(vi
784                         echo 'install.libs \' >> Makefile
785                         echo 'uninstall.libs ::' >> Makefile
786                         echo '  cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
787                         ;;
788                 esac
789         fi
790
791         if test -f $srcdir/$cf_dir/modules; then
792                 echo >> Makefile
793                 if test -f $srcdir/$cf_dir/headers; then
794 cat >> Makefile <<CF_EOF
795 install.includes \\
796 uninstall.includes \\
797 CF_EOF
798                 fi
799 if test "$cf_dir" != "c++" ; then
800 echo 'lint \' >> Makefile
801 fi
802 cat >> Makefile <<CF_EOF
803 lintlib \\
804 install.libs \\
805 uninstall.libs \\
806 install.$cf_dir \\
807 uninstall.$cf_dir ::
808         cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
809 CF_EOF
810         elif test -f $srcdir/$cf_dir/headers; then
811 cat >> Makefile <<CF_EOF
812
813 install.libs \\
814 uninstall.libs \\
815 install.includes \\
816 uninstall.includes ::
817         cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
818 CF_EOF
819 fi
820 done
821
822 cat >> Makefile <<CF_EOF
823
824 install.data ::
825         cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
826
827 install.man ::
828         cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
829
830 distclean ::
831         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
832         rm -f headers.sh headers.sed
833         rm -rf \$(DIRS_TO_MAKE)
834 CF_EOF
835
836 dnl If we're installing into a subdirectory of /usr/include, etc., we should
837 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
838 dnl anything, and will make it more standardized.  It's awkward to decide this
839 dnl at configuration because of quoting, so we'll simply make all headers
840 dnl installed via a script that can do the right thing.
841
842 rm -f headers.sed headers.sh
843
844 dnl ( generating this script makes the makefiles a little tidier :-)
845 echo creating headers.sh
846 cat >headers.sh <<CF_EOF
847 #! /bin/sh
848 # This shell script is generated by the 'configure' script.  It is invoked in a
849 # subdirectory of the build tree.  It generates a sed-script in the parent
850 # directory that is used to adjust includes for header files that reside in a
851 # subdirectory of /usr/include, etc.
852 PRG=""
853 while test \[$]# != 3
854 do
855 PRG="\$PRG \[$]1"; shift
856 done
857 DST=\[$]1
858 REF=\[$]2
859 SRC=\[$]3
860 echo installing \$SRC in \$DST
861 case \$DST in
862 /*/include/*)
863         TMP=\${TMPDIR-/tmp}/\`basename \$SRC\`
864         if test ! -f ../headers.sed ; then
865                 END=\`basename \$DST\`
866                 for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
867                 do
868                         NAME=\`basename \$i\`
869                         echo "s/<\$NAME>/<\$END\/\$NAME>/" >> ../headers.sed
870                 done
871         fi
872         rm -f \$TMP
873         sed -f ../headers.sed \$SRC > \$TMP
874         eval \$PRG \$TMP \$DST
875         rm -f \$TMP
876         ;;
877 *)
878         eval \$PRG \$SRC \$DST
879         ;;
880 esac
881 CF_EOF
882
883 chmod 0755 headers.sh
884
885 for cf_dir in $SRC_SUBDIRS
886 do
887         if test -f $srcdir/$cf_dir/headers; then
888         cat >>$cf_dir/Makefile <<CF_EOF
889 \$(INSTALL_PREFIX)\$(includedir) :
890         \$(srcdir)/../mkinstalldirs \[$]@
891
892 install \\
893 install.libs \\
894 install.includes :: \$(INSTALL_PREFIX)\$(includedir) \\
895 CF_EOF
896                 j=""
897                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
898                 do
899                         test -n "$j" && echo "          $j \\" >>$cf_dir/Makefile
900                         j=$i
901                 done
902                 echo "          $j" >>$cf_dir/Makefile
903                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
904                 do
905                         echo "  @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(INSTALL_PREFIX)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
906                         test $i = curses.h && echo "    @ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h && \$(LN_S) curses.h ncurses.h)" >>$cf_dir/Makefile
907                 done
908
909         cat >>$cf_dir/Makefile <<CF_EOF
910
911 uninstall \\
912 uninstall.libs \\
913 uninstall.includes ::
914 CF_EOF
915                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
916                 do
917                         i=`basename $i`
918                         echo "  -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
919                         test $i = curses.h && echo "    -@ (cd \$(INSTALL_PREFIX)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
920                 done
921         fi
922 done
923
924 ])dnl
925 dnl ---------------------------------------------------------------------------
926 dnl Compute the library-suffix from the given model name
927 dnl $1 = model name
928 dnl $2 = variable to set
929 AC_DEFUN([CF_LIB_SUFFIX],
930 [
931         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
932         case $1 in
933         normal)  $2='.a'   ;;
934         debug)   $2='_g.a' ;;
935         profile) $2='_p.a' ;;
936         shared)
937                 case $cf_cv_system_name in
938                 openbsd*|netbsd*|freebsd*)
939                         $2='.so.$(REL_VERSION)' ;;
940                 hpux*)  $2='.sl'  ;;
941                 *)      $2='.so'  ;;
942                 esac
943         esac
944 ])dnl
945 dnl ---------------------------------------------------------------------------
946 dnl Compute the string to append to -library from the given model name
947 AC_DEFUN([CF_LIB_TYPE],
948 [
949         case $1 in
950         normal)  $2=''   ;;
951         debug)   $2='_g' ;;
952         profile) $2='_p' ;;
953         shared)  $2=''   ;;
954         esac
955 ])dnl
956 dnl ---------------------------------------------------------------------------
957 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
958 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
959 dnl have to provide wrappers for global tables to ensure they're linked
960 dnl properly.
961 AC_DEFUN([CF_LINK_DATAONLY],
962 [
963 AC_MSG_CHECKING([if data-only library module links])
964 AC_CACHE_VAL(cf_cv_link_dataonly,[
965         rm -f conftest.a
966         changequote(,)dnl
967         cat >conftest.$ac_ext <<EOF
968 #line __oline__ "configure"
969 int     testdata[3] = { 123, 456, 789 };
970 EOF
971         changequote([,])dnl
972         if AC_TRY_EVAL(ac_compile) ; then
973                 mv conftest.o data.o && \
974                 ( $AR $AR_OPTS conftest.a data.o ) 2>&5 1>/dev/null
975         fi
976         rm -f conftest.$ac_ext data.o
977         changequote(,)dnl
978         cat >conftest.$ac_ext <<EOF
979 #line __oline__ "configure"
980 int     testfunc()
981 {
982 #if defined(NeXT)
983         exit(1);        /* I'm told this linker is broken */
984 #else
985         extern int testdata[3];
986         return testdata[0] == 123
987            &&  testdata[1] == 456
988            &&  testdata[2] == 789;
989 #endif
990 }
991 EOF
992         changequote([,])dnl
993         if AC_TRY_EVAL(ac_compile); then
994                 mv conftest.o func.o && \
995                 ( $AR $AR_OPTS conftest.a func.o ) 2>&5 1>/dev/null
996         fi
997         rm -f conftest.$ac_ext func.o
998         ( eval $ac_cv_prog_RANLIB conftest.a ) 2>&5 >/dev/null
999         cf_saveLIBS="$LIBS"
1000         LIBS="conftest.a $LIBS"
1001         AC_TRY_RUN([
1002         int main()
1003         {
1004                 extern int testfunc();
1005                 exit (!testfunc());
1006         }
1007         ],
1008         [cf_cv_link_dataonly=yes],
1009         [cf_cv_link_dataonly=no],
1010         [cf_cv_link_dataonly=unknown])
1011         LIBS="$cf_saveLIBS"
1012         ])
1013 AC_MSG_RESULT($cf_cv_link_dataonly)
1014 test $cf_cv_link_dataonly = no && AC_DEFINE(BROKEN_LINKER)
1015 ])dnl
1016 dnl ---------------------------------------------------------------------------
1017 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1018 dnl A few non-Unix systems implement symlink, but not link.
1019 dnl A few non-systems implement neither (or have nonfunctional versions).
1020 AC_DEFUN([CF_LINK_FUNCS],
1021 [
1022 AC_CHECK_FUNCS( \
1023         remove \
1024         unlink )
1025
1026 if test "$ac_cv_prog_cc_cross" = yes ; then
1027         AC_CHECK_FUNCS( \
1028                 link \
1029                 symlink )
1030 else
1031         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1032                 cf_cv_link_funcs=
1033                 for cf_func in link symlink ; do
1034                         AC_TRY_RUN([
1035 #include <sys/types.h>
1036 #include <sys/stat.h>
1037 #ifdef HAVE_UNISTD_H
1038 #include <unistd.h>
1039 #endif
1040 int main()
1041 {
1042         int fail = 0;
1043         char *src = "config.log";
1044         char *dst = "conftest.chk";
1045         struct stat src_sb;
1046         struct stat dst_sb;
1047
1048         stat(src, &src_sb);
1049         fail = ($cf_func("config.log", "conftest.chk") < 0)
1050             || (stat(dst, &dst_sb) < 0)
1051             || (dst_sb.st_mtime != src_sb.st_mtime);
1052 #ifdef HAVE_UNLINK
1053         unlink(dst);
1054 #else
1055         remove(dst);
1056 #endif
1057         exit (fail);
1058 }
1059                         ],[
1060                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1061                         eval 'ac_cv_func_'$cf_func'=yes'],[
1062                         eval 'ac_cv_func_'$cf_func'=no'],[
1063                         eval 'ac_cv_func_'$cf_func'=error'])
1064                 done
1065                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1066         ])
1067 fi
1068 ])dnl
1069 dnl ---------------------------------------------------------------------------
1070 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1071 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
1072 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1073 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1074 AC_DEFUN([CF_MAKEFLAGS],
1075 [
1076 AC_MSG_CHECKING([for makeflags variable])
1077 AC_CACHE_VAL(cf_cv_makeflags,[
1078         cf_cv_makeflags=''
1079         for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)' 
1080         do
1081                 cat >cf_makeflags.tmp <<CF_EOF
1082 all :
1083         @ echo '.$cf_option'
1084 CF_EOF
1085                 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1086                 case "$cf_result" in
1087                 .*k)
1088                         cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1089                         case "$cf_result" in
1090                         .*CC=*) cf_cv_makeflags=
1091                                 ;;
1092                         *)      cf_cv_makeflags=$cf_option
1093                                 ;;
1094                         esac
1095                         break
1096                         ;;
1097                 *)      echo no match "$cf_result"
1098                         ;;
1099                 esac
1100         done
1101         rm -f cf_makeflags.tmp])
1102 AC_MSG_RESULT($cf_cv_makeflags)
1103 AC_SUBST(cf_cv_makeflags)
1104 ])dnl
1105 dnl ---------------------------------------------------------------------------
1106 dnl Option to allow user to override automatic configuration of manpage format.
1107 dnl There are several special cases.
1108 AC_DEFUN([CF_MANPAGE_FORMAT],
1109 [ AC_MSG_CHECKING(format of man-pages)
1110
1111 AC_ARG_WITH(manpage-format,
1112         [  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
1113                           optionally formatted, e.g., gzip,formatted],
1114         [cf_manpage_form=$withval],
1115         [cf_manpage_form=unknown])
1116
1117 case ".$cf_manpage_form" in
1118 .gzip|.compress|.BSDI|.normal|.formatted) # (vi
1119   ;;
1120 .unknown|.) # (vi
1121   if test -z "$MANPATH" ; then
1122     MANPATH="/usr/man:/usr/share/man"
1123   fi
1124   # look for the 'date' man-page (it's most likely to be installed!)
1125   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1126   cf_manpage_form=unknown
1127   for cf_dir in $MANPATH; do
1128     test -z "$cf_dir" && cf_dir=/usr/man
1129 changequote({{,}})dnl
1130     for cf_name in $cf_dir/*/date.[01]* $cf_dir/*/date
1131 changequote([,])dnl
1132     do
1133        cf_test=`echo $cf_name | sed -e 's/*//'`
1134        if test "x$cf_test" = "x$cf_name" ; then
1135           case "$cf_name" in
1136           *.gz) cf_manpage_form=gzip;;
1137           *.Z)  cf_manpage_form=compress;;
1138           *.0)  cf_manpage_form=BSDI,formatted;;
1139           *)    cf_manpage_form=normal;;
1140           esac
1141           break
1142        fi
1143     done
1144     if test "$cf_manpage_form" != "unknown" ; then
1145        break
1146     fi
1147   done
1148   IFS="$ac_save_ifs"
1149   ;;
1150 .*) # (vi
1151   AC_MSG_WARN(Unexpected manpage-format)
1152   ;;
1153 esac
1154
1155 AC_MSG_RESULT($cf_manpage_form)
1156 ])dnl
1157 dnl ---------------------------------------------------------------------------
1158 dnl The Debian people have their own naming convention for manpages.  This
1159 dnl option lets us override the name of the file containing renaming, or
1160 dnl disable it altogether.
1161 AC_DEFUN([CF_MANPAGE_RENAMES],
1162 [
1163 AC_MSG_CHECKING(for manpage renaming)
1164
1165 AC_ARG_WITH(manpage-renames,
1166         [  --with-manpage-renames  specify manpage-renaming],
1167         [cf_manpage_renames=$withval],
1168         [cf_manpage_renames=yes])
1169
1170 case ".$cf_manpage_renames" in #(vi
1171 .no) #(vi
1172   ;;
1173 .|.yes)
1174   # Debian 'man' program?
1175   if test -f /etc/debian_version ; then
1176     cf_manpage_renames=`cd $srcdir && pwd`/man/man_db.renames
1177   else
1178     cf_manpage_renames=no
1179   fi
1180   ;;
1181 esac
1182
1183 if test "$cf_manpage_renames" != no ; then
1184   if test ! -f $cf_manpage_renames ; then
1185     AC_MSG_ERROR(not a filename: $cf_manpage_renames)
1186   fi
1187
1188   test ! -d man && mkdir man
1189
1190   # Construct a sed-script to perform renaming within man-pages
1191   if test -n "$cf_manpage_renames" ; then
1192     test ! -d man && mkdir man
1193     $srcdir/man/make_sed.sh $cf_manpage_renames >man/edit_man.sed
1194   fi
1195 fi
1196
1197 AC_MSG_RESULT($cf_manpage_renames)
1198 ])dnl
1199 dnl ---------------------------------------------------------------------------
1200 dnl Try to determine if the man-pages on the system are compressed, and if
1201 dnl so, what format is used.  Use this information to construct a script that
1202 dnl will install man-pages.
1203 AC_DEFUN([CF_MAN_PAGES],
1204 [
1205 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
1206 CF_MANPAGE_FORMAT
1207 CF_MANPAGE_RENAMES
1208
1209   if test "$prefix" = "NONE" ; then
1210      cf_prefix="$ac_default_prefix"
1211   else
1212      cf_prefix="$prefix"
1213   fi
1214
1215   case "$cf_manpage_form" in # (vi
1216   *formatted*) # (vi
1217     cf_subdir='$mandir/cat'
1218     cf_format=yes
1219     ;;
1220   *)
1221     cf_subdir='$mandir/man'
1222     cf_format=no
1223     ;;
1224   esac
1225
1226 test ! -d man && mkdir man
1227 cat >man/edit_man.sh <<CF_EOF
1228 changequote({{,}})dnl
1229 #! /bin/sh
1230 # this script is generated by the configure-script
1231 prefix="$cf_prefix"
1232 datadir="$datadir"
1233 MKDIRS="`cd $srcdir && pwd`/mkinstalldirs"
1234 INSTALL="$INSTALL"
1235 INSTALL_DATA="$INSTALL_DATA"
1236 TMP=\${TMPDIR-/tmp}/man\$\$
1237 trap "rm -f \$TMP" 0 1 2 5 15
1238
1239 verb=\{{$}}1
1240 shift
1241
1242 mandir=\{{$}}1
1243 shift
1244
1245 for i in \{{$}}* ; do
1246 case \$i in #(vi
1247 *.orig|*.rej) ;; #(vi
1248 *.[0-9]*)
1249         section=\`expr "\$i" : '.*\\.\\([0-9]\\)[xm]*'\`;
1250         if test \$verb = installing ; then
1251         if test ! -d $cf_subdir\${section} ; then
1252                 \$MKDIRS $cf_subdir\$section
1253         fi
1254         fi
1255         source=\`basename \$i\`
1256 CF_EOF
1257 if test "$cf_manpage_renames" = no ; then
1258 cat >>man/edit_man.sh <<CF_EOF
1259         target=$cf_subdir\${section}/\$source
1260         sed -e "s,@DATADIR@,\$datadir," < \$i >\$TMP
1261 CF_EOF
1262 else
1263 cat >>man/edit_man.sh <<CF_EOF
1264         target=\`grep "^\$source" $cf_manpage_renames | $AWK '{print \{{$}}2}'\`
1265         if test -z "\$target" ; then
1266                 echo '? missing rename for '\$source
1267                 target="\$source"
1268         fi
1269         target="$cf_subdir\$section/\$target"
1270         test \$verb = installing && sed -e "s,@DATADIR@,\$datadir," < \$i | sed -f edit_man.sed >\$TMP
1271 CF_EOF
1272 fi
1273 if test $cf_format = yes ; then
1274 cat >>man/edit_man.sh <<CF_EOF
1275         nroff -man \$TMP >\$TMP.out
1276         mv \$TMP.out \$TMP
1277 CF_EOF
1278 fi
1279 case "$cf_manpage_form" in #(vi
1280 *compress*) #(vi
1281 cat >>man/edit_man.sh <<CF_EOF
1282         if test \$verb = installing ; then
1283         if ( compress -f \$TMP )
1284         then
1285                 mv \$TMP.Z \$TMP
1286         fi
1287         fi
1288         target="\$target.Z"
1289 CF_EOF
1290   ;;
1291 *gzip*) #(vi
1292 cat >>man/edit_man.sh <<CF_EOF
1293         if test \$verb = installing ; then
1294         if ( gzip -f \$TMP )
1295         then
1296                 mv \$TMP.gz \$TMP
1297         fi
1298         fi
1299         target="\$target.gz"
1300 CF_EOF
1301   ;;
1302 *BSDI*)
1303 cat >>man/edit_man.sh <<CF_EOF
1304         # BSDI installs only .0 suffixes in the cat directories
1305         target="\`echo \$target|sed -e 's/\.[1-9]\+.\?/.0/'\`"
1306 CF_EOF
1307   ;;
1308 esac
1309 cat >>man/edit_man.sh <<CF_EOF
1310         echo \$verb \$target
1311         if test \$verb = installing ; then
1312                 \$INSTALL_DATA \$TMP \$target
1313         else
1314                 rm -f \$target
1315         fi
1316         ;;
1317 esac
1318 done
1319 CF_EOF
1320 changequote([,])dnl
1321 chmod 755 man/edit_man.sh
1322
1323 ])dnl
1324 dnl ---------------------------------------------------------------------------
1325 dnl Compute the object-directory name from the given model name
1326 AC_DEFUN([CF_OBJ_SUBDIR],
1327 [
1328         case $1 in
1329         normal)  $2='objects' ;;
1330         debug)   $2='obj_g' ;;
1331         profile) $2='obj_p' ;;
1332         shared)  $2='obj_s' ;;
1333         esac
1334 ])dnl
1335 dnl ---------------------------------------------------------------------------
1336 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
1337 dnl begins with one of the prefix/exec_prefix variables, and then again if the
1338 dnl result begins with 'NONE'.  This is necessary to workaround autoconf's
1339 dnl delayed evaluation of those symbols.
1340 AC_DEFUN([CF_PATH_SYNTAX],[
1341 case ".[$]$1" in #(vi
1342 ./*) #(vi
1343   ;;
1344 .\[$]{*prefix}*) #(vi
1345   eval $1="[$]$1"
1346   case ".[$]$1" in #(vi
1347   .NONE/*)
1348     $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1349     ;;
1350   esac
1351   ;; #(vi
1352 .NONE/*)
1353   $1=`echo [$]$1 | sed -e s@NONE@$ac_default_prefix@`
1354   ;;
1355 *)
1356   AC_ERROR(expected a pathname)
1357   ;;
1358 esac
1359 ])dnl
1360 dnl ---------------------------------------------------------------------------
1361 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
1362 AC_DEFUN([CF_PROG_EXT],
1363 [
1364 AC_REQUIRE([CF_CHECK_CACHE])
1365 PROG_EXT=
1366 case $cf_cv_system_name in
1367 os2*)
1368     # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@
1369     CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__"
1370     LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"`
1371     PROG_EXT=".exe"
1372     ;;
1373 esac
1374 AC_SUBST(PROG_EXT)
1375 ])dnl
1376 dnl ---------------------------------------------------------------------------
1377 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
1378 dnl misc/tabset install won't work properly.  Usually this happens only when
1379 dnl using the fallback mkinstalldirs script
1380 AC_DEFUN([CF_PROG_INSTALL],
1381 [AC_PROG_INSTALL
1382 case $INSTALL in
1383 /*)
1384   ;;
1385 *)
1386 changequote({{,}})dnl
1387   cf_dir=`echo $INSTALL|sed -e 's%/[^/]*$%%'`
1388   test -z "$cf_dir" && cf_dir=.
1389 changequote([,])dnl
1390   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's:^.*/::'`
1391   ;;
1392 esac
1393 ])dnl
1394 dnl ---------------------------------------------------------------------------
1395 dnl Attempt to determine if we've got one of the flavors of regular-expression
1396 dnl code that we can support.
1397 AC_DEFUN([CF_REGEX],
1398 [
1399 AC_MSG_CHECKING([for regular-expression headers])
1400 AC_CACHE_VAL(cf_cv_regex,[
1401 AC_TRY_LINK([#include <sys/types.h>
1402 #include <regex.h>],[
1403         regex_t *p;
1404         int x = regcomp(p, "", 0);
1405         int y = regexec(p, "", 0, 0, 0);
1406         regfree(p);
1407         ],[cf_cv_regex="regex.h"],[
1408         AC_TRY_LINK([#include <regexp.h>],[
1409                 char *p = compile("", "", "", 0);
1410                 int x = step("", "");
1411         ],[cf_cv_regex="regexp.h"],[
1412                 cf_save_LIBS="$LIBS"
1413                 LIBS="-lgen $LIBS"
1414                 AC_TRY_LINK([#include <regexpr.h>],[
1415                         char *p = compile("", "", "");
1416                         int x = step("", "");
1417                 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
1418 ])
1419 AC_MSG_RESULT($cf_cv_regex)
1420 case $cf_cv_regex in
1421         regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
1422         regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
1423         regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
1424 esac
1425 ])dnl
1426 dnl ---------------------------------------------------------------------------
1427 dnl Attempt to determine the appropriate CC/LD options for creating a shared
1428 dnl library.
1429 dnl
1430 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
1431 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
1432 dnl We avoid compiling-in a ../lib path for the shared library since that can
1433 dnl lead to unexpected results at runtime.
1434 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
1435 dnl are compiled in ../../lib
1436 dnl
1437 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
1438 dnl to install symbolic links to the rel/abi versions of shared libraries.
1439 dnl
1440 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
1441 dnl version when making symbolic links.
1442 dnl
1443 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
1444 AC_DEFUN([CF_SHARED_OPTS],
1445 [
1446         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1447         LOCAL_LDFLAGS=
1448         LOCAL_LDFLAGS2=
1449         LD_SHARED_OPTS=
1450         INSTALL_LIB="-m 644"
1451
1452         cf_cv_do_symlinks=no
1453
1454         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
1455         AC_ARG_WITH(shlib-version,
1456         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
1457         [test -z "$withval" && withval=auto
1458         case $withval in #(vi
1459         yes) #(vi
1460                 cf_cv_shlib_version=auto
1461                 ;;
1462         rel|abi|auto|no) #(vi
1463                 cf_cv_shlib_version=$withval
1464                 ;;
1465         *)
1466                 AC_ERROR([option value must be one of: rel, abi, auto or no])
1467                 ;;
1468         esac
1469         ],[cf_cv_shlib_version=auto])
1470         AC_MSG_RESULT($cf_cv_shlib_version)
1471
1472         cf_cv_rm_so_locs=no
1473
1474         case $cf_cv_system_name in
1475         hpux10.*)
1476                 # (tested with gcc 2.7.2 -- I don't have c89)
1477                 if test -n "$GCC"; then
1478                         CC_SHARED_OPTS='-fPIC'
1479                         LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1480                 else
1481                         CC_SHARED_OPTS='+Z'
1482                         LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1483                 fi
1484                 MK_SHARED_LIB='$(LD) +b $(libdir) -b +h `basename $[@]` -o $[@]'
1485                 # HP-UX shared libraries must be executable, and should be
1486                 # readonly to exploit a quirk in the memory manager.
1487                 INSTALL_LIB="-m 555"
1488                 cf_cv_do_symlinks=reverse
1489                 ;;
1490         hpux*)
1491                 # (tested with gcc 2.7.2 -- I don't have c89)
1492                 if test -n "$GCC"; then
1493                         CC_SHARED_OPTS='-fPIC'
1494                         LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
1495                 else
1496                         CC_SHARED_OPTS='+Z'
1497                         LD_SHARED_OPTS='-Wl,+b,$(libdir)'
1498                 fi
1499                 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]'
1500                 # HP-UX shared libraries must be executable, and should be
1501                 # readonly to exploit a quirk in the memory manager.
1502                 INSTALL_LIB="-m 555"
1503                 ;;
1504         irix*)
1505                 # tested with IRIX 5.2 and 'cc'.
1506                 if test -n "$GCC"; then
1507                         CC_SHARED_OPTS='-fPIC'
1508                 else
1509                         CC_SHARED_OPTS='-KPIC'
1510                 fi
1511                 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
1512                 cf_cv_rm_so_locs=yes
1513                 ;;
1514         linux*|gnu*)
1515                 # tested with Linux 2.0.29 and gcc 2.7.2 (ELF)
1516                 CC_SHARED_OPTS='-fpic'
1517                 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-Wl,-rpath,"
1518                 if test $DFT_LWR_MODEL = "shared" ; then
1519                         LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1520                         LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1521                 fi
1522                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1523                 if test $cf_cv_shlib_version = no ; then
1524                         MK_SHARED_LIB='gcc -shared -Wl,-stats,-lc -o $[@]'
1525                 else
1526                         MK_SHARED_LIB='gcc -shared -Wl,-soname,`basename $[@].$(ABI_VERSION)`,-stats,-lc -o $[@]'
1527                 fi
1528                 ;;
1529         openbsd2*)
1530                 CC_SHARED_OPTS='-fpic -DPIC'
1531                 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
1532                 ;;
1533         openbsd*|netbsd*|freebsd*)
1534                 CC_SHARED_OPTS='-fpic -DPIC'
1535                 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
1536                 ;;
1537         osf*|mls+*)
1538                 # tested with OSF/1 V3.2 and 'cc'
1539                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
1540                 # link with shared libs).
1541                 CC_SHARED_OPTS=''
1542                 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`'
1543                 test $cf_cv_ld_rpath = yes && cf_ld_rpath_opt="-rpath"
1544                 case $host_os in
1545                 osf4*)
1546                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
1547                         ;;
1548                 esac
1549                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
1550                 if test $DFT_LWR_MODEL = "shared" ; then
1551                         LOCAL_LDFLAGS='-Wl,-rpath,../lib'
1552                         LOCAL_LDFLAGS2='-Wl,-rpath,../../lib'
1553                 fi
1554                 cf_cv_rm_so_locs=yes
1555                 ;;
1556         sco3.2v5*)  # (also uw2* and UW7) hops 13-Apr-98
1557                 # tested with osr5.0.5
1558                 if test $ac_cv_prog_gcc = yes; then
1559                         CC_SHARED_OPTS='-melf -fpic'
1560                 else
1561                         CC_SHARED_OPTS='-KPIC'
1562                 fi
1563                 MK_SHARED_LIB='$(LD) -dy -G -h `basename [$]@.$(ABI_VERSION)` -o [$]@'
1564                 if test $cf_cv_ld_rpath = yes ; then
1565                         # only way is to set LD_RUN_PATH but no switch for it
1566                         RUN_PATH=$libdir
1567                 fi
1568                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1569                 LINK_PROGS='LD_RUN_PATH=$(libdir)'
1570                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
1571                 ;;
1572         sunos4*)
1573                 # tested with SunOS 4.1.1 and gcc 2.7.0
1574                 if test $ac_cv_prog_gcc = yes; then
1575                         CC_SHARED_OPTS='-fpic'
1576                 else
1577                         CC_SHARED_OPTS='-KPIC'
1578                 fi
1579                 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]'
1580                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1581                 ;;
1582         solaris2*)
1583                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
1584                 if test $ac_cv_prog_gcc = yes; then
1585                         CC_SHARED_OPTS='-fpic'
1586                 else
1587                         CC_SHARED_OPTS='-KPIC'
1588                 fi
1589                 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@].$(ABI_VERSION)` -o $[@]'
1590                 if test $cf_cv_ld_rpath = yes ; then
1591                         cf_ld_rpath_opt="-R"
1592                         EXTRA_LDFLAGS="-R ../lib:\$(libdir) $EXTRA_LDFLAGS"
1593                 fi
1594                 test $cf_cv_shlib_version = auto && cf_cv_shlib_version=rel
1595                 ;;
1596         unix_sv*)
1597                 # tested with UnixWare 1.1.2
1598                 CC_SHARED_OPTS='-KPIC'
1599                 MK_SHARED_LIB='$(LD) -d y -G -o $[@]'
1600                 ;;
1601         *)
1602                 CC_SHARED_OPTS='unknown'
1603                 MK_SHARED_LIB='echo unknown'
1604                 ;;
1605         esac
1606
1607         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
1608         case "$cf_cv_shlib_version" in #(vi
1609         rel|abi)
1610                 case "$MK_SHARED_LIB" in #(vi
1611                 *'-o $[@]')
1612                         if test "$cf_cv_do_symlinks" = reverse ; then
1613                                 AC_ERROR(cannot use --with-shlib-version with this platform)
1614                         fi
1615                         if test "$cf_cv_shlib_version" = rel ; then
1616                                 MK_SHARED_LIB="$MK_SHARED_LIB"'.$(REL_VERSION)'
1617                         else
1618                                 MK_SHARED_LIB="$MK_SHARED_LIB"'.$(ABI_VERSION)'
1619                         fi
1620                         cf_cv_do_symlinks=yes
1621                         ;;
1622                 *)
1623                         AC_MSG_WARN(ignored --with-shlib-version)
1624                         ;;
1625                 esac
1626                 ;;
1627         esac
1628
1629         if test -n "$cf_ld_rpath_opt" ; then
1630                 AC_MSG_CHECKING(if we need a space after rpath option)
1631                 cf_save_LIBS="$LIBS"
1632                 LIBS="$LIBS ${cf_ld_rpath_opt}/usr/lib"
1633                 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1634                 LIBS="$cf_save_LIBS"
1635                 AC_MSG_RESULT($cf_rpath_space)
1636                 test $cf_rpath_space = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
1637                 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
1638         fi
1639
1640         AC_SUBST(CC_SHARED_OPTS)
1641         AC_SUBST(LD_SHARED_OPTS)
1642         AC_SUBST(MK_SHARED_LIB)
1643         AC_SUBST(LINK_PROGS)
1644         AC_SUBST(LINK_TESTS)
1645         AC_SUBST(EXTRA_LDFLAGS)
1646         AC_SUBST(LOCAL_LDFLAGS)
1647         AC_SUBST(LOCAL_LDFLAGS2)
1648         AC_SUBST(INSTALL_LIB)
1649 ])dnl
1650 dnl ---------------------------------------------------------------------------
1651 dnl Check for definitions & structures needed for window size-changing
1652 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
1653 AC_DEFUN([CF_SIZECHANGE],
1654 [
1655 AC_MSG_CHECKING([declaration of size-change])
1656 AC_CACHE_VAL(cf_cv_sizechange,[
1657     cf_cv_sizechange=unknown
1658     cf_save_CFLAGS="$CFLAGS"
1659
1660 for cf_opts in "" "NEED_PTEM_H"
1661 do
1662
1663     CFLAGS="$cf_save_CFLAGS"
1664     test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts"
1665     AC_TRY_COMPILE([#include <sys/types.h>
1666 #if HAVE_TERMIOS_H
1667 #include <termios.h>
1668 #else
1669 #if HAVE_TERMIO_H
1670 #include <termio.h>
1671 #endif
1672 #endif
1673 #if NEED_PTEM_H
1674 /* This is a workaround for SCO:  they neglected to define struct winsize in
1675  * termios.h -- it's only in termio.h and ptem.h
1676  */
1677 #include        <sys/stream.h>
1678 #include        <sys/ptem.h>
1679 #endif
1680 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
1681 #include <sys/ioctl.h>
1682 #endif
1683 ],[
1684 #ifdef TIOCGSIZE
1685         struct ttysize win;     /* FIXME: what system is this? */
1686         int y = win.ts_lines;
1687         int x = win.ts_cols;
1688 #else
1689 #ifdef TIOCGWINSZ
1690         struct winsize win;
1691         int y = win.ws_row;
1692         int x = win.ws_col;
1693 #else
1694         no TIOCGSIZE or TIOCGWINSZ
1695 #endif /* TIOCGWINSZ */
1696 #endif /* TIOCGSIZE */
1697         ],
1698         [cf_cv_sizechange=yes],
1699         [cf_cv_sizechange=no])
1700
1701         CFLAGS="$cf_save_CFLAGS"
1702         if test "$cf_cv_sizechange" = yes ; then
1703                 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
1704                 test -n "$cf_opts" && AC_DEFINE_UNQUOTED($cf_opts)
1705                 break
1706         fi
1707 done
1708         ])
1709 AC_MSG_RESULT($cf_cv_sizechange)
1710 test $cf_cv_sizechange != no && AC_DEFINE(HAVE_SIZECHANGE)
1711 ])dnl
1712 dnl ---------------------------------------------------------------------------
1713 dnl Check for datatype 'speed_t', which is normally declared via either
1714 dnl sys/types.h or termios.h
1715 AC_DEFUN([CF_SPEED_TYPE],
1716 [
1717 AC_MSG_CHECKING(for speed_t)
1718 OSPEED_INCLUDES=
1719 AC_TRY_COMPILE([#include <sys/types.h>],
1720         [speed_t some_variable = 0],
1721         [OSPEED_TYPE=speed_t],
1722         [OSPEED_TYPE=unsigned])
1723 AC_TRY_COMPILE([#include <termios.h>],
1724         [speed_t some_variable = 0],
1725         [OSPEED_TYPE=speed_t
1726          OSPEED_INCLUDES="#include <termios.h>"],[])
1727 AC_SUBST(OSPEED_TYPE)
1728 AC_SUBST(OSPEED_INCLUDES)
1729 if test "$OSPEED_TYPE" = "unsigned" ; then
1730         AC_MSG_RESULT(no)
1731         AC_DEFINE(speed_t,unsigned)
1732 else
1733         AC_MSG_RESULT(yes)
1734 fi
1735 ])dnl
1736 dnl ---------------------------------------------------------------------------
1737 dnl For each parameter, test if the source-directory exists, and if it contains
1738 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
1739 dnl use in CF_LIB_RULES.
1740 dnl
1741 dnl This uses the configured value to make the lists SRC_SUBDIRS and
1742 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
1743 AC_DEFUN([CF_SRC_MODULES],
1744 [
1745 AC_MSG_CHECKING(for src modules)
1746
1747 # dependencies and linker-arguments for test-programs
1748 TEST_DEPS="${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
1749 TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
1750
1751 # dependencies and linker-arguments for utility-programs
1752 PROG_ARGS="$TEST_ARGS"
1753
1754 cf_cv_src_modules=
1755 for cf_dir in $1
1756 do
1757         if test -f $srcdir/$cf_dir/modules; then
1758
1759                 # We may/may not have tack in the distribution, though the
1760                 # makefile is.
1761                 if test $cf_dir = tack ; then
1762                         if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
1763                                 continue
1764                         fi
1765                 fi
1766
1767                 if test -z "$cf_cv_src_modules"; then
1768                         cf_cv_src_modules=$cf_dir
1769                 else
1770                         cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
1771                 fi
1772
1773                 # Make the ncurses_cfg.h file record the library interface files as
1774                 # well.  These are header files that are the same name as their
1775                 # directory.  Ncurses is the only library that does not follow
1776                 # that pattern.
1777                 if test $cf_dir = tack ; then
1778                         continue
1779                 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
1780                         CF_UPPER(cf_have_include,$cf_dir)
1781                         AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
1782                         AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
1783                         TEST_DEPS="${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
1784                         TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
1785                 fi
1786         fi
1787 done
1788 AC_MSG_RESULT($cf_cv_src_modules)
1789 TEST_ARGS="-L${LIB_DIR} -L\$(libdir) $TEST_ARGS"
1790 AC_SUBST(TEST_DEPS)
1791 AC_SUBST(TEST_ARGS)
1792
1793 PROG_ARGS="-L${LIB_DIR} -L\$(libdir) $PROG_ARGS"
1794 AC_SUBST(PROG_ARGS)
1795
1796 SRC_SUBDIRS="man include"
1797 for cf_dir in $cf_cv_src_modules
1798 do
1799         SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
1800 done
1801 SRC_SUBDIRS="$SRC_SUBDIRS misc test"
1802 test $cf_cxx_library != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
1803
1804 ADA_SUBDIRS=
1805 if test "$cf_cv_prog_gnat_correct" = yes && test -d $srcdir/Ada95; then
1806    SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
1807    ADA_SUBDIRS="gen src samples"
1808 fi
1809
1810 SUB_MAKEFILES=
1811 for cf_dir in $SRC_SUBDIRS
1812 do
1813         SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
1814 done
1815
1816 if test -n "$ADA_SUBDIRS"; then
1817    for cf_dir in $ADA_SUBDIRS
1818    do
1819       SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
1820    done
1821    AC_SUBST(ADA_SUBDIRS)
1822 fi
1823 ])dnl
1824 dnl ---------------------------------------------------------------------------
1825 dnl     Remove "-g" option from the compiler options
1826 AC_DEFUN([CF_STRIP_G_OPT],
1827 [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl
1828 dnl ---------------------------------------------------------------------------
1829 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
1830 dnl do this if we've found the sigaction function.
1831 dnl
1832 dnl If needed, define SVR4_ACTION.
1833 AC_DEFUN([CF_STRUCT_SIGACTION],[
1834 if test $ac_cv_func_sigaction = yes; then
1835 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
1836 AC_TRY_COMPILE([
1837 #include <sys/types.h>
1838 #include <signal.h>],
1839         [struct sigaction act],
1840         [sigact_bad=no],
1841         [
1842 AC_TRY_COMPILE([
1843 #define _POSIX_SOURCE
1844 #include <sys/types.h>
1845 #include <signal.h>],
1846         [struct sigaction act],
1847         [sigact_bad=yes
1848          AC_DEFINE(SVR4_ACTION)],
1849          [sigact_bad=unknown])])
1850 AC_MSG_RESULT($sigact_bad)
1851 fi
1852 ])dnl
1853 dnl ---------------------------------------------------------------------------
1854 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
1855 dnl If so, define SVR4_TERMIO
1856 AC_DEFUN([CF_STRUCT_TERMIOS],[
1857 if test $ac_cv_header_termios_h = yes ; then
1858         case "$CFLAGS" in
1859         *-D_POSIX_SOURCE*)
1860                 termios_bad=dunno ;;
1861         *)      termios_bad=maybe ;;
1862         esac
1863         if test $termios_bad = maybe ; then
1864         AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
1865         AC_TRY_COMPILE([#include <termios.h>],
1866                 [struct termios foo; int x = foo.c_iflag],
1867                 termios_bad=no, [
1868                 AC_TRY_COMPILE([
1869 #define _POSIX_SOURCE
1870 #include <termios.h>],
1871                         [struct termios foo; int x = foo.c_iflag],
1872                         termios_bad=unknown,
1873                         termios_bad=yes AC_DEFINE(SVR4_TERMIO))
1874                         ])
1875         AC_MSG_RESULT($termios_bad)
1876         fi
1877 fi
1878 ])dnl
1879 dnl ---------------------------------------------------------------------------
1880 dnl     Shorthand macro for substituting things that the user may override
1881 dnl     with an environment variable.
1882 dnl
1883 dnl     $1 = long/descriptive name
1884 dnl     $2 = environment variable
1885 dnl     $3 = default value
1886 AC_DEFUN([CF_SUBST],
1887 [AC_CACHE_VAL(cf_cv_subst_$2,[
1888 AC_MSG_CHECKING(for $1 (symbol $2))
1889 test -z "[$]$2" && $2=$3
1890 AC_MSG_RESULT([$]$2)
1891 AC_SUBST($2)
1892 cf_cv_subst_$2=[$]$2])
1893 $2=${cf_cv_subst_$2}
1894 ])dnl
1895 dnl ---------------------------------------------------------------------------
1896 dnl Get the version-number for use in shared-library naming, etc.
1897 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
1898 [
1899 changequote(,)dnl
1900 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[  ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1901 NCURSES_MINOR="`egrep '^NCURSES_MINOR[  ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1902 NCURSES_PATCH="`egrep '^NCURSES_PATCH[  ]*=' $srcdir/dist.mk | sed -e 's/^[^0-9]*//'`"
1903 changequote([,])dnl
1904 cf_cv_abi_version=${NCURSES_MAJOR}
1905 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
1906 dnl Show the computed version, for logging
1907 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version (`date`))
1908 dnl We need these values in the generated headers
1909 AC_SUBST(NCURSES_MAJOR)
1910 AC_SUBST(NCURSES_MINOR)
1911 AC_SUBST(NCURSES_PATCH)
1912 dnl We need these values in the generated makefiles
1913 AC_SUBST(cf_cv_rel_version)
1914 AC_SUBST(cf_cv_abi_version)
1915 AC_SUBST(cf_cv_cc_bool_type)
1916 AC_SUBST(cf_cv_builtin_bool)
1917 AC_SUBST(cf_cv_type_of_bool)dnl
1918 ])dnl
1919 dnl ---------------------------------------------------------------------------
1920 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
1921 dnl older SCO configurations.
1922 AC_DEFUN([CF_SYS_TIME_SELECT],
1923 [
1924 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
1925 AC_CACHE_VAL(cf_cv_sys_time_select,[
1926 AC_TRY_COMPILE([
1927 #include <sys/types.h>
1928 #if HAVE_SYS_TIME_H
1929 #include <sys/time.h>
1930 #endif
1931 #if HAVE_SYS_SELECT_H
1932 #include <sys/select.h>
1933 #endif
1934 ],[],[cf_cv_sys_time_select=yes],
1935      [cf_cv_sys_time_select=no])
1936      ])
1937 AC_MSG_RESULT($cf_cv_sys_time_select)
1938 test $cf_cv_sys_time_select = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
1939 ])dnl
1940 dnl ---------------------------------------------------------------------------
1941 dnl Determine the type we should use for chtype (and attr_t, which is treated
1942 dnl as the same thing).  We want around 32 bits, so on most machines want a
1943 dnl long, but on newer 64-bit machines, probably want an int.  If we're using
1944 dnl wide characters, we have to have a type compatible with that, as well.
1945 AC_DEFUN([CF_TYPEOF_CHTYPE],
1946 [
1947 AC_REQUIRE([CF_UNSIGNED_LITERALS])
1948 AC_MSG_CHECKING([for type of chtype])
1949 AC_CACHE_VAL(cf_cv_typeof_chtype,[
1950                 AC_TRY_RUN([
1951 #if USE_WIDEC_SUPPORT
1952 #include <stddef.h>     /* we want wchar_t */
1953 #define WANT_BITS 39
1954 #else
1955 #define WANT_BITS 31
1956 #endif
1957 #include <stdio.h>
1958 int main()
1959 {
1960         FILE *fp = fopen("cf_test.out", "w");
1961         if (fp != 0) {
1962                 char *result = "long";
1963 #if USE_WIDEC_SUPPORT
1964                 /*
1965                  * If wchar_t is smaller than a long, it must be an int or a
1966                  * short.  We prefer not to use a short anyway.
1967                  */
1968                 if (sizeof(unsigned long) > sizeof(wchar_t))
1969                         result = "int";
1970 #endif
1971                 if (sizeof(unsigned long) > sizeof(unsigned int)) {
1972                         int n;
1973                         unsigned int x;
1974                         for (n = 0; n < WANT_BITS; n++) {
1975                                 unsigned int y = (x >> n);
1976                                 if (y != 1 || x == 0) {
1977                                         x = 0;
1978                                         break;
1979                                 }
1980                         }
1981                         /*
1982                          * If x is nonzero, an int is big enough for the bits
1983                          * that we want.
1984                          */
1985                         result = (x != 0) ? "int" : "long";
1986                 }
1987                 fputs(result, fp);
1988                 fclose(fp);
1989         }
1990         exit(0);
1991 }
1992                 ],
1993                 [cf_cv_typeof_chtype=`cat cf_test.out`],
1994                 [cf_cv_typeof_chtype=long],
1995                 [cf_cv_typeof_chtype=long])
1996                 rm -f cf_test.out
1997         ])
1998 AC_MSG_RESULT($cf_cv_typeof_chtype)
1999
2000 AC_SUBST(cf_cv_typeof_chtype)
2001 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
2002
2003 cf_cv_1UL="1"
2004 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
2005 test "$cf_cv_typeof_chtype"    = long && cf_cv_1UL="${cf_cv_1UL}L"
2006 AC_SUBST(cf_cv_1UL)
2007
2008 ])dnl
2009 dnl ---------------------------------------------------------------------------
2010 dnl
2011 AC_DEFUN([CF_TYPE_SIGACTION],
2012 [
2013 AC_MSG_CHECKING([for type sigaction_t])
2014 AC_CACHE_VAL(cf_cv_type_sigaction,[
2015         AC_TRY_COMPILE([
2016 #include <signal.h>],
2017                 [sigaction_t x],
2018                 [cf_cv_type_sigaction=yes],
2019                 [cf_cv_type_sigaction=no])])
2020 AC_MSG_RESULT($cf_cv_type_sigaction)
2021 test $cf_cv_type_sigaction = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
2022 ])dnl
2023 dnl ---------------------------------------------------------------------------
2024 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
2025 dnl won't, but they're still there.
2026 AC_DEFUN([CF_UNSIGNED_LITERALS],
2027 [
2028 AC_MSG_CHECKING([if unsigned literals are legal])
2029 AC_CACHE_VAL(cf_cv_unsigned_literals,[
2030         AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
2031                 [cf_cv_unsigned_literals=yes],
2032                 [cf_cv_unsigned_literals=no])
2033         ])
2034 AC_MSG_RESULT($cf_cv_unsigned_literals)
2035 ])dnl
2036 dnl ---------------------------------------------------------------------------
2037 dnl Make an uppercase version of a variable
2038 dnl $1=uppercase($2)
2039 AC_DEFUN([CF_UPPER],
2040 [
2041 changequote(,)dnl
2042 $1=`echo $2 | tr '[a-z]' '[A-Z]'`
2043 changequote([,])dnl
2044 ])dnl
2045 dnl ---------------------------------------------------------------------------
2046 dnl Compute the shift-mask that we'll use for wide-character indices.  We use
2047 dnl all but the index portion of chtype for storing attributes.
2048 AC_DEFUN([CF_WIDEC_SHIFT],
2049 [
2050 AC_REQUIRE([CF_TYPEOF_CHTYPE])
2051 AC_MSG_CHECKING([for number of bits in chtype])
2052 AC_CACHE_VAL(cf_cv_shift_limit,[
2053         AC_TRY_RUN([
2054 #include <stdio.h>
2055 int main()
2056 {
2057         FILE *fp = fopen("cf_test.out", "w");
2058         if (fp != 0) {
2059                 int n;
2060                 unsigned TYPEOF_CHTYPE x = 1L;
2061                 for (n = 0; ; n++) {
2062                         unsigned long y = (x >> n);
2063                         if (y != 1 || x == 0)
2064                                 break;
2065                         x <<= 1;
2066                 }
2067                 fprintf(fp, "%d", n);
2068                 fclose(fp);
2069         }
2070         exit(0);
2071 }
2072                 ],
2073                 [cf_cv_shift_limit=`cat cf_test.out`],
2074                 [cf_cv_shift_limit=32],
2075                 [cf_cv_shift_limit=32])
2076                 rm -f cf_test.out
2077         ])
2078 AC_MSG_RESULT($cf_cv_shift_limit)
2079 AC_SUBST(cf_cv_shift_limit)
2080
2081 AC_MSG_CHECKING([for width of character-index])
2082 AC_CACHE_VAL(cf_cv_widec_shift,[
2083 if test ".$with_widec" = ".yes" ; then
2084         cf_attrs_width=39
2085         if ( expr $cf_cv_shift_limit \> $cf_attrs_width >/dev/null )
2086         then
2087                 cf_cv_widec_shift=`expr 16 + $cf_cv_shift_limit - $cf_attrs_width`
2088         else
2089                 cf_cv_widec_shift=16
2090         fi
2091 else
2092         cf_cv_widec_shift=8
2093 fi
2094 ])
2095 AC_MSG_RESULT($cf_cv_widec_shift)
2096 AC_SUBST(cf_cv_widec_shift)
2097 ])dnl
2098 dnl ---------------------------------------------------------------------------
2099 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2100 dnl defaulting to yes/no.
2101 dnl
2102 dnl $1 = option name
2103 dnl $2 = help-text
2104 dnl $3 = environment variable to set
2105 dnl $4 = default value, shown in the help-message, must be a constant
2106 dnl $5 = default value, if it's an expression & cannot be in the help-message
2107 dnl
2108 AC_DEFUN([CF_WITH_PATH],
2109 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2110 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2111 CF_PATH_SYNTAX(withval)
2112 eval $3="$withval"
2113 AC_SUBST($3)dnl
2114 ])dnl
2115 dnl ---------------------------------------------------------------------------
2116 dnl Process an option specifying a list of colon-separated paths.
2117 dnl
2118 dnl $1 = option name
2119 dnl $2 = help-text
2120 dnl $3 = environment variable to set
2121 dnl $4 = default value, shown in the help-message, must be a constant
2122 dnl $5 = default value, if it's an expression & cannot be in the help-message
2123 dnl
2124 AC_DEFUN([CF_WITH_PATHLIST],[
2125 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
2126 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
2127
2128 IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
2129 cf_dst_path=
2130 for cf_src_path in $withval
2131 do
2132   CF_PATH_SYNTAX(cf_src_path)
2133   test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
2134   cf_dst_path="${cf_dst_path}${cf_src_path}"
2135 done
2136 IFS="$ac_save_ifs"
2137
2138 eval $3="$cf_dst_path"
2139 AC_SUBST($3)dnl
2140 ])dnl