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