a70a64e1a338bed405bf742eb01b0f696804d6c9
[ncurses.git] / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 1998-2003,2004 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 1995-2003
30 dnl
31 dnl $Id: aclocal.m4,v 1.333 2004/01/30 20:59:56 tom Exp $
32 dnl Macros used in NCURSES auto-configuration script.
33 dnl
34 dnl See http://invisible-island.net/autoconf/ for additional information.
35 dnl
36 dnl ---------------------------------------------------------------------------
37 dnl ---------------------------------------------------------------------------
38 dnl CF_ADA_INCLUDE_DIRS version: 4 updated: 2002/12/01 00:12:15
39 dnl -------------------
40 dnl Construct the list of include-options for the C programs in the Ada95
41 dnl binding.
42 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
43 [
44 ACPPFLAGS="-I. -I../../include $ACPPFLAGS"
45 if test "$srcdir" != "."; then
46         ACPPFLAGS="-I\$(srcdir)/../../include $ACPPFLAGS"
47 fi
48 if test "$GCC" != yes; then
49         ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
50 elif test "$includedir" != "/usr/include"; then
51         if test "$includedir" = '${prefix}/include' ; then
52                 if test $prefix != /usr ; then
53                         ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
54                 fi
55         else
56                 ACPPFLAGS="$ACPPFLAGS -I\$(includedir)"
57         fi
58 fi
59 AC_SUBST(ACPPFLAGS)
60 ])dnl
61 dnl ---------------------------------------------------------------------------
62 dnl CF_ADD_CFLAGS version: 5 updated: 2002/12/01 00:12:15
63 dnl -------------
64 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
65 dnl The second parameter if given makes this macro verbose.
66 AC_DEFUN([CF_ADD_CFLAGS],
67 [
68 cf_new_cflags=
69 cf_new_cppflags=
70 for cf_add_cflags in $1
71 do
72         case $cf_add_cflags in #(vi
73         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
74                 case "$CPPFLAGS" in
75                 *$cf_add_cflags) #(vi
76                         ;;
77                 *) #(vi
78                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
79                         ;;
80                 esac
81                 ;;
82         *)
83                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
84                 ;;
85         esac
86 done
87
88 if test -n "$cf_new_cflags" ; then
89         ifelse($2,,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
90         CFLAGS="$CFLAGS $cf_new_cflags"
91 fi
92
93 if test -n "$cf_new_cppflags" ; then
94         ifelse($2,,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
95         CPPFLAGS="$cf_new_cppflags $CPPFLAGS"
96 fi
97
98 ])dnl
99 dnl ---------------------------------------------------------------------------
100 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
101 dnl ----------------
102 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
103 dnl in the sharutils 4.2 distribution.
104 AC_DEFUN([CF_ANSI_CC_CHECK],
105 [
106 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
107 cf_cv_ansi_cc=no
108 cf_save_CFLAGS="$CFLAGS"
109 cf_save_CPPFLAGS="$CPPFLAGS"
110 # Don't try gcc -ansi; that turns off useful extensions and
111 # breaks some systems' header files.
112 # AIX                   -qlanglvl=ansi
113 # Ultrix and OSF/1      -std1
114 # HP-UX                 -Aa -D_HPUX_SOURCE
115 # SVR4                  -Xc
116 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
117 for cf_arg in "-DCC_HAS_PROTOS" \
118         "" \
119         -qlanglvl=ansi \
120         -std1 \
121         -Ae \
122         "-Aa -D_HPUX_SOURCE" \
123         -Xc
124 do
125         CF_ADD_CFLAGS($cf_arg)
126         AC_TRY_COMPILE(
127 [
128 #ifndef CC_HAS_PROTOS
129 #if !defined(__STDC__) || (__STDC__ != 1)
130 choke me
131 #endif
132 #endif
133 ],[
134         int test (int i, double x);
135         struct s1 {int (*f) (int a);};
136         struct s2 {int (*f) (double a);};],
137         [cf_cv_ansi_cc="$cf_arg"; break])
138 done
139 CFLAGS="$cf_save_CFLAGS"
140 CPPFLAGS="$cf_save_CPPFLAGS"
141 ])
142
143 if test "$cf_cv_ansi_cc" != "no"; then
144 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
145         CF_ADD_CFLAGS($cf_cv_ansi_cc)
146 else
147         AC_DEFINE(CC_HAS_PROTOS)
148 fi
149 fi
150 ])dnl
151 dnl ---------------------------------------------------------------------------
152 dnl CF_ANSI_CC_REQD version: 3 updated: 1997/09/06 13:40:44
153 dnl ---------------
154 dnl For programs that must use an ANSI compiler, obtain compiler options that
155 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
156 dnl macros, since tools such as unproto can fake prototypes, but only part of
157 dnl the preprocessor.
158 AC_DEFUN([CF_ANSI_CC_REQD],
159 [AC_REQUIRE([CF_ANSI_CC_CHECK])
160 if test "$cf_cv_ansi_cc" = "no"; then
161         AC_ERROR(
162 [Your compiler does not appear to recognize prototypes.
163 You have the following choices:
164         a. adjust your compiler options
165         b. get an up-to-date compiler
166         c. use a wrapper such as unproto])
167 fi
168 ])dnl
169 dnl ---------------------------------------------------------------------------
170 dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
171 dnl ------------
172 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
173 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
174 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
175 dnl
176 dnl Treat the configuration-variable specially here, since we're directly
177 dnl substituting its value (i.e., 1/0).
178 dnl
179 dnl $1 is the shell variable to store the result in, if not $cv_cv_builtin_bool
180 AC_DEFUN([CF_BOOL_DECL],
181 [
182 AC_MSG_CHECKING(if we should include stdbool.h)
183
184 AC_CACHE_VAL(cf_cv_header_stdbool_h,[
185         AC_TRY_COMPILE([],[bool foo = false],
186                 [cf_cv_header_stdbool_h=0],
187                 [AC_TRY_COMPILE([
188 #ifndef __BEOS__
189 #include <stdbool.h>
190 #endif
191 ],[bool foo = false],
192                         [cf_cv_header_stdbool_h=1],
193                         [cf_cv_header_stdbool_h=0])])])
194
195 if test "$cf_cv_header_stdbool_h" = 1
196 then    AC_MSG_RESULT(yes)
197 else    AC_MSG_RESULT(no)
198 fi
199
200 AC_MSG_CHECKING([for builtin bool type])
201
202 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
203         AC_TRY_COMPILE([
204 #include <stdio.h>
205 #include <sys/types.h>
206 ],[bool x = false],
207                 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
208                 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
209         ])
210
211 if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
212 then    AC_MSG_RESULT(yes)
213 else    AC_MSG_RESULT(no)
214 fi
215 ])dnl
216 dnl ---------------------------------------------------------------------------
217 dnl CF_BOOL_SIZE version: 10 updated: 2002/02/23 20:38:31
218 dnl ------------
219 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
220 dnl Don't bother looking for bool.h, since it's been deprecated.
221 dnl
222 dnl If the current compiler is C rather than C++, we get the bool definition
223 dnl from <stdbool.h>.
224 AC_DEFUN([CF_BOOL_SIZE],
225 [
226 AC_MSG_CHECKING([for size of bool])
227 AC_CACHE_VAL(cf_cv_type_of_bool,[
228         rm -f cf_test.out
229         AC_TRY_RUN([
230 #include <stdlib.h>
231 #include <stdio.h>
232
233 #if defined(__cplusplus)
234
235 #ifdef HAVE_GXX_BUILTIN_H
236 #include <g++/builtin.h>
237 #elif HAVE_GPP_BUILTIN_H
238 #include <gpp/builtin.h>
239 #elif HAVE_BUILTIN_H
240 #include <builtin.h>
241 #endif
242
243 #else
244
245 #if $cf_cv_header_stdbool_h
246 #include <stdbool.h>
247 #endif
248
249 #endif
250
251 main()
252 {
253         FILE *fp = fopen("cf_test.out", "w");
254         if (fp != 0) {
255                 bool x = true;
256                 if ((bool)(-x) >= 0)
257                         fputs("unsigned ", fp);
258                 if (sizeof(x) == sizeof(int))       fputs("int",  fp);
259                 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
260                 else if (sizeof(x) == sizeof(short))fputs("short",fp);
261                 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
262                 fclose(fp);
263         }
264         exit(0);
265 }
266                 ],
267                 [cf_cv_type_of_bool=`cat cf_test.out`
268                  if test -z "$cf_cv_type_of_bool"; then
269                    cf_cv_type_of_bool=unknown
270                  fi],
271                 [cf_cv_type_of_bool=unknown],
272                 [cf_cv_type_of_bool=unknown])
273         ])
274         rm -f cf_test.out
275 AC_MSG_RESULT($cf_cv_type_of_bool)
276 if test "$cf_cv_type_of_bool" = unknown ; then
277         case .$NCURSES_BOOL in #(vi
278         .auto|.) NCURSES_BOOL=unsigned;;
279         esac
280         AC_MSG_WARN(Assuming $NCURSES_BOOL for type of bool)
281         cf_cv_type_of_bool=$NCURSES_BOOL
282 fi
283 ])dnl
284 dnl ---------------------------------------------------------------------------
285 dnl CF_CFG_DEFAULTS version: 6 updated: 2003/07/12 15:15:19
286 dnl ---------------
287 dnl Determine the default configuration into which we'll install ncurses.  This
288 dnl can be overridden by the user's command-line options.  There's two items to
289 dnl look for:
290 dnl     1. the prefix (e.g., /usr)
291 dnl     2. the header files (e.g., /usr/include/ncurses)
292 dnl We'll look for a previous installation of ncurses and use the same defaults.
293 dnl
294 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
295 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
296 dnl programs from a vendor's.
297 AC_DEFUN([CF_CFG_DEFAULTS],
298 [
299 AC_MSG_CHECKING(for prefix)
300 if test "x$prefix" = "xNONE" ; then
301         case "$cf_cv_system_name" in
302                 # non-vendor systems don't have a conflict
303         openbsd*|netbsd*|freebsd*|linux*|cygwin*|k*bsd*-gnu)
304                 prefix=/usr
305                 ;;
306         *)      prefix=$ac_default_prefix
307                 ;;
308         esac
309 fi
310 AC_MSG_RESULT($prefix)
311
312 if test "x$prefix" = "xNONE" ; then
313 AC_MSG_CHECKING(for default include-directory)
314 test -n "$verbose" && echo 1>&AC_FD_MSG
315 for cf_symbol in \
316         $includedir \
317         $includedir/ncurses \
318         $prefix/include \
319         $prefix/include/ncurses \
320         /usr/local/include \
321         /usr/local/include/ncurses \
322         /usr/include \
323         /usr/include/ncurses
324 do
325         cf_dir=`eval echo $cf_symbol`
326         if test -f $cf_dir/curses.h ; then
327         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
328                 includedir="$cf_symbol"
329                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
330                 break
331         fi
332         fi
333         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
334 done
335 AC_MSG_RESULT($includedir)
336 fi
337 ])dnl
338 dnl ---------------------------------------------------------------------------
339 dnl CF_CGETENT version: 3 updated: 2000/08/12 23:18:52
340 dnl ----------
341 dnl Check if the terminal-capability database functions are available.  If not,
342 dnl ncurses has a much-reduced version.
343 AC_DEFUN([CF_CGETENT],[
344 AC_MSG_CHECKING(for terminal-capability database functions)
345 AC_CACHE_VAL(cf_cv_cgetent,[
346 AC_TRY_LINK([
347 #include <stdlib.h>],[
348         char temp[128];
349         char *buf = temp;
350         char *db_array = temp;
351         cgetent(&buf, /* int *, */ &db_array, "vt100");
352         cgetcap(buf, "tc", '=');
353         cgetmatch(buf, "tc");
354         ],
355         [cf_cv_cgetent=yes],
356         [cf_cv_cgetent=no])
357 ])
358 AC_MSG_RESULT($cf_cv_cgetent)
359 test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT)
360 ])dnl
361 dnl ---------------------------------------------------------------------------
362 dnl CF_CHECK_CACHE version: 9 updated: 2004/01/30 15:59:13
363 dnl --------------
364 dnl Check if we're accidentally using a cache from a different machine.
365 dnl Derive the system name, as a check for reusing the autoconf cache.
366 dnl
367 dnl If we've packaged config.guess and config.sub, run that (since it does a
368 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
369 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
370 dnl which is useful in cross-compiles.
371 dnl
372 dnl Note: we would use $ac_config_sub, but that is one of the places where
373 dnl autoconf 2.5x broke compatibility with autoconf 2.13
374 AC_DEFUN([CF_CHECK_CACHE],
375 [
376 if test -f $srcdir/config.guess ; then
377         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
378         system_name="$host_os"
379 else
380         system_name="`(uname -s -r) 2>/dev/null`"
381         if test -z "$system_name" ; then
382                 system_name="`(hostname) 2>/dev/null`"
383         fi
384 fi
385 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
386 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
387
388 test -z "$system_name" && system_name="$cf_cv_system_name"
389 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
390
391 if test ".$system_name" != ".$cf_cv_system_name" ; then
392         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
393         AC_ERROR("Please remove config.cache and try again.")
394 fi
395 ])dnl
396 dnl ---------------------------------------------------------------------------
397 dnl CF_CHECK_ERRNO version: 9 updated: 2001/12/30 18:03:23
398 dnl --------------
399 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
400 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
401 dnl ourselves.
402 dnl
403 dnl $1 = the name to check
404 AC_DEFUN([CF_CHECK_ERRNO],
405 [
406 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
407     AC_TRY_COMPILE([
408 #ifdef HAVE_STDLIB_H
409 #include <stdlib.h>
410 #endif
411 #include <stdio.h>
412 #include <sys/types.h>
413 #include <errno.h> ],
414     [long x = (long) $1],
415     [cf_cv_dcl_$1=yes],
416     [cf_cv_dcl_$1=no])
417 ])
418
419 if test "$cf_cv_dcl_$1" = no ; then
420     CF_UPPER(cf_result,decl_$1)
421     AC_DEFINE_UNQUOTED($cf_result)
422 fi
423
424 # It's possible (for near-UNIX clones) that the data doesn't exist
425 CF_CHECK_EXTERN_DATA($1,int)
426 ])dnl
427 dnl ---------------------------------------------------------------------------
428 dnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
429 dnl --------------------
430 dnl Check for existence of external data in the current set of libraries.  If
431 dnl we can modify it, it's real enough.
432 dnl $1 = the name to check
433 dnl $2 = its type
434 AC_DEFUN([CF_CHECK_EXTERN_DATA],
435 [
436 AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
437     AC_TRY_LINK([
438 #undef $1
439 extern $2 $1;
440 ],
441     [$1 = 2],
442     [cf_cv_have_$1=yes],
443     [cf_cv_have_$1=no])
444 ])
445
446 if test "$cf_cv_have_$1" = yes ; then
447     CF_UPPER(cf_result,have_$1)
448     AC_DEFINE_UNQUOTED($cf_result)
449 fi
450
451 ])dnl
452 dnl ---------------------------------------------------------------------------
453 dnl CF_CPP_PARAM_INIT version: 4 updated: 2001/04/07 22:31:18
454 dnl -----------------
455 dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
456 dnl is a late feature for the standard and is not in some recent compilers
457 dnl (1999/9/11).
458 AC_DEFUN([CF_CPP_PARAM_INIT],
459 [
460 if test -n "$CXX"; then
461 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
462         AC_LANG_SAVE
463         AC_LANG_CPLUSPLUS
464         AC_TRY_RUN([
465 class TEST {
466 private:
467         int value;
468 public:
469         TEST(int x = 1);
470         ~TEST();
471 };
472
473 TEST::TEST(int x = 1)   // some compilers do not like second initializer
474 {
475         value = x;
476 }
477 void main() { }
478 ],
479         [cf_cv_cpp_param_init=yes],
480         [cf_cv_cpp_param_init=no],
481         [cf_cv_cpp_param_init=unknown])
482         AC_LANG_RESTORE
483 ])
484 fi
485 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT)
486 ])dnl
487 dnl ---------------------------------------------------------------------------
488 dnl CF_CPP_VSCAN_FUNC version: 5 updated: 2001/12/02 01:39:28
489 dnl -----------------
490 dnl Check if the g++ compiler supports vscan function (not a standard feature).
491 AC_DEFUN([CF_CPP_VSCAN_FUNC],
492 [
493 if test -n "$CXX"; then
494
495 AC_LANG_SAVE
496 AC_LANG_CPLUSPLUS
497 AC_CHECK_HEADERS(strstream.h)
498
499 AC_CACHE_CHECK(if $CXX supports vscan function,cf_cv_cpp_vscan_func,[
500         for cf_vscan_func in strstream strstream_cast stdio
501         do
502         case $cf_vscan_func in #(vi
503         stdio)          cf_vscan_defs=USE_STDIO_VSCAN ;; #(vi
504         strstream)      cf_vscan_defs=USE_STRSTREAM_VSCAN ;;
505         strstream_cast) cf_vscan_defs=USE_STRSTREAM_VSCAN_CAST ;;
506         esac
507         AC_TRY_LINK([
508 #include <stdio.h>
509 #include <stdarg.h>
510 #define $cf_vscan_defs 1
511 #if defined(USE_STDIO_VSCAN)
512 #elif defined(HAVE_STRSTREAM_H) && defined(USE_STRSTREAM_VSCAN)
513 #include <strstream.h>
514 #endif
515
516 int scanw(const char* fmt, ...)
517 {
518     int result = -1;
519     char buf[BUFSIZ];
520
521     va_list args;
522     va_start(args, fmt);
523 #if defined(USE_STDIO_VSCAN)
524     if (::vsscanf(buf, fmt, args) != -1)
525         result = 0;
526 #elif defined(USE_STRSTREAM_VSCAN)
527     strstreambuf ss(buf, sizeof(buf));
528     if (ss.vscan(fmt, args) != -1)
529         result = 0;
530 #elif defined(USE_STRSTREAM_VSCAN_CAST)
531     strstreambuf ss(buf, sizeof(buf));
532     if (ss.vscan(fmt, (_IO_va_list)args) != -1)
533         result = 0;
534 #else
535 #error case $cf_vscan_func failed
536 #endif
537     va_end(args);
538     return result;
539 }
540 ],[int tmp, foo = scanw("%d", &tmp)],
541         [cf_cv_cpp_vscan_func=$cf_vscan_func; break],
542         [cf_cv_cpp_vscan_func=no])
543         test "$cf_cv_cpp_vscan_func" != no && break
544         done
545 ])
546
547 AC_LANG_RESTORE
548 fi
549
550 case $cf_cv_cpp_vscan_func in #(vi
551 stdio) #(vi
552         AC_DEFINE(CPP_HAS_VSCAN_FUNC)
553         AC_DEFINE(USE_STDIO_VSCAN)
554         ;;
555 strstream)
556         AC_DEFINE(CPP_HAS_VSCAN_FUNC)
557         AC_DEFINE(USE_STRSTREAM_VSCAN)
558         ;;
559 strstream_cast)
560         AC_DEFINE(CPP_HAS_VSCAN_FUNC)
561         AC_DEFINE(USE_STRSTREAM_VSCAN_CAST)
562         ;;
563 esac
564 ])dnl
565 dnl ---------------------------------------------------------------------------
566 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
567 dnl ----------
568 dnl "dirname" is not portable, so we fake it with a shell script.
569 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
570 dnl ---------------------------------------------------------------------------
571 dnl CF_DIRS_TO_MAKE version: 3 updated: 2002/02/23 20:38:31
572 dnl ---------------
573 AC_DEFUN([CF_DIRS_TO_MAKE],
574 [
575 DIRS_TO_MAKE="lib"
576 for cf_item in $cf_list_models
577 do
578         CF_OBJ_SUBDIR($cf_item,cf_subdir)
579         for cf_item2 in $DIRS_TO_MAKE
580         do
581                 test $cf_item2 = $cf_subdir && break
582         done
583         test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
584 done
585 for cf_dir in $DIRS_TO_MAKE
586 do
587         test ! -d $cf_dir && mkdir $cf_dir
588 done
589 AC_SUBST(DIRS_TO_MAKE)
590 ])dnl
591 dnl ---------------------------------------------------------------------------
592 dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
593 dnl --------
594 dnl Check if 'errno' is declared in <errno.h>
595 AC_DEFUN([CF_ERRNO],
596 [
597 CF_CHECK_ERRNO(errno)
598 ])dnl
599 dnl ---------------------------------------------------------------------------
600 dnl CF_ETIP_DEFINES version: 3 updated: 2003/03/22 19:13:43
601 dnl ---------------
602 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
603 dnl math.h and builtin.h, only for ncurses
604 AC_DEFUN([CF_ETIP_DEFINES],
605 [
606 AC_MSG_CHECKING(for special defines needed for etip.h)
607 cf_save_CXXFLAGS="$CXXFLAGS"
608 cf_result="none"
609 for cf_math in "" MATH_H
610 do
611 for cf_excp in "" MATH_EXCEPTION
612 do
613         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -I${srcdir}/include"
614         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
615         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
616 AC_TRY_COMPILE([
617 #include <etip.h.in>
618 ],[],[
619         test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
620         test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
621         cf_result="$cf_math $cf_excp"
622         break
623 ],[])
624 done
625 done
626 AC_MSG_RESULT($cf_result)
627 CXXFLAGS="$cf_save_CXXFLAGS"
628 ])
629 dnl ---------------------------------------------------------------------------
630 dnl CF_FUNC_MEMMOVE version: 5 updated: 2000/08/12 23:18:52
631 dnl ---------------
632 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
633 dnl is found, add our own version of memmove to the list of objects.
634 AC_DEFUN([CF_FUNC_MEMMOVE],
635 [
636 AC_CHECK_FUNC(memmove,,[
637 AC_CHECK_FUNC(bcopy,[
638         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
639                 AC_TRY_RUN([
640 int main() {
641         static char data[] = "abcdefghijklmnopqrstuwwxyz";
642         char temp[40];
643         bcopy(data, temp, sizeof(data));
644         bcopy(temp+10, temp, 15);
645         bcopy(temp+5, temp+15, 10);
646         exit (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
647 }
648                 ],
649                 [cf_cv_good_bcopy=yes],
650                 [cf_cv_good_bcopy=no],
651                 [cf_cv_good_bcopy=unknown])
652                 ])
653         ],[cf_cv_good_bcopy=no])
654         if test "$cf_cv_good_bcopy" = yes ; then
655                 AC_DEFINE(USE_OK_BCOPY)
656         else
657                 AC_DEFINE(USE_MY_MEMMOVE)
658         fi
659 ])])dnl
660 dnl ---------------------------------------------------------------------------
661 dnl CF_FUNC_POLL version: 2 updated: 2000/02/06 01:38:04
662 dnl ------------
663 dnl See if the poll function really works.  Some platforms have poll(), but
664 dnl it does not work for terminals or files.
665 AC_DEFUN([CF_FUNC_POLL],[
666 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
667 AC_TRY_RUN([
668 #include <stdio.h>
669 #ifdef HAVE_POLL_H
670 #include <poll.h>
671 #else
672 #include <sys/poll.h>
673 #endif
674 int main() {
675         struct pollfd myfds;
676         int ret;
677
678         myfds.fd = 0;
679         myfds.events = POLLIN;
680
681         ret = poll(&myfds, 1, 100);
682         exit(ret != 0);
683 }],
684         [cf_cv_working_poll=yes],
685         [cf_cv_working_poll=no],
686         [cf_cv_working_poll=unknown])])
687 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
688 ])dnl
689 dnl ---------------------------------------------------------------------------
690 dnl CF_FUNC_TERMIOS version: 2 updated: 2000/07/22 23:37:24
691 dnl ---------------
692 dnl Some old/broken variations define tcgetattr() only as a macro in
693 dnl termio(s).h
694 AC_DEFUN([CF_FUNC_TERMIOS],[
695 AC_REQUIRE([CF_STRUCT_TERMIOS])
696 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
697 AC_TRY_LINK([
698 #include <sys/types.h>
699 #ifdef HAVE_UNISTD_H
700 #include <unistd.h>
701 #endif
702 #ifdef HAVE_TERMIOS_H
703 #include <termios.h>
704 #define TTY struct termios
705 #else
706 #ifdef HAVE_TERMIO_H
707 #include <termio.h>
708 #define TTY struct termio
709 #endif
710 #endif
711 ],[
712 TTY foo;
713 tcgetattr(1, &foo);],
714 [cf_cv_have_tcgetattr=yes],
715 [cf_cv_have_tcgetattr=no])])
716 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR)
717 ])dnl
718 dnl ---------------------------------------------------------------------------
719 dnl CF_FUNC_VSSCANF version: 3 updated: 2001/12/19 00:50:10
720 dnl ---------------
721 dnl Check for vsscanf() function, which is in c9x but generally not in earlier
722 dnl versions of C.  It is in the GNU C library, and can often be simulated by
723 dnl other functions.
724 AC_DEFUN([CF_FUNC_VSSCANF],
725 [
726 AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
727 AC_TRY_LINK([
728 #include <stdarg.h>
729 #include <stdio.h>],[
730         va_list ap;
731         vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
732 AC_TRY_LINK([
733 #include <stdarg.h>
734 #include <stdio.h>],[
735     FILE strbuf;
736     char *str = "from";
737
738     strbuf._flag = _IOREAD;
739     strbuf._ptr = strbuf._base = (unsigned char *) str;
740     strbuf._cnt = strlen(str);
741     strbuf._file = _NFILE;
742     return (vfscanf(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=vfscanf],[
743 AC_TRY_LINK([
744 #include <stdarg.h>
745 #include <stdio.h>],[
746     FILE strbuf;
747     char *str = "from";
748
749     strbuf._flag = _IOREAD;
750     strbuf._ptr = strbuf._base = (unsigned char *) str;
751     strbuf._cnt = strlen(str);
752     strbuf._file = _NFILE;
753     return (_doscan(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=_doscan],[
754 cf_cv_func_vsscanf=no])])])])
755
756 case $cf_cv_func_vsscanf in #(vi
757 vsscanf) AC_DEFINE(HAVE_VSSCANF);; #(vi
758 vfscanf) AC_DEFINE(HAVE_VFSCANF);; #(vi
759 _doscan) AC_DEFINE(HAVE__DOSCAN);;
760 esac
761
762 ])dnl
763 dnl ---------------------------------------------------------------------------
764 dnl CF_GCC_ATTRIBUTES version: 9 updated: 2002/12/21 19:25:52
765 dnl -----------------
766 dnl Test for availability of useful gcc __attribute__ directives to quiet
767 dnl compiler warnings.  Though useful, not all are supported -- and contrary
768 dnl to documentation, unrecognized directives cause older compilers to barf.
769 AC_DEFUN([CF_GCC_ATTRIBUTES],
770 [
771 if test "$GCC" = yes
772 then
773 cat > conftest.i <<EOF
774 #ifndef GCC_PRINTF
775 #define GCC_PRINTF 0
776 #endif
777 #ifndef GCC_SCANF
778 #define GCC_SCANF 0
779 #endif
780 #ifndef GCC_NORETURN
781 #define GCC_NORETURN /* nothing */
782 #endif
783 #ifndef GCC_UNUSED
784 #define GCC_UNUSED /* nothing */
785 #endif
786 EOF
787 if test "$GCC" = yes
788 then
789         AC_CHECKING([for $CC __attribute__ directives])
790 cat > conftest.$ac_ext <<EOF
791 #line __oline__ "configure"
792 #include "confdefs.h"
793 #include "conftest.h"
794 #include "conftest.i"
795 #if     GCC_PRINTF
796 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
797 #else
798 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
799 #endif
800 #if     GCC_SCANF
801 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
802 #else
803 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
804 #endif
805 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
806 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
807 extern void foo(void) GCC_NORETURN;
808 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
809 EOF
810         for cf_attribute in scanf printf unused noreturn
811         do
812                 CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
813                 cf_directive="__attribute__(($cf_attribute))"
814                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
815                 case $cf_attribute in
816                 scanf|printf)
817                 cat >conftest.h <<EOF
818 #define GCC_$CF_ATTRIBUTE 1
819 EOF
820                         ;;
821                 *)
822                 cat >conftest.h <<EOF
823 #define GCC_$CF_ATTRIBUTE $cf_directive
824 EOF
825                         ;;
826                 esac
827                 if AC_TRY_EVAL(ac_compile); then
828                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
829                         cat conftest.h >>confdefs.h
830                 fi
831         done
832 else
833         fgrep define conftest.i >>confdefs.h
834 fi
835 rm -rf conftest*
836 fi
837 ])dnl
838 dnl ---------------------------------------------------------------------------
839 dnl CF_GCC_VERSION version: 3 updated: 2003/09/06 19:16:57
840 dnl --------------
841 dnl Find version of gcc
842 AC_DEFUN([CF_GCC_VERSION],[
843 AC_REQUIRE([AC_PROG_CC])
844 GCC_VERSION=none
845 if test "$GCC" = yes ; then
846         AC_MSG_CHECKING(version of $CC)
847         GCC_VERSION="`${CC} --version|sed -e '2,$d' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
848         test -z "$GCC_VERSION" && GCC_VERSION=unknown
849         AC_MSG_RESULT($GCC_VERSION)
850 fi
851 ])dnl
852 dnl ---------------------------------------------------------------------------
853 dnl CF_GCC_WARNINGS version: 15 updated: 2003/07/05 18:42:30
854 dnl ---------------
855 dnl Check if the compiler supports useful warning options.  There's a few that
856 dnl we don't use, simply because they're too noisy:
857 dnl
858 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
859 dnl     -Wredundant-decls (system headers make this too noisy)
860 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
861 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
862 dnl             is enabled for ncurses using "--enable-const".
863 dnl     -pedantic
864 dnl
865 AC_DEFUN([CF_GCC_WARNINGS],
866 [
867 AC_REQUIRE([CF_GCC_VERSION])
868 if test "$GCC" = yes
869 then
870         cat > conftest.$ac_ext <<EOF
871 #line __oline__ "configure"
872 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
873 EOF
874         AC_CHECKING([for $CC warning options])
875         cf_save_CFLAGS="$CFLAGS"
876         EXTRA_CFLAGS="-W -Wall"
877         cf_warn_CONST=""
878         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
879         for cf_opt in \
880                 Wbad-function-cast \
881                 Wcast-align \
882                 Wcast-qual \
883                 Winline \
884                 Wmissing-declarations \
885                 Wmissing-prototypes \
886                 Wnested-externs \
887                 Wpointer-arith \
888                 Wshadow \
889                 Wstrict-prototypes \
890                 Wundef $cf_warn_CONST
891         do
892                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
893                 if AC_TRY_EVAL(ac_compile); then
894                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
895                         case $cf_opt in #(vi
896                         Wcast-qual) #(vi
897                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
898                                 ;;
899                         Winline) #(vi
900                                 case $GCC_VERSION in
901                                 3.3*)
902                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
903                                         continue;;
904                                 esac
905                                 ;;
906                         esac
907                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
908                 fi
909         done
910         rm -f conftest*
911         CFLAGS="$cf_save_CFLAGS"
912 fi
913 AC_SUBST(EXTRA_CFLAGS)
914 ])dnl
915 dnl ---------------------------------------------------------------------------
916 dnl CF_GNAT_TRY_RUN version: 2 updated: 1998/07/19 00:25:18
917 dnl ---------------
918 dnl Verify that a test program compiles and runs with GNAT
919 dnl $cf_ada_make is set to the program that compiles/links
920 AC_DEFUN([CF_GNAT_TRY_RUN],
921 [
922 rm -f conftest*
923 cat >>conftest.ads <<CF_EOF
924 $1
925 CF_EOF
926 cat >>conftest.adb <<CF_EOF
927 $2
928 CF_EOF
929 if ( $cf_ada_make conftest 1>&AC_FD_CC 2>&1 ) ; then
930    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
931 ifelse($3,,      :,[      $3])
932 ifelse($4,,,[   else
933       $4])
934    fi
935 ifelse($4,,,[else
936    $4])
937 fi
938 rm -f conftest*
939 ])dnl
940 dnl ---------------------------------------------------------------------------
941 dnl CF_GNAT_VERSION version: 11 updated: 2003/09/06 19:42:09
942 dnl ---------------
943 dnl Verify version of GNAT.
944 AC_DEFUN([CF_GNAT_VERSION],
945 [
946 AC_MSG_CHECKING(for gnat version)
947 cf_gnat_version=`${cf_ada_make-gnatmake} -v 2>&1 | grep '[[0-9]].[[0-9]][[0-9]]*' |\
948   sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
949 AC_MSG_RESULT($cf_gnat_version)
950
951 case $cf_gnat_version in
952   3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*)
953     cf_cv_prog_gnat_correct=yes
954     ;;
955   *) echo Unsupported GNAT version $cf_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
956      cf_cv_prog_gnat_correct=no
957      ;;
958 esac
959 case $cf_gnat_version in
960   3.[[1-9]]*|[[4-9]].*)
961       cf_compile_generics=generics
962       cf_generic_objects="\$(GENOBJS)"
963       ;;
964   *)  cf_compile_generics=
965       cf_generic_objects=
966       ;;
967 esac
968 ])
969 dnl ---------------------------------------------------------------------------
970 dnl CF_GNU_SOURCE version: 3 updated: 2000/10/29 23:30:53
971 dnl -------------
972 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
973 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
974 dnl (or misfeature) of glibc2, which breaks portability of many applications,
975 dnl since it is interwoven with GNU extensions.
976 dnl
977 dnl Well, yes we could work around it...
978 AC_DEFUN([CF_GNU_SOURCE],
979 [
980 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
981 AC_TRY_COMPILE([#include <sys/types.h>],[
982 #ifndef _XOPEN_SOURCE
983 make an error
984 #endif],
985         [cf_cv_gnu_source=no],
986         [cf_save="$CPPFLAGS"
987          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
988          AC_TRY_COMPILE([#include <sys/types.h>],[
989 #ifdef _XOPEN_SOURCE
990 make an error
991 #endif],
992         [cf_cv_gnu_source=no],
993         [cf_cv_gnu_source=yes])
994         CPPFLAGS="$cf_save"
995         ])
996 ])
997 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
998 ])dnl
999 dnl ---------------------------------------------------------------------------
1000 dnl CF_GPP_LIBRARY version: 8 updated: 2003/02/02 01:41:46
1001 dnl --------------
1002 dnl If we're trying to use g++, test if libg++ is installed (a rather common
1003 dnl problem :-).  If we have the compiler but no library, we'll be able to
1004 dnl configure, but won't be able to build the c++ demo program.
1005 AC_DEFUN([CF_GPP_LIBRARY],
1006 [
1007 cf_cxx_library=unknown
1008 case $cf_cv_system_name in #(vi
1009 os2*) #(vi
1010         cf_gpp_libname=gpp
1011         ;;
1012 *)
1013         cf_gpp_libname=g++
1014         ;;
1015 esac
1016 if test "$GXX" = yes; then
1017         AC_MSG_CHECKING([for lib$cf_gpp_libname])
1018         cf_save="$LIBS"
1019         LIBS="$LIBS -l$cf_gpp_libname"
1020         AC_TRY_LINK([
1021 #include <$cf_gpp_libname/builtin.h>
1022         ],
1023         [two_arg_error_handler_t foo2 = lib_error_handler],
1024         [cf_cxx_library=yes
1025          CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
1026          if test "$cf_gpp_libname" = cpp ; then
1027             AC_DEFINE(HAVE_GPP_BUILTIN_H)
1028          else
1029             AC_DEFINE(HAVE_GXX_BUILTIN_H)
1030          fi],
1031         [AC_TRY_LINK([
1032 #include <builtin.h>
1033         ],
1034         [two_arg_error_handler_t foo2 = lib_error_handler],
1035         [cf_cxx_library=yes
1036          CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
1037          AC_DEFINE(HAVE_BUILTIN_H)],
1038         [cf_cxx_library=no])])
1039         LIBS="$cf_save"
1040         AC_MSG_RESULT($cf_cxx_library)
1041 fi
1042 ])dnl
1043 dnl ---------------------------------------------------------------------------
1044 dnl CF_GXX_VERSION version: 3 updated: 2003/09/06 19:16:21
1045 dnl --------------
1046 dnl Check for version of g++
1047 AC_DEFUN([CF_GXX_VERSION],[
1048 AC_REQUIRE([AC_PROG_CPP])
1049 GXX_VERSION=none
1050 if test "$GXX" = yes; then
1051         AC_MSG_CHECKING(version of g++)
1052         GXX_VERSION="`${CXX-g++} --version|sed -e '2,$d'`"
1053         AC_MSG_RESULT($GXX_VERSION)
1054 fi
1055 ])dnl
1056 dnl ---------------------------------------------------------------------------
1057 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1058 dnl ---------------
1059 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1060 AC_DEFUN([CF_HELP_MESSAGE],
1061 [AC_DIVERT_HELP([$1])dnl
1062 ])dnl
1063 dnl ---------------------------------------------------------------------------
1064 dnl CF_INCLUDE_DIRS version: 4 updated: 2002/12/01 00:12:15
1065 dnl ---------------
1066 dnl Construct the list of include-options according to whether we're building
1067 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
1068 dnl with gcc, don't append the includedir if it happens to be /usr/include,
1069 dnl since that usually breaks gcc's shadow-includes.
1070 AC_DEFUN([CF_INCLUDE_DIRS],
1071 [
1072 CPPFLAGS="-I. -I../include $CPPFLAGS"
1073 if test "$srcdir" != "."; then
1074         CPPFLAGS="-I\$(srcdir)/../include $CPPFLAGS"
1075 fi
1076 if test "$GCC" != yes; then
1077         CPPFLAGS="$CPPFLAGS -I\$(includedir)"
1078 elif test "$includedir" != "/usr/include"; then
1079         if test "$includedir" = '${prefix}/include' ; then
1080                 if test $prefix != /usr ; then
1081                         CPPFLAGS="$CPPFLAGS -I\$(includedir)"
1082                 fi
1083         else
1084                 CPPFLAGS="$CPPFLAGS -I\$(includedir)"
1085         fi
1086 fi
1087 AC_SUBST(CPPFLAGS)
1088 ])dnl
1089 dnl ---------------------------------------------------------------------------
1090 dnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
1091 dnl ----------
1092 dnl Check if we have either a function or macro for 'isascii()'.
1093 AC_DEFUN([CF_ISASCII],
1094 [
1095 AC_MSG_CHECKING(for isascii)
1096 AC_CACHE_VAL(cf_cv_have_isascii,[
1097         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
1098         [cf_cv_have_isascii=yes],
1099         [cf_cv_have_isascii=no])
1100 ])dnl
1101 AC_MSG_RESULT($cf_cv_have_isascii)
1102 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII)
1103 ])dnl
1104 dnl ---------------------------------------------------------------------------
1105 dnl CF_LIBUTF8 version: 2 updated: 2002/01/19 22:51:32
1106 dnl ----------
1107 dnl Check for libutf8
1108 AC_DEFUN([CF_LIBUTF8],
1109 [
1110 AC_CACHE_CHECK(for putwc in libutf8,cf_cv_libutf8,[
1111         cf_save_LIBS="$LIBS"
1112         LIBS="-lutf8 $LIBS"
1113 AC_TRY_LINK([
1114 #include <libutf8.h>],[putwc(0,0);],
1115         [cf_cv_libutf8=yes],
1116         [cf_cv_libutf8=no])
1117         LIBS="$cf_save_LIBS"
1118 ])
1119
1120 if test "$cf_cv_libutf8" = yes ; then
1121         AC_DEFINE(HAVE_LIBUTF8_H)
1122         LIBS="-lutf8 $LIBS"
1123 fi
1124 ])dnl
1125 dnl ---------------------------------------------------------------------------
1126 dnl CF_LIB_PREFIX version: 7 updated: 2001/01/12 01:23:48
1127 dnl -------------
1128 dnl Compute the library-prefix for the given host system
1129 dnl $1 = variable to set
1130 AC_DEFUN([CF_LIB_PREFIX],
1131 [
1132         case $cf_cv_system_name in
1133         OS/2*)  LIB_PREFIX=''     ;;
1134         os2*)   LIB_PREFIX=''     ;;
1135         *)      LIB_PREFIX='lib'  ;;
1136         esac
1137 ifelse($1,,,[$1=$LIB_PREFIX])
1138         AC_SUBST(LIB_PREFIX)
1139 ])dnl
1140 dnl ---------------------------------------------------------------------------
1141 dnl CF_LIB_RULES version: 30 updated: 2004/01/10 15:50:50
1142 dnl ------------
1143 dnl Append definitions and rules for the given models to the subdirectory
1144 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
1145 dnl subdirectory is a library-source directory, modify the LIBRARIES list in
1146 dnl the corresponding makefile to list the models that we'll generate.
1147 dnl
1148 dnl For shared libraries, make a list of symbolic links to construct when
1149 dnl generating each library.  The convention used for Linux is the simplest
1150 dnl one:
1151 dnl     lib<name>.so    ->
1152 dnl     lib<name>.so.<major>    ->
1153 dnl     lib<name>.so.<maj>.<minor>
1154 AC_DEFUN([CF_LIB_RULES],
1155 [
1156 CF_LIB_PREFIX(cf_prefix)
1157 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1158 for cf_dir in $SRC_SUBDIRS
1159 do
1160         if test -f $srcdir/$cf_dir/modules; then
1161
1162                 IMPORT_LIB=
1163                 SHARED_LIB=
1164                 LIBS_TO_MAKE=
1165                 for cf_item in $CF_LIST_MODELS
1166                 do
1167                         CF_LIB_SUFFIX($cf_item,cf_suffix)
1168                         if test $cf_item = shared ; then
1169                         if test "$cf_cv_do_symlinks" = yes ; then
1170                                 case "$cf_cv_shlib_version" in #(vi
1171                                 rel) #(vi
1172                                         case "$cf_cv_system_name" in #(vi
1173                                         darwin*) cf_suffix='.$(REL_VERSION)'"$cf_suffix" ;; #(vi
1174                                         *) cf_suffix="$cf_suffix"'.$(REL_VERSION)' ;;
1175                                         esac
1176                                         ;;
1177                                 abi)
1178                                         case "$cf_cv_system_name" in #(vi
1179                                         darwin*) cf_suffix='.$(ABI_VERSION)'"$cf_suffix" ;; #(vi
1180                                         *) cf_suffix="$cf_suffix"'.$(ABI_VERSION)' ;;
1181                                         esac
1182                                         ;;
1183                                 esac
1184                         fi
1185                         # cygwin needs import library, and has unique naming convention
1186                         # use autodetected ${cf_prefix} for import lib and static lib, but
1187                         # use 'cyg' prefix for shared lib.
1188                         if test $cf_cv_shlib_version = cygdll ; then
1189                                 SHARED_LIB="../lib/cyg${cf_dir}\$(ABI_VERSION).dll"
1190                                 IMPORT_LIB="../lib/${cf_prefix}${cf_dir}.dll.a"
1191                                 LIBS_TO_MAKE="$LIBS_TO_MAKE \$(SHARED_LIB) \$(IMPORT_LIB)"
1192                                 continue
1193                         fi
1194                         fi
1195                         LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
1196                 done
1197
1198                 if test $cf_dir = ncurses ; then
1199                         cf_subsets="$LIB_SUBSETS"
1200                         cf_termlib=`echo "$cf_subsets" |sed -e 's/ .*$//'`
1201                         if test "$cf_termlib" != "$cf_subsets" ; then
1202                                 cf_item=`echo $LIBS_TO_MAKE |sed -e s%$LIB_NAME%$TINFO_NAME%g`
1203                                 LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
1204                         fi
1205                 else
1206                         cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
1207                 fi
1208
1209                 sed -e "s%@LIBS_TO_MAKE@%$LIBS_TO_MAKE%" \
1210                     -e "s%@IMPORT_LIB@%$IMPORT_LIB%" \
1211                     -e "s%@SHARED_LIB@%$SHARED_LIB%" \
1212                         $cf_dir/Makefile >$cf_dir/Makefile.out
1213                 mv $cf_dir/Makefile.out $cf_dir/Makefile
1214
1215                 $AWK -f $srcdir/mk-0th.awk \
1216                         libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" \
1217                         $srcdir/$cf_dir/modules >>$cf_dir/Makefile
1218
1219                 for cf_subset in $cf_subsets
1220                 do
1221                         cf_subdirs=
1222                         for cf_item in $CF_LIST_MODELS
1223                         do
1224                         echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
1225                         CF_UPPER(CF_ITEM,$cf_item)
1226                         CF_LIB_SUFFIX($cf_item,cf_suffix)
1227                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
1228
1229                         # These dependencies really are for development, not
1230                         # builds, but they are useful in porting, too.
1231                         cf_depend="../include/ncurses_cfg.h"
1232                         if test "$srcdir" = "."; then
1233                                 cf_reldir="."
1234                         else
1235                                 cf_reldir="\$(srcdir)"
1236                         fi
1237
1238                         if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
1239                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
1240                         elif test -f $srcdir/$cf_dir/curses.priv.h; then
1241                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
1242                         fi
1243
1244                         $AWK -f $srcdir/mk-1st.awk \
1245                                 name=$cf_dir \
1246                                 traces=$LIB_TRACING \
1247                                 MODEL=$CF_ITEM \
1248                                 model=$cf_subdir \
1249                                 prefix=$cf_prefix \
1250                                 suffix=$cf_suffix \
1251                                 subset=$cf_subset \
1252                                 ShlibVer=$cf_cv_shlib_version \
1253                                 ShlibVerInfix=$cf_cv_shlib_version_infix \
1254                                 DoLinks=$cf_cv_do_symlinks \
1255                                 rmSoLocs=$cf_cv_rm_so_locs \
1256                                 ldconfig="$LDCONFIG" \
1257                                 overwrite=$WITH_OVERWRITE \
1258                                 depend="$cf_depend" \
1259                                 host="$host" \
1260                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
1261                         for cf_subdir2 in $cf_subdirs lib
1262                         do
1263                                 test $cf_subdir = $cf_subdir2 && break
1264                         done
1265                         test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
1266                         $AWK -f $srcdir/mk-2nd.awk \
1267                                 name=$cf_dir \
1268                                 traces=$LIB_TRACING \
1269                                 MODEL=$CF_ITEM \
1270                                 model=$cf_subdir \
1271                                 subset=$cf_subset \
1272                                 srcdir=$srcdir \
1273                                 echo=$WITH_ECHO \
1274                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
1275                         cf_subdirs="$cf_subdirs $cf_subdir"
1276                         done
1277                 done
1278         fi
1279
1280         echo '  cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >>Makefile
1281 done
1282
1283 for cf_dir in $SRC_SUBDIRS
1284 do
1285         if test -f $cf_dir/Makefile ; then
1286                 case "$cf_dir" in
1287                 Ada95) #(vi
1288                         echo 'libs \' >> Makefile
1289                         echo 'install.libs \' >> Makefile
1290                         echo 'uninstall.libs ::' >> Makefile
1291                         echo '  cd '$cf_dir' && $(MAKE) $(CF_MFLAGS) [$]@' >> Makefile
1292                         ;;
1293                 esac
1294         fi
1295
1296         if test -f $srcdir/$cf_dir/modules; then
1297                 echo >> Makefile
1298                 if test -f $srcdir/$cf_dir/headers; then
1299 cat >> Makefile <<CF_EOF
1300 install.includes \\
1301 uninstall.includes \\
1302 CF_EOF
1303                 fi
1304 if test "$cf_dir" != "c++" ; then
1305 echo 'lint \' >> Makefile
1306 fi
1307 cat >> Makefile <<CF_EOF
1308 libs \\
1309 lintlib \\
1310 install.libs \\
1311 uninstall.libs \\
1312 install.$cf_dir \\
1313 uninstall.$cf_dir ::
1314         cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
1315 CF_EOF
1316         elif test -f $srcdir/$cf_dir/headers; then
1317 cat >> Makefile <<CF_EOF
1318
1319 libs \\
1320 install.libs \\
1321 uninstall.libs \\
1322 install.includes \\
1323 uninstall.includes ::
1324         cd $cf_dir && \$(MAKE) \$(CF_MFLAGS) \[$]@
1325 CF_EOF
1326 fi
1327 done
1328
1329 cat >> Makefile <<CF_EOF
1330
1331 install.data \\
1332 uninstall.data ::
1333 $MAKE_TERMINFO  cd misc && \$(MAKE) \$(CF_MFLAGS) \[$]@
1334
1335 install.man \\
1336 uninstall.man ::
1337         cd man && \$(MAKE) \$(CF_MFLAGS) \[$]@
1338
1339 distclean ::
1340         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
1341         rm -f headers.sh headers.sed
1342         rm -rf \$(DIRS_TO_MAKE)
1343 CF_EOF
1344
1345 # Special case: tack's manpage lives in its own directory.
1346 if test -d tack ; then
1347 if test -f $srcdir/$tack.h; then
1348 cat >> Makefile <<CF_EOF
1349
1350 install.man \\
1351 uninstall.man ::
1352         cd tack && \$(MAKE) \$(CF_MFLAGS) \[$]@
1353 CF_EOF
1354 fi
1355 fi
1356
1357 dnl If we're installing into a subdirectory of /usr/include, etc., we should
1358 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
1359 dnl anything, and will make it more standardized.  It's awkward to decide this
1360 dnl at configuration because of quoting, so we'll simply make all headers
1361 dnl installed via a script that can do the right thing.
1362
1363 rm -f headers.sed headers.sh
1364
1365 dnl ( generating this script makes the makefiles a little tidier :-)
1366 echo creating headers.sh
1367 cat >headers.sh <<CF_EOF
1368 #! /bin/sh
1369 # This shell script is generated by the 'configure' script.  It is invoked in a
1370 # subdirectory of the build tree.  It generates a sed-script in the parent
1371 # directory that is used to adjust includes for header files that reside in a
1372 # subdirectory of /usr/include, etc.
1373 PRG=""
1374 while test \[$]# != 3
1375 do
1376 PRG="\$PRG \[$]1"; shift
1377 done
1378 DST=\[$]1
1379 REF=\[$]2
1380 SRC=\[$]3
1381 TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
1382 TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
1383 echo installing \$SRC in \$DST
1384 CF_EOF
1385 if test $WITH_CURSES_H = yes; then
1386         cat >>headers.sh <<CF_EOF
1387 case \$DST in
1388 /*/include/*)
1389         END=\`basename \$DST\`
1390         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
1391         do
1392                 NAME=\`basename \$i\`
1393                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
1394         done
1395         ;;
1396 *)
1397         echo "" >> \$TMPSED
1398         ;;
1399 esac
1400 CF_EOF
1401 else
1402         cat >>headers.sh <<CF_EOF
1403 case \$DST in
1404 /*/include/*)
1405         END=\`basename \$DST\`
1406         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
1407         do
1408                 NAME=\`basename \$i\`
1409                 if test "\$NAME" = "curses.h"
1410                 then
1411                         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
1412                         NAME=ncurses.h
1413                 fi
1414                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
1415         done
1416         ;;
1417 *)
1418         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
1419         ;;
1420 esac
1421 CF_EOF
1422 fi
1423 cat >>headers.sh <<CF_EOF
1424 rm -f \$TMPSRC
1425 sed -f \$TMPSED \$SRC > \$TMPSRC
1426 NAME=\`basename \$SRC\`
1427 CF_EOF
1428 if test $WITH_CURSES_H != yes; then
1429         cat >>headers.sh <<CF_EOF
1430 test "\$NAME" = "curses.h" && NAME=ncurses.h
1431 CF_EOF
1432 fi
1433 cat >>headers.sh <<CF_EOF
1434 # Just in case someone gzip'd manpages, remove the conflicting copy.
1435 test -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
1436
1437 eval \$PRG \$TMPSRC \$DST/\$NAME
1438 rm -f \$TMPSRC \$TMPSED
1439 CF_EOF
1440
1441 chmod 0755 headers.sh
1442
1443 for cf_dir in $SRC_SUBDIRS
1444 do
1445         if test -f $srcdir/$cf_dir/headers; then
1446         cat >>$cf_dir/Makefile <<CF_EOF
1447 \$(DESTDIR)\$(includedir) :
1448         sh \$(srcdir)/../mkinstalldirs \[$]@
1449
1450 install \\
1451 install.libs \\
1452 install.includes :: \$(AUTO_SRC) \$(DESTDIR)\$(includedir) \\
1453 CF_EOF
1454                 j=""
1455                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1456                 do
1457                         test -n "$j" && echo "          $j \\" >>$cf_dir/Makefile
1458                         j=$i
1459                 done
1460                 echo "          $j" >>$cf_dir/Makefile
1461                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1462                 do
1463                         echo "  @ (cd \$(DESTDIR)\$(includedir) && rm -f `basename $i`) ; ../headers.sh \$(INSTALL_DATA) \$(DESTDIR)\$(includedir) \$(srcdir) $i" >>$cf_dir/Makefile
1464                         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
1465                 done
1466
1467         cat >>$cf_dir/Makefile <<CF_EOF
1468
1469 uninstall \\
1470 uninstall.libs \\
1471 uninstall.includes ::
1472 CF_EOF
1473                 for i in `cat $srcdir/$cf_dir/headers |fgrep -v "#"`
1474                 do
1475                         i=`basename $i`
1476                         echo "  -@ (cd \$(DESTDIR)\$(includedir) && rm -f $i)" >>$cf_dir/Makefile
1477                         test $i = curses.h && echo "    -@ (cd \$(DESTDIR)\$(includedir) && rm -f ncurses.h)" >>$cf_dir/Makefile
1478                 done
1479         fi
1480
1481         if test -f $srcdir/$cf_dir/modules; then
1482                 if test "$cf_dir" != "c++" ; then
1483                         cat >>$cf_dir/Makefile <<"CF_EOF"
1484 depend : $(AUTO_SRC)
1485         makedepend -- $(CPPFLAGS) -- $(C_SRC)
1486
1487 # DO NOT DELETE THIS LINE -- make depend depends on it.
1488 CF_EOF
1489                 fi
1490         fi
1491 done
1492
1493 ])dnl
1494 dnl ---------------------------------------------------------------------------
1495 dnl CF_LIB_SUFFIX version: 13 updated: 2003/11/01 16:09:07
1496 dnl -------------
1497 dnl Compute the library file-suffix from the given model name
1498 dnl $1 = model name
1499 dnl $2 = variable to set
1500 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1501 AC_DEFUN([CF_LIB_SUFFIX],
1502 [
1503         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1504         case $1 in
1505         libtool) $2='.la'  ;;
1506         normal)  $2='.a'   ;;
1507         debug)   $2='_g.a' ;;
1508         profile) $2='_p.a' ;;
1509         shared)
1510                 case $cf_cv_system_name in
1511                 cygwin*) $2='.dll' ;;
1512                 darwin*) $2='.dylib' ;;
1513                 hpux*)
1514                         case $target in
1515                         ia64*)  $2='.so' ;;
1516                         *)      $2='.sl' ;;
1517                         esac
1518                         ;;
1519                 *)      $2='.so'  ;;
1520                 esac
1521         esac
1522         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1523 ])dnl
1524 dnl ---------------------------------------------------------------------------
1525 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
1526 dnl -----------
1527 dnl Compute the string to append to -library from the given model name
1528 dnl $1 = model name
1529 dnl $2 = variable to set
1530 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1531 AC_DEFUN([CF_LIB_TYPE],
1532 [
1533         case $1 in
1534         libtool) $2=''   ;;
1535         normal)  $2=''   ;;
1536         debug)   $2='_g' ;;
1537         profile) $2='_p' ;;
1538         shared)  $2=''   ;;
1539         esac
1540         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1541 ])dnl
1542 dnl ---------------------------------------------------------------------------
1543 dnl CF_LINK_DATAONLY version: 6 updated: 2003/02/02 01:41:46
1544 dnl ----------------
1545 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1546 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
1547 dnl have to provide wrappers for global tables to ensure they're linked
1548 dnl properly.
1549 AC_DEFUN([CF_LINK_DATAONLY],
1550 [
1551 AC_MSG_CHECKING([if data-only library module links])
1552 AC_CACHE_VAL(cf_cv_link_dataonly,[
1553         rm -f conftest.a
1554         cat >conftest.$ac_ext <<EOF
1555 #line __oline__ "configure"
1556 int     testdata[[3]] = { 123, 456, 789 };
1557 EOF
1558         if AC_TRY_EVAL(ac_compile) ; then
1559                 mv conftest.o data.o && \
1560                 ( $AR $AR_OPTS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
1561         fi
1562         rm -f conftest.$ac_ext data.o
1563         cat >conftest.$ac_ext <<EOF
1564 #line __oline__ "configure"
1565 int     testfunc()
1566 {
1567 #if defined(NeXT)
1568         exit(1);        /* I'm told this linker is broken */
1569 #else
1570         extern int testdata[[3]];
1571         return testdata[[0]] == 123
1572            &&  testdata[[1]] == 456
1573            &&  testdata[[2]] == 789;
1574 #endif
1575 }
1576 EOF
1577         if AC_TRY_EVAL(ac_compile); then
1578                 mv conftest.o func.o && \
1579                 ( $AR $AR_OPTS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
1580         fi
1581         rm -f conftest.$ac_ext func.o
1582         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
1583         cf_saveLIBS="$LIBS"
1584         LIBS="conftest.a $LIBS"
1585         AC_TRY_RUN([
1586         int main()
1587         {
1588                 extern int testfunc();
1589                 exit (!testfunc());
1590         }
1591         ],
1592         [cf_cv_link_dataonly=yes],
1593         [cf_cv_link_dataonly=no],
1594         [cf_cv_link_dataonly=unknown])
1595         LIBS="$cf_saveLIBS"
1596         ])
1597 AC_MSG_RESULT($cf_cv_link_dataonly)
1598
1599 if test "$cf_cv_link_dataonly" = no ; then
1600         AC_DEFINE(BROKEN_LINKER)
1601         BROKEN_LINKER=1
1602 fi
1603
1604 ])dnl
1605 dnl ---------------------------------------------------------------------------
1606 dnl CF_LINK_FUNCS version: 5 updated: 2003/02/02 01:41:46
1607 dnl -------------
1608 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1609 dnl A few non-Unix systems implement symlink, but not link.
1610 dnl A few non-systems implement neither (or have nonfunctional versions).
1611 AC_DEFUN([CF_LINK_FUNCS],
1612 [
1613 AC_CHECK_FUNCS( \
1614         remove \
1615         unlink )
1616
1617 if test "$cross_compiling" = yes ; then
1618         AC_CHECK_FUNCS( \
1619                 link \
1620                 symlink )
1621 else
1622         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1623                 cf_cv_link_funcs=
1624                 for cf_func in link symlink ; do
1625                         AC_TRY_RUN([
1626 #include <sys/types.h>
1627 #include <sys/stat.h>
1628 #ifdef HAVE_UNISTD_H
1629 #include <unistd.h>
1630 #endif
1631 int main()
1632 {
1633         int fail = 0;
1634         char *src = "config.log";
1635         char *dst = "conftest.chk";
1636         struct stat src_sb;
1637         struct stat dst_sb;
1638
1639         stat(src, &src_sb);
1640         fail = ($cf_func("config.log", "conftest.chk") < 0)
1641             || (stat(dst, &dst_sb) < 0)
1642             || (dst_sb.st_mtime != src_sb.st_mtime);
1643 #ifdef HAVE_UNLINK
1644         unlink(dst);
1645 #else
1646         remove(dst);
1647 #endif
1648         exit (fail);
1649 }
1650                         ],[
1651                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1652                         eval 'ac_cv_func_'$cf_func'=yes'],[
1653                         eval 'ac_cv_func_'$cf_func'=no'],[
1654                         eval 'ac_cv_func_'$cf_func'=error'])
1655                 done
1656                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1657         ])
1658         test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK)
1659         test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
1660 fi
1661 ])dnl
1662 dnl ---------------------------------------------------------------------------
1663 dnl CF_MAKEFLAGS version: 9 updated: 2001/12/30 18:17:27
1664 dnl ------------
1665 dnl Some 'make' programs support $(MAKEFLAGS), some $(MFLAGS), to pass 'make'
1666 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
1667 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1668 dnl $(MAKEFLAGS) variable incompatible because it adds the assignments :-)
1669 AC_DEFUN([CF_MAKEFLAGS],
1670 [
1671 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
1672         cf_cv_makeflags=''
1673         for cf_option in '-$(MAKEFLAGS)' '$(MFLAGS)'
1674         do
1675                 cat >cf_makeflags.tmp <<CF_EOF
1676 SHELL = /bin/sh
1677 all :
1678         @ echo '.$cf_option'
1679 CF_EOF
1680                 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null`
1681                 case "$cf_result" in
1682                 .*k)
1683                         cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1684                         case "$cf_result" in
1685                         .*CC=*) cf_cv_makeflags=
1686                                 ;;
1687                         *)      cf_cv_makeflags=$cf_option
1688                                 ;;
1689                         esac
1690                         break
1691                         ;;
1692                 *)      echo no match "$cf_result"
1693                         ;;
1694                 esac
1695         done
1696         rm -f cf_makeflags.tmp
1697 ])
1698
1699 AC_SUBST(cf_cv_makeflags)
1700 ])dnl
1701 dnl ---------------------------------------------------------------------------
1702 dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
1703 dnl ------------
1704 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1705 dnl a monocase filesystem.
1706 AC_DEFUN([CF_MAKE_TAGS],[
1707 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1708 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
1709
1710 if test "$cf_cv_mixedcase" = yes ; then
1711         AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
1712 else
1713         MAKE_UPPER_TAGS=no
1714 fi
1715
1716 if test "$MAKE_UPPER_TAGS" = yes ; then
1717         MAKE_UPPER_TAGS=
1718 else
1719         MAKE_UPPER_TAGS="#"
1720 fi
1721 AC_SUBST(MAKE_UPPER_TAGS)
1722
1723 if test "$MAKE_LOWER_TAGS" = yes ; then
1724         MAKE_LOWER_TAGS=
1725 else
1726         MAKE_LOWER_TAGS="#"
1727 fi
1728 AC_SUBST(MAKE_LOWER_TAGS)
1729 ])dnl
1730 dnl ---------------------------------------------------------------------------
1731 dnl CF_MANPAGE_FORMAT version: 7 updated: 2003/12/20 19:30:34
1732 dnl -----------------
1733 dnl Option to allow user to override automatic configuration of manpage format.
1734 dnl There are several special cases:
1735 dnl
1736 dnl     gzip - man checks for, can display gzip'd files
1737 dnl     compress - man checks for, can display compressed files
1738 dnl     BSDI - files in the cat-directories are suffixed ".0"
1739 dnl     formatted - installer should format (put files in cat-directory)
1740 dnl     catonly - installer should only format, e.g., for a turnkey system.
1741 dnl
1742 dnl There are other configurations which this macro does not test, e.g., HPUX's
1743 dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
1744 dnl convention would not match our use).
1745 AC_DEFUN([CF_MANPAGE_FORMAT],
1746 [
1747 AC_REQUIRE([CF_PATHSEP])
1748 AC_MSG_CHECKING(format of man-pages)
1749
1750 AC_ARG_WITH(manpage-format,
1751         [  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
1752                           optionally formatted/catonly, e.g., gzip,formatted],
1753         [MANPAGE_FORMAT=$withval],
1754         [MANPAGE_FORMAT=unknown])
1755
1756 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
1757 MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
1758
1759 cf_unknown=
1760
1761 case $MANPAGE_FORMAT in
1762 unknown)
1763   if test -z "$MANPATH" ; then
1764     MANPATH="/usr/man:/usr/share/man"
1765   fi
1766
1767   # look for the 'date' man-page (it's most likely to be installed!)
1768   MANPAGE_FORMAT=
1769   cf_preform=no
1770   cf_catonly=yes
1771   cf_example=date
1772
1773   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
1774   for cf_dir in $MANPATH; do
1775     test -z "$cf_dir" && cf_dir=/usr/man
1776     for cf_name in $cf_dir/man*/$cf_example.[[01]]* $cf_dir/cat*/$cf_example.[[01]]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
1777     do
1778       cf_test=`echo $cf_name | sed -e 's/*//'`
1779       if test "x$cf_test" = "x$cf_name" ; then
1780
1781         case "$cf_name" in
1782         *.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
1783         *.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
1784         *.0)    MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
1785         *)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
1786         esac
1787
1788         case "$cf_name" in
1789         $cf_dir/man*)
1790           cf_catonly=no
1791           ;;
1792         $cf_dir/cat*)
1793           cf_preform=yes
1794           ;;
1795         esac
1796         break
1797       fi
1798
1799       # if we found a match in either man* or cat*, stop looking
1800       if test -n "$MANPAGE_FORMAT" ; then
1801         cf_found=no
1802         test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
1803         test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
1804         case "$cf_name" in
1805         $cf_dir/cat*)
1806           cf_found=yes
1807           ;;
1808         esac
1809         test $cf_found=yes && break
1810       fi
1811     done
1812     # only check the first directory in $MANPATH where we find manpages
1813     if test -n "$MANPAGE_FORMAT" ; then
1814        break
1815     fi
1816   done
1817   # if we did not find the example, just assume it is normal
1818   test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
1819   IFS="$ac_save_ifs"
1820   ;;
1821 *)
1822   for cf_option in $MANPAGE_FORMAT; do
1823      case $cf_option in #(vi
1824      gzip|compress|BSDI|normal|formatted|catonly)
1825        ;;
1826      *)
1827        cf_unknown="$cf_unknown $cf_option"
1828        ;;
1829      esac
1830   done
1831   ;;
1832 esac
1833
1834 AC_MSG_RESULT($MANPAGE_FORMAT)
1835 if test -n "$cf_unknown" ; then
1836   AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
1837 fi
1838 ])dnl
1839 dnl ---------------------------------------------------------------------------
1840 dnl CF_MANPAGE_RENAMES version: 6 updated: 2002/01/19 22:51:32
1841 dnl ------------------
1842 dnl The Debian people have their own naming convention for manpages.  This
1843 dnl option lets us override the name of the file containing renaming, or
1844 dnl disable it altogether.
1845 AC_DEFUN([CF_MANPAGE_RENAMES],
1846 [
1847 AC_MSG_CHECKING(for manpage renaming)
1848
1849 AC_ARG_WITH(manpage-renames,
1850         [  --with-manpage-renames  specify manpage-renaming],
1851         [MANPAGE_RENAMES=$withval],
1852         [MANPAGE_RENAMES=yes])
1853
1854 case ".$MANPAGE_RENAMES" in #(vi
1855 .no) #(vi
1856   ;;
1857 .|.yes)
1858   # Debian 'man' program?
1859   if test -f /etc/debian_version ; then
1860     MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
1861   else
1862     MANPAGE_RENAMES=no
1863   fi
1864   ;;
1865 esac
1866
1867 if test "$MANPAGE_RENAMES" != no ; then
1868   if test -f $srcdir/man/$MANPAGE_RENAMES ; then
1869     MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
1870   elif test ! -f $MANPAGE_RENAMES ; then
1871     AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
1872   fi
1873
1874   test ! -d man && mkdir man
1875
1876   # Construct a sed-script to perform renaming within man-pages
1877   if test -n "$MANPAGE_RENAMES" ; then
1878     test ! -d man && mkdir man
1879     sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >man/edit_man.sed
1880   fi
1881 fi
1882
1883 AC_MSG_RESULT($MANPAGE_RENAMES)
1884 AC_SUBST(MANPAGE_RENAMES)
1885 ])dnl
1886 dnl ---------------------------------------------------------------------------
1887 dnl CF_MANPAGE_SYMLINKS version: 4 updated: 2003/12/13 18:01:58
1888 dnl -------------------
1889 dnl Some people expect each tool to make all aliases for manpages in the
1890 dnl man-directory.  This accommodates the older, less-capable implementations
1891 dnl of 'man', and is optional.
1892 AC_DEFUN([CF_MANPAGE_SYMLINKS],
1893 [
1894 AC_MSG_CHECKING(if manpage aliases will be installed)
1895
1896 AC_ARG_WITH(manpage-aliases,
1897         [  --with-manpage-aliases  specify manpage-aliases using .so],
1898         [MANPAGE_ALIASES=$withval],
1899         [MANPAGE_ALIASES=yes])
1900
1901 AC_MSG_RESULT($MANPAGE_ALIASES)
1902
1903 if test "$LN_S" = "ln -s"; then
1904         cf_use_symlinks=yes
1905 else
1906         cf_use_symlinks=no
1907 fi
1908
1909 MANPAGE_SYMLINKS=no
1910 if test "$MANPAGE_ALIASES" = yes ; then
1911 AC_MSG_CHECKING(if manpage symlinks should be used)
1912
1913 AC_ARG_WITH(manpage-symlinks,
1914         [  --with-manpage-symlinks specify manpage-aliases using symlinks],
1915         [MANPAGE_SYMLINKS=$withval],
1916         [MANPAGE_SYMLINKS=$cf_use_symlinks])
1917
1918 if test "$$cf_use_symlinks" = no; then
1919 if test "$MANPAGE_SYMLINKS" = yes ; then
1920         AC_MSG_WARN(cannot make symlinks, will use .so files)
1921         MANPAGE_SYMLINKS=no
1922 fi
1923 fi
1924
1925 AC_MSG_RESULT($MANPAGE_SYMLINKS)
1926 fi
1927
1928 ])dnl
1929 dnl ---------------------------------------------------------------------------
1930 dnl CF_MANPAGE_TBL version: 3 updated: 2002/01/19 22:51:32
1931 dnl --------------
1932 dnl This option causes manpages to be run through tbl(1) to generate tables
1933 dnl correctly.
1934 AC_DEFUN([CF_MANPAGE_TBL],
1935 [
1936 AC_MSG_CHECKING(for manpage tbl)
1937
1938 AC_ARG_WITH(manpage-tbl,
1939         [  --with-manpage-tbl      specify manpage processing with tbl],
1940         [MANPAGE_TBL=$withval],
1941         [MANPAGE_TBL=no])
1942
1943 AC_MSG_RESULT($MANPAGE_TBL)
1944 ])dnl
1945 dnl ---------------------------------------------------------------------------
1946 dnl CF_MAN_PAGES version: 27 updated: 2003/12/20 20:39:45
1947 dnl ------------
1948 dnl Try to determine if the man-pages on the system are compressed, and if
1949 dnl so, what format is used.  Use this information to construct a script that
1950 dnl will install man-pages.
1951 AC_DEFUN([CF_MAN_PAGES],
1952 [
1953 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
1954 CF_MANPAGE_FORMAT
1955 CF_MANPAGE_RENAMES
1956 CF_MANPAGE_SYMLINKS
1957 CF_MANPAGE_TBL
1958
1959   if test "$prefix" = "NONE" ; then
1960      cf_prefix="$ac_default_prefix"
1961   else
1962      cf_prefix="$prefix"
1963   fi
1964
1965   case "$MANPAGE_FORMAT" in # (vi
1966   *catonly*) # (vi
1967     cf_format=yes
1968     cf_inboth=no
1969     ;;
1970   *formatted*) # (vi
1971     cf_format=yes
1972     cf_inboth=yes
1973     ;;
1974   *)
1975     cf_format=no
1976     cf_inboth=no
1977     ;;
1978   esac
1979
1980 test ! -d man && mkdir man
1981
1982 cf_so_strip=
1983 cf_compress=
1984 case "$MANPAGE_FORMAT" in #(vi
1985 *compress*) #(vi
1986         cf_so_strip="Z"
1987         cf_compress=compress
1988   ;;
1989 *gzip*) #(vi
1990         cf_so_strip="gz"
1991         cf_compress=gzip
1992   ;;
1993 esac
1994
1995 cf_edit_man=man/edit_man.sh
1996
1997 cat >$cf_edit_man <<CF_EOF
1998 #! /bin/sh
1999 # this script is generated by the configure-script CF_MAN_PAGES macro.
2000 prefix="$cf_prefix"
2001 datadir="$datadir"
2002 NCURSES_OSPEED="$NCURSES_OSPEED"
2003 TERMINFO="$TERMINFO"
2004 MKDIRS="sh `cd $srcdir && pwd`/mkinstalldirs"
2005 INSTALL="$INSTALL"
2006 INSTALL_DATA="$INSTALL_DATA"
2007 transform="$program_transform_name"
2008
2009 TMP=\${TMPDIR-/tmp}/man\$\$
2010 trap "rm -f \$TMP" 0 1 2 5 15
2011
2012 form=\[$]1
2013 shift || exit 1
2014
2015 verb=\[$]1
2016 shift || exit 1
2017
2018 mandir=\[$]1
2019 shift || exit 1
2020
2021 srcdir=\[$]1
2022 shift || exit 1
2023
2024 if test "\$form" = normal ; then
2025         if test "$cf_format" = yes ; then
2026         if test "$cf_inboth" = no ; then
2027                 sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
2028                 exit $?
2029         fi
2030         fi
2031         cf_subdir=\$mandir/man
2032         cf_tables=$MANPAGE_TBL
2033 else
2034         cf_subdir=\$mandir/cat
2035         cf_tables=yes
2036 fi
2037
2038 # process the list of source-files
2039 for i in \[$]* ; do
2040 case \$i in #(vi
2041 *.orig|*.rej) ;; #(vi
2042 *.[[0-9]]*)
2043         section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
2044         if test \$verb = installing ; then
2045         if test ! -d \$cf_subdir\${section} ; then
2046                 \$MKDIRS \$cf_subdir\$section
2047         fi
2048         fi
2049         aliases=
2050         source=\`basename \$i\`
2051         inalias=\$source
2052         test ! -f \$inalias && inalias="\$srcdir/\$inalias"
2053         if test ! -f \$inalias ; then
2054                 echo .. skipped \$source
2055                 continue
2056         fi
2057 CF_EOF
2058
2059 if test "$MANPAGE_ALIASES" != no ; then
2060 cat >>$cf_edit_man <<CF_EOF
2061         aliases=\`sed -f \$srcdir/manlinks.sed \$inalias | sort -u\`
2062 CF_EOF
2063 fi
2064
2065 if test "$MANPAGE_RENAMES" = no ; then
2066 cat >>$cf_edit_man <<CF_EOF
2067         # perform program transformations for section 1 man pages
2068         if test \$section = 1 ; then
2069                 target=\$cf_subdir\${section}/\`echo \$source|sed "\${transform}"\`
2070         else
2071                 target=\$cf_subdir\${section}/\$source
2072         fi
2073 CF_EOF
2074 else
2075 cat >>$cf_edit_man <<CF_EOF
2076         target=\`grep "^\$source" $MANPAGE_RENAMES | $AWK '{print \[$]2}'\`
2077         if test -z "\$target" ; then
2078                 echo '? missing rename for '\$source
2079                 target="\$source"
2080         fi
2081         target="\$cf_subdir\${section}/\${target}"
2082 CF_EOF
2083 fi
2084
2085         # replace variables in man page
2086         ifelse($1,,,[
2087         for cf_name in $1
2088         do
2089 cat >>$cf_edit_man <<CF_EOF
2090         prog_$cf_name=\`echo $cf_name|sed "\${transform}"\`
2091 CF_EOF
2092         done
2093         ])
2094 cat >>$cf_edit_man <<CF_EOF
2095         sed     -e "s,@DATADIR@,\$datadir," \\
2096                 -e "s,@TERMINFO@,\$TERMINFO," \\
2097                 -e "s,@NCURSES_OSPEED@,\$NCURSES_OSPEED," \\
2098 CF_EOF
2099
2100         ifelse($1,,,[
2101         for cf_name in $1
2102         do
2103                 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2104 cat >>$cf_edit_man <<CF_EOF
2105                 -e "s,@$cf_NAME@,\$prog_$cf_name," \\
2106 CF_EOF
2107         done
2108         ])
2109
2110 if test -f $MANPAGE_RENAMES ; then
2111 cat >>$cf_edit_man <<CF_EOF
2112                 < \$i | sed -f $srcdir/edit_man.sed >\$TMP
2113 CF_EOF
2114 else
2115 cat >>$cf_edit_man <<CF_EOF
2116                 < \$i >\$TMP
2117 CF_EOF
2118 fi
2119
2120 cat >>$cf_edit_man <<CF_EOF
2121 if test \$cf_tables = yes ; then
2122         tbl \$TMP >\$TMP.out
2123         mv \$TMP.out \$TMP
2124 fi
2125 CF_EOF
2126
2127 if test $with_curses_h != yes ; then
2128 cat >>$cf_edit_man <<CF_EOF
2129         sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
2130         mv \$TMP.out \$TMP
2131 CF_EOF
2132 fi
2133
2134 cat >>$cf_edit_man <<CF_EOF
2135         if test \$form = format ; then
2136                 nroff -man \$TMP >\$TMP.out
2137                 mv \$TMP.out \$TMP
2138         fi
2139 CF_EOF
2140
2141 if test -n "$cf_compress" ; then
2142 cat >>$cf_edit_man <<CF_EOF
2143         if test \$verb = installing ; then
2144         if ( $cf_compress -f \$TMP )
2145         then
2146                 mv \$TMP.$cf_so_strip \$TMP
2147         fi
2148         fi
2149         target="\$target.$cf_so_strip"
2150 CF_EOF
2151 fi
2152
2153 case "$MANPAGE_FORMAT" in #(vi
2154 *BSDI*)
2155 cat >>$cf_edit_man <<CF_EOF
2156         if test \$form = format ; then
2157                 # BSDI installs only .0 suffixes in the cat directories
2158                 target="\`echo \$target|sed -e 's/\.[[1-9]]\+[[a-z]]*/.0/'\`"
2159         fi
2160 CF_EOF
2161   ;;
2162 esac
2163
2164 cat >>$cf_edit_man <<CF_EOF
2165         suffix=\`basename \$target | sed -e 's%^[[^.]]*%%'\`
2166         if test \$verb = installing ; then
2167                 echo \$verb \$target
2168                 \$INSTALL_DATA \$TMP \$target
2169                 test -n "\$aliases" && (
2170                         cd \$cf_subdir\${section} && (
2171                                 source=\`echo \$target |sed -e 's%^.*/\([[^/]][[^/]]*/[[^/]][[^/]]*$\)%\1%'\`
2172                                 test -n "$cf_so_strip" && source=\`echo \$source |sed -e 's%\.$cf_so_strip\$%%'\`
2173                                 target=\`basename \$target\`
2174                                 for cf_alias in \$aliases
2175                                 do
2176                                         if test \$section = 1 ; then
2177                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
2178                                         fi
2179
2180                                         if test "$MANPAGE_SYMLINKS" = yes ; then
2181                                                 if test -f \$cf_alias\${suffix} ; then
2182                                                         if ( cmp -s \$target \$cf_alias\${suffix} )
2183                                                         then
2184                                                                 continue
2185                                                         fi
2186                                                 fi
2187                                                 echo .. \$verb alias \$cf_alias\${suffix}
2188                                                 rm -f \$cf_alias\${suffix}
2189                                                 $LN_S \$target \$cf_alias\${suffix}
2190                                         elif test "\$target" != "\$cf_alias\${suffix}" ; then
2191                                                 echo ".so \$source" >\$TMP
2192 CF_EOF
2193 if test -n "$cf_compress" ; then
2194 cat >>$cf_edit_man <<CF_EOF
2195                                                 if test -n "$cf_so_strip" ; then
2196                                                         $cf_compress -f \$TMP
2197                                                         mv \$TMP.$cf_so_strip \$TMP
2198                                                 fi
2199 CF_EOF
2200 fi
2201 cat >>$cf_edit_man <<CF_EOF
2202                                                 echo .. \$verb alias \$cf_alias\${suffix}
2203                                                 rm -f \$cf_alias\${suffix}
2204                                                 \$INSTALL_DATA \$TMP \$cf_alias\${suffix}
2205                                         fi
2206                                 done
2207                         )
2208                 )
2209         elif test \$verb = removing ; then
2210                 echo \$verb \$target
2211                 rm -f \$target
2212                 test -n "\$aliases" && (
2213                         cd \$cf_subdir\${section} && (
2214                                 for cf_alias in \$aliases
2215                                 do
2216                                         if test \$section = 1 ; then
2217                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
2218                                         fi
2219
2220                                         echo .. \$verb alias \$cf_alias\${suffix}
2221                                         rm -f \$cf_alias\${suffix}
2222                                 done
2223                         )
2224                 )
2225         else
2226 #               echo ".hy 0"
2227                 cat \$TMP
2228         fi
2229         ;;
2230 esac
2231 done
2232
2233 if test $cf_inboth = yes ; then
2234 if test \$form != format ; then
2235         sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
2236 fi
2237 fi
2238
2239 exit 0
2240 CF_EOF
2241 chmod 755 $cf_edit_man
2242
2243 ])dnl
2244 dnl ---------------------------------------------------------------------------
2245 dnl CF_MATH_LIB version: 5 updated: 2000/05/28 01:39:10
2246 dnl -----------
2247 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
2248 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
2249 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
2250 AC_DEFUN([CF_MATH_LIB],
2251 [
2252 AC_CACHE_CHECK(if -lm needed for math functions,
2253         cf_cv_need_libm,[
2254         AC_TRY_LINK([
2255         #include <stdio.h>
2256         #include <math.h>
2257         ],
2258         [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
2259         [cf_cv_need_libm=no],
2260         [cf_cv_need_libm=yes])])
2261 if test "$cf_cv_need_libm" = yes
2262 then
2263 ifelse($1,,[
2264         LIBS="$LIBS -lm"
2265 ],[$1=-lm])
2266 fi
2267 ])
2268 dnl ---------------------------------------------------------------------------
2269 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
2270 dnl ----------------------
2271 dnl Check if the file-system supports mixed-case filenames.  If we're able to
2272 dnl create a lowercase name and see it as uppercase, it doesn't support that.
2273 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
2274 [
2275 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
2276 if test "$cross_compiling" = yes ; then
2277         case $target_alias in #(vi
2278         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
2279                 cf_cv_mixedcase=no
2280                 ;;
2281         *)
2282                 cf_cv_mixedcase=yes
2283                 ;;
2284         esac
2285 else
2286         rm -f conftest CONFTEST
2287         echo test >conftest
2288         if test -f CONFTEST ; then
2289                 cf_cv_mixedcase=no
2290         else
2291                 cf_cv_mixedcase=yes
2292         fi
2293         rm -f conftest CONFTEST
2294 fi
2295 ])
2296 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
2297 ])dnl
2298 dnl ---------------------------------------------------------------------------
2299 dnl CF_MKSTEMP version: 3 updated: 2001/11/08 20:59:59
2300 dnl ----------
2301 dnl Check for a working mkstemp.  This creates two files, checks that they are
2302 dnl successfully created and distinct (AmigaOS apparently fails on the last).
2303 AC_DEFUN([CF_MKSTEMP],[
2304 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
2305 rm -f conftest*
2306 AC_TRY_RUN([
2307 #include <sys/types.h>
2308 #include <stdlib.h>
2309 #include <stdio.h>
2310 #include <string.h>
2311 #include <sys/stat.h>
2312 int main()
2313 {
2314         char *tmpl = "conftestXXXXXX";
2315         char name[2][80];
2316         int n;
2317         int result = 0;
2318         int fd;
2319         struct stat sb;
2320
2321         umask(077);
2322         for (n = 0; n < 2; ++n) {
2323                 strcpy(name[n], tmpl);
2324                 if ((fd = mkstemp(name[n])) >= 0) {
2325                         if (!strcmp(name[n], tmpl)
2326                          || stat(name[n], &sb) != 0
2327                          || (sb.st_mode & S_IFMT) != S_IFREG
2328                          || (sb.st_mode & 077) != 0) {
2329                                 result = 1;
2330                         }
2331                         close(fd);
2332                 }
2333         }
2334         if (result == 0
2335          && !strcmp(name[0], name[1]))
2336                 result = 1;
2337         exit(result);
2338 }
2339 ],[cf_cv_func_mkstemp=yes
2340 ],[cf_cv_func_mkstemp=no
2341 ],[AC_CHECK_FUNC(mkstemp)
2342 ])
2343 ])
2344 if test "$cf_cv_func_mkstemp" = yes ; then
2345         AC_DEFINE(HAVE_MKSTEMP)
2346 fi
2347 ])dnl
2348 dnl ---------------------------------------------------------------------------
2349 dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
2350 dnl ----------------
2351 dnl Check if the given variable is a number.  If not, report an error.
2352 dnl $1 is the variable
2353 dnl $2 is the message
2354 AC_DEFUN([CF_NUMBER_SYNTAX],[
2355 if test -n "$1" ; then
2356   case $1 in #(vi
2357   [[0-9]]*) #(vi
2358         ;;
2359   *)
2360         AC_MSG_ERROR($2 is not a number: $1)
2361         ;;
2362   esac
2363 else
2364   AC_MSG_ERROR($2 value is empty)
2365 fi
2366 ])dnl
2367 dnl ---------------------------------------------------------------------------
2368 dnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
2369 dnl -------------
2370 dnl Compute the object-directory name from the given model name
2371 AC_DEFUN([CF_OBJ_SUBDIR],
2372 [
2373         case $1 in
2374         libtool) $2='obj_lo'  ;;
2375         normal)  $2='objects' ;;
2376         debug)   $2='obj_g' ;;
2377         profile) $2='obj_p' ;;
2378         shared)
2379                 case $cf_cv_system_name in #(vi
2380                 cygwin) #(vi
2381                         $2='objects' ;;
2382                 *)
2383                         $2='obj_s' ;;
2384                 esac
2385         esac
2386 ])dnl
2387 dnl ---------------------------------------------------------------------------
2388 dnl CF_PATHSEP version: 3 updated: 2001/01/12 01:23:53
2389 dnl ----------
2390 dnl Provide a value for the $PATH and similar separator
2391 AC_DEFUN([CF_PATHSEP],
2392 [
2393         case $cf_cv_system_name in
2394         os2*)   PATHSEP=';'  ;;
2395         *)      PATHSEP=':'  ;;
2396         esac
2397 ifelse($1,,,[$1=$PATHSEP])
2398         AC_SUBST(PATHSEP)
2399 ])dnl
2400 dnl ---------------------------------------------------------------------------
2401 dnl CF_PATH_SYNTAX version: 9 updated: 2002/09/17 23:03:38
2402 dnl --------------
2403 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2404 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2405 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2406 dnl delayed evaluation of those symbols.
2407 AC_DEFUN([CF_PATH_SYNTAX],[
2408 case ".[$]$1" in #(vi
2409 .\[$]\(*\)*|.\'*\'*) #(vi
2410   ;;
2411 ..|./*|.\\*) #(vi
2412   ;;
2413 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
2414   ;;
2415 .\[$]{*prefix}*) #(vi
2416   eval $1="[$]$1"
2417   case ".[$]$1" in #(vi
2418   .NONE/*)
2419     $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
2420     ;;
2421   esac
2422   ;; #(vi
2423 .NONE/*)
2424   $1=`echo [$]$1 | sed -e s%NONE%$ac_default_prefix%`
2425   ;;
2426 *)
2427   ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2428   ;;
2429 esac
2430 ])dnl
2431 dnl ---------------------------------------------------------------------------
2432 dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
2433 dnl ------------
2434 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
2435 dnl
2436 dnl $1 = symbol to test
2437 dnl $2 = value (if any) to use for a predefinition
2438 AC_DEFUN([CF_PREDEFINE],
2439 [
2440 AC_MSG_CHECKING(if we must define $1)
2441 AC_TRY_COMPILE([#include <sys/types.h>
2442 ],[
2443 #ifndef $1
2444 make an error
2445 #endif],[cf_result=no],[cf_result=yes])
2446 AC_MSG_RESULT($cf_result)
2447
2448 if test "$cf_result" = yes ; then
2449         CPPFLAGS="$CPPFLAGS ifelse($2,,-D$1,[-D$1=$2])"
2450 elif test "x$2" != "x" ; then
2451         AC_MSG_CHECKING(checking for compatible value versus $2)
2452         AC_TRY_COMPILE([#include <sys/types.h>
2453 ],[
2454 #if $1-$2 < 0
2455 make an error
2456 #endif],[cf_result=yes],[cf_result=no])
2457         AC_MSG_RESULT($cf_result)
2458         if test "$cf_result" = no ; then
2459                 # perhaps we can override it - try...
2460                 CPPFLAGS="$CPPFLAGS -D$1=$2"
2461         fi
2462 fi
2463 ])dnl
2464 dnl ---------------------------------------------------------------------------
2465 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
2466 dnl -----------
2467 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
2468 AC_DEFUN([CF_PROG_EXT],
2469 [
2470 AC_REQUIRE([CF_CHECK_CACHE])
2471 case $cf_cv_system_name in
2472 os2*)
2473     CFLAGS="$CFLAGS -Zmt"
2474     CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
2475     CXXFLAGS="$CXXFLAGS -Zmt"
2476     # autoconf's macro sets -Zexe and suffix both, which conflict:w
2477     LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
2478     ac_cv_exeext=.exe
2479     ;;
2480 esac
2481
2482 AC_EXEEXT
2483 AC_OBJEXT
2484
2485 PROG_EXT="$EXEEXT"
2486 AC_SUBST(PROG_EXT)
2487 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
2488 ])dnl
2489 dnl ---------------------------------------------------------------------------
2490 dnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
2491 dnl ---------------
2492 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
2493 dnl misc/tabset install won't work properly.  Usually this happens only when
2494 dnl using the fallback mkinstalldirs script
2495 AC_DEFUN([CF_PROG_INSTALL],
2496 [AC_PROG_INSTALL
2497 case $INSTALL in
2498 /*)
2499   ;;
2500 *)
2501   CF_DIRNAME(cf_dir,$INSTALL)
2502   test -z "$cf_dir" && cf_dir=.
2503   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
2504   ;;
2505 esac
2506 ])dnl
2507 dnl ---------------------------------------------------------------------------
2508 dnl CF_PROG_LDCONFIG version: 1 updated: 2003/09/20 17:07:55
2509 dnl ----------------
2510 dnl Check for ldconfig, needed to fixup shared libraries that would be built
2511 dnl and then used in the install.
2512 AC_DEFUN([CF_PROG_LDCONFIG],[
2513 if test "$cross_compiling" = yes ; then
2514   LDCONFIG=:
2515 else
2516 case "$cf_cv_system_name" in #(vi
2517 freebsd*) #(vi
2518   test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
2519   ;;
2520 *) LDPATH=$PATH:/sbin:/usr/sbin
2521   AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
2522   ;;
2523 esac
2524 fi
2525 AC_SUBST(LDCONFIG)
2526 ])dnl
2527 dnl ---------------------------------------------------------------------------
2528 dnl CF_REGEX version: 3 updated: 1997/11/01 14:26:01
2529 dnl --------
2530 dnl Attempt to determine if we've got one of the flavors of regular-expression
2531 dnl code that we can support.
2532 AC_DEFUN([CF_REGEX],
2533 [
2534 AC_MSG_CHECKING([for regular-expression headers])
2535 AC_CACHE_VAL(cf_cv_regex,[
2536 AC_TRY_LINK([#include <sys/types.h>
2537 #include <regex.h>],[
2538         regex_t *p;
2539         int x = regcomp(p, "", 0);
2540         int y = regexec(p, "", 0, 0, 0);
2541         regfree(p);
2542         ],[cf_cv_regex="regex.h"],[
2543         AC_TRY_LINK([#include <regexp.h>],[
2544                 char *p = compile("", "", "", 0);
2545                 int x = step("", "");
2546         ],[cf_cv_regex="regexp.h"],[
2547                 cf_save_LIBS="$LIBS"
2548                 LIBS="-lgen $LIBS"
2549                 AC_TRY_LINK([#include <regexpr.h>],[
2550                         char *p = compile("", "", "");
2551                         int x = step("", "");
2552                 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
2553 ])
2554 AC_MSG_RESULT($cf_cv_regex)
2555 case $cf_cv_regex in
2556         regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
2557         regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
2558         regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
2559 esac
2560 ])dnl
2561 dnl ---------------------------------------------------------------------------
2562 dnl CF_SHARED_OPTS version: 30 updated: 2003/12/27 20:48:07
2563 dnl --------------
2564 dnl Attempt to determine the appropriate CC/LD options for creating a shared
2565 dnl library.
2566 dnl
2567 dnl Note: $(LOCAL_LDFLAGS) is used to link executables that will run within the
2568 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
2569 dnl We avoid compiling-in a ../lib path for the shared library since that can
2570 dnl lead to unexpected results at runtime.
2571 dnl $(LOCAL_LDFLAGS2) has the same intention but assumes that the shared libraries
2572 dnl are compiled in ../../lib
2573 dnl
2574 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
2575 dnl to install symbolic links to the rel/abi versions of shared libraries.
2576 dnl
2577 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
2578 dnl version when making symbolic links.
2579 dnl
2580 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
2581 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
2582 dnl (ex: libncurses.so.<ver>).
2583 dnl
2584 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
2585 AC_DEFUN([CF_SHARED_OPTS],
2586 [
2587         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2588         LOCAL_LDFLAGS=
2589         LOCAL_LDFLAGS2=
2590         LD_SHARED_OPTS=
2591         INSTALL_LIB="-m 644"
2592
2593         cf_cv_do_symlinks=no
2594
2595         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
2596         AC_ARG_WITH(shlib-version,
2597         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
2598         [test -z "$withval" && withval=auto
2599         case $withval in #(vi
2600         yes) #(vi
2601                 cf_cv_shlib_version=auto
2602                 ;;
2603         rel|abi|auto|no) #(vi
2604                 cf_cv_shlib_version=$withval
2605                 ;;
2606         *)
2607                 AC_ERROR([option value must be one of: rel, abi, auto or no])
2608                 ;;
2609         esac
2610         ],[cf_cv_shlib_version=auto])
2611         AC_MSG_RESULT($cf_cv_shlib_version)
2612
2613         cf_cv_rm_so_locs=no
2614
2615         # Some less-capable ports of gcc support only -fpic
2616         CC_SHARED_OPTS=
2617         if test "$GCC" = yes
2618         then
2619                 AC_MSG_CHECKING(which $CC option to use)
2620                 cf_save_CFLAGS="$CFLAGS"
2621                 for CC_SHARED_OPTS in -fPIC -fpic ''
2622                 do
2623                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
2624                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
2625                 done
2626                 AC_MSG_RESULT($CC_SHARED_OPTS)
2627                 CFLAGS="$cf_save_CFLAGS"
2628         fi
2629
2630         cf_cv_shlib_version_infix=no
2631
2632         case $cf_cv_system_name in
2633         beos*)
2634                 MK_SHARED_LIB='$(CC) -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
2635                 ;;
2636         cygwin*)
2637                 CC_SHARED_OPTS=
2638                 MK_SHARED_LIB='$(CC) -shared -Wl,--out-implib=$(IMPORT_LIB) -Wl,--export-all-symbols -o $(SHARED_LIB)'
2639                 cf_cv_shlib_version=cygdll
2640                 cf_cv_shlib_version_infix=cygdll
2641                 ;;
2642         darwin*)
2643                 EXTRA_CFLAGS="-no-cpp-precomp"
2644                 CC_SHARED_OPTS="-dynamic"
2645                 MK_SHARED_LIB='$(CC) -dynamiclib -install_name $(DESTDIR)$(libdir)/`basename $[@]` -compatibility_version $(ABI_VERSION) -current_version $(ABI_VERSION) -o $[@]'
2646                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
2647                 cf_cv_shlib_version_infix=yes
2648                 ;;
2649         hpux*)
2650                 # (tested with gcc 2.7.2 -- I don't have c89)
2651                 if test "$GCC" = yes; then
2652                         LD_SHARED_OPTS='-Xlinker +b -Xlinker $(libdir)'
2653                 else
2654                         CC_SHARED_OPTS='+Z'
2655                         LD_SHARED_OPTS='-Wl,+b,$(libdir)'
2656                 fi
2657                 MK_SHARED_LIB='$(LD) +b $(libdir) -b -o $[@]'
2658                 # HP-UX shared libraries must be executable, and should be
2659                 # readonly to exploit a quirk in the memory manager.
2660                 INSTALL_LIB="-m 555"
2661                 ;;
2662         irix*)
2663                 if test "$cf_cv_ld_rpath" = yes ; then
2664                         cf_ld_rpath_opt="-Wl,-rpath,"
2665                         EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
2666                 fi
2667                 # tested with IRIX 5.2 and 'cc'.
2668                 if test "$GCC" != yes; then
2669                         CC_SHARED_OPTS='-KPIC'
2670                 fi
2671                 MK_SHARED_LIB='$(LD) -shared -rdata_shared -soname `basename $[@]` -o $[@]'
2672                 cf_cv_rm_so_locs=yes
2673                 ;;
2674         linux*|gnu*|k*bsd*-gnu)
2675                 if test "$DFT_LWR_MODEL" = "shared" ; then
2676                         LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
2677                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2678                 fi
2679                 if test "$cf_cv_ld_rpath" = yes ; then
2680                         cf_ld_rpath_opt="-Wl,-rpath,"
2681                         EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2682                 fi
2683                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2684                 MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION),-stats,-lc -o $[@]'
2685                 ;;
2686         openbsd2*)
2687                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2688                 MK_SHARED_LIB='$(LD) -Bshareable -soname,`basename $[@].$(ABI_VERSION)` -o $[@]'
2689                 ;;
2690         freebsd[[45]]*)
2691                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2692                 MK_SHARED_LIB='$(LD) -Bshareable -soname=`basename $[@]` -o $[@]'
2693                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2694
2695 # This doesn't work - I keep getting spurious references to needing
2696 # libncurses.so.5.3 when ldd says it's resolved.  LOCAL_LDFLAGS2 seems to be
2697 # no longer used anyway.  And the rpath logic isn't relative - so I have to
2698 # add the local and install lib-directories:
2699 #
2700 #               if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
2701 #                       LOCAL_LDFLAGS="-rpath `pwd`/lib"
2702 #                       LOCAL_LDFLAGS2="-rpath \$(libdir) $LOCAL_LDFLAGS"
2703 #                       cf_ld_rpath_opt="-rpath "
2704 #                       EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2705 #               fi
2706                 ;;
2707         openbsd*|freebsd*)
2708                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2709                 MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
2710                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2711                 ;;
2712         netbsd*)
2713                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2714                 test "$cf_cv_ld_rpath" = yes && cf_ld_rpath_opt="-Wl,-rpath,"
2715                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
2716                         LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
2717                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2718                         EXTRA_LDFLAGS="-Wl,-rpath,\$(libdir) $EXTRA_LDFLAGS"
2719                         MK_SHARED_LIB='$(CC) -shared -Wl,-soname,`basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
2720                         if test "$cf_cv_shlib_version" = auto; then
2721                         if test ! -f /usr/libexec/ld.elf_so; then
2722                                 cf_cv_shlib_version=rel
2723                         fi
2724                         fi
2725                 else
2726                         MK_SHARED_LIB='$(LD) -Bshareable -o $[@]'
2727                 fi
2728                 ;;
2729         osf*|mls+*)
2730                 # tested with OSF/1 V3.2 and 'cc'
2731                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
2732                 # link with shared libs).
2733                 MK_SHARED_LIB='$(LD) -set_version $(REL_VERSION):$(ABI_VERSION) -expect_unresolved "*" -shared -soname `basename $[@]`'
2734                 case $host_os in
2735                 osf4*)
2736                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
2737                         ;;
2738                 esac
2739                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
2740                 if test "$DFT_LWR_MODEL" = "shared" ; then
2741                         LOCAL_LDFLAGS="-Wl,-rpath,`pwd`/lib"
2742                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2743                 fi
2744                 if test "$cf_cv_ld_rpath" = yes ; then
2745                         cf_ld_rpath_opt="-rpath"
2746                         # EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2747                 fi
2748                 cf_cv_rm_so_locs=yes
2749                 ;;
2750         sco3.2v5*)  # (also uw2* and UW7) hops 13-Apr-98
2751                 # tested with osr5.0.5
2752                 if test "$GCC" != yes; then
2753                         CC_SHARED_OPTS='-belf -KPIC'
2754                 fi
2755                 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o [$]@'
2756                 if test "$cf_cv_ld_rpath" = yes ; then
2757                         # only way is to set LD_RUN_PATH but no switch for it
2758                         RUN_PATH=$libdir
2759                 fi
2760                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2761                 LINK_PROGS='LD_RUN_PATH=$(libdir)'
2762                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
2763                 ;;
2764         sunos4*)
2765                 # tested with SunOS 4.1.1 and gcc 2.7.0
2766                 if test "$GCC" != yes; then
2767                         CC_SHARED_OPTS='-KPIC'
2768                 fi
2769                 MK_SHARED_LIB='$(LD) -assert pure-text -o $[@]'
2770                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2771                 ;;
2772         solaris2*)
2773                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
2774                 if test "$GCC" != yes; then
2775                         CC_SHARED_OPTS='-KPIC'
2776                 fi
2777                 MK_SHARED_LIB='$(LD) -dy -G -h `basename $[@] .$(REL_VERSION)`.$(ABI_VERSION) -o $[@]'
2778                 if test "$DFT_LWR_MODEL" = "shared" ; then
2779                         LOCAL_LDFLAGS="-R `pwd`/lib:\$(libdir)"
2780                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2781                 fi
2782                 if test "$cf_cv_ld_rpath" = yes ; then
2783                         cf_ld_rpath_opt="-R"
2784                         EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2785                 fi
2786                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2787                 ;;
2788         sysv5uw7*|unix_sv*)
2789                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
2790                 if test "$GCC" != yes; then
2791                         CC_SHARED_OPTS='-KPIC'
2792                 fi
2793                 MK_SHARED_LIB='$(LD) -d y -G -o [$]@'
2794                 ;;
2795         *)
2796                 CC_SHARED_OPTS='unknown'
2797                 MK_SHARED_LIB='echo unknown'
2798                 ;;
2799         esac
2800
2801         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
2802         case "$cf_cv_shlib_version" in #(vi
2803         rel|abi)
2804                 case "$MK_SHARED_LIB" in #(vi
2805                 *'-o $[@]')
2806                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
2807                         ;;
2808                 *)
2809                         AC_MSG_WARN(ignored --with-shlib-version)
2810                         ;;
2811                 esac
2812                 ;;
2813         esac
2814
2815         if test -n "$cf_ld_rpath_opt" ; then
2816                 AC_MSG_CHECKING(if we need a space after rpath option)
2817                 cf_save_LIBS="$LIBS"
2818                 LIBS="$LIBS ${cf_ld_rpath_opt}$libdir"
2819                 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2820                 LIBS="$cf_save_LIBS"
2821                 AC_MSG_RESULT($cf_rpath_space)
2822                 test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
2823                 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\$(libdir)"
2824         fi
2825
2826         AC_SUBST(CC_SHARED_OPTS)
2827         AC_SUBST(LD_SHARED_OPTS)
2828         AC_SUBST(MK_SHARED_LIB)
2829         AC_SUBST(LINK_PROGS)
2830         AC_SUBST(LINK_TESTS)
2831         AC_SUBST(EXTRA_LDFLAGS)
2832         AC_SUBST(LOCAL_LDFLAGS)
2833         AC_SUBST(LOCAL_LDFLAGS2)
2834         AC_SUBST(INSTALL_LIB)
2835 ])dnl
2836 dnl ---------------------------------------------------------------------------
2837 dnl CF_SIZECHANGE version: 8 updated: 2000/11/04 12:22:16
2838 dnl -------------
2839 dnl Check for definitions & structures needed for window size-changing
2840 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
2841 AC_DEFUN([CF_SIZECHANGE],
2842 [
2843 AC_REQUIRE([CF_STRUCT_TERMIOS])
2844 AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
2845     cf_cv_sizechange=unknown
2846     cf_save_CPPFLAGS="$CPPFLAGS"
2847
2848 for cf_opts in "" "NEED_PTEM_H"
2849 do
2850
2851     CPPFLAGS="$cf_save_CPPFLAGS"
2852     test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
2853     AC_TRY_COMPILE([#include <sys/types.h>
2854 #ifdef HAVE_TERMIOS_H
2855 #include <termios.h>
2856 #else
2857 #ifdef HAVE_TERMIO_H
2858 #include <termio.h>
2859 #endif
2860 #endif
2861 #ifdef NEED_PTEM_H
2862 /* This is a workaround for SCO:  they neglected to define struct winsize in
2863  * termios.h -- it's only in termio.h and ptem.h
2864  */
2865 #include        <sys/stream.h>
2866 #include        <sys/ptem.h>
2867 #endif
2868 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
2869 #include <sys/ioctl.h>
2870 #endif
2871 ],[
2872 #ifdef TIOCGSIZE
2873         struct ttysize win;     /* FIXME: what system is this? */
2874         int y = win.ts_lines;
2875         int x = win.ts_cols;
2876 #else
2877 #ifdef TIOCGWINSZ
2878         struct winsize win;
2879         int y = win.ws_row;
2880         int x = win.ws_col;
2881 #else
2882         no TIOCGSIZE or TIOCGWINSZ
2883 #endif /* TIOCGWINSZ */
2884 #endif /* TIOCGSIZE */
2885         ],
2886         [cf_cv_sizechange=yes],
2887         [cf_cv_sizechange=no])
2888
2889         CPPFLAGS="$cf_save_CPPFLAGS"
2890         if test "$cf_cv_sizechange" = yes ; then
2891                 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
2892                 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
2893                 break
2894         fi
2895 done
2896 ])
2897 if test "$cf_cv_sizechange" != no ; then
2898         AC_DEFINE(HAVE_SIZECHANGE)
2899         case $cf_cv_sizechange in #(vi
2900         NEED*)
2901                 AC_DEFINE_UNQUOTED($cf_cv_sizechange )
2902                 ;;
2903         esac
2904 fi
2905 ])dnl
2906 dnl ---------------------------------------------------------------------------
2907 dnl CF_SRC_MODULES version: 15 updated: 2004/01/10 16:05:16
2908 dnl --------------
2909 dnl For each parameter, test if the source-directory exists, and if it contains
2910 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
2911 dnl use in CF_LIB_RULES.
2912 dnl
2913 dnl This uses the configured value to make the lists SRC_SUBDIRS and
2914 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
2915 AC_DEFUN([CF_SRC_MODULES],
2916 [
2917 AC_MSG_CHECKING(for src modules)
2918
2919 # dependencies and linker-arguments for test-programs
2920 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
2921 if test "$DFT_LWR_MODEL" = "libtool"; then
2922         TEST_ARGS="${TEST_DEPS}"
2923 else
2924         TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
2925 fi
2926
2927 # dependencies and linker-arguments for utility-programs
2928 test "$with_termlib" != yes && PROG_ARGS="$TEST_ARGS"
2929
2930 cf_cv_src_modules=
2931 for cf_dir in $1
2932 do
2933         if test -f $srcdir/$cf_dir/modules; then
2934
2935                 # We may/may not have tack in the distribution, though the
2936                 # makefile is.
2937                 if test $cf_dir = tack ; then
2938                         if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
2939                                 continue
2940                         fi
2941                 fi
2942
2943                 if test -z "$cf_cv_src_modules"; then
2944                         cf_cv_src_modules=$cf_dir
2945                 else
2946                         cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
2947                 fi
2948
2949                 # Make the ncurses_cfg.h file record the library interface files as
2950                 # well.  These are header files that are the same name as their
2951                 # directory.  Ncurses is the only library that does not follow
2952                 # that pattern.
2953                 if test $cf_dir = tack ; then
2954                         continue
2955                 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
2956                         CF_UPPER(cf_have_include,$cf_dir)
2957                         AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
2958                         AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
2959                         TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
2960                         if test "$DFT_LWR_MODEL" = "libtool"; then
2961                                 TEST_ARGS="${TEST_DEPS}"
2962                         else
2963                                 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
2964                         fi
2965                 fi
2966         fi
2967 done
2968 AC_MSG_RESULT($cf_cv_src_modules)
2969 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
2970 AC_SUBST(TEST_DEPS)
2971 AC_SUBST(TEST_ARGS)
2972
2973 PROG_ARGS="-L${LIB_DIR} $PROG_ARGS"
2974 AC_SUBST(PROG_ARGS)
2975
2976 SRC_SUBDIRS="man include"
2977 for cf_dir in $cf_cv_src_modules
2978 do
2979         SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
2980 done
2981 SRC_SUBDIRS="$SRC_SUBDIRS test"
2982 test -z "$MAKE_TERMINFO" && SRC_SUBDIRS="$SRC_SUBDIRS misc"
2983 test "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
2984
2985 ADA_SUBDIRS=
2986 if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
2987    SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
2988    ADA_SUBDIRS="gen src samples"
2989 fi
2990
2991 SUB_MAKEFILES=
2992 for cf_dir in $SRC_SUBDIRS
2993 do
2994         SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
2995 done
2996
2997 if test -n "$ADA_SUBDIRS"; then
2998    for cf_dir in $ADA_SUBDIRS
2999    do
3000       SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
3001    done
3002    AC_SUBST(ADA_SUBDIRS)
3003 fi
3004 ])dnl
3005 dnl ---------------------------------------------------------------------------
3006 dnl CF_STDCPP_LIBRARY version: 5 updated: 2000/08/12 23:18:52
3007 dnl -----------------
3008 dnl Check for -lstdc++, which is GNU's standard C++ library.
3009 AC_DEFUN([CF_STDCPP_LIBRARY],
3010 [
3011 if test -n "$GXX" ; then
3012 case $cf_cv_system_name in #(vi
3013 os2*) #(vi
3014         cf_stdcpp_libname=stdcpp
3015         ;;
3016 *)
3017         cf_stdcpp_libname=stdc++
3018         ;;
3019 esac
3020 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
3021         cf_save="$LIBS"
3022         LIBS="$LIBS -l$cf_stdcpp_libname"
3023 AC_TRY_LINK([
3024 #include <strstream.h>],[
3025 char buf[80];
3026 strstreambuf foo(buf, sizeof(buf))
3027 ],
3028         [cf_cv_libstdcpp=yes],
3029         [cf_cv_libstdcpp=no])
3030         LIBS="$cf_save"
3031 ])
3032 test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
3033 fi
3034 ])dnl
3035 dnl ---------------------------------------------------------------------------
3036 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
3037 dnl --------------
3038 dnl     Remove "-g" option from the compiler options
3039 AC_DEFUN([CF_STRIP_G_OPT],
3040 [$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
3041 dnl ---------------------------------------------------------------------------
3042 dnl CF_STRUCT_SIGACTION version: 3 updated: 2000/08/12 23:18:52
3043 dnl -------------------
3044 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
3045 dnl do this if we've found the sigaction function.
3046 dnl
3047 dnl If needed, define SVR4_ACTION.
3048 AC_DEFUN([CF_STRUCT_SIGACTION],[
3049 if test "$ac_cv_func_sigaction" = yes; then
3050 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
3051 AC_TRY_COMPILE([
3052 #include <sys/types.h>
3053 #include <signal.h>],
3054         [struct sigaction act],
3055         [sigact_bad=no],
3056         [
3057 AC_TRY_COMPILE([
3058 #define _POSIX_SOURCE
3059 #include <sys/types.h>
3060 #include <signal.h>],
3061         [struct sigaction act],
3062         [sigact_bad=yes
3063          AC_DEFINE(SVR4_ACTION)],
3064          [sigact_bad=unknown])])
3065 AC_MSG_RESULT($sigact_bad)
3066 fi
3067 ])dnl
3068 dnl ---------------------------------------------------------------------------
3069 dnl CF_STRUCT_TERMIOS version: 5 updated: 2000/11/04 12:22:46
3070 dnl -----------------
3071 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
3072 dnl If so, define SVR4_TERMIO
3073 AC_DEFUN([CF_STRUCT_TERMIOS],[
3074 AC_CHECK_HEADERS( \
3075 termio.h \
3076 termios.h \
3077 unistd.h \
3078 )
3079 if test "$ISC" = yes ; then
3080         AC_CHECK_HEADERS( sys/termio.h )
3081 fi
3082 if test "$ac_cv_header_termios_h" = yes ; then
3083         case "$CFLAGS $CPPFLAGS" in
3084         *-D_POSIX_SOURCE*)
3085                 termios_bad=dunno ;;
3086         *)      termios_bad=maybe ;;
3087         esac
3088         if test "$termios_bad" = maybe ; then
3089         AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
3090         AC_TRY_COMPILE([#include <termios.h>],
3091                 [struct termios foo; int x = foo.c_iflag],
3092                 termios_bad=no, [
3093                 AC_TRY_COMPILE([
3094 #define _POSIX_SOURCE
3095 #include <termios.h>],
3096                         [struct termios foo; int x = foo.c_iflag],
3097                         termios_bad=unknown,
3098                         termios_bad=yes AC_DEFINE(SVR4_TERMIO))
3099                         ])
3100         AC_MSG_RESULT($termios_bad)
3101         fi
3102 fi
3103 ])dnl
3104 dnl ---------------------------------------------------------------------------
3105 dnl CF_SUBST version: 2 updated: 1997/09/06 23:41:28
3106 dnl --------
3107 dnl     Shorthand macro for substituting things that the user may override
3108 dnl     with an environment variable.
3109 dnl
3110 dnl     $1 = long/descriptive name
3111 dnl     $2 = environment variable
3112 dnl     $3 = default value
3113 AC_DEFUN([CF_SUBST],
3114 [AC_CACHE_VAL(cf_cv_subst_$2,[
3115 AC_MSG_CHECKING(for $1 (symbol $2))
3116 test -z "[$]$2" && $2=$3
3117 AC_MSG_RESULT([$]$2)
3118 AC_SUBST($2)
3119 cf_cv_subst_$2=[$]$2])
3120 $2=${cf_cv_subst_$2}
3121 ])dnl
3122 dnl ---------------------------------------------------------------------------
3123 dnl CF_SUBST_NCURSES_VERSION version: 7 updated: 2003/06/07 16:22:51
3124 dnl ------------------------
3125 dnl Get the version-number for use in shared-library naming, etc.
3126 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
3127 [
3128 NCURSES_MAJOR="`egrep '^NCURSES_MAJOR[[         ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
3129 NCURSES_MINOR="`egrep '^NCURSES_MINOR[[         ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
3130 NCURSES_PATCH="`egrep '^NCURSES_PATCH[[         ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
3131 cf_cv_abi_version=${NCURSES_MAJOR}
3132 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
3133 dnl Show the computed version, for logging
3134 cf_cv_timestamp=`date`
3135 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
3136 dnl We need these values in the generated headers
3137 AC_SUBST(NCURSES_MAJOR)
3138 AC_SUBST(NCURSES_MINOR)
3139 AC_SUBST(NCURSES_PATCH)
3140 dnl We need these values in the generated makefiles
3141 AC_SUBST(cf_cv_rel_version)
3142 AC_SUBST(cf_cv_abi_version)
3143 AC_SUBST(cf_cv_builtin_bool)
3144 AC_SUBST(cf_cv_header_stdbool_h)
3145 AC_SUBST(cf_cv_type_of_bool)dnl
3146 ])dnl
3147 dnl ---------------------------------------------------------------------------
3148 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
3149 dnl ------------------
3150 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
3151 dnl older SCO configurations.
3152 AC_DEFUN([CF_SYS_TIME_SELECT],
3153 [
3154 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
3155 AC_CACHE_VAL(cf_cv_sys_time_select,[
3156 AC_TRY_COMPILE([
3157 #include <sys/types.h>
3158 #ifdef HAVE_SYS_TIME_H
3159 #include <sys/time.h>
3160 #endif
3161 #ifdef HAVE_SYS_SELECT_H
3162 #include <sys/select.h>
3163 #endif
3164 ],[],[cf_cv_sys_time_select=yes],
3165      [cf_cv_sys_time_select=no])
3166      ])
3167 AC_MSG_RESULT($cf_cv_sys_time_select)
3168 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
3169 ])dnl
3170 dnl ---------------------------------------------------------------------------
3171 dnl CF_TYPEOF_CHTYPE version: 4 updated: 2000/10/04 09:18:40
3172 dnl ----------------
3173 dnl Determine the type we should use for chtype (and attr_t, which is treated
3174 dnl as the same thing).  We want around 32 bits, so on most machines want a
3175 dnl long, but on newer 64-bit machines, probably want an int.  If we're using
3176 dnl wide characters, we have to have a type compatible with that, as well.
3177 AC_DEFUN([CF_TYPEOF_CHTYPE],
3178 [
3179 AC_REQUIRE([CF_UNSIGNED_LITERALS])
3180 AC_MSG_CHECKING([for type of chtype])
3181 AC_CACHE_VAL(cf_cv_typeof_chtype,[
3182                 AC_TRY_RUN([
3183 #ifdef USE_WIDEC_SUPPORT
3184 #include <stddef.h>     /* we want wchar_t */
3185 #define WANT_BITS 39
3186 #else
3187 #define WANT_BITS 31
3188 #endif
3189 #include <stdio.h>
3190 int main()
3191 {
3192         FILE *fp = fopen("cf_test.out", "w");
3193         if (fp != 0) {
3194                 char *result = "long";
3195 #ifdef USE_WIDEC_SUPPORT
3196                 /*
3197                  * If wchar_t is smaller than a long, it must be an int or a
3198                  * short.  We prefer not to use a short anyway.
3199                  */
3200                 if (sizeof(unsigned long) > sizeof(wchar_t))
3201                         result = "int";
3202 #endif
3203                 if (sizeof(unsigned long) > sizeof(unsigned int)) {
3204                         int n;
3205                         unsigned int x;
3206                         for (n = 0; n < WANT_BITS; n++) {
3207                                 unsigned int y = (x >> n);
3208                                 if (y != 1 || x == 0) {
3209                                         x = 0;
3210                                         break;
3211                                 }
3212                         }
3213                         /*
3214                          * If x is nonzero, an int is big enough for the bits
3215                          * that we want.
3216                          */
3217                         result = (x != 0) ? "int" : "long";
3218                 }
3219                 fputs(result, fp);
3220                 fclose(fp);
3221         }
3222         exit(0);
3223 }
3224                 ],
3225                 [cf_cv_typeof_chtype=`cat cf_test.out`],
3226                 [cf_cv_typeof_chtype=long],
3227                 [cf_cv_typeof_chtype=long])
3228                 rm -f cf_test.out
3229         ])
3230 AC_MSG_RESULT($cf_cv_typeof_chtype)
3231
3232 AC_SUBST(cf_cv_typeof_chtype)
3233 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
3234
3235 cf_cv_1UL="1"
3236 test "$cf_cv_unsigned_literals" = yes && cf_cv_1UL="${cf_cv_1UL}U"
3237 test "$cf_cv_typeof_chtype"    = long && cf_cv_1UL="${cf_cv_1UL}L"
3238 AC_SUBST(cf_cv_1UL)
3239
3240 ])dnl
3241 dnl ---------------------------------------------------------------------------
3242 dnl CF_TYPE_SIGACTION version: 3 updated: 2000/08/12 23:18:52
3243 dnl -----------------
3244 dnl
3245 AC_DEFUN([CF_TYPE_SIGACTION],
3246 [
3247 AC_MSG_CHECKING([for type sigaction_t])
3248 AC_CACHE_VAL(cf_cv_type_sigaction,[
3249         AC_TRY_COMPILE([
3250 #include <signal.h>],
3251                 [sigaction_t x],
3252                 [cf_cv_type_sigaction=yes],
3253                 [cf_cv_type_sigaction=no])])
3254 AC_MSG_RESULT($cf_cv_type_sigaction)
3255 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
3256 ])dnl
3257 dnl ---------------------------------------------------------------------------
3258 dnl CF_UNSIGNED_LITERALS version: 2 updated: 1998/02/07 22:10:16
3259 dnl --------------------
3260 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
3261 dnl won't, but they're still there.
3262 AC_DEFUN([CF_UNSIGNED_LITERALS],
3263 [
3264 AC_MSG_CHECKING([if unsigned literals are legal])
3265 AC_CACHE_VAL(cf_cv_unsigned_literals,[
3266         AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
3267                 [cf_cv_unsigned_literals=yes],
3268                 [cf_cv_unsigned_literals=no])
3269         ])
3270 AC_MSG_RESULT($cf_cv_unsigned_literals)
3271 ])dnl
3272 dnl ---------------------------------------------------------------------------
3273 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3274 dnl --------
3275 dnl Make an uppercase version of a variable
3276 dnl $1=uppercase($2)
3277 AC_DEFUN([CF_UPPER],
3278 [
3279 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3280 ])dnl
3281 dnl ---------------------------------------------------------------------------
3282 dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
3283 dnl ----------
3284 dnl Use AC_VERBOSE w/o the warnings
3285 AC_DEFUN([CF_VERBOSE],
3286 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
3287 ])dnl
3288 dnl ---------------------------------------------------------------------------
3289 dnl CF_WCHAR_TYPE version: 2 updated: 2004/01/17 19:18:20
3290 dnl -------------
3291 dnl Check if type wide-character type $1 is declared, and if so, which header
3292 dnl file is needed.  The second parameter is used to set a shell variable when
3293 dnl the type is not found.  The first parameter sets a shell variable for the
3294 dnl opposite sense.
3295 AC_DEFUN([CF_WCHAR_TYPE],
3296 [
3297 # This is needed on Tru64 5.0 to declare $1
3298 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
3299 AC_TRY_COMPILE([
3300 #include <stdlib.h>
3301 #include <stdarg.h>
3302 #include <stdio.h>
3303 #ifdef HAVE_LIBUTF8_H
3304 #include <libutf8.h>
3305 #endif],
3306         [$1 state],
3307         [cf_cv_$1=no],
3308         [AC_TRY_COMPILE([
3309 #include <stdlib.h>
3310 #include <stdarg.h>
3311 #include <stdio.h>
3312 #include <wchar.h>
3313 #ifdef HAVE_LIBUTF8_H
3314 #include <libutf8.h>
3315 #endif],
3316         [$1 value],
3317         [cf_cv_$1=yes],
3318         [cf_cv_$1=unknown])])])
3319
3320 if test "$cf_cv_$1" = yes ; then
3321         AC_DEFINE(NEED_WCHAR_H)
3322         NEED_WCHAR_H=1
3323 fi
3324
3325 ifelse($2,,,[
3326 # if we do not find $1 in either place, use substitution to provide a fallback.
3327 if test "$cf_cv_$1" = unknown ; then
3328         $2=1
3329 fi
3330 ])
3331 ifelse($3,,,[
3332 # if we find $1 in either place, use substitution to provide a fallback.
3333 if test "$cf_cv_$1" != unknown ; then
3334         $3=1
3335 fi
3336 ])
3337 ])dnl
3338 dnl ---------------------------------------------------------------------------
3339 dnl CF_WITH_ABI_VERSION version: 1 updated: 2003/09/20 18:12:49
3340 dnl -------------------
3341 dnl Allow library's ABI to be overridden.  Generally this happens when a
3342 dnl packager has incremented the ABI past that used in the original package,
3343 dnl and wishes to keep doing this.
3344 dnl
3345 dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
3346 dnl symbol.
3347 AC_DEFUN([CF_WITH_ABI_VERSION],[
3348 test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
3349 AC_ARG_WITH(abi-version,
3350 [  --with-abi-version=XXX  override derived ABI version],
3351 [AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
3352  cf_cv_abi_version=$withval])
3353  CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
3354 ifelse($1,,,[
3355 $1_ABI=$cf_cv_abi_version
3356 ])
3357 ])dnl
3358 dnl ---------------------------------------------------------------------------
3359 dnl CF_WITH_DBMALLOC version: 2 updated: 2002/12/29 21:11:45
3360 dnl ----------------
3361 dnl Configure-option for dbmalloc
3362 AC_DEFUN([CF_WITH_DBMALLOC],[
3363 AC_MSG_CHECKING(if you want to link with dbmalloc for testing)
3364 AC_ARG_WITH(dbmalloc,
3365         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
3366         [with_dbmalloc=$withval],
3367         [with_dbmalloc=no])
3368 AC_MSG_RESULT($with_dbmalloc)
3369 if test $with_dbmalloc = yes ; then
3370         AC_CHECK_LIB(dbmalloc,debug_malloc)
3371 fi
3372 ])dnl
3373 dnl ---------------------------------------------------------------------------
3374 dnl CF_WITH_DMALLOC version: 2 updated: 2002/12/29 21:11:45
3375 dnl ---------------
3376 dnl Configure-option for dmalloc
3377 AC_DEFUN([CF_WITH_DMALLOC],[
3378 AC_MSG_CHECKING(if you want to link with dmalloc for testing)
3379 AC_ARG_WITH(dmalloc,
3380         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
3381         [with_dmalloc=$withval],
3382         [with_dmalloc=no])
3383 AC_MSG_RESULT($with_dmalloc)
3384 if test $with_dmalloc = yes ; then
3385         AC_CHECK_LIB(dmalloc,dmalloc_debug)
3386 fi
3387 ])dnl
3388 dnl ---------------------------------------------------------------------------
3389 dnl CF_WITH_LIBTOOL version: 9 updated: 2004/01/16 14:55:37
3390 dnl ---------------
3391 dnl Provide a configure option to incorporate libtool.  Define several useful
3392 dnl symbols for the makefile rules.
3393 dnl
3394 dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
3395 dnl macros from libtool.m4 which is in the aclocal directory of automake.
3396 dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
3397 dnl But that still does not work properly since the macro is expanded outside
3398 dnl the CF_WITH_LIBTOOL macro:
3399 dnl
3400 dnl     #!/bin/sh
3401 dnl     ACLOCAL=`aclocal --print-ac-dir`
3402 dnl     if test -z "$ACLOCAL" ; then
3403 dnl             echo cannot find aclocal directory
3404 dnl             exit 1
3405 dnl     elif test ! -f $ACLOCAL/libtool.m4 ; then
3406 dnl             echo cannot find libtool.m4 file
3407 dnl             exit 1
3408 dnl     fi
3409 dnl     
3410 dnl     LOCAL=aclocal.m4
3411 dnl     ORIG=aclocal.m4.orig
3412 dnl     
3413 dnl     trap "mv $ORIG $LOCAL" 0 1 2 5 15
3414 dnl     rm -f $ORIG
3415 dnl     mv $LOCAL $ORIG
3416 dnl     
3417 dnl     # sed the LIBTOOL= assignment to omit the current directory?
3418 dnl     sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
3419 dnl     cat $ORIG >>$LOCAL
3420 dnl     
3421 dnl     autoconf-257 $*
3422 dnl
3423 AC_DEFUN([CF_WITH_LIBTOOL],
3424 [
3425 ifdef([AC_PROG_LIBTOOL],,[
3426 LIBTOOL=
3427 ])
3428 # common library maintenance symbols that are convenient for libtool scripts:
3429 LIB_CREATE='$(AR) -cr'
3430 LIB_OBJECT='$(OBJECTS)'
3431 LIB_SUFFIX=.a
3432 LIB_PREP="$RANLIB"
3433
3434 # symbols used to prop libtool up to enable it to determine what it should be
3435 # doing:
3436 LIB_CLEAN=
3437 LIB_COMPILE=
3438 LIB_LINK=
3439 LIB_INSTALL=
3440 LIB_UNINSTALL=
3441
3442 AC_MSG_CHECKING(if you want to build libraries with libtool)
3443 AC_ARG_WITH(libtool,
3444         [  --with-libtool          generate libraries with libtool],
3445         [with_libtool=$withval],
3446         [with_libtool=no])
3447 AC_MSG_RESULT($with_libtool)
3448 if test "$with_libtool" != "no"; then
3449 ifdef([AC_PROG_LIBTOOL],[
3450         # missing_content_AC_PROG_LIBTOOL{{
3451         AC_PROG_LIBTOOL
3452         # missing_content_AC_PROG_LIBTOOL}}
3453 ],[
3454         if test "$with_libtool" != "yes" ; then
3455                 CF_PATH_SYNTAX(with_libtool)
3456                 LIBTOOL=$with_libtool
3457         else
3458                 AC_PATH_PROG(LIBTOOL,libtool)
3459         fi
3460         if test -z "$LIBTOOL" ; then
3461                 AC_MSG_ERROR(Cannot find libtool)
3462         fi
3463 ])dnl
3464         LIB_CREATE='$(LIBTOOL) --mode=link $(CC) -rpath $(DESTDIR)$(libdir) -version-info `cut -f1 $(srcdir)/VERSION` -o'
3465         LIB_OBJECT='$(OBJECTS:.o=.lo)'
3466         LIB_SUFFIX=.la
3467         LIB_CLEAN='$(LIBTOOL) --mode=clean'
3468         LIB_COMPILE='$(LIBTOOL) --mode=compile'
3469         LIB_LINK='$(LIBTOOL) --mode=link'
3470         LIB_INSTALL='$(LIBTOOL) --mode=install'
3471         LIB_UNINSTALL='$(LIBTOOL) --mode=uninstall'
3472         LIB_PREP=:
3473
3474         # Show the version of libtool
3475         AC_MSG_CHECKING(version of libtool)
3476
3477         # Save the version in a cache variable - this is not entirely a good
3478         # thing, but the version string from libtool is very ugly, and for
3479         # bug reports it might be useful to have the original string.
3480         cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
3481         AC_MSG_RESULT($cf_cv_libtool_version)
3482         if test -z "$cf_cv_libtool_version" ; then
3483                 AC_MSG_ERROR(This is not libtool)
3484         fi
3485
3486         # special hack to add --tag option for C++ compiler
3487         case $cf_cv_libtool_version in
3488         1.[[5-9]]*|[[2-9]]*)
3489                 LIBTOOL_CXX="$LIBTOOL --tag=CXX"
3490                 ;;
3491         *)
3492                 LIBTOOL_CXX="$LIBTOOL"
3493                 ;;
3494         esac
3495 else
3496         LIBTOOL=""
3497         LIBTOOL_CXX=""
3498 fi
3499
3500 test -z "$LIBTOOL" && ECHO_LT=
3501
3502 AC_SUBST(LIBTOOL)
3503 AC_SUBST(LIBTOOL_CXX)
3504
3505 AC_SUBST(LIB_CREATE)
3506 AC_SUBST(LIB_OBJECT)
3507 AC_SUBST(LIB_SUFFIX)
3508 AC_SUBST(LIB_PREP)
3509
3510 AC_SUBST(LIB_CLEAN)
3511 AC_SUBST(LIB_COMPILE)
3512 AC_SUBST(LIB_LINK)
3513 AC_SUBST(LIB_INSTALL)
3514 AC_SUBST(LIB_UNINSTALL)
3515
3516 ])dnl
3517 dnl ---------------------------------------------------------------------------
3518 dnl CF_WITH_PATH version: 6 updated: 1998/10/11 00:40:17
3519 dnl ------------
3520 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
3521 dnl defaulting to yes/no.
3522 dnl
3523 dnl $1 = option name
3524 dnl $2 = help-text
3525 dnl $3 = environment variable to set
3526 dnl $4 = default value, shown in the help-message, must be a constant
3527 dnl $5 = default value, if it's an expression & cannot be in the help-message
3528 dnl
3529 AC_DEFUN([CF_WITH_PATH],
3530 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
3531 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
3532 CF_PATH_SYNTAX(withval)
3533 eval $3="$withval"
3534 AC_SUBST($3)dnl
3535 ])dnl
3536 dnl ---------------------------------------------------------------------------
3537 dnl CF_WITH_PATHLIST version: 5 updated: 2001/12/10 01:28:30
3538 dnl ----------------
3539 dnl Process an option specifying a list of colon-separated paths.
3540 dnl
3541 dnl $1 = option name
3542 dnl $2 = help-text
3543 dnl $3 = environment variable to set
3544 dnl $4 = default value, shown in the help-message, must be a constant
3545 dnl $5 = default value, if it's an expression & cannot be in the help-message
3546 dnl $6 = flag to tell if we want to define or substitute
3547 dnl
3548 AC_DEFUN([CF_WITH_PATHLIST],[
3549 AC_REQUIRE([CF_PATHSEP])
3550 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
3551 ifelse($4,,[withval=${$3}],[withval=${$3-ifelse($5,,$4,$5)}]))dnl
3552
3553 IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${PATHSEP}"
3554 cf_dst_path=
3555 for cf_src_path in $withval
3556 do
3557   CF_PATH_SYNTAX(cf_src_path)
3558   test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
3559   cf_dst_path="${cf_dst_path}${cf_src_path}"
3560 done
3561 IFS="$ac_save_ifs"
3562
3563 ifelse($6,define,[
3564 # Strip single quotes from the value, e.g., when it was supplied as a literal
3565 # for $4 or $5.
3566 case $cf_dst_path in #(vi
3567 \'*)
3568   cf_dst_path=`echo $cf_dst_path |sed -e s/\'// -e s/\'\$//`
3569   ;;
3570 esac
3571 cf_dst_path=`echo "$cf_dst_path" | sed -e 's/\\\\/\\\\\\\\/g'`
3572 ])
3573
3574 eval '$3="$cf_dst_path"'
3575 AC_SUBST($3)dnl
3576
3577 ])dnl
3578 dnl ---------------------------------------------------------------------------
3579 dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
3580 dnl -------------------
3581 dnl Allow library's release-version to be overridden.  Generally this happens when a
3582 dnl packager has incremented the release-version past that used in the original package,
3583 dnl and wishes to keep doing this.
3584 dnl
3585 dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
3586 dnl and {package}_MINOR symbols
3587 dnl symbol.
3588 AC_DEFUN([CF_WITH_REL_VERSION],[
3589 test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
3590 AC_ARG_WITH(rel-version,
3591 [  --with-rel-version=XXX  override derived release version],
3592 [AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
3593  cf_cv_rel_version=$withval])
3594 ifelse($1,,[
3595  CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
3596 ],[
3597  $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
3598  $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
3599  CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
3600  CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
3601 ])
3602 ])dnl
3603 dnl ---------------------------------------------------------------------------
3604 dnl CF_WITH_SYSMOUSE version: 2 updated: 2003/03/22 19:13:43
3605 dnl ----------------
3606 dnl If we can compile with sysmouse, make it available unless it is not wanted.
3607 AC_DEFUN([CF_WITH_SYSMOUSE],[
3608 # not everyone has "test -c"
3609 if test -c /dev/sysmouse 2>/dev/null ; then
3610 AC_MSG_CHECKING(if you want to use sysmouse)
3611 AC_ARG_WITH(sysmouse,
3612         [  --with-sysmouse         use sysmouse (FreeBSD console)],
3613         [cf_with_sysmouse=$withval],
3614         [cf_with_sysmouse=maybe])
3615         if test "$cf_with_sysmouse" != no ; then
3616         AC_TRY_COMPILE([
3617 #include <osreldate.h>
3618 #if (__FreeBSD_version >= 400017)
3619 #include <sys/consio.h>
3620 #include <sys/fbio.h>
3621 #else
3622 #include <machine/console.h>
3623 #endif
3624 ],[
3625         struct mouse_info the_mouse;
3626         ioctl(0, CONS_MOUSECTL, &the_mouse);
3627 ],[cf_with_sysmouse=yes],[cf_with_sysmouse=no])
3628         fi
3629 AC_MSG_RESULT($cf_with_sysmouse)
3630 test "$cf_with_sysmouse" = yes && AC_DEFINE(USE_SYSMOUSE)
3631 fi
3632 ])dnl
3633 dnl ---------------------------------------------------------------------------
3634 dnl CF_XOPEN_SOURCE version: 11 updated: 2004/01/26 20:58:41
3635 dnl ---------------
3636 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3637 dnl or adapt to the vendor's definitions to get equivalent functionality.
3638 AC_DEFUN([CF_XOPEN_SOURCE],[
3639 case $host_os in #(vi
3640 freebsd*) #(vi
3641         CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600"
3642         ;;
3643 hpux*) #(vi
3644         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
3645         ;;
3646 irix6.*) #(vi
3647         CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
3648         ;;
3649 linux*) #(vi
3650         CF_GNU_SOURCE
3651         ;;
3652 mirbsd*) #(vi
3653         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
3654         ;;
3655 netbsd*) #(vi
3656         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3657         ;;
3658 openbsd*) #(vi
3659         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3660         ;;
3661 osf[[45]]*) #(vi
3662         CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
3663         ;;
3664 sco*) #(vi
3665         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3666         ;;
3667 solaris*) #(vi
3668         CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
3669         ;;
3670 *)
3671         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3672         AC_TRY_COMPILE([#include <sys/types.h>],[
3673 #ifndef _XOPEN_SOURCE
3674 make an error
3675 #endif],
3676         [cf_cv_xopen_source=no],
3677         [cf_save="$CPPFLAGS"
3678          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
3679          AC_TRY_COMPILE([#include <sys/types.h>],[
3680 #ifdef _XOPEN_SOURCE
3681 make an error
3682 #endif],
3683         [cf_cv_xopen_source=no],
3684         [cf_cv_xopen_source=yes])
3685         CPPFLAGS="$cf_save"
3686         ])
3687 ])
3688 test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500"
3689
3690         # FreeBSD 5.x headers demand this...
3691         AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_xopen_source,[
3692         AC_TRY_COMPILE([#include <sys/types.h>],[
3693 #ifndef _POSIX_C_SOURCE
3694 make an error
3695 #endif],
3696         [cf_cv_xopen_source=no],
3697         [cf_save="$CPPFLAGS"
3698          CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
3699          AC_TRY_COMPILE([#include <sys/types.h>],[
3700 #ifdef _POSIX_C_SOURCE
3701 make an error
3702 #endif],
3703         [cf_cv_xopen_source=no],
3704         [cf_cv_xopen_source=yes])
3705         CPPFLAGS="$cf_save"
3706         ])
3707 ])
3708 test "$cf_cv_xopen_source" = yes && CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE"
3709         ;;
3710 esac
3711 ])