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