]> ncurses.scripts.mit.edu Git - ncurses.git/blob - aclocal.m4
cbb29c50825221729093c0475c13ed766994ab72
[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.429 2007/04/19 20:04:46 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_DIRNAME version: 4 updated: 2002/12/21 19:25:52
707 dnl ----------
708 dnl "dirname" is not portable, so we fake it with a shell script.
709 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
710 dnl ---------------------------------------------------------------------------
711 dnl CF_DIRS_TO_MAKE version: 3 updated: 2002/02/23 20:38:31
712 dnl ---------------
713 AC_DEFUN([CF_DIRS_TO_MAKE],
714 [
715 DIRS_TO_MAKE="lib"
716 for cf_item in $cf_list_models
717 do
718         CF_OBJ_SUBDIR($cf_item,cf_subdir)
719         for cf_item2 in $DIRS_TO_MAKE
720         do
721                 test $cf_item2 = $cf_subdir && break
722         done
723         test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
724 done
725 for cf_dir in $DIRS_TO_MAKE
726 do
727         test ! -d $cf_dir && mkdir $cf_dir
728 done
729 AC_SUBST(DIRS_TO_MAKE)
730 ])dnl
731 dnl ---------------------------------------------------------------------------
732 dnl CF_DISABLE_LEAKS version: 4 updated: 2006/12/16 15:10:42
733 dnl ----------------
734 dnl Combine no-leak checks with the libraries or tools that are used for the
735 dnl checks.
736 AC_DEFUN([CF_DISABLE_LEAKS],[
737
738 AC_REQUIRE([CF_WITH_DMALLOC])
739 AC_REQUIRE([CF_WITH_DBMALLOC])
740 AC_REQUIRE([CF_WITH_VALGRIND])
741
742 AC_MSG_CHECKING(if you want to perform memory-leak testing)
743 AC_ARG_ENABLE(leaks,
744         [  --disable-leaks         test: free permanent memory, analyze leaks],
745         [with_no_leaks=yes],
746         : ${with_no_leaks:=no})
747 AC_MSG_RESULT($with_no_leaks)
748
749 if test "$with_no_leaks" = yes ; then
750         AC_DEFINE(NO_LEAKS)
751 fi
752 ])dnl
753 dnl ---------------------------------------------------------------------------
754 dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
755 dnl --------
756 dnl Check if 'errno' is declared in <errno.h>
757 AC_DEFUN([CF_ERRNO],
758 [
759 CF_CHECK_ERRNO(errno)
760 ])dnl
761 dnl ---------------------------------------------------------------------------
762 dnl CF_ETIP_DEFINES version: 3 updated: 2003/03/22 19:13:43
763 dnl ---------------
764 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
765 dnl math.h and builtin.h, only for ncurses
766 AC_DEFUN([CF_ETIP_DEFINES],
767 [
768 AC_MSG_CHECKING(for special defines needed for etip.h)
769 cf_save_CXXFLAGS="$CXXFLAGS"
770 cf_result="none"
771 for cf_math in "" MATH_H
772 do
773 for cf_excp in "" MATH_EXCEPTION
774 do
775         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -I${srcdir}/include"
776         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
777         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
778 AC_TRY_COMPILE([
779 #include <etip.h.in>
780 ],[],[
781         test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
782         test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
783         cf_result="$cf_math $cf_excp"
784         break
785 ],[])
786 done
787 done
788 AC_MSG_RESULT($cf_result)
789 CXXFLAGS="$cf_save_CXXFLAGS"
790 ])
791 dnl ---------------------------------------------------------------------------
792 dnl CF_FUNC_DLSYM version: 1 updated: 2004/06/16 20:52:45
793 dnl -------------
794 dnl Test for dlsym() and related functions, as well as libdl.
795 dnl
796 dnl Sets
797 dnl     $cf_have_dlsym
798 dnl     $cf_have_libdl
799 AC_DEFUN([CF_FUNC_DLSYM],[
800 cf_have_dlsym=no
801 AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
802
803 cf_have_libdl=no
804 AC_CHECK_LIB(dl,dlsym,[
805         cf_have_dlsym=yes
806         cf_have_libdl=yes])])
807
808 if test "$cf_have_dlsym" = yes ; then
809         test "$cf_have_libdl" = yes && LIBS="-ldl $LIBS"
810
811         AC_MSG_CHECKING(whether able to link to dl*() functions)
812         AC_TRY_LINK([#include <dlfcn.h>],[
813                 void *obj;
814                 if ((obj = dlopen("filename", 0)) != 0) {
815                         if (dlsym(obj, "symbolname") == 0) {
816                         dlclose(obj);
817                         }
818                 }],[
819                 AC_DEFINE(HAVE_LIBDL)],[
820                 AC_MSG_ERROR(Cannot link test program for libdl)])
821         AC_MSG_RESULT(ok)
822 else
823         AC_MSG_ERROR(Cannot find dlsym function)
824 fi
825 ])
826 dnl ---------------------------------------------------------------------------
827 dnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
828 dnl ---------------
829 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
830 dnl is found, add our own version of memmove to the list of objects.
831 AC_DEFUN([CF_FUNC_MEMMOVE],
832 [
833 AC_CHECK_FUNC(memmove,,[
834 AC_CHECK_FUNC(bcopy,[
835         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
836                 AC_TRY_RUN([
837 int main() {
838         static char data[] = "abcdefghijklmnopqrstuwwxyz";
839         char temp[40];
840         bcopy(data, temp, sizeof(data));
841         bcopy(temp+10, temp, 15);
842         bcopy(temp+5, temp+15, 10);
843         ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
844 }
845                 ],
846                 [cf_cv_good_bcopy=yes],
847                 [cf_cv_good_bcopy=no],
848                 [cf_cv_good_bcopy=unknown])
849                 ])
850         ],[cf_cv_good_bcopy=no])
851         if test "$cf_cv_good_bcopy" = yes ; then
852                 AC_DEFINE(USE_OK_BCOPY)
853         else
854                 AC_DEFINE(USE_MY_MEMMOVE)
855         fi
856 ])])dnl
857 dnl ---------------------------------------------------------------------------
858 dnl CF_FUNC_NANOSLEEP version: 3 updated: 2006/12/16 12:33:30
859 dnl -----------------
860 dnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
861 dnl AIX 4.x, provide a non-working version.
862 AC_DEFUN([CF_FUNC_NANOSLEEP],[
863 AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
864 AC_TRY_RUN([
865 #include <stdio.h>
866 #include <errno.h>
867 #include <time.h>
868
869 #ifdef HAVE_SYS_TIME_H
870 #include <sys/time.h>
871 #endif
872
873 int main() {
874         struct timespec ts1, ts2;
875         int code;
876         ts1.tv_sec  = 0;
877         ts1.tv_nsec = 750000000;
878         ts2.tv_sec  = 0;
879         ts2.tv_nsec = 0;
880         errno = 0;
881         code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */
882         ${cf_cv_main_return:-return}(code != 0);
883 }
884 ],
885         [cf_cv_func_nanosleep=yes],
886         [cf_cv_func_nanosleep=no],
887         [cf_cv_func_nanosleep=unknown])])
888
889 test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP)
890 ])
891 dnl ---------------------------------------------------------------------------
892 dnl CF_FUNC_POLL version: 4 updated: 2006/12/16 12:33:30
893 dnl ------------
894 dnl See if the poll function really works.  Some platforms have poll(), but
895 dnl it does not work for terminals or files.
896 AC_DEFUN([CF_FUNC_POLL],[
897 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
898 AC_TRY_RUN([
899 #include <stdio.h>
900 #ifdef HAVE_POLL_H
901 #include <poll.h>
902 #else
903 #include <sys/poll.h>
904 #endif
905 int main() {
906         struct pollfd myfds;
907         int ret;
908
909         myfds.fd = 0;
910         myfds.events = POLLIN;
911
912         ret = poll(&myfds, 1, 100);
913         ${cf_cv_main_return:-return}(ret != 0);
914 }],
915         [cf_cv_working_poll=yes],
916         [cf_cv_working_poll=no],
917         [cf_cv_working_poll=unknown])])
918 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL)
919 ])dnl
920 dnl ---------------------------------------------------------------------------
921 dnl CF_FUNC_TERMIOS version: 2 updated: 2000/07/22 23:37:24
922 dnl ---------------
923 dnl Some old/broken variations define tcgetattr() only as a macro in
924 dnl termio(s).h
925 AC_DEFUN([CF_FUNC_TERMIOS],[
926 AC_REQUIRE([CF_STRUCT_TERMIOS])
927 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
928 AC_TRY_LINK([
929 #include <sys/types.h>
930 #ifdef HAVE_UNISTD_H
931 #include <unistd.h>
932 #endif
933 #ifdef HAVE_TERMIOS_H
934 #include <termios.h>
935 #define TTY struct termios
936 #else
937 #ifdef HAVE_TERMIO_H
938 #include <termio.h>
939 #define TTY struct termio
940 #endif
941 #endif
942 ],[
943 TTY foo;
944 tcgetattr(1, &foo);],
945 [cf_cv_have_tcgetattr=yes],
946 [cf_cv_have_tcgetattr=no])])
947 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR)
948 ])dnl
949 dnl ---------------------------------------------------------------------------
950 dnl CF_FUNC_VSSCANF version: 3 updated: 2001/12/19 00:50:10
951 dnl ---------------
952 dnl Check for vsscanf() function, which is in c9x but generally not in earlier
953 dnl versions of C.  It is in the GNU C library, and can often be simulated by
954 dnl other functions.
955 AC_DEFUN([CF_FUNC_VSSCANF],
956 [
957 AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
958 AC_TRY_LINK([
959 #include <stdarg.h>
960 #include <stdio.h>],[
961         va_list ap;
962         vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
963 AC_TRY_LINK([
964 #include <stdarg.h>
965 #include <stdio.h>],[
966     FILE strbuf;
967     char *str = "from";
968
969     strbuf._flag = _IOREAD;
970     strbuf._ptr = strbuf._base = (unsigned char *) str;
971     strbuf._cnt = strlen(str);
972     strbuf._file = _NFILE;
973     return (vfscanf(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=vfscanf],[
974 AC_TRY_LINK([
975 #include <stdarg.h>
976 #include <stdio.h>],[
977     FILE strbuf;
978     char *str = "from";
979
980     strbuf._flag = _IOREAD;
981     strbuf._ptr = strbuf._base = (unsigned char *) str;
982     strbuf._cnt = strlen(str);
983     strbuf._file = _NFILE;
984     return (_doscan(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=_doscan],[
985 cf_cv_func_vsscanf=no])])])])
986
987 case $cf_cv_func_vsscanf in #(vi
988 vsscanf) AC_DEFINE(HAVE_VSSCANF);; #(vi
989 vfscanf) AC_DEFINE(HAVE_VFSCANF);; #(vi
990 _doscan) AC_DEFINE(HAVE__DOSCAN);;
991 esac
992
993 ])dnl
994 dnl ---------------------------------------------------------------------------
995 dnl CF_GCC_ATTRIBUTES version: 10 updated: 2005/05/28 13:16:28
996 dnl -----------------
997 dnl Test for availability of useful gcc __attribute__ directives to quiet
998 dnl compiler warnings.  Though useful, not all are supported -- and contrary
999 dnl to documentation, unrecognized directives cause older compilers to barf.
1000 AC_DEFUN([CF_GCC_ATTRIBUTES],
1001 [
1002 if test "$GCC" = yes
1003 then
1004 cat > conftest.i <<EOF
1005 #ifndef GCC_PRINTF
1006 #define GCC_PRINTF 0
1007 #endif
1008 #ifndef GCC_SCANF
1009 #define GCC_SCANF 0
1010 #endif
1011 #ifndef GCC_NORETURN
1012 #define GCC_NORETURN /* nothing */
1013 #endif
1014 #ifndef GCC_UNUSED
1015 #define GCC_UNUSED /* nothing */
1016 #endif
1017 EOF
1018 if test "$GCC" = yes
1019 then
1020         AC_CHECKING([for $CC __attribute__ directives])
1021 cat > conftest.$ac_ext <<EOF
1022 #line __oline__ "configure"
1023 #include "confdefs.h"
1024 #include "conftest.h"
1025 #include "conftest.i"
1026 #if     GCC_PRINTF
1027 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1028 #else
1029 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1030 #endif
1031 #if     GCC_SCANF
1032 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1033 #else
1034 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1035 #endif
1036 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1037 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1038 extern void foo(void) GCC_NORETURN;
1039 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1040 EOF
1041         for cf_attribute in scanf printf unused noreturn
1042         do
1043                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1044                 cf_directive="__attribute__(($cf_attribute))"
1045                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1046                 case $cf_attribute in
1047                 scanf|printf)
1048                 cat >conftest.h <<EOF
1049 #define GCC_$cf_ATTRIBUTE 1
1050 EOF
1051                         ;;
1052                 *)
1053                 cat >conftest.h <<EOF
1054 #define GCC_$cf_ATTRIBUTE $cf_directive
1055 EOF
1056                         ;;
1057                 esac
1058                 if AC_TRY_EVAL(ac_compile); then
1059                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1060                         cat conftest.h >>confdefs.h
1061                 fi
1062         done
1063 else
1064         fgrep define conftest.i >>confdefs.h
1065 fi
1066 rm -rf conftest*
1067 fi
1068 ])dnl
1069 dnl ---------------------------------------------------------------------------
1070 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
1071 dnl --------------
1072 dnl Find version of gcc
1073 AC_DEFUN([CF_GCC_VERSION],[
1074 AC_REQUIRE([AC_PROG_CC])
1075 GCC_VERSION=none
1076 if test "$GCC" = yes ; then
1077         AC_MSG_CHECKING(version of $CC)
1078         GCC_VERSION="`${CC} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1079         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1080         AC_MSG_RESULT($GCC_VERSION)
1081 fi
1082 ])dnl
1083 dnl ---------------------------------------------------------------------------
1084 dnl CF_GCC_WARNINGS version: 20 updated: 2005/08/06 18:37:29
1085 dnl ---------------
1086 dnl Check if the compiler supports useful warning options.  There's a few that
1087 dnl we don't use, simply because they're too noisy:
1088 dnl
1089 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1090 dnl     -Wredundant-decls (system headers make this too noisy)
1091 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1092 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1093 dnl             is enabled for ncurses using "--enable-const".
1094 dnl     -pedantic
1095 dnl
1096 dnl Parameter:
1097 dnl     $1 is an optional list of gcc warning flags that a particular
1098 dnl             application might want to use, e.g., "no-unused" for
1099 dnl             -Wno-unused
1100 dnl Special:
1101 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1102 dnl
1103 AC_DEFUN([CF_GCC_WARNINGS],
1104 [
1105 AC_REQUIRE([CF_GCC_VERSION])
1106 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1107
1108 cat > conftest.$ac_ext <<EOF
1109 #line __oline__ "configure"
1110 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1111 EOF
1112
1113 if test "$INTEL_COMPILER" = yes
1114 then
1115 # The "-wdXXX" options suppress warnings:
1116 # remark #1419: external declaration in primary source file
1117 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1118 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1119 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1120 # remark #193: zero used for undefined preprocessing identifier
1121 # remark #593: variable "curs_sb_left_arrow" was set but never used
1122 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1123 # remark #869: parameter "tw" was never referenced
1124 # remark #981: operands are evaluated in unspecified order
1125 # warning #269: invalid format string conversion
1126
1127         AC_CHECKING([for $CC warning options])
1128         cf_save_CFLAGS="$CFLAGS"
1129         EXTRA_CFLAGS="-Wall"
1130         for cf_opt in $1 \
1131                 wd1419 \
1132                 wd1682 \
1133                 wd1683 \
1134                 wd1684 \
1135                 wd193 \
1136                 wd279 \
1137                 wd593 \
1138                 wd810 \
1139                 wd869 \
1140                 wd981
1141         do
1142                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1143                 if AC_TRY_EVAL(ac_compile); then
1144                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1145                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1146                 fi
1147         done
1148         CFLAGS="$cf_save_CFLAGS"
1149
1150 elif test "$GCC" = yes
1151 then
1152         AC_CHECKING([for $CC warning options])
1153         cf_save_CFLAGS="$CFLAGS"
1154         EXTRA_CFLAGS="-W -Wall"
1155         cf_warn_CONST=""
1156         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1157         for cf_opt in \
1158                 Wbad-function-cast \
1159                 Wcast-align \
1160                 Wcast-qual \
1161                 Winline \
1162                 Wmissing-declarations \
1163                 Wmissing-prototypes \
1164                 Wnested-externs \
1165                 Wpointer-arith \
1166                 Wshadow \
1167                 Wstrict-prototypes \
1168                 Wundef $cf_warn_CONST $1
1169         do
1170                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1171                 if AC_TRY_EVAL(ac_compile); then
1172                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1173                         case $cf_opt in #(vi
1174                         Wcast-qual) #(vi
1175                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1176                                 ;;
1177                         Winline) #(vi
1178                                 case $GCC_VERSION in
1179                                 3.3*)
1180                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1181                                         continue;;
1182                                 esac
1183                                 ;;
1184                         esac
1185                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1186                 fi
1187         done
1188         CFLAGS="$cf_save_CFLAGS"
1189 fi
1190 rm -f conftest*
1191
1192 AC_SUBST(EXTRA_CFLAGS)
1193 ])dnl
1194 dnl ---------------------------------------------------------------------------
1195 dnl CF_GNAT_TRY_LINK version: 1 updated: 2004/08/21 19:02:08
1196 dnl ----------------
1197 dnl Verify that a test program compiles/links with GNAT.
1198 dnl $cf_ada_make is set to the program that compiles/links
1199 dnl $ADAFLAGS may be set to the GNAT flags.
1200 dnl
1201 dnl $1 is the text of the spec
1202 dnl $2 is the text of the body
1203 dnl $3 is the shell command to execute if successful
1204 dnl $4 is the shell command to execute if not successful
1205 AC_DEFUN([CF_GNAT_TRY_LINK],
1206 [
1207 rm -f conftest*
1208 cat >>conftest.ads <<CF_EOF
1209 $1
1210 CF_EOF
1211 cat >>conftest.adb <<CF_EOF
1212 $2
1213 CF_EOF
1214 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1215 ifelse($3,,      :,[      $3])
1216 ifelse($4,,,[else
1217    $4])
1218 fi
1219 rm -f conftest*
1220 ])dnl
1221 dnl ---------------------------------------------------------------------------
1222 dnl CF_GNAT_TRY_RUN version: 3 updated: 2004/08/21 19:02:08
1223 dnl ---------------
1224 dnl Verify that a test program compiles and runs with GNAT
1225 dnl $cf_ada_make is set to the program that compiles/links
1226 dnl $ADAFLAGS may be set to the GNAT flags.
1227 dnl
1228 dnl $1 is the text of the spec
1229 dnl $2 is the text of the body
1230 dnl $3 is the shell command to execute if successful
1231 dnl $4 is the shell command to execute if not successful
1232 AC_DEFUN([CF_GNAT_TRY_RUN],
1233 [
1234 rm -f conftest*
1235 cat >>conftest.ads <<CF_EOF
1236 $1
1237 CF_EOF
1238 cat >>conftest.adb <<CF_EOF
1239 $2
1240 CF_EOF
1241 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1242    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
1243 ifelse($3,,      :,[      $3])
1244 ifelse($4,,,[   else
1245       $4])
1246    fi
1247 ifelse($4,,,[else
1248    $4])
1249 fi
1250 rm -f conftest*
1251 ])dnl
1252 dnl ---------------------------------------------------------------------------
1253 dnl CF_GNAT_VERSION version: 12 updated: 2006/10/14 15:23:15
1254 dnl ---------------
1255 dnl Verify version of GNAT.
1256 AC_DEFUN([CF_GNAT_VERSION],
1257 [
1258 AC_MSG_CHECKING(for gnat version)
1259 cf_gnat_version=`${cf_ada_make-gnatmake} -v 2>&1 | grep '[[0-9]].[[0-9]][[0-9]]*' |\
1260   sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
1261 AC_MSG_RESULT($cf_gnat_version)
1262
1263 case $cf_gnat_version in
1264   3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*)
1265     cf_cv_prog_gnat_correct=yes
1266     ;;
1267   *) echo Unsupported GNAT version $cf_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
1268      cf_cv_prog_gnat_correct=no
1269      ;;
1270 esac
1271 case $cf_gnat_version in
1272   3.[[1-9]]*|[[4-9]].*)
1273       cf_compile_generics=generics
1274       cf_generic_objects="\${GENOBJS}"
1275       ;;
1276   *)  cf_compile_generics=
1277       cf_generic_objects=
1278       ;;
1279 esac
1280 ])
1281 dnl ---------------------------------------------------------------------------
1282 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1283 dnl -------------
1284 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1285 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1286 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1287 dnl since it is interwoven with GNU extensions.
1288 dnl
1289 dnl Well, yes we could work around it...
1290 AC_DEFUN([CF_GNU_SOURCE],
1291 [
1292 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1293 AC_TRY_COMPILE([#include <sys/types.h>],[
1294 #ifndef _XOPEN_SOURCE
1295 make an error
1296 #endif],
1297         [cf_cv_gnu_source=no],
1298         [cf_save="$CPPFLAGS"
1299          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1300          AC_TRY_COMPILE([#include <sys/types.h>],[
1301 #ifdef _XOPEN_SOURCE
1302 make an error
1303 #endif],
1304         [cf_cv_gnu_source=no],
1305         [cf_cv_gnu_source=yes])
1306         CPPFLAGS="$cf_save"
1307         ])
1308 ])
1309 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1310 ])dnl
1311 dnl ---------------------------------------------------------------------------
1312 dnl CF_GPP_LIBRARY version: 8 updated: 2003/02/02 01:41:46
1313 dnl --------------
1314 dnl If we're trying to use g++, test if libg++ is installed (a rather common
1315 dnl problem :-).  If we have the compiler but no library, we'll be able to
1316 dnl configure, but won't be able to build the c++ demo program.
1317 AC_DEFUN([CF_GPP_LIBRARY],
1318 [
1319 cf_cxx_library=unknown
1320 case $cf_cv_system_name in #(vi
1321 os2*) #(vi
1322         cf_gpp_libname=gpp
1323         ;;
1324 *)
1325         cf_gpp_libname=g++
1326         ;;
1327 esac
1328 if test "$GXX" = yes; then
1329         AC_MSG_CHECKING([for lib$cf_gpp_libname])
1330         cf_save="$LIBS"
1331         LIBS="$LIBS -l$cf_gpp_libname"
1332         AC_TRY_LINK([
1333 #include <$cf_gpp_libname/builtin.h>
1334         ],
1335         [two_arg_error_handler_t foo2 = lib_error_handler],
1336         [cf_cxx_library=yes
1337          CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
1338          if test "$cf_gpp_libname" = cpp ; then
1339             AC_DEFINE(HAVE_GPP_BUILTIN_H)
1340          else
1341             AC_DEFINE(HAVE_GXX_BUILTIN_H)
1342          fi],
1343         [AC_TRY_LINK([
1344 #include <builtin.h>
1345         ],
1346         [two_arg_error_handler_t foo2 = lib_error_handler],
1347         [cf_cxx_library=yes
1348          CXXLIBS="$CXXLIBS -l$cf_gpp_libname"
1349          AC_DEFINE(HAVE_BUILTIN_H)],
1350         [cf_cxx_library=no])])
1351         LIBS="$cf_save"
1352         AC_MSG_RESULT($cf_cxx_library)
1353 fi
1354 ])dnl
1355 dnl ---------------------------------------------------------------------------
1356 dnl CF_GXX_VERSION version: 5 updated: 2005/08/27 09:53:42
1357 dnl --------------
1358 dnl Check for version of g++
1359 AC_DEFUN([CF_GXX_VERSION],[
1360 AC_REQUIRE([AC_PROG_CPP])
1361 GXX_VERSION=none
1362 if test "$GXX" = yes; then
1363         AC_MSG_CHECKING(version of g++)
1364         GXX_VERSION="`${CXX-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1365         test -z "$GXX_VERSION" && GXX_VERSION=unknown
1366         AC_MSG_RESULT($GXX_VERSION)
1367 fi
1368 ])dnl
1369 dnl ---------------------------------------------------------------------------
1370 dnl CF_GXX_WARNINGS version: 5 updated: 2005/08/13 14:54:38
1371 dnl ---------------
1372 dnl Check if the compiler supports useful warning options.
1373 dnl
1374 dnl Most of gcc's options apply to g++, except:
1375 dnl     -Wbad-function-cast
1376 dnl     -Wmissing-declarations
1377 dnl     -Wnested-externs
1378 dnl
1379 dnl Omit a few (for now):
1380 dnl     -Winline
1381 dnl
1382 dnl Parameter:
1383 dnl     $1 is an optional list of g++ warning flags that a particular
1384 dnl             application might want to use, e.g., "no-unused" for
1385 dnl             -Wno-unused
1386 dnl Special:
1387 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1388 dnl
1389 AC_DEFUN([CF_GXX_WARNINGS],
1390 [
1391
1392 CF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS)
1393
1394 AC_REQUIRE([CF_GXX_VERSION])
1395
1396 AC_LANG_SAVE
1397 AC_LANG_CPLUSPLUS
1398
1399 cat > conftest.$ac_ext <<EOF
1400 #line __oline__ "configure"
1401 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1402 EOF
1403
1404 if test "$INTEL_CPLUSPLUS" = yes
1405 then
1406 # The "-wdXXX" options suppress warnings:
1407 # remark #1419: external declaration in primary source file
1408 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1409 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1410 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1411 # remark #193: zero used for undefined preprocessing identifier
1412 # remark #593: variable "curs_sb_left_arrow" was set but never used
1413 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1414 # remark #869: parameter "tw" was never referenced
1415 # remark #981: operands are evaluated in unspecified order
1416 # warning #269: invalid format string conversion
1417
1418         AC_CHECKING([for $CC warning options])
1419         cf_save_CXXFLAGS="$CXXFLAGS"
1420         EXTRA_CXXFLAGS="-Wall"
1421         for cf_opt in \
1422                 wd1419 \
1423                 wd1682 \
1424                 wd1683 \
1425                 wd1684 \
1426                 wd193 \
1427                 wd279 \
1428                 wd593 \
1429                 wd810 \
1430                 wd869 \
1431                 wd981
1432         do
1433                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
1434                 if AC_TRY_EVAL(ac_compile); then
1435                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1436                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
1437                 fi
1438         done
1439         CXXFLAGS="$cf_save_CXXFLAGS"
1440
1441 elif test "$GXX" = yes
1442 then
1443         AC_CHECKING([for $CXX warning options])
1444         cf_save_CXXFLAGS="$CXXFLAGS"
1445         EXTRA_CXXFLAGS="-W -Wall"
1446         cf_gxx_extra_warnings=""
1447         test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings"
1448         case "$GCC_VERSION" in
1449         [[1-2]].*)
1450                 ;;
1451         *)
1452                 cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++"
1453                 ;;
1454         esac
1455         for cf_opt in \
1456                 Wabi \
1457                 fabi-version=0 \
1458                 Woverloaded-virtual \
1459                 Wsign-promo \
1460                 Wsynth \
1461                 Wold-style-cast \
1462                 Wcast-align \
1463                 Wcast-qual \
1464                 Wmissing-prototypes \
1465                 Wpointer-arith \
1466                 Wshadow \
1467                 Wstrict-prototypes \
1468                 Wundef $cf_gxx_extra_warnings $1
1469         do
1470                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
1471                 if AC_TRY_EVAL(ac_compile); then
1472                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1473                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
1474                 else
1475                         test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
1476                 fi
1477         done
1478         CXXFLAGS="$cf_save_CXXFLAGS"
1479 fi
1480
1481 rm -f conftest*
1482 AC_LANG_RESTORE
1483 AC_SUBST(EXTRA_CXXFLAGS)
1484 ])dnl
1485 dnl ---------------------------------------------------------------------------
1486 dnl CF_HASHED_DB version: 1 updated: 2006/08/19 09:16:14
1487 dnl ------------
1488 dnl Look for an instance of the Berkeley hashed database.
1489 AC_DEFUN([CF_HASHED_DB],
1490 [
1491 AC_CHECK_HEADER(db.h,[
1492 CF_HASHED_DB_VERSION
1493 if test "$cf_cv_hashed_db_version" = unknown ; then
1494         AC_MSG_ERROR(Cannot determine version of db)
1495 else
1496         CF_HASHED_DB_LIBS
1497         if test "$cf_cv_hashed_db_libs" = unknown ; then
1498                 AC_MSG_ERROR(Cannot determine library for db)
1499         elif test "$cf_cv_hashed_db_libs" != default ; then
1500                 LIBS="-l$cf_cv_hashed_db_libs $LIBS"
1501         fi
1502 fi
1503 ],[
1504         AC_MSG_ERROR(Cannot find db.h)
1505 ])
1506 ])dnl
1507 dnl ---------------------------------------------------------------------------
1508 dnl CF_HASHED_DB_LIBS version: 6 updated: 2006/12/16 12:33:30
1509 dnl -----------------
1510 dnl Given that we have the header and version for hashed database, find the
1511 dnl library information.
1512 AC_DEFUN([CF_HASHED_DB_LIBS],
1513 [
1514 AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
1515 cf_cv_hashed_db_libs=unknown
1516 for cf_db_libs in db$cf_cv_hashed_db_version db ''
1517 do
1518         cf_save_libs="$LIBS"
1519         if test -n "$cf_db_libs"; then
1520                 LIBS="-l$cf_db_libs $LIBS"
1521         fi
1522         CF_MSG_LOG(checking for library "$cf_db_libs")
1523         AC_TRY_LINK([
1524 $ac_includes_default
1525 #include <db.h>
1526 ],[
1527         char *path = "/tmp/foo";
1528 #ifdef DB_VERSION_MAJOR
1529 #if DB_VERSION_MAJOR >= 4
1530         DB *result = 0;
1531         db_create(&result, NULL, 0);
1532         result->open(result,
1533                 NULL,
1534                 path,
1535                 path,
1536                 DB_HASH,
1537                 DB_CREATE,
1538                 0644);
1539 #elif DB_VERSION_MAJOR >= 3
1540         DB *result = 0;
1541         db_create(&result, NULL, 0);
1542         result->open(result,
1543                 path,
1544                 path,
1545                 DB_HASH,
1546                 DB_CREATE,
1547                 0644);
1548 #elif DB_VERSION_MAJOR >= 2
1549         DB *result = 0;
1550         db_open(path,
1551                 DB_HASH,
1552                 DB_CREATE,
1553                 0644,
1554                 (DB_ENV *) 0,
1555                 (DB_INFO *) 0,
1556                 &result);
1557 #endif /* DB_VERSION_MAJOR */
1558 #else
1559         DB *result = dbopen(path,
1560                      2,
1561                      0644,
1562                      DB_HASH,
1563                      0);
1564 #endif
1565         ${cf_cv_main_return:-return}(result != 0)
1566 ],[
1567         if test -n "$cf_db_libs" ; then
1568                 cf_cv_hashed_db_libs=$cf_db_libs
1569         else
1570                 cf_cv_hashed_db_libs=default
1571         fi
1572         LIBS="$cf_save_libs"
1573         break
1574 ])
1575         LIBS="$cf_save_libs"
1576 done
1577 ])
1578 ])dnl
1579 dnl ---------------------------------------------------------------------------
1580 dnl CF_HASHED_DB_VERSION version: 2 updated: 2006/08/19 15:12:49
1581 dnl --------------------
1582 dnl Given that we have the header file for hashed database, find the version
1583 dnl information.
1584 AC_DEFUN([CF_HASHED_DB_VERSION],
1585 [
1586 AC_CACHE_CHECK(for version of db, cf_cv_hashed_db_version,[
1587 cf_cv_hashed_db_version=unknown
1588
1589 for cf_db_version in 1 2 3 4
1590 do
1591         CF_MSG_LOG(checking for db version $cf_db_version)
1592         AC_TRY_COMPILE([
1593 $ac_includes_default
1594 #include <db.h>
1595
1596 #ifdef DB_VERSION_MAJOR
1597         /* db2 (DB_VERSION_MAJOR=2) has also DB_VERSION_MINOR, tested with 7 */
1598 #if $cf_db_version == DB_VERSION_MAJOR
1599         /* ok */
1600 #else
1601         make an error
1602 #endif
1603 #else
1604 #if $cf_db_version == 1
1605         /* ok: assuming this is DB 1.8.5 */
1606 #else
1607         make an error
1608 #endif
1609 #endif
1610 ],[DBT *foo = 0],[
1611         cf_cv_hashed_db_version=$cf_db_version
1612         break
1613         ])
1614 done
1615 ])
1616 ])dnl
1617 dnl ---------------------------------------------------------------------------
1618 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1619 dnl ---------------
1620 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1621 AC_DEFUN([CF_HELP_MESSAGE],
1622 [AC_DIVERT_HELP([$1])dnl
1623 ])dnl
1624 dnl ---------------------------------------------------------------------------
1625 dnl CF_INCLUDE_DIRS version: 5 updated: 2006/10/14 15:23:15
1626 dnl ---------------
1627 dnl Construct the list of include-options according to whether we're building
1628 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
1629 dnl with gcc, don't append the includedir if it happens to be /usr/include,
1630 dnl since that usually breaks gcc's shadow-includes.
1631 AC_DEFUN([CF_INCLUDE_DIRS],
1632 [
1633 CPPFLAGS="-I. -I../include $CPPFLAGS"
1634 if test "$srcdir" != "."; then
1635         CPPFLAGS="-I\${srcdir}/../include $CPPFLAGS"
1636 fi
1637 if test "$GCC" != yes; then
1638         CPPFLAGS="$CPPFLAGS -I\${includedir}"
1639 elif test "$includedir" != "/usr/include"; then
1640         if test "$includedir" = '${prefix}/include' ; then
1641                 if test $prefix != /usr ; then
1642                         CPPFLAGS="$CPPFLAGS -I\${includedir}"
1643                 fi
1644         else
1645                 CPPFLAGS="$CPPFLAGS -I\${includedir}"
1646         fi
1647 fi
1648 AC_SUBST(CPPFLAGS)
1649 ])dnl
1650 dnl ---------------------------------------------------------------------------
1651 dnl CF_INTEL_COMPILER version: 3 updated: 2005/08/06 18:37:29
1652 dnl -----------------
1653 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1654 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1655 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1656 dnl
1657 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1658 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1659 dnl the wrappers for gcc and g++ warnings.
1660 dnl
1661 dnl $1 = GCC (default) or GXX
1662 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1663 dnl $3 = CFLAGS (default) or CXXFLAGS
1664 AC_DEFUN([CF_INTEL_COMPILER],[
1665 ifelse($2,,INTEL_COMPILER,[$2])=no
1666
1667 if test "$ifelse($1,,[$1],GCC)" = yes ; then
1668         case $host_os in
1669         linux*|gnu*)
1670                 AC_MSG_CHECKING(if this is really Intel ifelse($1,GXX,C++,C) compiler)
1671                 cf_save_CFLAGS="$ifelse($3,,CFLAGS,[$3])"
1672                 ifelse($3,,CFLAGS,[$3])="$ifelse($3,,CFLAGS,[$3]) -no-gcc"
1673                 AC_TRY_COMPILE([],[
1674 #ifdef __INTEL_COMPILER
1675 #else
1676 make an error
1677 #endif
1678 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
1679 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1680 ],[])
1681                 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
1682                 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
1683                 ;;
1684         esac
1685 fi
1686 ])dnl
1687 dnl ---------------------------------------------------------------------------
1688 dnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
1689 dnl ----------
1690 dnl Check if we have either a function or macro for 'isascii()'.
1691 AC_DEFUN([CF_ISASCII],
1692 [
1693 AC_MSG_CHECKING(for isascii)
1694 AC_CACHE_VAL(cf_cv_have_isascii,[
1695         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
1696         [cf_cv_have_isascii=yes],
1697         [cf_cv_have_isascii=no])
1698 ])dnl
1699 AC_MSG_RESULT($cf_cv_have_isascii)
1700 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII)
1701 ])dnl
1702 dnl ---------------------------------------------------------------------------
1703 dnl CF_LARGEFILE version: 6 updated: 2006/09/23 19:07:52
1704 dnl ------------
1705 dnl Add checks for large file support.
1706 AC_DEFUN([CF_LARGEFILE],[
1707 ifdef([AC_FUNC_FSEEKO],[
1708     AC_SYS_LARGEFILE
1709     if test "$enable_largefile" != no ; then
1710         AC_FUNC_FSEEKO
1711
1712         # Normally we would collect these definitions in the config.h,
1713         # but (like _XOPEN_SOURCE), some environments rely on having these
1714         # defined before any of the system headers are included.  Another
1715         # case comes up with C++, e.g., on AIX the compiler compiles the
1716         # header files by themselves before looking at the body files it is
1717         # told to compile.  For ncurses, those header files do not include
1718         # the config.h
1719         test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
1720         test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
1721
1722         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
1723                 AC_TRY_COMPILE([
1724 #include <sys/types.h>
1725 #include <dirent.h>
1726                 ],[
1727                 /* if transitional largefile support is setup, this is true */
1728                 extern struct dirent64 * readdir(DIR *);
1729                 struct dirent64 *x = readdir((DIR *)0);
1730                 struct dirent *y = readdir((DIR *)0);
1731                 int z = x - y;
1732                 ],
1733                 [cf_cv_struct_dirent64=yes],
1734                 [cf_cv_struct_dirent64=no])
1735         ])
1736         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
1737     fi
1738 ])
1739 ])
1740 dnl ---------------------------------------------------------------------------
1741 dnl CF_LIBUTF8 version: 2 updated: 2002/01/19 22:51:32
1742 dnl ----------
1743 dnl Check for libutf8
1744 AC_DEFUN([CF_LIBUTF8],
1745 [
1746 AC_CACHE_CHECK(for putwc in libutf8,cf_cv_libutf8,[
1747         cf_save_LIBS="$LIBS"
1748         LIBS="-lutf8 $LIBS"
1749 AC_TRY_LINK([
1750 #include <libutf8.h>],[putwc(0,0);],
1751         [cf_cv_libutf8=yes],
1752         [cf_cv_libutf8=no])
1753         LIBS="$cf_save_LIBS"
1754 ])
1755
1756 if test "$cf_cv_libutf8" = yes ; then
1757         AC_DEFINE(HAVE_LIBUTF8_H)
1758         LIBS="-lutf8 $LIBS"
1759 fi
1760 ])dnl
1761 dnl ---------------------------------------------------------------------------
1762 dnl CF_LIB_PREFIX version: 7 updated: 2001/01/12 01:23:48
1763 dnl -------------
1764 dnl Compute the library-prefix for the given host system
1765 dnl $1 = variable to set
1766 AC_DEFUN([CF_LIB_PREFIX],
1767 [
1768         case $cf_cv_system_name in
1769         OS/2*)  LIB_PREFIX=''     ;;
1770         os2*)   LIB_PREFIX=''     ;;
1771         *)      LIB_PREFIX='lib'  ;;
1772         esac
1773 ifelse($1,,,[$1=$LIB_PREFIX])
1774         AC_SUBST(LIB_PREFIX)
1775 ])dnl
1776 dnl ---------------------------------------------------------------------------
1777 dnl CF_LIB_RULES version: 50 updated: 2007/03/24 18:26:59
1778 dnl ------------
1779 dnl Append definitions and rules for the given models to the subdirectory
1780 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
1781 dnl subdirectory is a library-source directory, modify the LIBS_TO_MAKE list in
1782 dnl the corresponding makefile to list the models that we'll generate.
1783 dnl
1784 dnl For shared libraries, make a list of symbolic links to construct when
1785 dnl generating each library.  The convention used for Linux is the simplest
1786 dnl one:
1787 dnl     lib<name>.so    ->
1788 dnl     lib<name>.so.<major>    ->
1789 dnl     lib<name>.so.<maj>.<minor>
1790 AC_DEFUN([CF_LIB_RULES],
1791 [
1792 CF_LIB_PREFIX(cf_prefix)
1793 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1794 for cf_dir in $SRC_SUBDIRS
1795 do
1796         if test ! -d $srcdir/$cf_dir ; then
1797                 continue
1798         elif test -f $srcdir/$cf_dir/modules; then
1799
1800                 SHARED_LIB=
1801                 LIBS_TO_MAKE=
1802                 for cf_item in $cf_LIST_MODELS
1803                 do
1804                         CF_LIB_SUFFIX($cf_item,cf_suffix)
1805                         if test $cf_item = shared ; then
1806                         if test "$cf_cv_do_symlinks" = yes ; then
1807                                 case "$cf_cv_shlib_version" in #(vi
1808                                 rel) #(vi
1809                                         case "$cf_cv_system_name" in #(vi
1810                                         darwin*)
1811                                         case .${LIB_SUFFIX} in
1812                                         .w*)
1813                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
1814                                                 cf_suffix=w'.${REL_VERSION}'"$cf_suffix"
1815                                                 ;;
1816                                         *)
1817                                                 cf_suffix='.${REL_VERSION}'"$cf_suffix"
1818                                                 ;;
1819                                         esac
1820                                         ;; #(vi
1821                                         *) cf_suffix="$cf_suffix"'.${REL_VERSION}' ;;
1822                                         esac
1823                                         ;;
1824                                 abi)
1825                                         case "$cf_cv_system_name" in #(vi
1826                                         darwin*)
1827                                         case .${LIB_SUFFIX} in
1828                                         .w*)
1829                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
1830                                                 cf_suffix=w'.${ABI_VERSION}'"$cf_suffix"
1831                                                 ;;
1832                                         *)
1833                                                 cf_suffix='.${ABI_VERSION}'"$cf_suffix"
1834                                                 ;;
1835                                         esac
1836                                         ;; #(vi
1837                                         *) cf_suffix="$cf_suffix"'.${ABI_VERSION}' ;;
1838                                         esac
1839                                         ;;
1840                                 esac
1841                         fi
1842                         # cygwin needs import library, and has unique naming convention
1843                         # use autodetected ${cf_prefix} for import lib and static lib, but
1844                         # use 'cyg' prefix for shared lib.
1845                         if test $cf_cv_shlib_version = cygdll ; then
1846                                 LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/cyg${cf_dir}\${ABI_VERSION}.dll"
1847                                 continue
1848                         fi
1849                         fi
1850                         LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
1851                 done
1852
1853                 if test $cf_dir = ncurses ; then
1854                         cf_subsets="$LIB_SUBSETS"
1855                         cf_r_parts="$cf_subsets"
1856
1857                         while test -n "$cf_r_parts"
1858                         do
1859                                 cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'`
1860                                 cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'`
1861                                 if test "$cf_l_parts" != "$cf_r_parts" ; then
1862                                         case $cf_l_parts in #(vi
1863                                         *termlib*) #(vi
1864                                                 cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
1865                                                 ;;
1866                                         *ticlib*)
1867                                                 cf_item=`echo $LIBS_TO_MAKE |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g`
1868                                                 ;;
1869                                         *)
1870                                                 break
1871                                                 ;;
1872                                         esac
1873                                         LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
1874                                 else
1875                                         break
1876                                 fi
1877                         done
1878                 else
1879                         cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
1880                 fi
1881
1882                 sed -e "s%@LIBS_TO_MAKE@%$LIBS_TO_MAKE%" \
1883                     -e "s%@SHARED_LIB@%$SHARED_LIB%" \
1884                         $cf_dir/Makefile >$cf_dir/Makefile.out
1885                 mv $cf_dir/Makefile.out $cf_dir/Makefile
1886
1887                 $AWK -f $srcdir/mk-0th.awk \
1888                         libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" \
1889                         $srcdir/$cf_dir/modules >>$cf_dir/Makefile
1890
1891                 for cf_subset in $cf_subsets
1892                 do
1893                         cf_subdirs=
1894                         for cf_item in $cf_LIST_MODELS
1895                         do
1896                         echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
1897                         CF_UPPER(cf_ITEM,$cf_item)
1898                         CF_LIB_SUFFIX($cf_item,cf_suffix)
1899                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
1900
1901                         # Test for case where we build libtinfo with a different name.
1902                         cf_libname=$cf_dir
1903                         if test $cf_dir = ncurses ; then
1904                                 case $cf_subset in
1905                                 *base*)
1906                                         ;;
1907                                 *termlib*)
1908                                         cf_libname=$TINFO_LIB_SUFFIX
1909                                         if test -n "${DFT_ARG_SUFFIX}" ; then
1910                                                 # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
1911                                                 cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
1912                                         fi
1913                                         ;;
1914                                 ticlib*)
1915                                         cf_libname=$TICS_LIB_SUFFIX
1916                                         if test -n "${DFT_ARG_SUFFIX}" ; then
1917                                                 # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
1918                                                 cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
1919                                         fi
1920                                         ;;
1921                                 esac
1922                         fi
1923
1924                         # These dependencies really are for development, not
1925                         # builds, but they are useful in porting, too.
1926                         cf_depend="../include/ncurses_cfg.h"
1927                         if test "$srcdir" = "."; then
1928                                 cf_reldir="."
1929                         else
1930                                 cf_reldir="\${srcdir}"
1931                         fi
1932
1933                         if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
1934                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
1935                         elif test -f $srcdir/$cf_dir/curses.priv.h; then
1936                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
1937                         fi
1938
1939                         cf_dir_suffix=
1940                         old_cf_suffix="$cf_suffix"
1941                         if test "$cf_cv_shlib_version_infix" = yes ; then
1942                         if test -n "$LIB_SUFFIX" ; then
1943                                 case $LIB_SUFFIX in
1944                                 w*)
1945                                         cf_libname=`echo $cf_libname | sed 's/w$//'`
1946                                         cf_suffix=`echo $cf_suffix | sed 's/^w//'`
1947                                         cf_dir_suffix=w
1948                                         ;;
1949                                 esac
1950                         fi
1951                         fi
1952
1953                         $AWK -f $srcdir/mk-1st.awk \
1954                                 name=${cf_libname}${cf_dir_suffix} \
1955                                 traces=$LIB_TRACING \
1956                                 MODEL=$cf_ITEM \
1957                                 model=$cf_subdir \
1958                                 prefix=$cf_prefix \
1959                                 suffix=$cf_suffix \
1960                                 subset=$cf_subset \
1961                                 TermlibRoot=$TINFO_NAME \
1962                                 TermlibSuffix=$TINFO_SUFFIX \
1963                                 ShlibVer=$cf_cv_shlib_version \
1964                                 ShlibVerInfix=$cf_cv_shlib_version_infix \
1965                                 ReLink=${cf_cv_do_relink-no} \
1966                                 DoLinks=$cf_cv_do_symlinks \
1967                                 rmSoLocs=$cf_cv_rm_so_locs \
1968                                 ldconfig="$LDCONFIG" \
1969                                 overwrite=$WITH_OVERWRITE \
1970                                 depend="$cf_depend" \
1971                                 host="$host" \
1972                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
1973
1974                         cf_suffix="$old_cf_suffix"
1975
1976                         for cf_subdir2 in $cf_subdirs lib
1977                         do
1978                                 test $cf_subdir = $cf_subdir2 && break
1979                         done
1980                         test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
1981                         $AWK -f $srcdir/mk-2nd.awk \
1982                                 name=$cf_dir \
1983                                 traces=$LIB_TRACING \
1984                                 MODEL=$cf_ITEM \
1985                                 model=$cf_subdir \
1986                                 subset=$cf_subset \
1987                                 srcdir=$srcdir \
1988                                 echo=$WITH_ECHO \
1989                                 crenames=$cf_cv_prog_CC_c_o \
1990                                 cxxrenames=$cf_cv_prog_CXX_c_o \
1991                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
1992                         cf_subdirs="$cf_subdirs $cf_subdir"
1993                         done
1994                 done
1995         fi
1996
1997         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >>Makefile
1998 done
1999
2000 for cf_dir in $SRC_SUBDIRS
2001 do
2002         if test ! -d $srcdir/$cf_dir ; then
2003                 continue
2004         fi
2005
2006         if test -f $cf_dir/Makefile ; then
2007                 case "$cf_dir" in
2008                 Ada95) #(vi
2009                         echo 'libs \' >> Makefile
2010                         echo 'install.libs \' >> Makefile
2011                         echo 'uninstall.libs ::' >> Makefile
2012                         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >> Makefile
2013                         ;;
2014                 esac
2015         fi
2016
2017         if test -f $srcdir/$cf_dir/modules; then
2018                 echo >> Makefile
2019                 if test -f $srcdir/$cf_dir/headers; then
2020 cat >> Makefile <<CF_EOF
2021 install.includes \\
2022 uninstall.includes \\
2023 CF_EOF
2024                 fi
2025 if test "$cf_dir" != "c++" ; then
2026 echo 'lint \' >> Makefile
2027 fi
2028 cat >> Makefile <<CF_EOF
2029 libs \\
2030 lintlib \\
2031 install.libs \\
2032 uninstall.libs \\
2033 install.$cf_dir \\
2034 uninstall.$cf_dir ::
2035         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
2036 CF_EOF
2037         elif test -f $srcdir/$cf_dir/headers; then
2038 cat >> Makefile <<CF_EOF
2039
2040 libs \\
2041 install.libs \\
2042 uninstall.libs \\
2043 install.includes \\
2044 uninstall.includes ::
2045         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
2046 CF_EOF
2047 fi
2048 done
2049
2050 cat >> Makefile <<CF_EOF
2051
2052 install.libs uninstall.libs \\
2053 install.data uninstall.data ::
2054 $MAKE_TERMINFO  cd misc && \${MAKE} \${CF_MFLAGS} \[$]@
2055
2056 install.man \\
2057 uninstall.man ::
2058         cd man && \${MAKE} \${CF_MFLAGS} \[$]@
2059
2060 distclean ::
2061         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
2062         rm -f headers.sh headers.sed mk_shared_lib.sh
2063         rm -rf \${DIRS_TO_MAKE}
2064 CF_EOF
2065
2066 # Special case: tack's manpage lives in its own directory.
2067 if test -d tack ; then
2068 if test -f $srcdir/$tack.h; then
2069 cat >> Makefile <<CF_EOF
2070
2071 install.man \\
2072 uninstall.man ::
2073         cd tack && \${MAKE} \${CF_MFLAGS} \[$]@
2074 CF_EOF
2075 fi
2076 fi
2077
2078 dnl If we're installing into a subdirectory of /usr/include, etc., we should
2079 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
2080 dnl anything, and will make it more standardized.  It's awkward to decide this
2081 dnl at configuration because of quoting, so we'll simply make all headers
2082 dnl installed via a script that can do the right thing.
2083
2084 rm -f headers.sed headers.sh
2085
2086 dnl ( generating this script makes the makefiles a little tidier :-)
2087 echo creating headers.sh
2088 cat >headers.sh <<CF_EOF
2089 #! /bin/sh
2090 # This shell script is generated by the 'configure' script.  It is invoked in a
2091 # subdirectory of the build tree.  It generates a sed-script in the parent
2092 # directory that is used to adjust includes for header files that reside in a
2093 # subdirectory of /usr/include, etc.
2094 PRG=""
2095 while test \[$]# != 3
2096 do
2097 PRG="\$PRG \[$]1"; shift
2098 done
2099 DST=\[$]1
2100 REF=\[$]2
2101 SRC=\[$]3
2102 TMPSRC=\${TMPDIR-/tmp}/\`basename \$SRC\`\$\$
2103 TMPSED=\${TMPDIR-/tmp}/headers.sed\$\$
2104 echo installing \$SRC in \$DST
2105 CF_EOF
2106
2107 if test $WITH_CURSES_H = yes; then
2108         cat >>headers.sh <<CF_EOF
2109 case \$DST in
2110 /*/include/*)
2111         END=\`basename \$DST\`
2112         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
2113         do
2114                 NAME=\`basename \$i\`
2115                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
2116         done
2117         ;;
2118 *)
2119         echo "" >> \$TMPSED
2120         ;;
2121 esac
2122 CF_EOF
2123
2124 else
2125         cat >>headers.sh <<CF_EOF
2126 case \$DST in
2127 /*/include/*)
2128         END=\`basename \$DST\`
2129         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
2130         do
2131                 NAME=\`basename \$i\`
2132                 if test "\$NAME" = "curses.h"
2133                 then
2134                         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
2135                         NAME=ncurses.h
2136                 fi
2137                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
2138         done
2139         ;;
2140 *)
2141         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
2142         ;;
2143 esac
2144 CF_EOF
2145 fi
2146 cat >>headers.sh <<CF_EOF
2147 rm -f \$TMPSRC
2148 sed -f \$TMPSED \$SRC > \$TMPSRC
2149 NAME=\`basename \$SRC\`
2150 CF_EOF
2151 if test $WITH_CURSES_H != yes; then
2152         cat >>headers.sh <<CF_EOF
2153 test "\$NAME" = "curses.h" && NAME=ncurses.h
2154 CF_EOF
2155 fi
2156 cat >>headers.sh <<CF_EOF
2157 # Just in case someone gzip'd manpages, remove the conflicting copy.
2158 test -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
2159
2160 eval \$PRG \$TMPSRC \$DST/\$NAME
2161 rm -f \$TMPSRC \$TMPSED
2162 CF_EOF
2163
2164 chmod 0755 headers.sh
2165
2166 for cf_dir in $SRC_SUBDIRS
2167 do
2168         if test ! -d $srcdir/$cf_dir ; then
2169                 continue
2170         fi
2171
2172         if test -f $srcdir/$cf_dir/headers; then
2173                 $AWK -f $srcdir/mk-hdr.awk \
2174                         subset="$LIB_SUBSETS" \
2175                         compat="$WITH_CURSES_H" \
2176                         $srcdir/$cf_dir/headers >>$cf_dir/Makefile
2177         fi
2178
2179         if test -f $srcdir/$cf_dir/modules; then
2180                 if test "$cf_dir" != "c++" ; then
2181                         cat >>$cf_dir/Makefile <<"CF_EOF"
2182 depend : ${AUTO_SRC}
2183         makedepend -- ${CPPFLAGS} -- ${C_SRC}
2184
2185 # DO NOT DELETE THIS LINE -- make depend depends on it.
2186 CF_EOF
2187                 fi
2188         fi
2189 done
2190
2191 ])dnl
2192 dnl ---------------------------------------------------------------------------
2193 dnl CF_LIB_SONAME version: 3 updated: 2006/12/16 15:55:46
2194 dnl -------------
2195 dnl Find the and soname for the given shared library.  Set the cache variable
2196 dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
2197 dnl variable to "unknown".
2198 dnl
2199 dnl $1 = headers
2200 dnl $2 = code
2201 dnl $3 = library name
2202 AC_DEFUN([CF_LIB_SONAME],
2203 [
2204 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
2205
2206 cf_cv_$3_soname=unknown
2207 if test "$cross_compiling" != yes ; then
2208 cat >conftest.$ac_ext <<CF_EOF
2209 $1
2210 int main()
2211 {
2212 $2
2213         ${cf_cv_main_return:-return}(0);
2214 }
2215 CF_EOF
2216 cf_save_LIBS="$LIBS"
2217         LIBS="-l$3 $LIBS"
2218         if AC_TRY_EVAL(ac_compile) ; then
2219                 if AC_TRY_EVAL(ac_link) ; then
2220                         cf_cv_$3_soname=`ldd conftest$ac_exeext 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | fgrep lib$3.`
2221                         test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
2222                 fi
2223         fi
2224 rm -f conftest*
2225 LIBS="$cf_save_LIBS"
2226 fi
2227 ])
2228 ])
2229 dnl ---------------------------------------------------------------------------
2230 dnl CF_LIB_SUFFIX version: 13 updated: 2003/11/01 16:09:07
2231 dnl -------------
2232 dnl Compute the library file-suffix from the given model name
2233 dnl $1 = model name
2234 dnl $2 = variable to set
2235 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
2236 AC_DEFUN([CF_LIB_SUFFIX],
2237 [
2238         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2239         case $1 in
2240         libtool) $2='.la'  ;;
2241         normal)  $2='.a'   ;;
2242         debug)   $2='_g.a' ;;
2243         profile) $2='_p.a' ;;
2244         shared)
2245                 case $cf_cv_system_name in
2246                 cygwin*) $2='.dll' ;;
2247                 darwin*) $2='.dylib' ;;
2248                 hpux*)
2249                         case $target in
2250                         ia64*)  $2='.so' ;;
2251                         *)      $2='.sl' ;;
2252                         esac
2253                         ;;
2254                 *)      $2='.so'  ;;
2255                 esac
2256         esac
2257         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
2258 ])dnl
2259 dnl ---------------------------------------------------------------------------
2260 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
2261 dnl -----------
2262 dnl Compute the string to append to -library from the given model name
2263 dnl $1 = model name
2264 dnl $2 = variable to set
2265 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
2266 AC_DEFUN([CF_LIB_TYPE],
2267 [
2268         case $1 in
2269         libtool) $2=''   ;;
2270         normal)  $2=''   ;;
2271         debug)   $2='_g' ;;
2272         profile) $2='_p' ;;
2273         shared)  $2=''   ;;
2274         esac
2275         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
2276 ])dnl
2277 dnl ---------------------------------------------------------------------------
2278 dnl CF_LINK_DATAONLY version: 8 updated: 2006/12/16 12:33:30
2279 dnl ----------------
2280 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
2281 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
2282 dnl have to provide wrappers for global tables to ensure they're linked
2283 dnl properly.
2284 AC_DEFUN([CF_LINK_DATAONLY],
2285 [
2286 AC_MSG_CHECKING([if data-only library module links])
2287 AC_CACHE_VAL(cf_cv_link_dataonly,[
2288         rm -f conftest.a
2289         cat >conftest.$ac_ext <<EOF
2290 #line __oline__ "configure"
2291 int     testdata[[3]] = { 123, 456, 789 };
2292 EOF
2293         if AC_TRY_EVAL(ac_compile) ; then
2294                 mv conftest.o data.o && \
2295                 ( $AR $AR_OPTS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
2296         fi
2297         rm -f conftest.$ac_ext data.o
2298         cat >conftest.$ac_ext <<EOF
2299 #line __oline__ "configure"
2300 int     testfunc()
2301 {
2302 #if defined(NeXT)
2303         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
2304 #else
2305         extern int testdata[[3]];
2306         return testdata[[0]] == 123
2307            &&  testdata[[1]] == 456
2308            &&  testdata[[2]] == 789;
2309 #endif
2310 }
2311 EOF
2312         if AC_TRY_EVAL(ac_compile); then
2313                 mv conftest.o func.o && \
2314                 ( $AR $AR_OPTS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
2315         fi
2316         rm -f conftest.$ac_ext func.o
2317         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
2318         cf_saveLIBS="$LIBS"
2319         LIBS="conftest.a $LIBS"
2320         AC_TRY_RUN([
2321         int main()
2322         {
2323                 extern int testfunc();
2324                 ${cf_cv_main_return:-return} (!testfunc());
2325         }
2326         ],
2327         [cf_cv_link_dataonly=yes],
2328         [cf_cv_link_dataonly=no],
2329         [cf_cv_link_dataonly=unknown])
2330         LIBS="$cf_saveLIBS"
2331         ])
2332 AC_MSG_RESULT($cf_cv_link_dataonly)
2333
2334 if test "$cf_cv_link_dataonly" = no ; then
2335         AC_DEFINE(BROKEN_LINKER)
2336         BROKEN_LINKER=1
2337 fi
2338
2339 ])dnl
2340 dnl ---------------------------------------------------------------------------
2341 dnl CF_LINK_FUNCS version: 7 updated: 2006/12/16 12:33:30
2342 dnl -------------
2343 dnl Most Unix systems have both link and symlink, a few don't have symlink.
2344 dnl A few non-Unix systems implement symlink, but not link.
2345 dnl A few non-systems implement neither (or have nonfunctional versions).
2346 AC_DEFUN([CF_LINK_FUNCS],
2347 [
2348 AC_CHECK_FUNCS( \
2349         remove \
2350         unlink )
2351
2352 if test "$cross_compiling" = yes ; then
2353         AC_CHECK_FUNCS( \
2354                 link \
2355                 symlink )
2356 else
2357         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
2358                 cf_cv_link_funcs=
2359                 for cf_func in link symlink ; do
2360                         AC_TRY_RUN([
2361 #include <sys/types.h>
2362 #include <sys/stat.h>
2363 #ifdef HAVE_UNISTD_H
2364 #include <unistd.h>
2365 #endif
2366 int main()
2367 {
2368         int fail = 0;
2369         char *src = "config.log";
2370         char *dst = "conftest.chk";
2371         struct stat src_sb;
2372         struct stat dst_sb;
2373
2374         stat(src, &src_sb);
2375         fail = ($cf_func("config.log", "conftest.chk") < 0)
2376             || (stat(dst, &dst_sb) < 0)
2377             || (dst_sb.st_mtime != src_sb.st_mtime);
2378 #ifdef HAVE_UNLINK
2379         unlink(dst);
2380 #else
2381         remove(dst);
2382 #endif
2383         ${cf_cv_main_return:-return} (fail);
2384 }
2385                         ],[
2386                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
2387                         eval 'ac_cv_func_'$cf_func'=yes'],[
2388                         eval 'ac_cv_func_'$cf_func'=no'],[
2389                         eval 'ac_cv_func_'$cf_func'=error'])
2390                 done
2391                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
2392         ])
2393         test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK)
2394         test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
2395 fi
2396 ])dnl
2397 dnl ---------------------------------------------------------------------------
2398 dnl CF_MAIN_RETURN version: 1 updated: 2006/12/10 09:51:54
2399 dnl --------------
2400 dnl Check if a return from main to the shell actually returns the same exit
2401 dnl code.  This is true for almost any POSIX environment.
2402 dnl
2403 dnl Some very old environments did not flush stdout, etc., on an exit.  That
2404 dnl would be a useful case to test for also.
2405 AC_DEFUN([CF_MAIN_RETURN],
2406 [
2407 cf_cv_main_return=return
2408 ])dnl
2409 dnl ---------------------------------------------------------------------------
2410 dnl CF_MAKEFLAGS version: 12 updated: 2006/10/21 08:27:03
2411 dnl ------------
2412 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
2413 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
2414 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
2415 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
2416 AC_DEFUN([CF_MAKEFLAGS],
2417 [
2418 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
2419         cf_cv_makeflags=''
2420         for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
2421         do
2422                 cat >cf_makeflags.tmp <<CF_EOF
2423 SHELL = /bin/sh
2424 all :
2425         @ echo '.$cf_option'
2426 CF_EOF
2427                 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[       ]]*$,,'`
2428                 case "$cf_result" in
2429                 .*k)
2430                         cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
2431                         case "$cf_result" in
2432                         .*CC=*) cf_cv_makeflags=
2433                                 ;;
2434                         *)      cf_cv_makeflags=$cf_option
2435                                 ;;
2436                         esac
2437                         break
2438                         ;;
2439                 .-)     ;;
2440                 *)      echo "given option \"$cf_option\", no match \"$cf_result\""
2441                         ;;
2442                 esac
2443         done
2444         rm -f cf_makeflags.tmp
2445 ])
2446
2447 AC_SUBST(cf_cv_makeflags)
2448 ])dnl
2449 dnl ---------------------------------------------------------------------------
2450 dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
2451 dnl ------------
2452 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
2453 dnl a monocase filesystem.
2454 AC_DEFUN([CF_MAKE_TAGS],[
2455 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
2456 AC_CHECK_PROG(MAKE_LOWER_TAGS, ctags, yes, no)
2457
2458 if test "$cf_cv_mixedcase" = yes ; then
2459         AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
2460 else
2461         MAKE_UPPER_TAGS=no
2462 fi
2463
2464 if test "$MAKE_UPPER_TAGS" = yes ; then
2465         MAKE_UPPER_TAGS=
2466 else
2467         MAKE_UPPER_TAGS="#"
2468 fi
2469 AC_SUBST(MAKE_UPPER_TAGS)
2470
2471 if test "$MAKE_LOWER_TAGS" = yes ; then
2472         MAKE_LOWER_TAGS=
2473 else
2474         MAKE_LOWER_TAGS="#"
2475 fi
2476 AC_SUBST(MAKE_LOWER_TAGS)
2477 ])dnl
2478 dnl ---------------------------------------------------------------------------
2479 dnl CF_MANPAGE_FORMAT version: 7 updated: 2003/12/20 19:30:34
2480 dnl -----------------
2481 dnl Option to allow user to override automatic configuration of manpage format.
2482 dnl There are several special cases:
2483 dnl
2484 dnl     gzip - man checks for, can display gzip'd files
2485 dnl     compress - man checks for, can display compressed files
2486 dnl     BSDI - files in the cat-directories are suffixed ".0"
2487 dnl     formatted - installer should format (put files in cat-directory)
2488 dnl     catonly - installer should only format, e.g., for a turnkey system.
2489 dnl
2490 dnl There are other configurations which this macro does not test, e.g., HPUX's
2491 dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
2492 dnl convention would not match our use).
2493 AC_DEFUN([CF_MANPAGE_FORMAT],
2494 [
2495 AC_REQUIRE([CF_PATHSEP])
2496 AC_MSG_CHECKING(format of man-pages)
2497
2498 AC_ARG_WITH(manpage-format,
2499         [  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
2500                           optionally formatted/catonly, e.g., gzip,formatted],
2501         [MANPAGE_FORMAT=$withval],
2502         [MANPAGE_FORMAT=unknown])
2503
2504 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
2505 MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
2506
2507 cf_unknown=
2508
2509 case $MANPAGE_FORMAT in
2510 unknown)
2511   if test -z "$MANPATH" ; then
2512     MANPATH="/usr/man:/usr/share/man"
2513   fi
2514
2515   # look for the 'date' man-page (it's most likely to be installed!)
2516   MANPAGE_FORMAT=
2517   cf_preform=no
2518   cf_catonly=yes
2519   cf_example=date
2520
2521   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATHSEP}"
2522   for cf_dir in $MANPATH; do
2523     test -z "$cf_dir" && cf_dir=/usr/man
2524     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
2525     do
2526       cf_test=`echo $cf_name | sed -e 's/*//'`
2527       if test "x$cf_test" = "x$cf_name" ; then
2528
2529         case "$cf_name" in
2530         *.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
2531         *.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
2532         *.0)    MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
2533         *)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
2534         esac
2535
2536         case "$cf_name" in
2537         $cf_dir/man*)
2538           cf_catonly=no
2539           ;;
2540         $cf_dir/cat*)
2541           cf_preform=yes
2542           ;;
2543         esac
2544         break
2545       fi
2546
2547       # if we found a match in either man* or cat*, stop looking
2548       if test -n "$MANPAGE_FORMAT" ; then
2549         cf_found=no
2550         test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
2551         test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
2552         case "$cf_name" in
2553         $cf_dir/cat*)
2554           cf_found=yes
2555           ;;
2556         esac
2557         test $cf_found=yes && break
2558       fi
2559     done
2560     # only check the first directory in $MANPATH where we find manpages
2561     if test -n "$MANPAGE_FORMAT" ; then
2562        break
2563     fi
2564   done
2565   # if we did not find the example, just assume it is normal
2566   test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
2567   IFS="$ac_save_ifs"
2568   ;;
2569 *)
2570   for cf_option in $MANPAGE_FORMAT; do
2571      case $cf_option in #(vi
2572      gzip|compress|BSDI|normal|formatted|catonly)
2573        ;;
2574      *)
2575        cf_unknown="$cf_unknown $cf_option"
2576        ;;
2577      esac
2578   done
2579   ;;
2580 esac
2581
2582 AC_MSG_RESULT($MANPAGE_FORMAT)
2583 if test -n "$cf_unknown" ; then
2584   AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
2585 fi
2586 ])dnl
2587 dnl ---------------------------------------------------------------------------
2588 dnl CF_MANPAGE_RENAMES version: 7 updated: 2005/06/18 18:51:57
2589 dnl ------------------
2590 dnl The Debian people have their own naming convention for manpages.  This
2591 dnl option lets us override the name of the file containing renaming, or
2592 dnl disable it altogether.
2593 AC_DEFUN([CF_MANPAGE_RENAMES],
2594 [
2595 AC_MSG_CHECKING(for manpage renaming)
2596
2597 AC_ARG_WITH(manpage-renames,
2598         [  --with-manpage-renames  specify manpage-renaming],
2599         [MANPAGE_RENAMES=$withval],
2600         [MANPAGE_RENAMES=yes])
2601
2602 case ".$MANPAGE_RENAMES" in #(vi
2603 .no) #(vi
2604   ;;
2605 .|.yes)
2606   # Debian 'man' program?
2607   if test -f /etc/debian_version ; then
2608     MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
2609   else
2610     MANPAGE_RENAMES=no
2611   fi
2612   ;;
2613 esac
2614
2615 if test "$MANPAGE_RENAMES" != no ; then
2616   if test -f $srcdir/man/$MANPAGE_RENAMES ; then
2617     MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
2618   elif test ! -f $MANPAGE_RENAMES ; then
2619     AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
2620   fi
2621
2622   test ! -d man && mkdir man
2623
2624   # Construct a sed-script to perform renaming within man-pages
2625   if test -n "$MANPAGE_RENAMES" ; then
2626     test ! -d man && mkdir man
2627     sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >./edit_man.sed
2628   fi
2629 fi
2630
2631 AC_MSG_RESULT($MANPAGE_RENAMES)
2632 AC_SUBST(MANPAGE_RENAMES)
2633 ])dnl
2634 dnl ---------------------------------------------------------------------------
2635 dnl CF_MANPAGE_SYMLINKS version: 4 updated: 2003/12/13 18:01:58
2636 dnl -------------------
2637 dnl Some people expect each tool to make all aliases for manpages in the
2638 dnl man-directory.  This accommodates the older, less-capable implementations
2639 dnl of 'man', and is optional.
2640 AC_DEFUN([CF_MANPAGE_SYMLINKS],
2641 [
2642 AC_MSG_CHECKING(if manpage aliases will be installed)
2643
2644 AC_ARG_WITH(manpage-aliases,
2645         [  --with-manpage-aliases  specify manpage-aliases using .so],
2646         [MANPAGE_ALIASES=$withval],
2647         [MANPAGE_ALIASES=yes])
2648
2649 AC_MSG_RESULT($MANPAGE_ALIASES)
2650
2651 if test "$LN_S" = "ln -s"; then
2652         cf_use_symlinks=yes
2653 else
2654         cf_use_symlinks=no
2655 fi
2656
2657 MANPAGE_SYMLINKS=no
2658 if test "$MANPAGE_ALIASES" = yes ; then
2659 AC_MSG_CHECKING(if manpage symlinks should be used)
2660
2661 AC_ARG_WITH(manpage-symlinks,
2662         [  --with-manpage-symlinks specify manpage-aliases using symlinks],
2663         [MANPAGE_SYMLINKS=$withval],
2664         [MANPAGE_SYMLINKS=$cf_use_symlinks])
2665
2666 if test "$$cf_use_symlinks" = no; then
2667 if test "$MANPAGE_SYMLINKS" = yes ; then
2668         AC_MSG_WARN(cannot make symlinks, will use .so files)
2669         MANPAGE_SYMLINKS=no
2670 fi
2671 fi
2672
2673 AC_MSG_RESULT($MANPAGE_SYMLINKS)
2674 fi
2675
2676 ])dnl
2677 dnl ---------------------------------------------------------------------------
2678 dnl CF_MANPAGE_TBL version: 3 updated: 2002/01/19 22:51:32
2679 dnl --------------
2680 dnl This option causes manpages to be run through tbl(1) to generate tables
2681 dnl correctly.
2682 AC_DEFUN([CF_MANPAGE_TBL],
2683 [
2684 AC_MSG_CHECKING(for manpage tbl)
2685
2686 AC_ARG_WITH(manpage-tbl,
2687         [  --with-manpage-tbl      specify manpage processing with tbl],
2688         [MANPAGE_TBL=$withval],
2689         [MANPAGE_TBL=no])
2690
2691 AC_MSG_RESULT($MANPAGE_TBL)
2692 ])dnl
2693 dnl ---------------------------------------------------------------------------
2694 dnl CF_MAN_PAGES version: 35 updated: 2007/03/31 11:47:29
2695 dnl ------------
2696 dnl Try to determine if the man-pages on the system are compressed, and if
2697 dnl so, what format is used.  Use this information to construct a script that
2698 dnl will install man-pages.
2699 AC_DEFUN([CF_MAN_PAGES],
2700 [
2701 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
2702 CF_MANPAGE_FORMAT
2703 CF_MANPAGE_RENAMES
2704 CF_MANPAGE_SYMLINKS
2705 CF_MANPAGE_TBL
2706
2707   if test "$prefix" = "NONE" ; then
2708      cf_prefix="$ac_default_prefix"
2709   else
2710      cf_prefix="$prefix"
2711   fi
2712
2713   case "$MANPAGE_FORMAT" in # (vi
2714   *catonly*) # (vi
2715     cf_format=yes
2716     cf_inboth=no
2717     ;;
2718   *formatted*) # (vi
2719     cf_format=yes
2720     cf_inboth=yes
2721     ;;
2722   *)
2723     cf_format=no
2724     cf_inboth=no
2725     ;;
2726   esac
2727
2728 test ! -d man && mkdir man
2729
2730 cf_so_strip=
2731 cf_compress=
2732 case "$MANPAGE_FORMAT" in #(vi
2733 *compress*) #(vi
2734         cf_so_strip="Z"
2735         cf_compress=compress
2736   ;;
2737 *gzip*) #(vi
2738         cf_so_strip="gz"
2739         cf_compress=gzip
2740   ;;
2741 esac
2742
2743 cf_edit_man=./edit_man.sh
2744 cf_man_alias=`pwd`/man_alias.sed
2745
2746 cat >$cf_edit_man <<CF_EOF
2747 #! /bin/sh
2748 # this script is generated by the configure-script CF_MAN_PAGES macro.
2749
2750 prefix="$cf_prefix"
2751 datadir="$datadir"
2752
2753 NCURSES_MAJOR="$NCURSES_MAJOR"
2754 NCURSES_MINOR="$NCURSES_MINOR"
2755 NCURSES_PATCH="$NCURSES_PATCH"
2756
2757 NCURSES_OSPEED="$NCURSES_OSPEED"
2758 TERMINFO="$TERMINFO"
2759
2760 MKDIRS="sh `cd $srcdir && pwd`/mkdirs.sh"
2761
2762 INSTALL="$INSTALL"
2763 INSTALL_DATA="$INSTALL_DATA"
2764
2765 transform="$program_transform_name"
2766
2767 TMP=\${TMPDIR-/tmp}/man\$\$
2768 trap "rm -f \$TMP" 0 1 2 5 15
2769
2770 form=\[$]1
2771 shift || exit 1
2772
2773 verb=\[$]1
2774 shift || exit 1
2775
2776 mandir=\[$]1
2777 shift || exit 1
2778
2779 srcdir=\[$]1
2780 top_srcdir=\[$]srcdir/..
2781 shift || exit 1
2782
2783 if test "\$form" = normal ; then
2784         if test "$cf_format" = yes ; then
2785         if test "$cf_inboth" = no ; then
2786                 sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
2787                 exit $?
2788         fi
2789         fi
2790         cf_subdir=\$mandir/man
2791         cf_tables=$MANPAGE_TBL
2792 else
2793         cf_subdir=\$mandir/cat
2794         cf_tables=yes
2795 fi
2796
2797 # process the list of source-files
2798 for i in \[$]* ; do
2799 case \$i in #(vi
2800 *.orig|*.rej) ;; #(vi
2801 *.[[0-9]]*)
2802         section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
2803         if test \$verb = installing ; then
2804         if test ! -d \$cf_subdir\${section} ; then
2805                 \$MKDIRS \$cf_subdir\$section
2806         fi
2807         fi
2808
2809         # replace variables in man page
2810         if test ! -f $cf_man_alias ; then
2811 cat >>$cf_man_alias <<-CF_EOF2
2812                 s,@DATADIR@,\$datadir,g
2813                 s,@TERMINFO@,\$TERMINFO,g
2814                 s,@NCURSES_MAJOR@,\$NCURSES_MAJOR,g
2815                 s,@NCURSES_MINOR@,\$NCURSES_MINOR,g
2816                 s,@NCURSES_PATCH@,\$NCURSES_PATCH,g
2817                 s,@NCURSES_OSPEED@,\$NCURSES_OSPEED,g
2818 CF_EOF
2819         ifelse($1,,,[
2820         for cf_name in $1
2821         do
2822                 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2823                 cf_name=`echo $cf_name|sed "$program_transform_name"`
2824 cat >>$cf_edit_man <<-CF_EOF
2825                 s,@$cf_NAME@,$cf_name,
2826 CF_EOF
2827         done
2828         ])
2829 cat >>$cf_edit_man <<CF_EOF
2830 CF_EOF2
2831                 echo "...made $cf_man_alias"
2832         fi
2833
2834         aliases=
2835         cf_source=\`basename \$i\`
2836         inalias=\$cf_source
2837         test ! -f \$inalias && inalias="\$srcdir/\$inalias"
2838         if test ! -f \$inalias ; then
2839                 echo .. skipped \$cf_source
2840                 continue
2841         fi
2842 CF_EOF
2843
2844 if test "$MANPAGE_ALIASES" != no ; then
2845 cat >>$cf_edit_man <<CF_EOF
2846         aliases=\`sed -f \$top_srcdir/man/manlinks.sed \$inalias |sed -f $cf_man_alias | sort -u\`
2847 CF_EOF
2848 fi
2849
2850 if test "$MANPAGE_RENAMES" = no ; then
2851 cat >>$cf_edit_man <<CF_EOF
2852         # perform program transformations for section 1 man pages
2853         if test \$section = 1 ; then
2854                 cf_target=\$cf_subdir\${section}/\`echo \$cf_source|sed "\${transform}"\`
2855         else
2856                 cf_target=\$cf_subdir\${section}/\$cf_source
2857         fi
2858 CF_EOF
2859 else
2860 cat >>$cf_edit_man <<CF_EOF
2861         cf_target=\`grep "^\$cf_source" $MANPAGE_RENAMES | $AWK '{print \[$]2}'\`
2862         if test -z "\$cf_target" ; then
2863                 echo '? missing rename for '\$cf_source
2864                 cf_target="\$cf_source"
2865         fi
2866         cf_target="\$cf_subdir\${section}/\${cf_target}"
2867
2868 CF_EOF
2869 fi
2870
2871 cat >>$cf_edit_man <<CF_EOF
2872         sed     -f $cf_man_alias \\
2873 CF_EOF
2874
2875 if test -f $MANPAGE_RENAMES ; then
2876 cat >>$cf_edit_man <<CF_EOF
2877                 < \$i | sed -f `pwd`/edit_man.sed >\$TMP
2878 CF_EOF
2879 else
2880 cat >>$cf_edit_man <<CF_EOF
2881                 < \$i >\$TMP
2882 CF_EOF
2883 fi
2884
2885 cat >>$cf_edit_man <<CF_EOF
2886 if test \$cf_tables = yes ; then
2887         tbl \$TMP >\$TMP.out
2888         mv \$TMP.out \$TMP
2889 fi
2890 CF_EOF
2891
2892 if test $with_curses_h != yes ; then
2893 cat >>$cf_edit_man <<CF_EOF
2894         sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
2895         mv \$TMP.out \$TMP
2896 CF_EOF
2897 fi
2898
2899 cat >>$cf_edit_man <<CF_EOF
2900         if test \$form = format ; then
2901                 nroff -man \$TMP >\$TMP.out
2902                 mv \$TMP.out \$TMP
2903         fi
2904 CF_EOF
2905
2906 if test -n "$cf_compress" ; then
2907 cat >>$cf_edit_man <<CF_EOF
2908         if test \$verb = installing ; then
2909         if ( $cf_compress -f \$TMP )
2910         then
2911                 mv \$TMP.$cf_so_strip \$TMP
2912         fi
2913         fi
2914         cf_target="\$cf_target.$cf_so_strip"
2915 CF_EOF
2916 fi
2917
2918 case "$MANPAGE_FORMAT" in #(vi
2919 *BSDI*)
2920 cat >>$cf_edit_man <<CF_EOF
2921         if test \$form = format ; then
2922                 # BSDI installs only .0 suffixes in the cat directories
2923                 cf_target="\`echo \$cf_target|sed -e 's/\.[[1-9]]\+[[a-z]]*/.0/'\`"
2924         fi
2925 CF_EOF
2926   ;;
2927 esac
2928
2929 cat >>$cf_edit_man <<CF_EOF
2930         suffix=\`basename \$cf_target | sed -e 's%^[[^.]]*%%'\`
2931         if test \$verb = installing ; then
2932                 echo \$verb \$cf_target
2933                 \$INSTALL_DATA \$TMP \$cf_target
2934                 test -d \$cf_subdir\${section} &&
2935                 test -n "\$aliases" && (
2936                         cd \$cf_subdir\${section} && (
2937                                 cf_source=\`echo \$cf_target |sed -e 's%^.*/\([[^/]][[^/]]*/[[^/]][[^/]]*$\)%\1%'\`
2938                                 test -n "$cf_so_strip" && cf_source=\`echo \$cf_source |sed -e 's%\.$cf_so_strip\$%%'\`
2939                                 cf_target=\`basename \$cf_target\`
2940                                 for cf_alias in \$aliases
2941                                 do
2942                                         if test \$section = 1 ; then
2943                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
2944                                         fi
2945
2946                                         if test "$MANPAGE_SYMLINKS" = yes ; then
2947                                                 if test -f \$cf_alias\${suffix} ; then
2948                                                         if ( cmp -s \$cf_target \$cf_alias\${suffix} )
2949                                                         then
2950                                                                 continue
2951                                                         fi
2952                                                 fi
2953                                                 echo .. \$verb alias \$cf_alias\${suffix}
2954                                                 rm -f \$cf_alias\${suffix}
2955                                                 $LN_S \$cf_target \$cf_alias\${suffix}
2956                                         elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
2957                                                 echo ".so \$cf_source" >\$TMP
2958 CF_EOF
2959 if test -n "$cf_compress" ; then
2960 cat >>$cf_edit_man <<CF_EOF
2961                                                 if test -n "$cf_so_strip" ; then
2962                                                         $cf_compress -f \$TMP
2963                                                         mv \$TMP.$cf_so_strip \$TMP
2964                                                 fi
2965 CF_EOF
2966 fi
2967 cat >>$cf_edit_man <<CF_EOF
2968                                                 echo .. \$verb alias \$cf_alias\${suffix}
2969                                                 rm -f \$cf_alias\${suffix}
2970                                                 \$INSTALL_DATA \$TMP \$cf_alias\${suffix}
2971                                         fi
2972                                 done
2973                         )
2974                 )
2975         elif test \$verb = removing ; then
2976                 test -f \$cf_target && (
2977                         echo \$verb \$cf_target
2978                         rm -f \$cf_target
2979                 )
2980                 test -d \$cf_subdir\${section} &&
2981                 test -n "\$aliases" && (
2982                         cd \$cf_subdir\${section} && (
2983                                 for cf_alias in \$aliases
2984                                 do
2985                                         if test \$section = 1 ; then
2986                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
2987                                         fi
2988
2989                                         echo .. \$verb alias \$cf_alias\${suffix}
2990                                         rm -f \$cf_alias\${suffix}
2991                                 done
2992                         )
2993                 )
2994         else
2995 #               echo ".hy 0"
2996                 cat \$TMP
2997         fi
2998         ;;
2999 esac
3000 done
3001
3002 if test $cf_inboth = yes ; then
3003 if test \$form != format ; then
3004         sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
3005 fi
3006 fi
3007
3008 exit 0
3009 CF_EOF
3010 chmod 755 $cf_edit_man
3011
3012 ])dnl
3013 dnl ---------------------------------------------------------------------------
3014 dnl CF_MATH_LIB version: 5 updated: 2000/05/28 01:39:10
3015 dnl -----------
3016 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
3017 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
3018 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
3019 AC_DEFUN([CF_MATH_LIB],
3020 [
3021 AC_CACHE_CHECK(if -lm needed for math functions,
3022         cf_cv_need_libm,[
3023         AC_TRY_LINK([
3024         #include <stdio.h>
3025         #include <math.h>
3026         ],
3027         [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)],
3028         [cf_cv_need_libm=no],
3029         [cf_cv_need_libm=yes])])
3030 if test "$cf_cv_need_libm" = yes
3031 then
3032 ifelse($1,,[
3033         LIBS="$LIBS -lm"
3034 ],[$1=-lm])
3035 fi
3036 ])
3037 dnl ---------------------------------------------------------------------------
3038 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
3039 dnl ----------------------
3040 dnl Check if the file-system supports mixed-case filenames.  If we're able to
3041 dnl create a lowercase name and see it as uppercase, it doesn't support that.
3042 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
3043 [
3044 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
3045 if test "$cross_compiling" = yes ; then
3046         case $target_alias in #(vi
3047         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
3048                 cf_cv_mixedcase=no
3049                 ;;
3050         *)
3051                 cf_cv_mixedcase=yes
3052                 ;;
3053         esac
3054 else
3055         rm -f conftest CONFTEST
3056         echo test >conftest
3057         if test -f CONFTEST ; then
3058                 cf_cv_mixedcase=no
3059         else
3060                 cf_cv_mixedcase=yes
3061         fi
3062         rm -f conftest CONFTEST
3063 fi
3064 ])
3065 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
3066 ])dnl
3067 dnl ---------------------------------------------------------------------------
3068 dnl CF_MKSTEMP version: 5 updated: 2006/12/16 12:33:30
3069 dnl ----------
3070 dnl Check for a working mkstemp.  This creates two files, checks that they are
3071 dnl successfully created and distinct (AmigaOS apparently fails on the last).
3072 AC_DEFUN([CF_MKSTEMP],[
3073 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
3074 rm -f conftest*
3075 AC_TRY_RUN([
3076 #include <sys/types.h>
3077 #include <stdlib.h>
3078 #include <stdio.h>
3079 #include <string.h>
3080 #include <sys/stat.h>
3081 int main()
3082 {
3083         char *tmpl = "conftestXXXXXX";
3084         char name[2][80];
3085         int n;
3086         int result = 0;
3087         int fd;
3088         struct stat sb;
3089
3090         umask(077);
3091         for (n = 0; n < 2; ++n) {
3092                 strcpy(name[n], tmpl);
3093                 if ((fd = mkstemp(name[n])) >= 0) {
3094                         if (!strcmp(name[n], tmpl)
3095                          || stat(name[n], &sb) != 0
3096                          || (sb.st_mode & S_IFMT) != S_IFREG
3097                          || (sb.st_mode & 077) != 0) {
3098                                 result = 1;
3099                         }
3100                         close(fd);
3101                 }
3102         }
3103         if (result == 0
3104          && !strcmp(name[0], name[1]))
3105                 result = 1;
3106         ${cf_cv_main_return:-return}(result);
3107 }
3108 ],[cf_cv_func_mkstemp=yes
3109 ],[cf_cv_func_mkstemp=no
3110 ],[AC_CHECK_FUNC(mkstemp)
3111 ])
3112 ])
3113 if test "$cf_cv_func_mkstemp" = yes ; then
3114         AC_DEFINE(HAVE_MKSTEMP)
3115 fi
3116 ])dnl
3117 dnl ---------------------------------------------------------------------------
3118 dnl CF_MSG_LOG version: 3 updated: 1997/09/07 14:05:52
3119 dnl ----------
3120 dnl Write a debug message to config.log, along with the line number in the
3121 dnl configure script.
3122 AC_DEFUN([CF_MSG_LOG],[
3123 echo "(line __oline__) testing $* ..." 1>&AC_FD_CC
3124 ])dnl
3125 dnl ---------------------------------------------------------------------------
3126 dnl CF_NCURSES_ABI_6 version: 1 updated: 2005/09/17 18:42:49
3127 dnl ----------------
3128 dnl Set ncurses' ABI to 6 unless overridden by explicit configure option, and
3129 dnl warn about this.
3130 AC_DEFUN([CF_NCURSES_ABI_6],[
3131 if test "${with_abi_version+set}" != set; then
3132         case $cf_cv_rel_version in
3133         5.*)
3134                 cf_cv_rel_version=6.0
3135                 cf_cv_abi_version=6
3136                 AC_MSG_WARN(Overriding ABI version to $cf_cv_abi_version)
3137                 ;;
3138         esac
3139 fi
3140 ])dnl
3141 dnl ---------------------------------------------------------------------------
3142 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
3143 dnl ------------------
3144 dnl see CF_WITH_NO_LEAKS
3145 AC_DEFUN([CF_NO_LEAKS_OPTION],[
3146 AC_MSG_CHECKING(if you want to use $1 for testing)
3147 AC_ARG_WITH($1,
3148         [$2],
3149         [AC_DEFINE($3)ifelse([$4],,[
3150          $4
3151 ])
3152         : ${with_cflags:=-g}
3153         : ${with_no_leaks:=yes}
3154          with_$1=yes],
3155         [with_$1=])
3156 AC_MSG_RESULT(${with_$1:-no})
3157
3158 case .$with_cflags in #(vi
3159 .*-g*)
3160         case .$CFLAGS in #(vi
3161         .*-g*) #(vi
3162                 ;;
3163         *)
3164                 CF_ADD_CFLAGS([-g])
3165                 ;;
3166         esac
3167         ;;
3168 esac
3169 ])dnl
3170 dnl ---------------------------------------------------------------------------
3171 dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
3172 dnl ----------------
3173 dnl Check if the given variable is a number.  If not, report an error.
3174 dnl $1 is the variable
3175 dnl $2 is the message
3176 AC_DEFUN([CF_NUMBER_SYNTAX],[
3177 if test -n "$1" ; then
3178   case $1 in #(vi
3179   [[0-9]]*) #(vi
3180         ;;
3181   *)
3182         AC_MSG_ERROR($2 is not a number: $1)
3183         ;;
3184   esac
3185 else
3186   AC_MSG_ERROR($2 value is empty)
3187 fi
3188 ])dnl
3189 dnl ---------------------------------------------------------------------------
3190 dnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
3191 dnl -------------
3192 dnl Compute the object-directory name from the given model name
3193 AC_DEFUN([CF_OBJ_SUBDIR],
3194 [
3195         case $1 in
3196         libtool) $2='obj_lo'  ;;
3197         normal)  $2='objects' ;;
3198         debug)   $2='obj_g' ;;
3199         profile) $2='obj_p' ;;
3200         shared)
3201                 case $cf_cv_system_name in #(vi
3202                 cygwin) #(vi
3203                         $2='objects' ;;
3204                 *)
3205                         $2='obj_s' ;;
3206                 esac
3207         esac
3208 ])dnl
3209 dnl ---------------------------------------------------------------------------
3210 dnl CF_PATHSEP version: 3 updated: 2001/01/12 01:23:53
3211 dnl ----------
3212 dnl Provide a value for the $PATH and similar separator
3213 AC_DEFUN([CF_PATHSEP],
3214 [
3215         case $cf_cv_system_name in
3216         os2*)   PATHSEP=';'  ;;
3217         *)      PATHSEP=':'  ;;
3218         esac
3219 ifelse($1,,,[$1=$PATHSEP])
3220         AC_SUBST(PATHSEP)
3221 ])dnl
3222 dnl ---------------------------------------------------------------------------
3223 dnl CF_PATH_SYNTAX version: 11 updated: 2006/09/02 08:55:46
3224 dnl --------------
3225 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
3226 dnl begins with one of the prefix/exec_prefix variables, and then again if the
3227 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
3228 dnl delayed evaluation of those symbols.
3229 AC_DEFUN([CF_PATH_SYNTAX],[
3230 if test "x$prefix" != xNONE; then
3231   cf_path_syntax="$prefix"
3232 else
3233   cf_path_syntax="$ac_default_prefix"
3234 fi
3235
3236 case ".[$]$1" in #(vi
3237 .\[$]\(*\)*|.\'*\'*) #(vi
3238   ;;
3239 ..|./*|.\\*) #(vi
3240   ;;
3241 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
3242   ;;
3243 .\[$]{*prefix}*) #(vi
3244   eval $1="[$]$1"
3245   case ".[$]$1" in #(vi
3246   .NONE/*)
3247     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
3248     ;;
3249   esac
3250   ;; #(vi
3251 .no|.NONE/*)
3252   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
3253   ;;
3254 *)
3255   ifelse($2,,[AC_ERROR([expected a pathname, not \"[$]$1\"])],$2)
3256   ;;
3257 esac
3258 ])dnl
3259 dnl ---------------------------------------------------------------------------
3260 dnl CF_POSIX_C_SOURCE version: 6 updated: 2005/07/14 20:25:10
3261 dnl -----------------
3262 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
3263 dnl
3264 dnl     POSIX.1-1990                            _POSIX_SOURCE
3265 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
3266 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
3267 dnl             Bindings Option
3268 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
3269 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
3270 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
3271 dnl
3272 dnl Parameters:
3273 dnl     $1 is the nominal value for _POSIX_C_SOURCE
3274 AC_DEFUN([CF_POSIX_C_SOURCE],
3275 [
3276 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
3277
3278 cf_save_CFLAGS="$CFLAGS"
3279 cf_save_CPPFLAGS="$CPPFLAGS"
3280
3281 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
3282 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
3283
3284 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
3285         CF_MSG_LOG(if the symbol is already defined go no further)
3286         AC_TRY_COMPILE([#include <sys/types.h>],[
3287 #ifndef _POSIX_C_SOURCE
3288 make an error
3289 #endif],
3290         [cf_cv_posix_c_source=no],
3291         [cf_want_posix_source=no
3292          case .$cf_POSIX_C_SOURCE in #(vi
3293          .[[12]]??*) #(vi
3294                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3295                 ;;
3296          .2) #(vi
3297                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
3298                 cf_want_posix_source=yes
3299                 ;;
3300          .*)
3301                 cf_want_posix_source=yes
3302                 ;;
3303          esac
3304          if test "$cf_want_posix_source" = yes ; then
3305                 AC_TRY_COMPILE([#include <sys/types.h>],[
3306 #ifdef _POSIX_SOURCE
3307 make an error
3308 #endif],[],
3309                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
3310          fi
3311          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
3312          CFLAGS="$cf_trim_CFLAGS"
3313          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
3314          CF_MSG_LOG(if the second compile does not leave our definition intact error)
3315          AC_TRY_COMPILE([#include <sys/types.h>],[
3316 #ifndef _POSIX_C_SOURCE
3317 make an error
3318 #endif],,
3319          [cf_cv_posix_c_source=no])
3320          CFLAGS="$cf_save_CFLAGS"
3321          CPPFLAGS="$cf_save_CPPFLAGS"
3322         ])
3323 ])
3324
3325 if test "$cf_cv_posix_c_source" != no ; then
3326         CFLAGS="$cf_trim_CFLAGS"
3327         CPPFLAGS="$cf_trim_CPPFLAGS"
3328         if test "$cf_cv_cc_u_d_options" = yes ; then
3329                 cf_temp_posix_c_source=`echo "$cf_cv_posix_c_source" | \
3330                                 sed -e 's/-D/-U/g' -e 's/=[[^   ]]*//g'`
3331                 CPPFLAGS="$CPPFLAGS $cf_temp_posix_c_source"
3332         fi
3333         CPPFLAGS="$CPPFLAGS $cf_cv_posix_c_source"
3334 fi
3335
3336 ])dnl
3337 dnl ---------------------------------------------------------------------------
3338 dnl CF_PREDEFINE version: 1 updated: 2003/07/26 17:53:56
3339 dnl ------------
3340 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
3341 dnl
3342 dnl $1 = symbol to test
3343 dnl $2 = value (if any) to use for a predefinition
3344 AC_DEFUN([CF_PREDEFINE],
3345 [
3346 AC_MSG_CHECKING(if we must define $1)
3347 AC_TRY_COMPILE([#include <sys/types.h>
3348 ],[
3349 #ifndef $1
3350 make an error
3351 #endif],[cf_result=no],[cf_result=yes])
3352 AC_MSG_RESULT($cf_result)
3353
3354 if test "$cf_result" = yes ; then
3355         CPPFLAGS="$CPPFLAGS ifelse($2,,-D$1,[-D$1=$2])"
3356 elif test "x$2" != "x" ; then
3357         AC_MSG_CHECKING(checking for compatible value versus $2)
3358         AC_TRY_COMPILE([#include <sys/types.h>
3359 ],[
3360 #if $1-$2 < 0
3361 make an error
3362 #endif],[cf_result=yes],[cf_result=no])
3363         AC_MSG_RESULT($cf_result)
3364         if test "$cf_result" = no ; then
3365                 # perhaps we can override it - try...
3366                 CPPFLAGS="$CPPFLAGS -D$1=$2"
3367         fi
3368 fi
3369 ])dnl
3370 dnl ---------------------------------------------------------------------------
3371 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
3372 dnl ------------
3373 dnl Append definitions and rules for the given programs to the subdirectory
3374 dnl Makefiles, and the recursion rule for the top-level Makefile.
3375 dnl
3376 dnl parameters
3377 dnl     $1 = script to run
3378 dnl     $2 = list of subdirectories
3379 dnl
3380 dnl variables
3381 dnl     $AWK
3382 AC_DEFUN([CF_PRG_RULES],
3383 [
3384 for cf_dir in $2
3385 do
3386         if test ! -d $srcdir/$cf_dir; then
3387                 continue
3388         elif test -f $srcdir/$cf_dir/programs; then
3389                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
3390         fi
3391 done
3392
3393 ])dnl
3394 dnl ---------------------------------------------------------------------------
3395 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
3396 dnl -----------
3397 dnl Check for awk, ensure that the check found something.
3398 AC_DEFUN([CF_PROG_AWK],
3399 [
3400 AC_PROG_AWK
3401 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
3402 ])dnl
3403 dnl ---------------------------------------------------------------------------
3404 dnl CF_PROG_CC_C_O version: 2 updated: 2006/12/16 15:55:46
3405 dnl --------------
3406 dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
3407 dnl the output file can be renamed, and allows for a shell variable that can
3408 dnl be used later.  The parameter is either CC or CXX.  The result is the
3409 dnl cache variable:
3410 dnl     $cf_cv_prog_CC_c_o
3411 dnl     $cf_cv_prog_CXX_c_o
3412 AC_DEFUN([CF_PROG_CC_C_O],
3413 [AC_REQUIRE([AC_PROG_CC])dnl
3414 AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
3415 AC_CACHE_VAL(cf_cv_prog_$1_c_o,
3416 [
3417 cat > conftest.$ac_ext <<CF_EOF
3418 #include <stdio.h>
3419 int main()
3420 {
3421         ${cf_cv_main_return:-return}(0);
3422 }
3423 CF_EOF
3424 # We do the test twice because some compilers refuse to overwrite an
3425 # existing .o file with -o, though they will create one.
3426 ac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
3427 if AC_TRY_EVAL(ac_try) &&
3428   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
3429 then
3430   eval cf_cv_prog_$1_c_o=yes
3431 else
3432   eval cf_cv_prog_$1_c_o=no
3433 fi
3434 rm -f conftest*
3435 ])dnl
3436 if test $cf_cv_prog_$1_c_o = yes; then
3437   AC_MSG_RESULT([yes])
3438 else
3439   AC_MSG_RESULT([no])
3440 fi
3441 ])dnl
3442 dnl ---------------------------------------------------------------------------
3443 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
3444 dnl --------------
3445 dnl Check if C (preprocessor) -U and -D options are processed in the order
3446 dnl given rather than by type of option.  Some compilers insist on apply all
3447 dnl of the -U options after all of the -D options.  Others allow mixing them,
3448 dnl and may predefine symbols that conflict with those we define.
3449 AC_DEFUN([CF_PROG_CC_U_D],
3450 [
3451 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
3452         cf_save_CPPFLAGS="$CPPFLAGS"
3453         CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
3454         AC_TRY_COMPILE([],[
3455 #ifndef U_D_OPTIONS
3456 make an undefined-error
3457 #endif
3458 #ifdef  D_U_OPTIONS
3459 make a defined-error
3460 #endif
3461         ],[
3462         cf_cv_cc_u_d_options=yes],[
3463         cf_cv_cc_u_d_options=no])
3464         CPPFLAGS="$cf_save_CPPFLAGS"
3465 ])
3466 ])dnl
3467 dnl ---------------------------------------------------------------------------
3468 dnl CF_PROG_EGREP version: 1 updated: 2006/09/16 11:40:59
3469 dnl -------------
3470 dnl AC_PROG_EGREP was introduced in autoconf 2.53.
3471 dnl This macro adds a check to ensure the script found something.
3472 AC_DEFUN([CF_PROG_EGREP],
3473 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
3474    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
3475     then ac_cv_prog_egrep='grep -E'
3476     else ac_cv_prog_egrep='egrep'
3477     fi])
3478  EGREP=$ac_cv_prog_egrep
3479  AC_SUBST([EGREP])
3480 test -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
3481 ])dnl
3482 dnl ---------------------------------------------------------------------------
3483 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
3484 dnl -----------
3485 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
3486 AC_DEFUN([CF_PROG_EXT],
3487 [
3488 AC_REQUIRE([CF_CHECK_CACHE])
3489 case $cf_cv_system_name in
3490 os2*)
3491     CFLAGS="$CFLAGS -Zmt"
3492     CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
3493     CXXFLAGS="$CXXFLAGS -Zmt"
3494     # autoconf's macro sets -Zexe and suffix both, which conflict:w
3495     LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
3496     ac_cv_exeext=.exe
3497     ;;
3498 esac
3499
3500 AC_EXEEXT
3501 AC_OBJEXT
3502
3503 PROG_EXT="$EXEEXT"
3504 AC_SUBST(PROG_EXT)
3505 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
3506 ])dnl
3507 dnl ---------------------------------------------------------------------------
3508 dnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
3509 dnl ---------------
3510 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
3511 dnl misc/tabset install won't work properly.  Usually this happens only when
3512 dnl using the fallback mkinstalldirs script
3513 AC_DEFUN([CF_PROG_INSTALL],
3514 [AC_PROG_INSTALL
3515 case $INSTALL in
3516 /*)
3517   ;;
3518 *)
3519   CF_DIRNAME(cf_dir,$INSTALL)
3520   test -z "$cf_dir" && cf_dir=.
3521   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
3522   ;;
3523 esac
3524 ])dnl
3525 dnl ---------------------------------------------------------------------------
3526 dnl CF_PROG_LDCONFIG version: 1 updated: 2003/09/20 17:07:55
3527 dnl ----------------
3528 dnl Check for ldconfig, needed to fixup shared libraries that would be built
3529 dnl and then used in the install.
3530 AC_DEFUN([CF_PROG_LDCONFIG],[
3531 if test "$cross_compiling" = yes ; then
3532   LDCONFIG=:
3533 else
3534 case "$cf_cv_system_name" in #(vi
3535 freebsd*) #(vi
3536   test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
3537   ;;
3538 *) LDPATH=$PATH:/sbin:/usr/sbin
3539   AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
3540   ;;
3541 esac
3542 fi
3543 AC_SUBST(LDCONFIG)
3544 ])dnl
3545 dnl ---------------------------------------------------------------------------
3546 dnl CF_PROG_LINT version: 1 updated: 2006/09/16 11:40:59
3547 dnl ------------
3548 AC_DEFUN([CF_PROG_LINT],
3549 [
3550 AC_CHECK_PROGS(LINT, tdlint lint alint)
3551 AC_SUBST(LINT_OPTS)
3552 ])dnl
3553 dnl ---------------------------------------------------------------------------
3554 dnl CF_REGEX version: 3 updated: 1997/11/01 14:26:01
3555 dnl --------
3556 dnl Attempt to determine if we've got one of the flavors of regular-expression
3557 dnl code that we can support.
3558 AC_DEFUN([CF_REGEX],
3559 [
3560 AC_MSG_CHECKING([for regular-expression headers])
3561 AC_CACHE_VAL(cf_cv_regex,[
3562 AC_TRY_LINK([#include <sys/types.h>
3563 #include <regex.h>],[
3564         regex_t *p;
3565         int x = regcomp(p, "", 0);
3566         int y = regexec(p, "", 0, 0, 0);
3567         regfree(p);
3568         ],[cf_cv_regex="regex.h"],[
3569         AC_TRY_LINK([#include <regexp.h>],[
3570                 char *p = compile("", "", "", 0);
3571                 int x = step("", "");
3572         ],[cf_cv_regex="regexp.h"],[
3573                 cf_save_LIBS="$LIBS"
3574                 LIBS="-lgen $LIBS"
3575                 AC_TRY_LINK([#include <regexpr.h>],[
3576                         char *p = compile("", "", "");
3577                         int x = step("", "");
3578                 ],[cf_cv_regex="regexpr.h"],[LIBS="$cf_save_LIBS"])])])
3579 ])
3580 AC_MSG_RESULT($cf_cv_regex)
3581 case $cf_cv_regex in
3582         regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS) ;;
3583         regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS) ;;
3584         regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS) ;;
3585 esac
3586 ])dnl
3587 dnl ---------------------------------------------------------------------------
3588 dnl CF_REMOVE_DEFINE version: 2 updated: 2005/07/09 16:12:18
3589 dnl ----------------
3590 dnl Remove all -U and -D options that refer to the given symbol from a list
3591 dnl of C compiler options.  This works around the problem that not all
3592 dnl compilers process -U and -D options from left-to-right, so a -U option
3593 dnl cannot be used to cancel the effect of a preceding -D option.
3594 dnl
3595 dnl $1 = target (which could be the same as the source variable)
3596 dnl $2 = source (including '$')
3597 dnl $3 = symbol to remove
3598 define([CF_REMOVE_DEFINE],
3599 [
3600 # remove $3 symbol from $2
3601 $1=`echo "$2" | \
3602         sed     -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[[       ]]/ /g' \
3603                 -e 's/-[[UD]]$3\(=[[^   ]]*\)\?[$]//g'`
3604 ])dnl
3605 dnl ---------------------------------------------------------------------------
3606 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
3607 dnl -------------
3608 dnl Remove the given library from the symbol
3609 dnl
3610 dnl $1 = target (which could be the same as the source variable)
3611 dnl $2 = source (including '$')
3612 dnl $3 = library to remove
3613 define([CF_REMOVE_LIB],
3614 [
3615 # remove $3 library from $2
3616 $1=`echo "$2" | sed -e 's/-l$3[[        ]]//g' -e 's/-l$3[$]//'`
3617 ])dnl
3618 dnl ---------------------------------------------------------------------------
3619 dnl CF_SHARED_OPTS version: 46 updated: 2007/02/24 18:58:09
3620 dnl --------------
3621 dnl --------------
3622 dnl Attempt to determine the appropriate CC/LD options for creating a shared
3623 dnl library.
3624 dnl
3625 dnl Note: ${LOCAL_LDFLAGS} is used to link executables that will run within the
3626 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
3627 dnl We avoid compiling-in a ../lib path for the shared library since that can
3628 dnl lead to unexpected results at runtime.
3629 dnl ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared libraries
3630 dnl are compiled in ../../lib
3631 dnl
3632 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
3633 dnl to install symbolic links to the rel/abi versions of shared libraries.
3634 dnl
3635 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
3636 dnl version when making symbolic links.
3637 dnl
3638 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
3639 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
3640 dnl (ex: libncurses.so.<ver>).
3641 dnl
3642 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
3643 AC_DEFUN([CF_SHARED_OPTS],
3644 [
3645         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
3646         LOCAL_LDFLAGS=
3647         LOCAL_LDFLAGS2=
3648         LD_SHARED_OPTS=
3649         INSTALL_LIB="-m 644"
3650
3651         cf_cv_do_symlinks=no
3652
3653         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
3654         AC_ARG_WITH(shlib-version,
3655         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
3656         [test -z "$withval" && withval=auto
3657         case $withval in #(vi
3658         yes) #(vi
3659                 cf_cv_shlib_version=auto
3660                 ;;
3661         rel|abi|auto|no) #(vi
3662                 cf_cv_shlib_version=$withval
3663                 ;;
3664         *)
3665                 AC_ERROR([option value must be one of: rel, abi, auto or no])
3666                 ;;
3667         esac
3668         ],[cf_cv_shlib_version=auto])
3669         AC_MSG_RESULT($cf_cv_shlib_version)
3670
3671         cf_cv_rm_so_locs=no
3672
3673         # Some less-capable ports of gcc support only -fpic
3674         CC_SHARED_OPTS=
3675         if test "$GCC" = yes
3676         then
3677                 AC_MSG_CHECKING(which $CC option to use)
3678                 cf_save_CFLAGS="$CFLAGS"
3679                 for CC_SHARED_OPTS in -fPIC -fpic ''
3680                 do
3681                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
3682                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
3683                 done
3684                 AC_MSG_RESULT($CC_SHARED_OPTS)
3685                 CFLAGS="$cf_save_CFLAGS"
3686         fi
3687
3688         cf_cv_shlib_version_infix=no
3689
3690         case $cf_cv_system_name in
3691         beos*)
3692                 MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
3693                 ;;
3694         cygwin*)
3695                 CC_SHARED_OPTS=
3696                 MK_SHARED_LIB='sh ../mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
3697                 cf_cv_shlib_version=cygdll
3698                 cf_cv_shlib_version_infix=cygdll
3699                 cat >mk_shared_lib.sh <<-CF_EOF
3700                 #!/bin/sh
3701                 SHARED_LIB=\[$]1
3702                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
3703                 shift
3704                 cat <<-EOF
3705                 Linking shared library
3706                 ** SHARED_LIB \[$]SHARED_LIB
3707                 ** IMPORT_LIB \[$]IMPORT_LIB
3708 EOF
3709                 exec \[$]* -shared -Wl,--out-implib=../lib/\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o ../lib/\[$]{SHARED_LIB}
3710 CF_EOF
3711                 chmod +x mk_shared_lib.sh 
3712                 ;;
3713         darwin*)
3714                 EXTRA_CFLAGS="-no-cpp-precomp"
3715                 CC_SHARED_OPTS="-dynamic"
3716                 MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
3717                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
3718                 cf_cv_shlib_version_infix=yes
3719                 AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
3720                         cf_save_LDFLAGS=$LDFLAGS
3721                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
3722                         AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
3723                                 LDFLAGS=$cf_save_LDFLAGS])
3724                 if test $cf_cv_ldflags_search_paths_first = yes; then
3725                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
3726                 fi
3727                 ;;
3728         hpux*)
3729                 # (tested with gcc 2.7.2 -- I don't have c89)
3730                 if test "$GCC" = yes; then
3731                         LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
3732                 else
3733                         CC_SHARED_OPTS='+Z'
3734                         LD_SHARED_OPTS='-Wl,+b,${libdir}'
3735                 fi
3736                 MK_SHARED_LIB='${LD} +b ${libdir} -b -o $[@]'
3737                 # HP-UX shared libraries must be executable, and should be
3738                 # readonly to exploit a quirk in the memory manager.
3739                 INSTALL_LIB="-m 555"
3740                 ;;
3741         irix*)
3742                 if test "$cf_cv_ld_rpath" = yes ; then
3743                         if test "$GCC" = yes; then
3744                                 cf_ld_rpath_opt="-Wl,-rpath,"
3745                                 EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
3746                         else
3747                                 cf_ld_rpath_opt="-rpath "
3748                                 EXTRA_LDFLAGS="-rpath \${libdir} $EXTRA_LDFLAGS"
3749                         fi
3750                 fi
3751                 # tested with IRIX 5.2 and 'cc'.
3752                 if test "$GCC" != yes; then
3753                         CC_SHARED_OPTS='-KPIC'
3754                 fi
3755                 MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
3756                 cf_cv_rm_so_locs=yes
3757                 ;;
3758         linux*|gnu*|k*bsd*-gnu)
3759                 if test "$DFT_LWR_MODEL" = "shared" ; then
3760                         LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
3761                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3762                 fi
3763                 if test "$cf_cv_ld_rpath" = yes ; then
3764                         cf_ld_rpath_opt="-Wl,-rpath,"
3765                         EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
3766                 fi
3767                 CF_SHARED_SONAME
3768                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_shared_soname',-stats,-lc -o $[@]'
3769                 ;;
3770         openbsd[[2-9]].*)
3771                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3772                 MK_SHARED_LIB='${LD} -Bshareable -soname,`basename $[@].${ABI_VERSION}` -o $[@]'
3773                 ;;
3774         openbsd*|freebsd[[12]].*)
3775                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3776                 MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
3777                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3778                 ;;
3779         freebsd*)
3780                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3781                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
3782                         LOCAL_LDFLAGS="-rpath \$(LOCAL_LIBDIR)"
3783                         LOCAL_LDFLAGS2="-rpath \${libdir} $LOCAL_LDFLAGS"
3784                         cf_ld_rpath_opt="-rpath "
3785                         EXTRA_LDFLAGS="-rpath \${libdir} $EXTRA_LDFLAGS"
3786                 fi
3787                 CF_SHARED_SONAME
3788                 MK_SHARED_LIB='${LD} -Bshareable -soname=`basename $[@]` -o $[@]'
3789                 ;;
3790         netbsd*)
3791                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
3792                 test "$cf_cv_ld_rpath" = yes && cf_ld_rpath_opt="-Wl,-rpath,"
3793                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_ld_rpath" = yes ; then
3794                         LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
3795                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3796                         EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
3797                         if test "$cf_cv_shlib_version" = auto; then
3798                         if test -f /usr/libexec/ld.elf_so; then
3799                                 cf_cv_shlib_version=abi
3800                         else
3801                                 cf_cv_shlib_version=rel
3802                         fi
3803                         fi
3804                         CF_SHARED_SONAME
3805                         MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_shared_soname' -o $[@]'
3806                 else
3807                         MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
3808                 fi
3809                 ;;
3810         osf*|mls+*)
3811                 # tested with OSF/1 V3.2 and 'cc'
3812                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
3813                 # link with shared libs).
3814                 MK_SHARED_LIB='${LD} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
3815                 case $host_os in
3816                 osf4*)
3817                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
3818                         ;;
3819                 esac
3820                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
3821                 if test "$DFT_LWR_MODEL" = "shared" ; then
3822                         LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
3823                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3824                 fi
3825                 if test "$cf_cv_ld_rpath" = yes ; then
3826                         cf_ld_rpath_opt="-rpath"
3827                         # EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
3828                 fi
3829                 cf_cv_rm_so_locs=yes
3830                 ;;
3831         sco3.2v5*)  # (also uw2* and UW7) hops 13-Apr-98
3832                 # tested with osr5.0.5
3833                 if test "$GCC" != yes; then
3834                         CC_SHARED_OPTS='-belf -KPIC'
3835                 fi
3836                 MK_SHARED_LIB='${LD} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
3837                 if test "$cf_cv_ld_rpath" = yes ; then
3838                         # only way is to set LD_RUN_PATH but no switch for it
3839                         RUN_PATH=$libdir
3840                 fi
3841                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3842                 LINK_PROGS='LD_RUN_PATH=${libdir}'
3843                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
3844                 ;;
3845         sunos4*)
3846                 # tested with SunOS 4.1.1 and gcc 2.7.0
3847                 if test "$GCC" != yes; then
3848                         CC_SHARED_OPTS='-KPIC'
3849                 fi
3850                 MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
3851                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
3852                 ;;
3853         solaris2*)
3854                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
3855                 if test "$GCC" != yes; then
3856                         CC_SHARED_OPTS='-KPIC'
3857                 fi
3858                 if test "$DFT_LWR_MODEL" = "shared" ; then
3859                         LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
3860                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
3861                 fi
3862                 if test "$cf_cv_ld_rpath" = yes ; then
3863                         cf_ld_rpath_opt="-R"
3864                         EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
3865                 fi
3866                 CF_SHARED_SONAME
3867                 MK_SHARED_LIB='${CC} -dy -G -h '$cf_shared_soname' -o $[@]'
3868                 ;;
3869         sysv5uw7*|unix_sv*)
3870                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
3871                 if test "$GCC" != yes; then
3872                         CC_SHARED_OPTS='-KPIC'
3873                 fi
3874                 MK_SHARED_LIB='${LD} -d y -G -o [$]@'
3875                 ;;
3876         *)
3877                 CC_SHARED_OPTS='unknown'
3878                 MK_SHARED_LIB='echo unknown'
3879                 ;;
3880         esac
3881
3882         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
3883         case "$cf_cv_shlib_version" in #(vi
3884         rel|abi)
3885                 case "$MK_SHARED_LIB" in #(vi
3886                 *'-o $[@]')
3887                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
3888                         ;;
3889                 *)
3890                         AC_MSG_WARN(ignored --with-shlib-version)
3891                         ;;
3892                 esac
3893                 ;;
3894         esac
3895
3896         if test -n "$cf_ld_rpath_opt" ; then
3897                 AC_MSG_CHECKING(if we need a space after rpath option)
3898                 cf_save_LIBS="$LIBS"
3899                 LIBS="$LIBS ${cf_ld_rpath_opt}$libdir"
3900                 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
3901                 LIBS="$cf_save_LIBS"
3902                 AC_MSG_RESULT($cf_rpath_space)
3903                 test "$cf_rpath_space" = yes && cf_ld_rpath_opt="$cf_ld_rpath_opt "
3904                 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${libdir}"
3905         fi
3906
3907         AC_SUBST(CC_SHARED_OPTS)
3908         AC_SUBST(LD_SHARED_OPTS)
3909         AC_SUBST(MK_SHARED_LIB)
3910         AC_SUBST(LINK_PROGS)
3911         AC_SUBST(LINK_TESTS)
3912         AC_SUBST(EXTRA_LDFLAGS)
3913         AC_SUBST(LOCAL_LDFLAGS)
3914         AC_SUBST(LOCAL_LDFLAGS2)
3915         AC_SUBST(INSTALL_LIB)
3916 ])dnl
3917 dnl ---------------------------------------------------------------------------
3918 dnl CF_SHARED_SONAME version: 2 updated: 2006/10/21 12:33:41
3919 dnl ----------------
3920 dnl utility macro for CF_SHARED_OPTS, constructs "$cf_shared_soname" for
3921 dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
3922 dnl option.
3923 dnl
3924 dnl $1 is the default that should be used for "$cf_cv_shlib_version".
3925 dnl If missing, use "rel".
3926 define([CF_SHARED_SONAME],
3927 [
3928         test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
3929         if test "$cf_cv_shlib_version" = rel; then
3930                 cf_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
3931         else
3932                 cf_shared_soname='`basename $[@]`'
3933         fi
3934 ])
3935 dnl ---------------------------------------------------------------------------
3936 dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
3937 dnl -----------
3938 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
3939 dnl programs need this test).
3940 dnl
3941 dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
3942 dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
3943 dnl winsize declaration is left alone - we may revisit this if Apple choose to
3944 dnl break that part of the interface as well.
3945 AC_DEFUN([CF_SIGWINCH],
3946 [
3947 AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
3948         AC_TRY_COMPILE([
3949 #include <sys/types.h>
3950 #include <sys/signal.h>
3951 ],[int x = SIGWINCH],
3952         [cf_cv_define_sigwinch=yes],
3953         [AC_TRY_COMPILE([
3954 #undef _XOPEN_SOURCE
3955 #undef _POSIX_SOURCE
3956 #undef _POSIX_C_SOURCE
3957 #include <sys/types.h>
3958 #include <sys/signal.h>
3959 ],[int x = SIGWINCH],
3960         [cf_cv_define_sigwinch=maybe],
3961         [cf_cv_define_sigwinch=no])
3962 ])
3963 ])
3964
3965 if test "$cf_cv_define_sigwinch" = maybe ; then
3966 AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
3967 cf_cv_fixup_sigwinch=unknown
3968 cf_sigwinch=32
3969 while test $cf_sigwinch != 1
3970 do
3971         AC_TRY_COMPILE([
3972 #undef _XOPEN_SOURCE
3973 #undef _POSIX_SOURCE
3974 #undef _POSIX_C_SOURCE
3975 #include <sys/types.h>
3976 #include <sys/signal.h>
3977 ],[
3978 #if SIGWINCH != $cf_sigwinch
3979 make an error
3980 #endif
3981 int x = SIGWINCH],
3982         [cf_cv_fixup_sigwinch=$cf_sigwinch
3983          break])
3984
3985 cf_sigwinch=`expr $cf_sigwinch - 1`
3986 done
3987 ])
3988
3989         if test "$cf_cv_fixup_sigwinch" != unknown ; then
3990                 CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
3991         fi
3992 fi
3993 ])dnl
3994 dnl ---------------------------------------------------------------------------
3995 dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
3996 dnl ---------------
3997 dnl signal handler, but there are some gcc depedencies in that recommendation.
3998 dnl Try anyway.
3999 AC_DEFUN([CF_SIG_ATOMIC_T],
4000 [
4001 AC_MSG_CHECKING(for signal global datatype)
4002 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
4003         for cf_type in \
4004                 "volatile sig_atomic_t" \
4005                 "sig_atomic_t" \
4006                 "int"
4007         do
4008         AC_TRY_COMPILE([
4009 #include <sys/types.h>
4010 #include <signal.h>
4011 #include <stdio.h>
4012
4013 extern $cf_type x;
4014 $cf_type x;
4015 static void handler(int sig)
4016 {
4017         x = 5;
4018 }],
4019                 [signal(SIGINT, handler);
4020                  x = 1],
4021                 [cf_cv_sig_atomic_t=$cf_type],
4022                 [cf_cv_sig_atomic_t=no])
4023                 test "$cf_cv_sig_atomic_t" != no && break
4024         done
4025         ])
4026 AC_MSG_RESULT($cf_cv_sig_atomic_t)
4027 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t)
4028 ])dnl
4029 dnl ---------------------------------------------------------------------------
4030 dnl CF_SIZECHANGE version: 8 updated: 2000/11/04 12:22:16
4031 dnl -------------
4032 dnl Check for definitions & structures needed for window size-changing
4033 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
4034 AC_DEFUN([CF_SIZECHANGE],
4035 [
4036 AC_REQUIRE([CF_STRUCT_TERMIOS])
4037 AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
4038     cf_cv_sizechange=unknown
4039     cf_save_CPPFLAGS="$CPPFLAGS"
4040
4041 for cf_opts in "" "NEED_PTEM_H"
4042 do
4043
4044     CPPFLAGS="$cf_save_CPPFLAGS"
4045     test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
4046     AC_TRY_COMPILE([#include <sys/types.h>
4047 #ifdef HAVE_TERMIOS_H
4048 #include <termios.h>
4049 #else
4050 #ifdef HAVE_TERMIO_H
4051 #include <termio.h>
4052 #endif
4053 #endif
4054 #ifdef NEED_PTEM_H
4055 /* This is a workaround for SCO:  they neglected to define struct winsize in
4056  * termios.h -- it's only in termio.h and ptem.h
4057  */
4058 #include        <sys/stream.h>
4059 #include        <sys/ptem.h>
4060 #endif
4061 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
4062 #include <sys/ioctl.h>
4063 #endif
4064 ],[
4065 #ifdef TIOCGSIZE
4066         struct ttysize win;     /* FIXME: what system is this? */
4067         int y = win.ts_lines;
4068         int x = win.ts_cols;
4069 #else
4070 #ifdef TIOCGWINSZ
4071         struct winsize win;
4072         int y = win.ws_row;
4073         int x = win.ws_col;
4074 #else
4075         no TIOCGSIZE or TIOCGWINSZ
4076 #endif /* TIOCGWINSZ */
4077 #endif /* TIOCGSIZE */
4078         ],
4079         [cf_cv_sizechange=yes],
4080         [cf_cv_sizechange=no])
4081
4082         CPPFLAGS="$cf_save_CPPFLAGS"
4083         if test "$cf_cv_sizechange" = yes ; then
4084                 echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
4085                 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
4086                 break
4087         fi
4088 done
4089 ])
4090 if test "$cf_cv_sizechange" != no ; then
4091         AC_DEFINE(HAVE_SIZECHANGE)
4092         case $cf_cv_sizechange in #(vi
4093         NEED*)
4094                 AC_DEFINE_UNQUOTED($cf_cv_sizechange )
4095                 ;;
4096         esac
4097 fi
4098 ])dnl
4099 dnl ---------------------------------------------------------------------------
4100 dnl CF_SRC_MODULES version: 18 updated: 2005/05/28 12:58:54
4101 dnl --------------
4102 dnl For each parameter, test if the source-directory exists, and if it contains
4103 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
4104 dnl use in CF_LIB_RULES.
4105 dnl
4106 dnl This uses the configured value to make the lists SRC_SUBDIRS and
4107 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
4108 AC_DEFUN([CF_SRC_MODULES],
4109 [
4110 AC_MSG_CHECKING(for src modules)
4111
4112 # dependencies and linker-arguments for test-programs
4113 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
4114 TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEP2"
4115 if test "$DFT_LWR_MODEL" = "libtool"; then
4116         TEST_ARGS="${TEST_DEPS}"
4117         TEST_ARG2="${TEST_DEP2}"
4118 else
4119         TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
4120         TEST_ARG2="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARG2"
4121 fi
4122
4123 cf_cv_src_modules=
4124 for cf_dir in $1
4125 do
4126         if test -f $srcdir/$cf_dir/modules; then
4127
4128                 # We may/may not have tack in the distribution, though the
4129                 # makefile is.
4130                 if test $cf_dir = tack ; then
4131                         if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
4132                                 continue
4133                         fi
4134                 fi
4135
4136                 if test -z "$cf_cv_src_modules"; then
4137                         cf_cv_src_modules=$cf_dir
4138                 else
4139                         cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
4140                 fi
4141
4142                 # Make the ncurses_cfg.h file record the library interface files as
4143                 # well.  These are header files that are the same name as their
4144                 # directory.  Ncurses is the only library that does not follow
4145                 # that pattern.
4146                 if test $cf_dir = tack ; then
4147                         continue
4148                 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
4149                         CF_UPPER(cf_have_include,$cf_dir)
4150                         AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
4151                         AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
4152                         TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
4153                         TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEP2"
4154                         if test "$DFT_LWR_MODEL" = "libtool"; then
4155                                 TEST_ARGS="${TEST_DEPS}"
4156                                 TEST_ARG2="${TEST_DEP2}"
4157                         else
4158                                 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
4159                                 TEST_ARG2="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARG2"
4160                         fi
4161                 fi
4162         fi
4163 done
4164 AC_MSG_RESULT($cf_cv_src_modules)
4165
4166 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
4167 TEST_ARG2="-L${LIB_2ND} $TEST_ARG2"
4168
4169 AC_SUBST(TEST_ARGS)
4170 AC_SUBST(TEST_DEPS)
4171
4172 AC_SUBST(TEST_ARG2)
4173 AC_SUBST(TEST_DEP2)
4174
4175 SRC_SUBDIRS="man include"
4176 for cf_dir in $cf_cv_src_modules
4177 do
4178         SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
4179 done
4180 SRC_SUBDIRS="$SRC_SUBDIRS test"
4181 test -z "$MAKE_TERMINFO" && SRC_SUBDIRS="$SRC_SUBDIRS misc"
4182 test "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
4183
4184 ADA_SUBDIRS=
4185 if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
4186    SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
4187    ADA_SUBDIRS="gen src samples"
4188 fi
4189
4190 SUB_MAKEFILES=
4191 for cf_dir in $SRC_SUBDIRS
4192 do
4193         SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
4194 done
4195
4196 if test -n "$ADA_SUBDIRS"; then
4197    for cf_dir in $ADA_SUBDIRS
4198    do
4199       SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
4200    done
4201    AC_SUBST(ADA_SUBDIRS)
4202 fi
4203 ])dnl
4204 dnl ---------------------------------------------------------------------------
4205 dnl CF_STDCPP_LIBRARY version: 5 updated: 2000/08/12 23:18:52
4206 dnl -----------------
4207 dnl Check for -lstdc++, which is GNU's standard C++ library.
4208 AC_DEFUN([CF_STDCPP_LIBRARY],
4209 [
4210 if test -n "$GXX" ; then
4211 case $cf_cv_system_name in #(vi
4212 os2*) #(vi
4213         cf_stdcpp_libname=stdcpp
4214         ;;
4215 *)
4216         cf_stdcpp_libname=stdc++
4217         ;;
4218 esac
4219 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
4220         cf_save="$LIBS"
4221         LIBS="$LIBS -l$cf_stdcpp_libname"
4222 AC_TRY_LINK([
4223 #include <strstream.h>],[
4224 char buf[80];
4225 strstreambuf foo(buf, sizeof(buf))
4226 ],
4227         [cf_cv_libstdcpp=yes],
4228         [cf_cv_libstdcpp=no])
4229         LIBS="$cf_save"
4230 ])
4231 test "$cf_cv_libstdcpp" = yes && CXXLIBS="$CXXLIBS -l$cf_stdcpp_libname"
4232 fi
4233 ])dnl
4234 dnl ---------------------------------------------------------------------------
4235 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
4236 dnl --------------
4237 dnl     Remove "-g" option from the compiler options
4238 AC_DEFUN([CF_STRIP_G_OPT],
4239 [$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
4240 dnl ---------------------------------------------------------------------------
4241 dnl CF_STRUCT_SIGACTION version: 3 updated: 2000/08/12 23:18:52
4242 dnl -------------------
4243 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
4244 dnl do this if we've found the sigaction function.
4245 dnl
4246 dnl If needed, define SVR4_ACTION.
4247 AC_DEFUN([CF_STRUCT_SIGACTION],[
4248 if test "$ac_cv_func_sigaction" = yes; then
4249 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
4250 AC_TRY_COMPILE([
4251 #include <sys/types.h>
4252 #include <signal.h>],
4253         [struct sigaction act],
4254         [sigact_bad=no],
4255         [
4256 AC_TRY_COMPILE([
4257 #define _POSIX_SOURCE
4258 #include <sys/types.h>
4259 #include <signal.h>],
4260         [struct sigaction act],
4261         [sigact_bad=yes
4262          AC_DEFINE(SVR4_ACTION)],
4263          [sigact_bad=unknown])])
4264 AC_MSG_RESULT($sigact_bad)
4265 fi
4266 ])dnl
4267 dnl ---------------------------------------------------------------------------
4268 dnl CF_STRUCT_TERMIOS version: 5 updated: 2000/11/04 12:22:46
4269 dnl -----------------
4270 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
4271 dnl If so, define SVR4_TERMIO
4272 AC_DEFUN([CF_STRUCT_TERMIOS],[
4273 AC_CHECK_HEADERS( \
4274 termio.h \
4275 termios.h \
4276 unistd.h \
4277 )
4278 if test "$ISC" = yes ; then
4279         AC_CHECK_HEADERS( sys/termio.h )
4280 fi
4281 if test "$ac_cv_header_termios_h" = yes ; then
4282         case "$CFLAGS $CPPFLAGS" in
4283         *-D_POSIX_SOURCE*)
4284                 termios_bad=dunno ;;
4285         *)      termios_bad=maybe ;;
4286         esac
4287         if test "$termios_bad" = maybe ; then
4288         AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
4289         AC_TRY_COMPILE([#include <termios.h>],
4290                 [struct termios foo; int x = foo.c_iflag],
4291                 termios_bad=no, [
4292                 AC_TRY_COMPILE([
4293 #define _POSIX_SOURCE
4294 #include <termios.h>],
4295                         [struct termios foo; int x = foo.c_iflag],
4296                         termios_bad=unknown,
4297                         termios_bad=yes AC_DEFINE(SVR4_TERMIO))
4298                         ])
4299         AC_MSG_RESULT($termios_bad)
4300         fi
4301 fi
4302 ])dnl
4303 dnl ---------------------------------------------------------------------------
4304 dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
4305 dnl --------
4306 dnl     Shorthand macro for substituting things that the user may override
4307 dnl     with an environment variable.
4308 dnl
4309 dnl     $1 = long/descriptive name
4310 dnl     $2 = environment variable
4311 dnl     $3 = default value
4312 AC_DEFUN([CF_SUBST],
4313 [AC_CACHE_VAL(cf_cv_subst_$2,[
4314 AC_MSG_CHECKING(for $1 (symbol $2))
4315 CF_SUBST_IF([-z "[$]$2"], [$2], [$3])
4316 cf_cv_subst_$2=[$]$2
4317 AC_MSG_RESULT([$]$2)
4318 ])
4319 ])dnl
4320 dnl ---------------------------------------------------------------------------
4321 dnl CF_SUBST_IF version: 2 updated: 2006/06/17 12:33:03
4322 dnl -----------
4323 dnl     Shorthand macro for substituting things that the user may override
4324 dnl     with an environment variable.
4325 dnl
4326 dnl     $1 = condition to pass to "test"
4327 dnl     $2 = environment variable
4328 dnl     $3 = value if the test succeeds
4329 dnl     $4 = value if the test fails
4330 AC_DEFUN([CF_SUBST_IF],
4331 [
4332 if test $1 ; then
4333         $2=$3
4334 ifelse($4,,,[else
4335         $2=$4])
4336 fi
4337 AC_SUBST($2)
4338 ])dnl
4339 dnl ---------------------------------------------------------------------------
4340 dnl CF_SUBST_NCURSES_VERSION version: 8 updated: 2006/09/16 11:40:59
4341 dnl ------------------------
4342 dnl Get the version-number for use in shared-library naming, etc.
4343 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
4344 [
4345 AC_REQUIRE([CF_PROG_EGREP])
4346 NCURSES_MAJOR="`$ac_cv_prog_egrep '^NCURSES_MAJOR[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
4347 NCURSES_MINOR="`$ac_cv_prog_egrep '^NCURSES_MINOR[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
4348 NCURSES_PATCH="`$ac_cv_prog_egrep '^NCURSES_PATCH[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
4349 cf_cv_abi_version=${NCURSES_MAJOR}
4350 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
4351 dnl Show the computed version, for logging
4352 cf_cv_timestamp=`date`
4353 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
4354 dnl We need these values in the generated headers
4355 AC_SUBST(NCURSES_MAJOR)
4356 AC_SUBST(NCURSES_MINOR)
4357 AC_SUBST(NCURSES_PATCH)
4358 dnl We need these values in the generated makefiles
4359 AC_SUBST(cf_cv_rel_version)
4360 AC_SUBST(cf_cv_abi_version)
4361 AC_SUBST(cf_cv_builtin_bool)
4362 AC_SUBST(cf_cv_header_stdbool_h)
4363 AC_SUBST(cf_cv_type_of_bool)dnl
4364 ])dnl
4365 dnl ---------------------------------------------------------------------------
4366 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
4367 dnl ------------------
4368 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
4369 dnl older SCO configurations.
4370 AC_DEFUN([CF_SYS_TIME_SELECT],
4371 [
4372 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
4373 AC_CACHE_VAL(cf_cv_sys_time_select,[
4374 AC_TRY_COMPILE([
4375 #include <sys/types.h>
4376 #ifdef HAVE_SYS_TIME_H
4377 #include <sys/time.h>
4378 #endif
4379 #ifdef HAVE_SYS_SELECT_H
4380 #include <sys/select.h>
4381 #endif
4382 ],[],[cf_cv_sys_time_select=yes],
4383      [cf_cv_sys_time_select=no])
4384      ])
4385 AC_MSG_RESULT($cf_cv_sys_time_select)
4386 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT)
4387 ])dnl
4388 dnl ---------------------------------------------------------------------------
4389 dnl CF_TOP_BUILDDIR version: 1 updated: 2006/10/15 16:33:23
4390 dnl ---------------
4391 dnl Define a top_builddir symbol, for applications that need an absolute path.
4392 AC_DEFUN([CF_TOP_BUILDDIR],
4393 [
4394 top_builddir=`pwd`
4395 AC_SUBST(top_builddir)
4396 ])dnl
4397 dnl ---------------------------------------------------------------------------
4398 dnl CF_TYPEOF_CHTYPE version: 8 updated: 2006/12/16 12:33:30
4399 dnl ----------------
4400 dnl Determine the type we should use for chtype (and attr_t, which is treated
4401 dnl as the same thing).  We want around 32 bits, so on most machines want a
4402 dnl long, but on newer 64-bit machines, probably want an int.  If we're using
4403 dnl wide characters, we have to have a type compatible with that, as well.
4404 AC_DEFUN([CF_TYPEOF_CHTYPE],
4405 [
4406 AC_MSG_CHECKING([for type of chtype])
4407 AC_CACHE_VAL(cf_cv_typeof_chtype,[
4408                 AC_TRY_RUN([
4409 #define WANT_BITS 31
4410 #include <stdio.h>
4411 int main()
4412 {
4413         FILE *fp = fopen("cf_test.out", "w");
4414         if (fp != 0) {
4415                 char *result = "long";
4416                 if (sizeof(unsigned long) > sizeof(unsigned int)) {
4417                         int n;
4418                         unsigned int x, y;
4419                         for (n = 0; n < WANT_BITS; n++) {
4420                                 x = (1 << n);
4421                                 y = (x >> n);
4422                                 if (y != 1 || x == 0) {
4423                                         x = 0;
4424                                         break;
4425                                 }
4426                         }
4427                         /*
4428                          * If x is nonzero, an int is big enough for the bits
4429                          * that we want.
4430                          */
4431                         result = (x != 0) ? "int" : "long";
4432                 }
4433                 fputs(result, fp);
4434                 fclose(fp);
4435         }
4436         ${cf_cv_main_return:-return}(0);
4437 }
4438                 ],
4439                 [cf_cv_typeof_chtype=`cat cf_test.out`],
4440                 [cf_cv_typeof_chtype=long],
4441                 [cf_cv_typeof_chtype=long])
4442                 rm -f cf_test.out
4443         ])
4444 AC_MSG_RESULT($cf_cv_typeof_chtype)
4445
4446 AC_SUBST(cf_cv_typeof_chtype)
4447 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype)
4448 ])dnl
4449 dnl ---------------------------------------------------------------------------
4450 dnl CF_TYPE_SIGACTION version: 3 updated: 2000/08/12 23:18:52
4451 dnl -----------------
4452 dnl
4453 AC_DEFUN([CF_TYPE_SIGACTION],
4454 [
4455 AC_MSG_CHECKING([for type sigaction_t])
4456 AC_CACHE_VAL(cf_cv_type_sigaction,[
4457         AC_TRY_COMPILE([
4458 #include <signal.h>],
4459                 [sigaction_t x],
4460                 [cf_cv_type_sigaction=yes],
4461                 [cf_cv_type_sigaction=no])])
4462 AC_MSG_RESULT($cf_cv_type_sigaction)
4463 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION)
4464 ])dnl
4465 dnl ---------------------------------------------------------------------------
4466 dnl CF_UNSIGNED_LITERALS version: 2 updated: 1998/02/07 22:10:16
4467 dnl --------------------
4468 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
4469 dnl won't, but they're still there.
4470 AC_DEFUN([CF_UNSIGNED_LITERALS],
4471 [
4472 AC_MSG_CHECKING([if unsigned literals are legal])
4473 AC_CACHE_VAL(cf_cv_unsigned_literals,[
4474         AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
4475                 [cf_cv_unsigned_literals=yes],
4476                 [cf_cv_unsigned_literals=no])
4477         ])
4478 AC_MSG_RESULT($cf_cv_unsigned_literals)
4479 ])dnl
4480 dnl ---------------------------------------------------------------------------
4481 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
4482 dnl --------
4483 dnl Make an uppercase version of a variable
4484 dnl $1=uppercase($2)
4485 AC_DEFUN([CF_UPPER],
4486 [
4487 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
4488 ])dnl
4489 dnl ---------------------------------------------------------------------------
4490 dnl CF_VERBOSE version: 2 updated: 1997/09/05 10:45:14
4491 dnl ----------
4492 dnl Use AC_VERBOSE w/o the warnings
4493 AC_DEFUN([CF_VERBOSE],
4494 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
4495 ])dnl
4496 dnl ---------------------------------------------------------------------------
4497 dnl CF_WCHAR_TYPE version: 2 updated: 2004/01/17 19:18:20
4498 dnl -------------
4499 dnl Check if type wide-character type $1 is declared, and if so, which header
4500 dnl file is needed.  The second parameter is used to set a shell variable when
4501 dnl the type is not found.  The first parameter sets a shell variable for the
4502 dnl opposite sense.
4503 AC_DEFUN([CF_WCHAR_TYPE],
4504 [
4505 # This is needed on Tru64 5.0 to declare $1
4506 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
4507 AC_TRY_COMPILE([
4508 #include <stdlib.h>
4509 #include <stdarg.h>
4510 #include <stdio.h>
4511 #ifdef HAVE_LIBUTF8_H
4512 #include <libutf8.h>
4513 #endif],
4514         [$1 state],
4515         [cf_cv_$1=no],
4516         [AC_TRY_COMPILE([
4517 #include <stdlib.h>
4518 #include <stdarg.h>
4519 #include <stdio.h>
4520 #include <wchar.h>
4521 #ifdef HAVE_LIBUTF8_H
4522 #include <libutf8.h>
4523 #endif],
4524         [$1 value],
4525         [cf_cv_$1=yes],
4526         [cf_cv_$1=unknown])])])
4527
4528 if test "$cf_cv_$1" = yes ; then
4529         AC_DEFINE(NEED_WCHAR_H)
4530         NEED_WCHAR_H=1
4531 fi
4532
4533 ifelse($2,,,[
4534 # if we do not find $1 in either place, use substitution to provide a fallback.
4535 if test "$cf_cv_$1" = unknown ; then
4536         $2=1
4537 fi
4538 ])
4539 ifelse($3,,,[
4540 # if we find $1 in either place, use substitution to provide a fallback.
4541 if test "$cf_cv_$1" != unknown ; then
4542         $3=1
4543 fi
4544 ])
4545 ])dnl
4546 dnl ---------------------------------------------------------------------------
4547 dnl CF_WITH_ABI_VERSION version: 1 updated: 2003/09/20 18:12:49
4548 dnl -------------------
4549 dnl Allow library's ABI to be overridden.  Generally this happens when a
4550 dnl packager has incremented the ABI past that used in the original package,
4551 dnl and wishes to keep doing this.
4552 dnl
4553 dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
4554 dnl symbol.
4555 AC_DEFUN([CF_WITH_ABI_VERSION],[
4556 test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
4557 AC_ARG_WITH(abi-version,
4558 [  --with-abi-version=XXX  override derived ABI version],
4559 [AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
4560  cf_cv_abi_version=$withval])
4561  CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
4562 ifelse($1,,,[
4563 $1_ABI=$cf_cv_abi_version
4564 ])
4565 ])dnl
4566 dnl ---------------------------------------------------------------------------
4567 dnl CF_WITH_DBMALLOC version: 6 updated: 2006/12/16 14:24:05
4568 dnl ----------------
4569 dnl Configure-option for dbmalloc.  The optional parameter is used to override
4570 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
4571 AC_DEFUN([CF_WITH_DBMALLOC],[
4572 CF_NO_LEAKS_OPTION(dbmalloc,
4573         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
4574         [USE_DBMALLOC])
4575
4576 if test "$with_dbmalloc" = yes ; then
4577         AC_CHECK_HEADER(dbmalloc.h,
4578                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse($1,,[],[,$1]))])
4579 fi
4580 ])dnl
4581 dnl ---------------------------------------------------------------------------
4582 dnl CF_WITH_DMALLOC version: 6 updated: 2006/12/16 14:24:05
4583 dnl ---------------
4584 dnl Configure-option for dmalloc.  The optional parameter is used to override
4585 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
4586 AC_DEFUN([CF_WITH_DMALLOC],[
4587 CF_NO_LEAKS_OPTION(dmalloc,
4588         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
4589         [USE_DMALLOC])
4590
4591 if test "$with_dmalloc" = yes ; then
4592         AC_CHECK_HEADER(dmalloc.h,
4593                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse($1,,[],[,$1]))])
4594 fi
4595 ])dnl
4596 dnl ---------------------------------------------------------------------------
4597 dnl CF_WITH_GPM version: 6 updated: 2006/12/17 11:12:09
4598 dnl -----------
4599 dnl
4600 dnl The option parameter (if neither yes/no) is assumed to be the name of
4601 dnl the gpm library, e.g., for dynamic loading.
4602 AC_DEFUN([CF_WITH_GPM],
4603 [
4604 AC_MSG_CHECKING(if you want to link with the GPM mouse library)
4605 AC_ARG_WITH(gpm,
4606         [  --with-gpm              use Alessandro Rubini's GPM library],
4607         [with_gpm=$withval],
4608         [with_gpm=maybe])
4609 AC_MSG_RESULT($with_gpm)
4610
4611 if test "$with_gpm" != no ; then
4612         AC_CHECK_HEADER(gpm.h,[
4613                 AC_DEFINE(HAVE_GPM_H)
4614                 if test "$with_gpm" != yes && test "$with_gpm" != maybe ; then
4615                         CF_VERBOSE(assuming we really have GPM library)
4616                         AC_DEFINE(HAVE_LIBGPM)
4617                 else
4618                         AC_CHECK_LIB(gpm,Gpm_Open,[:],[
4619                                 AC_ERROR(Cannot link with GPM library)
4620                 fi
4621                 with_gpm=yes
4622                 ])
4623         ],[
4624                 test "$with_gpm" != maybe && AC_MSG_WARN(Cannot find GPM header)
4625                 with_gpm=no
4626         ])
4627 fi
4628 ])
4629 dnl ---------------------------------------------------------------------------
4630 dnl CF_WITH_LIBTOOL version: 18 updated: 2007/04/08 20:02:38
4631 dnl ---------------
4632 dnl Provide a configure option to incorporate libtool.  Define several useful
4633 dnl symbols for the makefile rules.
4634 dnl
4635 dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
4636 dnl macros from libtool.m4 which is in the aclocal directory of automake.
4637 dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
4638 dnl But that still does not work properly since the macro is expanded outside
4639 dnl the CF_WITH_LIBTOOL macro:
4640 dnl
4641 dnl     #!/bin/sh
4642 dnl     ACLOCAL=`aclocal --print-ac-dir`
4643 dnl     if test -z "$ACLOCAL" ; then
4644 dnl             echo cannot find aclocal directory
4645 dnl             exit 1
4646 dnl     elif test ! -f $ACLOCAL/libtool.m4 ; then
4647 dnl             echo cannot find libtool.m4 file
4648 dnl             exit 1
4649 dnl     fi
4650 dnl     
4651 dnl     LOCAL=aclocal.m4
4652 dnl     ORIG=aclocal.m4.orig
4653 dnl     
4654 dnl     trap "mv $ORIG $LOCAL" 0 1 2 5 15
4655 dnl     rm -f $ORIG
4656 dnl     mv $LOCAL $ORIG
4657 dnl     
4658 dnl     # sed the LIBTOOL= assignment to omit the current directory?
4659 dnl     sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
4660 dnl     cat $ORIG >>$LOCAL
4661 dnl     
4662 dnl     autoconf-257 $*
4663 dnl
4664 AC_DEFUN([CF_WITH_LIBTOOL],
4665 [
4666 ifdef([AC_PROG_LIBTOOL],,[
4667 LIBTOOL=
4668 ])
4669 # common library maintenance symbols that are convenient for libtool scripts:
4670 LIB_CREATE='${AR} -cr'
4671 LIB_OBJECT='${OBJECTS}'
4672 LIB_SUFFIX=.a
4673 LIB_PREP="$RANLIB"
4674
4675 # symbols used to prop libtool up to enable it to determine what it should be
4676 # doing:
4677 LIB_CLEAN=
4678 LIB_COMPILE=
4679 LIB_LINK='${CC}'
4680 LIB_INSTALL=
4681 LIB_UNINSTALL=
4682
4683 AC_MSG_CHECKING(if you want to build libraries with libtool)
4684 AC_ARG_WITH(libtool,
4685         [  --with-libtool          generate libraries with libtool],
4686         [with_libtool=$withval],
4687         [with_libtool=no])
4688 AC_MSG_RESULT($with_libtool)
4689 if test "$with_libtool" != "no"; then
4690 ifdef([AC_PROG_LIBTOOL],[
4691         # missing_content_AC_PROG_LIBTOOL{{
4692         AC_PROG_LIBTOOL
4693         # missing_content_AC_PROG_LIBTOOL}}
4694 ],[
4695         if test "$with_libtool" != "yes" ; then
4696                 CF_PATH_SYNTAX(with_libtool)
4697                 LIBTOOL=$with_libtool
4698         else
4699                 AC_PATH_PROG(LIBTOOL,libtool)
4700         fi
4701         if test -z "$LIBTOOL" ; then
4702                 AC_MSG_ERROR(Cannot find libtool)
4703         fi
4704 ])dnl
4705         LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${DESTDIR}${libdir} -version-info `cut -f1 ${srcdir}/VERSION` ${LIBTOOL_OPTS} -o'
4706         LIB_OBJECT='${OBJECTS:.o=.lo}'
4707         LIB_SUFFIX=.la
4708         LIB_CLEAN='${LIBTOOL} --mode=clean'
4709         LIB_COMPILE='${LIBTOOL} --mode=compile'
4710         LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
4711         LIB_INSTALL='${LIBTOOL} --mode=install'
4712         LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
4713         LIB_PREP=:
4714
4715         # Show the version of libtool
4716         AC_MSG_CHECKING(version of libtool)
4717
4718         # Save the version in a cache variable - this is not entirely a good
4719         # thing, but the version string from libtool is very ugly, and for
4720         # bug reports it might be useful to have the original string.
4721         cf_cv_libtool_version=`$LIBTOOL --version 2>&1 | sed -e '/^$/d' |sed -e '2,$d' -e 's/([[^)]]*)//g' -e 's/^[[^1-9]]*//' -e 's/[[^0-9.]].*//'`
4722         AC_MSG_RESULT($cf_cv_libtool_version)
4723         if test -z "$cf_cv_libtool_version" ; then
4724                 AC_MSG_ERROR(This is not GNU libtool)
4725         fi
4726
4727         # special hack to add --tag option for C++ compiler
4728         case $cf_cv_libtool_version in
4729         1.[[5-9]]*|[[2-9]]*)
4730                 LIBTOOL_CXX="$LIBTOOL --tag=CXX"
4731                 ;;
4732         *)
4733                 LIBTOOL_CXX="$LIBTOOL"
4734                 ;;
4735         esac
4736 else
4737         LIBTOOL=""
4738         LIBTOOL_CXX=""
4739 fi
4740
4741 test -z "$LIBTOOL" && ECHO_LT=
4742
4743 AC_SUBST(LIBTOOL)
4744 AC_SUBST(LIBTOOL_CXX)
4745 AC_SUBST(LIBTOOL_OPTS)
4746
4747 AC_SUBST(LIB_CREATE)
4748 AC_SUBST(LIB_OBJECT)
4749 AC_SUBST(LIB_SUFFIX)
4750 AC_SUBST(LIB_PREP)
4751
4752 AC_SUBST(LIB_CLEAN)
4753 AC_SUBST(LIB_COMPILE)
4754 AC_SUBST(LIB_LINK)
4755 AC_SUBST(LIB_INSTALL)
4756 AC_SUBST(LIB_UNINSTALL)
4757
4758 ])dnl
4759 dnl ---------------------------------------------------------------------------
4760 dnl CF_WITH_PATH version: 7 updated: 2006/08/03 15:20:08
4761 dnl ------------
4762 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
4763 dnl defaulting to yes/no.
4764 dnl
4765 dnl $1 = option name
4766 dnl $2 = help-text
4767 dnl $3 = environment variable to set
4768 dnl $4 = default value, shown in the help-message, must be a constant
4769 dnl $5 = default value, if it's an expression & cannot be in the help-message
4770 dnl
4771 AC_DEFUN([CF_WITH_PATH],
4772 [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
4773 ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl
4774 CF_PATH_SYNTAX(withval)
4775 $3="$withval"
4776 AC_SUBST($3)dnl
4777 ])dnl
4778 dnl ---------------------------------------------------------------------------
4779 dnl CF_WITH_PATHLIST version: 5 updated: 2001/12/10 01:28:30
4780 dnl ----------------
4781 dnl Process an option specifying a list of colon-separated paths.
4782 dnl
4783 dnl $1 = option name
4784 dnl $2 = help-text
4785 dnl $3 = environment variable to set
4786 dnl $4 = default value, shown in the help-message, must be a constant
4787 dnl $5 = default value, if it's an expression & cannot be in the help-message
4788 dnl $6 = flag to tell if we want to define or substitute
4789 dnl
4790 AC_DEFUN([CF_WITH_PATHLIST],[
4791 AC_REQUIRE([CF_PATHSEP])
4792 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
4793 ifelse($4,,[withval=${$3}],[withval=${$3-ifelse($5,,$4,$5)}]))dnl
4794
4795 IFS="${IFS=     }"; ac_save_ifs="$IFS"; IFS="${PATHSEP}"
4796 cf_dst_path=
4797 for cf_src_path in $withval
4798 do
4799   CF_PATH_SYNTAX(cf_src_path)
4800   test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
4801   cf_dst_path="${cf_dst_path}${cf_src_path}"
4802 done
4803 IFS="$ac_save_ifs"
4804
4805 ifelse($6,define,[
4806 # Strip single quotes from the value, e.g., when it was supplied as a literal
4807 # for $4 or $5.
4808 case $cf_dst_path in #(vi
4809 \'*)
4810   cf_dst_path=`echo $cf_dst_path |sed -e s/\'// -e s/\'\$//`
4811   ;;
4812 esac
4813 cf_dst_path=`echo "$cf_dst_path" | sed -e 's/\\\\/\\\\\\\\/g'`
4814 ])
4815
4816 eval '$3="$cf_dst_path"'
4817 AC_SUBST($3)dnl
4818
4819 ])dnl
4820 dnl ---------------------------------------------------------------------------
4821 dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
4822 dnl -------------------
4823 dnl Allow library's release-version to be overridden.  Generally this happens when a
4824 dnl packager has incremented the release-version past that used in the original package,
4825 dnl and wishes to keep doing this.
4826 dnl
4827 dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
4828 dnl and {package}_MINOR symbols
4829 dnl symbol.
4830 AC_DEFUN([CF_WITH_REL_VERSION],[
4831 test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
4832 AC_ARG_WITH(rel-version,
4833 [  --with-rel-version=XXX  override derived release version],
4834 [AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
4835  cf_cv_rel_version=$withval])
4836 ifelse($1,,[
4837  CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
4838 ],[
4839  $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
4840  $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
4841  CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
4842  CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
4843 ])
4844 ])dnl
4845 dnl ---------------------------------------------------------------------------
4846 dnl CF_WITH_SYSMOUSE version: 2 updated: 2003/03/22 19:13:43
4847 dnl ----------------
4848 dnl If we can compile with sysmouse, make it available unless it is not wanted.
4849 AC_DEFUN([CF_WITH_SYSMOUSE],[
4850 # not everyone has "test -c"
4851 if test -c /dev/sysmouse 2>/dev/null ; then
4852 AC_MSG_CHECKING(if you want to use sysmouse)
4853 AC_ARG_WITH(sysmouse,
4854         [  --with-sysmouse         use sysmouse (FreeBSD console)],
4855         [cf_with_sysmouse=$withval],
4856         [cf_with_sysmouse=maybe])
4857         if test "$cf_with_sysmouse" != no ; then
4858         AC_TRY_COMPILE([
4859 #include <osreldate.h>
4860 #if (__FreeBSD_version >= 400017)
4861 #include <sys/consio.h>
4862 #include <sys/fbio.h>
4863 #else
4864 #include <machine/console.h>
4865 #endif
4866 ],[
4867         struct mouse_info the_mouse;
4868         ioctl(0, CONS_MOUSECTL, &the_mouse);
4869 ],[cf_with_sysmouse=yes],[cf_with_sysmouse=no])
4870         fi
4871 AC_MSG_RESULT($cf_with_sysmouse)
4872 test "$cf_with_sysmouse" = yes && AC_DEFINE(USE_SYSMOUSE)
4873 fi
4874 ])dnl
4875 dnl ---------------------------------------------------------------------------
4876 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
4877 dnl ----------------
4878 AC_DEFUN([CF_WITH_VALGRIND],[
4879 CF_NO_LEAKS_OPTION(valgrind,
4880         [  --with-valgrind         test: use valgrind],
4881         [USE_VALGRIND])
4882 ])dnl
4883 dnl ---------------------------------------------------------------------------
4884 dnl CF_XOPEN_SOURCE version: 25 updated: 2007/01/29 18:36:38
4885 dnl ---------------
4886 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
4887 dnl or adapt to the vendor's definitions to get equivalent functionality,
4888 dnl without losing the common non-POSIX features.
4889 dnl
4890 dnl Parameters:
4891 dnl     $1 is the nominal value for _XOPEN_SOURCE
4892 dnl     $2 is the nominal value for _POSIX_C_SOURCE
4893 AC_DEFUN([CF_XOPEN_SOURCE],[
4894
4895 AC_REQUIRE([CF_PROG_CC_U_D])
4896
4897 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
4898 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
4899
4900 case $host_os in #(vi
4901 aix[[45]]*) #(vi
4902         CPPFLAGS="$CPPFLAGS -D_ALL_SOURCE"
4903         ;;
4904 freebsd*) #(vi
4905         # 5.x headers associate
4906         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
4907         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
4908         cf_POSIX_C_SOURCE=200112L
4909         cf_XOPEN_SOURCE=600
4910         CPPFLAGS="$CPPFLAGS -D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
4911         ;;
4912 hpux*) #(vi
4913         CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE"
4914         ;;
4915 irix[[56]].*) #(vi
4916         CPPFLAGS="$CPPFLAGS -D_SGI_SOURCE"
4917         ;;
4918 linux*|gnu*|k*bsd*-gnu) #(vi
4919         CF_GNU_SOURCE
4920         ;;
4921 mirbsd*) #(vi
4922         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
4923         ;;
4924 netbsd*) #(vi
4925         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
4926         ;;
4927 openbsd*) #(vi
4928         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
4929         ;;
4930 osf[[45]]*) #(vi
4931         CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE"
4932         ;;
4933 nto-qnx*) #(vi
4934         CPPFLAGS="$CPPFLAGS -D_QNX_SOURCE"
4935         ;;
4936 sco*) #(vi
4937         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
4938         ;;
4939 solaris*) #(vi
4940         CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
4941         ;;
4942 *)
4943         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
4944         AC_TRY_COMPILE([#include <sys/types.h>],[
4945 #ifndef _XOPEN_SOURCE
4946 make an error
4947 #endif],
4948         [cf_cv_xopen_source=no],
4949         [cf_save="$CPPFLAGS"
4950          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
4951          AC_TRY_COMPILE([#include <sys/types.h>],[
4952 #ifdef _XOPEN_SOURCE
4953 make an error
4954 #endif],
4955         [cf_cv_xopen_source=no],
4956         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
4957         CPPFLAGS="$cf_save"
4958         ])
4959 ])
4960         if test "$cf_cv_xopen_source" != no ; then
4961                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
4962                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
4963                 test "$cf_cv_cc_u_d_options" = yes && \
4964                         CPPFLAGS="$CPPFLAGS -U_XOPEN_SOURCE"
4965                 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_cv_xopen_source"
4966         fi
4967         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
4968         ;;
4969 esac
4970 ])