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