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