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