]> ncurses.scripts.mit.edu Git - ncurses.git/blob - Ada95/aclocal.m4
63b5e372aa4dfba9de2293bb0cf8f846a69032e7
[ncurses.git] / Ada95 / aclocal.m4
1 dnl***************************************************************************
2 dnl Copyright (c) 2010 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
30 dnl
31 dnl $Id: aclocal.m4,v 1.9 2010/06/12 18:59:22 tom Exp $
32 dnl Macros used in NCURSES Ada95 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 CF_ADA_INCLUDE_DIRS version: 6 updated: 2010/02/26 19:52:07
43 dnl -------------------
44 dnl Construct the list of include-options for the C programs in the Ada95
45 dnl binding.
46 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
47 [
48 ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
49 if test "$srcdir" != "."; then
50         ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
51 fi
52 if test "$GCC" != yes; then
53         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
54 elif test "$includedir" != "/usr/include"; then
55         if test "$includedir" = '${prefix}/include' ; then
56                 if test $prefix != /usr ; then
57                         ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
58                 fi
59         else
60                 ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
61         fi
62 fi
63 AC_SUBST(ACPPFLAGS)
64 ])dnl
65 dnl ---------------------------------------------------------------------------
66 dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
67 dnl -------------
68 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
69 dnl The second parameter if given makes this macro verbose.
70 dnl
71 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
72 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
73 dnl confused by the quotes (which require backslashes to keep them usable).
74 AC_DEFUN([CF_ADD_CFLAGS],
75 [
76 cf_fix_cppflags=no
77 cf_new_cflags=
78 cf_new_cppflags=
79 cf_new_extra_cppflags=
80
81 for cf_add_cflags in $1
82 do
83 case $cf_fix_cppflags in
84 no)
85         case $cf_add_cflags in #(vi
86         -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
87                 case $cf_add_cflags in
88                 -D*)
89                         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
90
91                         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
92                                 && test -z "${cf_tst_cflags}" \
93                                 && cf_fix_cppflags=yes
94
95                         if test $cf_fix_cppflags = yes ; then
96                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
97                                 continue
98                         elif test "${cf_tst_cflags}" = "\"'" ; then
99                                 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
100                                 continue
101                         fi
102                         ;;
103                 esac
104                 case "$CPPFLAGS" in
105                 *$cf_add_cflags) #(vi
106                         ;;
107                 *) #(vi
108                         case $cf_add_cflags in #(vi
109                         -D*)
110                                 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
111                                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
112                                 ;;
113                         esac
114                         cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
115                         ;;
116                 esac
117                 ;;
118         *)
119                 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
120                 ;;
121         esac
122         ;;
123 yes)
124         cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
125
126         cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
127
128         test "${cf_add_cflags}" != "${cf_tst_cflags}" \
129                 && test -z "${cf_tst_cflags}" \
130                 && cf_fix_cppflags=no
131         ;;
132 esac
133 done
134
135 if test -n "$cf_new_cflags" ; then
136         ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
137         CFLAGS="$CFLAGS $cf_new_cflags"
138 fi
139
140 if test -n "$cf_new_cppflags" ; then
141         ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
142         CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
143 fi
144
145 if test -n "$cf_new_extra_cppflags" ; then
146         ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
147         EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
148 fi
149
150 AC_SUBST(EXTRA_CPPFLAGS)
151
152 ])dnl
153 dnl ---------------------------------------------------------------------------
154 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
155 dnl -------------
156 dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
157 dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
158 dnl but old versions (and some misinstalled ones) need that.  To make things
159 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
160 dnl the include-path).
161 AC_DEFUN([CF_ADD_INCDIR],
162 [
163 if test -n "$1" ; then
164   for cf_add_incdir in $1
165   do
166         while test $cf_add_incdir != /usr/include
167         do
168           if test -d $cf_add_incdir
169           then
170                 cf_have_incdir=no
171                 if test -n "$CFLAGS$CPPFLAGS" ; then
172                   # a loop is needed to ensure we can add subdirs of existing dirs
173                   for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
174                         if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
175                           cf_have_incdir=yes; break
176                         fi
177                   done
178                 fi
179
180                 if test "$cf_have_incdir" = no ; then
181                   if test "$cf_add_incdir" = /usr/local/include ; then
182                         if test "$GCC" = yes
183                         then
184                           cf_save_CPPFLAGS=$CPPFLAGS
185                           CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
186                           AC_TRY_COMPILE([#include <stdio.h>],
187                                   [printf("Hello")],
188                                   [],
189                                   [cf_have_incdir=yes])
190                           CPPFLAGS=$cf_save_CPPFLAGS
191                         fi
192                   fi
193                 fi
194
195                 if test "$cf_have_incdir" = no ; then
196                   CF_VERBOSE(adding $cf_add_incdir to include-path)
197                   ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
198
199                   cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
200                   test "$cf_top_incdir" = "$cf_add_incdir" && break
201                   cf_add_incdir="$cf_top_incdir"
202                 else
203                   break
204                 fi
205           fi
206         done
207   done
208 fi
209 ])dnl
210 dnl ---------------------------------------------------------------------------
211 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
212 dnl ----------
213 dnl Add a library, used to enforce consistency.
214 dnl
215 dnl $1 = library to add, without the "-l"
216 dnl $2 = variable to update (default $LIBS)
217 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
218 dnl ---------------------------------------------------------------------------
219 dnl CF_ADD_LIBDIR version: 9 updated: 2010/05/26 16:44:57
220 dnl -------------
221 dnl     Adds to the library-path
222 dnl
223 dnl     Some machines have trouble with multiple -L options.
224 dnl
225 dnl $1 is the (list of) directory(s) to add
226 dnl $2 is the optional name of the variable to update (default LDFLAGS)
227 dnl
228 AC_DEFUN([CF_ADD_LIBDIR],
229 [
230 if test -n "$1" ; then
231   for cf_add_libdir in $1
232   do
233     if test $cf_add_libdir = /usr/lib ; then
234       :
235     elif test -d $cf_add_libdir
236     then
237       cf_have_libdir=no
238       if test -n "$LDFLAGS$LIBS" ; then
239         # a loop is needed to ensure we can add subdirs of existing dirs
240         for cf_test_libdir in $LDFLAGS $LIBS ; do
241           if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
242             cf_have_libdir=yes; break
243           fi
244         done
245       fi
246       if test "$cf_have_libdir" = no ; then
247         CF_VERBOSE(adding $cf_add_libdir to library-path)
248         ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
249       fi
250     fi
251   done
252 fi
253 ])dnl
254 dnl ---------------------------------------------------------------------------
255 dnl CF_ADD_LIBS version: 1 updated: 2010/06/02 05:03:05
256 dnl -----------
257 dnl Add one or more libraries, used to enforce consistency.
258 dnl
259 dnl $1 = libraries to add, with the "-l", etc.
260 dnl $2 = variable to update (default $LIBS)
261 AC_DEFUN([CF_ADD_LIBS],[ifelse($2,,LIBS,[$2])="$1 [$]ifelse($2,,LIBS,[$2])"])dnl
262 dnl ---------------------------------------------------------------------------
263 dnl CF_ADD_SUBDIR_PATH version: 2 updated: 2007/07/29 10:12:59
264 dnl ------------------
265 dnl Append to a search-list for a nonstandard header/lib-file
266 dnl     $1 = the variable to return as result
267 dnl     $2 = the package name
268 dnl     $3 = the subdirectory, e.g., bin, include or lib
269 dnl $4 = the directory under which we will test for subdirectories
270 dnl $5 = a directory that we do not want $4 to match
271 AC_DEFUN([CF_ADD_SUBDIR_PATH],
272 [
273 test "$4" != "$5" && \
274 test -d "$4" && \
275 ifelse([$5],NONE,,[(test $5 = NONE || test -d $5) &&]) {
276         test -n "$verbose" && echo "    ... testing for $3-directories under $4"
277         test -d $4/$3 &&          $1="[$]$1 $4/$3"
278         test -d $4/$3/$2 &&       $1="[$]$1 $4/$3/$2"
279         test -d $4/$3/$2/$3 &&    $1="[$]$1 $4/$3/$2/$3"
280         test -d $4/$2/$3 &&       $1="[$]$1 $4/$2/$3"
281         test -d $4/$2/$3/$2 &&    $1="[$]$1 $4/$2/$3/$2"
282 }
283 ])dnl
284 dnl ---------------------------------------------------------------------------
285 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
286 dnl ----------------
287 dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
288 dnl in the sharutils 4.2 distribution.
289 AC_DEFUN([CF_ANSI_CC_CHECK],
290 [
291 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
292 cf_cv_ansi_cc=no
293 cf_save_CFLAGS="$CFLAGS"
294 cf_save_CPPFLAGS="$CPPFLAGS"
295 # Don't try gcc -ansi; that turns off useful extensions and
296 # breaks some systems' header files.
297 # AIX                   -qlanglvl=ansi
298 # Ultrix and OSF/1      -std1
299 # HP-UX                 -Aa -D_HPUX_SOURCE
300 # SVR4                  -Xc
301 # UnixWare 1.2          (cannot use -Xc, since ANSI/POSIX clashes)
302 for cf_arg in "-DCC_HAS_PROTOS" \
303         "" \
304         -qlanglvl=ansi \
305         -std1 \
306         -Ae \
307         "-Aa -D_HPUX_SOURCE" \
308         -Xc
309 do
310         CF_ADD_CFLAGS($cf_arg)
311         AC_TRY_COMPILE(
312 [
313 #ifndef CC_HAS_PROTOS
314 #if !defined(__STDC__) || (__STDC__ != 1)
315 choke me
316 #endif
317 #endif
318 ],[
319         int test (int i, double x);
320         struct s1 {int (*f) (int a);};
321         struct s2 {int (*f) (double a);};],
322         [cf_cv_ansi_cc="$cf_arg"; break])
323 done
324 CFLAGS="$cf_save_CFLAGS"
325 CPPFLAGS="$cf_save_CPPFLAGS"
326 ])
327
328 if test "$cf_cv_ansi_cc" != "no"; then
329 if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
330         CF_ADD_CFLAGS($cf_cv_ansi_cc)
331 else
332         AC_DEFINE(CC_HAS_PROTOS)
333 fi
334 fi
335 ])dnl
336 dnl ---------------------------------------------------------------------------
337 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
338 dnl ---------------
339 dnl For programs that must use an ANSI compiler, obtain compiler options that
340 dnl will make it recognize prototypes.  We'll do preprocessor checks in other
341 dnl macros, since tools such as unproto can fake prototypes, but only part of
342 dnl the preprocessor.
343 AC_DEFUN([CF_ANSI_CC_REQD],
344 [AC_REQUIRE([CF_ANSI_CC_CHECK])
345 if test "$cf_cv_ansi_cc" = "no"; then
346         AC_MSG_ERROR(
347 [Your compiler does not appear to recognize prototypes.
348 You have the following choices:
349         a. adjust your compiler options
350         b. get an up-to-date compiler
351         c. use a wrapper such as unproto])
352 fi
353 ])dnl
354 dnl ---------------------------------------------------------------------------
355 dnl CF_AR_FLAGS version: 5 updated: 2010/05/20 20:24:29
356 dnl -----------
357 dnl Check for suitable "ar" (archiver) options for updating an archive.
358 AC_DEFUN([CF_AR_FLAGS],[
359 AC_REQUIRE([CF_PROG_AR])
360
361 AC_CACHE_CHECK(for options to update archives, cf_cv_ar_flags,[
362         cf_cv_ar_flags=unknown
363         for cf_ar_flags in -curv curv -crv crv -cqv cqv -rv rv
364         do
365
366                 # check if $ARFLAGS already contains this choice
367                 if test "x$ARFLAGS" != "x" ; then
368                         cf_check_ar_flags=`echo "x$ARFLAGS" | sed -e "s/$cf_ar_flags\$//" -e "s/$cf_ar_flags / /"`
369                         if test "x$ARFLAGS" != "$cf_check_ar_flags" ; then
370                                 cf_cv_ar_flags=
371                                 break
372                         fi
373                 fi
374
375                 rm -f conftest.$ac_cv_objext
376                 rm -f conftest.a
377
378                 cat >conftest.$ac_ext <<EOF
379 #line __oline__ "configure"
380 int     testdata[[3]] = { 123, 456, 789 };
381 EOF
382                 if AC_TRY_EVAL(ac_compile) ; then
383                         echo "$AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext" >&AC_FD_CC
384                         $AR $ARFLAGS $cf_ar_flags conftest.a conftest.$ac_cv_objext 2>&AC_FD_CC 1>/dev/null
385                         if test -f conftest.a ; then
386                                 cf_cv_ar_flags=$cf_ar_flags
387                                 break
388                         fi
389                 else
390                         CF_VERBOSE(cannot compile test-program)
391                         break
392                 fi
393         done
394         rm -f conftest.a conftest.$ac_ext conftest.$ac_cv_objext
395 ])
396
397 if test -n "$ARFLAGS" ; then
398         if test -n "$cf_cv_ar_flags" ; then
399                 ARFLAGS="$ARFLAGS $cf_cv_ar_flags"
400         fi
401 else
402         ARFLAGS=$cf_cv_ar_flags
403 fi
404
405 AC_SUBST(ARFLAGS)
406 ])
407 dnl ---------------------------------------------------------------------------
408 dnl CF_BUILD_CC version: 6 updated: 2006/10/14 15:23:15
409 dnl -----------
410 dnl If we're cross-compiling, allow the user to override the tools and their
411 dnl options.  The configure script is oriented toward identifying the host
412 dnl compiler, etc., but we need a build compiler to generate parts of the
413 dnl source.
414 dnl
415 dnl $1 = default for $CPPFLAGS
416 dnl $2 = default for $LIBS
417 AC_DEFUN([CF_BUILD_CC],[
418 AC_REQUIRE([CF_PROG_EXT])
419 if test "$cross_compiling" = yes ; then
420
421         # defaults that we might want to override
422         : ${BUILD_CFLAGS:=''}
423         : ${BUILD_CPPFLAGS:='ifelse([$1],,,[$1])'}
424         : ${BUILD_LDFLAGS:=''}
425         : ${BUILD_LIBS:='ifelse([$2],,,[$2])'}
426         : ${BUILD_EXEEXT:='$x'}
427         : ${BUILD_OBJEXT:='o'}
428
429         AC_ARG_WITH(build-cc,
430                 [  --with-build-cc=XXX     the build C compiler ($BUILD_CC)],
431                 [BUILD_CC="$withval"],
432                 [AC_CHECK_PROGS(BUILD_CC, gcc cc cl)])
433         AC_MSG_CHECKING(for native build C compiler)
434         AC_MSG_RESULT($BUILD_CC)
435
436         AC_MSG_CHECKING(for native build C preprocessor)
437         AC_ARG_WITH(build-cpp,
438                 [  --with-build-cpp=XXX    the build C preprocessor ($BUILD_CPP)],
439                 [BUILD_CPP="$withval"],
440                 [BUILD_CPP='${BUILD_CC} -E'])
441         AC_MSG_RESULT($BUILD_CPP)
442
443         AC_MSG_CHECKING(for native build C flags)
444         AC_ARG_WITH(build-cflags,
445                 [  --with-build-cflags=XXX the build C compiler-flags ($BUILD_CFLAGS)],
446                 [BUILD_CFLAGS="$withval"])
447         AC_MSG_RESULT($BUILD_CFLAGS)
448
449         AC_MSG_CHECKING(for native build C preprocessor-flags)
450         AC_ARG_WITH(build-cppflags,
451                 [  --with-build-cppflags=XXX the build C preprocessor-flags ($BUILD_CPPFLAGS)],
452                 [BUILD_CPPFLAGS="$withval"])
453         AC_MSG_RESULT($BUILD_CPPFLAGS)
454
455         AC_MSG_CHECKING(for native build linker-flags)
456         AC_ARG_WITH(build-ldflags,
457                 [  --with-build-ldflags=XXX the build linker-flags ($BUILD_LDFLAGS)],
458                 [BUILD_LDFLAGS="$withval"])
459         AC_MSG_RESULT($BUILD_LDFLAGS)
460
461         AC_MSG_CHECKING(for native build linker-libraries)
462         AC_ARG_WITH(build-libs,
463                 [  --with-build-libs=XXX   the build libraries (${BUILD_LIBS})],
464                 [BUILD_LIBS="$withval"])
465         AC_MSG_RESULT($BUILD_LIBS)
466
467         # this assumes we're on Unix.
468         BUILD_EXEEXT=
469         BUILD_OBJEXT=o
470
471         : ${BUILD_CC:='${CC}'}
472
473         if ( test "$BUILD_CC" = "$CC" || test "$BUILD_CC" = '${CC}' ) ; then
474                 AC_MSG_ERROR([Cross-build requires two compilers.
475 Use --with-build-cc to specify the native compiler.])
476         fi
477
478 else
479         : ${BUILD_CC:='${CC}'}
480         : ${BUILD_CPP:='${CPP}'}
481         : ${BUILD_CFLAGS:='${CFLAGS}'}
482         : ${BUILD_CPPFLAGS:='${CPPFLAGS}'}
483         : ${BUILD_LDFLAGS:='${LDFLAGS}'}
484         : ${BUILD_LIBS:='${LIBS}'}
485         : ${BUILD_EXEEXT:='$x'}
486         : ${BUILD_OBJEXT:='o'}
487 fi
488
489 AC_SUBST(BUILD_CC)
490 AC_SUBST(BUILD_CPP)
491 AC_SUBST(BUILD_CFLAGS)
492 AC_SUBST(BUILD_CPPFLAGS)
493 AC_SUBST(BUILD_LDFLAGS)
494 AC_SUBST(BUILD_LIBS)
495 AC_SUBST(BUILD_EXEEXT)
496 AC_SUBST(BUILD_OBJEXT)
497 ])dnl
498 dnl ---------------------------------------------------------------------------
499 dnl CF_CFG_DEFAULTS version: 7 updated: 2005/09/24 16:15:00
500 dnl ---------------
501 dnl Determine the default configuration into which we'll install ncurses.  This
502 dnl can be overridden by the user's command-line options.  There's two items to
503 dnl look for:
504 dnl     1. the prefix (e.g., /usr)
505 dnl     2. the header files (e.g., /usr/include/ncurses)
506 dnl We'll look for a previous installation of ncurses and use the same defaults.
507 dnl
508 dnl We don't use AC_PREFIX_DEFAULT, because it gets evaluated too soon, and
509 dnl we don't use AC_PREFIX_PROGRAM, because we cannot distinguish ncurses's
510 dnl programs from a vendor's.
511 AC_DEFUN([CF_CFG_DEFAULTS],
512 [
513 AC_MSG_CHECKING(for prefix)
514 if test "x$prefix" = "xNONE" ; then
515         case "$cf_cv_system_name" in
516                 # non-vendor systems don't have a conflict
517         openbsd*|freebsd*|linux*|cygwin*|k*bsd*-gnu)
518                 prefix=/usr
519                 ;;
520         *)      prefix=$ac_default_prefix
521                 ;;
522         esac
523 fi
524 AC_MSG_RESULT($prefix)
525
526 if test "x$prefix" = "xNONE" ; then
527 AC_MSG_CHECKING(for default include-directory)
528 test -n "$verbose" && echo 1>&AC_FD_MSG
529 for cf_symbol in \
530         $includedir \
531         $includedir/ncurses \
532         $prefix/include \
533         $prefix/include/ncurses \
534         /usr/local/include \
535         /usr/local/include/ncurses \
536         /usr/include \
537         /usr/include/ncurses
538 do
539         cf_dir=`eval echo $cf_symbol`
540         if test -f $cf_dir/curses.h ; then
541         if ( fgrep NCURSES_VERSION $cf_dir/curses.h 2>&1 >/dev/null ) ; then
542                 includedir="$cf_symbol"
543                 test -n "$verbose"  && echo $ac_n "     found " 1>&AC_FD_MSG
544                 break
545         fi
546         fi
547         test -n "$verbose"  && echo "   tested $cf_dir" 1>&AC_FD_MSG
548 done
549 AC_MSG_RESULT($includedir)
550 fi
551 ])dnl
552 dnl ---------------------------------------------------------------------------
553 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
554 dnl --------------
555 dnl Check if we're accidentally using a cache from a different machine.
556 dnl Derive the system name, as a check for reusing the autoconf cache.
557 dnl
558 dnl If we've packaged config.guess and config.sub, run that (since it does a
559 dnl better job than uname).  Normally we'll use AC_CANONICAL_HOST, but allow
560 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
561 dnl which is useful in cross-compiles.
562 dnl
563 dnl Note: we would use $ac_config_sub, but that is one of the places where
564 dnl autoconf 2.5x broke compatibility with autoconf 2.13
565 AC_DEFUN([CF_CHECK_CACHE],
566 [
567 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
568         ifelse([$1],,[AC_CANONICAL_HOST],[$1])
569         system_name="$host_os"
570 else
571         system_name="`(uname -s -r) 2>/dev/null`"
572         if test -z "$system_name" ; then
573                 system_name="`(hostname) 2>/dev/null`"
574         fi
575 fi
576 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
577 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
578
579 test -z "$system_name" && system_name="$cf_cv_system_name"
580 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
581
582 if test ".$system_name" != ".$cf_cv_system_name" ; then
583         AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
584         AC_MSG_ERROR("Please remove config.cache and try again.")
585 fi
586 ])dnl
587 dnl ---------------------------------------------------------------------------
588 dnl CF_CURSES_HEADER version: 2 updated: 2010/04/28 06:02:16
589 dnl ----------------
590 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
591 dnl variations of ncurses' installs.
592 dnl
593 dnl $1 = ncurses when looking for ncurses, or is empty
594 AC_DEFUN([CF_CURSES_HEADER],[
595 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
596 cf_cv_ncurses_header=none
597 for cf_header in ifelse($1,,,[ \
598     $1/curses.h \
599         $1/ncurses.h]) \
600         curses.h \
601         ncurses.h ifelse($1,,[ncurses/curses.h ncurses/ncurses.h])
602 do
603 AC_TRY_COMPILE([#include <${cf_header}>],
604         [initscr(); tgoto("?", 0,0)],
605         [cf_cv_ncurses_header=$cf_header; break],[])
606 done
607 ])
608
609 if test "$cf_cv_ncurses_header" = none ; then
610         AC_MSG_ERROR(No curses header-files found)
611 fi
612
613 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
614 AC_CHECK_HEADERS($cf_cv_ncurses_header)
615 ])dnl
616 dnl ---------------------------------------------------------------------------
617 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
618 dnl ----------
619 dnl "dirname" is not portable, so we fake it with a shell script.
620 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
621 dnl ---------------------------------------------------------------------------
622 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
623 dnl ---------------
624 dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
625 dnl prefer a standard location, and use -L options only if we do not find the
626 dnl library in the standard library location(s).
627 dnl     $1 = library name
628 dnl     $2 = library class, usually the same as library name
629 dnl     $3 = includes
630 dnl     $4 = code fragment to compile/link
631 dnl     $5 = corresponding function-name
632 dnl     $6 = flag, nonnull if failure should not cause an error-exit
633 dnl
634 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
635 dnl to use a -L option.
636 AC_DEFUN([CF_FIND_LIBRARY],
637 [
638         eval 'cf_cv_have_lib_'$1'=no'
639         cf_libdir=""
640         AC_CHECK_FUNC($5,
641                 eval 'cf_cv_have_lib_'$1'=yes',[
642                 cf_save_LIBS="$LIBS"
643                 AC_MSG_CHECKING(for $5 in -l$1)
644                 LIBS="-l$1 $LIBS"
645                 AC_TRY_LINK([$3],[$4],
646                         [AC_MSG_RESULT(yes)
647                          eval 'cf_cv_have_lib_'$1'=yes'
648                         ],
649                         [AC_MSG_RESULT(no)
650                         CF_LIBRARY_PATH(cf_search,$2)
651                         for cf_libdir in $cf_search
652                         do
653                                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
654                                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
655                                 AC_TRY_LINK([$3],[$4],
656                                         [AC_MSG_RESULT(yes)
657                                          eval 'cf_cv_have_lib_'$1'=yes'
658                                          break],
659                                         [AC_MSG_RESULT(no)
660                                          LIBS="$cf_save_LIBS"])
661                         done
662                         ])
663                 ])
664 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
665 ifelse($6,,[
666 if test $cf_found_library = no ; then
667         AC_MSG_ERROR(Cannot link $1 library)
668 fi
669 ])
670 ])dnl
671 dnl ---------------------------------------------------------------------------
672 dnl CF_FIND_LINKAGE version: 19 updated: 2010/05/29 16:31:02
673 dnl ---------------
674 dnl Find a library (specifically the linkage used in the code fragment),
675 dnl searching for it if it is not already in the library path.
676 dnl See also CF_ADD_SEARCHPATH.
677 dnl
678 dnl Parameters (4-on are optional):
679 dnl     $1 = headers for library entrypoint
680 dnl     $2 = code fragment for library entrypoint
681 dnl     $3 = the library name without the "-l" option or ".so" suffix.
682 dnl     $4 = action to perform if successful (default: update CPPFLAGS, etc)
683 dnl     $5 = action to perform if not successful
684 dnl     $6 = module name, if not the same as the library name
685 dnl     $7 = extra libraries
686 dnl
687 dnl Sets these variables:
688 dnl     $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
689 dnl     $cf_cv_header_path_$3 - include-directory if needed
690 dnl     $cf_cv_library_path_$3 - library-directory if needed
691 dnl     $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
692 AC_DEFUN([CF_FIND_LINKAGE],[
693
694 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
695 # will be set on completion of the AC_TRY_LINK below.
696 cf_cv_header_path_$3=
697 cf_cv_library_path_$3=
698
699 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
700
701 cf_save_LIBS="$LIBS"
702
703 AC_TRY_LINK([$1],[$2],[
704         cf_cv_find_linkage_$3=yes
705         cf_cv_header_path_$3=/usr/include
706         cf_cv_library_path_$3=/usr/lib
707 ],[
708
709 LIBS="-l$3 $7 $cf_save_LIBS"
710
711 AC_TRY_LINK([$1],[$2],[
712         cf_cv_find_linkage_$3=yes
713         cf_cv_header_path_$3=/usr/include
714         cf_cv_library_path_$3=/usr/lib
715         cf_cv_library_file_$3="-l$3"
716 ],[
717         cf_cv_find_linkage_$3=no
718         LIBS="$cf_save_LIBS"
719
720     CF_VERBOSE(find linkage for $3 library)
721     CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
722
723     cf_save_CPPFLAGS="$CPPFLAGS"
724     cf_test_CPPFLAGS="$CPPFLAGS"
725
726     CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
727     for cf_cv_header_path_$3 in $cf_search
728     do
729       if test -d $cf_cv_header_path_$3 ; then
730         CF_VERBOSE(... testing $cf_cv_header_path_$3)
731         CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
732         AC_TRY_COMPILE([$1],[$2],[
733             CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
734             cf_cv_find_linkage_$3=maybe
735             cf_test_CPPFLAGS="$CPPFLAGS"
736             break],[
737             CPPFLAGS="$cf_save_CPPFLAGS"
738             ])
739       fi
740     done
741
742     if test "$cf_cv_find_linkage_$3" = maybe ; then
743
744       CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
745
746       cf_save_LIBS="$LIBS"
747       cf_save_LDFLAGS="$LDFLAGS"
748
749       ifelse([$6],,,[
750         CPPFLAGS="$cf_test_CPPFLAGS"
751         LIBS="-l$3 $7 $cf_save_LIBS"
752         AC_TRY_LINK([$1],[$2],[
753             CF_VERBOSE(... found $3 library in system)
754             cf_cv_find_linkage_$3=yes])
755             CPPFLAGS="$cf_save_CPPFLAGS"
756             LIBS="$cf_save_LIBS"
757             ])
758
759       if test "$cf_cv_find_linkage_$3" != yes ; then
760         CF_LIBRARY_PATH(cf_search,$3)
761         for cf_cv_library_path_$3 in $cf_search
762         do
763           if test -d $cf_cv_library_path_$3 ; then
764             CF_VERBOSE(... testing $cf_cv_library_path_$3)
765             CPPFLAGS="$cf_test_CPPFLAGS"
766             LIBS="-l$3 $7 $cf_save_LIBS"
767             LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
768             AC_TRY_LINK([$1],[$2],[
769                 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
770                 cf_cv_find_linkage_$3=yes
771                 cf_cv_library_file_$3="-l$3"
772                 break],[
773                 CPPFLAGS="$cf_save_CPPFLAGS"
774                 LIBS="$cf_save_LIBS"
775                 LDFLAGS="$cf_save_LDFLAGS"
776                 ])
777           fi
778         done
779         CPPFLAGS="$cf_save_CPPFLAGS"
780         LDFLAGS="$cf_save_LDFLAGS"
781       fi
782
783     else
784       cf_cv_find_linkage_$3=no
785     fi
786     ],$7)
787 ])
788
789 LIBS="$cf_save_LIBS"
790
791 if test "$cf_cv_find_linkage_$3" = yes ; then
792 ifelse([$4],,[
793         CF_ADD_INCDIR($cf_cv_header_path_$3)
794         CF_ADD_LIBDIR($cf_cv_library_path_$3)
795         CF_ADD_LIB($3)
796 ],[$4])
797 else
798 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
799 fi
800 ])dnl
801 dnl ---------------------------------------------------------------------------
802 dnl CF_GCC_ATTRIBUTES version: 13 updated: 2009/08/11 20:19:56
803 dnl -----------------
804 dnl Test for availability of useful gcc __attribute__ directives to quiet
805 dnl compiler warnings.  Though useful, not all are supported -- and contrary
806 dnl to documentation, unrecognized directives cause older compilers to barf.
807 AC_DEFUN([CF_GCC_ATTRIBUTES],
808 [
809 if test "$GCC" = yes
810 then
811 cat > conftest.i <<EOF
812 #ifndef GCC_PRINTF
813 #define GCC_PRINTF 0
814 #endif
815 #ifndef GCC_SCANF
816 #define GCC_SCANF 0
817 #endif
818 #ifndef GCC_NORETURN
819 #define GCC_NORETURN /* nothing */
820 #endif
821 #ifndef GCC_UNUSED
822 #define GCC_UNUSED /* nothing */
823 #endif
824 EOF
825 if test "$GCC" = yes
826 then
827         AC_CHECKING([for $CC __attribute__ directives])
828 cat > conftest.$ac_ext <<EOF
829 #line __oline__ "${as_me-configure}"
830 #include "confdefs.h"
831 #include "conftest.h"
832 #include "conftest.i"
833 #if     GCC_PRINTF
834 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
835 #else
836 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
837 #endif
838 #if     GCC_SCANF
839 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
840 #else
841 #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
842 #endif
843 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
844 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
845 extern void foo(void) GCC_NORETURN;
846 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
847 EOF
848         cf_printf_attribute=no
849         cf_scanf_attribute=no
850         for cf_attribute in scanf printf unused noreturn
851         do
852                 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
853                 cf_directive="__attribute__(($cf_attribute))"
854                 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
855
856                 case $cf_attribute in #(vi
857                 printf) #(vi
858                         cf_printf_attribute=yes
859                         cat >conftest.h <<EOF
860 #define GCC_$cf_ATTRIBUTE 1
861 EOF
862                         ;;
863                 scanf) #(vi
864                         cf_scanf_attribute=yes
865                         cat >conftest.h <<EOF
866 #define GCC_$cf_ATTRIBUTE 1
867 EOF
868                         ;;
869                 *) #(vi
870                         cat >conftest.h <<EOF
871 #define GCC_$cf_ATTRIBUTE $cf_directive
872 EOF
873                         ;;
874                 esac
875
876                 if AC_TRY_EVAL(ac_compile); then
877                         test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
878                         cat conftest.h >>confdefs.h
879                         case $cf_attribute in #(vi
880                         printf) #(vi
881                                 if test "$cf_printf_attribute" = no ; then
882                                         cat >>confdefs.h <<EOF
883 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
884 EOF
885                                 else
886                                         cat >>confdefs.h <<EOF
887 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
888 EOF
889                                 fi
890                                 ;;
891                         scanf) #(vi
892                                 if test "$cf_scanf_attribute" = no ; then
893                                         cat >>confdefs.h <<EOF
894 #define GCC_SCANFLIKE(fmt,var) /* nothing */
895 EOF
896                                 else
897                                         cat >>confdefs.h <<EOF
898 #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
899 EOF
900                                 fi
901                                 ;;
902                         esac
903                 fi
904         done
905 else
906         fgrep define conftest.i >>confdefs.h
907 fi
908 rm -rf conftest*
909 fi
910 ])dnl
911 dnl ---------------------------------------------------------------------------
912 dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
913 dnl --------------
914 dnl Find version of gcc
915 AC_DEFUN([CF_GCC_VERSION],[
916 AC_REQUIRE([AC_PROG_CC])
917 GCC_VERSION=none
918 if test "$GCC" = yes ; then
919         AC_MSG_CHECKING(version of $CC)
920         GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
921         test -z "$GCC_VERSION" && GCC_VERSION=unknown
922         AC_MSG_RESULT($GCC_VERSION)
923 fi
924 ])dnl
925 dnl ---------------------------------------------------------------------------
926 dnl CF_GCC_WARNINGS version: 25 updated: 2010/04/24 11:03:31
927 dnl ---------------
928 dnl Check if the compiler supports useful warning options.  There's a few that
929 dnl we don't use, simply because they're too noisy:
930 dnl
931 dnl     -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
932 dnl     -Wredundant-decls (system headers make this too noisy)
933 dnl     -Wtraditional (combines too many unrelated messages, only a few useful)
934 dnl     -Wwrite-strings (too noisy, but should review occasionally).  This
935 dnl             is enabled for ncurses using "--enable-const".
936 dnl     -pedantic
937 dnl
938 dnl Parameter:
939 dnl     $1 is an optional list of gcc warning flags that a particular
940 dnl             application might want to use, e.g., "no-unused" for
941 dnl             -Wno-unused
942 dnl Special:
943 dnl     If $with_ext_const is "yes", add a check for -Wwrite-strings
944 dnl
945 AC_DEFUN([CF_GCC_WARNINGS],
946 [
947 AC_REQUIRE([CF_GCC_VERSION])
948 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
949
950 cat > conftest.$ac_ext <<EOF
951 #line __oline__ "${as_me-configure}"
952 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
953 EOF
954
955 if test "$INTEL_COMPILER" = yes
956 then
957 # The "-wdXXX" options suppress warnings:
958 # remark #1419: external declaration in primary source file
959 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
960 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
961 # remark #193: zero used for undefined preprocessing identifier
962 # remark #593: variable "curs_sb_left_arrow" was set but never used
963 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
964 # remark #869: parameter "tw" was never referenced
965 # remark #981: operands are evaluated in unspecified order
966 # warning #279: controlling expression is constant
967
968         AC_CHECKING([for $CC warning options])
969         cf_save_CFLAGS="$CFLAGS"
970         EXTRA_CFLAGS="-Wall"
971         for cf_opt in \
972                 wd1419 \
973                 wd1683 \
974                 wd1684 \
975                 wd193 \
976                 wd593 \
977                 wd279 \
978                 wd810 \
979                 wd869 \
980                 wd981
981         do
982                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
983                 if AC_TRY_EVAL(ac_compile); then
984                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
985                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
986                 fi
987         done
988         CFLAGS="$cf_save_CFLAGS"
989
990 elif test "$GCC" = yes
991 then
992         AC_CHECKING([for $CC warning options])
993         cf_save_CFLAGS="$CFLAGS"
994         EXTRA_CFLAGS=
995         cf_warn_CONST=""
996         test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
997         for cf_opt in W Wall \
998                 Wbad-function-cast \
999                 Wcast-align \
1000                 Wcast-qual \
1001                 Winline \
1002                 Wmissing-declarations \
1003                 Wmissing-prototypes \
1004                 Wnested-externs \
1005                 Wpointer-arith \
1006                 Wshadow \
1007                 Wstrict-prototypes \
1008                 Wundef $cf_warn_CONST $1
1009         do
1010                 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1011                 if AC_TRY_EVAL(ac_compile); then
1012                         test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1013                         case $cf_opt in #(vi
1014                         Wcast-qual) #(vi
1015                                 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1016                                 ;;
1017                         Winline) #(vi
1018                                 case $GCC_VERSION in
1019                                 [[34]].*)
1020                                         CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1021                                         continue;;
1022                                 esac
1023                                 ;;
1024                         esac
1025                         EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1026                 fi
1027         done
1028         CFLAGS="$cf_save_CFLAGS"
1029 fi
1030 rm -f conftest*
1031
1032 AC_SUBST(EXTRA_CFLAGS)
1033 ])dnl
1034 dnl ---------------------------------------------------------------------------
1035 dnl CF_GNAT_TRY_LINK version: 1 updated: 2004/08/21 19:02:08
1036 dnl ----------------
1037 dnl Verify that a test program compiles/links with GNAT.
1038 dnl $cf_ada_make is set to the program that compiles/links
1039 dnl $ADAFLAGS may be set to the GNAT flags.
1040 dnl
1041 dnl $1 is the text of the spec
1042 dnl $2 is the text of the body
1043 dnl $3 is the shell command to execute if successful
1044 dnl $4 is the shell command to execute if not successful
1045 AC_DEFUN([CF_GNAT_TRY_LINK],
1046 [
1047 rm -f conftest*
1048 cat >>conftest.ads <<CF_EOF
1049 $1
1050 CF_EOF
1051 cat >>conftest.adb <<CF_EOF
1052 $2
1053 CF_EOF
1054 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1055 ifelse($3,,      :,[      $3])
1056 ifelse($4,,,[else
1057    $4])
1058 fi
1059 rm -f conftest*
1060 ])dnl
1061 dnl ---------------------------------------------------------------------------
1062 dnl CF_GNAT_TRY_RUN version: 3 updated: 2004/08/21 19:02:08
1063 dnl ---------------
1064 dnl Verify that a test program compiles and runs with GNAT
1065 dnl $cf_ada_make is set to the program that compiles/links
1066 dnl $ADAFLAGS may be set to the GNAT flags.
1067 dnl
1068 dnl $1 is the text of the spec
1069 dnl $2 is the text of the body
1070 dnl $3 is the shell command to execute if successful
1071 dnl $4 is the shell command to execute if not successful
1072 AC_DEFUN([CF_GNAT_TRY_RUN],
1073 [
1074 rm -f conftest*
1075 cat >>conftest.ads <<CF_EOF
1076 $1
1077 CF_EOF
1078 cat >>conftest.adb <<CF_EOF
1079 $2
1080 CF_EOF
1081 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
1082    if ( ./conftest 1>&AC_FD_CC 2>&1 ) ; then
1083 ifelse($3,,      :,[      $3])
1084 ifelse($4,,,[   else
1085       $4])
1086    fi
1087 ifelse($4,,,[else
1088    $4])
1089 fi
1090 rm -f conftest*
1091 ])dnl
1092 dnl ---------------------------------------------------------------------------
1093 dnl CF_GNAT_VERSION version: 12 updated: 2006/10/14 15:23:15
1094 dnl ---------------
1095 dnl Verify version of GNAT.
1096 AC_DEFUN([CF_GNAT_VERSION],
1097 [
1098 AC_MSG_CHECKING(for gnat version)
1099 cf_gnat_version=`${cf_ada_make-gnatmake} -v 2>&1 | grep '[[0-9]].[[0-9]][[0-9]]*' |\
1100   sed -e '2,$d' -e 's/[[^0-9 \.]]//g' -e 's/^[[ ]]*//' -e 's/ .*//'`
1101 AC_MSG_RESULT($cf_gnat_version)
1102
1103 case $cf_gnat_version in
1104   3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*)
1105     cf_cv_prog_gnat_correct=yes
1106     ;;
1107   *) echo Unsupported GNAT version $cf_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
1108      cf_cv_prog_gnat_correct=no
1109      ;;
1110 esac
1111 case $cf_gnat_version in
1112   3.[[1-9]]*|[[4-9]].*)
1113       cf_compile_generics=generics
1114       cf_generic_objects="\${GENOBJS}"
1115       ;;
1116   *)  cf_compile_generics=
1117       cf_generic_objects=
1118       ;;
1119 esac
1120 ])
1121 dnl ---------------------------------------------------------------------------
1122 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1123 dnl -------------
1124 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1125 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend.  This is a defect
1126 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1127 dnl since it is interwoven with GNU extensions.
1128 dnl
1129 dnl Well, yes we could work around it...
1130 AC_DEFUN([CF_GNU_SOURCE],
1131 [
1132 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1133 AC_TRY_COMPILE([#include <sys/types.h>],[
1134 #ifndef _XOPEN_SOURCE
1135 make an error
1136 #endif],
1137         [cf_cv_gnu_source=no],
1138         [cf_save="$CPPFLAGS"
1139          CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1140          AC_TRY_COMPILE([#include <sys/types.h>],[
1141 #ifdef _XOPEN_SOURCE
1142 make an error
1143 #endif],
1144         [cf_cv_gnu_source=no],
1145         [cf_cv_gnu_source=yes])
1146         CPPFLAGS="$cf_save"
1147         ])
1148 ])
1149 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1150 ])dnl
1151 dnl ---------------------------------------------------------------------------
1152 dnl CF_HEADER_PATH version: 12 updated: 2010/05/05 05:22:40
1153 dnl --------------
1154 dnl Construct a search-list of directories for a nonstandard header-file
1155 dnl
1156 dnl Parameters
1157 dnl     $1 = the variable to return as result
1158 dnl     $2 = the package name
1159 AC_DEFUN([CF_HEADER_PATH],
1160 [
1161 $1=
1162
1163 # collect the current set of include-directories from compiler flags
1164 cf_header_path_list=""
1165 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1166         for cf_header_path in $CPPFLAGS $CFLAGS
1167         do
1168                 case $cf_header_path in #(vi
1169                 -I*)
1170                         cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1171                         CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1172                         cf_header_path_list="$cf_header_path_list [$]$1"
1173                         ;;
1174                 esac
1175         done
1176 fi
1177
1178 # add the variations for the package we are looking for
1179 CF_SUBDIR_PATH($1,$2,include)
1180
1181 test "$includedir" != NONE && \
1182 test "$includedir" != "/usr/include" && \
1183 test -d "$includedir" && {
1184         test -d $includedir &&    $1="[$]$1 $includedir"
1185         test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1186 }
1187
1188 test "$oldincludedir" != NONE && \
1189 test "$oldincludedir" != "/usr/include" && \
1190 test -d "$oldincludedir" && {
1191         test -d $oldincludedir    && $1="[$]$1 $oldincludedir"
1192         test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1193 }
1194
1195 $1="[$]$1 $cf_header_path_list"
1196 ])dnl
1197 dnl ---------------------------------------------------------------------------
1198 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1199 dnl ---------------
1200 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1201 AC_DEFUN([CF_HELP_MESSAGE],
1202 [AC_DIVERT_HELP([$1])dnl
1203 ])dnl
1204 dnl ---------------------------------------------------------------------------
1205 dnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
1206 dnl ---------------
1207 dnl Construct the list of include-options according to whether we're building
1208 dnl in the source directory or using '--srcdir=DIR' option.  If we're building
1209 dnl with gcc, don't append the includedir if it happens to be /usr/include,
1210 dnl since that usually breaks gcc's shadow-includes.
1211 AC_DEFUN([CF_INCLUDE_DIRS],
1212 [
1213 CPPFLAGS="$CPPFLAGS -I. -I../include"
1214 if test "$srcdir" != "."; then
1215         CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
1216 fi
1217 if test "$GCC" != yes; then
1218         CPPFLAGS="$CPPFLAGS -I\${includedir}"
1219 elif test "$includedir" != "/usr/include"; then
1220         if test "$includedir" = '${prefix}/include' ; then
1221                 if test $prefix != /usr ; then
1222                         CPPFLAGS="$CPPFLAGS -I\${includedir}"
1223                 fi
1224         else
1225                 CPPFLAGS="$CPPFLAGS -I\${includedir}"
1226         fi
1227 fi
1228 AC_SUBST(CPPFLAGS)
1229 ])dnl
1230 dnl ---------------------------------------------------------------------------
1231 dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
1232 dnl -----------------
1233 dnl Check if the given compiler is really the Intel compiler for Linux.  It
1234 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1235 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1236 dnl
1237 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1238 dnl ensure that it is not mistaken for gcc/g++.  It is normally invoked from
1239 dnl the wrappers for gcc and g++ warnings.
1240 dnl
1241 dnl $1 = GCC (default) or GXX
1242 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1243 dnl $3 = CFLAGS (default) or CXXFLAGS
1244 AC_DEFUN([CF_INTEL_COMPILER],[
1245 ifelse([$2],,INTEL_COMPILER,[$2])=no
1246
1247 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1248         case $host_os in
1249         linux*|gnu*)
1250                 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1251                 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1252                 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1253                 AC_TRY_COMPILE([],[
1254 #ifdef __INTEL_COMPILER
1255 #else
1256 make an error
1257 #endif
1258 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1259 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1260 ],[])
1261                 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1262                 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1263                 ;;
1264         esac
1265 fi
1266 ])dnl
1267 dnl ---------------------------------------------------------------------------
1268 dnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
1269 dnl ------------
1270 dnl Add checks for large file support.
1271 AC_DEFUN([CF_LARGEFILE],[
1272 ifdef([AC_FUNC_FSEEKO],[
1273     AC_SYS_LARGEFILE
1274     if test "$enable_largefile" != no ; then
1275         AC_FUNC_FSEEKO
1276
1277         # Normally we would collect these definitions in the config.h,
1278         # but (like _XOPEN_SOURCE), some environments rely on having these
1279         # defined before any of the system headers are included.  Another
1280         # case comes up with C++, e.g., on AIX the compiler compiles the
1281         # header files by themselves before looking at the body files it is
1282         # told to compile.  For ncurses, those header files do not include
1283         # the config.h
1284         test "$ac_cv_sys_large_files"      != no && CPPFLAGS="$CPPFLAGS -D_LARGE_FILES "
1285         test "$ac_cv_sys_largefile_source" != no && CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE "
1286         test "$ac_cv_sys_file_offset_bits" != no && CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits "
1287
1288         AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
1289                 AC_TRY_COMPILE([
1290 #include <sys/types.h>
1291 #include <dirent.h>
1292                 ],[
1293                 /* if transitional largefile support is setup, this is true */
1294                 extern struct dirent64 * readdir(DIR *);
1295                 struct dirent64 *x = readdir((DIR *)0);
1296                 struct dirent *y = readdir((DIR *)0);
1297                 int z = x - y;
1298                 ],
1299                 [cf_cv_struct_dirent64=yes],
1300                 [cf_cv_struct_dirent64=no])
1301         ])
1302         test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
1303     fi
1304 ])
1305 ])
1306 dnl ---------------------------------------------------------------------------
1307 dnl CF_LD_RPATH_OPT version: 3 updated: 2010/06/02 05:03:05
1308 dnl ---------------
1309 dnl For the given system and compiler, find the compiler flags to pass to the
1310 dnl loader to use the "rpath" feature.
1311 AC_DEFUN([CF_LD_RPATH_OPT],
1312 [
1313 AC_REQUIRE([CF_CHECK_CACHE])
1314
1315 LD_RPATH_OPT=
1316 AC_MSG_CHECKING(for an rpath option)
1317 case $cf_cv_system_name in #(vi
1318 irix*) #(vi
1319         if test "$GCC" = yes; then
1320                 LD_RPATH_OPT="-Wl,-rpath,"
1321         else
1322                 LD_RPATH_OPT="-rpath "
1323         fi
1324         ;;
1325 linux*|gnu*|k*bsd*-gnu) #(vi
1326         LD_RPATH_OPT="-Wl,-rpath,"
1327         ;;
1328 openbsd[[2-9]].*) #(vi
1329         LD_RPATH_OPT="-Wl,-rpath,"
1330         ;;
1331 freebsd*) #(vi
1332         LD_RPATH_OPT="-rpath "
1333         ;;
1334 netbsd*) #(vi
1335         LD_RPATH_OPT="-Wl,-rpath,"
1336         ;;
1337 osf*|mls+*) #(vi
1338         LD_RPATH_OPT="-rpath "
1339         ;;
1340 solaris2*) #(vi
1341         LD_RPATH_OPT="-R"
1342         ;;
1343 *)
1344         ;;
1345 esac
1346 AC_MSG_RESULT($LD_RPATH_OPT)
1347
1348 case "x$LD_RPATH_OPT" in #(vi
1349 x-R*)
1350         AC_MSG_CHECKING(if we need a space after rpath option)
1351         cf_save_LIBS="$LIBS"
1352         CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1353         AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1354         LIBS="$cf_save_LIBS"
1355         AC_MSG_RESULT($cf_rpath_space)
1356         test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1357         ;;
1358 esac
1359 ])dnl
1360 dnl ---------------------------------------------------------------------------
1361 dnl CF_LIBRARY_PATH version: 9 updated: 2010/03/28 12:52:50
1362 dnl ---------------
1363 dnl Construct a search-list of directories for a nonstandard library-file
1364 dnl
1365 dnl Parameters
1366 dnl     $1 = the variable to return as result
1367 dnl     $2 = the package name
1368 AC_DEFUN([CF_LIBRARY_PATH],
1369 [
1370 $1=
1371 cf_library_path_list=""
1372 if test -n "${LDFLAGS}${LIBS}" ; then
1373         for cf_library_path in $LDFLAGS $LIBS
1374         do
1375                 case $cf_library_path in #(vi
1376                 -L*)
1377                         cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1378                         CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1379                         cf_library_path_list="$cf_library_path_list [$]$1"
1380                         ;;
1381                 esac
1382         done
1383 fi
1384
1385 CF_SUBDIR_PATH($1,$2,lib)
1386
1387 $1="$cf_library_path_list [$]$1"
1388 ])dnl
1389 dnl ---------------------------------------------------------------------------
1390 dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
1391 dnl -------------
1392 dnl Compute the library-prefix for the given host system
1393 dnl $1 = variable to set
1394 AC_DEFUN([CF_LIB_PREFIX],
1395 [
1396         case $cf_cv_system_name in #(vi
1397         OS/2*|os2*) #(vi
1398         LIB_PREFIX=''
1399         ;;
1400         *)      LIB_PREFIX='lib'
1401         ;;
1402         esac
1403 ifelse($1,,,[$1=$LIB_PREFIX])
1404         AC_SUBST(LIB_PREFIX)
1405 ])dnl
1406 dnl ---------------------------------------------------------------------------
1407 dnl CF_LIB_SONAME version: 4 updated: 2010/05/29 16:31:02
1408 dnl -------------
1409 dnl Find the and soname for the given shared library.  Set the cache variable
1410 dnl cf_cv_$3_soname to this, unless it is not found.  Then set the cache
1411 dnl variable to "unknown".
1412 dnl
1413 dnl $1 = headers
1414 dnl $2 = code
1415 dnl $3 = library name
1416 AC_DEFUN([CF_LIB_SONAME],
1417 [
1418 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
1419
1420 cf_cv_$3_soname=unknown
1421 if test "$cross_compiling" != yes ; then
1422 cat >conftest.$ac_ext <<CF_EOF
1423 $1
1424 int main()
1425 {
1426 $2
1427         ${cf_cv_main_return:-return}(0);
1428 }
1429 CF_EOF
1430 cf_save_LIBS="$LIBS"
1431         CF_ADD_LIB($3)
1432         if AC_TRY_EVAL(ac_compile) ; then
1433                 if AC_TRY_EVAL(ac_link) ; then
1434                         cf_cv_$3_soname=`ldd conftest$ac_exeext 2>/dev/null | sed -e 's,^.*/,,' -e 's, .*$,,' | fgrep lib$3.`
1435                         test -z "$cf_cv_$3_soname" && cf_cv_$3_soname=unknown
1436                 fi
1437         fi
1438 rm -f conftest*
1439 LIBS="$cf_save_LIBS"
1440 fi
1441 ])
1442 ])
1443 dnl ---------------------------------------------------------------------------
1444 dnl CF_LIB_SUFFIX version: 16 updated: 2008/12/27 12:30:03
1445 dnl -------------
1446 dnl Compute the library file-suffix from the given model name
1447 dnl $1 = model name
1448 dnl $2 = variable to set (the nominal library suffix)
1449 dnl $3 = dependency variable to set (actual filename)
1450 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1451 AC_DEFUN([CF_LIB_SUFFIX],
1452 [
1453         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1454         case $1 in #(vi
1455         libtool) #(vi
1456                 $2='.la'
1457                 $3=[$]$2
1458                 ;;
1459         normal) #(vi
1460                 $2='.a'
1461                 $3=[$]$2
1462                 ;;
1463         debug) #(vi
1464                 $2='_g.a'
1465                 $3=[$]$2
1466                 ;;
1467         profile) #(vi
1468                 $2='_p.a'
1469                 $3=[$]$2
1470                 ;;
1471         shared) #(vi
1472                 case $cf_cv_system_name in
1473                 aix[[56]]*) #(vi
1474                         $2='.a'
1475                         $3=[$]$2
1476                         ;;
1477                 cygwin*) #(vi
1478                         $2='.dll'
1479                         $3='.dll.a'
1480                         ;;
1481                 darwin*) #(vi
1482                         $2='.dylib'
1483                         $3=[$]$2
1484                         ;;
1485                 hpux*) #(vi
1486                         case $target in
1487                         ia64*) #(vi
1488                                 $2='.so'
1489                                 $3=[$]$2
1490                                 ;;
1491                         *) #(vi
1492                                 $2='.sl'
1493                                 $3=[$]$2
1494                                 ;;
1495                         esac
1496                         ;;
1497                 *)      $2='.so'
1498                         $3=[$]$2
1499                         ;;
1500                 esac
1501         esac
1502         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1503         test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
1504 ])dnl
1505 dnl ---------------------------------------------------------------------------
1506 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
1507 dnl -----------
1508 dnl Compute the string to append to -library from the given model name
1509 dnl $1 = model name
1510 dnl $2 = variable to set
1511 dnl The variable $LIB_SUFFIX, if set, prepends the variable to set.
1512 AC_DEFUN([CF_LIB_TYPE],
1513 [
1514         case $1 in
1515         libtool) $2=''   ;;
1516         normal)  $2=''   ;;
1517         debug)   $2='_g' ;;
1518         profile) $2='_p' ;;
1519         shared)  $2=''   ;;
1520         esac
1521         test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1522 ])dnl
1523 dnl ---------------------------------------------------------------------------
1524 dnl CF_LINK_DATAONLY version: 9 updated: 2009/01/01 20:21:38
1525 dnl ----------------
1526 dnl Some systems have a non-ANSI linker that doesn't pull in modules that have
1527 dnl only data (i.e., no functions), for example NeXT.  On those systems we'll
1528 dnl have to provide wrappers for global tables to ensure they're linked
1529 dnl properly.
1530 AC_DEFUN([CF_LINK_DATAONLY],
1531 [
1532 AC_MSG_CHECKING([if data-only library module links])
1533 AC_CACHE_VAL(cf_cv_link_dataonly,[
1534         rm -f conftest.a
1535         cat >conftest.$ac_ext <<EOF
1536 #line __oline__ "configure"
1537 int     testdata[[3]] = { 123, 456, 789 };
1538 EOF
1539         if AC_TRY_EVAL(ac_compile) ; then
1540                 mv conftest.o data.o && \
1541                 ( $AR $ARFLAGS conftest.a data.o ) 2>&AC_FD_CC 1>/dev/null
1542         fi
1543         rm -f conftest.$ac_ext data.o
1544         cat >conftest.$ac_ext <<EOF
1545 #line __oline__ "configure"
1546 int     testfunc()
1547 {
1548 #if defined(NeXT)
1549         ${cf_cv_main_return:-return}(1);        /* I'm told this linker is broken */
1550 #else
1551         extern int testdata[[3]];
1552         return testdata[[0]] == 123
1553            &&  testdata[[1]] == 456
1554            &&  testdata[[2]] == 789;
1555 #endif
1556 }
1557 EOF
1558         if AC_TRY_EVAL(ac_compile); then
1559                 mv conftest.o func.o && \
1560                 ( $AR $ARFLAGS conftest.a func.o ) 2>&AC_FD_CC 1>/dev/null
1561         fi
1562         rm -f conftest.$ac_ext func.o
1563         ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
1564         cf_saveLIBS="$LIBS"
1565         LIBS="conftest.a $LIBS"
1566         AC_TRY_RUN([
1567         int main()
1568         {
1569                 extern int testfunc();
1570                 ${cf_cv_main_return:-return} (!testfunc());
1571         }
1572         ],
1573         [cf_cv_link_dataonly=yes],
1574         [cf_cv_link_dataonly=no],
1575         [cf_cv_link_dataonly=unknown])
1576         LIBS="$cf_saveLIBS"
1577         ])
1578 AC_MSG_RESULT($cf_cv_link_dataonly)
1579
1580 if test "$cf_cv_link_dataonly" = no ; then
1581         AC_DEFINE(BROKEN_LINKER)
1582         BROKEN_LINKER=1
1583 fi
1584
1585 ])dnl
1586 dnl ---------------------------------------------------------------------------
1587 dnl CF_LINK_FUNCS version: 7 updated: 2006/12/16 12:33:30
1588 dnl -------------
1589 dnl Most Unix systems have both link and symlink, a few don't have symlink.
1590 dnl A few non-Unix systems implement symlink, but not link.
1591 dnl A few non-systems implement neither (or have nonfunctional versions).
1592 AC_DEFUN([CF_LINK_FUNCS],
1593 [
1594 AC_CHECK_FUNCS( \
1595         remove \
1596         unlink )
1597
1598 if test "$cross_compiling" = yes ; then
1599         AC_CHECK_FUNCS( \
1600                 link \
1601                 symlink )
1602 else
1603         AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1604                 cf_cv_link_funcs=
1605                 for cf_func in link symlink ; do
1606                         AC_TRY_RUN([
1607 #include <sys/types.h>
1608 #include <sys/stat.h>
1609 #ifdef HAVE_UNISTD_H
1610 #include <unistd.h>
1611 #endif
1612 int main()
1613 {
1614         int fail = 0;
1615         char *src = "config.log";
1616         char *dst = "conftest.chk";
1617         struct stat src_sb;
1618         struct stat dst_sb;
1619
1620         stat(src, &src_sb);
1621         fail = ($cf_func("config.log", "conftest.chk") < 0)
1622             || (stat(dst, &dst_sb) < 0)
1623             || (dst_sb.st_mtime != src_sb.st_mtime);
1624 #ifdef HAVE_UNLINK
1625         unlink(dst);
1626 #else
1627         remove(dst);
1628 #endif
1629         ${cf_cv_main_return:-return} (fail);
1630 }
1631                         ],[
1632                         cf_cv_link_funcs="$cf_cv_link_funcs $cf_func"
1633                         eval 'ac_cv_func_'$cf_func'=yes'],[
1634                         eval 'ac_cv_func_'$cf_func'=no'],[
1635                         eval 'ac_cv_func_'$cf_func'=error'])
1636                 done
1637                 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1638         ])
1639         test "$ac_cv_func_link"    = yes && AC_DEFINE(HAVE_LINK)
1640         test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
1641 fi
1642 ])dnl
1643 dnl ---------------------------------------------------------------------------
1644 dnl CF_MAIN_RETURN version: 1 updated: 2006/12/10 09:51:54
1645 dnl --------------
1646 dnl Check if a return from main to the shell actually returns the same exit
1647 dnl code.  This is true for almost any POSIX environment.
1648 dnl
1649 dnl Some very old environments did not flush stdout, etc., on an exit.  That
1650 dnl would be a useful case to test for also.
1651 AC_DEFUN([CF_MAIN_RETURN],
1652 [
1653 cf_cv_main_return=return
1654 ])dnl
1655 dnl ---------------------------------------------------------------------------
1656 dnl CF_MAKEFLAGS version: 12 updated: 2006/10/21 08:27:03
1657 dnl ------------
1658 dnl Some 'make' programs support ${MAKEFLAGS}, some ${MFLAGS}, to pass 'make'
1659 dnl options to lower-levels.  It's very useful for "make -n" -- if we have it.
1660 dnl (GNU 'make' does both, something POSIX 'make', which happens to make the
1661 dnl ${MAKEFLAGS} variable incompatible because it adds the assignments :-)
1662 AC_DEFUN([CF_MAKEFLAGS],
1663 [
1664 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
1665         cf_cv_makeflags=''
1666         for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
1667         do
1668                 cat >cf_makeflags.tmp <<CF_EOF
1669 SHELL = /bin/sh
1670 all :
1671         @ echo '.$cf_option'
1672 CF_EOF
1673                 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[       ]]*$,,'`
1674                 case "$cf_result" in
1675                 .*k)
1676                         cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null`
1677                         case "$cf_result" in
1678                         .*CC=*) cf_cv_makeflags=
1679                                 ;;
1680                         *)      cf_cv_makeflags=$cf_option
1681                                 ;;
1682                         esac
1683                         break
1684                         ;;
1685                 .-)     ;;
1686                 *)      echo "given option \"$cf_option\", no match \"$cf_result\""
1687                         ;;
1688                 esac
1689         done
1690         rm -f cf_makeflags.tmp
1691 ])
1692
1693 AC_SUBST(cf_cv_makeflags)
1694 ])dnl
1695 dnl ---------------------------------------------------------------------------
1696 dnl CF_MAKE_TAGS version: 5 updated: 2010/04/03 20:07:32
1697 dnl ------------
1698 dnl Generate tags/TAGS targets for makefiles.  Do not generate TAGS if we have
1699 dnl a monocase filesystem.
1700 AC_DEFUN([CF_MAKE_TAGS],[
1701 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1702
1703 AC_CHECK_PROGS(CTAGS, exctags ctags)
1704 AC_CHECK_PROGS(ETAGS, exetags etags)
1705
1706 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS-ctags}, yes, no)
1707
1708 if test "$cf_cv_mixedcase" = yes ; then
1709         AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS-etags}, yes, no)
1710 else
1711         MAKE_UPPER_TAGS=no
1712 fi
1713
1714 if test "$MAKE_UPPER_TAGS" = yes ; then
1715         MAKE_UPPER_TAGS=
1716 else
1717         MAKE_UPPER_TAGS="#"
1718 fi
1719
1720 if test "$MAKE_LOWER_TAGS" = yes ; then
1721         MAKE_LOWER_TAGS=
1722 else
1723         MAKE_LOWER_TAGS="#"
1724 fi
1725
1726 AC_SUBST(CTAGS)
1727 AC_SUBST(ETAGS)
1728
1729 AC_SUBST(MAKE_UPPER_TAGS)
1730 AC_SUBST(MAKE_LOWER_TAGS)
1731 ])dnl
1732 dnl ---------------------------------------------------------------------------
1733 dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
1734 dnl ----------------------
1735 dnl Check if the file-system supports mixed-case filenames.  If we're able to
1736 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1737 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1738 [
1739 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1740 if test "$cross_compiling" = yes ; then
1741         case $target_alias in #(vi
1742         *-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-mingw32*|*-uwin*) #(vi
1743                 cf_cv_mixedcase=no
1744                 ;;
1745         *)
1746                 cf_cv_mixedcase=yes
1747                 ;;
1748         esac
1749 else
1750         rm -f conftest CONFTEST
1751         echo test >conftest
1752         if test -f CONFTEST ; then
1753                 cf_cv_mixedcase=no
1754         else
1755                 cf_cv_mixedcase=yes
1756         fi
1757         rm -f conftest CONFTEST
1758 fi
1759 ])
1760 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1761 ])dnl
1762 dnl ---------------------------------------------------------------------------
1763 dnl CF_MKSTEMP version: 6 updated: 2010/05/22 14:44:30
1764 dnl ----------
1765 dnl Check for a working mkstemp.  This creates two files, checks that they are
1766 dnl successfully created and distinct (AmigaOS apparently fails on the last).
1767 AC_DEFUN([CF_MKSTEMP],[
1768 AC_CACHE_CHECK(for working mkstemp, cf_cv_func_mkstemp,[
1769 rm -f conftest*
1770 AC_TRY_RUN([
1771 #include <sys/types.h>
1772 #include <stdlib.h>
1773 #include <stdio.h>
1774 #include <string.h>
1775 #include <sys/stat.h>
1776 int main()
1777 {
1778         char *tmpl = "conftestXXXXXX";
1779         char name[2][80];
1780         int n;
1781         int result = 0;
1782         int fd;
1783         struct stat sb;
1784
1785         umask(077);
1786         for (n = 0; n < 2; ++n) {
1787                 strcpy(name[n], tmpl);
1788                 if ((fd = mkstemp(name[n])) >= 0) {
1789                         if (!strcmp(name[n], tmpl)
1790                          || stat(name[n], &sb) != 0
1791                          || (sb.st_mode & S_IFMT) != S_IFREG
1792                          || (sb.st_mode & 077) != 0) {
1793                                 result = 1;
1794                         }
1795                         close(fd);
1796                 }
1797         }
1798         if (result == 0
1799          && !strcmp(name[0], name[1]))
1800                 result = 1;
1801         ${cf_cv_main_return:-return}(result);
1802 }
1803 ],[cf_cv_func_mkstemp=yes
1804 ],[cf_cv_func_mkstemp=no
1805 ],[AC_CHECK_FUNC(mkstemp)
1806 ])
1807 ])
1808 if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
1809         AC_DEFINE(HAVE_MKSTEMP)
1810 fi
1811 ])dnl
1812 dnl ---------------------------------------------------------------------------
1813 dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
1814 dnl ----------
1815 dnl Write a debug message to config.log, along with the line number in the
1816 dnl configure script.
1817 AC_DEFUN([CF_MSG_LOG],[
1818 echo "${as_me-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1819 ])dnl
1820 dnl ---------------------------------------------------------------------------
1821 dnl CF_NCURSES_ADDON version: 2 updated: 2010/02/27 18:27:44
1822 dnl ----------------
1823 dnl Configure an ncurses add-on, built outside the ncurses tree.
1824 AC_DEFUN([CF_NCURSES_ADDON],[
1825
1826 AC_PROVIDE([CF_SUBST_NCURSES_VERSION])
1827
1828 AC_MSG_CHECKING(if you want wide-character code)
1829 AC_ARG_ENABLE(widec,
1830         [  --enable-widec          compile with wide-char/UTF-8 code],
1831         [with_widec=$enableval],
1832         [with_widec=no])
1833 AC_MSG_RESULT($with_widec)
1834 if test "$with_widec" = yes ; then
1835         CF_UTF8_LIB 
1836         CF_NCURSES_CONFIG(ncursesw)
1837 else
1838         CF_NCURSES_CONFIG(ncurses)
1839 fi
1840
1841 if test "$NCURSES_CONFIG" != none ; then
1842
1843 cf_version=`$NCURSES_CONFIG --version`
1844
1845 NCURSES_MAJOR=`echo "$cf_version" | sed -e 's/\..*//'`
1846 NCURSES_MINOR=`echo "$cf_version" | sed -e 's/^[[0-9]]\+\.//' -e 's/\..*//'`
1847 NCURSES_PATCH=`echo "$cf_version" | sed -e 's/^[[0-9]]\+\.[[0-9]]\+\.//'`
1848
1849 # ABI version is not available from headers
1850 cf_cv_abi_version=`$NCURSES_CONFIG --abi-version`
1851
1852 else
1853
1854 for cf_name in MAJOR MINOR PATCH
1855 do
1856 cat >conftest.$ac_ext <<CF_EOF
1857 #include <${cf_cv_ncurses_header-curses.h}>
1858 AUTOCONF_$cf_name NCURSES_VERSION_$cf_name
1859 CF_EOF
1860         cf_try="$ac_cpp conftest.$ac_ext 2>&5 | fgrep AUTOCONF_$cf_name >conftest.out"
1861         AC_TRY_EVAL(cf_try)
1862         if test -f conftest.out ; then
1863                 cf_result=`cat conftest.out | sed -e "s/^.*AUTOCONF_$cf_name[[  ]]\+//"`
1864                 eval NCURSES_$cf_name=$cf_result
1865                 cat conftest.$ac_ext
1866                 cat conftest.out
1867         fi
1868 done
1869
1870 cf_cv_abi_version=${NCURSES_MAJOR}
1871
1872 fi
1873
1874 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
1875
1876 dnl Show the computed version, for logging
1877 cf_cv_timestamp=`date`
1878
1879 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
1880
1881 dnl We need these values in the generated headers
1882 AC_SUBST(NCURSES_MAJOR)
1883 AC_SUBST(NCURSES_MINOR)
1884 AC_SUBST(NCURSES_PATCH)
1885
1886 dnl We need these values in the generated makefiles
1887 AC_SUBST(cf_cv_rel_version)
1888 AC_SUBST(cf_cv_abi_version)
1889
1890 dnl FIXME - not needed for Ada95
1891 AC_SUBST(cf_cv_builtin_bool)
1892 AC_SUBST(cf_cv_header_stdbool_h)
1893 AC_SUBST(cf_cv_type_of_bool)dnl
1894
1895 ])
1896 dnl ---------------------------------------------------------------------------
1897 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1898 dnl -------------------
1899 dnl Check if we can compile with ncurses' header file
1900 dnl $1 is the cache variable to set
1901 dnl $2 is the header-file to include
1902 dnl $3 is the root name (ncurses or ncursesw)
1903 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1904         AC_TRY_COMPILE([
1905 ]ifelse($3,ncursesw,[
1906 #define _XOPEN_SOURCE_EXTENDED
1907 #undef  HAVE_LIBUTF8_H  /* in case we used CF_UTF8_LIB */
1908 #define HAVE_LIBUTF8_H  /* to force ncurses' header file to use cchar_t */
1909 ])[
1910 #include <$2>],[
1911 #ifdef NCURSES_VERSION
1912 ]ifelse($3,ncursesw,[
1913 #ifndef WACS_BSSB
1914         make an error
1915 #endif
1916 ])[
1917 printf("%s\n", NCURSES_VERSION);
1918 #else
1919 #ifdef __NCURSES_H
1920 printf("old\n");
1921 #else
1922         make an error
1923 #endif
1924 #endif
1925         ]
1926         ,[$1=$2]
1927         ,[$1=no])
1928 ])dnl
1929 dnl ---------------------------------------------------------------------------
1930 dnl CF_NCURSES_CONFIG version: 6 updated: 2010/04/28 06:02:16
1931 dnl -----------------
1932 dnl Tie together the configure-script macros for ncurses.
1933 dnl Prefer the "-config" script from ncurses 5.6, to simplify analysis.
1934 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
1935 dnl
1936 dnl $1 is the root library name (default: "ncurses")
1937 AC_DEFUN([CF_NCURSES_CONFIG],
1938 [
1939 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1940
1941 echo "Looking for ${cf_ncuconfig_root}-config"
1942 AC_PATH_PROGS(NCURSES_CONFIG,${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config,none)
1943
1944 if test "$NCURSES_CONFIG" != none ; then
1945
1946 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1947 LIBS="`$NCURSES_CONFIG --libs` $LIBS"
1948
1949 # even with config script, some packages use no-override for curses.h
1950 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
1951
1952 dnl like CF_NCURSES_CPPFLAGS
1953 AC_DEFINE(NCURSES)
1954
1955 dnl like CF_NCURSES_LIBS
1956 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1957 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1958
1959 dnl like CF_NCURSES_VERSION
1960 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1961
1962 else
1963
1964 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1965 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1966
1967 fi
1968 ])dnl
1969 dnl ---------------------------------------------------------------------------
1970 dnl CF_NCURSES_CPPFLAGS version: 19 updated: 2007/07/29 13:35:20
1971 dnl -------------------
1972 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1973 dnl the CPPFLAGS variable so we can include its header.
1974 dnl
1975 dnl The header files may be installed as either curses.h, or ncurses.h (would
1976 dnl be obsolete, except that some packagers prefer this name to distinguish it
1977 dnl from a "native" curses implementation).  If not installed for overwrite,
1978 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
1979 dnl /usr/include/ncurses), but someone may have installed overwriting the
1980 dnl vendor's curses.  Only very old versions (pre-1.9.2d, the first autoconf'd
1981 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
1982 dnl the header.
1983 dnl
1984 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
1985 dnl is already in the include-path, don't even bother with this, since we cannot
1986 dnl easily determine which file it is.  In this case, it has to be <curses.h>.
1987 dnl
1988 dnl The optional parameter gives the root name of the library, in case it is
1989 dnl not installed as the default curses library.  That is how the
1990 dnl wide-character version of ncurses is installed.
1991 AC_DEFUN([CF_NCURSES_CPPFLAGS],
1992 [AC_REQUIRE([CF_WITH_CURSES_DIR])
1993
1994 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1995 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
1996
1997 test -n "$cf_cv_curses_dir" && \
1998 test "$cf_cv_curses_dir" != "no" && { \
1999   CF_ADD_INCDIR($cf_cv_curses_dir/include $cf_cv_curses_dir/include/$cf_ncuhdr_root)
2000 }
2001
2002 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2003         cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2004         ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2005         for cf_header in $cf_header_list
2006         do
2007                 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2008                 test "$cf_cv_ncurses_h" != no && break
2009         done
2010 ])
2011
2012 CF_NCURSES_HEADER
2013 CF_TERM_HEADER
2014
2015 # some applications need this, but should check for NCURSES_VERSION
2016 AC_DEFINE(NCURSES)
2017
2018 CF_NCURSES_VERSION
2019 ])dnl
2020 dnl ---------------------------------------------------------------------------
2021 dnl CF_NCURSES_HEADER version: 2 updated: 2008/03/23 14:48:54
2022 dnl -----------------
2023 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2024 dnl variations of ncurses' installs.
2025 dnl
2026 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2027 AC_DEFUN([CF_NCURSES_HEADER],[
2028
2029 if test "$cf_cv_ncurses_h" != no ; then
2030         cf_cv_ncurses_header=$cf_cv_ncurses_h
2031 else
2032
2033 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2034         test -n "$verbose" && echo
2035         CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2036         test -n "$verbose" && echo search path $cf_search
2037         cf_save2_CPPFLAGS="$CPPFLAGS"
2038         for cf_incdir in $cf_search
2039         do
2040                 CF_ADD_INCDIR($cf_incdir)
2041                 for cf_header in \
2042                         ncurses.h \
2043                         curses.h
2044                 do
2045                         CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2046                         if test "$cf_cv_ncurses_h2" != no ; then
2047                                 cf_cv_ncurses_h2=$cf_incdir/$cf_header
2048                                 test -n "$verbose" && echo $ac_n "      ... found $ac_c" 1>&AC_FD_MSG
2049                                 break
2050                         fi
2051                         test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2052                 done
2053                 CPPFLAGS="$cf_save2_CPPFLAGS"
2054                 test "$cf_cv_ncurses_h2" != no && break
2055         done
2056         test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2057         ])
2058
2059         CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2060         cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2061         if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2062                 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2063         fi
2064         CF_ADD_INCDIR($cf_1st_incdir)
2065
2066 fi
2067
2068 # Set definitions to allow ifdef'ing for ncurses.h
2069
2070 case $cf_cv_ncurses_header in # (vi
2071 *ncurses.h)
2072         AC_DEFINE(HAVE_NCURSES_H)
2073         ;;
2074 esac
2075
2076 case $cf_cv_ncurses_header in # (vi
2077 ncurses/curses.h|ncurses/ncurses.h)
2078         AC_DEFINE(HAVE_NCURSES_NCURSES_H)
2079         ;;
2080 ncursesw/curses.h|ncursesw/ncurses.h)
2081         AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
2082         ;;
2083 esac
2084
2085 ])dnl
2086 dnl ---------------------------------------------------------------------------
2087 dnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
2088 dnl ---------------
2089 dnl Look for the ncurses library.  This is a little complicated on Linux,
2090 dnl because it may be linked with the gpm (general purpose mouse) library.
2091 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2092 dnl unusable with ncurses.  However, we don't want to link with gpm unless
2093 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2094 dnl and the linker will record a dependency.
2095 dnl
2096 dnl The optional parameter gives the root name of the library, in case it is
2097 dnl not installed as the default curses library.  That is how the
2098 dnl wide-character version of ncurses is installed.
2099 AC_DEFUN([CF_NCURSES_LIBS],
2100 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2101
2102 cf_nculib_root=ifelse($1,,ncurses,$1)
2103         # This works, except for the special case where we find gpm, but
2104         # ncurses is in a nonstandard location via $LIBS, and we really want
2105         # to link gpm.
2106 cf_ncurses_LIBS=""
2107 cf_ncurses_SAVE="$LIBS"
2108 AC_CHECK_LIB(gpm,Gpm_Open,
2109         [AC_CHECK_LIB(gpm,initscr,
2110                 [LIBS="$cf_ncurses_SAVE"],
2111                 [cf_ncurses_LIBS="-lgpm"])])
2112
2113 case $host_os in #(vi
2114 freebsd*)
2115         # This is only necessary if you are linking against an obsolete
2116         # version of ncurses (but it should do no harm, since it's static).
2117         if test "$cf_nculib_root" = ncurses ; then
2118                 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2119         fi
2120         ;;
2121 esac
2122
2123 LIBS="$cf_ncurses_LIBS $LIBS"
2124
2125 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2126 then
2127         CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
2128         LIBS="-l$cf_nculib_root $LIBS"
2129 else
2130         CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2131                 [#include <${cf_cv_ncurses_header-curses.h}>],
2132                 [initscr()],
2133                 initscr)
2134 fi
2135
2136 if test -n "$cf_ncurses_LIBS" ; then
2137         AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2138         cf_ncurses_SAVE="$LIBS"
2139         for p in $cf_ncurses_LIBS ; do
2140                 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2141                 if test "$q" != "$LIBS" ; then
2142                         LIBS="$q"
2143                 fi
2144         done
2145         AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
2146                 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2147                 [AC_MSG_RESULT(yes)],
2148                 [AC_MSG_RESULT(no)
2149                  LIBS="$cf_ncurses_SAVE"])
2150 fi
2151
2152 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2153 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2154 ])dnl
2155 dnl ---------------------------------------------------------------------------
2156 dnl CF_NCURSES_VERSION version: 12 updated: 2007/04/28 09:15:55
2157 dnl ------------------
2158 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2159 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS.  We don't use
2160 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2161 AC_DEFUN([CF_NCURSES_VERSION],
2162 [
2163 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2164 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2165         cf_cv_ncurses_version=no
2166         cf_tempfile=out$$
2167         rm -f $cf_tempfile
2168         AC_TRY_RUN([
2169 #include <${cf_cv_ncurses_header-curses.h}>
2170 #include <stdio.h>
2171 int main()
2172 {
2173         FILE *fp = fopen("$cf_tempfile", "w");
2174 #ifdef NCURSES_VERSION
2175 # ifdef NCURSES_VERSION_PATCH
2176         fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2177 # else
2178         fprintf(fp, "%s\n", NCURSES_VERSION);
2179 # endif
2180 #else
2181 # ifdef __NCURSES_H
2182         fprintf(fp, "old\n");
2183 # else
2184         make an error
2185 # endif
2186 #endif
2187         ${cf_cv_main_return-return}(0);
2188 }],[
2189         cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2190
2191         # This will not work if the preprocessor splits the line after the
2192         # Autoconf token.  The 'unproto' program does that.
2193         cat > conftest.$ac_ext <<EOF
2194 #include <${cf_cv_ncurses_header-curses.h}>
2195 #undef Autoconf
2196 #ifdef NCURSES_VERSION
2197 Autoconf NCURSES_VERSION
2198 #else
2199 #ifdef __NCURSES_H
2200 Autoconf "old"
2201 #endif
2202 ;
2203 #endif
2204 EOF
2205         cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2206         AC_TRY_EVAL(cf_try)
2207         if test -f conftest.out ; then
2208                 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2209                 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2210                 rm -f conftest.out
2211         fi
2212 ])
2213         rm -f $cf_tempfile
2214 ])
2215 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
2216 ])dnl
2217 dnl ---------------------------------------------------------------------------
2218 dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
2219 dnl ------------------
2220 dnl see CF_WITH_NO_LEAKS
2221 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2222 AC_MSG_CHECKING(if you want to use $1 for testing)
2223 AC_ARG_WITH($1,
2224         [$2],
2225         [AC_DEFINE($3)ifelse([$4],,[
2226          $4
2227 ])
2228         : ${with_cflags:=-g}
2229         : ${with_no_leaks:=yes}
2230          with_$1=yes],
2231         [with_$1=])
2232 AC_MSG_RESULT(${with_$1:-no})
2233
2234 case .$with_cflags in #(vi
2235 .*-g*)
2236         case .$CFLAGS in #(vi
2237         .*-g*) #(vi
2238                 ;;
2239         *)
2240                 CF_ADD_CFLAGS([-g])
2241                 ;;
2242         esac
2243         ;;
2244 esac
2245 ])dnl
2246 dnl ---------------------------------------------------------------------------
2247 dnl CF_NUMBER_SYNTAX version: 1 updated: 2003/09/20 18:12:49
2248 dnl ----------------
2249 dnl Check if the given variable is a number.  If not, report an error.
2250 dnl $1 is the variable
2251 dnl $2 is the message
2252 AC_DEFUN([CF_NUMBER_SYNTAX],[
2253 if test -n "$1" ; then
2254   case $1 in #(vi
2255   [[0-9]]*) #(vi
2256         ;;
2257   *)
2258         AC_MSG_ERROR($2 is not a number: $1)
2259         ;;
2260   esac
2261 else
2262   AC_MSG_ERROR($2 value is empty)
2263 fi
2264 ])dnl
2265 dnl ---------------------------------------------------------------------------
2266 dnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
2267 dnl -------------
2268 dnl Compute the object-directory name from the given model name
2269 AC_DEFUN([CF_OBJ_SUBDIR],
2270 [
2271         case $1 in
2272         libtool) $2='obj_lo'  ;;
2273         normal)  $2='objects' ;;
2274         debug)   $2='obj_g' ;;
2275         profile) $2='obj_p' ;;
2276         shared)
2277                 case $cf_cv_system_name in #(vi
2278                 cygwin) #(vi
2279                         $2='objects' ;;
2280                 *)
2281                         $2='obj_s' ;;
2282                 esac
2283         esac
2284 ])dnl
2285 dnl ---------------------------------------------------------------------------
2286 dnl CF_PATHSEP version: 5 updated: 2010/05/26 05:38:42
2287 dnl ----------
2288 dnl Provide a value for the $PATH and similar separator
2289 AC_DEFUN([CF_PATHSEP],
2290 [
2291         case $cf_cv_system_name in
2292         os2*)   PATH_SEPARATOR=';'  ;;
2293         *)      PATH_SEPARATOR=':'  ;;
2294         esac
2295 ifelse([$1],,,[$1=$PATH_SEPARATOR])
2296         AC_SUBST(PATH_SEPARATOR)
2297 ])dnl
2298 dnl ---------------------------------------------------------------------------
2299 dnl CF_PATH_SYNTAX version: 13 updated: 2010/05/26 05:38:42
2300 dnl --------------
2301 dnl Check the argument to see that it looks like a pathname.  Rewrite it if it
2302 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2303 dnl result begins with 'NONE'.  This is necessary to work around autoconf's
2304 dnl delayed evaluation of those symbols.
2305 AC_DEFUN([CF_PATH_SYNTAX],[
2306 if test "x$prefix" != xNONE; then
2307   cf_path_syntax="$prefix"
2308 else
2309   cf_path_syntax="$ac_default_prefix"
2310 fi
2311
2312 case ".[$]$1" in #(vi
2313 .\[$]\(*\)*|.\'*\'*) #(vi
2314   ;;
2315 ..|./*|.\\*) #(vi
2316   ;;
2317 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
2318   ;;
2319 .\[$]{*prefix}*) #(vi
2320   eval $1="[$]$1"
2321   case ".[$]$1" in #(vi
2322   .NONE/*)
2323     $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2324     ;;
2325   esac
2326   ;; #(vi
2327 .no|.NONE/*)
2328   $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2329   ;;
2330 *)
2331   ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2332   ;;
2333 esac
2334 ])dnl
2335 dnl ---------------------------------------------------------------------------
2336 dnl CF_PKG_CONFIG version: 3 updated: 2009/01/25 10:55:09
2337 dnl -------------
2338 dnl Check for the package-config program, unless disabled by command-line.
2339 AC_DEFUN([CF_PKG_CONFIG],
2340 [
2341 AC_MSG_CHECKING(if you want to use pkg-config)
2342 AC_ARG_WITH(pkg-config,
2343         [  --with-pkg-config{=path} enable/disable use of pkg-config],
2344         [cf_pkg_config=$withval],
2345         [cf_pkg_config=yes])
2346 AC_MSG_RESULT($cf_pkg_config)
2347
2348 case $cf_pkg_config in #(vi
2349 no) #(vi
2350         PKG_CONFIG=none
2351         ;;
2352 yes) #(vi
2353         AC_PATH_PROG(PKG_CONFIG, pkg-config, none)
2354         ;;
2355 *)
2356         PKG_CONFIG=$withval
2357         ;;
2358 esac
2359
2360 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2361 if test "$PKG_CONFIG" != none ; then
2362         CF_PATH_SYNTAX(PKG_CONFIG)
2363 fi
2364
2365 AC_SUBST(PKG_CONFIG)
2366 ])dnl
2367 dnl ---------------------------------------------------------------------------
2368 dnl CF_POSIX_C_SOURCE version: 8 updated: 2010/05/26 05:38:42
2369 dnl -----------------
2370 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2371 dnl
2372 dnl     POSIX.1-1990                            _POSIX_SOURCE
2373 dnl     POSIX.1-1990 and                        _POSIX_SOURCE and
2374 dnl             POSIX.2-1992 C-Language                 _POSIX_C_SOURCE=2
2375 dnl             Bindings Option
2376 dnl     POSIX.1b-1993                           _POSIX_C_SOURCE=199309L
2377 dnl     POSIX.1c-1996                           _POSIX_C_SOURCE=199506L
2378 dnl     X/Open 2000                             _POSIX_C_SOURCE=200112L
2379 dnl
2380 dnl Parameters:
2381 dnl     $1 is the nominal value for _POSIX_C_SOURCE
2382 AC_DEFUN([CF_POSIX_C_SOURCE],
2383 [
2384 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2385
2386 cf_save_CFLAGS="$CFLAGS"
2387 cf_save_CPPFLAGS="$CPPFLAGS"
2388
2389 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2390 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2391
2392 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2393         CF_MSG_LOG(if the symbol is already defined go no further)
2394         AC_TRY_COMPILE([#include <sys/types.h>],[
2395 #ifndef _POSIX_C_SOURCE
2396 make an error
2397 #endif],
2398         [cf_cv_posix_c_source=no],
2399         [cf_want_posix_source=no
2400          case .$cf_POSIX_C_SOURCE in #(vi
2401          .[[12]]??*) #(vi
2402                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2403                 ;;
2404          .2) #(vi
2405                 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2406                 cf_want_posix_source=yes
2407                 ;;
2408          .*)
2409                 cf_want_posix_source=yes
2410                 ;;
2411          esac
2412          if test "$cf_want_posix_source" = yes ; then
2413                 AC_TRY_COMPILE([#include <sys/types.h>],[
2414 #ifdef _POSIX_SOURCE
2415 make an error
2416 #endif],[],
2417                 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2418          fi
2419          CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2420          CFLAGS="$cf_trim_CFLAGS"
2421          CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2422          CF_MSG_LOG(if the second compile does not leave our definition intact error)
2423          AC_TRY_COMPILE([#include <sys/types.h>],[
2424 #ifndef _POSIX_C_SOURCE
2425 make an error
2426 #endif],,
2427          [cf_cv_posix_c_source=no])
2428          CFLAGS="$cf_save_CFLAGS"
2429          CPPFLAGS="$cf_save_CPPFLAGS"
2430         ])
2431 ])
2432
2433 if test "$cf_cv_posix_c_source" != no ; then
2434         CFLAGS="$cf_trim_CFLAGS"
2435         CPPFLAGS="$cf_trim_CPPFLAGS"
2436         CF_ADD_CFLAGS($cf_cv_posix_c_source)
2437 fi
2438
2439 ])dnl
2440 dnl ---------------------------------------------------------------------------
2441 dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
2442 dnl ----------
2443 dnl Check for archiver "ar".
2444 AC_DEFUN([CF_PROG_AR],[
2445 AC_CHECK_TOOL(AR, ar, ar)
2446 ])
2447 dnl ---------------------------------------------------------------------------
2448 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
2449 dnl -----------
2450 dnl Check for awk, ensure that the check found something.
2451 AC_DEFUN([CF_PROG_AWK],
2452 [
2453 AC_PROG_AWK
2454 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
2455 ])dnl
2456 dnl ---------------------------------------------------------------------------
2457 dnl CF_PROG_CC_C_O version: 2 updated: 2006/12/16 15:55:46
2458 dnl --------------
2459 dnl Analogous to AC_PROG_CC_C_O, but more useful: tests only $CC, ensures that
2460 dnl the output file can be renamed, and allows for a shell variable that can
2461 dnl be used later.  The parameter is either CC or CXX.  The result is the
2462 dnl cache variable:
2463 dnl     $cf_cv_prog_CC_c_o
2464 dnl     $cf_cv_prog_CXX_c_o
2465 AC_DEFUN([CF_PROG_CC_C_O],
2466 [AC_REQUIRE([AC_PROG_CC])dnl
2467 AC_MSG_CHECKING([whether [$]$1 understands -c and -o together])
2468 AC_CACHE_VAL(cf_cv_prog_$1_c_o,
2469 [
2470 cat > conftest.$ac_ext <<CF_EOF
2471 #include <stdio.h>
2472 int main()
2473 {
2474         ${cf_cv_main_return:-return}(0);
2475 }
2476 CF_EOF
2477 # We do the test twice because some compilers refuse to overwrite an
2478 # existing .o file with -o, though they will create one.
2479 ac_try='[$]$1 -c conftest.$ac_ext -o conftest2.$ac_objext >&AC_FD_CC'
2480 if AC_TRY_EVAL(ac_try) &&
2481   test -f conftest2.$ac_objext && AC_TRY_EVAL(ac_try);
2482 then
2483   eval cf_cv_prog_$1_c_o=yes
2484 else
2485   eval cf_cv_prog_$1_c_o=no
2486 fi
2487 rm -f conftest*
2488 ])dnl
2489 if test $cf_cv_prog_$1_c_o = yes; then
2490   AC_MSG_RESULT([yes])
2491 else
2492   AC_MSG_RESULT([no])
2493 fi
2494 ])dnl
2495 dnl ---------------------------------------------------------------------------
2496 dnl CF_PROG_EGREP version: 1 updated: 2006/09/16 11:40:59
2497 dnl -------------
2498 dnl AC_PROG_EGREP was introduced in autoconf 2.53.
2499 dnl This macro adds a check to ensure the script found something.
2500 AC_DEFUN([CF_PROG_EGREP],
2501 [AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
2502    [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
2503     then ac_cv_prog_egrep='grep -E'
2504     else ac_cv_prog_egrep='egrep'
2505     fi])
2506  EGREP=$ac_cv_prog_egrep
2507  AC_SUBST([EGREP])
2508 test -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
2509 ])dnl
2510 dnl ---------------------------------------------------------------------------
2511 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
2512 dnl -----------
2513 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
2514 AC_DEFUN([CF_PROG_EXT],
2515 [
2516 AC_REQUIRE([CF_CHECK_CACHE])
2517 case $cf_cv_system_name in
2518 os2*)
2519     CFLAGS="$CFLAGS -Zmt"
2520     CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
2521     CXXFLAGS="$CXXFLAGS -Zmt"
2522     # autoconf's macro sets -Zexe and suffix both, which conflict:w
2523     LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
2524     ac_cv_exeext=.exe
2525     ;;
2526 esac
2527
2528 AC_EXEEXT
2529 AC_OBJEXT
2530
2531 PROG_EXT="$EXEEXT"
2532 AC_SUBST(PROG_EXT)
2533 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
2534 ])dnl
2535 dnl ---------------------------------------------------------------------------
2536 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2537 dnl ----------------
2538 dnl Remove all -U and -D options that refer to the given symbol from a list
2539 dnl of C compiler options.  This works around the problem that not all
2540 dnl compilers process -U and -D options from left-to-right, so a -U option
2541 dnl cannot be used to cancel the effect of a preceding -D option.
2542 dnl
2543 dnl $1 = target (which could be the same as the source variable)
2544 dnl $2 = source (including '$')
2545 dnl $3 = symbol to remove
2546 define([CF_REMOVE_DEFINE],
2547 [
2548 $1=`echo "$2" | \
2549         sed     -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[[       ]]/ /g' \
2550                 -e 's/-[[UD]]'"$3"'\(=[[^       ]]*\)\?[$]//g'`
2551 ])dnl
2552 dnl ---------------------------------------------------------------------------
2553 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
2554 dnl -------------
2555 dnl Remove the given library from the symbol
2556 dnl
2557 dnl $1 = target (which could be the same as the source variable)
2558 dnl $2 = source (including '$')
2559 dnl $3 = library to remove
2560 define([CF_REMOVE_LIB],
2561 [
2562 # remove $3 library from $2
2563 $1=`echo "$2" | sed -e 's/-l$3[[        ]]//g' -e 's/-l$3[$]//'`
2564 ])dnl
2565 dnl ---------------------------------------------------------------------------
2566 dnl CF_SHARED_OPTS version: 64 updated: 2010/06/05 16:51:16
2567 dnl --------------
2568 dnl --------------
2569 dnl Attempt to determine the appropriate CC/LD options for creating a shared
2570 dnl library.
2571 dnl
2572 dnl Note: ${LOCAL_LDFLAGS} is used to link executables that will run within the
2573 dnl build-tree, i.e., by making use of the libraries that are compiled in ../lib
2574 dnl We avoid compiling-in a ../lib path for the shared library since that can
2575 dnl lead to unexpected results at runtime.
2576 dnl ${LOCAL_LDFLAGS2} has the same intention but assumes that the shared libraries
2577 dnl are compiled in ../../lib
2578 dnl
2579 dnl The variable 'cf_cv_do_symlinks' is used to control whether we configure
2580 dnl to install symbolic links to the rel/abi versions of shared libraries.
2581 dnl
2582 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
2583 dnl version when making symbolic links.
2584 dnl
2585 dnl The variable 'cf_cv_shlib_version_infix' controls whether shared library
2586 dnl version numbers are infix (ex: libncurses.<ver>.dylib) or postfix
2587 dnl (ex: libncurses.so.<ver>).
2588 dnl
2589 dnl Some loaders leave 'so_locations' lying around.  It's nice to clean up.
2590 AC_DEFUN([CF_SHARED_OPTS],
2591 [
2592         AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2593         AC_REQUIRE([CF_LD_RPATH_OPT])
2594         LOCAL_LDFLAGS=
2595         LOCAL_LDFLAGS2=
2596         LD_SHARED_OPTS=
2597         INSTALL_LIB="-m 644"
2598
2599         cf_cv_do_symlinks=no
2600         cf_ld_rpath_opt=
2601         test "$cf_cv_enable_rpath" = yes && cf_ld_rpath_opt="$LD_RPATH_OPT"
2602
2603         AC_MSG_CHECKING(if release/abi version should be used for shared libs)
2604         AC_ARG_WITH(shlib-version,
2605         [  --with-shlib-version=X  Specify rel or abi version for shared libs],
2606         [test -z "$withval" && withval=auto
2607         case $withval in #(vi
2608         yes) #(vi
2609                 cf_cv_shlib_version=auto
2610                 ;;
2611         rel|abi|auto|no) #(vi
2612                 cf_cv_shlib_version=$withval
2613                 ;;
2614         *)
2615                 AC_MSG_ERROR([option value must be one of: rel, abi, auto or no])
2616                 ;;
2617         esac
2618         ],[cf_cv_shlib_version=auto])
2619         AC_MSG_RESULT($cf_cv_shlib_version)
2620
2621         cf_cv_rm_so_locs=no
2622
2623         # Some less-capable ports of gcc support only -fpic
2624         CC_SHARED_OPTS=
2625         if test "$GCC" = yes
2626         then
2627                 AC_MSG_CHECKING(which $CC option to use)
2628                 cf_save_CFLAGS="$CFLAGS"
2629                 for CC_SHARED_OPTS in -fPIC -fpic ''
2630                 do
2631                         CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
2632                         AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
2633                 done
2634                 AC_MSG_RESULT($CC_SHARED_OPTS)
2635                 CFLAGS="$cf_save_CFLAGS"
2636         fi
2637
2638         cf_cv_shlib_version_infix=no
2639
2640         case $cf_cv_system_name in #(vi
2641         aix[[56]]*) #(vi
2642                 if test "$GCC" = yes; then
2643                         CC_SHARED_OPTS=
2644                         MK_SHARED_LIB='$(CC) -shared'
2645                 fi
2646                 ;;
2647         beos*) #(vi
2648                 MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
2649                 ;;
2650         cygwin*) #(vi
2651                 CC_SHARED_OPTS=
2652                 MK_SHARED_LIB='sh ../mk_shared_lib.sh [$]@ [$]{CC} [$]{CFLAGS}'
2653                 cf_cv_shlib_version=cygdll
2654                 cf_cv_shlib_version_infix=cygdll
2655                 cat >mk_shared_lib.sh <<-CF_EOF
2656                 #!/bin/sh
2657                 SHARED_LIB=\[$]1
2658                 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
2659                 shift
2660                 cat <<-EOF
2661                 Linking shared library
2662                 ** SHARED_LIB \[$]SHARED_LIB
2663                 ** IMPORT_LIB \[$]IMPORT_LIB
2664 EOF
2665                 exec \[$]* -shared -Wl,--out-implib=../lib/\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o ../lib/\[$]{SHARED_LIB}
2666 CF_EOF
2667                 chmod +x mk_shared_lib.sh
2668                 ;;
2669         darwin*) #(vi
2670                 EXTRA_CFLAGS="-no-cpp-precomp"
2671                 CC_SHARED_OPTS="-dynamic"
2672                 MK_SHARED_LIB='${CC} ${CFLAGS} -dynamiclib -install_name ${libdir}/`basename $[@]` -compatibility_version ${ABI_VERSION} -current_version ${ABI_VERSION} -o $[@]'
2673                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=abi
2674                 cf_cv_shlib_version_infix=yes
2675                 AC_CACHE_CHECK([if ld -search_paths_first works], cf_cv_ldflags_search_paths_first, [
2676                         cf_save_LDFLAGS=$LDFLAGS
2677                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
2678                         AC_TRY_LINK(, [int i;], cf_cv_ldflags_search_paths_first=yes, cf_cv_ldflags_search_paths_first=no)
2679                                 LDFLAGS=$cf_save_LDFLAGS])
2680                 if test $cf_cv_ldflags_search_paths_first = yes; then
2681                         LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
2682                 fi
2683                 ;;
2684         hpux*) #(vi
2685                 # (tested with gcc 2.7.2 -- I don't have c89)
2686                 if test "$GCC" = yes; then
2687                         LD_SHARED_OPTS='-Xlinker +b -Xlinker ${libdir}'
2688                 else
2689                         CC_SHARED_OPTS='+Z'
2690                         LD_SHARED_OPTS='-Wl,+b,${libdir}'
2691                 fi
2692                 MK_SHARED_LIB='${LD} +b ${libdir} -b -o $[@]'
2693                 # HP-UX shared libraries must be executable, and should be
2694                 # readonly to exploit a quirk in the memory manager.
2695                 INSTALL_LIB="-m 555"
2696                 ;;
2697         irix*) #(vi
2698                 if test "$cf_cv_enable_rpath" = yes ; then
2699                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2700                 fi
2701                 # tested with IRIX 5.2 and 'cc'.
2702                 if test "$GCC" != yes; then
2703                         CC_SHARED_OPTS='-KPIC'
2704                         MK_SHARED_LIB='${CC} -shared -rdata_shared -soname `basename $[@]` -o $[@]'
2705                 else
2706                         MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
2707                 fi
2708                 cf_cv_rm_so_locs=yes
2709                 ;;
2710         linux*|gnu*|k*bsd*-gnu) #(vi
2711                 if test "$DFT_LWR_MODEL" = "shared" ; then
2712                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
2713                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2714                 fi
2715                 if test "$cf_cv_enable_rpath" = yes ; then
2716                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2717                 fi
2718                 CF_SHARED_SONAME
2719                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
2720                 ;;
2721         openbsd[[2-9]].*) #(vi
2722                 if test "$DFT_LWR_MODEL" = "shared" ; then
2723                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
2724                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2725                 fi
2726                 if test "$cf_cv_enable_rpath" = yes ; then
2727                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2728                 fi
2729                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2730                 CF_SHARED_SONAME
2731                 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
2732                 ;;
2733         nto-qnx*|openbsd*|freebsd[[12]].*) #(vi
2734                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2735                 MK_SHARED_LIB='${LD} -Bshareable -o $[@]'
2736                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2737                 ;;
2738         freebsd*) #(vi
2739                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2740                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
2741                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
2742                         LOCAL_LDFLAGS2="${cf_ld_rpath_opt}\${libdir} $LOCAL_LDFLAGS"
2743                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2744                 fi
2745                 CF_SHARED_SONAME
2746                 MK_SHARED_LIB='${LD} -shared -Bshareable -soname=`basename $[@]` -o $[@]'
2747                 ;;
2748         netbsd*) #(vi
2749                 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2750                 if test "$DFT_LWR_MODEL" = "shared" && test "$cf_cv_enable_rpath" = yes ; then
2751                         LOCAL_LDFLAGS="${cf_ld_rpath_opt}\$(LOCAL_LIBDIR)"
2752                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2753                         EXTRA_LDFLAGS="${cf_ld_rpath_opt}\${libdir} $EXTRA_LDFLAGS"
2754                         if test "$cf_cv_shlib_version" = auto; then
2755                         if test -f /usr/libexec/ld.elf_so; then
2756                                 cf_cv_shlib_version=abi
2757                         else
2758                                 cf_cv_shlib_version=rel
2759                         fi
2760                         fi
2761                         CF_SHARED_SONAME
2762                         MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
2763                 else
2764                         MK_SHARED_LIB='${LD} -shared -Bshareable -o $[@]'
2765                 fi
2766                 ;;
2767         osf*|mls+*) #(vi
2768                 # tested with OSF/1 V3.2 and 'cc'
2769                 # tested with OSF/1 V3.2 and gcc 2.6.3 (but the c++ demo didn't
2770                 # link with shared libs).
2771                 MK_SHARED_LIB='${LD} -set_version ${REL_VERSION}:${ABI_VERSION} -expect_unresolved "*" -shared -soname `basename $[@]`'
2772                 case $host_os in #(vi
2773                 osf4*)
2774                         MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
2775                         ;;
2776                 esac
2777                 MK_SHARED_LIB="${MK_SHARED_LIB}"' -o $[@]'
2778                 if test "$DFT_LWR_MODEL" = "shared" ; then
2779                         LOCAL_LDFLAGS="${LD_RPATH_OPT}\$(LOCAL_LIBDIR)"
2780                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2781                 fi
2782                 cf_cv_rm_so_locs=yes
2783                 ;;
2784         sco3.2v5*)  # (also uw2* and UW7: hops 13-Apr-98
2785                 # tested with osr5.0.5
2786                 if test "$GCC" != yes; then
2787                         CC_SHARED_OPTS='-belf -KPIC'
2788                 fi
2789                 MK_SHARED_LIB='${LD} -dy -G -h `basename $[@] .${REL_VERSION}`.${ABI_VERSION} -o [$]@'
2790                 if test "$cf_cv_enable_rpath" = yes ; then
2791                         # only way is to set LD_RUN_PATH but no switch for it
2792                         RUN_PATH=$libdir
2793                 fi
2794                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2795                 LINK_PROGS='LD_RUN_PATH=${libdir}'
2796                 LINK_TESTS='Pwd=`pwd`;LD_RUN_PATH=`dirname $${Pwd}`/lib'
2797                 ;;
2798         sunos4*) #(vi
2799                 # tested with SunOS 4.1.1 and gcc 2.7.0
2800                 if test "$GCC" != yes; then
2801                         CC_SHARED_OPTS='-KPIC'
2802                 fi
2803                 MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
2804                 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
2805                 ;;
2806         solaris2*) #(vi
2807                 # tested with SunOS 5.5.1 (solaris 2.5.1) and gcc 2.7.2
2808                 # tested with SunOS 5.10 (solaris 10) and gcc 3.4.3
2809                 if test "$DFT_LWR_MODEL" = "shared" ; then
2810                         LOCAL_LDFLAGS="-R \$(LOCAL_LIBDIR):\${libdir}"
2811                         LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2812                 fi
2813                 if test "$cf_cv_enable_rpath" = yes ; then
2814                         EXTRA_LDFLAGS="-R \${libdir} $EXTRA_LDFLAGS"
2815                 fi
2816                 CF_SHARED_SONAME
2817                 if test "$GCC" != yes; then
2818                         cf_save_CFLAGS="$CFLAGS"
2819                         for cf_shared_opts in -xcode=pic32 -xcode=pic13 -KPIC -Kpic -O
2820                         do
2821                                 CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
2822                                 AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\n");],[break])
2823                         done
2824                         CFLAGS="$cf_save_CFLAGS"
2825                         CC_SHARED_OPTS=$cf_shared_opts
2826                         MK_SHARED_LIB='${CC} -dy -G -h '$cf_cv_shared_soname' -o $[@]'
2827                 else
2828                         MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
2829                 fi
2830                 ;;
2831         sysv5uw7*|unix_sv*) #(vi
2832                 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
2833                 if test "$GCC" != yes; then
2834                         CC_SHARED_OPTS='-KPIC'
2835                 fi
2836                 MK_SHARED_LIB='${LD} -d y -G -o [$]@'
2837                 ;;
2838         *)
2839                 CC_SHARED_OPTS='unknown'
2840                 MK_SHARED_LIB='echo unknown'
2841                 ;;
2842         esac
2843
2844         # This works if the last tokens in $MK_SHARED_LIB are the -o target.
2845         case "$cf_cv_shlib_version" in #(vi
2846         rel|abi)
2847                 case "$MK_SHARED_LIB" in #(vi
2848                 *'-o $[@]') #(vi
2849                         test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
2850                         ;;
2851                 *)
2852                         AC_MSG_WARN(ignored --with-shlib-version)
2853                         ;;
2854                 esac
2855                 ;;
2856         esac
2857
2858         if test -n "$cf_ld_rpath_opt" ; then
2859                 MK_SHARED_LIB="$MK_SHARED_LIB $cf_ld_rpath_opt\${libdir}"
2860         fi
2861
2862         AC_SUBST(CC_SHARED_OPTS)
2863         AC_SUBST(LD_RPATH_OPT)
2864         AC_SUBST(LD_SHARED_OPTS)
2865         AC_SUBST(MK_SHARED_LIB)
2866         AC_SUBST(LINK_PROGS)
2867         AC_SUBST(LINK_TESTS)
2868         AC_SUBST(EXTRA_LDFLAGS)
2869         AC_SUBST(LOCAL_LDFLAGS)
2870         AC_SUBST(LOCAL_LDFLAGS2)
2871         AC_SUBST(INSTALL_LIB)
2872 ])dnl
2873 dnl ---------------------------------------------------------------------------
2874 dnl CF_SHARED_SONAME version: 3 updated: 2008/09/08 18:34:43
2875 dnl ----------------
2876 dnl utility macro for CF_SHARED_OPTS, constructs "$cf_cv_shared_soname" for
2877 dnl substitution into MK_SHARED_LIB string for the "-soname" (or similar)
2878 dnl option.
2879 dnl
2880 dnl $1 is the default that should be used for "$cf_cv_shlib_version".
2881 dnl If missing, use "rel".
2882 define([CF_SHARED_SONAME],
2883 [
2884         test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=ifelse($1,,rel,$1)
2885         if test "$cf_cv_shlib_version" = rel; then
2886                 cf_cv_shared_soname='`basename $[@] .${REL_VERSION}`.${ABI_VERSION}'
2887         else
2888                 cf_cv_shared_soname='`basename $[@]`'
2889         fi
2890 ])
2891 dnl ---------------------------------------------------------------------------
2892 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
2893 dnl --------------
2894 dnl     Remove "-g" option from the compiler options
2895 AC_DEFUN([CF_STRIP_G_OPT],
2896 [$1=`echo ${$1} | sed -e 's%-g %%' -e 's%-g$%%'`])dnl
2897 dnl ---------------------------------------------------------------------------
2898 dnl CF_SUBDIR_PATH version: 6 updated: 2010/04/21 06:20:50
2899 dnl --------------
2900 dnl Construct a search-list for a nonstandard header/lib-file
2901 dnl     $1 = the variable to return as result
2902 dnl     $2 = the package name
2903 dnl     $3 = the subdirectory, e.g., bin, include or lib
2904 AC_DEFUN([CF_SUBDIR_PATH],
2905 [
2906 $1=
2907
2908 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr,$prefix)
2909 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
2910 CF_ADD_SUBDIR_PATH($1,$2,$3,/usr/local,$prefix)
2911 CF_ADD_SUBDIR_PATH($1,$2,$3,/opt,$prefix)
2912 CF_ADD_SUBDIR_PATH($1,$2,$3,[$]HOME,$prefix)
2913 ])dnl
2914 dnl ---------------------------------------------------------------------------
2915 dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
2916 dnl --------
2917 dnl     Shorthand macro for substituting things that the user may override
2918 dnl     with an environment variable.
2919 dnl
2920 dnl     $1 = long/descriptive name
2921 dnl     $2 = environment variable
2922 dnl     $3 = default value
2923 AC_DEFUN([CF_SUBST],
2924 [AC_CACHE_VAL(cf_cv_subst_$2,[
2925 AC_MSG_CHECKING(for $1 (symbol $2))
2926 CF_SUBST_IF([-z "[$]$2"], [$2], [$3])
2927 cf_cv_subst_$2=[$]$2
2928 AC_MSG_RESULT([$]$2)
2929 ])
2930 ])dnl
2931 dnl ---------------------------------------------------------------------------
2932 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
2933 dnl --------------
2934 dnl Look for term.h, which is part of X/Open curses.  It defines the interface
2935 dnl to terminfo database.  Usually it is in the same include-path as curses.h,
2936 dnl but some packagers change this, breaking various applications.
2937 AC_DEFUN([CF_TERM_HEADER],[
2938 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2939 case ${cf_cv_ncurses_header} in #(vi
2940 */ncurses.h|*/ncursesw.h) #(vi
2941         cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2942         ;;
2943 *)
2944         cf_term_header=term.h
2945         ;;
2946 esac
2947
2948 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2949 do
2950 AC_TRY_COMPILE([#include <stdio.h>
2951 #include <${cf_cv_ncurses_header-curses.h}>
2952 #include <$cf_test>
2953 ],[int x = auto_left_margin],[
2954         cf_cv_term_header="$cf_test"],[
2955         cf_cv_term_header=unknown
2956         ])
2957         test "$cf_cv_term_header" != unknown && break
2958 done
2959 ])
2960
2961 # Set definitions to allow ifdef'ing to accommodate subdirectories
2962
2963 case $cf_cv_term_header in # (vi
2964 *term.h)
2965         AC_DEFINE(HAVE_TERM_H)
2966         ;;
2967 esac
2968
2969 case $cf_cv_term_header in # (vi
2970 ncurses/term.h) #(vi
2971         AC_DEFINE(HAVE_NCURSES_TERM_H)
2972         ;;
2973 ncursesw/term.h)
2974         AC_DEFINE(HAVE_NCURSESW_TERM_H)
2975         ;;
2976 esac
2977 ])dnl
2978 dnl ---------------------------------------------------------------------------
2979 dnl CF_TOP_BUILDDIR version: 1 updated: 2006/10/15 16:33:23
2980 dnl ---------------
2981 dnl Define a top_builddir symbol, for applications that need an absolute path.
2982 AC_DEFUN([CF_TOP_BUILDDIR],
2983 [
2984 top_builddir=`pwd`
2985 AC_SUBST(top_builddir)
2986 ])dnl
2987 dnl ---------------------------------------------------------------------------
2988 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2989 dnl --------
2990 dnl Make an uppercase version of a variable
2991 dnl $1=uppercase($2)
2992 AC_DEFUN([CF_UPPER],
2993 [
2994 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2995 ])dnl
2996 dnl ---------------------------------------------------------------------------
2997 dnl CF_UTF8_LIB version: 6 updated: 2010/04/21 06:20:50
2998 dnl -----------
2999 dnl Check for multibyte support, and if not found, utf8 compatibility library
3000 AC_DEFUN([CF_UTF8_LIB],
3001 [
3002 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3003         cf_save_LIBS="$LIBS"
3004         AC_TRY_LINK([
3005 #include <stdlib.h>],[putwc(0,0);],
3006         [cf_cv_utf8_lib=yes],
3007         [CF_FIND_LINKAGE([
3008 #include <libutf8.h>],[putwc(0,0);],utf8,
3009                 [cf_cv_utf8_lib=add-on],
3010                 [cf_cv_utf8_lib=no])
3011 ])])
3012
3013 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3014 # ncurses/ncursesw:
3015 if test "$cf_cv_utf8_lib" = "add-on" ; then
3016         AC_DEFINE(HAVE_LIBUTF8_H)
3017         CF_ADD_INCDIR($cf_cv_header_path_utf8)
3018         CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3019         LIBS="$cf_cv_library_file_utf8 $LIBS"
3020 fi
3021 ])dnl
3022 dnl ---------------------------------------------------------------------------
3023 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3024 dnl ----------
3025 dnl Use AC_VERBOSE w/o the warnings
3026 AC_DEFUN([CF_VERBOSE],
3027 [test -n "$verbose" && echo "   $1" 1>&AC_FD_MSG
3028 CF_MSG_LOG([$1])
3029 ])dnl
3030 dnl ---------------------------------------------------------------------------
3031 dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
3032 dnl ---------------
3033 dnl Check for compiler-support for weak symbols.
3034 dnl This works with "recent" gcc.
3035 AC_DEFUN([CF_WEAK_SYMBOLS],[
3036 AC_CACHE_CHECK(if $CC supports weak symbols,cf_cv_weak_symbols,[
3037
3038 AC_TRY_COMPILE([
3039 #include <stdio.h>],
3040 [
3041 #if defined(__GNUC__)
3042 #  if defined __USE_ISOC99
3043 #    define _cat_pragma(exp)    _Pragma(#exp)
3044 #    define _weak_pragma(exp)   _cat_pragma(weak name)
3045 #  else
3046 #    define _weak_pragma(exp)
3047 #  endif
3048 #  define _declare(name)        __extension__ extern __typeof__(name) name
3049 #  define weak_symbol(name)     _weak_pragma(name) _declare(name) __attribute__((weak))
3050 #endif
3051
3052 weak_symbol(fopen);
3053 ],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
3054 ])
3055 ])dnl
3056 dnl ---------------------------------------------------------------------------
3057 dnl CF_WITH_CURSES_DIR version: 2 updated: 2002/11/10 14:46:59
3058 dnl ------------------
3059 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3060 dnl libraries.
3061 AC_DEFUN([CF_WITH_CURSES_DIR],[
3062 AC_ARG_WITH(curses-dir,
3063         [  --with-curses-dir=DIR   directory in which (n)curses is installed],
3064         [CF_PATH_SYNTAX(withval)
3065          cf_cv_curses_dir=$withval],
3066         [cf_cv_curses_dir=no])
3067 ])dnl
3068 dnl ---------------------------------------------------------------------------
3069 dnl CF_WITH_PATH version: 9 updated: 2010/05/26 05:38:42
3070 dnl ------------
3071 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
3072 dnl defaulting to yes/no.
3073 dnl
3074 dnl $1 = option name
3075 dnl $2 = help-text
3076 dnl $3 = environment variable to set
3077 dnl $4 = default value, shown in the help-message, must be a constant
3078 dnl $5 = default value, if it's an expression & cannot be in the help-message
3079 dnl
3080 AC_DEFUN([CF_WITH_PATH],
3081 [AC_ARG_WITH($1,[$2 ](default: ifelse([$4],,empty,[$4])),,
3082 ifelse([$4],,[withval="${$3}"],[withval="${$3-ifelse([$5],,[$4],[$5])}"]))dnl
3083 if ifelse([$5],,true,[test -n "$5"]) ; then
3084 CF_PATH_SYNTAX(withval)
3085 fi
3086 $3="$withval"
3087 AC_SUBST($3)dnl
3088 ])dnl
3089 dnl ---------------------------------------------------------------------------
3090 dnl CF_WITH_PTHREAD version: 3 updated: 2010/05/29 16:31:02
3091 dnl ---------------
3092 dnl Check for POSIX thread library.
3093 AC_DEFUN([CF_WITH_PTHREAD],
3094 [
3095 AC_MSG_CHECKING(if you want to link with the pthread library)
3096 AC_ARG_WITH(pthread,
3097     [  --with-pthread          use POSIX thread library],
3098     [with_pthread=$withval],
3099     [with_pthread=no])
3100 AC_MSG_RESULT($with_pthread)
3101
3102 if test "$with_pthread" != no ; then
3103     AC_CHECK_HEADER(pthread.h,[
3104         AC_DEFINE(HAVE_PTHREADS_H)
3105
3106         AC_MSG_CHECKING(if we can link with the pthread library)
3107         cf_save_LIBS="$LIBS"
3108         CF_ADD_LIB(pthread)
3109         AC_TRY_LINK([
3110 #include <pthread.h>
3111 ],[
3112         int rc = pthread_create(0,0,0,0);
3113 ],[with_pthread=yes],[with_pthread=no])
3114         LIBS="$cf_save_LIBS"
3115         AC_MSG_RESULT($with_pthread)
3116
3117         if test "$with_pthread" = yes ; then
3118             CF_ADD_LIB(pthread)
3119             AC_DEFINE(HAVE_LIBPTHREADS)
3120         else
3121             AC_MSG_ERROR(Cannot link with pthread library)
3122         fi
3123     ])
3124 fi
3125 ])
3126 dnl ---------------------------------------------------------------------------
3127 dnl CF_XOPEN_SOURCE version: 34 updated: 2010/05/26 05:38:42
3128 dnl ---------------
3129 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3130 dnl or adapt to the vendor's definitions to get equivalent functionality,
3131 dnl without losing the common non-POSIX features.
3132 dnl
3133 dnl Parameters:
3134 dnl     $1 is the nominal value for _XOPEN_SOURCE
3135 dnl     $2 is the nominal value for _POSIX_C_SOURCE
3136 AC_DEFUN([CF_XOPEN_SOURCE],[
3137
3138 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3139 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3140 cf_xopen_source=
3141
3142 case $host_os in #(vi
3143 aix[[456]]*) #(vi
3144         cf_xopen_source="-D_ALL_SOURCE"
3145         ;;
3146 darwin[[0-8]].*) #(vi
3147         cf_xopen_source="-D_APPLE_C_SOURCE"
3148         ;;
3149 darwin*) #(vi
3150         cf_xopen_source="-D_DARWIN_C_SOURCE"
3151         ;;
3152 freebsd*|dragonfly*) #(vi
3153         # 5.x headers associate
3154         #       _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3155         #       _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3156         cf_POSIX_C_SOURCE=200112L
3157         cf_XOPEN_SOURCE=600
3158         cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3159         ;;
3160 hpux11*) #(vi
3161         cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3162         ;;
3163 hpux*) #(vi
3164         cf_xopen_source="-D_HPUX_SOURCE"
3165         ;;
3166 irix[[56]].*) #(vi
3167         cf_xopen_source="-D_SGI_SOURCE"
3168         ;;
3169 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
3170         CF_GNU_SOURCE
3171         ;;
3172 mirbsd*) #(vi
3173         # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
3174         ;;
3175 netbsd*) #(vi
3176         # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3177         ;;
3178 openbsd*) #(vi
3179         # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3180         ;;
3181 osf[[45]]*) #(vi
3182         cf_xopen_source="-D_OSF_SOURCE"
3183         ;;
3184 nto-qnx*) #(vi
3185         cf_xopen_source="-D_QNX_SOURCE"
3186         ;;
3187 sco*) #(vi
3188         # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3189         ;;
3190 solaris2.1[[0-9]]) #(vi
3191         cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3192         ;;
3193 solaris2.[[1-9]]) #(vi
3194         cf_xopen_source="-D__EXTENSIONS__"
3195         ;;
3196 *)
3197         AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
3198         AC_TRY_COMPILE([#include <sys/types.h>],[
3199 #ifndef _XOPEN_SOURCE
3200 make an error
3201 #endif],
3202         [cf_cv_xopen_source=no],
3203         [cf_save="$CPPFLAGS"
3204          CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3205          AC_TRY_COMPILE([#include <sys/types.h>],[
3206 #ifdef _XOPEN_SOURCE
3207 make an error
3208 #endif],
3209         [cf_cv_xopen_source=no],
3210         [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3211         CPPFLAGS="$cf_save"
3212         ])
3213 ])
3214         if test "$cf_cv_xopen_source" != no ; then
3215                 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3216                 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3217                 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3218                 CF_ADD_CFLAGS($cf_temp_xopen_source)
3219         fi
3220         CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3221         ;;
3222 esac
3223
3224 if test -n "$cf_xopen_source" ; then
3225         CF_ADD_CFLAGS($cf_xopen_source)
3226 fi
3227 ])