1 dnl***************************************************************************
2 dnl Copyright (c) 2010 Free Software Foundation, Inc. *
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: *
12 dnl The above copyright notice and this permission notice shall be included *
13 dnl in all copies or substantial portions of the Software. *
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. *
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 *
27 dnl***************************************************************************
29 dnl Author: Thomas E. Dickey
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.
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.
38 dnl See http://invisible-island.net/autoconf/ for additional information.
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
46 AC_DEFUN([CF_ADA_INCLUDE_DIRS],
48 ACPPFLAGS="-I. -I../include -I../../include $ACPPFLAGS"
49 if test "$srcdir" != "."; then
50 ACPPFLAGS="-I\${srcdir}/../../include $ACPPFLAGS"
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}"
60 ACPPFLAGS="$ACPPFLAGS -I\${includedir}"
65 dnl ---------------------------------------------------------------------------
66 dnl CF_ADD_CFLAGS version: 9 updated: 2010/01/09 11:05:50
68 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
69 dnl The second parameter if given makes this macro verbose.
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],
79 cf_new_extra_cppflags=
81 for cf_add_cflags in $1
83 case $cf_fix_cppflags in
85 case $cf_add_cflags in #(vi
86 -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C) #(vi
87 case $cf_add_cflags in
89 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
91 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
92 && test -z "${cf_tst_cflags}" \
93 && cf_fix_cppflags=yes
95 if test $cf_fix_cppflags = yes ; then
96 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
98 elif test "${cf_tst_cflags}" = "\"'" ; then
99 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
105 *$cf_add_cflags) #(vi
108 case $cf_add_cflags in #(vi
110 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
111 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
114 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
119 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
124 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
126 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
128 test "${cf_add_cflags}" != "${cf_tst_cflags}" \
129 && test -z "${cf_tst_cflags}" \
130 && cf_fix_cppflags=no
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"
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"
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"
150 AC_SUBST(EXTRA_CPPFLAGS)
153 dnl ---------------------------------------------------------------------------
154 dnl CF_ADD_INCDIR version: 12 updated: 2009/01/18 10:00:47
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],
163 if test -n "$1" ; then
164 for cf_add_incdir in $1
166 while test $cf_add_incdir != /usr/include
168 if test -d $cf_add_incdir
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
180 if test "$cf_have_incdir" = no ; then
181 if test "$cf_add_incdir" = /usr/local/include ; then
184 cf_save_CPPFLAGS=$CPPFLAGS
185 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
186 AC_TRY_COMPILE([#include <stdio.h>],
189 [cf_have_incdir=yes])
190 CPPFLAGS=$cf_save_CPPFLAGS
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"
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"
210 dnl ---------------------------------------------------------------------------
211 dnl CF_ADD_LIBDIR version: 8 updated: 2009/01/18 10:01:08
213 dnl Adds to the library-path
215 dnl Some machines have trouble with multiple -L options.
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)
220 AC_DEFUN([CF_ADD_LIBDIR],
222 if test -n "$1" ; then
223 for cf_add_libdir in $1
225 if test $cf_add_libdir = /usr/lib ; then
227 elif test -d $cf_add_libdir
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
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)"
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],
257 test "$4" != "$5" && \
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"
268 dnl ---------------------------------------------------------------------------
269 dnl CF_ANSI_CC_CHECK version: 9 updated: 2001/12/30 17:53:34
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],
275 AC_CACHE_CHECK(for ${CC-cc} option to accept ANSI C, cf_cv_ansi_cc,[
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.
282 # Ultrix and OSF/1 -std1
283 # HP-UX -Aa -D_HPUX_SOURCE
285 # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
286 for cf_arg in "-DCC_HAS_PROTOS" \
291 "-Aa -D_HPUX_SOURCE" \
294 CF_ADD_CFLAGS($cf_arg)
297 #ifndef CC_HAS_PROTOS
298 #if !defined(__STDC__) || (__STDC__ != 1)
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])
308 CFLAGS="$cf_save_CFLAGS"
309 CPPFLAGS="$cf_save_CPPFLAGS"
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)
316 AC_DEFINE(CC_HAS_PROTOS)
320 dnl ---------------------------------------------------------------------------
321 dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
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
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])
338 dnl ---------------------------------------------------------------------------
339 dnl CF_AR_FLAGS version: 4 updated: 2009/02/07 13:42:23
341 dnl Check for suitable "ar" (archiver) options for updating an archive.
342 AC_DEFUN([CF_AR_FLAGS],[
343 AC_REQUIRE([CF_PROG_AR])
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
349 rm -f conftest.$ac_cv_objext
352 cat >conftest.$ac_ext <<EOF
353 #line __oline__ "configure"
354 int testdata[[3]] = { 123, 456, 789 };
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
363 CF_VERBOSE(cannot compile test-program)
367 rm -f conftest.a conftest.$ac_ext conftest.$ac_cv_objext
369 test -z "$ARFLAGS" && ARFLAGS=$cf_cv_ar_flags
370 AC_SUBST(ARFLAGS,$cf_cv_ar_flags)
372 dnl ---------------------------------------------------------------------------
373 dnl CF_BUILD_CC version: 6 updated: 2006/10/14 15:23:15
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
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
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'}
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)
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)
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)
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)
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)
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)
432 # this assumes we're on Unix.
436 : ${BUILD_CC:='${CC}'}
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.])
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'}
456 AC_SUBST(BUILD_CFLAGS)
457 AC_SUBST(BUILD_CPPFLAGS)
458 AC_SUBST(BUILD_LDFLAGS)
460 AC_SUBST(BUILD_EXEEXT)
461 AC_SUBST(BUILD_OBJEXT)
463 dnl ---------------------------------------------------------------------------
464 dnl CF_CFG_DEFAULTS version: 7 updated: 2005/09/24 16:15:00
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
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.
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],
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)
485 *) prefix=$ac_default_prefix
489 AC_MSG_RESULT($prefix)
491 if test "x$prefix" = "xNONE" ; then
492 AC_MSG_CHECKING(for default include-directory)
493 test -n "$verbose" && echo 1>&AC_FD_MSG
496 $includedir/ncurses \
498 $prefix/include/ncurses \
500 /usr/local/include/ncurses \
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
512 test -n "$verbose" && echo " tested $cf_dir" 1>&AC_FD_MSG
514 AC_MSG_RESULT($includedir)
517 dnl ---------------------------------------------------------------------------
518 dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
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.
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.
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],
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"
536 system_name="`(uname -s -r) 2>/dev/null`"
537 if test -z "$system_name" ; then
538 system_name="`(hostname) 2>/dev/null`"
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"])
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)
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.")
552 dnl ---------------------------------------------------------------------------
553 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
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
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
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
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],
574 eval 'cf_cv_have_lib_'$1'=no'
577 eval 'cf_cv_have_lib_'$1'=yes',[
579 AC_MSG_CHECKING(for $5 in -l$1)
581 AC_TRY_LINK([$3],[$4],
583 eval 'cf_cv_have_lib_'$1'=yes'
586 CF_LIBRARY_PATH(cf_search,$2)
587 for cf_libdir in $cf_search
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],
593 eval 'cf_cv_have_lib_'$1'=yes'
596 LIBS="$cf_save_LIBS"])
600 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
602 if test $cf_found_library = no ; then
603 AC_MSG_ERROR(Cannot link $1 library)
607 dnl ---------------------------------------------------------------------------
608 dnl CF_FIND_LINKAGE version: 13 updated: 2008/12/24 07:59:55
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.
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
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],[
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=
635 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
637 AC_TRY_LINK([$1],[$2],
638 cf_cv_find_linkage_$3=yes,[
639 cf_cv_find_linkage_$3=no
641 CF_VERBOSE(find linkage for $3 library)
642 CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
644 cf_save_CPPFLAGS="$CPPFLAGS"
645 cf_test_CPPFLAGS="$CPPFLAGS"
647 CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
648 for cf_cv_header_path_$3 in $cf_search
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"
658 CPPFLAGS="$cf_save_CPPFLAGS"
663 if test "$cf_cv_find_linkage_$3" = maybe ; then
665 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
668 cf_save_LDFLAGS="$LDFLAGS"
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"
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
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"
694 CPPFLAGS="$cf_save_CPPFLAGS"
696 LDFLAGS="$cf_save_LDFLAGS"
701 CPPFLAGS="$cf_save_CPPFLAGS"
702 LDFLAGS="$cf_save_LDFLAGS"
706 cf_cv_find_linkage_$3=no
710 if test "$cf_cv_find_linkage_$3" = yes ; then
712 CF_ADD_INCDIR($cf_cv_header_path_$3)
713 CF_ADD_LIBDIR($cf_cv_library_path_$3)
717 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
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],
730 cat > conftest.i <<EOF
738 #define GCC_NORETURN /* nothing */
741 #define GCC_UNUSED /* nothing */
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"
753 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
755 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
758 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
760 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
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; }
767 cf_printf_attribute=no
768 cf_scanf_attribute=no
769 for cf_attribute in scanf printf unused noreturn
771 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
772 cf_directive="__attribute__(($cf_attribute))"
773 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
775 case $cf_attribute in #(vi
777 cf_printf_attribute=yes
778 cat >conftest.h <<EOF
779 #define GCC_$cf_ATTRIBUTE 1
783 cf_scanf_attribute=yes
784 cat >conftest.h <<EOF
785 #define GCC_$cf_ATTRIBUTE 1
789 cat >conftest.h <<EOF
790 #define GCC_$cf_ATTRIBUTE $cf_directive
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
800 if test "$cf_printf_attribute" = no ; then
801 cat >>confdefs.h <<EOF
802 #define GCC_PRINTFLIKE(fmt,var) /* nothing */
805 cat >>confdefs.h <<EOF
806 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
811 if test "$cf_scanf_attribute" = no ; then
812 cat >>confdefs.h <<EOF
813 #define GCC_SCANFLIKE(fmt,var) /* nothing */
816 cat >>confdefs.h <<EOF
817 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
825 fgrep define conftest.i >>confdefs.h
830 dnl ---------------------------------------------------------------------------
831 dnl CF_GCC_VERSION version: 4 updated: 2005/08/27 09:53:42
833 dnl Find version of gcc
834 AC_DEFUN([CF_GCC_VERSION],[
835 AC_REQUIRE([AC_PROG_CC])
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)
844 dnl ---------------------------------------------------------------------------
845 dnl CF_GCC_WARNINGS version: 24 updated: 2009/02/01 15:21:00
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:
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".
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
862 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
864 AC_DEFUN([CF_GCC_WARNINGS],
866 AC_REQUIRE([CF_GCC_VERSION])
867 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
869 cat > conftest.$ac_ext <<EOF
870 #line __oline__ "${as_me-configure}"
871 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
874 if test "$INTEL_COMPILER" = yes
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
887 AC_CHECKING([for $CC warning options])
888 cf_save_CFLAGS="$CFLAGS"
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"
907 CFLAGS="$cf_save_CFLAGS"
909 elif test "$GCC" = yes
911 AC_CHECKING([for $CC warning options])
912 cf_save_CFLAGS="$CFLAGS"
913 EXTRA_CFLAGS="-W -Wall"
915 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
921 Wmissing-declarations \
922 Wmissing-prototypes \
927 Wundef $cf_warn_CONST $1
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)
934 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
939 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
944 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
947 CFLAGS="$cf_save_CFLAGS"
951 AC_SUBST(EXTRA_CFLAGS)
953 dnl ---------------------------------------------------------------------------
954 dnl CF_GNAT_TRY_LINK version: 1 updated: 2004/08/21 19:02:08
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.
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],
967 cat >>conftest.ads <<CF_EOF
970 cat >>conftest.adb <<CF_EOF
973 if ( $cf_ada_make $ADAFLAGS conftest 1>&AC_FD_CC 2>&1 ) ; then
980 dnl ---------------------------------------------------------------------------
981 dnl CF_GNAT_TRY_RUN version: 3 updated: 2004/08/21 19:02:08
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.
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],
994 cat >>conftest.ads <<CF_EOF
997 cat >>conftest.adb <<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])
1011 dnl ---------------------------------------------------------------------------
1012 dnl CF_GNAT_VERSION version: 12 updated: 2006/10/14 15:23:15
1014 dnl Verify version of GNAT.
1015 AC_DEFUN([CF_GNAT_VERSION],
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)
1022 case $cf_gnat_version in
1023 3.1[[1-9]]*|3.[[2-9]]*|[[4-9]].*)
1024 cf_cv_prog_gnat_correct=yes
1026 *) echo Unsupported GNAT version $cf_gnat_version. Required is 3.11 or better. Disabling Ada95 binding.
1027 cf_cv_prog_gnat_correct=no
1030 case $cf_gnat_version in
1031 3.[[1-9]]*|[[4-9]].*)
1032 cf_compile_generics=generics
1033 cf_generic_objects="\${GENOBJS}"
1035 *) cf_compile_generics=
1040 dnl ---------------------------------------------------------------------------
1041 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
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.
1048 dnl Well, yes we could work around it...
1049 AC_DEFUN([CF_GNU_SOURCE],
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
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
1063 [cf_cv_gnu_source=no],
1064 [cf_cv_gnu_source=yes])
1068 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1070 dnl ---------------------------------------------------------------------------
1071 dnl CF_HEADER_PATH version: 10 updated: 2010/01/17 20:36:17
1073 dnl Construct a search-list of directories for a nonstandard header-file
1076 dnl $1 = the variable to return as result
1077 dnl $2 = the package name
1078 AC_DEFUN([CF_HEADER_PATH],
1081 cf_header_path_list=""
1082 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1083 for cf_header_path in $CPPFLAGS $CFLAGS
1085 case $cf_header_path in #(vi
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"
1095 CF_SUBDIR_PATH($1,$2,include)
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"
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"
1111 $1="$cf_header_path_list [$]$1"
1113 dnl ---------------------------------------------------------------------------
1114 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
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
1120 dnl ---------------------------------------------------------------------------
1121 dnl CF_INCLUDE_DIRS version: 6 updated: 2009/01/06 19:37:40
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],
1129 CPPFLAGS="$CPPFLAGS -I. -I../include"
1130 if test "$srcdir" != "."; then
1131 CPPFLAGS="$CPPFLAGS -I\${srcdir}/../include"
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}"
1141 CPPFLAGS="$CPPFLAGS -I\${includedir}"
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.
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.
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
1163 if test "$ifelse($1,,[$1],GCC)" = yes ; then
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"
1170 #ifdef __INTEL_COMPILER
1174 ],[ifelse($2,,INTEL_COMPILER,[$2])=yes
1175 cf_save_CFLAGS="$cf_save_CFLAGS -we147 -no-gcc"
1177 ifelse($3,,CFLAGS,[$3])="$cf_save_CFLAGS"
1178 AC_MSG_RESULT($ifelse($2,,INTEL_COMPILER,[$2]))
1183 dnl ---------------------------------------------------------------------------
1184 dnl CF_LARGEFILE version: 7 updated: 2007/06/02 11:58:50
1186 dnl Add checks for large file support.
1187 AC_DEFUN([CF_LARGEFILE],[
1188 ifdef([AC_FUNC_FSEEKO],[
1190 if test "$enable_largefile" != no ; then
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
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 "
1204 AC_CACHE_CHECK(whether to use struct dirent64, cf_cv_struct_dirent64,[
1206 #include <sys/types.h>
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);
1215 [cf_cv_struct_dirent64=yes],
1216 [cf_cv_struct_dirent64=no])
1218 test "$cf_cv_struct_dirent64" = yes && AC_DEFINE(HAVE_STRUCT_DIRENT64)
1222 dnl ---------------------------------------------------------------------------
1223 dnl CF_LIBRARY_PATH version: 8 updated: 2008/12/07 19:38:31
1225 dnl Construct a search-list of directories for a nonstandard library-file
1228 dnl $1 = the variable to return as result
1229 dnl $2 = the package name
1230 AC_DEFUN([CF_LIBRARY_PATH],
1232 cf_library_path_list=""
1233 if test -n "${LDFLAGS}${LIBS}" ; then
1234 for cf_library_path in $LDFLAGS $LIBS
1236 case $cf_library_path in #(vi
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"
1246 CF_SUBDIR_PATH($1,$2,lib)
1248 $1="$cf_library_path_list [$]$1"
1250 dnl ---------------------------------------------------------------------------
1251 dnl CF_LIB_PREFIX version: 8 updated: 2008/09/13 11:34:16
1253 dnl Compute the library-prefix for the given host system
1254 dnl $1 = variable to set
1255 AC_DEFUN([CF_LIB_PREFIX],
1257 case $cf_cv_system_name in #(vi
1264 ifelse($1,,,[$1=$LIB_PREFIX])
1265 AC_SUBST(LIB_PREFIX)
1267 dnl ---------------------------------------------------------------------------
1268 dnl CF_LIB_SONAME version: 3 updated: 2006/12/16 15:55:46
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".
1276 dnl $3 = library name
1277 AC_DEFUN([CF_LIB_SONAME],
1279 AC_CACHE_CHECK(for soname of $3 library,cf_cv_$3_soname,[
1281 cf_cv_$3_soname=unknown
1282 if test "$cross_compiling" != yes ; then
1283 cat >conftest.$ac_ext <<CF_EOF
1288 ${cf_cv_main_return:-return}(0);
1291 cf_save_LIBS="$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
1300 LIBS="$cf_save_LIBS"
1304 dnl ---------------------------------------------------------------------------
1305 dnl CF_LIB_SUFFIX version: 16 updated: 2008/12/27 12:30:03
1307 dnl Compute the library file-suffix from the given 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],
1314 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
1333 case $cf_cv_system_name in
1363 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
1364 test -n "$LIB_SUFFIX" && $3="${LIB_SUFFIX}[$]{$3}"
1366 dnl ---------------------------------------------------------------------------
1367 dnl CF_LIB_TYPE version: 4 updated: 2000/10/20 22:57:49
1369 dnl Compute the string to append to -library from the given 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],
1382 test -n "$LIB_SUFFIX" && $2="${LIB_SUFFIX}[$]{$2}"
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
1391 AC_DEFUN([CF_LINK_DATAONLY],
1393 AC_MSG_CHECKING([if data-only library module links])
1394 AC_CACHE_VAL(cf_cv_link_dataonly,[
1396 cat >conftest.$ac_ext <<EOF
1397 #line __oline__ "configure"
1398 int testdata[[3]] = { 123, 456, 789 };
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
1404 rm -f conftest.$ac_ext data.o
1405 cat >conftest.$ac_ext <<EOF
1406 #line __oline__ "configure"
1410 ${cf_cv_main_return:-return}(1); /* I'm told this linker is broken */
1412 extern int testdata[[3]];
1413 return testdata[[0]] == 123
1414 && testdata[[1]] == 456
1415 && testdata[[2]] == 789;
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
1423 rm -f conftest.$ac_ext func.o
1424 ( eval $RANLIB conftest.a ) 2>&AC_FD_CC >/dev/null
1426 LIBS="conftest.a $LIBS"
1430 extern int testfunc();
1431 ${cf_cv_main_return:-return} (!testfunc());
1434 [cf_cv_link_dataonly=yes],
1435 [cf_cv_link_dataonly=no],
1436 [cf_cv_link_dataonly=unknown])
1439 AC_MSG_RESULT($cf_cv_link_dataonly)
1441 if test "$cf_cv_link_dataonly" = no ; then
1442 AC_DEFINE(BROKEN_LINKER)
1447 dnl ---------------------------------------------------------------------------
1448 dnl CF_LINK_FUNCS version: 7 updated: 2006/12/16 12:33:30
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],
1459 if test "$cross_compiling" = yes ; then
1464 AC_CACHE_CHECK(if link/symlink functions work,cf_cv_link_funcs,[
1466 for cf_func in link symlink ; do
1468 #include <sys/types.h>
1469 #include <sys/stat.h>
1470 #ifdef HAVE_UNISTD_H
1476 char *src = "config.log";
1477 char *dst = "conftest.chk";
1482 fail = ($cf_func("config.log", "conftest.chk") < 0)
1483 || (stat(dst, &dst_sb) < 0)
1484 || (dst_sb.st_mtime != src_sb.st_mtime);
1490 ${cf_cv_main_return:-return} (fail);
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'])
1498 test -z "$cf_cv_link_funcs" && cf_cv_link_funcs=no
1500 test "$ac_cv_func_link" = yes && AC_DEFINE(HAVE_LINK)
1501 test "$ac_cv_func_symlink" = yes && AC_DEFINE(HAVE_SYMLINK)
1504 dnl ---------------------------------------------------------------------------
1505 dnl CF_MAIN_RETURN version: 1 updated: 2006/12/10 09:51:54
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.
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],
1514 cf_cv_main_return=return
1516 dnl ---------------------------------------------------------------------------
1517 dnl CF_MAKEFLAGS version: 12 updated: 2006/10/21 08:27:03
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],
1525 AC_CACHE_CHECK(for makeflags variable, cf_cv_makeflags,[
1527 for cf_option in '-${MAKEFLAGS}' '${MFLAGS}'
1529 cat >cf_makeflags.tmp <<CF_EOF
1532 @ echo '.$cf_option'
1534 cf_result=`${MAKE-make} -k -f cf_makeflags.tmp 2>/dev/null | sed -e 's,[[ ]]*$,,'`
1535 case "$cf_result" in
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=
1541 *) cf_cv_makeflags=$cf_option
1547 *) echo "given option \"$cf_option\", no match \"$cf_result\""
1551 rm -f cf_makeflags.tmp
1554 AC_SUBST(cf_cv_makeflags)
1556 dnl ---------------------------------------------------------------------------
1557 dnl CF_MAKE_TAGS version: 2 updated: 2000/10/04 09:18:40
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)
1565 if test "$cf_cv_mixedcase" = yes ; then
1566 AC_CHECK_PROG(MAKE_UPPER_TAGS, etags, yes, no)
1571 if test "$MAKE_UPPER_TAGS" = yes ; then
1576 AC_SUBST(MAKE_UPPER_TAGS)
1578 if test "$MAKE_LOWER_TAGS" = yes ; then
1583 AC_SUBST(MAKE_LOWER_TAGS)
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],
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
1603 rm -f conftest CONFTEST
1605 if test -f CONFTEST ; then
1610 rm -f conftest CONFTEST
1613 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
1615 dnl ---------------------------------------------------------------------------
1616 dnl CF_MKSTEMP version: 5 updated: 2006/12/16 12:33:30
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,[
1624 #include <sys/types.h>
1628 #include <sys/stat.h>
1631 char *tmpl = "conftestXXXXXX";
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) {
1652 && !strcmp(name[0], name[1]))
1654 ${cf_cv_main_return:-return}(result);
1656 ],[cf_cv_func_mkstemp=yes
1657 ],[cf_cv_func_mkstemp=no
1658 ],[AC_CHECK_FUNC(mkstemp)
1661 if test "$cf_cv_func_mkstemp" = yes ; then
1662 AC_DEFINE(HAVE_MKSTEMP)
1665 dnl ---------------------------------------------------------------------------
1666 dnl CF_MSG_LOG version: 4 updated: 2007/07/29 09:55:12
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
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],[
1679 AC_PROVIDE([CF_SUBST_NCURSES_VERSION])
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],
1686 AC_MSG_RESULT($with_widec)
1687 if test "$with_widec" = yes ; then
1689 CF_NCURSES_CONFIG(ncursesw)
1691 CF_NCURSES_CONFIG(ncurses)
1694 if test "$NCURSES_CONFIG" != none ; then
1696 cf_version=`$NCURSES_CONFIG --version`
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]]\+\.//'`
1702 # ABI version is not available from headers
1703 cf_cv_abi_version=`$NCURSES_CONFIG --abi-version`
1707 for cf_name in MAJOR MINOR PATCH
1709 cat >conftest.$ac_ext <<CF_EOF
1710 #include <${cf_cv_ncurses_header-curses.h}>
1711 AUTOCONF_$cf_name NCURSES_VERSION_$cf_name
1713 cf_try="$ac_cpp conftest.$ac_ext 2>&5 | fgrep AUTOCONF_$cf_name >conftest.out"
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
1723 cf_cv_abi_version=${NCURSES_MAJOR}
1727 cf_cv_rel_version=${NCURSES_MAJOR}.${NCURSES_MINOR}
1729 dnl Show the computed version, for logging
1730 cf_cv_timestamp=`date`
1732 AC_MSG_RESULT(Configuring NCURSES $cf_cv_rel_version ABI $cf_cv_abi_version ($cf_cv_timestamp))
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)
1739 dnl We need these values in the generated makefiles
1740 AC_SUBST(cf_cv_rel_version)
1741 AC_SUBST(cf_cv_abi_version)
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
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],[
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 */
1764 #ifdef NCURSES_VERSION
1765 ]ifelse($3,ncursesw,[
1770 printf("%s\n", NCURSES_VERSION);
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.
1789 dnl $1 is the root library name (default: "ncurses")
1790 AC_DEFUN([CF_NCURSES_CONFIG],
1792 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
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)
1797 if test "$NCURSES_CONFIG" != none ; then
1799 cf_cv_ncurses_header=curses.h
1801 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1802 LIBS="`$NCURSES_CONFIG --libs` $LIBS"
1804 dnl like CF_NCURSES_CPPFLAGS
1807 dnl like CF_NCURSES_LIBS
1808 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1809 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1811 dnl like CF_NCURSES_VERSION
1812 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1816 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1817 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
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.
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
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>.
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])
1846 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
1847 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
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)
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
1859 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
1860 test "$cf_cv_ncurses_h" != no && break
1867 # some applications need this, but should check for NCURSES_VERSION
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.
1878 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
1879 AC_DEFUN([CF_NCURSES_HEADER],[
1881 if test "$cf_cv_ncurses_h" != no ; then
1882 cf_cv_ncurses_header=$cf_cv_ncurses_h
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
1892 CF_ADD_INCDIR($cf_incdir)
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
1903 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
1905 CPPFLAGS="$cf_save2_CPPFLAGS"
1906 test "$cf_cv_ncurses_h2" != no && break
1908 test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
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
1916 CF_ADD_INCDIR($cf_1st_incdir)
1920 # Set definitions to allow ifdef'ing for ncurses.h
1922 case $cf_cv_ncurses_header in # (vi
1924 AC_DEFINE(HAVE_NCURSES_H)
1928 case $cf_cv_ncurses_header in # (vi
1929 ncurses/curses.h|ncurses/ncurses.h)
1930 AC_DEFINE(HAVE_NCURSES_NCURSES_H)
1932 ncursesw/curses.h|ncursesw/ncurses.h)
1933 AC_DEFINE(HAVE_NCURSESW_NCURSES_H)
1938 dnl ---------------------------------------------------------------------------
1939 dnl CF_NCURSES_LIBS version: 13 updated: 2007/07/29 10:29:20
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.
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])
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
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"])])
1965 case $host_os in #(vi
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"])
1975 LIBS="$cf_ncurses_LIBS $LIBS"
1977 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
1979 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
1980 LIBS="-l$cf_nculib_root $LIBS"
1982 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
1983 [#include <${cf_cv_ncurses_header-curses.h}>],
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
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)],
2001 LIBS="$cf_ncurses_SAVE"])
2004 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2005 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
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],
2015 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2016 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2017 cf_cv_ncurses_version=no
2021 #include <${cf_cv_ncurses_header-curses.h}>
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);
2030 fprintf(fp, "%s\n", NCURSES_VERSION);
2034 fprintf(fp, "old\n");
2039 ${cf_cv_main_return-return}(0);
2041 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
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}>
2048 #ifdef NCURSES_VERSION
2049 Autoconf NCURSES_VERSION
2057 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
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"
2067 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES)
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)
2077 [AC_DEFINE($3)ifelse([$4],,[
2080 : ${with_cflags:=-g}
2081 : ${with_no_leaks:=yes}
2084 AC_MSG_RESULT(${with_$1:-no})
2086 case .$with_cflags in #(vi
2088 case .$CFLAGS in #(vi
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
2110 AC_MSG_ERROR($2 is not a number: $1)
2114 AC_MSG_ERROR($2 value is empty)
2117 dnl ---------------------------------------------------------------------------
2118 dnl CF_OBJ_SUBDIR version: 4 updated: 2002/02/23 20:38:31
2120 dnl Compute the object-directory name from the given model name
2121 AC_DEFUN([CF_OBJ_SUBDIR],
2124 libtool) $2='obj_lo' ;;
2125 normal) $2='objects' ;;
2126 debug) $2='obj_g' ;;
2127 profile) $2='obj_p' ;;
2129 case $cf_cv_system_name in #(vi
2137 dnl ---------------------------------------------------------------------------
2138 dnl CF_PATHSEP version: 4 updated: 2009/01/11 20:30:23
2140 dnl Provide a value for the $PATH and similar separator
2141 AC_DEFUN([CF_PATHSEP],
2143 case $cf_cv_system_name in
2144 os2*) PATH_SEPARATOR=';' ;;
2145 *) PATH_SEPARATOR=':' ;;
2147 ifelse($1,,,[$1=$PATH_SEPARATOR])
2148 AC_SUBST(PATH_SEPARATOR)
2150 dnl ---------------------------------------------------------------------------
2151 dnl CF_PATH_SYNTAX version: 12 updated: 2008/03/23 14:45:59
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"
2161 cf_path_syntax="$ac_default_prefix"
2164 case ".[$]$1" in #(vi
2165 .\[$]\(*\)*|.\'*\'*) #(vi
2169 .[[a-zA-Z]]:[[\\/]]*) #(vi OS/2 EMX
2171 .\[$]{*prefix}*) #(vi
2173 case ".[$]$1" in #(vi
2175 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2180 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2183 ifelse($2,,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2187 dnl ---------------------------------------------------------------------------
2188 dnl CF_PKG_CONFIG version: 3 updated: 2009/01/25 10:55:09
2190 dnl Check for the package-config program, unless disabled by command-line.
2191 AC_DEFUN([CF_PKG_CONFIG],
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)
2200 case $cf_pkg_config in #(vi
2205 AC_PATH_PROG(PKG_CONFIG, pkg-config, none)
2212 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2213 if test "$PKG_CONFIG" != none ; then
2214 CF_PATH_SYNTAX(PKG_CONFIG)
2217 AC_SUBST(PKG_CONFIG)
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.
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
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
2233 dnl $1 is the nominal value for _POSIX_C_SOURCE
2234 AC_DEFUN([CF_POSIX_C_SOURCE],
2236 cf_POSIX_C_SOURCE=ifelse($1,,199506L,$1)
2238 cf_save_CFLAGS="$CFLAGS"
2239 cf_save_CPPFLAGS="$CPPFLAGS"
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)
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
2250 [cf_cv_posix_c_source=no],
2251 [cf_want_posix_source=no
2252 case .$cf_POSIX_C_SOURCE in #(vi
2254 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2257 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2258 cf_want_posix_source=yes
2261 cf_want_posix_source=yes
2264 if test "$cf_want_posix_source" = yes ; then
2265 AC_TRY_COMPILE([#include <sys/types.h>],[
2266 #ifdef _POSIX_SOURCE
2269 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
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
2279 [cf_cv_posix_c_source=no])
2280 CFLAGS="$cf_save_CFLAGS"
2281 CPPFLAGS="$cf_save_CPPFLAGS"
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)
2292 dnl ---------------------------------------------------------------------------
2293 dnl CF_PROG_AR version: 1 updated: 2009/01/01 20:15:22
2295 dnl Check for archiver "ar".
2296 AC_DEFUN([CF_PROG_AR],[
2297 AC_CHECK_TOOL(AR, ar, ar)
2299 dnl ---------------------------------------------------------------------------
2300 dnl CF_PROG_AWK version: 1 updated: 2006/09/16 11:40:59
2302 dnl Check for awk, ensure that the check found something.
2303 AC_DEFUN([CF_PROG_AWK],
2306 test -z "$AWK" && AC_MSG_ERROR(No awk program found)
2308 dnl ---------------------------------------------------------------------------
2309 dnl CF_PROG_CC_C_O version: 2 updated: 2006/12/16 15:55:46
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
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,
2322 cat > conftest.$ac_ext <<CF_EOF
2326 ${cf_cv_main_return:-return}(0);
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);
2335 eval cf_cv_prog_$1_c_o=yes
2337 eval cf_cv_prog_$1_c_o=no
2341 if test $cf_cv_prog_$1_c_o = yes; then
2342 AC_MSG_RESULT([yes])
2347 dnl ---------------------------------------------------------------------------
2348 dnl CF_PROG_EGREP version: 1 updated: 2006/09/16 11:40:59
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'
2358 EGREP=$ac_cv_prog_egrep
2360 test -z "$EGREP" && AC_MSG_ERROR(No egrep program found)
2362 dnl ---------------------------------------------------------------------------
2363 dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
2365 dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
2366 AC_DEFUN([CF_PROG_EXT],
2368 AC_REQUIRE([CF_CHECK_CACHE])
2369 case $cf_cv_system_name in
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"
2385 test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
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.
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],
2401 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
2402 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
2404 dnl ---------------------------------------------------------------------------
2405 dnl CF_REMOVE_LIB version: 1 updated: 2007/02/17 14:11:52
2407 dnl Remove the given library from the symbol
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],
2414 # remove $3 library from $2
2415 $1=`echo "$2" | sed -e 's/-l$3[[ ]]//g' -e 's/-l$3[$]//'`
2417 dnl ---------------------------------------------------------------------------
2418 dnl CF_SHARED_OPTS version: 58 updated: 2009/12/19 13:46:49
2421 dnl Attempt to determine the appropriate CC/LD options for creating a shared
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
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.
2434 dnl The variable 'cf_cv_shlib_version' controls whether we use the rel or abi
2435 dnl version when making symbolic links.
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>).
2441 dnl Some loaders leave 'so_locations' lying around. It's nice to clean up.
2442 AC_DEFUN([CF_SHARED_OPTS],
2444 AC_REQUIRE([CF_SUBST_NCURSES_VERSION])
2449 INSTALL_LIB="-m 644"
2451 cf_cv_do_symlinks=no
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
2459 cf_cv_shlib_version=auto
2461 rel|abi|auto|no) #(vi
2462 cf_cv_shlib_version=$withval
2465 AC_MSG_ERROR([option value must be one of: rel, abi, auto or no])
2468 ],[cf_cv_shlib_version=auto])
2469 AC_MSG_RESULT($cf_cv_shlib_version)
2473 # Some less-capable ports of gcc support only -fpic
2475 if test "$GCC" = yes
2477 AC_MSG_CHECKING(which $CC option to use)
2478 cf_save_CFLAGS="$CFLAGS"
2479 for CC_SHARED_OPTS in -fPIC -fpic ''
2481 CFLAGS="$cf_save_CFLAGS $CC_SHARED_OPTS"
2482 AC_TRY_COMPILE([#include <stdio.h>],[int x = 1],[break],[])
2484 AC_MSG_RESULT($CC_SHARED_OPTS)
2485 CFLAGS="$cf_save_CFLAGS"
2488 cf_cv_shlib_version_infix=no
2490 case $cf_cv_system_name in
2492 if test "$GCC" = yes; then
2494 MK_SHARED_LIB="$(CC) -shared"
2498 MK_SHARED_LIB='${CC} ${CFLAGS} -o $[@] -Xlinker -soname=`basename $[@]` -nostart -e 0'
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
2508 IMPORT_LIB=\`echo "\[$]1" | sed -e 's/cyg/lib/' -e 's/[[0-9]]*\.dll[$]/.dll.a/'\`
2511 Linking shared library
2512 ** SHARED_LIB \[$]SHARED_LIB
2513 ** IMPORT_LIB \[$]IMPORT_LIB
2515 exec \[$]* -shared -Wl,--out-implib=../lib/\[$]{IMPORT_LIB} -Wl,--export-all-symbols -o ../lib/\[$]{SHARED_LIB}
2517 chmod +x mk_shared_lib.sh
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"
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}'
2540 LD_SHARED_OPTS='-Wl,+b,${libdir}'
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"
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"
2553 LD_RPATH_OPT="-rpath "
2554 EXTRA_LDFLAGS="-rpath \${libdir} $EXTRA_LDFLAGS"
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 $[@]'
2562 MK_SHARED_LIB='${CC} -shared -Wl,-soname,`basename $[@]` -o $[@]'
2564 cf_cv_rm_so_locs=yes
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"
2571 if test "$cf_cv_ld_rpath" = yes ; then
2572 LD_RPATH_OPT="-Wl,-rpath,"
2573 EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
2576 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
2579 if test "$DFT_LWR_MODEL" = "shared" ; then
2580 LOCAL_LDFLAGS="-Wl,-rpath,\$(LOCAL_LIBDIR)"
2581 LOCAL_LDFLAGS2="$LOCAL_LDFLAGS"
2583 if test "$cf_cv_ld_rpath" = yes ; then
2584 LD_RPATH_OPT="-Wl,-rpath,"
2585 EXTRA_LDFLAGS="-Wl,-rpath,\${libdir} $EXTRA_LDFLAGS"
2587 CC_SHARED_OPTS="$CC_SHARED_OPTS -DPIC"
2589 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-Bshareable,-soname,'$cf_cv_shared_soname',-stats,-lc -o $[@]'
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
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"
2605 MK_SHARED_LIB='${LD} -shared -Bshareable -soname=`basename $[@]` -o $[@]'
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
2618 cf_cv_shlib_version=rel
2622 MK_SHARED_LIB='${CC} ${CFLAGS} -shared -Wl,-soname,'$cf_cv_shared_soname' -o $[@]'
2624 MK_SHARED_LIB='${LD} -shared -Bshareable -o $[@]'
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 $[@]`'
2634 MK_SHARED_LIB="${MK_SHARED_LIB} -msym"
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"
2642 if test "$cf_cv_ld_rpath" = yes ; then
2643 LD_RPATH_OPT="-rpath"
2644 # EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2646 cf_cv_rm_so_locs=yes
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'
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
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'
2663 # tested with SunOS 4.1.1 and gcc 2.7.0
2664 if test "$GCC" != yes; then
2665 CC_SHARED_OPTS='-KPIC'
2667 MK_SHARED_LIB='${LD} -assert pure-text -o $[@]'
2668 test "$cf_cv_shlib_version" = auto && cf_cv_shlib_version=rel
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"
2677 if test "$cf_cv_ld_rpath" = yes ; then
2679 EXTRA_LDFLAGS="$LOCAL_LDFLAGS $EXTRA_LDFLAGS"
2682 if test "$GCC" != yes; then
2683 cf_save_CFLAGS="$CFLAGS"
2684 for cf_shared_opts in -xcode=pic13 -xcode=pic32 -Kpic -KPIC -O
2686 CFLAGS="$cf_shared_opts $cf_save_CFLAGS"
2687 AC_TRY_COMPILE([#include <stdio.h>],[printf("Hello\n");],[break])
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 $[@]'
2693 MK_SHARED_LIB='${CC} -shared -dy -G -h '$cf_cv_shared_soname' -o $[@]'
2697 # tested with UnixWare 7.1.0 (gcc 2.95.2 and cc)
2698 if test "$GCC" != yes; then
2699 CC_SHARED_OPTS='-KPIC'
2701 MK_SHARED_LIB='${LD} -d y -G -o [$]@'
2704 CC_SHARED_OPTS='unknown'
2705 MK_SHARED_LIB='echo unknown'
2709 # This works if the last tokens in $MK_SHARED_LIB are the -o target.
2710 case "$cf_cv_shlib_version" in #(vi
2712 case "$MK_SHARED_LIB" in #(vi
2714 test "$cf_cv_do_symlinks" = no && cf_cv_do_symlinks=yes
2717 AC_MSG_WARN(ignored --with-shlib-version)
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}"
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)
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)
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],
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}'
2760 cf_cv_shared_soname='`basename $[@]`'
2763 dnl ---------------------------------------------------------------------------
2764 dnl CF_STRIP_G_OPT version: 3 updated: 2002/12/21 19:25:52
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
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],
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)
2785 dnl ---------------------------------------------------------------------------
2786 dnl CF_SUBST version: 4 updated: 2006/06/17 12:33:03
2788 dnl Shorthand macro for substituting things that the user may override
2789 dnl with an environment variable.
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)
2802 dnl ---------------------------------------------------------------------------
2803 dnl CF_TERM_HEADER version: 1 updated: 2005/12/31 13:26:39
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%'`
2815 cf_term_header=term.h
2819 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2821 AC_TRY_COMPILE([#include <stdio.h>
2822 #include <${cf_cv_ncurses_header-curses.h}>
2824 ],[int x = auto_left_margin],[
2825 cf_cv_term_header="$cf_test"],[
2826 cf_cv_term_header=unknown
2828 test "$cf_cv_term_header" != unknown && break
2832 # Set definitions to allow ifdef'ing to accommodate subdirectories
2834 case $cf_cv_term_header in # (vi
2836 AC_DEFINE(HAVE_TERM_H)
2840 case $cf_cv_term_header in # (vi
2841 ncurses/term.h) #(vi
2842 AC_DEFINE(HAVE_NCURSES_TERM_H)
2845 AC_DEFINE(HAVE_NCURSESW_TERM_H)
2849 dnl ---------------------------------------------------------------------------
2850 dnl CF_TOP_BUILDDIR version: 1 updated: 2006/10/15 16:33:23
2852 dnl Define a top_builddir symbol, for applications that need an absolute path.
2853 AC_DEFUN([CF_TOP_BUILDDIR],
2856 AC_SUBST(top_builddir)
2858 dnl ---------------------------------------------------------------------------
2859 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
2861 dnl Make an uppercase version of a variable
2862 dnl $1=uppercase($2)
2863 AC_DEFUN([CF_UPPER],
2865 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
2867 dnl ---------------------------------------------------------------------------
2868 dnl CF_UTF8_LIB version: 5 updated: 2008/10/17 19:37:52
2870 dnl Check for multibyte support, and if not found, utf8 compatibility library
2871 AC_DEFUN([CF_UTF8_LIB],
2873 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
2874 cf_save_LIBS="$LIBS"
2876 #include <stdlib.h>],[putwc(0,0);],
2877 [cf_cv_utf8_lib=yes],
2879 #include <libutf8.h>],[putwc(0,0);],utf8,
2880 [cf_cv_utf8_lib=add-on],
2881 [cf_cv_utf8_lib=no])
2884 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
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)
2893 dnl ---------------------------------------------------------------------------
2894 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
2896 dnl Use AC_VERBOSE w/o the warnings
2897 AC_DEFUN([CF_VERBOSE],
2898 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
2901 dnl ---------------------------------------------------------------------------
2902 dnl CF_WEAK_SYMBOLS version: 1 updated: 2008/08/16 19:18:06
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,[
2910 #include <stdio.h>],
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)
2917 # define _weak_pragma(exp)
2919 # define _declare(name) __extension__ extern __typeof__(name) name
2920 # define weak_symbol(name) _weak_pragma(name) _declare(name) __attribute__((weak))
2924 ],[cf_cv_weak_symbols=yes],[cf_cv_weak_symbols=no])
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
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])
2939 dnl ---------------------------------------------------------------------------
2940 dnl CF_WITH_PATH version: 8 updated: 2007/05/13 13:16:35
2942 dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just
2943 dnl defaulting to yes/no.
2945 dnl $1 = option name
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
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)
2960 dnl ---------------------------------------------------------------------------
2961 dnl CF_WITH_PTHREAD version: 2 updated: 2008/08/23 18:26:05
2963 dnl Check for POSIX thread library.
2964 AC_DEFUN([CF_WITH_PTHREAD],
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],
2971 AC_MSG_RESULT($with_pthread)
2973 if test "$with_pthread" != no ; then
2974 AC_CHECK_HEADER(pthread.h,[
2975 AC_DEFINE(HAVE_PTHREADS_H)
2977 AC_MSG_CHECKING(if we can link with the pthread library)
2978 cf_save_LIBS="$LIBS"
2979 LIBS="-lpthread $LIBS"
2981 #include <pthread.h>
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)
2988 if test "$with_pthread" = yes ; then
2989 LIBS="-lpthread $LIBS"
2990 AC_DEFINE(HAVE_LIBPTHREADS)
2992 AC_MSG_ERROR(Cannot link with pthread library)
2997 dnl ---------------------------------------------------------------------------
2998 dnl CF_XOPEN_SOURCE version: 32 updated: 2010/01/09 11:05:50
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.
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],[
3009 cf_XOPEN_SOURCE=ifelse($1,,500,$1)
3010 cf_POSIX_C_SOURCE=ifelse($2,,199506L,$2)
3013 case $host_os in #(vi
3015 cf_xopen_source="-D_ALL_SOURCE"
3017 darwin[[0-8]].*) #(vi
3018 cf_xopen_source="-D_APPLE_C_SOURCE"
3021 cf_xopen_source="-D_DARWIN_C_SOURCE"
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
3029 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3032 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3035 cf_xopen_source="-D_HPUX_SOURCE"
3038 cf_xopen_source="-D_SGI_SOURCE"
3040 linux*|gnu*|mint*|k*bsd*-gnu) #(vi
3044 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
3047 # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3050 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3053 cf_xopen_source="-D_OSF_SOURCE"
3056 cf_xopen_source="-D_QNX_SOURCE"
3059 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3062 cf_xopen_source="-D__EXTENSIONS__"
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
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
3077 [cf_cv_xopen_source=no],
3078 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
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)
3088 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3092 if test -n "$cf_xopen_source" ; then
3093 CF_ADD_CFLAGS($cf_xopen_source)