FIXUP: HAVE_SYS_IOCTL_H
[mirror-ossqm-ncurses.git] / macros.m4
blob8f6ed30f05d1c41ea9629625f6e72d64376789ac
1 dnl***************************************************************************
2 dnl Copyright (c) 1998-2010,2011 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.549 2011/02/21 01:40:21 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],
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: 6 updated: 2010/02/26 19:52:07
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],
71 ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
72 if test "$srcdir" != "."; then
73         ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
75 AC_SUBST(ACPPFLAGS)
76 ])dnl
77 dnl ---------------------------------------------------------------------------
78 dnl CF_ADD_ADAFLAGS version: 1 updated: 2010/06/19 15:22:18
79 dnl ---------------
80 dnl Add to $ADAFLAGS, which is substituted into makefile and scripts.
81 AC_DEFUN([CF_ADD_ADAFLAGS],[
82         ADAFLAGS="$ADAFLAGS $1"
83         AC_SUBST(ADAFLAGS)
84 ])dnl
85 dnl ---------------------------------------------------------------------------
86 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
87 dnl -------------
88 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
89 dnl The second parameter if given makes this macro verbose.
90 dnl
91 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
92 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
93 dnl confused by the quotes (which require backslashes to keep them usable).
94 AC_DEFUN([CF_ADD_CFLAGS],
96 cf_fix_cppflags=no
97 cf_new_cflags=
98 cf_new_cppflags=
99 cf_new_extra_cppflags=
101 for cf_add_cflags in $1
103 case $cf_fix_cppflags in
105         case $cf_add_cflags in #(vi
106         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
107                 case $cf_add_cflags in
108                 -D*)
109                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
111                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
112                                 && test -z "${cf_tst_cflags}" \
113                                 && cf_fix_cppflags=yes
115                         if test $cf_fix_cppflags = yes ; then
116                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
117                                 continue
118                         elif test "${cf_tst_cflags}" = "\"'" ; then
119                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
120                                 continue
121                         fi
122                         ;;
123                 esac
124                 case "$CPPFLAGS" in
125                 *$cf_add_cflags) #(vi
126                         ;;
127                 *) #(vi
128                         case $cf_add_cflags in #(vi
129                         -D*)
130                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
131                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
132                                 ;;
133                         esac
134                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
135                         ;;
136                 esac
137                 ;;
138         *)
139                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
140                 ;;
141         esac
142         ;;
143 yes)
144         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
146         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
148         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
149                 && test -z "${cf_tst_cflags}" \
150                 && cf_fix_cppflags=no
151         ;;
152 esac
153 done
155 if test -n "$cf_new_cflags" ; then
156         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
157         CFLAGS="$CFLAGS $cf_new_cflags"
160 if test -n "$cf_new_cppflags" ; then
161         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
162         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
165 if test -n "$cf_new_extra_cppflags" ; then
166         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
167         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
170 AC_SUBST(EXTRA_CPPFLAGS)
172 ])dnl
173 dnl ---------------------------------------------------------------------------
174 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
175 dnl -------------
176 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
177 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
178 dnl but old versions (and some misinstalled ones) need that.  To make things
179 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
180 dnl the include-path).
181 AC_DEFUN([CF_ADD_INCDIR],
183 if test -n "$1" ; then
184   for cf_add_incdir in $1
185   do
186         while test $cf_add_incdir != /usr/include
187         do
188           if test -d $cf_add_incdir
189           then
190                 cf_have_incdir=no
191                 if test -n "$CFLAGS$CPPFLAGS" ; then
192                   # a loop is needed to ensure we can add subdirs of existing dirs
193                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
194                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
195                           cf_have_incdir=yes; break
196                         fi
197                   done
198                 fi
200                 if test "$cf_have_incdir" = no ; then
201                   if test "$cf_add_incdir" = /usr/local/include ; then
202                         if test "$GCC" = yes
203                         then
204                           cf_save_CPPFLAGS=$CPPFLAGS
205                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
206                           AC_TRY_COMPILE([#include <stdio.h>],
207                                   [printf("Hello")],
208                                   [],
209                                   [cf_have_incdir=yes])
210                           CPPFLAGS=$cf_save_CPPFLAGS
211                         fi
212                   fi
213                 fi
215                 if test "$cf_have_incdir" = no ; then
216                   CF_VERBOSE(adding $cf_add_incdir to include-path)
217                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
219                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
220                   test "$cf_top_incdir" = "$cf_add_incdir" && break
221                   cf_add_incdir="$cf_top_incdir"
222                 else
223                   break
224                 fi
225           fi
226         done
227   done
229 ])dnl
230 dnl ---------------------------------------------------------------------------
231 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
232 dnl ----------
233 dnl Add a library, used to enforce consistency.
235 dnl $1 = library to add, without the "-l"
236 dnl $2 = variable to update (default $LIBS)
237 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
238 dnl ---------------------------------------------------------------------------
239 dnl CF_ADD_LIBDIR version: 9 updated: 2010/05/26 16:44:57
240 dnl -------------
241 dnl     Adds to the library-path
243 dnl     Some machines have trouble with multiple -L options.
245 dnl $1 is the (list of) directory(s) to add
246 dnl $2 is the optional name of the variable to update (default LDFLAGS)
248 AC_DEFUN([CF_ADD_LIBDIR],
250 if test -n "$1" ; then
251   for cf_add_libdir in $1
252   do
253     if test $cf_add_libdir = /usr/lib ; then
254       :
255     elif test -d $cf_add_libdir
256     then
257       cf_have_libdir=no
258       if test -n "$LDFLAGS$LIBS" ; then
259         # a loop is needed to ensure we can add subdirs of existing dirs
260         for cf_test_libdir in $LDFLAGS $LIBS ; do
261           if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
262             cf_have_libdir=yes; break
263           fi
264         done
265       fi
266       if test "$cf_have_libdir" = no ; then
267         CF_VERBOSE(adding $cf_add_libdir to library-path)
268         ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
269       fi
270     fi
271   done
273 ])dnl
274 dnl ---------------------------------------------------------------------------
275 dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
276 dnl -----------
277 dnl Add one or more libraries, used to enforce consistency.
279 dnl $1 = libraries to add, with the "-l", etc.
280 dnl $2 = variable to update (default $LIBS)
281 AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
282 dnl ---------------------------------------------------------------------------
283 dnl CF_ADD_SUBDIR_PATH version: 3 updated: 2010/07/03 20:58:12
284 dnl ------------------
285 dnl Append to a search-list for a nonstandard header/lib-file
286 dnl     $1 = the variable to return as result
287 dnl     $2 = the package name
288 dnl     $3 = the subdirectory, e.g., bin, include or lib
289 dnl $4 = the directory under which we will test for subdirectories
290 dnl $5 = a directory that we do not want $4 to match
291 AC_DEFUN([CF_ADD_SUBDIR_PATH],
293 test "$4" != "$5" && \
294 test -d "$4" && \
295 ifelse([$5],NONE,,[(test $5 = NONE || test "$4" != "$5") &&]) {
296         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
297         test -d $4/$3 &&          $1="[$]$1 $4/$3"
298         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
299         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
300         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
301         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
303 ])dnl
304 dnl ---------------------------------------------------------------------------
305 dnl CF_ANSI_CC_CHECK version: 10 updated: 2010/10/23 15:52:32
306 dnl ----------------
307 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
308 dnl in the sharutils 4.2 distribution.
309 AC_DEFUN([CF_ANSI_CC_CHECK],
311 AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
312 cf_cv_ansi_cc=no
313 cf_save_CFLAGS="$CFLAGS"
314 cf_save_CPPFLAGS="$CPPFLAGS"
315 # Don't try gcc -ansi; that turns off useful extensions and
316 # breaks some systems' header files.
317 # AIX                   -qlanglvl=ansi
318 # Ultrix and OSF/1      -std1
319 # HP-UX                 -Aa -D_HPUX_SOURCE
320 # SVR4                  -Xc
321 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
322 for cf_arg in "-DCC_HAS_PROTOS" \
323         "" \
324         -qlanglvl=ansi \
325         -std1 \
326         -Ae \
327         "-Aa -D_HPUX_SOURCE" \
328         -Xc
330         CF_ADD_CFLAGS($cf_arg)
331         AC_TRY_COMPILE(
333 #ifndef CC_HAS_PROTOS
334 #if !defined(__STDC__) || (__STDC__ != 1)
335 choke me
336 #endif
337 #endif
339         int test (int i, double x);
340         struct s1 {int (*f) (int a);};
341         struct s2 {int (*f) (double a);};],
342         [cf_cv_ansi_cc="$cf_arg"; break])
343 done
344 CFLAGS="$cf_save_CFLAGS"
345 CPPFLAGS="$cf_save_CPPFLAGS"
348 if test "$cf_cv_ansi_cc" != "no"; then
349 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
350         CF_ADD_CFLAGS($cf_cv_ansi_cc)
351 else
352         AC_DEFINE(CC_HAS_PROTOS,[],[CC_HAS_PROTOS])
355 ])dnl
356 dnl ---------------------------------------------------------------------------
357 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
358 dnl ---------------
359 dnl For programs that must use an ANSI compiler, obtain compiler options that
360 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
361 dnl macros, since tools such as unproto can fake prototypes, but only part of
362 dnl the preprocessor.
363 AC_DEFUN([CF_ANSI_CC_REQD],
364 [AC_REQUIRE([CF_ANSI_CC_CHECK])
365 if test "$cf_cv_ansi_cc" = "no"; then
366         AC_MSG_ERROR(
367 [Your compiler does not appear to recognize prototypes.
368 You have the following choices:
369         a. adjust your compiler options
370         b. get an up-to-date compiler
371         c. use a wrapper such as unproto])
373 ])dnl
374 dnl ---------------------------------------------------------------------------
375 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
376 dnl --------------
377 dnl Allow user to disable a normally-on option.
378 AC_DEFUN([CF_ARG_DISABLE],
379 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
380 dnl ---------------------------------------------------------------------------
381 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
382 dnl -------------
383 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
384 dnl values.
386 dnl Parameters:
387 dnl $1 = option name
388 dnl $2 = help-string
389 dnl $3 = action to perform if option is not default
390 dnl $4 = action if perform if option is default
391 dnl $5 = default option value (either 'yes' or 'no')
392 AC_DEFUN([CF_ARG_OPTION],
393 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
394   if test "$enableval" != "$5" ; then
395 ifelse([$3],,[    :]dnl
396 ,[    $3]) ifelse([$4],,,[
397   else
398     $4])
399   fi],[enableval=$5 ifelse([$4],,,[
400   $4
401 ])dnl
402   ])])dnl
403 dnl ---------------------------------------------------------------------------
404 dnl CF_AR_FLAGS version: 5 updated: 2010/05/20 20:24:29
405 dnl -----------
406 dnl Check for suitable "ar" (archiver) options for updating an archive.
407 AC_DEFUN([CF_AR_FLAGS],[
408 AC_REQUIRE([CF_PROG_AR])
410 AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
411         cf_cv_ar_flags=unknown
412         for cf_ar_flags in -curv curv -crv crv -cqv cqv -rv rv
413         do
415                 # check if $ARFLAGS already contains this choice
416                 if test "x$ARFLAGS" != "x" ; then
417                         cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
418                         if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
419                                 cf_cv_ar_flags=
420                                 break
421                         fi
422                 fi
424                 rm -f conftest.$ac_cv_objext
425                 rm -f conftest.a
427                 cat >conftest.$ac_ext <<EOF
428 #line __oline__ "configure"
429 int     testdata[[3]] = { 123, 456, 789 };
431                 if AC_TRY_EVAL(ac_compile) ; then
432                         echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AS_MESSAGE_LOG_FD
433                         $AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext 2>&AS_MESSAGE_LOG_FD 1>/dev/null
434                         if test -f conftest.a ; then
435                                 cf_cv_ar_flags=$cf_ar_flags
436                                 break
437                         fi
438                 else
439                         CF_VERBOSE(cannot compile test-program)
440                         break
441                 fi
442         done
443         rm -f conftest.a conftest.$ac_ext conftest.$ac_cv_objext
446 if test -n "$ARFLAGS" ; then
447         if test -n "$cf_cv_ar_flags" ; then
448                 ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
449         fi
450 else
451         ARFLAGS=$cf_cv_ar_flags
454 AC_SUBST(ARFLAGS)
456 dnl ---------------------------------------------------------------------------
457 dnl CF_AWK_BIG_PRINTF version: 3 updated: 2008/12/27 12:30:03
458 dnl -----------------
459 dnl Check if awk can handle big strings using printf.  Some older versions of
460 dnl awk choke on large strings passed via "%s".
462 dnl $1 = desired string size
463 dnl $2 = variable to set with result
464 AC_DEFUN([CF_AWK_BIG_PRINTF],
466         case x$AWK in #(vi
467         x)
468                 eval $2=no
469                 ;;
470         *) #(vi
471                 if ( ${AWK} 'BEGIN { xx = "x"; while (length(xx) < $1) { xx = xx "x"; }; printf("%s\n", xx); }' \
472                         | $AWK '{ printf "%d\n", length([$]0); }' | $AWK 'BEGIN { eqls=0; recs=0; } { recs++; if ([$]0 == 12000) eqls++; } END { if (recs != 1 || eqls != 1) exit 1; }' 2>/dev/null >/dev/null ) ; then
473                         eval $2=yes
474                 else
475                         eval $2=no
476                 fi
477                 ;;
478         esac
479 ])dnl
480 dnl ---------------------------------------------------------------------------
481 dnl CF_BOOL_DECL version: 8 updated: 2004/01/30 15:51:18
482 dnl ------------
483 dnl Test if 'bool' is a builtin type in the configured C++ compiler.  Some
484 dnl older compilers (e.g., gcc 2.5.8) don't support 'bool' directly; gcc
485 dnl 2.6.3 does, in anticipation of the ANSI C++ standard.
487 dnl Treat the configuration-variable specially here, since we're directly
488 dnl substituting its value (i.e., 1/0).
490 dnl $1 is the shell variable to store the result in, if not $cv_cv_builtin_bool
491 AC_DEFUN([CF_BOOL_DECL],
493 AC_MSG_CHECKING(if we should include stdbool.h)
495 AC_CACHE_VAL(cf_cv_header_stdbool_h,[
496         AC_TRY_COMPILE([],[bool foo = false],
497                 [cf_cv_header_stdbool_h=0],
498                 [AC_TRY_COMPILE([
499 #ifndef __BEOS__
500 #include <stdbool.h>
501 #endif
502 ],[bool foo = false],
503                         [cf_cv_header_stdbool_h=1],
504                         [cf_cv_header_stdbool_h=0])])])
506 if test "$cf_cv_header_stdbool_h" = 1
507 then    AC_MSG_RESULT(yes)
508 else    AC_MSG_RESULT(no)
511 AC_MSG_CHECKING([for builtin bool type])
513 AC_CACHE_VAL(ifelse($1,,cf_cv_builtin_bool,[$1]),[
514         AC_TRY_COMPILE([
515 #include <stdio.h>
516 #include <sys/types.h>
517 ],[bool x = false],
518                 [ifelse($1,,cf_cv_builtin_bool,[$1])=1],
519                 [ifelse($1,,cf_cv_builtin_bool,[$1])=0])
520         ])
522 if test "$ifelse($1,,cf_cv_builtin_bool,[$1])" = 1
523 then    AC_MSG_RESULT(yes)
524 else    AC_MSG_RESULT(no)
526 ])dnl
527 dnl ---------------------------------------------------------------------------
528 dnl CF_BOOL_SIZE version: 12 updated: 2006/12/16 12:33:30
529 dnl ------------
530 dnl Test for the size of 'bool' in the configured C++ compiler (e.g., a type).
531 dnl Don't bother looking for bool.h, since it's been deprecated.
533 dnl If the current compiler is C rather than C++, we get the bool definition
534 dnl from <stdbool.h>.
535 AC_DEFUN([CF_BOOL_SIZE],
537 AC_MSG_CHECKING([for size of bool])
538 AC_CACHE_VAL(cf_cv_type_of_bool,[
539         rm -f cf_test.out
540         AC_TRY_RUN([
541 #include <stdlib.h>
542 #include <stdio.h>
544 #if defined(__cplusplus)
546 #ifdef HAVE_GXX_BUILTIN_H
547 #include <g++/builtin.h>
548 #elif HAVE_GPP_BUILTIN_H
549 #include <gpp/builtin.h>
550 #elif HAVE_BUILTIN_H
551 #include <builtin.h>
552 #endif
554 #else
556 #if $cf_cv_header_stdbool_h
557 #include <stdbool.h>
558 #endif
560 #endif
562 main()
564         FILE *fp = fopen("cf_test.out", "w");
565         if (fp != 0) {
566                 bool x = true;
567                 if ((bool)(-x) >= 0)
568                         fputs("unsigned ", fp);
569                 if (sizeof(x) == sizeof(int))       fputs("int",  fp);
570                 else if (sizeof(x) == sizeof(char)) fputs("char", fp);
571                 else if (sizeof(x) == sizeof(short))fputs("short",fp);
572                 else if (sizeof(x) == sizeof(long)) fputs("long", fp);
573                 fclose(fp);
574         }
575         ${cf_cv_main_return:-return}(0);
577                 ],
578                 [cf_cv_type_of_bool=`cat cf_test.out`
579                  if test -z "$cf_cv_type_of_bool"; then
580                    cf_cv_type_of_bool=unknown
581                  fi],
582                 [cf_cv_type_of_bool=unknown],
583                 [cf_cv_type_of_bool=unknown])
584         ])
585         rm -f cf_test.out
586 AC_MSG_RESULT($cf_cv_type_of_bool)
587 if test "$cf_cv_type_of_bool" = unknown ; then
588         case .$NCURSES_BOOL in #(vi
589         .auto|.) NCURSES_BOOL=unsigned;;
590         esac
591         AC_MSG_WARN(Assuming $NCURSES_BOOL for type of bool)
592         cf_cv_type_of_bool=$NCURSES_BOOL
594 ])dnl
595 dnl ---------------------------------------------------------------------------
596 dnl CF_BUILD_CC version: 6 updated: 2006/10/14 15:23:15
597 dnl -----------
598 dnl If we're cross-compiling, allow the user to override the tools and their
599 dnl options.  The configure script is oriented toward identifying the host
600 dnl compiler, etc., but we need a build compiler to generate parts of the
601 dnl source.
603 dnl $1 = default for $CPPFLAGS
604 dnl $2 = default for $LIBS
605 AC_DEFUN([CF_BUILD_CC],[
606 AC_REQUIRE([CF_PROG_EXT])
607 if test "$cross_compiling" = yes ; then
609         # defaults that we might want to override
610         : ${BUILD_CFLAGS:=''}
611         : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
612         : ${BUILD_LDFLAGS:=''}
613         : ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
614         : ${BUILD_EXEEXT:='$x'}
615         : ${BUILD_OBJEXT:='o'}
617         AC_ARG_WITH(build-cc,
618                 [  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
619                 [BUILD_CC="$withval"],
620                 [AC_CHECK_PROGS(BUILD_CC, gcc cc cl)])
621         AC_MSG_CHECKING(for native build C compiler)
622         AC_MSG_RESULT($BUILD_CC)
624         AC_MSG_CHECKING(for native build C preprocessor)
625         AC_ARG_WITH(build-cpp,
626                 [  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
627                 [BUILD_CPP="$withval"],
628                 [BUILD_CPP='${BUILD_CC} -E'])
629         AC_MSG_RESULT($BUILD_CPP)
631         AC_MSG_CHECKING(for native build C flags)
632         AC_ARG_WITH(build-cflags,
633                 [  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
634                 [BUILD_CFLAGS="$withval"])
635         AC_MSG_RESULT($BUILD_CFLAGS)
637         AC_MSG_CHECKING(for native build C preprocessor-flags)
638         AC_ARG_WITH(build-cppflags,
639                 [  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
640                 [BUILD_CPPFLAGS="$withval"])
641         AC_MSG_RESULT($BUILD_CPPFLAGS)
643         AC_MSG_CHECKING(for native build linker-flags)
644         AC_ARG_WITH(build-ldflags,
645                 [  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
646                 [BUILD_LDFLAGS="$withval"])
647         AC_MSG_RESULT($BUILD_LDFLAGS)
649         AC_MSG_CHECKING(for native build linker-libraries)
650         AC_ARG_WITH(build-libs,
651                 [  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
652                 [BUILD_LIBS="$withval"])
653         AC_MSG_RESULT($BUILD_LIBS)
655         # this assumes we're on Unix.
656         BUILD_EXEEXT=
657         BUILD_OBJEXT=o
659         : ${BUILD_CC:='${CC}'}
661         if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
662                 AC_MSG_ERROR([Cross-build requires two compilers.
663 Use --with-build-cc to specify the native compiler.])
664         fi
666 else
667         : ${BUILD_CC:='${CC}'}
668         : ${BUILD_CPP:='${CPP}'}
669         : ${BUILD_CFLAGS:='${CFLAGS}'}
670         : ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
671         : ${BUILD_LDFLAGS:='${LDFLAGS}'}
672         : ${BUILD_LIBS:='${LIBS}'}
673         : ${BUILD_EXEEXT:='$x'}
674         : ${BUILD_OBJEXT:='o'}
677 AC_SUBST(BUILD_CC)
678 AC_SUBST(BUILD_CPP)
679 AC_SUBST(BUILD_CFLAGS)
680 AC_SUBST(BUILD_CPPFLAGS)
681 AC_SUBST(BUILD_LDFLAGS)
682 AC_SUBST(BUILD_LIBS)
683 AC_SUBST(BUILD_EXEEXT)
684 AC_SUBST(BUILD_OBJEXT)
685 ])dnl
686 dnl ---------------------------------------------------------------------------
687 dnl CF_CFG_DEFAULTS version: 7 updated: 2005/09/24 16:15:00
688 dnl ---------------
689 dnl Determine the default configuration into which we'll install ncurses.  This
690 dnl can be overridden by the user's command-line options.  There's two items to
691 dnl look for:
692 dnl     1. the prefix (e.g., /usr)
693 dnl     2. the header files (e.g., /usr/include/ncurses)
694 dnl We'll look for a previous installation of ncurses and use the same defaults.
696 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
697 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
698 dnl programs from a vendor's.
699 AC_DEFUN([CF_CFG_DEFAULTS],
701 AC_MSG_CHECKING(for prefix)
702 if test "x$prefix" = "xNONE" ; then
703         case "$cf_cv_system_name" in
704                 # non-vendor systems don't have a conflict
705         openbsd*|freebsd*|linux*|cygwin*|k*bsd*-gnu)
706                 prefix=/usr
707                 ;;
708         *)      prefix=$ac_default_prefix
709                 ;;
710         esac
712 AC_MSG_RESULT($prefix)
714 if test "x$prefix" = "xNONE" ; then
715 AC_MSG_CHECKING(for default include-directory)
716 test -n "$verbose" && echo 1>&AS_MESSAGE_FD
717 for cf_symbol in \
718         $includedir \
719         $includedir/ncurses \
720         $prefix/include \
721         $prefix/include/ncurses \
722         /usr/local/include \
723         /usr/local/include/ncurses \
724         /usr/include \
725         /usr/include/ncurses
727         cf_dir=`eval echo $cf_symbol`
728         if test -f $cf_dir/curses.h ; then
729         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
730                 includedir="$cf_symbol"
731                 test -n "$verbose"  && echo $ac_n "     found " 1>&AS_MESSAGE_FD
732                 break
733         fi
734         fi
735         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AS_MESSAGE_FD
736 done
737 AC_MSG_RESULT($includedir)
739 ])dnl
740 dnl ---------------------------------------------------------------------------
741 dnl CF_CGETENT version: 3 updated: 2000/08/12 23:18:52
742 dnl ----------
743 dnl Check if the terminal-capability database functions are available.  If not,
744 dnl ncurses has a much-reduced version.
745 AC_DEFUN([CF_CGETENT],[
746 AC_MSG_CHECKING(for terminal-capability database functions)
747 AC_CACHE_VAL(cf_cv_cgetent,[
748 AC_TRY_LINK([
749 #include <stdlib.h>],[
750         char temp[128];
751         char *buf = temp;
752         char *db_array = temp;
753         cgetent(&buf, /* int *, */ &db_array, "vt100");
754         cgetcap(buf, "tc", '=');
755         cgetmatch(buf, "tc");
756         ],
757         [cf_cv_cgetent=yes],
758         [cf_cv_cgetent=no])
760 AC_MSG_RESULT($cf_cv_cgetent)
761 test "$cf_cv_cgetent" = yes && AC_DEFINE(HAVE_BSD_CGETENT,[],[HAVE_BSD_CGETENT])
762 ])dnl
763 dnl ---------------------------------------------------------------------------
764 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
765 dnl --------------
766 dnl Check if we're accidentally using a cache from a different machine.
767 dnl Derive the system name, as a check for reusing the autoconf cache.
769 dnl If we've packaged config.guess and config.sub, run that (since it does a
770 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
771 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
772 dnl which is useful in cross-compiles.
774 dnl Note: we would use $ac_config_sub, but that is one of the places where
775 dnl autoconf 2.5x broke compatibility with autoconf 2.13
776 AC_DEFUN([CF_CHECK_CACHE],
778 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
779         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
780         system_name="$host_os"
781 else
782         system_name="`(uname -s -r) 2>/dev/null`"
783         if test -z "$system_name" ; then
784                 system_name="`(hostname) 2>/dev/null`"
785         fi
787 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[SYSTEM_NAME])
788 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
790 test -z "$system_name" && system_name="$cf_cv_system_name"
791 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
793 if test ".$system_name" != ".$cf_cv_system_name" ; then
794         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
795         AC_MSG_ERROR("Please remove config.cache and try again.")
797 ])dnl
798 dnl ---------------------------------------------------------------------------
799 dnl CF_CHECK_ERRNO version: 11 updated: 2010/05/26 05:38:42
800 dnl --------------
801 dnl Check for data that is usually declared in <stdio.h> or <errno.h>, e.g.,
802 dnl the 'errno' variable.  Define a DECL_xxx symbol if we must declare it
803 dnl ourselves.
805 dnl $1 = the name to check
806 dnl $2 = the assumed type
807 AC_DEFUN([CF_CHECK_ERRNO],
809 AC_CACHE_CHECK(if external $1 is declared, cf_cv_dcl_$1,[
810     AC_TRY_COMPILE([
811 #ifdef HAVE_STDLIB_H
812 #include <stdlib.h>
813 #endif
814 #include <stdio.h>
815 #include <sys/types.h>
816 #include <errno.h> ],
817     ifelse([$2],,int,[$2]) x = (ifelse([$2],,int,[$2])) $1,
818     [cf_cv_dcl_$1=yes],
819     [cf_cv_dcl_$1=no])
822 if test "$cf_cv_dcl_$1" = no ; then
823     CF_UPPER(cf_result,decl_$1)
824     AC_DEFINE_UNQUOTED($cf_result)
827 # It's possible (for near-UNIX clones) that the data doesn't exist
828 CF_CHECK_EXTERN_DATA($1,ifelse([$2],,int,[$2]))
829 ])dnl
830 dnl ---------------------------------------------------------------------------
831 dnl CF_CHECK_EXTERN_DATA version: 3 updated: 2001/12/30 18:03:23
832 dnl --------------------
833 dnl Check for existence of external data in the current set of libraries.  If
834 dnl we can modify it, it's real enough.
835 dnl $1 = the name to check
836 dnl $2 = its type
837 AC_DEFUN([CF_CHECK_EXTERN_DATA],
839 AC_CACHE_CHECK(if external $1 exists, cf_cv_have_$1,[
840     AC_TRY_LINK([
841 #undef $1
842 extern $2 $1;
844     [$1 = 2],
845     [cf_cv_have_$1=yes],
846     [cf_cv_have_$1=no])
849 if test "$cf_cv_have_$1" = yes ; then
850     CF_UPPER(cf_result,have_$1)
851     AC_DEFINE_UNQUOTED($cf_result)
854 ])dnl
855 dnl ---------------------------------------------------------------------------
856 dnl CF_CHECK_GPM_WGETCH version: 2 updated: 2010/08/14 18:25:37
857 dnl -------------------
858 dnl Check if GPM is already linked with curses.  If so - and if the linkage
859 dnl is not "weak" - warn about this because it can create problems linking
860 dnl applications with ncurses.
861 AC_DEFUN([CF_CHECK_GPM_WGETCH],[
862 AC_CHECK_LIB(gpm,Gpm_Wgetch,[
864 AC_CACHE_CHECK(if GPM is weakly bound to curses library, cf_cv_check_gpm_wgetch,[
865 cf_cv_check_gpm_wgetch=unknown
866 if test "$cross_compiling" != yes ; then
868 cat >conftest.$ac_ext <<CF_EOF
869 #include <gpm.h>
870 int main()
872         Gpm_Wgetch();
873         ${cf_cv_main_return:-return}(0);
875 CF_EOF
877         cf_save_LIBS="$LIBS"
878         # This only works if we can look at the symbol table.  If a shared
879         # library is stripped for install, we cannot use that.  So we're forced
880         # to rely on the static library, noting that some packagers may not
881         # include it.
882         LIBS="-static -lgpm -dynamic $LIBS"
883         if AC_TRY_EVAL(ac_compile) ; then
884                 if AC_TRY_EVAL(ac_link) ; then
885                         cf_cv_check_gpm_wgetch=`nm conftest$ac_exeext | egrep '\<wgetch\>' | egrep '\<[[vVwW]]\>'`
886                         test -n "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=yes
887                         test -z "$cf_cv_check_gpm_wgetch" && cf_cv_check_gpm_wgetch=no
888                 fi
889         fi
890         rm -rf conftest*
891         LIBS="$cf_save_LIBS"
895 if test "$cf_cv_check_gpm_wgetch" != yes ; then
896         AC_MSG_WARN(GPM library is already linked with curses - read the FAQ)
898 ])])dnl
899 dnl ---------------------------------------------------------------------------
900 dnl CF_CPP_PARAM_INIT version: 4 updated: 2001/04/07 22:31:18
901 dnl -----------------
902 dnl Check if the C++ compiler accepts duplicate parameter initialization.  This
903 dnl is a late feature for the standard and is not in some recent compilers
904 dnl (1999/9/11).
905 AC_DEFUN([CF_CPP_PARAM_INIT],
907 if test -n "$CXX"; then
908 AC_CACHE_CHECK(if $CXX accepts parameter initialization,cf_cv_cpp_param_init,[
909         AC_LANG_SAVE
910         AC_LANG_CPLUSPLUS
911         AC_TRY_RUN([
912 class TEST {
913 private:
914         int value;
915 public:
916         TEST(int x = 1);
917         ~TEST();
920 TEST::TEST(int x = 1)   // some compilers do not like second initializer
922         value = x;
924 void main() { }
926         [cf_cv_cpp_param_init=yes],
927         [cf_cv_cpp_param_init=no],
928         [cf_cv_cpp_param_init=unknown])
929         AC_LANG_RESTORE
932 test "$cf_cv_cpp_param_init" = yes && AC_DEFINE(CPP_HAS_PARAM_INIT,[],[CPP_HAS_PARAM_INIT])
933 ])dnl
934 dnl ---------------------------------------------------------------------------
935 dnl CF_CPP_STATIC_CAST version: 1 updated: 2005/07/23 16:52:43
936 dnl ------------------
937 dnl Check if the C++ compiler accepts static_cast in generics.  This appears to
938 dnl not be supported in g++ before 3.0
939 AC_DEFUN([CF_CPP_STATIC_CAST],
941 if test -n "$CXX"; then
943 AC_CACHE_CHECK(if $CXX accepts static_cast,cf_cv_cpp_static_cast,[
944         AC_LANG_SAVE
945         AC_LANG_CPLUSPLUS
947         AC_TRY_COMPILE([
948 class NCursesPanel
950 public:
951   NCursesPanel(int nlines,
952                int ncols,
953                int begin_y = 0,
954                int begin_x = 0)
955   {
956   }
958   ~NCursesPanel();
961 template<class T> class NCursesUserPanel : public NCursesPanel
963 public:
964   NCursesUserPanel (int nlines,
965                     int ncols,
966                     int begin_y = 0,
967                     int begin_x = 0,
968                     const T* p_UserData = static_cast<T*>(0))
969     : NCursesPanel (nlines, ncols, begin_y, begin_x)
970   {
971   };
972   NCursesUserPanel(const T* p_UserData = static_cast<T*>(0)) : NCursesPanel()
973   {
974   };
976   virtual ~NCursesUserPanel() {};
979         const char* p_UserData = static_cast<char*>(0)],
980         [cf_cv_cpp_static_cast=yes],
981         [cf_cv_cpp_static_cast=no])
983         AC_LANG_RESTORE
988 test "$cf_cv_cpp_static_cast" = yes && AC_DEFINE(CPP_HAS_STATIC_CAST,[],[CPP_HAS_STATIC_CAST])
989 ])dnl
990 dnl ---------------------------------------------------------------------------
991 dnl CF_C_INLINE version: 3 updated: 2010/05/01 15:14:41
992 dnl -----------
993 dnl Check if the C compiler supports "inline".
994 dnl $1 is the name of a shell variable to set if inline is supported
995 dnl $2 is the threshold for gcc 4.x's option controlling maximum inline size
996 AC_DEFUN([CF_C_INLINE],[
997 AC_C_INLINE
999 if test "$ac_cv_c_inline" != no ; then
1000   $1=inline
1001   if test "$INTEL_COMPILER" = yes
1002   then
1003     :
1004   elif test "$GCC" = yes
1005   then
1006     AC_CACHE_CHECK(if $CC supports options to tune inlining,cf_cv_gcc_inline,[
1007       cf_save_CFLAGS=$CFLAGS
1008       CFLAGS="$CFLAGS --param max-inline-insns-single=$2"
1009       AC_TRY_COMPILE([inline int foo(void) { return 1; }],
1010       [${cf_cv_main_return:-return} foo()],
1011       [cf_cv_gcc_inline=yes],
1012       [cf_cv_gcc_inline=no])
1013       CFLAGS=$cf_save_CFLAGS
1014     ])
1015     if test "$cf_cv_gcc_inline" = yes ; then
1016         CF_ADD_CFLAGS([--param max-inline-insns-single=$2])
1017     fi
1018   fi
1020 AC_SUBST($1)
1021 ])dnl
1022 dnl ---------------------------------------------------------------------------
1023 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
1024 dnl ----------
1025 dnl "dirname" is not portable, so we fake it with a shell script.
1026 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
1027 dnl ---------------------------------------------------------------------------
1028 dnl CF_DIRS_TO_MAKE version: 3 updated: 2002/02/23 20:38:31
1029 dnl ---------------
1030 AC_DEFUN([CF_DIRS_TO_MAKE],
1032 DIRS_TO_MAKE="lib"
1033 for cf_item in $cf_list_models
1035         CF_OBJ_SUBDIR($cf_item,cf_subdir)
1036         for cf_item2 in $DIRS_TO_MAKE
1037         do
1038                 test $cf_item2 = $cf_subdir && break
1039         done
1040         test ".$cf_item2" != ".$cf_subdir" && DIRS_TO_MAKE="$DIRS_TO_MAKE $cf_subdir"
1041 done
1042 for cf_dir in $DIRS_TO_MAKE
1044         test ! -d $cf_dir && mkdir $cf_dir
1045 done
1046 AC_SUBST(DIRS_TO_MAKE)
1047 ])dnl
1048 dnl ---------------------------------------------------------------------------
1049 dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
1050 dnl ----------------
1051 dnl Combine no-leak checks with the libraries or tools that are used for the
1052 dnl checks.
1053 AC_DEFUN([CF_DISABLE_LEAKS],[
1055 AC_REQUIRE([CF_WITH_DMALLOC])
1056 AC_REQUIRE([CF_WITH_DBMALLOC])
1057 AC_REQUIRE([CF_WITH_VALGRIND])
1059 AC_MSG_CHECKING(if you want to perform memory-leak testing)
1060 AC_ARG_ENABLE(leaks,
1061         [  --disable-leaks         test: free permanent memory, analyze leaks],
1062         [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
1063         : ${with_no_leaks:=no})
1064 AC_MSG_RESULT($with_no_leaks)
1066 if test "$with_no_leaks" = yes ; then
1067         AC_DEFINE(NO_LEAKS)
1068         AC_DEFINE(YY_NO_LEAKS,[],[NO_LEAKS])
1070 ])dnl
1071 dnl ---------------------------------------------------------------------------
1072 dnl CF_DISABLE_LIBTOOL_VERSION version: 1 updated: 2010/05/15 15:45:59
1073 dnl --------------------------
1074 dnl Check if we should use the libtool 1.5 feature "-version-number" instead of
1075 dnl the older "-version-info" feature.  The newer feature allows us to use
1076 dnl version numbering on shared libraries which make them compatible with
1077 dnl various systems.
1078 AC_DEFUN([CF_DISABLE_LIBTOOL_VERSION],
1080 AC_MSG_CHECKING(if libtool -version-number should be used)
1081 CF_ARG_DISABLE(libtool-version,
1082         [  --disable-libtool-version  enable to use libtool's incompatible naming scheme],
1083         [cf_libtool_version=no],
1084         [cf_libtool_version=yes])
1085 AC_MSG_RESULT($cf_libtool_version)
1087 if test "$cf_libtool_version" = yes ; then
1088         LIBTOOL_VERSION="-version-number"
1089 else
1090         LIBTOOL_VERSION="-version-info"
1093 AC_SUBST(LIBTOOL_VERSION)
1094 ])dnl
1095 dnl ---------------------------------------------------------------------------
1096 dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
1097 dnl ---------------------
1098 dnl The rpath-hack makes it simpler to build programs, particularly with the
1099 dnl *BSD ports which may have essential libraries in unusual places.  But it
1100 dnl can interfere with building an executable for the base system.  Use this
1101 dnl option in that case.
1102 AC_DEFUN([CF_DISABLE_RPATH_HACK],
1104 AC_MSG_CHECKING(if rpath-hack should be disabled)
1105 CF_ARG_DISABLE(rpath-hack,
1106         [  --disable-rpath-hack    don't add rpath options for additional libraries],
1107         [cf_disable_rpath_hack=yes],
1108         [cf_disable_rpath_hack=no])
1109 AC_MSG_RESULT($cf_disable_rpath_hack)
1110 if test "$cf_disable_rpath_hack" = no ; then
1111         CF_RPATH_HACK
1114 dnl ---------------------------------------------------------------------------
1115 dnl CF_ENABLE_RPATH version: 2 updated: 2010/03/27 18:39:42
1116 dnl ---------------
1117 dnl Check if the rpath option should be used, setting cache variable
1118 dnl cf_cv_enable_rpath if so.
1119 AC_DEFUN([CF_ENABLE_RPATH],
1121 AC_MSG_CHECKING(if rpath option should be used)
1122 AC_ARG_ENABLE(rpath,
1123 [  --enable-rpath          use rpath option when generating shared libraries],
1124 [cf_cv_enable_rpath=$enableval],
1125 [cf_cv_enable_rpath=no])
1126 AC_MSG_RESULT($cf_cv_enable_rpath)
1127 ])dnl
1128 dnl ---------------------------------------------------------------------------
1129 dnl CF_ERRNO version: 5 updated: 1997/11/30 12:44:39
1130 dnl --------
1131 dnl Check if 'errno' is declared in <errno.h>
1132 AC_DEFUN([CF_ERRNO],
1134 CF_CHECK_ERRNO(errno)
1135 ])dnl
1136 dnl ---------------------------------------------------------------------------
1137 dnl CF_ETIP_DEFINES version: 3 updated: 2003/03/22 19:13:43
1138 dnl ---------------
1139 dnl Test for conflicting definitions of exception in gcc 2.8.0, etc., between
1140 dnl math.h and builtin.h, only for ncurses
1141 AC_DEFUN([CF_ETIP_DEFINES],
1143 AC_MSG_CHECKING(for special defines needed for etip.h)
1144 cf_save_CXXFLAGS="$CXXFLAGS"
1145 cf_result="none"
1146 for cf_math in "" MATH_H
1148 for cf_excp in "" MATH_EXCEPTION
1150         CXXFLAGS="$cf_save_CXXFLAGS -I${srcdir}/c++ -I${srcdir}/menu -I${srcdir}/include"
1151         test -n "$cf_math" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_math}"
1152         test -n "$cf_excp" && CXXFLAGS="$CXXFLAGS -DETIP_NEEDS_${cf_excp}"
1153 AC_TRY_COMPILE([
1154 #include <etip.h.in>
1155 ],[],[
1156         test -n "$cf_math" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_math})
1157         test -n "$cf_excp" && AC_DEFINE_UNQUOTED(ETIP_NEEDS_${cf_excp})
1158         cf_result="$cf_math $cf_excp"
1159         break
1160 ],[])
1161 done
1162 done
1163 AC_MSG_RESULT($cf_result)
1164 CXXFLAGS="$cf_save_CXXFLAGS"
1166 dnl ---------------------------------------------------------------------------
1167 dnl CF_FIND_LINKAGE version: 19 updated: 2010/05/29 16:31:02
1168 dnl ---------------
1169 dnl Find a library (specifically the linkage used in the code fragment),
1170 dnl searching for it if it is not already in the library path.
1171 dnl See also CF_ADD_SEARCHPATH.
1173 dnl Parameters (4-on are optional):
1174 dnl     $1 = headers for library entrypoint
1175 dnl     $2 = code fragment for library entrypoint
1176 dnl     $3 = the library name without the "-l" option or ".so" suffix.
1177 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
1178 dnl     $5 = action to perform if not successful
1179 dnl     $6 = module name, if not the same as the library name
1180 dnl     $7 = extra libraries
1182 dnl Sets these variables:
1183 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1184 dnl     $cf_cv_header_path_$3 - include-directory if needed
1185 dnl     $cf_cv_library_path_$3 - library-directory if needed
1186 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1187 AC_DEFUN([CF_FIND_LINKAGE],[
1189 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1190 # will be set on completion of the AC_TRY_LINK below.
1191 cf_cv_header_path_$3=
1192 cf_cv_library_path_$3=
1194 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1196 cf_save_LIBS="$LIBS"
1198 AC_TRY_LINK([$1],[$2],[
1199         cf_cv_find_linkage_$3=yes
1200         cf_cv_header_path_$3=/usr/include
1201         cf_cv_library_path_$3=/usr/lib
1204 LIBS="-l$3 $7 $cf_save_LIBS"
1206 AC_TRY_LINK([$1],[$2],[
1207         cf_cv_find_linkage_$3=yes
1208         cf_cv_header_path_$3=/usr/include
1209         cf_cv_library_path_$3=/usr/lib
1210         cf_cv_library_file_$3="-l$3"
1212         cf_cv_find_linkage_$3=no
1213         LIBS="$cf_save_LIBS"
1215     CF_VERBOSE(find linkage for $3 library)
1216     CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1218     cf_save_CPPFLAGS="$CPPFLAGS"
1219     cf_test_CPPFLAGS="$CPPFLAGS"
1221     CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1222     for cf_cv_header_path_$3 in $cf_search
1223     do
1224       if test -d $cf_cv_header_path_$3 ; then
1225         CF_VERBOSE(... testing $cf_cv_header_path_$3)
1226         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1227         AC_TRY_COMPILE([$1],[$2],[
1228             CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1229             cf_cv_find_linkage_$3=maybe
1230             cf_test_CPPFLAGS="$CPPFLAGS"
1231             break],[
1232             CPPFLAGS="$cf_save_CPPFLAGS"
1233             ])
1234       fi
1235     done
1237     if test "$cf_cv_find_linkage_$3" = maybe ; then
1239       CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1241       cf_save_LIBS="$LIBS"
1242       cf_save_LDFLAGS="$LDFLAGS"
1244       ifelse([$6],,,[
1245         CPPFLAGS="$cf_test_CPPFLAGS"
1246         LIBS="-l$3 $7 $cf_save_LIBS"
1247         AC_TRY_LINK([$1],[$2],[
1248             CF_VERBOSE(... found $3 library in system)
1249             cf_cv_find_linkage_$3=yes])
1250             CPPFLAGS="$cf_save_CPPFLAGS"
1251             LIBS="$cf_save_LIBS"
1252             ])
1254       if test "$cf_cv_find_linkage_$3" != yes ; then
1255         CF_LIBRARY_PATH(cf_search,$3)
1256         for cf_cv_library_path_$3 in $cf_search
1257         do
1258           if test -d $cf_cv_library_path_$3 ; then
1259             CF_VERBOSE(... testing $cf_cv_library_path_$3)
1260             CPPFLAGS="$cf_test_CPPFLAGS"
1261             LIBS="-l$3 $7 $cf_save_LIBS"
1262             LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1263             AC_TRY_LINK([$1],[$2],[
1264                 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1265                 cf_cv_find_linkage_$3=yes
1266                 cf_cv_library_file_$3="-l$3"
1267                 break],[
1268                 CPPFLAGS="$cf_save_CPPFLAGS"
1269                 LIBS="$cf_save_LIBS"
1270                 LDFLAGS="$cf_save_LDFLAGS"
1271                 ])
1272           fi
1273         done
1274         CPPFLAGS="$cf_save_CPPFLAGS"
1275         LDFLAGS="$cf_save_LDFLAGS"
1276       fi
1278     else
1279       cf_cv_find_linkage_$3=no
1280     fi
1281     ],$7)
1284 LIBS="$cf_save_LIBS"
1286 if test "$cf_cv_find_linkage_$3" = yes ; then
1287 ifelse([$4],,[
1288         CF_ADD_INCDIR($cf_cv_header_path_$3)
1289         CF_ADD_LIBDIR($cf_cv_library_path_$3)
1290         CF_ADD_LIB($3)
1291 ],[$4])
1292 else
1293 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1295 ])dnl
1296 dnl ---------------------------------------------------------------------------
1297 dnl CF_FUNC_DLSYM version: 2 updated: 2010/05/29 16:31:02
1298 dnl -------------
1299 dnl Test for dlsym() and related functions, as well as libdl.
1301 dnl Sets
1302 dnl     $cf_have_dlsym
1303 dnl     $cf_have_libdl
1304 AC_DEFUN([CF_FUNC_DLSYM],[
1305 cf_have_dlsym=no
1306 AC_CHECK_FUNC(dlsym,cf_have_dlsym=yes,[
1308 cf_have_libdl=no
1309 AC_CHECK_LIB(dl,dlsym,[
1310         cf_have_dlsym=yes
1311         cf_have_libdl=yes])])
1313 if test "$cf_have_dlsym" = yes ; then
1314         test "$cf_have_libdl" = yes && CF_ADD_LIB(dl)
1316         AC_MSG_CHECKING(whether able to link to dl*() functions)
1317         AC_TRY_LINK([#include <dlfcn.h>],[
1318                 void *obj;
1319                 if ((obj = dlopen("filename", 0)) != 0) {
1320                         if (dlsym(obj, "symbolname") == 0) {
1321                         dlclose(obj);
1322                         }
1323                 }],[
1324                 AC_DEFINE(HAVE_LIBDL,[],[HAVE_LIBDL])],[
1325                 AC_MSG_ERROR(Cannot link test program for libdl)])
1326         AC_MSG_RESULT(ok)
1327 else
1328         AC_MSG_ERROR(Cannot find dlsym function)
1331 dnl ---------------------------------------------------------------------------
1332 dnl CF_FUNC_MEMMOVE version: 7 updated: 2006/12/16 12:33:30
1333 dnl ---------------
1334 dnl Check for memmove, or a bcopy that can handle overlapping copy.  If neither
1335 dnl is found, add our own version of memmove to the list of objects.
1336 AC_DEFUN([CF_FUNC_MEMMOVE],
1338 AC_CHECK_FUNC(memmove,,[
1339 AC_CHECK_FUNC(bcopy,[
1340         AC_CACHE_CHECK(if bcopy does overlapping moves,cf_cv_good_bcopy,[
1341                 AC_TRY_RUN([
1342 int main() {
1343         static char data[] = "abcdefghijklmnopqrstuwwxyz";
1344         char temp[40];
1345         bcopy(data, temp, sizeof(data));
1346         bcopy(temp+10, temp, 15);
1347         bcopy(temp+5, temp+15, 10);
1348         ${cf_cv_main_return:-return} (strcmp(temp, "klmnopqrstuwwxypqrstuwwxyz"));
1350                 ],
1351                 [cf_cv_good_bcopy=yes],
1352                 [cf_cv_good_bcopy=no],
1353                 [cf_cv_good_bcopy=unknown])
1354                 ])
1355         ],[cf_cv_good_bcopy=no])
1356         if test "$cf_cv_good_bcopy" = yes ; then
1357                 AC_DEFINE(USE_OK_BCOPY,[],[USE_OK_BCOPY])
1358         else
1359                 AC_DEFINE(USE_MY_MEMMOVE,[],[USE_MY_MEMMOVE])
1360         fi
1361 ])])dnl
1362 dnl ---------------------------------------------------------------------------
1363 dnl CF_FUNC_NANOSLEEP version: 3 updated: 2006/12/16 12:33:30
1364 dnl -----------------
1365 dnl Check for existence of workable nanosleep() function.  Some systems, e.g.,
1366 dnl AIX 4.x, provide a non-working version.
1367 AC_DEFUN([CF_FUNC_NANOSLEEP],[
1368 AC_CACHE_CHECK(if nanosleep really works,cf_cv_func_nanosleep,[
1369 AC_TRY_RUN([
1370 #include <stdio.h>
1371 #include <errno.h>
1372 #include <time.h>
1374 #ifdef HAVE_SYS_TIME_H
1375 #include <sys/time.h>
1376 #endif
1378 int main() {
1379         struct timespec ts1, ts2;
1380         int code;
1381         ts1.tv_sec  = 0;
1382         ts1.tv_nsec = 750000000;
1383         ts2.tv_sec  = 0;
1384         ts2.tv_nsec = 0;
1385         errno = 0;
1386         code = nanosleep(&ts1, &ts2); /* on failure errno is ENOSYS. */
1387         ${cf_cv_main_return:-return}(code != 0);
1390         [cf_cv_func_nanosleep=yes],
1391         [cf_cv_func_nanosleep=no],
1392         [cf_cv_func_nanosleep=unknown])])
1394 test "$cf_cv_func_nanosleep" = "yes" && AC_DEFINE(HAVE_NANOSLEEP,[],[HAVE_NANOSLEEP])
1396 dnl ---------------------------------------------------------------------------
1397 dnl CF_FUNC_OPENPTY version: 3 updated: 2010/05/29 16:31:02
1398 dnl ---------------
1399 dnl Check for openpty() function, along with <pty.h> header.  It may need the
1400 dnl "util" library as well.
1401 AC_DEFUN([CF_FUNC_OPENPTY],
1403 AC_CHECK_LIB(util,openpty,cf_cv_lib_util=yes,cf_cv_lib_util=no)
1404 AC_CACHE_CHECK(for openpty header,cf_cv_func_openpty,[
1405     cf_save_LIBS="$LIBS"
1406     test $cf_cv_lib_util = yes && CF_ADD_LIB(util)
1407     for cf_header in pty.h libutil.h util.h
1408     do
1409     AC_TRY_LINK([
1410 #include <$cf_header>
1412     int x = openpty((int *)0, (int *)0, (char *)0,
1413                    (struct termios *)0, (struct winsize *)0);
1415         cf_cv_func_openpty=$cf_header
1416         break
1418         cf_cv_func_openpty=no
1420     done
1421     LIBS="$cf_save_LIBS"
1423 ])dnl
1424 dnl ---------------------------------------------------------------------------
1425 dnl CF_FUNC_POLL version: 4 updated: 2006/12/16 12:33:30
1426 dnl ------------
1427 dnl See if the poll function really works.  Some platforms have poll(), but
1428 dnl it does not work for terminals or files.
1429 AC_DEFUN([CF_FUNC_POLL],[
1430 AC_CACHE_CHECK(if poll really works,cf_cv_working_poll,[
1431 AC_TRY_RUN([
1432 #include <stdio.h>
1433 #ifdef HAVE_POLL_H
1434 #include <poll.h>
1435 #else
1436 #include <sys/poll.h>
1437 #endif
1438 int main() {
1439         struct pollfd myfds;
1440         int ret;
1442         myfds.fd = 0;
1443         myfds.events = POLLIN;
1445         ret = poll(&myfds, 1, 100);
1446         ${cf_cv_main_return:-return}(ret != 0);
1448         [cf_cv_working_poll=yes],
1449         [cf_cv_working_poll=no],
1450         [cf_cv_working_poll=unknown])])
1451 test "$cf_cv_working_poll" = "yes" && AC_DEFINE(HAVE_WORKING_POLL,[],[HAVE_WORKING_POLL])
1452 ])dnl
1453 dnl ---------------------------------------------------------------------------
1454 dnl CF_FUNC_TERMIOS version: 2 updated: 2000/07/22 23:37:24
1455 dnl ---------------
1456 dnl Some old/broken variations define tcgetattr() only as a macro in
1457 dnl termio(s).h
1458 AC_DEFUN([CF_FUNC_TERMIOS],[
1459 AC_REQUIRE([CF_STRUCT_TERMIOS])
1460 AC_CACHE_CHECK(for tcgetattr, cf_cv_have_tcgetattr,[
1461 AC_TRY_LINK([
1462 #include <sys/types.h>
1463 #ifdef HAVE_UNISTD_H
1464 #include <unistd.h>
1465 #endif
1466 #ifdef HAVE_TERMIOS_H
1467 #include <termios.h>
1468 #define TTY struct termios
1469 #else
1470 #ifdef HAVE_TERMIO_H
1471 #include <termio.h>
1472 #define TTY struct termio
1473 #endif
1474 #endif
1476 TTY foo;
1477 tcgetattr(1, &foo);],
1478 [cf_cv_have_tcgetattr=yes],
1479 [cf_cv_have_tcgetattr=no])])
1480 test "$cf_cv_have_tcgetattr" = yes && AC_DEFINE(HAVE_TCGETATTR,[],[HAVE_TCGETATTR])
1481 ])dnl
1482 dnl ---------------------------------------------------------------------------
1483 dnl CF_FUNC_VSSCANF version: 3 updated: 2001/12/19 00:50:10
1484 dnl ---------------
1485 dnl Check for vsscanf() function, which is in c9x but generally not in earlier
1486 dnl versions of C.  It is in the GNU C library, and can often be simulated by
1487 dnl other functions.
1488 AC_DEFUN([CF_FUNC_VSSCANF],
1490 AC_CACHE_CHECK(for vsscanf function or workaround,cf_cv_func_vsscanf,[
1491 AC_TRY_LINK([
1492 #include <stdarg.h>
1493 #include <stdio.h>],[
1494         va_list ap;
1495         vsscanf("from", "%d", ap)],[cf_cv_func_vsscanf=vsscanf],[
1496 AC_TRY_LINK([
1497 #include <stdarg.h>
1498 #include <stdio.h>],[
1499     FILE strbuf;
1500     char *str = "from";
1502     strbuf._flag = _IOREAD;
1503     strbuf._ptr = strbuf._base = (unsigned char *) str;
1504     strbuf._cnt = strlen(str);
1505     strbuf._file = _NFILE;
1506     return (vfscanf(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=vfscanf],[
1507 AC_TRY_LINK([
1508 #include <stdarg.h>
1509 #include <stdio.h>],[
1510     FILE strbuf;
1511     char *str = "from";
1513     strbuf._flag = _IOREAD;
1514     strbuf._ptr = strbuf._base = (unsigned char *) str;
1515     strbuf._cnt = strlen(str);
1516     strbuf._file = _NFILE;
1517     return (_doscan(&strbuf, "%d", ap))],[cf_cv_func_vsscanf=_doscan],[
1518 cf_cv_func_vsscanf=no])])])])
1520 case $cf_cv_func_vsscanf in #(vi
1521 vsscanf) AC_DEFINE(HAVE_VSSCANF,[],[HAVE_VSSCANF]);; #(vi
1522 vfscanf) AC_DEFINE(HAVE_VFSCANF,[1],[HAVE_VSSCANF]);; #(vi
1523 _doscan) AC_DEFINE(HAVE__DOSCAN,[],[HAVE__DOSCAN]);;
1524 esac
1526 ])dnl
1527 dnl ---------------------------------------------------------------------------
1528 dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
1529 dnl -----------------
1530 dnl Test for availability of useful gcc __attribute__ directives to quiet
1531 dnl compiler warnings.  Though useful, not all are supported -- and contrary
1532 dnl to documentation, unrecognized directives cause older compilers to barf.
1533 AC_DEFUN([CF_GCC_ATTRIBUTES],
1535 if test "$GCC" = yes
1536 then
1537 cat > conftest.i <<EOF
1538 #ifndef GCC_PRINTF
1539 #define GCC_PRINTF 0
1540 #endif
1541 #ifndef GCC_SCANF
1542 #define GCC_SCANF 0
1543 #endif
1544 #ifndef GCC_NORETURN
1545 #define GCC_NORETURN /* nothing */
1546 #endif
1547 #ifndef GCC_UNUSED
1548 #define GCC_UNUSED /* nothing */
1549 #endif
1551 if test "$GCC" = yes
1552 then
1553         AC_CHECKING([for $CC __attribute__ directives])
1554 cat > conftest.$ac_ext <<EOF
1555 #line __oline__ "${as_me:-configure}"
1556 #include "confdefs.h"
1557 #include "conftest.h"
1558 #include "conftest.i"
1559 #if     GCC_PRINTF
1560 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1561 #else
1562 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1563 #endif
1564 #if     GCC_SCANF
1565 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1566 #else
1567 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
1568 #endif
1569 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1570 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1571 extern void foo(void) GCC_NORETURN;
1572 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1574         cf_printf_attribute=no
1575         cf_scanf_attribute=no
1576         for cf_attribute in scanf printf unused noreturn
1577         do
1578                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1579                 cf_directive="__attribute__(($cf_attribute))"
1580                 echo "checking for $CC $cf_directive" 1>&AS_MESSAGE_LOG_FD
1582                 case $cf_attribute in #(vi
1583                 printf) #(vi
1584                         cf_printf_attribute=yes
1585                         cat >conftest.h <<EOF
1586 #define GCC_$cf_ATTRIBUTE 1
1588                         ;;
1589                 scanf) #(vi
1590                         cf_scanf_attribute=yes
1591                         cat >conftest.h <<EOF
1592 #define GCC_$cf_ATTRIBUTE 1
1594                         ;;
1595                 *) #(vi
1596                         cat >conftest.h <<EOF
1597 #define GCC_$cf_ATTRIBUTE $cf_directive
1599                         ;;
1600                 esac
1602                 if AC_TRY_EVAL(ac_compile); then
1603                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1604                         cat conftest.h >>confdefs.h
1605                         case $cf_attribute in #(vi
1606                         printf) #(vi
1607                                 if test "$cf_printf_attribute" = no ; then
1608                                         cat >>confdefs.h <<EOF
1609 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
1611                                 else
1612                                         cat >>confdefs.h <<EOF
1613 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1615                                 fi
1616                                 ;;
1617                         scanf) #(vi
1618                                 if test "$cf_scanf_attribute" = no ; then
1619                                         cat >>confdefs.h <<EOF
1620 #define GCC_SCANFLIKE(fmt,var) /* nothing */
1622                                 else
1623                                         cat >>confdefs.h <<EOF
1624 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
1626                                 fi
1627                                 ;;
1628                         esac
1629                 fi
1630         done
1631 else
1632         fgrep define conftest.i >>confdefs.h
1634 rm -rf conftest*
1636 ])dnl
1637 dnl ---------------------------------------------------------------------------
1638 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
1639 dnl --------------
1640 dnl Find version of gcc
1641 AC_DEFUN([CF_GCC_VERSION],[
1642 AC_REQUIRE([AC_PROG_CC])
1643 GCC_VERSION=none
1644 if test "$GCC" = yes ; then
1645         AC_MSG_CHECKING(version of $CC)
1646         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1647         test -z "$GCC_VERSION" && GCC_VERSION=unknown
1648         AC_MSG_RESULT($GCC_VERSION)
1650 ])dnl
1651 dnl ---------------------------------------------------------------------------
1652 dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
1653 dnl ---------------
1654 dnl Check if the compiler supports useful warning options.  There's a few that
1655 dnl we don't use, simply because they're too noisy:
1657 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1658 dnl     -Wredundant-decls (system headers make this too noisy)
1659 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
1660 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
1661 dnl             is enabled for ncurses using "--enable-const".
1662 dnl     -pedantic
1664 dnl Parameter:
1665 dnl     $1 is an optional list of gcc warning flags that a particular
1666 dnl             application might want to use, e.g., "no-unused" for
1667 dnl             -Wno-unused
1668 dnl Special:
1669 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
1671 AC_DEFUN([CF_GCC_WARNINGS],
1673 AC_REQUIRE([CF_GCC_VERSION])
1674 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1676 cat > conftest.$ac_ext <<EOF
1677 #line __oline__ "${as_me:-configure}"
1678 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1681 if test "$INTEL_COMPILER" = yes
1682 then
1683 # The "-wdXXX" options suppress warnings:
1684 # remark #1419: external declaration in primary source file
1685 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1686 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1687 # remark #193: zero used for undefined preprocessing identifier
1688 # remark #593: variable "curs_sb_left_arrow" was set but never used
1689 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1690 # remark #869: parameter "tw" was never referenced
1691 # remark #981: operands are evaluated in unspecified order
1692 # warning #279: controlling expression is constant
1694         AC_CHECKING([for $CC warning options])
1695         cf_save_CFLAGS="$CFLAGS"
1696         EXTRA_CFLAGS="-Wall"
1697         for cf_opt in \
1698                 wd1419 \
1699                 wd1683 \
1700                 wd1684 \
1701                 wd193 \
1702                 wd593 \
1703                 wd279 \
1704                 wd810 \
1705                 wd869 \
1706                 wd981
1707         do
1708                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1709                 if AC_TRY_EVAL(ac_compile); then
1710                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1711                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1712                 fi
1713         done
1714         CFLAGS="$cf_save_CFLAGS"
1716 elif test "$GCC" = yes
1717 then
1718         AC_CHECKING([for $CC warning options])
1719         cf_save_CFLAGS="$CFLAGS"
1720         EXTRA_CFLAGS=
1721         cf_warn_CONST=""
1722         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1723         for cf_opt in W Wall \
1724                 Wbad-function-cast \
1725                 Wcast-align \
1726                 Wcast-qual \
1727                 Winline \
1728                 Wmissing-declarations \
1729                 Wmissing-prototypes \
1730                 Wnested-externs \
1731                 Wpointer-arith \
1732                 Wshadow \
1733                 Wstrict-prototypes \
1734                 Wundef $cf_warn_CONST $1
1735         do
1736                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1737                 if AC_TRY_EVAL(ac_compile); then
1738                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1739                         case $cf_opt in #(vi
1740                         Wcast-qual) #(vi
1741                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1742                                 ;;
1743                         Winline) #(vi
1744                                 case $GCC_VERSION in
1745                                 [[34]].*)
1746                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1747                                         continue;;
1748                                 esac
1749                                 ;;
1750                         esac
1751                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1752                 fi
1753         done
1754         CFLAGS="$cf_save_CFLAGS"
1756 rm -rf conftest*
1758 AC_SUBST(EXTRA_CFLAGS)
1759 ])dnl
1760 dnl ---------------------------------------------------------------------------
1761 dnl CF_GNAT_GENERICS version: 1 updated: 2010/11/13 14:15:18
1762 dnl ----------------
1763 AC_DEFUN([CF_GNAT_GENERICS],
1765 AC_MSG_CHECKING(if GNAT supports generics)
1766 case $cf_gnat_version in #(vi
1767 3.[[1-9]]*|[[4-9]].*) #(vi
1768         cf_gnat_generics=yes
1769         ;;
1771         cf_gnat_generics=no
1772         ;;
1773 esac
1774 AC_MSG_RESULT($cf_gnat_generics)
1776 if test "$cf_gnat_generics" = yes
1777 then
1778         cf_compile_generics=generics
1779         cf_generic_objects="\${GENOBJS}"
1780 else
1781         cf_compile_generics=
1782         cf_generic_objects=
1785 AC_SUBST(cf_compile_generics)
1786 AC_SUBST(cf_generic_objects)
1787 ])dnl
1788 dnl ---------------------------------------------------------------------------
1789 dnl CF_GNAT_PRAGMA_UNREF version: 1 updated: 2010/06/19 15:22:18
1790 dnl --------------------
1791 dnl Check if the gnat pragma "Unreferenced" works.
1792 AC_DEFUN([CF_GNAT_PRAGMA_UNREF],[
1793 AC_CACHE_CHECK(if GNAT pragma Unreferenced works,cf_cv_pragma_unreferenced,[
1794 CF_GNAT_TRY_LINK([procedure conftest;],
1795 [with Text_IO;
1796 with GNAT.OS_Lib;
1797 procedure conftest is
1798    test : Integer;
1799    pragma Unreferenced (test);
1800 begin
1801    test := 1;
1802    Text_IO.Put ("Hello World");
1803    Text_IO.New_Line;
1804    GNAT.OS_Lib.OS_Exit (0);
1805 end conftest;],
1806         [cf_cv_pragma_unreferenced=yes],
1807         [cf_cv_pragma_unreferenced=no])])
1809 # if the pragma is supported, use it (needed in the Trace code).
1810 if test $cf_cv_pragma_unreferenced = yes ; then
1811         PRAGMA_UNREF=TRUE
1812 else
1813         PRAGMA_UNREF=FALSE
1815 AC_SUBST(PRAGMA_UNREF)
1816 ])dnl
1817 dnl ---------------------------------------------------------------------------
1818 dnl CF_GNAT_PROJECTS version: 1 updated: 2010/11/13 14:15:18
1819 dnl ----------------
1820 AC_DEFUN([CF_GNAT_PROJECTS],
1822 AC_MSG_CHECKING(if GNAT supports project files)
1823 case $cf_gnat_version in #(vi
1824 3.[[0-9]]*) #(vi
1825         cf_gnat_projects=no
1826         ;;
1828         case $cf_cv_system_name in #(vi
1829         cygwin*) #(vi
1830                 cf_gnat_projects=no
1831                 ;;
1832         *)
1833                 cf_gnat_projects=yes
1834                 ;;
1835         esac
1836         ;;
1837 esac
1838 AC_MSG_RESULT($cf_gnat_projects)
1840 if test "$cf_gnat_projects" = yes
1841 then
1842         USE_OLD_MAKERULES="#"
1843         USE_GNAT_PROJECTS=""
1844 else
1845         USE_OLD_MAKERULES=""
1846         USE_GNAT_PROJECTS="#"
1849 AC_SUBST(USE_OLD_MAKERULES)
1850 AC_SUBST(USE_GNAT_PROJECTS)
1851 ])dnl
1852 dnl ---------------------------------------------------------------------------
1853 dnl CF_GNAT_TRY_LINK version: 2 updated: 2010/08/14 18:25:37
1854 dnl ----------------
1855 dnl Verify that a test program compiles/links with GNAT.
1856 dnl $cf_ada_make is set to the program that compiles/links
1857 dnl $ADAFLAGS may be set to the GNAT flags.
1859 dnl $1 is the text of the spec
1860 dnl $2 is the text of the body
1861 dnl $3 is the shell command to execute if successful
1862 dnl $4 is the shell command to execute if not successful
1863 AC_DEFUN([CF_GNAT_TRY_LINK],
1865 rm -rf conftest*
1866 cat >>conftest.ads <<CF_EOF
1868 CF_EOF
1869 cat >>conftest.adb <<CF_EOF
1871 CF_EOF
1872 if ( $cf_ada_make $ADAFLAGS conftest 1>&AS_MESSAGE_LOG_FD 2>&1 ) ; then
1873 ifelse($3,,      :,[      $3])
1874 ifelse($4,,,[else
1875    $4])
1877 rm -rf conftest*
1878 ])dnl
1879 dnl ---------------------------------------------------------------------------
1880 dnl CF_GNAT_TRY_RUN version: 4 updated: 2010/08/14 18:25:37
1881 dnl ---------------
1882 dnl Verify that a test program compiles and runs with GNAT
1883 dnl $cf_ada_make is set to the program that compiles/links
1884 dnl $ADAFLAGS may be set to the GNAT flags.
1886 dnl $1 is the text of the spec
1887 dnl $2 is the text of the body
1888 dnl $3 is the shell command to execute if successful
1889 dnl $4 is the shell command to execute if not successful
1890 AC_DEFUN([CF_GNAT_TRY_RUN],
1892 rm -rf conftest*
1893 cat >>conftest.ads <<CF_EOF
1895 CF_EOF
1896 cat >>conftest.adb <<CF_EOF
1898 CF_EOF
1899 if ( $cf_ada_make $ADAFLAGS conftest 1>&AS_MESSAGE_LOG_FD 2>&1 ) ; then
1900    if ( ./conftest 1>&AS_MESSAGE_LOG_FD 2>&1 ) ; then
1901 ifelse($3,,      :,[      $3])
1902 ifelse($4,,,[   else
1903       $4])
1904    fi
1905 ifelse($4,,,[else
1906    $4])
1908 rm -rf conftest*
1909 ])dnl
1910 dnl ---------------------------------------------------------------------------
1911 dnl CF_GNAT_VERSION version: 16 updated: 2010/11/13 14:15:18
1912 dnl ---------------
1913 dnl Verify version of GNAT.
1914 AC_DEFUN([CF_GNAT_VERSION],
1916 AC_MSG_CHECKING(for gnat version)
1917 cf_gnat_version=`${cf_ada_make:-gnatmake} -v 2>&1 | \
1918         grep '[[0-9]].[[0-9]][[0-9]]*' |\
1919     sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
1920 AC_MSG_RESULT($cf_gnat_version)
1922 case $cf_gnat_version in #(vi
1923 3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*) #(vi
1924         cf_cv_prog_gnat_correct=yes
1925         ;;
1927         AC_MSG_WARN(Unsupported GNAT version $cf_gnat_version. We require 3.11 or better. Disabling Ada95 binding.)
1928         cf_cv_prog_gnat_correct=no
1929         ;;
1930 esac
1932 CF_GNAT_GENERICS
1933 CF_GNAT_PROJECTS
1935 dnl ---------------------------------------------------------------------------
1936 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1937 dnl -------------
1938 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1939 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1940 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1941 dnl since it is interwoven with GNU extensions.
1943 dnl Well, yes we could work around it...
1944 AC_DEFUN([CF_GNU_SOURCE],
1946 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1947 AC_TRY_COMPILE([#include <sys/types.h>],[
1948 #ifndef _XOPEN_SOURCE
1949 make an error
1950 #endif],
1951         [cf_cv_gnu_source=no],
1952         [cf_save="$CPPFLAGS"
1953          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1954          AC_TRY_COMPILE([#include <sys/types.h>],[
1955 #ifdef _XOPEN_SOURCE
1956 make an error
1957 #endif],
1958         [cf_cv_gnu_source=no],
1959         [cf_cv_gnu_source=yes])
1960         CPPFLAGS="$cf_save"
1961         ])
1963 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1964 ])dnl
1965 dnl ---------------------------------------------------------------------------
1966 dnl CF_GPP_LIBRARY version: 10 updated: 2010/05/29 16:31:02
1967 dnl --------------
1968 dnl If we're trying to use g++, test if libg++ is installed (a rather common
1969 dnl problem :-).  If we have the compiler but no library, we'll be able to
1970 dnl configure, but won't be able to build the c++ demo program.
1971 AC_DEFUN([CF_GPP_LIBRARY],
1973 cf_cxx_library=unknown
1974 case $cf_cv_system_name in #(vi
1975 os2*) #(vi
1976         cf_gpp_libname=gpp
1977         ;;
1979         cf_gpp_libname=g++
1980         ;;
1981 esac
1982 if test "$GXX" = yes; then
1983         AC_MSG_CHECKING([for lib$cf_gpp_libname])
1984         cf_save="$LIBS"
1985         CF_ADD_LIB($cf_gpp_libname)
1986         AC_TRY_LINK([
1987 #include <$cf_gpp_libname/builtin.h>
1988         ],
1989         [two_arg_error_handler_t foo2 = lib_error_handler],
1990         [cf_cxx_library=yes
1991          CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
1992          if test "$cf_gpp_libname" = cpp ; then
1993             AC_DEFINE(HAVE_GPP_BUILTIN_H,[],[HAVE_GPP_BUILTIN_H])
1994          else
1995             AC_DEFINE(HAVE_GXX_BUILTIN_H,[],[HAVE_GXX_BUILTIN_H])
1996          fi],
1997         [AC_TRY_LINK([
1998 #include <builtin.h>
1999         ],
2000         [two_arg_error_handler_t foo2 = lib_error_handler],
2001         [cf_cxx_library=yes
2002          CF_ADD_LIB($cf_gpp_libname,CXXLIBS)
2003          AC_DEFINE(HAVE_BUILTIN_H,[],[HAVE_BUILTIN_H])],
2004         [cf_cxx_library=no])])
2005         LIBS="$cf_save"
2006         AC_MSG_RESULT($cf_cxx_library)
2008 ])dnl
2009 dnl ---------------------------------------------------------------------------
2010 dnl CF_GXX_VERSION version: 6 updated: 2010/10/23 15:44:18
2011 dnl --------------
2012 dnl Check for version of g++
2013 AC_DEFUN([CF_GXX_VERSION],[
2014 AC_REQUIRE([AC_PROG_CPP])
2015 GXX_VERSION=none
2016 if test "$GXX" = yes; then
2017         AC_MSG_CHECKING(version of g++)
2018         GXX_VERSION="`${CXX:-g++} --version| sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
2019         test -z "$GXX_VERSION" && GXX_VERSION=unknown
2020         AC_MSG_RESULT($GXX_VERSION)
2022 ])dnl
2023 dnl ---------------------------------------------------------------------------
2024 dnl CF_GXX_WARNINGS version: 6 updated: 2010/08/14 18:25:37
2025 dnl ---------------
2026 dnl Check if the compiler supports useful warning options.
2028 dnl Most of gcc's options apply to g++, except:
2029 dnl     -Wbad-function-cast
2030 dnl     -Wmissing-declarations
2031 dnl     -Wnested-externs
2033 dnl Omit a few (for now):
2034 dnl     -Winline
2036 dnl Parameter:
2037 dnl     $1 is an optional list of g++ warning flags that a particular
2038 dnl             application might want to use, e.g., "no-unused" for
2039 dnl             -Wno-unused
2040 dnl Special:
2041 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
2043 AC_DEFUN([CF_GXX_WARNINGS],
2046 CF_INTEL_COMPILER(GXX,INTEL_CPLUSPLUS,CXXFLAGS)
2048 AC_REQUIRE([CF_GXX_VERSION])
2050 AC_LANG_SAVE
2051 AC_LANG_CPLUSPLUS
2053 cat > conftest.$ac_ext <<EOF
2054 #line __oline__ "configure"
2055 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
2058 if test "$INTEL_CPLUSPLUS" = yes
2059 then
2060 # The "-wdXXX" options suppress warnings:
2061 # remark #1419: external declaration in primary source file
2062 # remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2063 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
2064 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
2065 # remark #193: zero used for undefined preprocessing identifier
2066 # remark #593: variable "curs_sb_left_arrow" was set but never used
2067 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
2068 # remark #869: parameter "tw" was never referenced
2069 # remark #981: operands are evaluated in unspecified order
2070 # warning #269: invalid format string conversion
2072         AC_CHECKING([for $CC warning options])
2073         cf_save_CXXFLAGS="$CXXFLAGS"
2074         EXTRA_CXXFLAGS="-Wall"
2075         for cf_opt in \
2076                 wd1419 \
2077                 wd1682 \
2078                 wd1683 \
2079                 wd1684 \
2080                 wd193 \
2081                 wd279 \
2082                 wd593 \
2083                 wd810 \
2084                 wd869 \
2085                 wd981
2086         do
2087                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -$cf_opt"
2088                 if AC_TRY_EVAL(ac_compile); then
2089                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2090                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
2091                 fi
2092         done
2093         CXXFLAGS="$cf_save_CXXFLAGS"
2095 elif test "$GXX" = yes
2096 then
2097         AC_CHECKING([for $CXX warning options])
2098         cf_save_CXXFLAGS="$CXXFLAGS"
2099         EXTRA_CXXFLAGS="-W -Wall"
2100         cf_gxx_extra_warnings=""
2101         test "$with_ext_const" = yes && cf_gxx_extra_warnings="Wwrite-strings"
2102         case "$GCC_VERSION" in
2103         [[1-2]].*)
2104                 ;;
2105         *)
2106                 cf_gxx_extra_warnings="$cf_gxx_extra_warnings Weffc++"
2107                 ;;
2108         esac
2109         for cf_opt in \
2110                 Wabi \
2111                 fabi-version=0 \
2112                 Woverloaded-virtual \
2113                 Wsign-promo \
2114                 Wsynth \
2115                 Wold-style-cast \
2116                 Wcast-align \
2117                 Wcast-qual \
2118                 Wmissing-prototypes \
2119                 Wpointer-arith \
2120                 Wshadow \
2121                 Wstrict-prototypes \
2122                 Wundef $cf_gxx_extra_warnings $1
2123         do
2124                 CXXFLAGS="$cf_save_CXXFLAGS $EXTRA_CXXFLAGS -Werror -$cf_opt"
2125                 if AC_TRY_EVAL(ac_compile); then
2126                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
2127                         EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS -$cf_opt"
2128                 else
2129                         test -n "$verbose" && AC_MSG_RESULT(... no -$cf_opt)
2130                 fi
2131         done
2132         CXXFLAGS="$cf_save_CXXFLAGS"
2135 rm -rf conftest*
2136 AC_LANG_RESTORE
2137 AC_SUBST(EXTRA_CXXFLAGS)
2138 ])dnl
2139 dnl ---------------------------------------------------------------------------
2140 dnl CF_HASHED_DB version: 4 updated: 2010/05/29 16:31:02
2141 dnl ------------
2142 dnl Look for an instance of the Berkeley hashed database.
2144 dnl $1 = optional parameter, to specify install-prefix for the database.
2145 AC_DEFUN([CF_HASHED_DB],
2147 ifelse([$1],,,[
2148 case $1 in #(vi
2149 yes|*able*) #(vi
2150     ;;
2152     if test -d "$1" ; then
2153         CF_ADD_INCDIR($1/include)
2154         CF_ADD_LIBDIR($1/lib)
2155     fi
2156 esac
2158 AC_CHECK_HEADER(db.h,[
2159 CF_HASHED_DB_VERSION
2160 if test "$cf_cv_hashed_db_version" = unknown ; then
2161         AC_MSG_ERROR(Cannot determine version of db)
2162 else
2163         CF_HASHED_DB_LIBS
2164         if test "$cf_cv_hashed_db_libs" = unknown ; then
2165                 AC_MSG_ERROR(Cannot determine library for db)
2166         elif test "$cf_cv_hashed_db_libs" != default ; then
2167                 CF_ADD_LIB($cf_cv_hashed_db_libs)
2168         fi
2171         AC_MSG_ERROR(Cannot find db.h)
2173 ])dnl
2174 dnl ---------------------------------------------------------------------------
2175 dnl CF_HASHED_DB_LIBS version: 9 updated: 2010/05/29 16:31:02
2176 dnl -----------------
2177 dnl Given that we have the header and version for hashed database, find the
2178 dnl library information.
2179 AC_DEFUN([CF_HASHED_DB_LIBS],
2181 AC_CACHE_CHECK(for db libraries, cf_cv_hashed_db_libs,[
2182 cf_cv_hashed_db_libs=unknown
2183 for cf_db_libs in "" db$cf_cv_hashed_db_version db-$cf_cv_hashed_db_version db ''
2185         cf_save_libs="$LIBS"
2186         if test -n "$cf_db_libs"; then
2187                 CF_ADD_LIB($cf_db_libs)
2188         fi
2189         CF_MSG_LOG(checking for library "$cf_db_libs")
2190         AC_TRY_LINK([
2191 $ac_includes_default
2192 #include <db.h>
2194         char *path = "/tmp/foo";
2195 #ifdef DB_VERSION_MAJOR
2196 #if DB_VERSION_MAJOR >= 4
2197         DB *result = 0;
2198         db_create(&result, NULL, 0);
2199         result->open(result,
2200                 NULL,
2201                 path,
2202                 path,
2203                 DB_HASH,
2204                 DB_CREATE,
2205                 0644);
2206 #elif DB_VERSION_MAJOR >= 3
2207         DB *result = 0;
2208         db_create(&result, NULL, 0);
2209         result->open(result,
2210                 path,
2211                 path,
2212                 DB_HASH,
2213                 DB_CREATE,
2214                 0644);
2215 #elif DB_VERSION_MAJOR >= 2
2216         DB *result = 0;
2217         db_open(path,
2218                 DB_HASH,
2219                 DB_CREATE,
2220                 0644,
2221                 (DB_ENV *) 0,
2222                 (DB_INFO *) 0,
2223                 &result);
2224 #endif /* DB_VERSION_MAJOR */
2225 #else
2226         DB *result = dbopen(path,
2227                      2,
2228                      0644,
2229                      DB_HASH,
2230                      0);
2231 #endif
2232         ${cf_cv_main_return:-return}(result != 0)
2234         if test -n "$cf_db_libs" ; then
2235                 cf_cv_hashed_db_libs=$cf_db_libs
2236         else
2237                 cf_cv_hashed_db_libs=default
2238         fi
2239         LIBS="$cf_save_libs"
2240         break
2242         LIBS="$cf_save_libs"
2243 done
2245 ])dnl
2246 dnl ---------------------------------------------------------------------------
2247 dnl CF_HASHED_DB_VERSION version: 3 updated: 2007/12/01 15:01:37
2248 dnl --------------------
2249 dnl Given that we have the header file for hashed database, find the version
2250 dnl information.
2251 AC_DEFUN([CF_HASHED_DB_VERSION],
2253 AC_CACHE_CHECK(for version of db, cf_cv_hashed_db_version,[
2254 cf_cv_hashed_db_version=unknown
2256 for cf_db_version in 1 2 3 4 5
2258         CF_MSG_LOG(checking for db version $cf_db_version)
2259         AC_TRY_COMPILE([
2260 $ac_includes_default
2261 #include <db.h>
2263 #ifdef DB_VERSION_MAJOR
2264         /* db2 (DB_VERSION_MAJOR=2) has also DB_VERSION_MINOR, tested with 7 */
2265 #if $cf_db_version == DB_VERSION_MAJOR
2266         /* ok */
2267 #else
2268         make an error
2269 #endif
2270 #else
2271 #if $cf_db_version == 1
2272         /* ok: assuming this is DB 1.8.5 */
2273 #else
2274         make an error
2275 #endif
2276 #endif
2277 ],[DBT *foo = 0],[
2278         cf_cv_hashed_db_version=$cf_db_version
2279         break
2280         ])
2281 done
2283 ])dnl
2284 dnl ---------------------------------------------------------------------------
2285 dnl CF_HEADER_PATH version: 12 updated: 2010/05/05 05:22:40
2286 dnl --------------
2287 dnl Construct a search-list of directories for a nonstandard header-file
2289 dnl Parameters
2290 dnl     $1 = the variable to return as result
2291 dnl     $2 = the package name
2292 AC_DEFUN([CF_HEADER_PATH],
2296 # collect the current set of include-directories from compiler flags
2297 cf_header_path_list=""
2298 if test -n "${CFLAGS}${CPPFLAGS}" ; then
2299         for cf_header_path in $CPPFLAGS $CFLAGS
2300         do
2301                 case $cf_header_path in #(vi
2302                 -I*)
2303                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
2304                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
2305                         cf_header_path_list="$cf_header_path_list [$]$1"
2306                         ;;
2307                 esac
2308         done
2311 # add the variations for the package we are looking for
2312 CF_SUBDIR_PATH($1,$2,include)
2314 test "$includedir" != NONE && \
2315 test "$includedir" != "/usr/include" && \
2316 test -d "$includedir" && {
2317         test -d $includedir &&    $1="[$]$1 $includedir"
2318         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
2321 test "$oldincludedir" != NONE && \
2322 test "$oldincludedir" != "/usr/include" && \
2323 test -d "$oldincludedir" && {
2324         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
2325         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
2328 $1="[$]$1 $cf_header_path_list"
2329 ])dnl
2330 dnl ---------------------------------------------------------------------------
2331 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
2332 dnl ---------------
2333 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
2334 AC_DEFUN([CF_HELP_MESSAGE], [m4_append_uniq([HELP_ENABLE],[$1])])dnl
2335 dnl AC_DEFUN([CF_HELP_MESSAGE], [m4_append_uniq([_AC_USER_OPTS],[$1])])dnl
2337 dnl ---------------------------------------------------------------------------
2338 dnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
2339 dnl ---------------
2340 dnl Construct the list of include-options according to whether we're building
2341 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
2342 dnl with gcc, don't append the includedir if it happens to be /usr/include,
2343 dnl since that usually breaks gcc's shadow-includes.
2344 AC_DEFUN([CF_INCLUDE_DIRS],
2346 CPPFLAGS="$CPPFLAGS -I. -I../include"
2347 if test "$srcdir" != "."; then
2348         CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
2350 AC_SUBST(CPPFLAGS)
2351 ])dnl
2352 dnl ---------------------------------------------------------------------------
2353 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
2354 dnl -----------------
2355 dnl Check if the given compiler is really the Intel compiler for Linux.  It
2356 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
2357 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
2359 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
2360 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
2361 dnl the wrappers for gcc and g++ warnings.
2363 dnl $1 = GCC (default) or GXX
2364 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
2365 dnl $3 = CFLAGS (default) or CXXFLAGS
2366 AC_DEFUN([CF_INTEL_COMPILER],[
2367 ifelse([$2],,INTEL_COMPILER,[$2])=no
2369 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
2370         case $host_os in
2371         linux*|gnu*)
2372                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
2373                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
2374                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
2375                 AC_TRY_COMPILE([],[
2376 #ifdef __INTEL_COMPILER
2377 #else
2378 make an error
2379 #endif
2380 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
2381 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
2382 ],[])
2383                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
2384                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
2385                 ;;
2386         esac
2388 ])dnl
2389 dnl ---------------------------------------------------------------------------
2390 dnl CF_ISASCII version: 3 updated: 2000/08/12 23:18:52
2391 dnl ----------
2392 dnl Check if we have either a function or macro for 'isascii()'.
2393 AC_DEFUN([CF_ISASCII],
2395 AC_MSG_CHECKING(for isascii)
2396 AC_CACHE_VAL(cf_cv_have_isascii,[
2397         AC_TRY_LINK([#include <ctype.h>],[int x = isascii(' ')],
2398         [cf_cv_have_isascii=yes],
2399         [cf_cv_have_isascii=no])
2400 ])dnl
2401 AC_MSG_RESULT($cf_cv_have_isascii)
2402 test "$cf_cv_have_isascii" = yes && AC_DEFINE(HAVE_ISASCII,[],[HAVE_ISASCII])
2403 ])dnl
2404 dnl ---------------------------------------------------------------------------
2405 dnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
2406 dnl ------------
2407 dnl Add checks for large file support.
2408 AC_DEFUN([CF_LARGEFILE],[
2409 ifdef([AC_FUNC_FSEEKO],[
2410     AC_SYS_LARGEFILE
2411     if test "$enable_largefile" != no ; then
2412         AC_FUNC_FSEEKO
2414         # Normally we would collect these definitions in the config.h,
2415         # but (like _XOPEN_SOURCE), some environments rely on having these
2416         # defined before any of the system headers are included.  Another
2417         # case comes up with C++, e.g., on AIX the compiler compiles the
2418         # header files by themselves before looking at the body files it is
2419         # told to compile.  For ncurses, those header files do not include
2420         # the config.h
2421         test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
2422         test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
2423         test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
2425         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
2426                 AC_TRY_COMPILE([
2427 #include <sys/types.h>
2428 #include <dirent.h>
2429                 ],[
2430                 /* if transitional largefile support is setup, this is true */
2431                 extern struct dirent64 * readdir(DIR *);
2432                 struct dirent64 *x = readdir((DIR *)0);
2433                 struct dirent *y = readdir((DIR *)0);
2434                 int z = x - y;
2435                 ],
2436                 [cf_cv_struct_dirent64=yes],
2437                 [cf_cv_struct_dirent64=no])
2438         ])
2439         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64,[],[HAVE_STRUCT_DIRENT64])
2440     fi
2443 dnl ---------------------------------------------------------------------------
2444 dnl CF_LDFLAGS_STATIC version: 8 updated: 2010/10/23 14:39:56
2445 dnl -----------------
2446 dnl Check for compiler/linker flags used to temporarily force usage of static
2447 dnl libraries.  This depends on the compiler and platform.  Use this to help
2448 dnl ensure that the linker picks up a given library based on its position in
2449 dnl the list of linker options and libraries.
2450 AC_DEFUN([CF_LDFLAGS_STATIC],[
2452 if test "$GCC" = yes ; then
2453         case $cf_cv_system_name in #(
2454         OS/2*|os2*|aix[[4]]*|solaris2.1[[0-9]]|darwin*)         #( vi
2455                 LDFLAGS_STATIC=
2456                 LDFLAGS_SHARED=
2457                 ;;
2458     *)  #( normally, except when broken
2459         LDFLAGS_STATIC=-static
2460         LDFLAGS_SHARED=-dynamic
2461         ;;
2462     esac
2463 else
2464         case $cf_cv_system_name in #(
2465         aix[[456]]*)    #( from ld manpage
2466                 LDFLAGS_STATIC=-bstatic
2467                 LDFLAGS_SHARED=-bdynamic
2468                 ;;
2469         hpux*)          #( from ld manpage for hpux10.20, hpux11.11
2470                 # We could also use just "archive" and "shared".
2471                 LDFLAGS_STATIC=-Wl,-a,archive_shared
2472                 LDFLAGS_SHARED=-Wl,-a,shared_archive
2473                 ;;
2474         irix*)          #( from ld manpage IRIX64
2475                 LDFLAGS_STATIC=-Bstatic
2476                 LDFLAGS_SHARED=-Bdynamic
2477                 ;;
2478         osf[[45]]*)     #( from ld manpage osf4.0d, osf5.1
2479                 # alternative "-oldstyle_liblookup" (not in cc manpage)
2480                 LDFLAGS_STATIC=-noso
2481                 LDFLAGS_SHARED=-so_archive
2482                 ;;
2483         solaris2*)
2484                 LDFLAGS_STATIC=-Bstatic
2485                 LDFLAGS_SHARED=-Bdynamic
2486                 ;;
2487         esac
2490 if test -n "$LDFLAGS_STATIC" && test -n "$LDFLAGS_SHARED"
2491 then
2492         AC_MSG_CHECKING(if linker supports switching between static/dynamic)
2494         rm -f libconftest.a
2495         cat >conftest.$ac_ext <<EOF
2496 #line __oline__ "configure"
2497 #include <stdio.h>
2498 int cf_ldflags_static(FILE *fp) { return fflush(fp); }
2500         if AC_TRY_EVAL(ac_compile) ; then
2501                 ( $AR $ARFLAGS libconftest.a conftest.o ) 2>&AS_MESSAGE_LOG_FD 1>/dev/null
2502                 ( eval $RANLIB libconftest.a ) 2>&AS_MESSAGE_LOG_FD >/dev/null
2503         fi
2504         rm -f conftest.*
2506         cf_save_LIBS="$LIBS"
2508         LIBS="$LDFLAGS_STATIC -L`pwd` -lconftest $LDFLAGS_DYNAMIC $LIBS"
2509         AC_TRY_LINK([
2510 #line __oline__ "configure"
2511 #include <stdio.h>
2512 int cf_ldflags_static(FILE *fp);
2514         return cf_ldflags_static(stdin);
2515 ],[cf_ldflags_static=yes],[cf_ldflags_static=no])
2517         rm -f libconftest.*
2518         LIBS="$cf_save_LIBS"
2520         AC_MSG_RESULT($cf_ldflags_static)
2522         if test $cf_ldflags_static != yes
2523         then
2524                 LDFLAGS_STATIC=
2525                 LDFLAGS_SHARED=
2526         fi
2527 else
2528         LDFLAGS_STATIC=
2529         LDFLAGS_SHARED=
2532 AC_SUBST(LDFLAGS_STATIC)
2533 AC_SUBST(LDFLAGS_SHARED)
2535 dnl ---------------------------------------------------------------------------
2536 dnl CF_LD_RPATH_OPT version: 3 updated: 2010/06/02 05:03:05
2537 dnl ---------------
2538 dnl For the given system and compiler, find the compiler flags to pass to the
2539 dnl loader to use the "rpath" feature.
2540 AC_DEFUN([CF_LD_RPATH_OPT],
2542 AC_REQUIRE([CF_CHECK_CACHE])
2544 LD_RPATH_OPT=
2545 AC_MSG_CHECKING(for an rpath option)
2546 case $cf_cv_system_name in #(vi
2547 irix*) #(vi
2548         if test "$GCC" = yes; then
2549                 LD_RPATH_OPT="-Wl,-rpath,"
2550         else
2551                 LD_RPATH_OPT="-rpath "
2552         fi
2553         ;;
2554 linux*|gnu*|k*bsd*-gnu) #(vi
2555         LD_RPATH_OPT="-Wl,-rpath,"
2556         ;;
2557 openbsd[[2-9]].*) #(vi
2558         LD_RPATH_OPT="-Wl,-rpath,"
2559         ;;
2560 freebsd*) #(vi
2561         LD_RPATH_OPT="-rpath "
2562         ;;
2563 netbsd*) #(vi
2564         LD_RPATH_OPT="-Wl,-rpath,"
2565         ;;
2566 osf*|mls+*) #(vi
2567         LD_RPATH_OPT="-rpath "
2568         ;;
2569 solaris2*) #(vi
2570         LD_RPATH_OPT="-R"
2571         ;;
2573         ;;
2574 esac
2575 AC_MSG_RESULT($LD_RPATH_OPT)
2577 case "x$LD_RPATH_OPT" in #(vi
2578 x-R*)
2579         AC_MSG_CHECKING(if we need a space after rpath option)
2580         cf_save_LIBS="$LIBS"
2581         CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
2582         AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
2583         LIBS="$cf_save_LIBS"
2584         AC_MSG_RESULT($cf_rpath_space)
2585         test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
2586         ;;
2587 esac
2588 ])dnl
2589 dnl ---------------------------------------------------------------------------
2590 dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
2591 dnl ---------------
2592 dnl Construct a search-list of directories for a nonstandard library-file
2594 dnl Parameters
2595 dnl     $1 = the variable to return as result
2596 dnl     $2 = the package name
2597 AC_DEFUN([CF_LIBRARY_PATH],
2600 cf_library_path_list=""
2601 if test -n "${LDFLAGS}${LIBS}" ; then
2602         for cf_library_path in $LDFLAGS $LIBS
2603         do
2604                 case $cf_library_path in #(vi
2605                 -L*)
2606                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
2607                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
2608                         cf_library_path_list="$cf_library_path_list [$]$1"
2609                         ;;
2610                 esac
2611         done
2614 CF_SUBDIR_PATH($1,$2,lib)
2616 $1="$cf_library_path_list [$]$1"
2617 ])dnl
2618 dnl ---------------------------------------------------------------------------
2619 dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
2620 dnl -------------
2621 dnl Compute the library-prefix for the given host system
2622 dnl $1 = variable to set
2623 AC_DEFUN([CF_LIB_PREFIX],
2625         case $cf_cv_system_name in #(vi
2626         OS/2*|os2*) #(vi
2627         LIB_PREFIX=''
2628         ;;
2629         *)      LIB_PREFIX='lib'
2630         ;;
2631         esac
2632 ifelse($1,,,[$1=$LIB_PREFIX])
2633         AC_SUBST(LIB_PREFIX)
2634 ])dnl
2635 dnl ---------------------------------------------------------------------------
2636 dnl CF_LIB_RULES version: 61 updated: 2010/10/23 16:10:30
2637 dnl ------------
2638 dnl Append definitions and rules for the given models to the subdirectory
2639 dnl Makefiles, and the recursion rule for the top-level Makefile.  If the
2640 dnl subdirectory is a library-source directory, modify the LIBS_TO_MAKE list in
2641 dnl the corresponding makefile to list the models that we'll generate.
2643 dnl For shared libraries, make a list of symbolic links to construct when
2644 dnl generating each library.  The convention used for Linux is the simplest
2645 dnl one:
2646 dnl     lib<name>.so    ->
2647 dnl     lib<name>.so.<major>    ->
2648 dnl     lib<name>.so.<maj>.<minor>
2649 AC_DEFUN([CF_LIB_RULES],
2651 CF_LIB_PREFIX(cf_prefix)
2652 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2654 if test $cf_cv_shlib_version = cygdll ; then
2655         TINFO_NAME=$TINFO_ARG_SUFFIX
2656         TINFO_SUFFIX=.dll
2659 if test -n "$TINFO_SUFFIX" ; then
2660         case $TINFO_SUFFIX in
2661         tw*)
2662                 TINFO_NAME="${TINFO_NAME}tw"
2663                 TINFO_SUFFIX=`echo $TINFO_SUFFIX | sed 's/^tw//'`
2664                 ;;
2665         t*)
2666                 TINFO_NAME="${TINFO_NAME}t"
2667                 TINFO_SUFFIX=`echo $TINFO_SUFFIX | sed 's/^t//'`
2668                 ;;
2669         w*)
2670                 TINFO_NAME="${TINFO_NAME}w"
2671                 TINFO_SUFFIX=`echo $TINFO_SUFFIX | sed 's/^w//'`
2672                 ;;
2673         esac
2676 for cf_dir in $SRC_SUBDIRS
2678         if test ! -d $srcdir/$cf_dir ; then
2679                 continue
2680         elif test -f $srcdir/$cf_dir/modules; then
2682                 SHARED_LIB=
2683                 LIBS_TO_MAKE=
2684                 for cf_item in $cf_LIST_MODELS
2685                 do
2686                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
2687                         if test $cf_item = shared ; then
2688                         if test "$cf_cv_do_symlinks" = yes ; then
2689                                 case "$cf_cv_shlib_version" in #(vi
2690                                 rel) #(vi
2691                                         case "$cf_cv_system_name" in #(vi
2692                                         darwin*)
2693                                         case .${LIB_SUFFIX} in
2694                                         .tw*)
2695                                                 cf_suffix=`echo $cf_suffix | sed 's/^tw//'`
2696                                                 cf_suffix=tw'.${REL_VERSION}'"$cf_suffix"
2697                                                 ;;
2698                                         .t*)
2699                                                 cf_suffix=`echo $cf_suffix | sed 's/^t//'`
2700                                                 cf_suffix=t'.${REL_VERSION}'"$cf_suffix"
2701                                                 ;;
2702                                         .w*)
2703                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2704                                                 cf_suffix=w'.${REL_VERSION}'"$cf_suffix"
2705                                                 ;;
2706                                         *)
2707                                                 cf_suffix='.${REL_VERSION}'"$cf_suffix"
2708                                                 ;;
2709                                         esac
2710                                         ;; #(vi
2711                                         *) cf_suffix="$cf_suffix"'.${REL_VERSION}' ;;
2712                                         esac
2713                                         ;;
2714                                 abi)
2715                                         case "$cf_cv_system_name" in #(vi
2716                                         darwin*)
2717                                         case .${LIB_SUFFIX} in
2718                                         .tw*)
2719                                                 cf_suffix=`echo $cf_suffix | sed 's/^tw//'`
2720                                                 cf_suffix=tw'.${ABI_VERSION}'"$cf_suffix"
2721                                                 ;;
2722                                         .t*)
2723                                                 cf_suffix=`echo $cf_suffix | sed 's/^t//'`
2724                                                 cf_suffix=t'.${ABI_VERSION}'"$cf_suffix"
2725                                                 ;;
2726                                         .w*)
2727                                                 cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2728                                                 cf_suffix=w'.${ABI_VERSION}'"$cf_suffix"
2729                                                 ;;
2730                                         *)
2731                                                 cf_suffix='.${ABI_VERSION}'"$cf_suffix"
2732                                                 ;;
2733                                         esac
2734                                         ;; #(vi
2735                                         *) cf_suffix="$cf_suffix"'.${ABI_VERSION}' ;;
2736                                         esac
2737                                         ;;
2738                                 esac
2739                         fi
2740                         # cygwin needs import library, and has unique naming convention
2741                         # use autodetected ${cf_prefix} for import lib and static lib, but
2742                         # use 'cyg' prefix for shared lib.
2743                         if test $cf_cv_shlib_version = cygdll ; then
2744                                 cf_cygsuf=`echo "$cf_suffix" | sed -e 's/\.dll/\${ABI_VERSION}.dll/'`
2745                                 LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/cyg${cf_dir}${cf_cygsuf}"
2746                                 continue
2747                         fi
2748                         fi
2749                         LIBS_TO_MAKE="$LIBS_TO_MAKE ../lib/${cf_prefix}${cf_dir}${cf_suffix}"
2750                 done
2752                 if test $cf_dir = ncurses ; then
2753                         cf_subsets="$LIB_SUBSETS"
2754                         cf_r_parts="$cf_subsets"
2755                         cf_liblist="$LIBS_TO_MAKE"
2757                         while test -n "$cf_r_parts"
2758                         do
2759                                 cf_l_parts=`echo "$cf_r_parts" |sed -e 's/ .*$//'`
2760                                 cf_r_parts=`echo "$cf_r_parts" |sed -e 's/^[[^ ]]* //'`
2761                                 if test "$cf_l_parts" != "$cf_r_parts" ; then
2762                                         cf_item=
2763                                         case $cf_l_parts in #(vi
2764                                         *termlib*) #(vi
2765                                                 cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TINFO_LIB_SUFFIX}%g`
2766                                                 ;;
2767                                         *ticlib*)
2768                                                 cf_item=`echo $cf_liblist |sed -e s%${LIB_NAME}${LIB_SUFFIX}%${TICS_LIB_SUFFIX}%g`
2769                                                 ;;
2770                                         *)
2771                                                 break
2772                                                 ;;
2773                                         esac
2774                                         if test -n "$cf_item"; then
2775                                                 LIBS_TO_MAKE="$cf_item $LIBS_TO_MAKE"
2776                                         fi
2777                                 else
2778                                         break
2779                                 fi
2780                         done
2781                 else
2782                         cf_subsets=`echo "$LIB_SUBSETS" | sed -e 's/^termlib.* //'`
2783                 fi
2785                 sed -e "s%@LIBS_TO_MAKE@%$LIBS_TO_MAKE%" \
2786                     -e "s%@SHARED_LIB@%$SHARED_LIB%" \
2787                         $cf_dir/Makefile >$cf_dir/Makefile.out
2788                 mv $cf_dir/Makefile.out $cf_dir/Makefile
2790                 $AWK -f $srcdir/mk-0th.awk \
2791                         libname="${cf_dir}${LIB_SUFFIX}" subsets="$LIB_SUBSETS" \
2792                         $srcdir/$cf_dir/modules >>$cf_dir/Makefile
2794                 for cf_subset in $cf_subsets
2795                 do
2796                         cf_subdirs=
2797                         for cf_item in $cf_LIST_MODELS
2798                         do
2799                         echo "Appending rules for ${cf_item} model (${cf_dir}: ${cf_subset})"
2800                         CF_UPPER(cf_ITEM,$cf_item)
2801                         CF_LIB_SUFFIX($cf_item,cf_suffix,cf_depsuf)
2802                         CF_OBJ_SUBDIR($cf_item,cf_subdir)
2804                         # Test for case where we build libtinfo with a different name.
2805                         cf_libname=$cf_dir
2806                         if test $cf_dir = ncurses ; then
2807                                 case $cf_subset in
2808                                 *base*)
2809                                         cf_libname=${cf_libname}$LIB_SUFFIX
2810                                         ;;
2811                                 *termlib*)
2812                                         cf_libname=$TINFO_LIB_SUFFIX
2813                                         ;;
2814                                 ticlib*)
2815                                         cf_libname=$TICS_LIB_SUFFIX
2816                                         ;;
2817                                 esac
2818                         else
2819                                 cf_libname=${cf_libname}$LIB_SUFFIX
2820                         fi
2821                         if test -n "${DFT_ARG_SUFFIX}" ; then
2822                                 # undo $LIB_SUFFIX add-on in CF_LIB_SUFFIX
2823                                 cf_suffix=`echo $cf_suffix |sed -e "s%^${LIB_SUFFIX}%%"`
2824                         fi
2826                         # These dependencies really are for development, not
2827                         # builds, but they are useful in porting, too.
2828                         cf_depend="../include/ncurses_cfg.h"
2829                         if test "$srcdir" = "."; then
2830                                 cf_reldir="."
2831                         else
2832                                 cf_reldir="\${srcdir}"
2833                         fi
2835                         if test -f $srcdir/$cf_dir/$cf_dir.priv.h; then
2836                                 cf_depend="$cf_depend $cf_reldir/$cf_dir.priv.h"
2837                         elif test -f $srcdir/$cf_dir/curses.priv.h; then
2838                                 cf_depend="$cf_depend $cf_reldir/curses.priv.h"
2839                         fi
2841                         cf_dir_suffix=
2842                         old_cf_suffix="$cf_suffix"
2843                         if test "$cf_cv_shlib_version_infix" = yes ; then
2844                         if test -n "$LIB_SUFFIX" ; then
2845                                 case $LIB_SUFFIX in
2846                                 tw*)
2847                                         cf_libname=`echo $cf_libname | sed 's/tw$//'`
2848                                         cf_suffix=`echo $cf_suffix | sed 's/^tw//'`
2849                                         cf_dir_suffix=tw
2850                                         ;;
2851                                 t*)
2852                                         cf_libname=`echo $cf_libname | sed 's/t$//'`
2853                                         cf_suffix=`echo $cf_suffix | sed 's/^t//'`
2854                                         cf_dir_suffix=t
2855                                         ;;
2856                                 w*)
2857                                         cf_libname=`echo $cf_libname | sed 's/w$//'`
2858                                         cf_suffix=`echo $cf_suffix | sed 's/^w//'`
2859                                         cf_dir_suffix=w
2860                                         ;;
2861                                 esac
2862                         fi
2863                         fi
2865                         $AWK -f $srcdir/mk-1st.awk \
2866                                 name=${cf_libname}${cf_dir_suffix} \
2867                                 traces=$LIB_TRACING \
2868                                 MODEL=$cf_ITEM \
2869                                 model=$cf_subdir \
2870                                 prefix=$cf_prefix \
2871                                 suffix=$cf_suffix \
2872                                 subset=$cf_subset \
2873                                 SymLink="$LN_S" \
2874                                 TermlibRoot=$TINFO_NAME \
2875                                 TermlibSuffix=$TINFO_SUFFIX \
2876                                 ShlibVer=$cf_cv_shlib_version \
2877                                 ShlibVerInfix=$cf_cv_shlib_version_infix \
2878                                 ReLink=${cf_cv_do_relink:-no} \
2879                                 DoLinks=$cf_cv_do_symlinks \
2880                                 rmSoLocs=$cf_cv_rm_so_locs \
2881                                 ldconfig="$LDCONFIG" \
2882                                 overwrite=$WITH_OVERWRITE \
2883                                 depend="$cf_depend" \
2884                                 host="$host" \
2885                                 libtool_version="$LIBTOOL_VERSION" \
2886                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
2888                         cf_suffix="$old_cf_suffix"
2890                         for cf_subdir2 in $cf_subdirs lib
2891                         do
2892                                 test $cf_subdir = $cf_subdir2 && break
2893                         done
2894                         test "${cf_subset}.${cf_subdir2}" != "${cf_subset}.${cf_subdir}" && \
2895                         $AWK -f $srcdir/mk-2nd.awk \
2896                                 name=$cf_dir \
2897                                 traces=$LIB_TRACING \
2898                                 MODEL=$cf_ITEM \
2899                                 model=$cf_subdir \
2900                                 subset=$cf_subset \
2901                                 srcdir=$srcdir \
2902                                 echo=$WITH_ECHO \
2903                                 crenames=$cf_cv_prog_CC_c_o \
2904                                 cxxrenames=$cf_cv_prog_CXX_c_o \
2905                                 $srcdir/$cf_dir/modules >>$cf_dir/Makefile
2906                         cf_subdirs="$cf_subdirs $cf_subdir"
2907                         done
2908                 done
2909         fi
2911         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >>Makefile
2912 done
2914 for cf_dir in $SRC_SUBDIRS
2916         if test ! -d $srcdir/$cf_dir ; then
2917                 continue
2918         fi
2920         if test -f $cf_dir/Makefile ; then
2921                 case "$cf_dir" in
2922                 Ada95) #(vi
2923                         echo 'libs \' >> Makefile
2924                         echo 'install.libs \' >> Makefile
2925                         echo 'uninstall.libs ::' >> Makefile
2926                         echo '  cd '$cf_dir' && ${MAKE} ${CF_MFLAGS} [$]@' >> Makefile
2927                         ;;
2928                 esac
2929         fi
2931         if test -f $srcdir/$cf_dir/modules; then
2932                 echo >> Makefile
2933                 if test -f $srcdir/$cf_dir/headers; then
2934 cat >> Makefile <<CF_EOF
2935 install.includes \\
2936 uninstall.includes \\
2937 CF_EOF
2938                 fi
2939 if test "$cf_dir" != "c++" ; then
2940 echo 'lint \' >> Makefile
2942 cat >> Makefile <<CF_EOF
2943 libs \\
2944 lintlib \\
2945 install.libs \\
2946 uninstall.libs \\
2947 install.$cf_dir \\
2948 uninstall.$cf_dir ::
2949         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
2950 CF_EOF
2951         elif test -f $srcdir/$cf_dir/headers; then
2952 cat >> Makefile <<CF_EOF
2954 libs \\
2955 install.libs \\
2956 uninstall.libs \\
2957 install.includes \\
2958 uninstall.includes ::
2959         cd $cf_dir && \${MAKE} \${CF_MFLAGS} \[$]@
2960 CF_EOF
2962 done
2964 cat >> Makefile <<CF_EOF
2966 install.libs uninstall.libs \\
2967 install.data uninstall.data ::
2968 $MAKE_TERMINFO  cd misc && \${MAKE} \${CF_MFLAGS} \[$]@
2969 CF_EOF
2971 if test "x$cf_with_manpages" = xyes; then
2972 cat >> Makefile <<CF_EOF
2974 install.man \\
2975 uninstall.man ::
2976         cd man && \${MAKE} \${CF_MFLAGS} \[$]@
2977 CF_EOF
2980 cat >> Makefile <<CF_EOF
2982 distclean ::
2983         rm -f config.cache config.log config.status Makefile include/ncurses_cfg.h
2984         rm -f headers.sh headers.sed mk_shared_lib.sh
2985         rm -f edit_man.* man_alias.*
2986         rm -rf \${DIRS_TO_MAKE}
2987 CF_EOF
2989 # Special case: tack's manpage lives in its own directory.
2990 if test "x$cf_with_manpages" = xyes; then
2991 if test -d tack ; then
2992 if test -f $srcdir/$tack.h; then
2993 cat >> Makefile <<CF_EOF
2995 install.man \\
2996 uninstall.man ::
2997         cd tack && \${MAKE} \${CF_MFLAGS} \[$]@
2998 CF_EOF
3003 dnl If we're installing into a subdirectory of /usr/include, etc., we should
3004 dnl prepend the subdirectory's name to the "#include" paths.  It won't hurt
3005 dnl anything, and will make it more standardized.  It's awkward to decide this
3006 dnl at configuration because of quoting, so we'll simply make all headers
3007 dnl installed via a script that can do the right thing.
3009 rm -f headers.sed headers.sh
3011 dnl ( generating this script makes the makefiles a little tidier :-)
3012 echo creating headers.sh
3013 cat >headers.sh <<CF_EOF
3014 #! /bin/sh
3015 # This shell script is generated by the 'configure' script.  It is invoked in a
3016 # subdirectory of the build tree.  It generates a sed-script in the parent
3017 # directory that is used to adjust includes for header files that reside in a
3018 # subdirectory of /usr/include, etc.
3019 PRG=""
3020 while test \[$]# != 3
3022 PRG="\$PRG \[$]1"; shift
3023 done
3024 DST=\[$]1
3025 REF=\[$]2
3026 SRC=\[$]3
3027 TMPSRC=\${TMPDIR:-/tmp}/\`basename \$SRC\`\$\$
3028 TMPSED=\${TMPDIR:-/tmp}/headers.sed\$\$
3029 echo installing \$SRC in \$DST
3030 CF_EOF
3032 if test $WITH_CURSES_H = yes; then
3033         cat >>headers.sh <<CF_EOF
3034 case \$DST in
3035 /*/include/*)
3036         END=\`basename \$DST\`
3037         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
3038         do
3039                 NAME=\`basename \$i\`
3040                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
3041         done
3042         ;;
3044         echo "" >> \$TMPSED
3045         ;;
3046 esac
3047 CF_EOF
3049 else
3050         cat >>headers.sh <<CF_EOF
3051 case \$DST in
3052 /*/include/*)
3053         END=\`basename \$DST\`
3054         for i in \`cat \$REF/../*/headers |fgrep -v "#"\`
3055         do
3056                 NAME=\`basename \$i\`
3057                 if test "\$NAME" = "curses.h"
3058                 then
3059                         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
3060                         NAME=ncurses.h
3061                 fi
3062                 echo "s/<\$NAME>/<\$END\/\$NAME>/" >> \$TMPSED
3063         done
3064         ;;
3066         echo "s/<curses.h>/<ncurses.h>/" >> \$TMPSED
3067         ;;
3068 esac
3069 CF_EOF
3071 cat >>headers.sh <<CF_EOF
3072 rm -f \$TMPSRC
3073 sed -f \$TMPSED \$SRC > \$TMPSRC
3074 NAME=\`basename \$SRC\`
3075 CF_EOF
3076 if test $WITH_CURSES_H != yes; then
3077         cat >>headers.sh <<CF_EOF
3078 test "\$NAME" = "curses.h" && NAME=ncurses.h
3079 CF_EOF
3081 cat >>headers.sh <<CF_EOF
3082 # Just in case someone gzip'd manpages, remove the conflicting copy.
3083 test -f \$DST/\$NAME.gz && rm -f \$DST/\$NAME.gz
3085 eval \$PRG \$TMPSRC \$DST/\$NAME
3086 rm -f \$TMPSRC \$TMPSED
3087 CF_EOF
3089 chmod 0755 headers.sh
3091 for cf_dir in $SRC_SUBDIRS
3093         if test ! -d $srcdir/$cf_dir ; then
3094                 continue
3095         fi
3097         if test -f $srcdir/$cf_dir/headers; then
3098                 $AWK -f $srcdir/mk-hdr.awk \
3099                         subset="$LIB_SUBSETS" \
3100                         compat="$WITH_CURSES_H" \
3101                         $srcdir/$cf_dir/headers >>$cf_dir/Makefile
3102         fi
3104         if test -f $srcdir/$cf_dir/modules; then
3105                 if test "$cf_dir" != "c++" ; then
3106                         cat >>$cf_dir/Makefile <<"CF_EOF"
3107 depend : ${AUTO_SRC}
3108         makedepend -- ${CPPFLAGS} -- ${C_SRC}
3110 # DO NOT DELETE THIS LINE -- make depend depends on it.
3111 CF_EOF
3112                 fi
3113         fi
3114 done
3115 AC_SUBST(LIBS_TO_MAKE)
3116 ])dnl
3117 dnl ---------------------------------------------------------------------------
3118 dnl CF_LIB_SONAME version: 5 updated: 2010/08/14 18:25:37
3119 dnl -------------
3120 dnl Find the and soname for the given shared library.  Set the cache variable
3121 dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
3122 dnl variable to "unknown".
3124 dnl $1 = headers
3125 dnl $2 = code
3126 dnl $3 = library name
3127 AC_DEFUN([CF_LIB_SONAME],
3129 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
3131 cf_cv_$3_soname=unknown
3132 if test "$cross_compiling" != yes ; then
3133 cat >conftest.$ac_ext <<CF_EOF
3135 int main()
3138         ${cf_cv_main_return:-return}(0);
3140 CF_EOF
3141 cf_save_LIBS="$LIBS"
3142         CF_ADD_LIB($3)
3143         if AC_TRY_EVAL(ac_compile) ; then
3144                 if AC_TRY_EVAL(ac_link) ; then
3145                         cf_cv_$3_soname=`ldd conftest$ac_exeext 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | fgrep lib$3.`
3146                         test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
3147                 fi
3148         fi
3149 rm -rf conftest*
3150 LIBS="$cf_save_LIBS"
3154 dnl ---------------------------------------------------------------------------
3155 dnl CF_LIB_SUFFIX version: 16 updated: 2008/12/27 12:30:03
3156 dnl -------------
3157 dnl Compute the library file-suffix from the given model name
3158 dnl $1 = model name
3159 dnl $2 = variable to set (the nominal library suffix)
3160 dnl $3 = dependency variable to set (actual filename)
3161 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
3162 AC_DEFUN([CF_LIB_SUFFIX],
3164         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
3165         case $1 in #(vi
3166         libtool) #(vi
3167                 $2='.la'
3168                 $3=[$]$2
3169                 ;;
3170         normal) #(vi
3171                 $2='.a'
3172                 $3=[$]$2
3173                 ;;
3174         debug) #(vi
3175                 $2='_g.a'
3176                 $3=[$]$2
3177                 ;;
3178         profile) #(vi
3179                 $2='_p.a'
3180                 $3=[$]$2
3181                 ;;
3182         shared) #(vi
3183                 case $cf_cv_system_name in
3184                 aix[[56]]*) #(vi
3185                         $2='.a'
3186                         $3=[$]$2
3187                         ;;
3188                 cygwin*) #(vi
3189                         $2='.dll'
3190                         $3='.dll.a'
3191                         ;;
3192                 darwin*) #(vi
3193                         $2='.dylib'
3194                         $3=[$]$2
3195                         ;;
3196                 hpux*) #(vi
3197                         case $target in
3198                         ia64*) #(vi
3199                                 $2='.so'
3200                                 $3=[$]$2
3201                                 ;;
3202                         *) #(vi
3203                                 $2='.sl'
3204                                 $3=[$]$2
3205                                 ;;
3206                         esac
3207                         ;;
3208                 *)      $2='.so'
3209                         $3=[$]$2
3210                         ;;
3211                 esac
3212         esac
3213         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
3214         test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
3215 ])dnl
3216 dnl ---------------------------------------------------------------------------
3217 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
3218 dnl -----------
3219 dnl Compute the string to append to -library from the given model name
3220 dnl $1 = model name
3221 dnl $2 = variable to set
3222 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
3223 AC_DEFUN([CF_LIB_TYPE],
3225         case $1 in
3226         libtool) $2=''   ;;
3227         normal)  $2=''   ;;
3228         debug)   $2='_g' ;;
3229         profile) $2='_p' ;;
3230         shared)  $2=''   ;;
3231         esac
3232         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
3233 ])dnl
3234 dnl ---------------------------------------------------------------------------
3235 dnl CF_LINK_DATAONLY version: 9 updated: 2009/01/01 20:21:38
3236 dnl ----------------
3237 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
3238 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
3239 dnl have to provide wrappers for global tables to ensure they're linked
3240 dnl properly.
3241 AC_DEFUN([CF_LINK_DATAONLY],
3243 AC_MSG_CHECKING([if data-only library module links])
3244 AC_CACHE_VAL(cf_cv_link_dataonly,[
3245         rm -f conftest.a
3246         cat >conftest.$ac_ext <<EOF
3247 #line __oline__ "configure"
3248 int     testdata[[3]] = { 123, 456, 789 };
3250         if AC_TRY_EVAL(ac_compile) ; then
3251                 mv conftest.o data.o && \
3252                 ( $AR $ARFLAGS conftest.a data.o ) 2>&AS_MESSAGE_LOG_FD 1>/dev/null
3253         fi
3254         rm -f conftest.$ac_ext data.o
3255         cat >conftest.$ac_ext <<EOF
3256 #line __oline__ "configure"
3257 int     testfunc()
3259 #if defined(NeXT)
3260         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
3261 #else
3262         extern int testdata[[3]];
3263         return testdata[[0]] == 123
3264            &&  testdata[[1]] == 456
3265            &&  testdata[[2]] == 789;
3266 #endif
3269         if AC_TRY_EVAL(ac_compile); then
3270                 mv conftest.o func.o && \
3271                 ( $AR $ARFLAGS conftest.a func.o ) 2>&AS_MESSAGE_LOG_FD 1>/dev/null
3272         fi
3273         rm -f conftest.$ac_ext func.o
3274         ( eval $RANLIB conftest.a ) 2>&AS_MESSAGE_LOG_FD >/dev/null
3275         cf_saveLIBS="$LIBS"
3276         LIBS="conftest.a $LIBS"
3277         AC_TRY_RUN([
3278         int main()
3279         {
3280                 extern int testfunc();
3281                 ${cf_cv_main_return:-return} (!testfunc());
3282         }
3283         ],
3284         [cf_cv_link_dataonly=yes],
3285         [cf_cv_link_dataonly=no],
3286         [cf_cv_link_dataonly=unknown])
3287         LIBS="$cf_saveLIBS"
3288         ])
3289 AC_MSG_RESULT($cf_cv_link_dataonly)
3291 if test "$cf_cv_link_dataonly" = no ; then
3292         AC_DEFINE(BROKEN_LINKER)
3293         BROKEN_LINKER=1
3296 ])dnl
3297 dnl ---------------------------------------------------------------------------
3298 dnl CF_LINK_FUNCS version: 7 updated: 2006/12/16 12:33:30
3299 dnl -------------
3300 dnl Most Unix systems have both link and symlink, a few don't have symlink.
3301 dnl A few non-Unix systems implement symlink, but not link.
3302 dnl A few non-systems implement neither (or have nonfunctional versions).
3303 AC_DEFUN([CF_LINK_FUNCS],
3305 AC_CHECK_FUNCS( \
3306         remove \
3307         unlink )
3309 if test "$cross_compiling" = yes ; then
3310         AC_CHECK_FUNCS( \
3311                 link \
3312                 symlink )
3313 else
3314         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
3315                 cf_cv_link_funcs=
3316                 for cf_func in link symlink ; do
3317                         AC_TRY_RUN([
3318 #include <sys/types.h>
3319 #include <sys/stat.h>
3320 #ifdef HAVE_UNISTD_H
3321 #include <unistd.h>
3322 #endif
3323 int main()
3325         int fail = 0;
3326         char *src = "config.log";
3327         char *dst = "conftest.chk";
3328         struct stat src_sb;
3329         struct stat dst_sb;
3331         stat(src, &src_sb);
3332         fail = ($cf_func("config.log", "conftest.chk") < 0)
3333             || (stat(dst, &dst_sb) < 0)
3334             || (dst_sb.st_mtime != src_sb.st_mtime);
3335 #ifdef HAVE_UNLINK
3336         unlink(dst);
3337 #else
3338         remove(dst);
3339 #endif
3340         ${cf_cv_main_return:-return} (fail);
3342                         ],[
3343                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
3344                         eval 'ac_cv_func_'$cf_func'=yes'],[
3345                         eval 'ac_cv_func_'$cf_func'=no'],[
3346                         eval 'ac_cv_func_'$cf_func'=error'])
3347                 done
3348                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
3349         ])
3350         test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK,[],[HAVE_LINK])
3351         test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK,[],[HAVE_SYMLINK])
3353 ])dnl
3354 dnl ---------------------------------------------------------------------------
3355 dnl CF_MAIN_RETURN version: 1 updated: 2006/12/10 09:51:54
3356 dnl --------------
3357 dnl Check if a return from main to the shell actually returns the same exit
3358 dnl code.  This is true for almost any POSIX environment.
3360 dnl Some very old environments did not flush stdout, etc., on an exit.  That
3361 dnl would be a useful case to test for also.
3362 AC_DEFUN([CF_MAIN_RETURN],
3364 cf_cv_main_return=return
3365 ])dnl
3366 dnl ---------------------------------------------------------------------------
3367 dnl CF_MAKEFLAGS version: 13 updated: 2010/10/23 15:52:32
3368 dnl ------------
3369 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
3370 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
3371 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
3372 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
3373 AC_DEFUN([CF_MAKEFLAGS],
3375 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
3376         cf_cv_makeflags=''
3377         for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
3378         do
3379                 cat >cf_makeflags.tmp <<CF_EOF
3380 SHELL = /bin/sh
3381 all :
3382         @ echo '.$cf_option'
3383 CF_EOF
3384                 cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[      ]]*$,,'`
3385                 case "$cf_result" in
3386                 .*k)
3387                         cf_result=`${MAKE:-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
3388                         case "$cf_result" in
3389                         .*CC=*) cf_cv_makeflags=
3390                                 ;;
3391                         *)      cf_cv_makeflags=$cf_option
3392                                 ;;
3393                         esac
3394                         break
3395                         ;;
3396                 .-)     ;;
3397                 *)      echo "given option \"$cf_option\", no match \"$cf_result\""
3398                         ;;
3399                 esac
3400         done
3401         rm -f cf_makeflags.tmp
3404 AC_SUBST(cf_cv_makeflags)
3405 ])dnl
3406 dnl ---------------------------------------------------------------------------
3407 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
3408 dnl ------------
3409 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
3410 dnl a monocase filesystem.
3411 AC_DEFUN([CF_MAKE_TAGS],[
3412 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
3414 AC_CHECK_PROGS(CTAGS, exctags ctags)
3415 AC_CHECK_PROGS(ETAGS, exetags etags)
3417 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
3419 if test "$cf_cv_mixedcase" = yes ; then
3420         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
3421 else
3422         MAKE_UPPER_TAGS=no
3425 if test "$MAKE_UPPER_TAGS" = yes ; then
3426         MAKE_UPPER_TAGS=
3427 else
3428         MAKE_UPPER_TAGS="#"
3431 if test "$MAKE_LOWER_TAGS" = yes ; then
3432         MAKE_LOWER_TAGS=
3433 else
3434         MAKE_LOWER_TAGS="#"
3437 AC_SUBST(CTAGS)
3438 AC_SUBST(ETAGS)
3440 AC_SUBST(MAKE_UPPER_TAGS)
3441 AC_SUBST(MAKE_LOWER_TAGS)
3442 ])dnl
3443 dnl ---------------------------------------------------------------------------
3444 dnl CF_MANPAGE_FORMAT version: 9 updated: 2010/10/23 16:10:30
3445 dnl -----------------
3446 dnl Option to allow user to override automatic configuration of manpage format.
3447 dnl There are several special cases:
3449 dnl     gzip - man checks for, can display gzip'd files
3450 dnl     compress - man checks for, can display compressed files
3451 dnl     BSDI - files in the cat-directories are suffixed ".0"
3452 dnl     formatted - installer should format (put files in cat-directory)
3453 dnl     catonly - installer should only format, e.g., for a turnkey system.
3455 dnl There are other configurations which this macro does not test, e.g., HPUX's
3456 dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
3457 dnl convention would not match our use).
3458 AC_DEFUN([CF_MANPAGE_FORMAT],
3460 AC_REQUIRE([CF_PATHSEP])
3461 AC_MSG_CHECKING(format of man-pages)
3463 AC_ARG_WITH(manpage-format,
3464         [  --with-manpage-format   specify manpage-format: gzip/compress/BSDI/normal and
3465                           optionally formatted/catonly, e.g., gzip,formatted],
3466         [MANPAGE_FORMAT=$withval],
3467         [MANPAGE_FORMAT=unknown])
3469 test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
3470 MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
3472 cf_unknown=
3474 case $MANPAGE_FORMAT in
3475 unknown)
3476   if test -z "$MANPATH" ; then
3477     MANPATH="/usr/man:/usr/share/man"
3478   fi
3480   # look for the 'date' man-page (it's most likely to be installed!)
3481   MANPAGE_FORMAT=
3482   cf_preform=no
3483   cf_catonly=yes
3484   cf_example=date
3486   IFS="${IFS:-  }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
3487   for cf_dir in $MANPATH; do
3488     test -z "$cf_dir" && cf_dir=/usr/man
3489     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
3490     do
3491       cf_test=`echo $cf_name | sed -e 's/*//'`
3492       if test "x$cf_test" = "x$cf_name" ; then
3494         case "$cf_name" in
3495         *.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
3496         *.Z)  MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
3497         *.0)    MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
3498         *)    MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
3499         esac
3501         case "$cf_name" in
3502         $cf_dir/man*)
3503           cf_catonly=no
3504           ;;
3505         $cf_dir/cat*)
3506           cf_preform=yes
3507           ;;
3508         esac
3509         break
3510       fi
3512       # if we found a match in either man* or cat*, stop looking
3513       if test -n "$MANPAGE_FORMAT" ; then
3514         cf_found=no
3515         test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
3516         test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
3517         case "$cf_name" in
3518         $cf_dir/cat*)
3519           cf_found=yes
3520           ;;
3521         esac
3522         test $cf_found=yes && break
3523       fi
3524     done
3525     # only check the first directory in $MANPATH where we find manpages
3526     if test -n "$MANPAGE_FORMAT" ; then
3527        break
3528     fi
3529   done
3530   # if we did not find the example, just assume it is normal
3531   test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
3532   IFS="$ac_save_ifs"
3533   ;;
3535   for cf_option in $MANPAGE_FORMAT; do
3536      case $cf_option in #(vi
3537      gzip|compress|BSDI|normal|formatted|catonly)
3538        ;;
3539      *)
3540        cf_unknown="$cf_unknown $cf_option"
3541        ;;
3542      esac
3543   done
3544   ;;
3545 esac
3547 AC_MSG_RESULT($MANPAGE_FORMAT)
3548 if test -n "$cf_unknown" ; then
3549   AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
3551 ])dnl
3552 dnl ---------------------------------------------------------------------------
3553 dnl CF_MANPAGE_RENAMES version: 7 updated: 2005/06/18 18:51:57
3554 dnl ------------------
3555 dnl The Debian people have their own naming convention for manpages.  This
3556 dnl option lets us override the name of the file containing renaming, or
3557 dnl disable it altogether.
3558 AC_DEFUN([CF_MANPAGE_RENAMES],
3560 AC_MSG_CHECKING(for manpage renaming)
3562 AC_ARG_WITH(manpage-renames,
3563         [  --with-manpage-renames  specify manpage-renaming],
3564         [MANPAGE_RENAMES=$withval],
3565         [MANPAGE_RENAMES=yes])
3567 case ".$MANPAGE_RENAMES" in #(vi
3568 .no) #(vi
3569   ;;
3570 .|.yes)
3571   # Debian 'man' program?
3572   if test -f /etc/debian_version ; then
3573     MANPAGE_RENAMES=`cd $srcdir && pwd`/man/man_db.renames
3574   else
3575     MANPAGE_RENAMES=no
3576   fi
3577   ;;
3578 esac
3580 if test "$MANPAGE_RENAMES" != no ; then
3581   if test -f $srcdir/man/$MANPAGE_RENAMES ; then
3582     MANPAGE_RENAMES=`cd $srcdir/man && pwd`/$MANPAGE_RENAMES
3583   elif test ! -f $MANPAGE_RENAMES ; then
3584     AC_MSG_ERROR(not a filename: $MANPAGE_RENAMES)
3585   fi
3587   test ! -d man && mkdir man
3589   # Construct a sed-script to perform renaming within man-pages
3590   if test -n "$MANPAGE_RENAMES" ; then
3591     test ! -d man && mkdir man
3592     sh $srcdir/man/make_sed.sh $MANPAGE_RENAMES >./edit_man.sed
3593   fi
3596 AC_MSG_RESULT($MANPAGE_RENAMES)
3597 AC_SUBST(MANPAGE_RENAMES)
3598 ])dnl
3599 dnl ---------------------------------------------------------------------------
3600 dnl CF_MANPAGE_SYMLINKS version: 5 updated: 2010/07/24 17:12:40
3601 dnl -------------------
3602 dnl Some people expect each tool to make all aliases for manpages in the
3603 dnl man-directory.  This accommodates the older, less-capable implementations
3604 dnl of 'man', and is optional.
3605 AC_DEFUN([CF_MANPAGE_SYMLINKS],
3607 AC_MSG_CHECKING(if manpage aliases will be installed)
3609 AC_ARG_WITH(manpage-aliases,
3610         [  --with-manpage-aliases  specify manpage-aliases using .so],
3611         [MANPAGE_ALIASES=$withval],
3612         [MANPAGE_ALIASES=yes])
3614 AC_MSG_RESULT($MANPAGE_ALIASES)
3616 case "x$LN_S" in #(vi
3617 xln*) #(vi
3618         cf_use_symlinks=yes
3619         ;;
3621         cf_use_symlinks=no
3622         ;;
3623 esac
3625 MANPAGE_SYMLINKS=no
3626 if test "$MANPAGE_ALIASES" = yes ; then
3627 AC_MSG_CHECKING(if manpage symlinks should be used)
3629 AC_ARG_WITH(manpage-symlinks,
3630         [  --with-manpage-symlinks specify manpage-aliases using symlinks],
3631         [MANPAGE_SYMLINKS=$withval],
3632         [MANPAGE_SYMLINKS=$cf_use_symlinks])
3634 if test "$$cf_use_symlinks" = no; then
3635 if test "$MANPAGE_SYMLINKS" = yes ; then
3636         AC_MSG_WARN(cannot make symlinks, will use .so files)
3637         MANPAGE_SYMLINKS=no
3641 AC_MSG_RESULT($MANPAGE_SYMLINKS)
3644 ])dnl
3645 dnl ---------------------------------------------------------------------------
3646 dnl CF_MANPAGE_TBL version: 3 updated: 2002/01/19 22:51:32
3647 dnl --------------
3648 dnl This option causes manpages to be run through tbl(1) to generate tables
3649 dnl correctly.
3650 AC_DEFUN([CF_MANPAGE_TBL],
3652 AC_MSG_CHECKING(for manpage tbl)
3654 AC_ARG_WITH(manpage-tbl,
3655         [  --with-manpage-tbl      specify manpage processing with tbl],
3656         [MANPAGE_TBL=$withval],
3657         [MANPAGE_TBL=no])
3659 AC_MSG_RESULT($MANPAGE_TBL)
3660 ])dnl
3661 dnl ---------------------------------------------------------------------------
3662 dnl CF_MAN_PAGES version: 39 updated: 2010/10/23 15:44:18
3663 dnl ------------
3664 dnl Try to determine if the man-pages on the system are compressed, and if
3665 dnl so, what format is used.  Use this information to construct a script that
3666 dnl will install man-pages.
3667 AC_DEFUN([CF_MAN_PAGES],
3669 CF_HELP_MESSAGE(Options to Specify How Manpages are Installed:)
3670 CF_MANPAGE_FORMAT
3671 CF_MANPAGE_RENAMES
3672 CF_MANPAGE_SYMLINKS
3673 CF_MANPAGE_TBL
3675   if test "$prefix" = "NONE" ; then
3676      cf_prefix="$ac_default_prefix"
3677   else
3678      cf_prefix="$prefix"
3679   fi
3681   case "$MANPAGE_FORMAT" in # (vi
3682   *catonly*) # (vi
3683     cf_format=yes
3684     cf_inboth=no
3685     ;;
3686   *formatted*) # (vi
3687     cf_format=yes
3688     cf_inboth=yes
3689     ;;
3690   *)
3691     cf_format=no
3692     cf_inboth=no
3693     ;;
3694   esac
3696 test ! -d man && mkdir man
3698 cf_so_strip=
3699 cf_compress=
3700 case "$MANPAGE_FORMAT" in #(vi
3701 *compress*) #(vi
3702         cf_so_strip="Z"
3703         cf_compress=compress
3704   ;;
3705 *gzip*)
3706         cf_so_strip="gz"
3707         cf_compress=gzip
3708   ;;
3709 esac
3711 cf_edit_man=./edit_man.sh
3712 cf_man_alias=`pwd`/man_alias.sed
3714 cat >$cf_edit_man <<CF_EOF
3715 #! /bin/sh
3716 # this script is generated by the configure-script CF_MAN_PAGES macro.
3718 prefix="$cf_prefix"
3719 datadir="$datadir"
3721 NCURSES_MAJOR="$NCURSES_MAJOR"
3722 NCURSES_MINOR="$NCURSES_MINOR"
3723 NCURSES_PATCH="$NCURSES_PATCH"
3725 NCURSES_OSPEED="$NCURSES_OSPEED"
3726 TERMINFO="$TERMINFO"
3728 INSTALL="$INSTALL"
3729 INSTALL_DATA="$INSTALL_DATA"
3731 transform="$program_transform_name"
3733 TMP=\${TMPDIR:=/tmp}/man\$\$
3734 trap "rm -f \$TMP" 0 1 2 5 15
3736 form=\[$]1
3737 shift || exit 1
3739 verb=\[$]1
3740 shift || exit 1
3742 mandir=\[$]1
3743 shift || exit 1
3745 srcdir=\[$]1
3746 top_srcdir=\[$]srcdir/..
3747 shift || exit 1
3749 if test "\$form" = normal ; then
3750         if test "$cf_format" = yes ; then
3751         if test "$cf_inboth" = no ; then
3752                 sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
3753                 exit $?
3754         fi
3755         fi
3756         cf_subdir=\$mandir/man
3757         cf_tables=$MANPAGE_TBL
3758 else
3759         cf_subdir=\$mandir/cat
3760         cf_tables=yes
3763 # process the list of source-files
3764 for i in \[$]* ; do
3765 case \$i in #(vi
3766 *.orig|*.rej) ;; #(vi
3767 *.[[0-9]]*)
3768         section=\`expr "\$i" : '.*\\.\\([[0-9]]\\)[[xm]]*'\`;
3769         if test \$verb = installing ; then
3770         if test ! -d \$cf_subdir\${section} ; then
3771                 mkdir -p \$cf_subdir\$section
3772         fi
3773         fi
3775         # replace variables in man page
3776         if test ! -f $cf_man_alias ; then
3777 cat >>$cf_man_alias <<-CF_EOF2
3778                 s,@DATADIR@,\$datadir,g
3779                 s,@TERMINFO@,\$TERMINFO,g
3780                 s,@NCURSES_MAJOR@,\$NCURSES_MAJOR,g
3781                 s,@NCURSES_MINOR@,\$NCURSES_MINOR,g
3782                 s,@NCURSES_PATCH@,\$NCURSES_PATCH,g
3783                 s,@NCURSES_OSPEED@,\$NCURSES_OSPEED,g
3784 CF_EOF
3785         ifelse($1,,,[
3786         for cf_name in $1
3787         do
3788                 cf_NAME=`echo "$cf_name" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3789                 cf_name=`echo $cf_name|sed "$program_transform_name"`
3790 cat >>$cf_edit_man <<-CF_EOF
3791                 s,@$cf_NAME@,$cf_name,g
3792 CF_EOF
3793         done
3794         ])
3795 cat >>$cf_edit_man <<CF_EOF
3796 CF_EOF2
3797                 echo "...made $cf_man_alias"
3798         fi
3800         aliases=
3801         cf_source=\`basename \$i\`
3802         inalias=\$cf_source
3803         test ! -f \$inalias && inalias="\$srcdir/\$inalias"
3804         if test ! -f \$inalias ; then
3805                 echo .. skipped \$cf_source
3806                 continue
3807         fi
3808 CF_EOF
3810 if test "$MANPAGE_ALIASES" != no ; then
3811 cat >>$cf_edit_man <<CF_EOF
3812         aliases=\`sed -f \$top_srcdir/man/manlinks.sed \$inalias |sed -f $cf_man_alias | sort -u\`
3813 CF_EOF
3816 if test "$MANPAGE_RENAMES" = no ; then
3817 cat >>$cf_edit_man <<CF_EOF
3818         # perform program transformations for section 1 man pages
3819         if test \$section = 1 ; then
3820                 cf_target=\$cf_subdir\${section}/\`echo \$cf_source|sed "\${transform}"\`
3821         else
3822                 cf_target=\$cf_subdir\${section}/\$cf_source
3823         fi
3824 CF_EOF
3825 else
3826 cat >>$cf_edit_man <<CF_EOF
3827         cf_target=\`grep "^\$cf_source" $MANPAGE_RENAMES | $AWK '{print \[$]2}'\`
3828         if test -z "\$cf_target" ; then
3829                 echo '? missing rename for '\$cf_source
3830                 cf_target="\$cf_source"
3831         fi
3832         cf_target="\$cf_subdir\${section}/\${cf_target}"
3834 CF_EOF
3837 cat >>$cf_edit_man <<CF_EOF
3838         sed     -f $cf_man_alias \\
3839 CF_EOF
3841 if test -f $MANPAGE_RENAMES ; then
3842 cat >>$cf_edit_man <<CF_EOF
3843                 < \$i | sed -f `pwd`/edit_man.sed >\$TMP
3844 CF_EOF
3845 else
3846 cat >>$cf_edit_man <<CF_EOF
3847                 < \$i >\$TMP
3848 CF_EOF
3851 cat >>$cf_edit_man <<CF_EOF
3852 if test \$cf_tables = yes ; then
3853         tbl \$TMP >\$TMP.out
3854         mv \$TMP.out \$TMP
3856 CF_EOF
3858 if test $with_curses_h != yes ; then
3859 cat >>$cf_edit_man <<CF_EOF
3860         sed -e "/\#[    ]*include/s,curses.h,ncurses.h," < \$TMP >\$TMP.out
3861         mv \$TMP.out \$TMP
3862 CF_EOF
3865 cat >>$cf_edit_man <<CF_EOF
3866         if test \$form = format ; then
3867                 nroff -man \$TMP >\$TMP.out
3868                 mv \$TMP.out \$TMP
3869         fi
3870 CF_EOF
3872 if test -n "$cf_compress" ; then
3873 cat >>$cf_edit_man <<CF_EOF
3874         if test \$verb = installing ; then
3875         if ( $cf_compress -f \$TMP )
3876         then
3877                 mv \$TMP.$cf_so_strip \$TMP
3878         fi
3879         fi
3880         cf_target="\$cf_target.$cf_so_strip"
3881 CF_EOF
3884 case "$MANPAGE_FORMAT" in #(vi
3885 *BSDI*)
3886 cat >>$cf_edit_man <<CF_EOF
3887         if test \$form = format ; then
3888                 # BSDI installs only .0 suffixes in the cat directories
3889                 cf_target="\`echo \$cf_target|sed -e 's/\.[[1-9]]\+[[a-z]]*/.0/'\`"
3890         fi
3891 CF_EOF
3892   ;;
3893 esac
3895 cat >>$cf_edit_man <<CF_EOF
3896         suffix=\`basename \$cf_target | sed -e 's%^[[^.]]*%%'\`
3897         if test \$verb = installing ; then
3898                 echo \$verb \$cf_target
3899                 \$INSTALL_DATA \$TMP \$cf_target
3900                 test -d \$cf_subdir\${section} &&
3901                 test -n "\$aliases" && (
3902                         cd \$cf_subdir\${section} && (
3903                                 cf_source=\`echo \$cf_target |sed -e 's%^.*/\([[^/]][[^/]]*/[[^/]][[^/]]*$\)%\1%'\`
3904                                 test -n "$cf_so_strip" && cf_source=\`echo \$cf_source |sed -e 's%\.$cf_so_strip\$%%'\`
3905                                 cf_target=\`basename \$cf_target\`
3906                                 for cf_alias in \$aliases
3907                                 do
3908                                         if test \$section = 1 ; then
3909                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
3910                                         fi
3912                                         if test "$MANPAGE_SYMLINKS" = yes ; then
3913                                                 if test -f \$cf_alias\${suffix} ; then
3914                                                         if ( cmp -s \$cf_target \$cf_alias\${suffix} )
3915                                                         then
3916                                                                 continue
3917                                                         fi
3918                                                 fi
3919                                                 echo .. \$verb alias \$cf_alias\${suffix}
3920 CF_EOF
3921 case "x$LN_S" in #(vi
3922 *-f) #(vi
3923 cat >>$cf_edit_man <<CF_EOF
3924                                                 $LN_S \$cf_target \$cf_alias\${suffix}
3925 CF_EOF
3926         ;;
3928 cat >>$cf_edit_man <<CF_EOF
3929                                                 rm -f \$cf_alias\${suffix}
3930                                                 $LN_S \$cf_target \$cf_alias\${suffix}
3931 CF_EOF
3932         ;;
3933 esac
3934 cat >>$cf_edit_man <<CF_EOF
3935                                         elif test "\$cf_target" != "\$cf_alias\${suffix}" ; then
3936                                                 echo ".so \$cf_source" >\$TMP
3937 CF_EOF
3938 if test -n "$cf_compress" ; then
3939 cat >>$cf_edit_man <<CF_EOF
3940                                                 if test -n "$cf_so_strip" ; then
3941                                                         $cf_compress -f \$TMP
3942                                                         mv \$TMP.$cf_so_strip \$TMP
3943                                                 fi
3944 CF_EOF
3946 cat >>$cf_edit_man <<CF_EOF
3947                                                 echo .. \$verb alias \$cf_alias\${suffix}
3948                                                 rm -f \$cf_alias\${suffix}
3949                                                 \$INSTALL_DATA \$TMP \$cf_alias\${suffix}
3950                                         fi
3951                                 done
3952                         )
3953                 )
3954         elif test \$verb = removing ; then
3955                 test -f \$cf_target && (
3956                         echo \$verb \$cf_target
3957                         rm -f \$cf_target
3958                 )
3959                 test -d \$cf_subdir\${section} &&
3960                 test -n "\$aliases" && (
3961                         cd \$cf_subdir\${section} && (
3962                                 for cf_alias in \$aliases
3963                                 do
3964                                         if test \$section = 1 ; then
3965                                                 cf_alias=\`echo \$cf_alias|sed "\${transform}"\`
3966                                         fi
3968                                         echo .. \$verb alias \$cf_alias\${suffix}
3969                                         rm -f \$cf_alias\${suffix}
3970                                 done
3971                         )
3972                 )
3973         else
3974 #               echo ".hy 0"
3975                 cat \$TMP
3976         fi
3977         ;;
3978 esac
3979 done
3981 if test $cf_inboth = yes ; then
3982 if test \$form != format ; then
3983         sh \[$]0 format \$verb \$mandir \$srcdir \[$]*
3987 exit 0
3988 CF_EOF
3989 chmod 755 $cf_edit_man
3991 ])dnl
3992 dnl ---------------------------------------------------------------------------
3993 dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
3994 dnl -----------
3995 dnl Checks for libraries.  At least one UNIX system, Apple Macintosh
3996 dnl Rhapsody 5.5, does not have -lm.  We cannot use the simpler
3997 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
3998 AC_DEFUN([CF_MATH_LIB],
4000 AC_CACHE_CHECK(if -lm needed for math functions,
4001         cf_cv_need_libm,[
4002         AC_TRY_LINK([
4003         #include <stdio.h>
4004         #include <math.h>
4005         ],
4006         [double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
4007         [cf_cv_need_libm=no],
4008         [cf_cv_need_libm=yes])])
4009 if test "$cf_cv_need_libm" = yes
4010 then
4011 ifelse($1,,[
4012         CF_ADD_LIB(m)
4013 ],[$1=-lm])
4016 dnl ---------------------------------------------------------------------------
4017 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
4018 dnl ----------------------
4019 dnl Check if the file-system supports mixed-case filenames.  If we're able to
4020 dnl create a lowercase name and see it as uppercase, it doesn't support that.
4021 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
4023 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
4024 if test "$cross_compiling" = yes ; then
4025         case $target_alias in #(vi
4026         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
4027                 cf_cv_mixedcase=no
4028                 ;;
4029         *)
4030                 cf_cv_mixedcase=yes
4031                 ;;
4032         esac
4033 else
4034         rm -f conftest CONFTEST
4035         echo test >conftest
4036         if test -f CONFTEST ; then
4037                 cf_cv_mixedcase=no
4038         else
4039                 cf_cv_mixedcase=yes
4040         fi
4041         rm -f conftest CONFTEST
4044 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,[],[MIXEDCASE_FILENAMES])
4045 ])dnl
4046 dnl ---------------------------------------------------------------------------
4047 dnl CF_MKSTEMP version: 7 updated: 2010/08/14 18:25:37
4048 dnl ----------
4049 dnl Check for a working mkstemp.  This creates two files, checks that they are
4050 dnl successfully created and distinct (AmigaOS apparently fails on the last).
4051 AC_DEFUN([CF_MKSTEMP],[
4052 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
4053 rm -rf conftest*
4054 AC_TRY_RUN([
4055 #include <sys/types.h>
4056 #include <stdlib.h>
4057 #include <stdio.h>
4058 #include <string.h>
4059 #include <sys/stat.h>
4060 int main()
4062         char *tmpl = "conftestXXXXXX";
4063         char name[2][80];
4064         int n;
4065         int result = 0;
4066         int fd;
4067         struct stat sb;
4069         umask(077);
4070         for (n = 0; n < 2; ++n) {
4071                 strcpy(name[n], tmpl);
4072                 if ((fd = mkstemp(name[n])) >= 0) {
4073                         if (!strcmp(name[n], tmpl)
4074                          || stat(name[n], &sb) != 0
4075                          || (sb.st_mode & S_IFMT) != S_IFREG
4076                          || (sb.st_mode & 077) != 0) {
4077                                 result = 1;
4078                         }
4079                         close(fd);
4080                 }
4081         }
4082         if (result == 0
4083          && !strcmp(name[0], name[1]))
4084                 result = 1;
4085         ${cf_cv_main_return:-return}(result);
4087 ],[cf_cv_func_mkstemp=yes
4088 ],[cf_cv_func_mkstemp=no
4089 ],[AC_CHECK_FUNC(mkstemp)
4092 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
4093         AC_DEFINE(HAVE_MKSTEMP,[],[HAVE_MKSTEMP])
4095 ])dnl
4096 dnl ---------------------------------------------------------------------------
4097 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
4098 dnl ----------
4099 dnl Write a debug message to config.log, along with the line number in the
4100 dnl configure script.
4101 AC_DEFUN([CF_MSG_LOG],[
4102 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AS_MESSAGE_LOG_FD
4103 ])dnl
4104 dnl ---------------------------------------------------------------------------
4105 dnl CF_NCURSES_ABI_6 version: 1 updated: 2005/09/17 18:42:49
4106 dnl ----------------
4107 dnl Set ncurses' ABI to 6 unless overridden by explicit configure option, and
4108 dnl warn about this.
4109 AC_DEFUN([CF_NCURSES_ABI_6],[
4110 if test "${with_abi_version+set}" != set; then
4111         case $cf_cv_rel_version in
4112         5.*)
4113                 cf_cv_rel_version=6.0
4114                 cf_cv_abi_version=6
4115                 AC_MSG_WARN(Overriding ABI version to $cf_cv_abi_version)
4116                 ;;
4117         esac
4119 ])dnl
4120 dnl ---------------------------------------------------------------------------
4121 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
4122 dnl ------------------
4123 dnl see CF_WITH_NO_LEAKS
4124 AC_DEFUN([CF_NO_LEAKS_OPTION],[
4125 AC_MSG_CHECKING(if you want to use $1 for testing)
4126 AC_ARG_WITH($1,
4127         [$2],
4128         [AC_DEFINE($3,[],[$3])ifelse([$4],,[
4129          $4
4131         : ${with_cflags:=-g}
4132         : ${with_no_leaks:=yes}
4133          with_$1=yes],
4134         [with_$1=])
4135 AC_MSG_RESULT(${with_$1:-no})
4137 case .$with_cflags in #(vi
4138 .*-g*)
4139         case .$CFLAGS in #(vi
4140         .*-g*) #(vi
4141                 ;;
4142         *)
4143                 CF_ADD_CFLAGS([-g])
4144                 ;;
4145         esac
4146         ;;
4147 esac
4148 ])dnl
4149 dnl ---------------------------------------------------------------------------
4150 dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
4151 dnl ----------------
4152 dnl Check if the given variable is a number.  If not, report an error.
4153 dnl $1 is the variable
4154 dnl $2 is the message
4155 AC_DEFUN([CF_NUMBER_SYNTAX],[
4156 if test -n "$1" ; then
4157   case $1 in #(vi
4158   [[0-9]]*) #(vi
4159         ;;
4160   *)
4161         AC_MSG_ERROR($2 is not a number: $1)
4162         ;;
4163   esac
4164 else
4165   AC_MSG_ERROR($2 value is empty)
4167 ])dnl
4168 dnl ---------------------------------------------------------------------------
4169 dnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
4170 dnl -------------
4171 dnl Compute the object-directory name from the given model name
4172 AC_DEFUN([CF_OBJ_SUBDIR],
4174         case $1 in
4175         libtool) $2='obj_lo'  ;;
4176         normal)  $2='objects' ;;
4177         debug)   $2='obj_g' ;;
4178         profile) $2='obj_p' ;;
4179         shared)
4180                 case $cf_cv_system_name in #(vi
4181                 cygwin) #(vi
4182                         $2='objects' ;;
4183                 *)
4184                         $2='obj_s' ;;
4185                 esac
4186         esac
4187 ])dnl
4188 dnl ---------------------------------------------------------------------------
4189 dnl CF_PATHSEP version: 5 updated: 2010/05/26 05:38:42
4190 dnl ----------
4191 dnl Provide a value for the $PATH and similar separator
4192 AC_DEFUN([CF_PATHSEP],
4194         case $cf_cv_system_name in
4195         os2*)   PATH_SEPARATOR=';'  ;;
4196         *)      PATH_SEPARATOR=':'  ;;
4197         esac
4198 ifelse([$1],,,[$1=$PATH_SEPARATOR])
4199         AC_SUBST(PATH_SEPARATOR)
4200 ])dnl
4201 dnl ---------------------------------------------------------------------------
4202 dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
4203 dnl --------------
4204 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
4205 dnl begins with one of the prefix/exec_prefix variables, and then again if the
4206 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
4207 dnl delayed evaluation of those symbols.
4208 AC_DEFUN([CF_PATH_SYNTAX],[
4209 if test "x$prefix" != xNONE; then
4210   cf_path_syntax="$prefix"
4211 else
4212   cf_path_syntax="$ac_default_prefix"
4215 case ".[$]$1" in #(vi
4216 .\[$]\(*\)*|.\'*\'*) #(vi
4217   ;;
4218 ..|./*|.\\*) #(vi
4219   ;;
4220 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
4221   ;;
4222 .\[$]{*prefix}*) #(vi
4223   eval $1="[$]$1"
4224   case ".[$]$1" in #(vi
4225   .NONE/*)
4226     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
4227     ;;
4228   esac
4229   ;; #(vi
4230 .\[$]{datadir}*) #(vi
4231   eval $1="[$]$1"
4232   case ".[$]$1" in #(vi
4233   .NONE/*)
4234     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
4235     ;;
4236   esac
4237   ;; #(vi
4238 .\[$]{datarootdir}*) #(vi
4239   eval $1="[$]$1"
4240   case ".[$]$1" in #(vi
4241   .NONE/*)
4242     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
4243     ;;
4244   esac
4245   ;; #(vi
4246 .no|.NONE/*)
4247   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
4248   ;;
4250   ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
4251   ;;
4252 esac
4253 ])dnl
4254 dnl ---------------------------------------------------------------------------
4255 dnl CF_PKG_CONFIG version: 4 updated: 2011/02/18 20:26:24
4256 dnl -------------
4257 dnl Check for the package-config program, unless disabled by command-line.
4258 AC_DEFUN([CF_PKG_CONFIG],
4260 AC_MSG_CHECKING(if you want to use pkg-config)
4261 AC_ARG_WITH(pkg-config,
4262         [  --with-pkg-config{=path} enable/disable use of pkg-config],
4263         [cf_pkg_config=$withval],
4264         [cf_pkg_config=yes])
4265 AC_MSG_RESULT($cf_pkg_config)
4267 case $cf_pkg_config in #(vi
4268 no) #(vi
4269         PKG_CONFIG=none
4270         ;;
4271 yes) #(vi
4272         AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)
4273         ;;
4275         PKG_CONFIG=$withval
4276         ;;
4277 esac
4279 test -z "$PKG_CONFIG" && PKG_CONFIG=none
4280 if test "$PKG_CONFIG" != none ; then
4281         CF_PATH_SYNTAX(PKG_CONFIG)
4284 AC_SUBST(PKG_CONFIG)
4285 ])dnl
4286 dnl ---------------------------------------------------------------------------
4287 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
4288 dnl -----------------
4289 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
4291 dnl     POSIX.1-1990                            _POSIX_SOURCE
4292 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
4293 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
4294 dnl             Bindings Option
4295 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
4296 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
4297 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
4299 dnl Parameters:
4300 dnl     $1 is the nominal value for _POSIX_C_SOURCE
4301 AC_DEFUN([CF_POSIX_C_SOURCE],
4303 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
4305 cf_save_CFLAGS="$CFLAGS"
4306 cf_save_CPPFLAGS="$CPPFLAGS"
4308 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
4309 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
4311 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
4312         CF_MSG_LOG(if the symbol is already defined go no further)
4313         AC_TRY_COMPILE([#include <sys/types.h>],[
4314 #ifndef _POSIX_C_SOURCE
4315 make an error
4316 #endif],
4317         [cf_cv_posix_c_source=no],
4318         [cf_want_posix_source=no
4319          case .$cf_POSIX_C_SOURCE in #(vi
4320          .[[12]]??*) #(vi
4321                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
4322                 ;;
4323          .2) #(vi
4324                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
4325                 cf_want_posix_source=yes
4326                 ;;
4327          .*)
4328                 cf_want_posix_source=yes
4329                 ;;
4330          esac
4331          if test "$cf_want_posix_source" = yes ; then
4332                 AC_TRY_COMPILE([#include <sys/types.h>],[
4333 #ifdef _POSIX_SOURCE
4334 make an error
4335 #endif],[],
4336                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
4337          fi
4338          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
4339          CFLAGS="$cf_trim_CFLAGS"
4340          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
4341          CF_MSG_LOG(if the second compile does not leave our definition intact error)
4342          AC_TRY_COMPILE([#include <sys/types.h>],[
4343 #ifndef _POSIX_C_SOURCE
4344 make an error
4345 #endif],,
4346          [cf_cv_posix_c_source=no])
4347          CFLAGS="$cf_save_CFLAGS"
4348          CPPFLAGS="$cf_save_CPPFLAGS"
4349         ])
4352 if test "$cf_cv_posix_c_source" != no ; then
4353         CFLAGS="$cf_trim_CFLAGS"
4354         CPPFLAGS="$cf_trim_CPPFLAGS"
4355         CF_ADD_CFLAGS($cf_cv_posix_c_source)
4358 ])dnl
4359 dnl ---------------------------------------------------------------------------
4360 dnl CF_PREDEFINE version: 2 updated: 2010/05/26 16:44:57
4361 dnl ------------
4362 dnl Add definitions to CPPFLAGS to ensure they're predefined for all compiles.
4364 dnl $1 = symbol to test
4365 dnl $2 = value (if any) to use for a predefinition
4366 AC_DEFUN([CF_PREDEFINE],
4368 AC_MSG_CHECKING(if we must define $1)
4369 AC_TRY_COMPILE([#include <sys/types.h>
4371 #ifndef $1
4372 make an error
4373 #endif],[cf_result=no],[cf_result=yes])
4374 AC_MSG_RESULT($cf_result)
4376 if test "$cf_result" = yes ; then
4377         CPPFLAGS="$CPPFLAGS ifelse([$2],,-D$1,[-D$1=$2])"
4378 elif test "x$2" != "x" ; then
4379         AC_MSG_CHECKING(checking for compatible value versus $2)
4380         AC_TRY_COMPILE([#include <sys/types.h>
4382 #if $1-$2 < 0
4383 make an error
4384 #endif],[cf_result=yes],[cf_result=no])
4385         AC_MSG_RESULT($cf_result)
4386         if test "$cf_result" = no ; then
4387                 # perhaps we can override it - try...
4388                 CPPFLAGS="$CPPFLAGS -D$1=$2"
4389         fi
4391 ])dnl
4392 dnl ---------------------------------------------------------------------------
4393 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
4394 dnl ------------
4395 dnl Append definitions and rules for the given programs to the subdirectory
4396 dnl Makefiles, and the recursion rule for the top-level Makefile.
4398 dnl parameters
4399 dnl     $1 = script to run
4400 dnl     $2 = list of subdirectories
4402 dnl variables
4403 dnl     $AWK
4404 AC_DEFUN([CF_PRG_RULES],
4406 for cf_dir in $2
4408         if test ! -d $srcdir/$cf_dir; then
4409                 continue
4410         elif test -f $srcdir/$cf_dir/programs; then
4411                 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
4412         fi
4413 done
4415 ])dnl
4416 dnl ---------------------------------------------------------------------------
4417 dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
4418 dnl ----------
4419 dnl Check for archiver "ar".
4420 AC_DEFUN([CF_PROG_AR],[
4421 AC_CHECK_TOOL(AR, ar, ar)
4423 dnl ---------------------------------------------------------------------------
4424 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
4425 dnl -----------
4426 dnl Check for awk, ensure that the check found something.
4427 AC_DEFUN([CF_PROG_AWK],
4429 AC_PROG_AWK
4430 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
4431 ])dnl
4432 dnl ---------------------------------------------------------------------------
4433 dnl CF_PROG_CC_C_O version: 3 updated: 2010/08/14 18:25:37
4434 dnl --------------
4435 dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
4436 dnl the output file can be renamed, and allows for a shell variable that can
4437 dnl be used later.  The parameter is either CC or CXX.  The result is the
4438 dnl cache variable:
4439 dnl     $cf_cv_prog_CC_c_o
4440 dnl     $cf_cv_prog_CXX_c_o
4441 AC_DEFUN([CF_PROG_CC_C_O],
4442 [AC_REQUIRE([AC_PROG_CC])dnl
4443 AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
4444 AC_CACHE_VAL(cf_cv_prog_$1_c_o,
4446 cat > conftest.$ac_ext <<CF_EOF
4447 #include <stdio.h>
4448 int main()
4450         ${cf_cv_main_return:-return}(0);
4452 CF_EOF
4453 # We do the test twice because some compilers refuse to overwrite an
4454 # existing .o file with -o, though they will create one.
4455 ac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
4456 if AC_TRY_EVAL(ac_try) &&
4457   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
4458 then
4459   eval cf_cv_prog_$1_c_o=yes
4460 else
4461   eval cf_cv_prog_$1_c_o=no
4463 rm -rf conftest*
4464 ])dnl
4465 if test $cf_cv_prog_$1_c_o = yes; then
4466   AC_MSG_RESULT([yes])
4467 else
4468   AC_MSG_RESULT([no])
4470 ])dnl
4471 dnl ---------------------------------------------------------------------------
4472 dnl CF_PROG_CC_U_D version: 1 updated: 2005/07/14 16:59:30
4473 dnl --------------
4474 dnl Check if C (preprocessor) -U and -D options are processed in the order
4475 dnl given rather than by type of option.  Some compilers insist on apply all
4476 dnl of the -U options after all of the -D options.  Others allow mixing them,
4477 dnl and may predefine symbols that conflict with those we define.
4478 AC_DEFUN([CF_PROG_CC_U_D],
4480 AC_CACHE_CHECK(if $CC -U and -D options work together,cf_cv_cc_u_d_options,[
4481         cf_save_CPPFLAGS="$CPPFLAGS"
4482         CPPFLAGS="-UU_D_OPTIONS -DU_D_OPTIONS -DD_U_OPTIONS -UD_U_OPTIONS"
4483         AC_TRY_COMPILE([],[
4484 #ifndef U_D_OPTIONS
4485 make an undefined-error
4486 #endif
4487 #ifdef  D_U_OPTIONS
4488 make a defined-error
4489 #endif
4490         ],[
4491         cf_cv_cc_u_d_options=yes],[
4492         cf_cv_cc_u_d_options=no])
4493         CPPFLAGS="$cf_save_CPPFLAGS"
4495 ])dnl
4496 dnl ---------------------------------------------------------------------------
4497 dnl CF_PROG_EGREP version: 1 updated: 2006/09/16 11:40:59
4498 dnl -------------
4499 dnl AC_PROG_EGREP was introduced in autoconf 2.53.
4500 dnl This macro adds a check to ensure the script found something.
4501 AC_DEFUN([CF_PROG_EGREP],
4502 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
4503    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
4504     then ac_cv_prog_egrep='grep -E'
4505     else ac_cv_prog_egrep='egrep'
4506     fi])
4507  EGREP=$ac_cv_prog_egrep
4508  AC_SUBST([EGREP])
4509 test -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
4510 ])dnl
4511 dnl ---------------------------------------------------------------------------
4512 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
4513 dnl -----------
4514 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
4515 AC_DEFUN([CF_PROG_EXT],
4517 AC_REQUIRE([CF_CHECK_CACHE])
4518 case $cf_cv_system_name in
4519 os2*)
4520     CFLAGS="$CFLAGS -Zmt"
4521     CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
4522     CXXFLAGS="$CXXFLAGS -Zmt"
4523     # autoconf's macro sets -Zexe and suffix both, which conflict:w
4524     LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
4525     ac_cv_exeext=.exe
4526     ;;
4527 esac
4529 AC_EXEEXT
4530 AC_OBJEXT
4532 PROG_EXT="$EXEEXT"
4533 AC_SUBST(PROG_EXT)
4534 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT",[PROG_EXT])
4535 ])dnl
4536 dnl ---------------------------------------------------------------------------
4537 dnl CF_PROG_GNAT version: 1 updated: 2010/06/19 15:22:18
4538 dnl ------------
4539 dnl Check for gnatmake, ensure that it is complete.
4540 AC_DEFUN([CF_PROG_GNAT],[
4541 cf_ada_make=gnatmake
4542 AC_CHECK_PROG(gnat_exists, $cf_ada_make, yes, no)
4543 if test "$ac_cv_prog_gnat_exists" = no; then
4544    cf_ada_make=
4545 else
4546    CF_GNAT_VERSION
4547    AC_CHECK_PROG(M4_exists, m4, yes, no)
4548    if test "$ac_cv_prog_M4_exists" = no; then
4549       cf_cv_prog_gnat_correct=no
4550       echo Ada95 binding required program m4 not found. Ada95 binding disabled.
4551    fi
4552    if test "$cf_cv_prog_gnat_correct" = yes; then
4553       AC_MSG_CHECKING(if GNAT works)
4554       CF_GNAT_TRY_RUN([procedure conftest;],
4555 [with Text_IO;
4556 with GNAT.OS_Lib;
4557 procedure conftest is
4558 begin
4559    Text_IO.Put ("Hello World");
4560    Text_IO.New_Line;
4561    GNAT.OS_Lib.OS_Exit (0);
4562 end conftest;],[cf_cv_prog_gnat_correct=yes],[cf_cv_prog_gnat_correct=no])
4563       AC_MSG_RESULT($cf_cv_prog_gnat_correct)
4564    fi
4567 AC_SUBST(cf_ada_make)
4568 ])dnl
4569 dnl ---------------------------------------------------------------------------
4570 dnl CF_PROG_INSTALL version: 5 updated: 2002/12/21 22:46:07
4571 dnl ---------------
4572 dnl Force $INSTALL to be an absolute-path.  Otherwise, edit_man.sh and the
4573 dnl misc/tabset install won't work properly.  Usually this happens only when
4574 dnl using the fallback mkinstalldirs script
4575 AC_DEFUN([CF_PROG_INSTALL],
4576 [AC_PROG_INSTALL
4577 case $INSTALL in
4579   ;;
4581   CF_DIRNAME(cf_dir,$INSTALL)
4582   test -z "$cf_dir" && cf_dir=.
4583   INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
4584   ;;
4585 esac
4586 ])dnl
4587 dnl ---------------------------------------------------------------------------
4588 dnl CF_PROG_LDCONFIG version: 2 updated: 2008/12/13 14:08:40
4589 dnl ----------------
4590 dnl Check for ldconfig, needed to fixup shared libraries that would be built
4591 dnl and then used in the install.
4592 AC_DEFUN([CF_PROG_LDCONFIG],[
4593 if test "$cross_compiling" = yes ; then
4594   LDCONFIG=:
4595 else
4596 case "$cf_cv_system_name" in #(vi
4597 dragonfly*|freebsd*) #(vi
4598   test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
4599   ;;
4600 *) LDPATH=$PATH:/sbin:/usr/sbin
4601   AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
4602   ;;
4603 esac
4605 AC_SUBST(LDCONFIG)
4606 ])dnl
4607 dnl ---------------------------------------------------------------------------
4608 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
4609 dnl ------------
4610 AC_DEFUN([CF_PROG_LINT],
4612 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
4613 AC_SUBST(LINT_OPTS)
4614 ])dnl
4615 dnl ---------------------------------------------------------------------------
4616 dnl CF_PROG_LN_S version: 2 updated: 2010/08/14 18:25:37
4617 dnl ------------
4618 dnl Combine checks for "ln -s" and "ln -sf", updating $LN_S to include "-f"
4619 dnl option if it is supported.
4620 AC_DEFUN([CF_PROG_LN_S],[
4621 AC_PROG_LN_S
4622 AC_MSG_CHECKING(if $LN_S -f options work)
4624 rm -f conf$$.src conf$$dst
4625 echo >conf$$.dst
4626 echo first >conf$$.src
4627 if $LN_S -f conf$$.src conf$$.dst 2>/dev/null; then
4628         cf_prog_ln_sf=yes
4629 else
4630         cf_prog_ln_sf=no
4632 rm -f conf$$.dst conf$$src
4633 AC_MSG_RESULT($cf_prog_ln_sf)
4635 test "$cf_prog_ln_sf" = yes && LN_S="$LN_S -f"
4636 ])dnl
4637 dnl ---------------------------------------------------------------------------
4638 dnl CF_REGEX version: 8 updated: 2010/08/07 14:09:44
4639 dnl --------
4640 dnl Attempt to determine if we've got one of the flavors of regular-expression
4641 dnl code that we can support.
4642 AC_DEFUN([CF_REGEX],
4645 cf_regex_func=no
4647 cf_regex_libs="regex re"
4648 case $host_os in #(vi
4649 mingw*)
4650         cf_regex_libs="regex.dll $cf_regex_libs"
4651         ;;
4652 esac
4654 AC_CHECK_FUNC(regcomp,[cf_regex_func=regcomp],[
4655         for cf_regex_lib in $cf_regex_libs
4656         do
4657                 AC_CHECK_LIB($cf_regex_lib,regcomp,[
4658                                 CF_ADD_LIB($cf_regex_lib)
4659                                 cf_regex_func=regcomp
4660                                 break])
4661         done
4664 if test "$cf_regex_func" = no ; then
4665         AC_CHECK_FUNC(compile,[cf_regex_func=compile],[
4666                 AC_CHECK_LIB(gen,compile,[
4667                                 CF_ADD_LIB(gen)
4668                                 cf_regex_func=compile])])
4671 if test "$cf_regex_func" = no ; then
4672         AC_MSG_WARN(cannot find regular expression library)
4675 AC_CACHE_CHECK(for regular-expression headers,cf_cv_regex_hdrs,[
4677 cf_cv_regex_hdrs=no
4678 case $cf_regex_func in #(vi
4679 compile) #(vi
4680         for cf_regex_hdr in regexp.h regexpr.h
4681         do
4682                 AC_TRY_LINK([#include <$cf_regex_hdr>],[
4683                         char *p = compile("", "", "", 0);
4684                         int x = step("", "");
4685                 ],[
4686                         cf_cv_regex_hdrs=$cf_regex_hdr
4687                         break
4688                 ])
4689         done
4690         ;;
4692         for cf_regex_hdr in regex.h
4693         do
4694                 AC_TRY_LINK([#include <sys/types.h>
4695 #include <$cf_regex_hdr>],[
4696                         regex_t *p;
4697                         int x = regcomp(p, "", 0);
4698                         int y = regexec(p, "", 0, 0, 0);
4699                         regfree(p);
4700                 ],[
4701                         cf_cv_regex_hdrs=$cf_regex_hdr
4702                         break
4703                 ])
4704         done
4705         ;;
4706 esac
4710 case $cf_cv_regex_hdrs in #(vi
4711     no)        AC_MSG_WARN(no regular expression header found) ;; #(vi
4712     regex.h)   AC_DEFINE(HAVE_REGEX_H_FUNCS,[],[HAVE_REGEX_H_FUNCS]) ;; #(vi
4713     regexp.h)  AC_DEFINE(HAVE_REGEXP_H_FUNCS,[],[HAVE_REGEXP_H_FUNCS]) ;; #(vi
4714     regexpr.h) AC_DEFINE(HAVE_REGEXPR_H_FUNCS,[],[HAVE_REGPR_H_FUNCS]) ;;
4715 esac
4716 ])dnl
4717 dnl ---------------------------------------------------------------------------
4718 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
4719 dnl ----------------
4720 dnl Remove all -U and -D options that refer to the given symbol from a list
4721 dnl of C compiler options.  This works around the problem that not all
4722 dnl compilers process -U and -D options from left-to-right, so a -U option
4723 dnl cannot be used to cancel the effect of a preceding -D option.
4725 dnl $1 = target (which could be the same as the source variable)
4726 dnl $2 = source (including '$')
4727 dnl $3 = symbol to remove
4728 define([CF_REMOVE_DEFINE],
4730 $1=`echo "$2" | \
4731         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
4732                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
4733 ])dnl
4734 dnl ---------------------------------------------------------------------------
4735 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
4736 dnl -------------
4737 dnl Remove the given library from the symbol
4739 dnl $1 = target (which could be the same as the source variable)
4740 dnl $2 = source (including '$')
4741 dnl $3 = library to remove
4742 define([CF_REMOVE_LIB],
4744 # remove $3 library from $2
4745 $1=`echo "$2" | sed -e 's/-l$3[[        ]]//g' -e 's/-l$3[$]//'`
4746 ])dnl
4747 dnl ---------------------------------------------------------------------------
4748 dnl CF_RPATH_HACK version: 9 updated: 2011/02/13 13:31:33
4749 dnl -------------
4750 AC_DEFUN([CF_RPATH_HACK],
4752 AC_REQUIRE([CF_LD_RPATH_OPT])
4753 AC_MSG_CHECKING(for updated LDFLAGS)
4754 if test -n "$LD_RPATH_OPT" ; then
4755         AC_MSG_RESULT(maybe)
4757         AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
4758         cf_rpath_list="/usr/lib /lib"
4759         if test "$cf_ldd_prog" != no
4760         then
4761                 cf_rpath_oops=
4763 AC_TRY_LINK([#include <stdio.h>],
4764                 [printf("Hello");],
4765                 [cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort -u`
4766                  cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[     ]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort -u`])
4768                 # If we passed the link-test, but get a "not found" on a given library,
4769                 # this could be due to inept reconfiguration of gcc to make it only
4770                 # partly honor /usr/local/lib (or whatever).  Sometimes this behavior
4771                 # is intentional, e.g., installing gcc in /usr/bin and suppressing the
4772                 # /usr/local libraries.
4773                 if test -n "$cf_rpath_oops"
4774                 then
4775                         for cf_rpath_src in $cf_rpath_oops
4776                         do
4777                                 for cf_rpath_dir in \
4778                                         /usr/local \
4779                                         /usr/pkg \
4780                                         /opt/sfw
4781                                 do
4782                                         if test -f $cf_rpath_dir/lib/$cf_rpath_src
4783                                         then
4784                                                 CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
4785                                                 LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
4786                                                 break
4787                                         fi
4788                                 done
4789                         done
4790                 fi
4791         fi
4793         CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4795         CF_RPATH_HACK_2(LDFLAGS)
4796         CF_RPATH_HACK_2(LIBS)
4798         CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
4800 AC_SUBST(EXTRA_LDFLAGS)
4801 ])dnl
4802 dnl ---------------------------------------------------------------------------
4803 dnl CF_RPATH_HACK_2 version: 6 updated: 2010/04/17 16:31:24
4804 dnl ---------------
4805 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
4806 dnl EXTRA_LDFLAGS for each -L option found.
4808 dnl $cf_rpath_list contains a list of directories to ignore.
4810 dnl $1 = variable name to update.  The LDFLAGS variable should be the only one,
4811 dnl      but LIBS often has misplaced -L options.
4812 AC_DEFUN([CF_RPATH_HACK_2],
4814 CF_VERBOSE(...checking $1 [$]$1)
4816 cf_rpath_dst=
4817 for cf_rpath_src in [$]$1
4819         case $cf_rpath_src in #(vi
4820         -L*) #(vi
4822                 # check if this refers to a directory which we will ignore
4823                 cf_rpath_skip=no
4824                 if test -n "$cf_rpath_list"
4825                 then
4826                         for cf_rpath_item in $cf_rpath_list
4827                         do
4828                                 if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
4829                                 then
4830                                         cf_rpath_skip=yes
4831                                         break
4832                                 fi
4833                         done
4834                 fi
4836                 if test "$cf_rpath_skip" = no
4837                 then
4838                         # transform the option
4839                         if test "$LD_RPATH_OPT" = "-R " ; then
4840                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
4841                         else
4842                                 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
4843                         fi
4845                         # if we have not already added this, add it now
4846                         cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
4847                         if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
4848                         then
4849                                 CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
4850                                 EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
4851                         fi
4852                 fi
4853                 ;;
4854         esac
4855         cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
4856 done
4857 $1=$cf_rpath_dst
4859 CF_VERBOSE(...checked $1 [$]$1)
4860 AC_SUBST(EXTRA_LDFLAGS)
4861 ])dnl
4862 dnl ---------------------------------------------------------------------------
4863 dnl CF_SHARED_OPTS version: 64 updated: 2010/06/05 16:51:16
4864 dnl --------------
4865 dnl --------------
4866 dnl Attempt to determine the appropriate CC/LD options for creating a shared
4867 dnl library.
4869 dnl Note: ${LOCAL_LDFLAGS} is used to link executables that will run within the
4870 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
4871 dnl We avoid compiling-in a ../lib path for the shared library since that can
4872 dnl lead to unexpected results at runtime.
4873 dnl ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared libraries
4874 dnl are compiled in ../../lib
4876 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
4877 dnl to install symbolic links to the rel/abi versions of shared libraries.
4879 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
4880 dnl version when making symbolic links.
4882 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
4883 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
4884 dnl (ex: libncurses.so.<ver>).
4886 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
4887 AC_DEFUN([CF_SHARED_OPTS],
4889         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
4890         AC_REQUIRE([CF_LD_RPATH_OPT])
4891         LOCAL_LDFLAGS=
4892         LOCAL_LDFLAGS2=
4893         LD_SHARED_OPTS=
4894         INSTALL_LIB="-m 644"
4896         cf_cv_do_symlinks=no
4897         cf_ld_rpath_opt=
4898         test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
4900         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
4901         AC_ARG_WITH(shlib-version,
4902         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
4903         [test -z "$withval" && withval=auto
4904         case $withval in #(vi
4905         yes) #(vi
4906                 cf_cv_shlib_version=auto
4907                 ;;
4908         rel|abi|auto|no) #(vi
4909                 cf_cv_shlib_version=$withval
4910                 ;;
4911         *)
4912                 AC_MSG_ERROR([option value must be one of: rel, abi, auto or no])
4913                 ;;
4914         esac
4915         ],[cf_cv_shlib_version=auto])
4916         AC_MSG_RESULT($cf_cv_shlib_version)
4918         cf_cv_rm_so_locs=no
4920         # Some less-capable ports of gcc support only -fpic
4921         CC_SHARED_OPTS=
4922         if test "$GCC" = yes
4923         then
4924                 AC_MSG_CHECKING(which $CC option to use)
4925                 cf_save_CFLAGS="$CFLAGS"
4926                 for CC_SHARED_OPTS in -fPIC -fpic ''
4927                 do
4928                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
4929                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
4930                 done
4931                 AC_MSG_RESULT($CC_SHARED_OPTS)
4932                 CFLAGS="$cf_save_CFLAGS"
4933         fi
4935         cf_cv_shlib_version_infix=no
4937         case $cf_cv_system_name in #(vi
4938         aix[[56]]*) #(vi
4939                 if test "$GCC" = yes; then
4940                         CC_SHARED_OPTS=
4941                         MK_SHARED_LIB='$(CC) -shared'
4942                 fi
4943                 ;;
4944         beos*) #(vi
4945                 MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
4946                 ;;
4947         cygwin*) #(vi
4948                 CC_SHARED_OPTS=
4949                 MK_SHARED_LIB='sh ../mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
4950                 cf_cv_shlib_version=cygdll
4951                 cf_cv_shlib_version_infix=cygdll
4952                 cat >mk_shared_lib.sh <<-CF_EOF
4953                 #!/bin/sh
4954                 SHARED_LIB=\[$]1
4955                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
4956                 shift
4957                 cat <<-EOF
4958                 Linking shared library
4959                 ** SHARED_LIB \[$]SHARED_LIB
4960                 ** IMPORT_LIB \[$]IMPORT_LIB
4962                 exec \[$]* -shared -Wl,--out-implib=../lib/\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o ../lib/\[$]{SHARED_LIB}
4963 CF_EOF
4964                 chmod +x mk_shared_lib.sh
4965                 ;;
4966         darwin*) #(vi
4967                 EXTRA_CFLAGS="-no-cpp-precomp"
4968                 CC_SHARED_OPTS="-dynamic"
4969                 MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
4970                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
4971                 cf_cv_shlib_version_infix=yes
4972                 AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
4973                         cf_save_LDFLAGS=$LDFLAGS
4974                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4975                         AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
4976                                 LDFLAGS=$cf_save_LDFLAGS])
4977                 if test $cf_cv_ldflags_search_paths_first = yes; then
4978                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
4979                 fi
4980                 ;;
4981         hpux*) #(vi
4982                 # (tested with gcc 2.7.2 -- I don't have c89)
4983                 if test "$GCC" = yes; then
4984                         LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
4985                 else
4986                         CC_SHARED_OPTS='+Z'
4987                         LD_SHARED_OPTS='-Wl,+b,${libdir}'
4988                 fi
4989                 MK_SHARED_LIB='${LD} +b ${libdir} -b -o $[@]'
4990                 # HP-UX shared libraries must be executable, and should be
4991                 # readonly to exploit a quirk in the memory manager.
4992                 INSTALL_LIB="-m 555"
4993                 ;;
4994         irix*) #(vi
4995                 if test "$cf_cv_enable_rpath" = yes ; then
4996                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
4997                 fi
4998                 # tested with IRIX 5.2 and 'cc'.
4999                 if test "$GCC" != yes; then
5000                         CC_SHARED_OPTS='-KPIC'
5001                         MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
5002                 else
5003                         MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
5004                 fi
5005                 cf_cv_rm_so_locs=yes
5006                 ;;
5007         linux*|gnu*|k*bsd*-gnu) #(vi
5008                 if test "$DFT_LWR_MODEL" = "shared" ; then
5009                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
5010                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
5011                 fi
5012                 if test "$cf_cv_enable_rpath" = yes ; then
5013                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
5014                 fi
5015                 CF_SHARED_SONAME
5016                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
5017                 ;;
5018         openbsd[[2-9]].*) #(vi
5019                 if test "$DFT_LWR_MODEL" = "shared" ; then
5020                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
5021                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
5022                 fi
5023                 if test "$cf_cv_enable_rpath" = yes ; then
5024                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
5025                 fi
5026                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
5027                 CF_SHARED_SONAME
5028                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
5029                 ;;
5030         nto-qnx*|openbsd*|freebsd[[12]].*) #(vi
5031                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
5032                 MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
5033                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
5034                 ;;
5035         freebsd*) #(vi
5036                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
5037                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
5038                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
5039                         LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${libdir} $LOCAL_LDFLAGS"
5040                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
5041                 fi
5042                 CF_SHARED_SONAME
5043                 MK_SHARED_LIB='${LD} -shared -Bshareable -soname=`basename $[@]` -o $[@]'
5044                 ;;
5045         netbsd*) #(vi
5046                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
5047                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
5048                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
5049                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
5050                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
5051                         if test "$cf_cv_shlib_version" = auto; then
5052                         if test -f /usr/libexec/ld.elf_so; then
5053                                 cf_cv_shlib_version=abi
5054                         else
5055                                 cf_cv_shlib_version=rel
5056                         fi
5057                         fi
5058                         CF_SHARED_SONAME
5059                         MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
5060                 else
5061                         MK_SHARED_LIB='${LD} -shared -Bshareable -o $[@]'
5062                 fi
5063                 ;;
5064         osf*|mls+*) #(vi
5065                 # tested with OSF/1 V3.2 and 'cc'
5066                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
5067                 # link with shared libs).
5068                 MK_SHARED_LIB='${LD} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
5069                 case $host_os in #(vi
5070                 osf4*)
5071                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
5072                         ;;
5073                 esac
5074                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
5075                 if test "$DFT_LWR_MODEL" = "shared" ; then
5076                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
5077                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
5078                 fi
5079                 cf_cv_rm_so_locs=yes
5080                 ;;
5081         sco3.2v5*)  # (also uw2* and UW7: hops 13-Apr-98
5082                 # tested with osr5.0.5
5083                 if test "$GCC" != yes; then
5084                         CC_SHARED_OPTS='-belf -KPIC'
5085                 fi
5086                 MK_SHARED_LIB='${LD} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
5087                 if test "$cf_cv_enable_rpath" = yes ; then
5088                         # only way is to set LD_RUN_PATH but no switch for it
5089                         RUN_PATH=$libdir
5090                 fi
5091                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
5092                 LINK_PROGS='LD_RUN_PATH=${libdir}'
5093                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
5094                 ;;
5095         sunos4*) #(vi
5096                 # tested with SunOS 4.1.1 and gcc 2.7.0
5097                 if test "$GCC" != yes; then
5098                         CC_SHARED_OPTS='-KPIC'
5099                 fi
5100                 MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
5101                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
5102                 ;;
5103         solaris2*) #(vi
5104                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
5105                 # tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
5106                 if test "$DFT_LWR_MODEL" = "shared" ; then
5107                         LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
5108                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
5109                 fi
5110                 if test "$cf_cv_enable_rpath" = yes ; then
5111                         EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
5112                 fi
5113                 CF_SHARED_SONAME
5114                 if test "$GCC" != yes; then
5115                         cf_save_CFLAGS="$CFLAGS"
5116                         for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
5117                         do
5118                                 CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
5119                                 AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\n");],[break])
5120                         done
5121                         CFLAGS="$cf_save_CFLAGS"
5122                         CC_SHARED_OPTS=$cf_shared_opts
5123                         MK_SHARED_LIB='${CC} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
5124                 else
5125                         MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
5126                 fi
5127                 ;;
5128         sysv5uw7*|unix_sv*) #(vi
5129                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
5130                 if test "$GCC" != yes; then
5131                         CC_SHARED_OPTS='-KPIC'
5132                 fi
5133                 MK_SHARED_LIB='${LD} -d y -G -o [$]@'
5134                 ;;
5135         *)
5136                 CC_SHARED_OPTS='unknown'
5137                 MK_SHARED_LIB='echo unknown'
5138                 ;;
5139         esac
5141         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
5142         case "$cf_cv_shlib_version" in #(vi
5143         rel|abi)
5144                 case "$MK_SHARED_LIB" in #(vi
5145                 *'-o $[@]') #(vi
5146                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
5147                         ;;
5148                 *)
5149                         AC_MSG_WARN(ignored --with-shlib-version)
5150                         ;;
5151                 esac
5152                 ;;
5153         esac
5155         if test -n "$cf_ld_rpath_opt" ; then
5156                 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${libdir}"
5157         fi
5159         AC_SUBST(CC_SHARED_OPTS)
5160         AC_SUBST(LD_RPATH_OPT)
5161         AC_SUBST(LD_SHARED_OPTS)
5162         AC_SUBST(MK_SHARED_LIB)
5163         AC_SUBST(LINK_PROGS)
5164         AC_SUBST(LINK_TESTS)
5165         AC_SUBST(EXTRA_LDFLAGS)
5166         AC_SUBST(LOCAL_LDFLAGS)
5167         AC_SUBST(LOCAL_LDFLAGS2)
5168         AC_SUBST(INSTALL_LIB)
5169 ])dnl
5170 dnl ---------------------------------------------------------------------------
5171 dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
5172 dnl ----------------
5173 dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
5174 dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
5175 dnl option.
5177 dnl $1 is the default that should be used for "$cf_cv_shlib_version".
5178 dnl If missing, use "rel".
5179 define([CF_SHARED_SONAME],
5181         test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
5182         if test "$cf_cv_shlib_version" = rel; then
5183                 cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
5184         else
5185                 cf_cv_shared_soname='`basename $[@]`'
5186         fi
5188 dnl ---------------------------------------------------------------------------
5189 dnl CF_SIGWINCH version: 1 updated: 2006/04/02 16:41:09
5190 dnl -----------
5191 dnl Use this macro after CF_XOPEN_SOURCE, but do not require it (not all
5192 dnl programs need this test).
5194 dnl This is really a MacOS X 10.4.3 workaround.  Defining _POSIX_C_SOURCE
5195 dnl forces SIGWINCH to be undefined (breaks xterm, ncurses).  Oddly, the struct
5196 dnl winsize declaration is left alone - we may revisit this if Apple choose to
5197 dnl break that part of the interface as well.
5198 AC_DEFUN([CF_SIGWINCH],
5200 AC_CACHE_CHECK(if SIGWINCH is defined,cf_cv_define_sigwinch,[
5201         AC_TRY_COMPILE([
5202 #include <sys/types.h>
5203 #include <sys/signal.h>
5204 ],[int x = SIGWINCH],
5205         [cf_cv_define_sigwinch=yes],
5206         [AC_TRY_COMPILE([
5207 #undef _XOPEN_SOURCE
5208 #undef _POSIX_SOURCE
5209 #undef _POSIX_C_SOURCE
5210 #include <sys/types.h>
5211 #include <sys/signal.h>
5212 ],[int x = SIGWINCH],
5213         [cf_cv_define_sigwinch=maybe],
5214         [cf_cv_define_sigwinch=no])
5218 if test "$cf_cv_define_sigwinch" = maybe ; then
5219 AC_CACHE_CHECK(for actual SIGWINCH definition,cf_cv_fixup_sigwinch,[
5220 cf_cv_fixup_sigwinch=unknown
5221 cf_sigwinch=32
5222 while test $cf_sigwinch != 1
5224         AC_TRY_COMPILE([
5225 #undef _XOPEN_SOURCE
5226 #undef _POSIX_SOURCE
5227 #undef _POSIX_C_SOURCE
5228 #include <sys/types.h>
5229 #include <sys/signal.h>
5231 #if SIGWINCH != $cf_sigwinch
5232 make an error
5233 #endif
5234 int x = SIGWINCH],
5235         [cf_cv_fixup_sigwinch=$cf_sigwinch
5236          break])
5238 cf_sigwinch=`expr $cf_sigwinch - 1`
5239 done
5242         if test "$cf_cv_fixup_sigwinch" != unknown ; then
5243                 CPPFLAGS="$CPPFLAGS -DSIGWINCH=$cf_cv_fixup_sigwinch"
5244         fi
5246 ])dnl
5247 dnl ---------------------------------------------------------------------------
5248 dnl CF_SIG_ATOMIC_T version: 2 updated: 2005/09/18 17:27:12
5249 dnl ---------------
5250 dnl signal handler, but there are some gcc depedencies in that recommendation.
5251 dnl Try anyway.
5252 AC_DEFUN([CF_SIG_ATOMIC_T],
5254 AC_MSG_CHECKING(for signal global datatype)
5255 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
5256         for cf_type in \
5257                 "volatile sig_atomic_t" \
5258                 "sig_atomic_t" \
5259                 "int"
5260         do
5261         AC_TRY_COMPILE([
5262 #include <sys/types.h>
5263 #include <signal.h>
5264 #include <stdio.h>
5266 extern $cf_type x;
5267 $cf_type x;
5268 static void handler(int sig)
5270         x = 5;
5272                 [signal(SIGINT, handler);
5273                  x = 1],
5274                 [cf_cv_sig_atomic_t=$cf_type],
5275                 [cf_cv_sig_atomic_t=no])
5276                 test "$cf_cv_sig_atomic_t" != no && break
5277         done
5278         ])
5279 AC_MSG_RESULT($cf_cv_sig_atomic_t)
5280 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[SIG_ATOMIC_T])
5281 ])dnl
5282 dnl ---------------------------------------------------------------------------
5283 dnl CF_SIZECHANGE version: 8 updated: 2000/11/04 12:22:16
5284 dnl -------------
5285 dnl Check for definitions & structures needed for window size-changing
5286 dnl FIXME: check that this works with "snake" (HP-UX 10.x)
5287 AC_DEFUN([CF_SIZECHANGE],
5289 AC_REQUIRE([CF_STRUCT_TERMIOS])
5290 AC_CACHE_CHECK(declaration of size-change, cf_cv_sizechange,[
5291     cf_cv_sizechange=unknown
5292     cf_save_CPPFLAGS="$CPPFLAGS"
5294 for cf_opts in "" "NEED_PTEM_H"
5297     CPPFLAGS="$cf_save_CPPFLAGS"
5298     test -n "$cf_opts" && CPPFLAGS="$CPPFLAGS -D$cf_opts"
5299     AC_TRY_COMPILE([#include <sys/types.h>
5300 #ifdef HAVE_TERMIOS_H
5301 #include <termios.h>
5302 #else
5303 #ifdef HAVE_TERMIO_H
5304 #include <termio.h>
5305 #endif
5306 #endif
5307 #ifdef NEED_PTEM_H
5308 /* This is a workaround for SCO:  they neglected to define struct winsize in
5309  * termios.h -- it's only in termio.h and ptem.h
5310  */
5311 #include        <sys/stream.h>
5312 #include        <sys/ptem.h>
5313 #endif
5314 #if !defined(sun) || !defined(HAVE_TERMIOS_H)
5315 #include <sys/ioctl.h>
5316 #endif
5318 #ifdef TIOCGSIZE
5319         struct ttysize win;     /* FIXME: what system is this? */
5320         int y = win.ts_lines;
5321         int x = win.ts_cols;
5322 #else
5323 #ifdef TIOCGWINSZ
5324         struct winsize win;
5325         int y = win.ws_row;
5326         int x = win.ws_col;
5327 #else
5328         no TIOCGSIZE or TIOCGWINSZ
5329 #endif /* TIOCGWINSZ */
5330 #endif /* TIOCGSIZE */
5331         ],
5332         [cf_cv_sizechange=yes],
5333         [cf_cv_sizechange=no])
5335         CPPFLAGS="$cf_save_CPPFLAGS"
5336         if test "$cf_cv_sizechange" = yes ; then
5337                 echo "size-change succeeded ($cf_opts)" >&AS_MESSAGE_LOG_FD
5338                 test -n "$cf_opts" && cf_cv_sizechange="$cf_opts"
5339                 break
5340         fi
5341 done
5343 if test "$cf_cv_sizechange" != no ; then
5344         AC_DEFINE(HAVE_SIZECHANGE,[1],[HAVE_SIZECHANGE])
5345         case $cf_cv_sizechange in #(vi
5346         NEED*)
5347                 AC_DEFINE_UNQUOTED($cf_cv_sizechange )
5348                 ;;
5349         esac
5351 ])dnl
5352 dnl ---------------------------------------------------------------------------
5353 dnl CF_SRC_MODULES version: 21 updated: 2010/09/04 17:37:40
5354 dnl --------------
5355 dnl For each parameter, test if the source-directory exists, and if it contains
5356 dnl a 'modules' file.  If so, add to the list $cf_cv_src_modules which we'll
5357 dnl use in CF_LIB_RULES.
5359 dnl This uses the configured value to make the lists SRC_SUBDIRS and
5360 dnl SUB_MAKEFILES which are used in the makefile-generation scheme.
5361 AC_DEFUN([CF_SRC_MODULES],
5363 AC_MSG_CHECKING(for src modules)
5365 # dependencies and linker-arguments for test-programs
5366 TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEPS"
5367 TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${LIB_NAME}${DFT_DEP_SUFFIX} $TEST_DEP2"
5368 if test "$DFT_LWR_MODEL" = "libtool"; then
5369         TEST_ARGS="${TEST_DEPS}"
5370         TEST_ARG2="${TEST_DEP2}"
5371 else
5372         TEST_ARGS="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARGS"
5373         TEST_ARG2="-l${LIB_NAME}${DFT_ARG_SUFFIX} $TEST_ARG2"
5376 cf_cv_src_modules=
5377 for cf_dir in $1
5379         if test -f $srcdir/$cf_dir/modules; then
5381                 # We may/may not have tack in the distribution, though the
5382                 # makefile is.
5383                 if test $cf_dir = tack ; then
5384                         if test ! -f $srcdir/${cf_dir}/${cf_dir}.h; then
5385                                 continue
5386                         fi
5387                 fi
5389                 if test -z "$cf_cv_src_modules"; then
5390                         cf_cv_src_modules=$cf_dir
5391                 else
5392                         cf_cv_src_modules="$cf_cv_src_modules $cf_dir"
5393                 fi
5395                 # Make the ncurses_cfg.h file record the library interface files as
5396                 # well.  These are header files that are the same name as their
5397                 # directory.  Ncurses is the only library that does not follow
5398                 # that pattern.
5399                 if test $cf_dir = tack ; then
5400                         continue
5401                 elif test -f $srcdir/${cf_dir}/${cf_dir}.h; then
5402                         CF_UPPER(cf_have_include,$cf_dir)
5403                         AC_DEFINE_UNQUOTED(HAVE_${cf_have_include}_H)
5404                         AC_DEFINE_UNQUOTED(HAVE_LIB${cf_have_include})
5405                         TEST_DEPS="${LIB_DIR}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEPS"
5406                         TEST_DEP2="${LIB_2ND}/${LIB_PREFIX}${cf_dir}${DFT_DEP_SUFFIX} $TEST_DEP2"
5407                         if test "$DFT_LWR_MODEL" = "libtool"; then
5408                                 TEST_ARGS="${TEST_DEPS}"
5409                                 TEST_ARG2="${TEST_DEP2}"
5410                         else
5411                                 TEST_ARGS="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARGS"
5412                                 TEST_ARG2="-l${cf_dir}${DFT_ARG_SUFFIX} $TEST_ARG2"
5413                         fi
5414                 fi
5415         fi
5416 done
5417 AC_MSG_RESULT($cf_cv_src_modules)
5419 TEST_ARGS="-L${LIB_DIR} $TEST_ARGS"
5420 TEST_ARG2="-L${LIB_2ND} $TEST_ARG2"
5422 AC_SUBST(TEST_ARGS)
5423 AC_SUBST(TEST_DEPS)
5425 AC_SUBST(TEST_ARG2)
5426 AC_SUBST(TEST_DEP2)
5428 SRC_SUBDIRS=
5429 if test "x$cf_with_manpages" != xno ; then
5430         SRC_SUBDIRS="$SRC_SUBDIRS man"
5432 SRC_SUBDIRS="$SRC_SUBDIRS include"
5433 for cf_dir in $cf_cv_src_modules
5435         SRC_SUBDIRS="$SRC_SUBDIRS $cf_dir"
5436 done
5437 if test "x$cf_with_tests" != "xno" ; then
5438         SRC_SUBDIRS="$SRC_SUBDIRS test"
5440 test -z "$MAKE_TERMINFO" && SRC_SUBDIRS="$SRC_SUBDIRS misc"
5441 test "$cf_with_cxx_binding" != no && SRC_SUBDIRS="$SRC_SUBDIRS c++"
5443 ADA_SUBDIRS=
5444 if test "$cf_cv_prog_gnat_correct" = yes && test -f $srcdir/Ada95/Makefile.in; then
5445         SRC_SUBDIRS="$SRC_SUBDIRS Ada95"
5446         ADA_SUBDIRS="gen src"
5447         if test "x$cf_with_tests" != "xno" ; then
5448                 ADA_SUBDIRS="$ADA_SUBDIRS samples"
5449         fi
5452 SUB_MAKEFILES=
5453 for cf_dir in $SRC_SUBDIRS
5455         SUB_MAKEFILES="$SUB_MAKEFILES $cf_dir/Makefile"
5456 done
5458 if test -n "$ADA_SUBDIRS"; then
5459         for cf_dir in $ADA_SUBDIRS
5460         do
5461                 SUB_MAKEFILES="$SUB_MAKEFILES Ada95/$cf_dir/Makefile"
5462         done
5463         AC_SUBST(ADA_SUBDIRS)
5465 ])dnl
5466 dnl ---------------------------------------------------------------------------
5467 dnl CF_STDCPP_LIBRARY version: 7 updated: 2010/05/29 16:31:02
5468 dnl -----------------
5469 dnl Check for -lstdc++, which is GNU's standard C++ library.
5470 AC_DEFUN([CF_STDCPP_LIBRARY],
5472 if test -n "$GXX" ; then
5473 case $cf_cv_system_name in #(vi
5474 os2*) #(vi
5475         cf_stdcpp_libname=stdcpp
5476         ;;
5478         cf_stdcpp_libname=stdc++
5479         ;;
5480 esac
5481 AC_CACHE_CHECK(for library $cf_stdcpp_libname,cf_cv_libstdcpp,[
5482         cf_save="$LIBS"
5483         CF_ADD_LIB($cf_stdcpp_libname)
5484 AC_TRY_LINK([
5485 #include <strstream.h>],[
5486 char buf[80];
5487 strstreambuf foo(buf, sizeof(buf))
5489         [cf_cv_libstdcpp=yes],
5490         [cf_cv_libstdcpp=no])
5491         LIBS="$cf_save"
5493 test "$cf_cv_libstdcpp" = yes && CF_ADD_LIB($cf_stdcpp_libname,CXXLIBS)
5495 ])dnl
5496 dnl ---------------------------------------------------------------------------
5497 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
5498 dnl --------------
5499 dnl     Remove "-g" option from the compiler options
5500 AC_DEFUN([CF_STRIP_G_OPT],
5501 [$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
5502 dnl ---------------------------------------------------------------------------
5503 dnl CF_STRUCT_SIGACTION version: 3 updated: 2000/08/12 23:18:52
5504 dnl -------------------
5505 dnl Check if we need _POSIX_SOURCE defined to use struct sigaction.  We'll only
5506 dnl do this if we've found the sigaction function.
5508 dnl If needed, define SVR4_ACTION.
5509 AC_DEFUN([CF_STRUCT_SIGACTION],[
5510 if test "$ac_cv_func_sigaction" = yes; then
5511 AC_MSG_CHECKING(whether sigaction needs _POSIX_SOURCE)
5512 AC_TRY_COMPILE([
5513 #include <sys/types.h>
5514 #include <signal.h>],
5515         [struct sigaction act],
5516         [sigact_bad=no],
5517         [
5518 AC_TRY_COMPILE([
5519 #define _POSIX_SOURCE
5520 #include <sys/types.h>
5521 #include <signal.h>],
5522         [struct sigaction act],
5523         [sigact_bad=yes
5524          AC_DEFINE(SVR4_ACTION,[],[SRV4_ACTION])],
5525          [sigact_bad=unknown])])
5526 AC_MSG_RESULT($sigact_bad)
5528 ])dnl
5529 dnl ---------------------------------------------------------------------------
5530 dnl CF_STRUCT_TERMIOS version: 5 updated: 2000/11/04 12:22:46
5531 dnl -----------------
5532 dnl Some machines require _POSIX_SOURCE to completely define struct termios.
5533 dnl If so, define SVR4_TERMIO
5534 AC_DEFUN([CF_STRUCT_TERMIOS],[
5535 AC_CHECK_HEADERS( \
5536 termio.h \
5537 termios.h \
5538 unistd.h \
5540 if test "$ISC" = yes ; then
5541         AC_CHECK_HEADERS( sys/termio.h )
5543 if test "$ac_cv_header_termios_h" = yes ; then
5544         case "$CFLAGS $CPPFLAGS" in
5545         *-D_POSIX_SOURCE*)
5546                 termios_bad=dunno ;;
5547         *)      termios_bad=maybe ;;
5548         esac
5549         if test "$termios_bad" = maybe ; then
5550         AC_MSG_CHECKING(whether termios.h needs _POSIX_SOURCE)
5551         AC_TRY_COMPILE([#include <termios.h>],
5552                 [struct termios foo; int x = foo.c_iflag],
5553                 termios_bad=no, [
5554                 AC_TRY_COMPILE([
5555 #define _POSIX_SOURCE
5556 #include <termios.h>],
5557                         [struct termios foo; int x = foo.c_iflag],
5558                         termios_bad=unknown,
5559                         termios_bad=yes AC_DEFINE(SVR4_TERMIO,[],[SRV4_TERMIO]))
5560                         ])
5561         AC_MSG_RESULT($termios_bad)
5562         fi
5564 ])dnl
5565 dnl ---------------------------------------------------------------------------
5566 dnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
5567 dnl --------------
5568 dnl Construct a search-list for a nonstandard header/lib-file
5569 dnl     $1 = the variable to return as result
5570 dnl     $2 = the package name
5571 dnl     $3 = the subdirectory, e.g., bin, include or lib
5572 AC_DEFUN([CF_SUBDIR_PATH],
5576 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
5577 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
5578 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
5579 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
5580 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
5581 ])dnl
5582 dnl ---------------------------------------------------------------------------
5583 dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
5584 dnl --------
5585 dnl     Shorthand macro for substituting things that the user may override
5586 dnl     with an environment variable.
5588 dnl     $1 = long/descriptive name
5589 dnl     $2 = environment variable
5590 dnl     $3 = default value
5591 AC_DEFUN([CF_SUBST],
5592 [AC_CACHE_VAL(cf_cv_subst_$2,[
5593 AC_MSG_CHECKING(for $1 (symbol $2))
5594 CF_SUBST_IF([-z "[$]$2"], [$2], [$3])
5595 cf_cv_subst_$2=[$]$2
5596 AC_MSG_RESULT([$]$2)
5598 ])dnl
5599 dnl ---------------------------------------------------------------------------
5600 dnl CF_SUBST_IF version: 2 updated: 2006/06/17 12:33:03
5601 dnl -----------
5602 dnl     Shorthand macro for substituting things that the user may override
5603 dnl     with an environment variable.
5605 dnl     $1 = condition to pass to "test"
5606 dnl     $2 = environment variable
5607 dnl     $3 = value if the test succeeds
5608 dnl     $4 = value if the test fails
5609 AC_DEFUN([CF_SUBST_IF],
5611 if test $1 ; then
5612         $2=$3
5613 ifelse($4,,,[else
5614         $2=$4])
5616 AC_SUBST($2)
5617 ])dnl
5618 dnl ---------------------------------------------------------------------------
5619 dnl CF_SUBST_NCURSES_VERSION version: 8 updated: 2006/09/16 11:40:59
5620 dnl ------------------------
5621 dnl Get the version-number for use in shared-library naming, etc.
5622 AC_DEFUN([CF_SUBST_NCURSES_VERSION],
5624 AC_REQUIRE([CF_PROG_EGREP])
5625 NCURSES_MAJOR="`$ac_cv_prog_egrep '^NCURSES_MAJOR[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
5626 NCURSES_MINOR="`$ac_cv_prog_egrep '^NCURSES_MINOR[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
5627 NCURSES_PATCH="`$ac_cv_prog_egrep '^NCURSES_PATCH[[     ]]*=' $srcdir/dist.mk | sed -e 's/^[[^0-9]]*//'`"
5628 cf_cv_abi_version=${NCURSES_MAJOR}
5629 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
5630 dnl Show the computed version, for logging
5631 cf_cv_timestamp=`date`
5632 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
5633 dnl We need these values in the generated headers
5634 AC_SUBST(NCURSES_MAJOR)
5635 AC_SUBST(NCURSES_MINOR)
5636 AC_SUBST(NCURSES_PATCH)
5637 dnl We need these values in the generated makefiles
5638 AC_SUBST(cf_cv_rel_version)
5639 AC_SUBST(cf_cv_abi_version)
5640 AC_SUBST(cf_cv_builtin_bool)
5641 AC_SUBST(cf_cv_header_stdbool_h)
5642 AC_SUBST(cf_cv_type_of_bool)dnl
5643 ])dnl
5644 dnl ---------------------------------------------------------------------------
5645 dnl CF_SYS_TIME_SELECT version: 4 updated: 2000/10/04 09:18:40
5646 dnl ------------------
5647 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
5648 dnl older SCO configurations.
5649 AC_DEFUN([CF_SYS_TIME_SELECT],
5651 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
5652 AC_CACHE_VAL(cf_cv_sys_time_select,[
5653 AC_TRY_COMPILE([
5654 #include <sys/types.h>
5655 #ifdef HAVE_SYS_TIME_H
5656 #include <sys/time.h>
5657 #endif
5658 #ifdef HAVE_SYS_SELECT_H
5659 #include <sys/select.h>
5660 #endif
5661 ],[],[cf_cv_sys_time_select=yes],
5662      [cf_cv_sys_time_select=no])
5663      ])
5664 AC_MSG_RESULT($cf_cv_sys_time_select)
5665 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT,[],[HAVE_SYS_TIME_SELECT])
5666 ])dnl
5667 dnl ---------------------------------------------------------------------------
5668 dnl CF_TOP_BUILDDIR version: 1 updated: 2006/10/15 16:33:23
5669 dnl ---------------
5670 dnl Define a top_builddir symbol, for applications that need an absolute path.
5671 AC_DEFUN([CF_TOP_BUILDDIR],
5673 top_builddir=`pwd`
5674 AC_SUBST(top_builddir)
5675 ])dnl
5676 dnl ---------------------------------------------------------------------------
5677 dnl CF_TYPEOF_CHTYPE version: 8 updated: 2006/12/16 12:33:30
5678 dnl ----------------
5679 dnl Determine the type we should use for chtype (and attr_t, which is treated
5680 dnl as the same thing).  We want around 32 bits, so on most machines want a
5681 dnl long, but on newer 64-bit machines, probably want an int.  If we're using
5682 dnl wide characters, we have to have a type compatible with that, as well.
5683 AC_DEFUN([CF_TYPEOF_CHTYPE],
5685 AC_MSG_CHECKING([for type of chtype])
5686 AC_CACHE_VAL(cf_cv_typeof_chtype,[
5687                 AC_TRY_RUN([
5688 #define WANT_BITS 31
5689 #include <stdio.h>
5690 int main()
5692         FILE *fp = fopen("cf_test.out", "w");
5693         if (fp != 0) {
5694                 char *result = "long";
5695                 if (sizeof(unsigned long) > sizeof(unsigned int)) {
5696                         int n;
5697                         unsigned int x, y;
5698                         for (n = 0; n < WANT_BITS; n++) {
5699                                 x = (1 << n);
5700                                 y = (x >> n);
5701                                 if (y != 1 || x == 0) {
5702                                         x = 0;
5703                                         break;
5704                                 }
5705                         }
5706                         /*
5707                          * If x is nonzero, an int is big enough for the bits
5708                          * that we want.
5709                          */
5710                         result = (x != 0) ? "int" : "long";
5711                 }
5712                 fputs(result, fp);
5713                 fclose(fp);
5714         }
5715         ${cf_cv_main_return:-return}(0);
5717                 ],
5718                 [cf_cv_typeof_chtype=`cat cf_test.out`],
5719                 [cf_cv_typeof_chtype=long],
5720                 [cf_cv_typeof_chtype=long])
5721                 rm -f cf_test.out
5722         ])
5723 AC_MSG_RESULT($cf_cv_typeof_chtype)
5725 AC_SUBST(cf_cv_typeof_chtype)
5726 AC_DEFINE_UNQUOTED(TYPEOF_CHTYPE,$cf_cv_typeof_chtype,[TYPEOF_CHTYPE])
5727 ])dnl
5728 dnl ---------------------------------------------------------------------------
5729 dnl CF_TYPE_SIGACTION version: 3 updated: 2000/08/12 23:18:52
5730 dnl -----------------
5732 AC_DEFUN([CF_TYPE_SIGACTION],
5734 AC_MSG_CHECKING([for type sigaction_t])
5735 AC_CACHE_VAL(cf_cv_type_sigaction,[
5736         AC_TRY_COMPILE([
5737 #include <signal.h>],
5738                 [sigaction_t x],
5739                 [cf_cv_type_sigaction=yes],
5740                 [cf_cv_type_sigaction=no])])
5741 AC_MSG_RESULT($cf_cv_type_sigaction)
5742 test "$cf_cv_type_sigaction" = yes && AC_DEFINE(HAVE_TYPE_SIGACTION,[],[HAVE_TYPE_SIGACTION])
5743 ])dnl
5744 dnl ---------------------------------------------------------------------------
5745 dnl CF_UNSIGNED_LITERALS version: 2 updated: 1998/02/07 22:10:16
5746 dnl --------------------
5747 dnl Test if the compiler supports 'U' and 'L' suffixes.  Only old compilers
5748 dnl won't, but they're still there.
5749 AC_DEFUN([CF_UNSIGNED_LITERALS],
5751 AC_MSG_CHECKING([if unsigned literals are legal])
5752 AC_CACHE_VAL(cf_cv_unsigned_literals,[
5753         AC_TRY_COMPILE([],[long x = 1L + 1UL + 1U + 1],
5754                 [cf_cv_unsigned_literals=yes],
5755                 [cf_cv_unsigned_literals=no])
5756         ])
5757 AC_MSG_RESULT($cf_cv_unsigned_literals)
5758 ])dnl
5759 dnl ---------------------------------------------------------------------------
5760 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
5761 dnl --------
5762 dnl Make an uppercase version of a variable
5763 dnl $1=uppercase($2)
5764 AC_DEFUN([CF_UPPER],
5766 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
5767 ])dnl
5768 dnl ---------------------------------------------------------------------------
5769 dnl CF_UTF8_LIB version: 7 updated: 2010/06/20 09:24:28
5770 dnl -----------
5771 dnl Check for multibyte support, and if not found, utf8 compatibility library
5772 AC_DEFUN([CF_UTF8_LIB],
5774 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
5775         cf_save_LIBS="$LIBS"
5776         AC_TRY_LINK([
5777 #include <stdlib.h>],[putwc(0,0);],
5778         [cf_cv_utf8_lib=yes],
5779         [CF_FIND_LINKAGE([
5780 #include <libutf8.h>],[putwc(0,0);],utf8,
5781                 [cf_cv_utf8_lib=add-on],
5782                 [cf_cv_utf8_lib=no])
5783 ])])
5785 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
5786 # ncurses/ncursesw:
5787 if test "$cf_cv_utf8_lib" = "add-on" ; then
5788         AC_DEFINE(HAVE_LIBUTF8_H,[],[Have libutf8.h])
5789         CF_ADD_INCDIR($cf_cv_header_path_utf8)
5790         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
5791         CF_ADD_LIBS($cf_cv_library_file_utf8)
5793 ])dnl
5794 dnl ---------------------------------------------------------------------------
5795 dnl CF_VA_COPY version: 2 updated: 2010/03/04 05:37:29
5796 dnl ----------
5797 dnl check for va_copy, part of stdarg.h
5798 dnl Also, workaround for glibc's __va_copy, by checking for both.
5799 AC_DEFUN([CF_VA_COPY],[
5800 AC_CACHE_CHECK(for va_copy, cf_cv_have_va_copy,[
5801 AC_TRY_LINK([
5802 #include <stdarg.h>
5804         static va_list dst;
5805         static va_list src;
5806         va_copy(dst, src)],
5807         cf_cv_have_va_copy=yes,
5808         cf_cv_have_va_copy=no)])
5810 test "$cf_cv_have_va_copy" = yes && AC_DEFINE(HAVE_VA_COPY)
5812 AC_CACHE_CHECK(for __va_copy, cf_cv_have___va_copy,[
5813 AC_TRY_LINK([
5814 #include <stdarg.h>
5816         static va_list dst;
5817         static va_list src;
5818         __va_copy(dst, src)],
5819         cf_cv_have___va_copy=yes,
5820         cf_cv_have___va_copy=no)])
5822 test "$cf_cv_have___va_copy" = yes && AC_DEFINE(HAVE___VA_COPY)
5824 dnl ---------------------------------------------------------------------------
5825 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
5826 dnl ----------
5827 dnl Use AC_VERBOSE w/o the warnings
5828 AC_DEFUN([CF_VERBOSE],
5829 [test -n "$verbose" && echo "   $1" 1>&AS_MESSAGE_FD
5830 CF_MSG_LOG([$1])
5831 ])dnl
5832 dnl ---------------------------------------------------------------------------
5833 dnl CF_WCHAR_TYPE version: 3 updated: 2010/05/26 16:44:57
5834 dnl -------------
5835 dnl Check if type wide-character type $1 is declared, and if so, which header
5836 dnl file is needed.  The second parameter is used to set a shell variable when
5837 dnl the type is not found.  The first parameter sets a shell variable for the
5838 dnl opposite sense.
5839 AC_DEFUN([CF_WCHAR_TYPE],
5841 # This is needed on Tru64 5.0 to declare $1
5842 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
5843 AC_TRY_COMPILE([
5844 #include <stdlib.h>
5845 #include <stdarg.h>
5846 #include <stdio.h>
5847 #ifdef HAVE_LIBUTF8_H
5848 #include <libutf8.h>
5849 #endif],
5850         [$1 state],
5851         [cf_cv_$1=no],
5852         [AC_TRY_COMPILE([
5853 #include <stdlib.h>
5854 #include <stdarg.h>
5855 #include <stdio.h>
5856 #include <wchar.h>
5857 #ifdef HAVE_LIBUTF8_H
5858 #include <libutf8.h>
5859 #endif],
5860         [$1 value],
5861         [cf_cv_$1=yes],
5862         [cf_cv_$1=unknown])])])
5864 if test "$cf_cv_$1" = yes ; then
5865         AC_DEFINE(NEED_WCHAR_H,[],[NEED_WCHAR_H])
5866         NEED_WCHAR_H=1
5869 ifelse([$2],,,[
5870 # if we do not find $1 in either place, use substitution to provide a fallback.
5871 if test "$cf_cv_$1" = unknown ; then
5872         $2=1
5875 ifelse($3,,,[
5876 # if we find $1 in either place, use substitution to provide a fallback.
5877 if test "$cf_cv_$1" != unknown ; then
5878         $3=1
5881 ])dnl
5882 dnl ---------------------------------------------------------------------------
5883 dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
5884 dnl ---------------
5885 dnl Check for compiler-support for weak symbols.
5886 dnl This works with "recent" gcc.
5887 AC_DEFUN([CF_WEAK_SYMBOLS],[
5888 AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
5890 AC_TRY_COMPILE([
5891 #include <stdio.h>],
5893 #if defined(__GNUC__)
5894 #  if defined __USE_ISOC99
5895 #    define _cat_pragma(exp)    _Pragma(#exp)
5896 #    define _weak_pragma(exp)   _cat_pragma(weak name)
5897 #  else
5898 #    define _weak_pragma(exp)
5899 #  endif
5900 #  define _declare(name)        __extension__ extern __typeof__(name) name
5901 #  define weak_symbol(name)     _weak_pragma(name) _declare(name) __attribute__((weak))
5902 #endif
5904 weak_symbol(fopen);
5905 ],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
5907 ])dnl
5908 dnl ---------------------------------------------------------------------------
5909 dnl CF_WITH_ABI_VERSION version: 1 updated: 2003/09/20 18:12:49
5910 dnl -------------------
5911 dnl Allow library's ABI to be overridden.  Generally this happens when a
5912 dnl packager has incremented the ABI past that used in the original package,
5913 dnl and wishes to keep doing this.
5915 dnl $1 is the package name, if any, to derive a corresponding {package}_ABI
5916 dnl symbol.
5917 AC_DEFUN([CF_WITH_ABI_VERSION],[
5918 test -z "$cf_cv_abi_version" && cf_cv_abi_version=0
5919 AC_ARG_WITH(abi-version,
5920 [  --with-abi-version=XXX  override derived ABI version],
5921 [AC_MSG_WARN(overriding ABI version $cf_cv_abi_version to $withval)
5922  cf_cv_abi_version=$withval])
5923  CF_NUMBER_SYNTAX($cf_cv_abi_version,ABI version)
5924 ifelse($1,,,[
5925 $1_ABI=$cf_cv_abi_version
5927 ])dnl
5928 dnl ---------------------------------------------------------------------------
5929 dnl CF_WITH_ADA_COMPILER version: 2 updated: 2010/06/26 17:35:58
5930 dnl --------------------
5931 dnl Command-line option to specify the Ada95 compiler.
5932 AC_DEFUN([CF_WITH_ADA_COMPILER],[
5933 AC_MSG_CHECKING(for ada-compiler)
5934 AC_ARG_WITH(ada-compiler,
5935         [  --with-ada-compiler=CMD specify Ada95 compiler command (default gnatmake)],
5936         [cf_ada_compiler=$withval],
5937         [cf_ada_compiler=gnatmake])
5938 AC_SUBST(cf_ada_compiler)
5939 AC_MSG_RESULT($cf_ada_compiler)
5940 ])dnl
5941 dnl ---------------------------------------------------------------------------
5942 dnl CF_WITH_ADA_INCLUDE version: 2 updated: 2010/06/26 17:35:58
5943 dnl -------------------
5944 dnl Command-line option to specify where Ada includes will install.
5945 AC_DEFUN([CF_WITH_ADA_INCLUDE],[
5946 AC_MSG_CHECKING(for ada-include)
5947 CF_WITH_PATH(ada-include,
5948    [  --with-ada-include=DIR  Ada includes are in DIR],
5949    ADA_INCLUDE,
5950    PREFIX/share/ada/adainclude,
5951    [$]prefix/share/ada/adainclude)
5952 AC_SUBST(ADA_INCLUDE)
5953 AC_MSG_RESULT($ADA_INCLUDE)
5954 ])dnl
5955 dnl ---------------------------------------------------------------------------
5956 dnl CF_WITH_ADA_OBJECTS version: 2 updated: 2010/06/26 17:35:58
5957 dnl -------------------
5958 dnl Command-line option to specify where Ada objects will install.
5959 AC_DEFUN([CF_WITH_ADA_OBJECTS],[
5960 AC_MSG_CHECKING(for ada-objects)
5961 CF_WITH_PATH(ada-objects,
5962    [  --with-ada-objects=DIR  Ada objects are in DIR],
5963    ADA_OBJECTS,
5964    PREFIX/lib/ada/adalib,
5965    [$]prefix/lib/ada/adalib)
5966 AC_SUBST(ADA_OBJECTS)
5967 AC_MSG_RESULT($ADA_OBJECTS)
5968 ])dnl
5969 dnl ---------------------------------------------------------------------------
5970 dnl CF_WITH_ADA_SHAREDLIB version: 2 updated: 2010/06/26 17:35:58
5971 dnl ---------------------
5972 dnl Command-line option to specify if an Ada95 shared-library should be built,
5973 dnl and optionally what its soname should be.
5974 AC_DEFUN([CF_WITH_ADA_SHAREDLIB],[
5975 AC_MSG_CHECKING(if an Ada95 shared-library should be built)
5976 AC_ARG_WITH(ada-sharedlib,
5977         [  --with-ada-sharedlib=XX build Ada95 shared-library],
5978         [with_ada_sharedlib=$withval],
5979         [with_ada_sharedlib=no])
5980 AC_MSG_RESULT($with_ada_sharedlib)
5982 ADA_SHAREDLIB='lib$(LIB_NAME).so.1'
5983 MAKE_ADA_SHAREDLIB="#"
5985 if test "x$with_ada_sharedlib" != xno
5986 then
5987         MAKE_ADA_SHAREDLIB=
5988         if test "x$with_ada_sharedlib" != xyes
5989         then
5990                 ADA_SHAREDLIB="$with_ada_sharedlib"
5991         fi
5994 AC_SUBST(ADA_SHAREDLIB)
5995 AC_SUBST(MAKE_ADA_SHAREDLIB)
5996 ])dnl
5997 dnl ---------------------------------------------------------------------------
5998 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
5999 dnl ----------------
6000 dnl Configure-option for dbmalloc.  The optional parameter is used to override
6001 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
6002 AC_DEFUN([CF_WITH_DBMALLOC],[
6003 CF_NO_LEAKS_OPTION(dbmalloc,
6004         [  --with-dbmalloc         test: use Conor Cahill's dbmalloc library],
6005         [USE_DBMALLOC])
6007 if test "$with_dbmalloc" = yes ; then
6008         AC_CHECK_HEADER(dbmalloc.h,
6009                 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
6011 ])dnl
6012 dnl ---------------------------------------------------------------------------
6013 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
6014 dnl ---------------
6015 dnl Configure-option for dmalloc.  The optional parameter is used to override
6016 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
6017 AC_DEFUN([CF_WITH_DMALLOC],[
6018 CF_NO_LEAKS_OPTION(dmalloc,
6019         [  --with-dmalloc          test: use Gray Watson's dmalloc library],
6020         [USE_DMALLOC])
6022 if test "$with_dmalloc" = yes ; then
6023         AC_CHECK_HEADER(dmalloc.h,
6024                 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
6026 ])dnl
6027 dnl ---------------------------------------------------------------------------
6028 dnl CF_WITH_GPM version: 7 updated: 2008/03/23 14:48:54
6029 dnl -----------
6031 dnl The option parameter (if neither yes/no) is assumed to be the name of
6032 dnl the gpm library, e.g., for dynamic loading.
6033 AC_DEFUN([CF_WITH_GPM],
6035 AC_MSG_CHECKING(if you want to link with the GPM mouse library)
6036 AC_ARG_WITH(gpm,
6037         [  --with-gpm              use Alessandro Rubini's GPM library],
6038         [with_gpm=$withval],
6039         [with_gpm=maybe])
6040 AC_MSG_RESULT($with_gpm)
6042 if test "$with_gpm" != no ; then
6043         AC_CHECK_HEADER(gpm.h,[
6044                 AC_DEFINE([HAVE_GPM_H],[],[HAVE_GPM_H])
6045                 if test "$with_gpm" != yes && test "$with_gpm" != maybe ; then
6046                         CF_VERBOSE(assuming we really have GPM library)
6047                         AC_DEFINE(HAVE_LIBGPM,[],[HAVE_LIBGPM])
6048                 else
6049                         AC_CHECK_LIB(gpm,Gpm_Open,[:],[
6050                                 AC_MSG_ERROR(Cannot link with GPM library)
6051                 fi
6052                 with_gpm=yes
6053                 ])
6054         ],[
6055                 test "$with_gpm" != maybe && AC_MSG_WARN(Cannot find GPM header)
6056                 with_gpm=no
6057         ])
6060 dnl ---------------------------------------------------------------------------
6061 dnl CF_WITH_LIBTOOL version: 26 updated: 2010/10/23 15:55:24
6062 dnl ---------------
6063 dnl Provide a configure option to incorporate libtool.  Define several useful
6064 dnl symbols for the makefile rules.
6066 dnl The reference to AC_PROG_LIBTOOL does not normally work, since it uses
6067 dnl macros from libtool.m4 which is in the aclocal directory of automake.
6068 dnl Following is a simple script which turns on the AC_PROG_LIBTOOL macro.
6069 dnl But that still does not work properly since the macro is expanded outside
6070 dnl the CF_WITH_LIBTOOL macro:
6072 dnl     #!/bin/sh
6073 dnl     ACLOCAL=`aclocal --print-ac-dir`
6074 dnl     if test -z "$ACLOCAL" ; then
6075 dnl             echo cannot find aclocal directory
6076 dnl             exit 1
6077 dnl     elif test ! -f $ACLOCAL/libtool.m4 ; then
6078 dnl             echo cannot find libtool.m4 file
6079 dnl             exit 1
6080 dnl     fi
6082 dnl     LOCAL=aclocal.m4
6083 dnl     ORIG=aclocal.m4.orig
6085 dnl     trap "mv $ORIG $LOCAL" 0 1 2 5 15
6086 dnl     rm -f $ORIG
6087 dnl     mv $LOCAL $ORIG
6089 dnl     # sed the LIBTOOL= assignment to omit the current directory?
6090 dnl     sed -e 's/^LIBTOOL=.*/LIBTOOL=${LIBTOOL:-libtool}/' $ACLOCAL/libtool.m4 >>$LOCAL
6091 dnl     cat $ORIG >>$LOCAL
6093 dnl     autoconf-257 $*
6095 AC_DEFUN([CF_WITH_LIBTOOL],
6097 AC_REQUIRE([CF_DISABLE_LIBTOOL_VERSION])
6098 ifdef([AC_PROG_LIBTOOL],,[
6099 LIBTOOL=
6101 # common library maintenance symbols that are convenient for libtool scripts:
6102 LIB_CREATE='${AR} -cr'
6103 LIB_OBJECT='${OBJECTS}'
6104 LIB_SUFFIX=.a
6105 LIB_PREP="$RANLIB"
6107 # symbols used to prop libtool up to enable it to determine what it should be
6108 # doing:
6109 LIB_CLEAN=
6110 LIB_COMPILE=
6111 LIB_LINK='${CC}'
6112 LIB_INSTALL=
6113 LIB_UNINSTALL=
6115 AC_MSG_CHECKING(if you want to build libraries with libtool)
6116 AC_ARG_WITH(libtool,
6117         [  --with-libtool          generate libraries with libtool],
6118         [with_libtool=$withval],
6119         [with_libtool=no])
6120 AC_MSG_RESULT($with_libtool)
6121 if test "$with_libtool" != "no"; then
6122 ifdef([AC_PROG_LIBTOOL],[
6123         # missing_content_AC_PROG_LIBTOOL{{
6124         AC_PROG_LIBTOOL
6125         # missing_content_AC_PROG_LIBTOOL}}
6127         if test "$with_libtool" != "yes" ; then
6128                 CF_PATH_SYNTAX(with_libtool)
6129                 LIBTOOL=$with_libtool
6130         else
6131                 AC_PATH_PROG(LIBTOOL,libtool)
6132         fi
6133         if test -z "$LIBTOOL" ; then
6134                 AC_MSG_ERROR(Cannot find libtool)
6135         fi
6136 ])dnl
6137         LIB_CREATE='${LIBTOOL} --mode=link ${CC} -rpath ${DESTDIR}${libdir} ${LIBTOOL_VERSION} `cut -f1 ${srcdir}/VERSION` ${LIBTOOL_OPTS} ${LT_UNDEF} -o'
6138         LIB_OBJECT='${OBJECTS:.o=.lo}'
6139         LIB_SUFFIX=.la
6140         LIB_CLEAN='${LIBTOOL} --mode=clean'
6141         LIB_COMPILE='${LIBTOOL} --mode=compile'
6142         LIB_LINK='${LIBTOOL} --mode=link ${CC} ${LIBTOOL_OPTS}'
6143         LIB_INSTALL='${LIBTOOL} --mode=install'
6144         LIB_UNINSTALL='${LIBTOOL} --mode=uninstall'
6145         LIB_PREP=:
6147         # Show the version of libtool
6148         AC_MSG_CHECKING(version of libtool)
6150         # Save the version in a cache variable - this is not entirely a good
6151         # thing, but the version string from libtool is very ugly, and for
6152         # bug reports it might be useful to have the original string. "("
6153         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.]].*//'`
6154         AC_MSG_RESULT($cf_cv_libtool_version)
6155         if test -z "$cf_cv_libtool_version" ; then
6156                 AC_MSG_ERROR(This is not GNU libtool)
6157         fi
6159         # special hack to add -no-undefined (which libtool should do for itself)
6160         LT_UNDEF=
6161         case "$cf_cv_system_name" in #(vi
6162         cygwin*|mingw32*|uwin*|aix[[456]]) #(vi
6163                 LT_UNDEF=-no-undefined
6164                 ;;
6165         esac
6166         AC_SUBST([LT_UNDEF])
6168         # special hack to add --tag option for C++ compiler
6169         case $cf_cv_libtool_version in #(vi
6170         1.[[5-9]]*|[[2-9]].[[0-9.a-z]]*) #(vi
6171                 LIBTOOL_CXX="$LIBTOOL --tag=CXX"
6172                 LIBTOOL="$LIBTOOL --tag=CC"
6173                 ;;
6174         *)
6175                 LIBTOOL_CXX="$LIBTOOL"
6176                 ;;
6177         esac
6178 else
6179         LIBTOOL=""
6180         LIBTOOL_CXX=""
6183 test -z "$LIBTOOL" && ECHO_LT=
6185 AC_SUBST(LIBTOOL)
6186 AC_SUBST(LIBTOOL_CXX)
6187 AC_SUBST(LIBTOOL_OPTS)
6189 AC_SUBST(LIB_CREATE)
6190 AC_SUBST(LIB_OBJECT)
6191 AC_SUBST(LIB_SUFFIX)
6192 AC_SUBST(LIB_PREP)
6194 AC_SUBST(LIB_CLEAN)
6195 AC_SUBST(LIB_COMPILE)
6196 AC_SUBST(LIB_LINK)
6197 AC_SUBST(LIB_INSTALL)
6198 AC_SUBST(LIB_UNINSTALL)
6200 ])dnl
6201 dnl ---------------------------------------------------------------------------
6202 dnl CF_WITH_PATH version: 10 updated: 2010/10/23 15:44:18
6203 dnl ------------
6204 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
6205 dnl defaulting to yes/no.
6207 dnl $1 = option name
6208 dnl $2 = help-text
6209 dnl $3 = environment variable to set
6210 dnl $4 = default value, shown in the help-message, must be a constant
6211 dnl $5 = default value, if it's an expression & cannot be in the help-message
6213 AC_DEFUN([CF_WITH_PATH],
6214 [AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
6215 ifelse([$4],,[withval="${$3}"],[withval="${$3:-ifelse([$5],,[$4],[$5])}"]))dnl
6216 if ifelse([$5],,true,[test -n "$5"]) ; then
6217 CF_PATH_SYNTAX(withval)
6219 $3="$withval"
6220 AC_SUBST($3)dnl
6221 ])dnl
6222 dnl ---------------------------------------------------------------------------
6223 dnl CF_WITH_PATHLIST version: 7 updated: 2010/10/23 16:10:30
6224 dnl ----------------
6225 dnl Process an option specifying a list of colon-separated paths.
6227 dnl $1 = option name
6228 dnl $2 = help-text
6229 dnl $3 = environment variable to set
6230 dnl $4 = default value, shown in the help-message, must be a constant
6231 dnl $5 = default value, if it's an expression & cannot be in the help-message
6232 dnl $6 = flag to tell if we want to define or substitute
6234 AC_DEFUN([CF_WITH_PATHLIST],[
6235 AC_REQUIRE([CF_PATHSEP])
6236 AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),,
6237 ifelse($4,,[withval=${$3}],[withval=${$3:-ifelse($5,,$4,$5)}]))dnl
6239 IFS="${IFS:-    }"; ac_save_ifs="$IFS"; IFS="${PATH_SEPARATOR}"
6240 cf_dst_path=
6241 for cf_src_path in $withval
6243   CF_PATH_SYNTAX(cf_src_path)
6244   test -n "$cf_dst_path" && cf_dst_path="${cf_dst_path}:"
6245   cf_dst_path="${cf_dst_path}${cf_src_path}"
6246 done
6247 IFS="$ac_save_ifs"
6249 ifelse($6,define,[
6250 # Strip single quotes from the value, e.g., when it was supplied as a literal
6251 # for $4 or $5.
6252 case $cf_dst_path in #(vi
6253 \'*)
6254   cf_dst_path=`echo $cf_dst_path |sed -e s/\'// -e s/\'\$//`
6255   ;;
6256 esac
6257 cf_dst_path=`echo "$cf_dst_path" | sed -e 's/\\\\/\\\\\\\\/g'`
6260 eval '$3="$cf_dst_path"'
6261 AC_SUBST($3)dnl
6263 ])dnl
6264 dnl ---------------------------------------------------------------------------
6265 dnl CF_WITH_PTHREAD version: 3 updated: 2010/05/29 16:31:02
6266 dnl ---------------
6267 dnl Check for POSIX thread library.
6268 AC_DEFUN([CF_WITH_PTHREAD],
6270 AC_MSG_CHECKING(if you want to link with the pthread library)
6271 AC_ARG_WITH(pthread,
6272     [  --with-pthread          use POSIX thread library],
6273     [with_pthread=$withval],
6274     [with_pthread=no])
6275 AC_MSG_RESULT($with_pthread)
6277 if test "$with_pthread" != no ; then
6278     AC_CHECK_HEADER(pthread.h,[
6279         AC_DEFINE(HAVE_PTHREADS_H,[],[Define if we have pthreads.h])
6281         AC_MSG_CHECKING(if we can link with the pthread library)
6282         cf_save_LIBS="$LIBS"
6283         CF_ADD_LIB(pthread)
6284         AC_TRY_LINK([
6285 #include <pthread.h>
6287         int rc = pthread_create(0,0,0,0);
6288 ],[with_pthread=yes],[with_pthread=no])
6289         LIBS="$cf_save_LIBS"
6290         AC_MSG_RESULT($with_pthread)
6292         if test "$with_pthread" = yes ; then
6293             CF_ADD_LIB(pthread)
6294             AC_DEFINE(HAVE_LIBPTHREADS,[],[Define if we have libpthreads])
6295         else
6296             AC_MSG_ERROR(Cannot link with pthread library)
6297         fi
6298     ])
6301 dnl ---------------------------------------------------------------------------
6302 dnl CF_WITH_REL_VERSION version: 1 updated: 2003/09/20 18:12:49
6303 dnl -------------------
6304 dnl Allow library's release-version to be overridden.  Generally this happens when a
6305 dnl packager has incremented the release-version past that used in the original package,
6306 dnl and wishes to keep doing this.
6308 dnl $1 is the package name, if any, to derive corresponding {package}_MAJOR
6309 dnl and {package}_MINOR symbols
6310 dnl symbol.
6311 AC_DEFUN([CF_WITH_REL_VERSION],[
6312 test -z "$cf_cv_rel_version" && cf_cv_rel_version=0.0
6313 AC_ARG_WITH(rel-version,
6314 [  --with-rel-version=XXX  override derived release version],
6315 [AC_MSG_WARN(overriding release version $cf_cv_rel_version to $withval)
6316  cf_cv_rel_version=$withval])
6317 ifelse($1,,[
6318  CF_NUMBER_SYNTAX($cf_cv_rel_version,Release version)
6320  $1_MAJOR=`echo "$cf_cv_rel_version" | sed -e 's/\..*//'`
6321  $1_MINOR=`echo "$cf_cv_rel_version" | sed -e 's/^[[^.]]*//' -e 's/^\.//' -e 's/\..*//'`
6322  CF_NUMBER_SYNTAX([$]$1_MAJOR,Release major-version)
6323  CF_NUMBER_SYNTAX([$]$1_MINOR,Release minor-version)
6325 ])dnl
6326 dnl ---------------------------------------------------------------------------
6327 dnl CF_WITH_SYSMOUSE version: 2 updated: 2003/03/22 19:13:43
6328 dnl ----------------
6329 dnl If we can compile with sysmouse, make it available unless it is not wanted.
6330 AC_DEFUN([CF_WITH_SYSMOUSE],[
6331 # not everyone has "test -c"
6332 if test -c /dev/sysmouse 2>/dev/null ; then
6333 AC_MSG_CHECKING(if you want to use sysmouse)
6334 AC_ARG_WITH(sysmouse,
6335         [  --with-sysmouse         use sysmouse (FreeBSD console)],
6336         [cf_with_sysmouse=$withval],
6337         [cf_with_sysmouse=maybe])
6338         if test "$cf_with_sysmouse" != no ; then
6339         AC_TRY_COMPILE([
6340 #include <osreldate.h>
6341 #if (__FreeBSD_version >= 400017)
6342 #include <sys/consio.h>
6343 #include <sys/fbio.h>
6344 #else
6345 #include <machine/console.h>
6346 #endif
6348         struct mouse_info the_mouse;
6349         ioctl(0, CONS_MOUSECTL, &the_mouse);
6350 ],[cf_with_sysmouse=yes],[cf_with_sysmouse=no])
6351         fi
6352 AC_MSG_RESULT($cf_with_sysmouse)
6353 test "$cf_with_sysmouse" = yes && AC_DEFINE(USE_SYSMOUSE,[],[USE_SYSMOUSE])
6355 ])dnl
6356 dnl ---------------------------------------------------------------------------
6357 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
6358 dnl ----------------
6359 AC_DEFUN([CF_WITH_VALGRIND],[
6360 CF_NO_LEAKS_OPTION(valgrind,
6361         [  --with-valgrind         test: use valgrind],
6362         [USE_VALGRIND])
6363 ])dnl
6364 dnl ---------------------------------------------------------------------------
6365 dnl CF_XOPEN_SOURCE version: 35 updated: 2011/02/20 20:37:37
6366 dnl ---------------
6367 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
6368 dnl or adapt to the vendor's definitions to get equivalent functionality,
6369 dnl without losing the common non-POSIX features.
6371 dnl Parameters:
6372 dnl     $1 is the nominal value for _XOPEN_SOURCE
6373 dnl     $2 is the nominal value for _POSIX_C_SOURCE
6374 AC_DEFUN([CF_XOPEN_SOURCE],[
6376 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
6377 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
6378 cf_xopen_source=
6380 case $host_os in #(vi
6381 aix[[456]]*) #(vi
6382         cf_xopen_source="-D_ALL_SOURCE"
6383         ;;
6384 cygwin) #(vi
6385         cf_XOPEN_SOURCE=600
6386         ;;
6387 darwin[[0-8]].*) #(vi
6388         cf_xopen_source="-D_APPLE_C_SOURCE"
6389         ;;
6390 darwin*) #(vi
6391         cf_xopen_source="-D_DARWIN_C_SOURCE"
6392         ;;
6393 freebsd*|dragonfly*) #(vi
6394         # 5.x headers associate
6395         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
6396         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
6397         cf_POSIX_C_SOURCE=200112L
6398         cf_XOPEN_SOURCE=600
6399         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
6400         ;;
6401 hpux11*) #(vi
6402         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
6403         ;;
6404 hpux*) #(vi
6405         cf_xopen_source="-D_HPUX_SOURCE"
6406         ;;
6407 irix[[56]].*) #(vi
6408         cf_xopen_source="-D_SGI_SOURCE"
6409         ;;
6410 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
6411         CF_GNU_SOURCE
6412         ;;
6413 mirbsd*) #(vi
6414         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
6415         ;;
6416 netbsd*) #(vi
6417         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
6418         ;;
6419 openbsd*) #(vi
6420         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
6421         ;;
6422 osf[[45]]*) #(vi
6423         cf_xopen_source="-D_OSF_SOURCE"
6424         ;;
6425 nto-qnx*) #(vi
6426         cf_xopen_source="-D_QNX_SOURCE"
6427         ;;
6428 sco*) #(vi
6429         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
6430         ;;
6431 solaris2.1[[0-9]]) #(vi
6432         cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
6433         ;;
6434 solaris2.[[1-9]]) #(vi
6435         cf_xopen_source="-D__EXTENSIONS__"
6436         ;;
6438         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
6439         AC_TRY_COMPILE([#include <sys/types.h>],[
6440 #ifndef _XOPEN_SOURCE
6441 make an error
6442 #endif],
6443         [cf_cv_xopen_source=no],
6444         [cf_save="$CPPFLAGS"
6445          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
6446          AC_TRY_COMPILE([#include <sys/types.h>],[
6447 #ifdef _XOPEN_SOURCE
6448 make an error
6449 #endif],
6450         [cf_cv_xopen_source=no],
6451         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
6452         CPPFLAGS="$cf_save"
6453         ])
6455         if test "$cf_cv_xopen_source" != no ; then
6456                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
6457                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
6458                 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
6459                 CF_ADD_CFLAGS($cf_temp_xopen_source)
6460         fi
6461         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
6462         ;;
6463 esac
6465 if test -n "$cf_xopen_source" ; then
6466         CF_ADD_CFLAGS($cf_xopen_source)