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