1 dnl***************************************************************************
2 dnl Copyright (c) 2003-2014,2015 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 $Id: aclocal.m4,v 1.112 2015/04/26 00:54:24 tom Exp $
31 dnl Author: Thomas E. Dickey
33 dnl Macros used in NCURSES test programs auto-configuration script.
35 dnl These macros are maintained separately from NCURSES. The copyright on
36 dnl this file applies to the aggregation of macros and does not affect use of
37 dnl these macros in other applications.
39 dnl See http://invisible-island.net/autoconf/ for additional information.
41 dnl ---------------------------------------------------------------------------
42 dnl ---------------------------------------------------------------------------
43 dnl CF_ACVERSION_CHECK version: 5 updated: 2014/06/04 19:11:49
44 dnl ------------------
45 dnl Conditionally generate script according to whether we're using a given autoconf.
47 dnl $1 = version to compare against
48 dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
49 dnl $3 = code to use if AC_ACVERSION is older than $1.
50 define([CF_ACVERSION_CHECK],
52 ifdef([AC_ACVERSION], ,[ifdef([AC_AUTOCONF_VERSION],[m4_copy([AC_AUTOCONF_VERSION],[AC_ACVERSION])],[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])])dnl
53 ifdef([m4_version_compare],
54 [m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
55 [CF_ACVERSION_COMPARE(
56 AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
57 AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
58 dnl ---------------------------------------------------------------------------
59 dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
60 dnl --------------------
61 dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
62 dnl MAJOR2, MINOR2, TERNARY2,
63 dnl PRINTABLE2, not FOUND, FOUND)
64 define([CF_ACVERSION_COMPARE],
65 [ifelse(builtin([eval], [$2 < $5]), 1,
66 [ifelse([$8], , ,[$8])],
67 [ifelse([$9], , ,[$9])])])dnl
68 dnl ---------------------------------------------------------------------------
69 dnl CF_ADD_CFLAGS version: 12 updated: 2015/04/12 15:39:00
71 dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
72 dnl The second parameter if given makes this macro verbose.
74 dnl Put any preprocessor definitions that use quoted strings in $EXTRA_CPPFLAGS,
75 dnl to simplify use of $CPPFLAGS in compiler checks, etc., that are easily
76 dnl confused by the quotes (which require backslashes to keep them usable).
77 AC_DEFUN([CF_ADD_CFLAGS],
82 cf_new_extra_cppflags=
84 for cf_add_cflags in $1
86 case $cf_fix_cppflags in
88 case $cf_add_cflags in
89 (-undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
90 case $cf_add_cflags in
92 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^-D[[^=]]*='\''\"[[^"]]*//'`
94 test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
95 && test -z "${cf_tst_cflags}" \
96 && cf_fix_cppflags=yes
98 if test $cf_fix_cppflags = yes ; then
99 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
101 elif test "${cf_tst_cflags}" = "\"'" ; then
102 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
111 case $cf_add_cflags in
113 cf_tst_cppflags=`echo "x$cf_add_cflags" | sed -e 's/^...//' -e 's/=.*//'`
114 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,$cf_tst_cppflags)
117 cf_new_cppflags="$cf_new_cppflags $cf_add_cflags"
122 cf_new_cflags="$cf_new_cflags $cf_add_cflags"
127 cf_new_extra_cppflags="$cf_new_extra_cppflags $cf_add_cflags"
129 cf_tst_cflags=`echo ${cf_add_cflags} |sed -e 's/^[[^"]]*"'\''//'`
131 test "x${cf_add_cflags}" != "x${cf_tst_cflags}" \
132 && test -z "${cf_tst_cflags}" \
133 && cf_fix_cppflags=no
138 if test -n "$cf_new_cflags" ; then
139 ifelse([$2],,,[CF_VERBOSE(add to \$CFLAGS $cf_new_cflags)])
140 CFLAGS="$CFLAGS $cf_new_cflags"
143 if test -n "$cf_new_cppflags" ; then
144 ifelse([$2],,,[CF_VERBOSE(add to \$CPPFLAGS $cf_new_cppflags)])
145 CPPFLAGS="$CPPFLAGS $cf_new_cppflags"
148 if test -n "$cf_new_extra_cppflags" ; then
149 ifelse([$2],,,[CF_VERBOSE(add to \$EXTRA_CPPFLAGS $cf_new_extra_cppflags)])
150 EXTRA_CPPFLAGS="$cf_new_extra_cppflags $EXTRA_CPPFLAGS"
153 AC_SUBST(EXTRA_CPPFLAGS)
156 dnl ---------------------------------------------------------------------------
157 dnl CF_ADD_INCDIR version: 13 updated: 2010/05/26 16:44:57
159 dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's
160 dnl redundant. We don't normally need to add -I/usr/local/include for gcc,
161 dnl but old versions (and some misinstalled ones) need that. To make things
162 dnl worse, gcc 3.x may give error messages if -I/usr/local/include is added to
163 dnl the include-path).
164 AC_DEFUN([CF_ADD_INCDIR],
166 if test -n "$1" ; then
167 for cf_add_incdir in $1
169 while test $cf_add_incdir != /usr/include
171 if test -d $cf_add_incdir
174 if test -n "$CFLAGS$CPPFLAGS" ; then
175 # a loop is needed to ensure we can add subdirs of existing dirs
176 for cf_test_incdir in $CFLAGS $CPPFLAGS ; do
177 if test ".$cf_test_incdir" = ".-I$cf_add_incdir" ; then
178 cf_have_incdir=yes; break
183 if test "$cf_have_incdir" = no ; then
184 if test "$cf_add_incdir" = /usr/local/include ; then
187 cf_save_CPPFLAGS=$CPPFLAGS
188 CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
189 AC_TRY_COMPILE([#include <stdio.h>],
192 [cf_have_incdir=yes])
193 CPPFLAGS=$cf_save_CPPFLAGS
198 if test "$cf_have_incdir" = no ; then
199 CF_VERBOSE(adding $cf_add_incdir to include-path)
200 ifelse([$2],,CPPFLAGS,[$2])="$ifelse([$2],,CPPFLAGS,[$2]) -I$cf_add_incdir"
202 cf_top_incdir=`echo $cf_add_incdir | sed -e 's%/include/.*$%/include%'`
203 test "$cf_top_incdir" = "$cf_add_incdir" && break
204 cf_add_incdir="$cf_top_incdir"
213 dnl ---------------------------------------------------------------------------
214 dnl CF_ADD_LIB version: 2 updated: 2010/06/02 05:03:05
216 dnl Add a library, used to enforce consistency.
218 dnl $1 = library to add, without the "-l"
219 dnl $2 = variable to update (default $LIBS)
220 AC_DEFUN([CF_ADD_LIB],[CF_ADD_LIBS(-l$1,ifelse($2,,LIBS,[$2]))])dnl
221 dnl ---------------------------------------------------------------------------
222 dnl CF_ADD_LIBDIR version: 10 updated: 2015/04/18 08:56:57
224 dnl Adds to the library-path
226 dnl Some machines have trouble with multiple -L options.
228 dnl $1 is the (list of) directory(s) to add
229 dnl $2 is the optional name of the variable to update (default LDFLAGS)
231 AC_DEFUN([CF_ADD_LIBDIR],
233 if test -n "$1" ; then
234 for cf_add_libdir in $1
236 if test $cf_add_libdir = /usr/lib ; then
238 elif test -d $cf_add_libdir
241 if test -n "$LDFLAGS$LIBS" ; then
242 # a loop is needed to ensure we can add subdirs of existing dirs
243 for cf_test_libdir in $LDFLAGS $LIBS ; do
244 if test ".$cf_test_libdir" = ".-L$cf_add_libdir" ; then
245 cf_have_libdir=yes; break
249 if test "$cf_have_libdir" = no ; then
250 CF_VERBOSE(adding $cf_add_libdir to library-path)
251 ifelse([$2],,LDFLAGS,[$2])="-L$cf_add_libdir $ifelse([$2],,LDFLAGS,[$2])"
257 dnl ---------------------------------------------------------------------------
258 dnl CF_ADD_LIBS version: 2 updated: 2014/07/13 14:33:27
260 dnl Add one or more libraries, used to enforce consistency. Libraries are
261 dnl prepended to an existing list, since their dependencies are assumed to
262 dnl already exist in the list.
264 dnl $1 = libraries to add, with the "-l", etc.
265 dnl $2 = variable to update (default $LIBS)
266 AC_DEFUN([CF_ADD_LIBS],[
268 # Filter out duplicates - this happens with badly-designed ".pc" files...
269 for cf_add_1lib in [$]ifelse($2,,LIBS,[$2])
271 for cf_add_2lib in $cf_add_libs
273 if test "x$cf_add_1lib" = "x$cf_add_2lib"
279 test -n "$cf_add_1lib" && cf_add_libs="$cf_add_libs $cf_add_1lib"
281 ifelse($2,,LIBS,[$2])="$cf_add_libs"
283 dnl ---------------------------------------------------------------------------
284 dnl CF_ADD_LIB_AFTER version: 3 updated: 2013/07/09 21:27:22
286 dnl Add a given library after another, e.g., following the one it satisfies a
289 dnl $1 = the first library
290 dnl $2 = its dependency
291 AC_DEFUN([CF_ADD_LIB_AFTER],[
292 CF_VERBOSE(...before $LIBS)
293 LIBS=`echo "$LIBS" | sed -e "s/[[ ]][[ ]]*/ /g" -e "s%$1 %$1 $2 %" -e 's% % %g'`
294 CF_VERBOSE(...after $LIBS)
296 dnl ---------------------------------------------------------------------------
297 dnl CF_ADD_SUBDIR_PATH version: 4 updated: 2013/10/08 17:47:05
298 dnl ------------------
299 dnl Append to a search-list for a nonstandard header/lib-file
300 dnl $1 = the variable to return as result
301 dnl $2 = the package name
302 dnl $3 = the subdirectory, e.g., bin, include or lib
303 dnl $4 = the directory under which we will test for subdirectories
304 dnl $5 = a directory that we do not want $4 to match
305 AC_DEFUN([CF_ADD_SUBDIR_PATH],
307 test "x$4" != "x$5" && \
309 ifelse([$5],NONE,,[(test -z "$5" || test x$5 = xNONE || test "x$4" != "x$5") &&]) {
310 test -n "$verbose" && echo " ... testing for $3-directories under $4"
311 test -d $4/$3 && $1="[$]$1 $4/$3"
312 test -d $4/$3/$2 && $1="[$]$1 $4/$3/$2"
313 test -d $4/$3/$2/$3 && $1="[$]$1 $4/$3/$2/$3"
314 test -d $4/$2/$3 && $1="[$]$1 $4/$2/$3"
315 test -d $4/$2/$3/$2 && $1="[$]$1 $4/$2/$3/$2"
318 dnl ---------------------------------------------------------------------------
319 dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
321 dnl Allow user to disable a normally-on option.
322 AC_DEFUN([CF_ARG_DISABLE],
323 [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl
324 dnl ---------------------------------------------------------------------------
325 dnl CF_ARG_ENABLE version: 3 updated: 1999/03/30 17:24:31
327 dnl Allow user to enable a normally-off option.
328 AC_DEFUN([CF_ARG_ENABLE],
329 [CF_ARG_OPTION($1,[$2],[$3],[$4],no)])dnl
330 dnl ---------------------------------------------------------------------------
331 dnl CF_ARG_OPTION version: 4 updated: 2010/05/26 05:38:42
333 dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
339 dnl $3 = action to perform if option is not default
340 dnl $4 = action if perform if option is default
341 dnl $5 = default option value (either 'yes' or 'no')
342 AC_DEFUN([CF_ARG_OPTION],
343 [AC_ARG_ENABLE([$1],[$2],[test "$enableval" != ifelse([$5],no,yes,no) && enableval=ifelse([$5],no,no,yes)
344 if test "$enableval" != "$5" ; then
346 ,[ $3]) ifelse([$4],,,[
349 fi],[enableval=$5 ifelse([$4],,,[
353 dnl ---------------------------------------------------------------------------
354 dnl CF_CC_ENV_FLAGS version: 2 updated: 2015/04/12 15:39:00
356 dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
357 dnl into CC. This will not help with broken scripts that wrap the compiler with
358 dnl options, but eliminates a more common category of user confusion.
359 AC_DEFUN([CF_CC_ENV_FLAGS],
361 # This should have been defined by AC_PROG_CC
364 AC_MSG_CHECKING(\$CC variable)
367 AC_MSG_RESULT(broken)
368 AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
370 cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
371 CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
372 CF_ADD_CFLAGS($cf_flags)
379 dnl ---------------------------------------------------------------------------
380 dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
382 dnl Check if we're accidentally using a cache from a different machine.
383 dnl Derive the system name, as a check for reusing the autoconf cache.
385 dnl If we've packaged config.guess and config.sub, run that (since it does a
386 dnl better job than uname). Normally we'll use AC_CANONICAL_HOST, but allow
387 dnl an extra parameter that we may override, e.g., for AC_CANONICAL_SYSTEM
388 dnl which is useful in cross-compiles.
390 dnl Note: we would use $ac_config_sub, but that is one of the places where
391 dnl autoconf 2.5x broke compatibility with autoconf 2.13
392 AC_DEFUN([CF_CHECK_CACHE],
394 if test -f $srcdir/config.guess || test -f $ac_aux_dir/config.guess ; then
395 ifelse([$1],,[AC_CANONICAL_HOST],[$1])
396 system_name="$host_os"
398 system_name="`(uname -s -r) 2>/dev/null`"
399 if test -z "$system_name" ; then
400 system_name="`(hostname) 2>/dev/null`"
403 test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
404 AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
406 test -z "$system_name" && system_name="$cf_cv_system_name"
407 test -n "$cf_cv_system_name" && AC_MSG_RESULT(Configuring for $cf_cv_system_name)
409 if test ".$system_name" != ".$cf_cv_system_name" ; then
410 AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
411 AC_MSG_ERROR("Please remove config.cache and try again.")
414 dnl ---------------------------------------------------------------------------
415 dnl CF_CHECK_CFLAGS version: 3 updated: 2014/07/22 05:32:57
417 dnl Conditionally add to $CFLAGS and $CPPFLAGS values which are derived from
418 dnl a build-configuration such as imake. These have the pitfall that they
419 dnl often contain compiler-specific options which we cannot use, mixed with
420 dnl preprocessor options that we usually can.
421 AC_DEFUN([CF_CHECK_CFLAGS],
423 CF_VERBOSE(checking additions to CFLAGS)
424 cf_check_cflags="$CFLAGS"
425 cf_check_cppflags="$CPPFLAGS"
426 CF_ADD_CFLAGS($1,yes)
427 if test "x$cf_check_cflags" != "x$CFLAGS" ; then
428 AC_TRY_LINK([#include <stdio.h>],[printf("Hello world");],,
429 [CF_VERBOSE(test-compile failed. Undoing change to \$CFLAGS)
430 if test "x$cf_check_cppflags" != "x$CPPFLAGS" ; then
431 CF_VERBOSE(but keeping change to \$CPPFLAGS)
433 CFLAGS="$cf_check_flags"])
436 dnl ---------------------------------------------------------------------------
437 dnl CF_CHECK_CURSES_LIB version: 1 updated: 2015/04/25 20:53:11
438 dnl -------------------
439 dnl $1 = nominal library name, used also for header lookup
440 dnl $2 = suffix to append to library name
441 dnl $3 = function to check for using AC_CHECK_LIB
442 AC_DEFUN([CF_CHECK_CURSES_LIB],
444 AC_CHECK_LIB($1$2,$3,[
445 CF_UPPER(cf_upper,have_lib$1)
447 AC_DEFINE_UNQUOTED($cf_upper,1)])
449 dnl ---------------------------------------------------------------------------
450 dnl CF_CLANG_COMPILER version: 2 updated: 2013/11/19 19:23:35
451 dnl -----------------
452 dnl Check if the given compiler is really clang. clang's C driver defines
453 dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
454 dnl not ignore some gcc options.
456 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
457 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
458 dnl the wrappers for gcc and g++ warnings.
460 dnl $1 = GCC (default) or GXX
461 dnl $2 = CLANG_COMPILER (default)
462 dnl $3 = CFLAGS (default) or CXXFLAGS
463 AC_DEFUN([CF_CLANG_COMPILER],[
464 ifelse([$2],,CLANG_COMPILER,[$2])=no
466 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
467 AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
468 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
469 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
475 ],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
476 cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
478 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
479 AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
482 dnl ---------------------------------------------------------------------------
483 dnl CF_CURSES_ACS_MAP version: 7 updated: 2012/10/06 16:39:58
484 dnl -----------------
485 dnl Check for likely values of acs_map[]:
486 AC_DEFUN([CF_CURSES_ACS_MAP],
488 AC_REQUIRE([CF_NCURSES_WRAP_PREFIX])dnl
489 AC_CACHE_CHECK(for alternate character set array, cf_cv_curses_acs_map,[
490 cf_cv_curses_acs_map=unknown
491 for name in acs_map _acs_map __acs_map ${NCURSES_WRAP_PREFIX}acs_map
494 #include <${cf_cv_ncurses_header:-curses.h}>
496 $name['k'] = ACS_PLUS
497 ],[cf_cv_curses_acs_map=$name; break])
501 test "$cf_cv_curses_acs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_ACS_ARRAY,$cf_cv_curses_acs_map,[Define as needed to override ncurses prefix _nc_])
503 dnl ---------------------------------------------------------------------------
504 dnl CF_CURSES_CHECK_DATA version: 5 updated: 2014/07/19 18:41:17
505 dnl --------------------
506 dnl Check if curses.h defines the given data/variable.
507 dnl Use this after CF_NCURSES_CONFIG or CF_CURSES_CONFIG.
508 AC_DEFUN([CF_CURSES_CHECK_DATA],
510 AC_MSG_CHECKING(for data $1 declaration in ${cf_cv_ncurses_header:-curses.h})
512 AC_TRY_COMPILE(CF__CURSES_HEAD,[
514 ],cf_result=yes,cf_result=no)
515 AC_MSG_RESULT($cf_result)
517 if test $cf_result = yes ; then
518 CF_UPPER(cf_result,have_curses_data_$1)
519 AC_DEFINE_UNQUOTED($cf_result)
521 AC_MSG_CHECKING(for data $1 in library)
522 # BSD linkers insist on making weak linkage, but resolve at runtime.
523 AC_TRY_RUN(CF__CURSES_HEAD
529 fprintf(stderr, "testing linkage of $1:%p\n", foo);
530 ${cf_cv_main_return:-return}(foo == 0);
531 }],[cf_result=yes],[cf_result=no],[
533 AC_TRY_LINK(CF__CURSES_HEAD
537 fprintf(stderr, "testing linkage of $1:%p\n", foo);
538 ${cf_cv_main_return:-return}(foo == 0);
540 ],[cf_result=yes],[cf_result=no])
542 AC_MSG_RESULT($cf_result)
543 if test $cf_result = yes ; then
544 CF_UPPER(cf_result,decl_curses_data_$1)
545 AC_DEFINE_UNQUOTED($cf_result)
549 dnl ---------------------------------------------------------------------------
550 dnl CF_CURSES_CHECK_TYPE version: 4 updated: 2012/10/06 16:39:58
551 dnl --------------------
552 dnl Check if curses.h defines the given type
553 AC_DEFUN([CF_CURSES_CHECK_TYPE],
555 AC_MSG_CHECKING(for type $1 in ${cf_cv_ncurses_header:-curses.h})
557 #ifndef _XOPEN_SOURCE_EXTENDED
558 #define _XOPEN_SOURCE_EXTENDED
560 #include <${cf_cv_ncurses_header:-curses.h}>],[
562 ],cf_result=yes,cf_result=no)
563 AC_MSG_RESULT($cf_result)
564 if test $cf_result = yes ; then
565 CF_UPPER(cf_result,have_type_$1)
566 AC_DEFINE_UNQUOTED($cf_result,1,[Define to 1 if we have type $1])
568 AC_DEFINE_UNQUOTED($1,$2,[Define to appropriate type if $1 is not declared])
571 dnl ---------------------------------------------------------------------------
572 dnl CF_CURSES_CONFIG version: 2 updated: 2006/10/29 11:06:27
574 dnl Tie together the configure-script macros for curses. It may be ncurses,
575 dnl but unless asked, we do not make a special search for ncurses. However,
576 dnl still check for the ncurses version number, for use in other macros.
577 AC_DEFUN([CF_CURSES_CONFIG],
583 dnl ---------------------------------------------------------------------------
584 dnl CF_CURSES_CPPFLAGS version: 12 updated: 2015/04/15 19:08:48
585 dnl ------------------
586 dnl Look for the curses headers.
587 AC_DEFUN([CF_CURSES_CPPFLAGS],[
589 AC_CACHE_CHECK(for extra include directories,cf_cv_curses_incdir,[
590 cf_cv_curses_incdir=no
593 if test "x$cf_cv_screen" = "xcurses_colr"
595 test -d /usr/include/curses_colr && \
596 cf_cv_curses_incdir="-I/usr/include/curses_colr"
600 if test "x$cf_cv_screen" = "xcurses_5lib"
602 test -d /usr/5lib && \
603 test -d /usr/5include && \
604 cf_cv_curses_incdir="-I/usr/5include"
609 test "$cf_cv_curses_incdir" != no && CPPFLAGS="$CPPFLAGS $cf_cv_curses_incdir"
614 dnl ---------------------------------------------------------------------------
615 dnl CF_CURSES_FUNCS version: 18 updated: 2014/07/19 18:44:41
617 dnl Curses-functions are a little complicated, since a lot of them are macros.
618 AC_DEFUN([CF_CURSES_FUNCS],
620 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
621 AC_REQUIRE([CF_XOPEN_CURSES])
622 AC_REQUIRE([CF_CURSES_TERM_H])
623 AC_REQUIRE([CF_CURSES_UNCTRL_H])
626 CF_UPPER(cf_tr_func,$cf_func)
627 AC_MSG_CHECKING(for ${cf_func})
628 CF_MSG_LOG(${cf_func})
629 AC_CACHE_VAL(cf_cv_func_$cf_func,[
630 eval cf_result='$ac_cv_func_'$cf_func
631 if test ".$cf_result" != ".no"; then
632 AC_TRY_LINK(CF__CURSES_HEAD,
635 long foo = (long)(&${cf_func});
636 fprintf(stderr, "testing linkage of $cf_func:%p\n", foo);
637 if (foo + 1234 > 5678)
638 ${cf_cv_main_return:-return}(foo);
644 eval 'cf_cv_func_'$cf_func'=$cf_result'
646 # use the computed/retrieved cache-value:
647 eval 'cf_result=$cf_cv_func_'$cf_func
648 AC_MSG_RESULT($cf_result)
649 if test $cf_result != no; then
650 AC_DEFINE_UNQUOTED(HAVE_${cf_tr_func})
654 dnl ---------------------------------------------------------------------------
655 dnl CF_CURSES_HEADER version: 5 updated: 2015/04/23 20:35:30
657 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
658 dnl variations of ncurses' installs.
660 dnl $1 = ncurses when looking for ncurses, or is empty
661 AC_DEFUN([CF_CURSES_HEADER],[
662 AC_CACHE_CHECK(if we have identified curses headers,cf_cv_ncurses_header,[
663 cf_cv_ncurses_header=none
665 ncurses.h ifelse($1,,,[$1/ncurses.h]) \
666 curses.h ifelse($1,,,[$1/curses.h]) ifelse($1,,[ncurses/ncurses.h ncurses/curses.h])
668 AC_TRY_COMPILE([#include <${cf_header}>],
669 [initscr(); tgoto("?", 0,0)],
670 [cf_cv_ncurses_header=$cf_header; break],[])
674 if test "$cf_cv_ncurses_header" = none ; then
675 AC_MSG_ERROR(No curses header-files found)
678 # cheat, to get the right #define's for HAVE_NCURSES_H, etc.
679 AC_CHECK_HEADERS($cf_cv_ncurses_header)
681 dnl ---------------------------------------------------------------------------
682 dnl CF_CURSES_LIBS version: 38 updated: 2015/04/15 19:08:48
684 dnl Look for the curses libraries. Older curses implementations may require
685 dnl termcap/termlib to be linked as well. Call CF_CURSES_CPPFLAGS first.
686 AC_DEFUN([CF_CURSES_LIBS],[
688 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
689 AC_MSG_CHECKING(if we have identified curses libraries)
690 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
691 [initscr(); tgoto("?", 0,0)],
694 AC_MSG_RESULT($cf_result)
696 if test "$cf_result" = no ; then
699 AC_CHECK_LIB(mytinfo,tgoto,[CF_ADD_LIBS(-lmytinfo)])
702 # Looking at HPUX 10.20, the Hcurses library is the oldest (1997), cur_colr
703 # next (1998), and xcurses "newer" (2000). There is no header file for
704 # Hcurses; the subdirectory curses_colr has the headers (curses.h and
705 # term.h) for cur_colr
706 if test "x$cf_cv_screen" = "xcurses_colr"
708 AC_CHECK_LIB(cur_colr,initscr,[
709 CF_ADD_LIBS(-lcur_colr)
710 ac_cv_func_initscr=yes
712 AC_CHECK_LIB(Hcurses,initscr,[
713 # HP's header uses __HP_CURSES, but user claims _HP_CURSES.
714 CF_ADD_LIBS(-lHcurses)
715 CPPFLAGS="$CPPFLAGS -D__HP_CURSES -D_HP_CURSES"
716 ac_cv_func_initscr=yes
721 case `arch 2>/dev/null` in
725 CF_ADD_LIBDIR(/lib64)
736 if test "x$cf_cv_screen" = "xcurses_5lib"
738 if test -d /usr/5lib ; then
739 CF_ADD_LIBDIR(/usr/5lib)
740 CF_ADD_LIBS(-lcurses -ltermcap)
743 ac_cv_func_initscr=yes
747 if test ".$ac_cv_func_initscr" != .yes ; then
750 if test ".${cf_cv_ncurses_version:-no}" != .no
752 cf_check_list="ncurses curses cursesX"
754 cf_check_list="cursesX curses ncurses"
757 # Check for library containing tgoto. Do this before curses library
758 # because it may be needed to link the test-case for initscr.
759 if test "x$cf_term_lib" = x
761 AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[
762 for cf_term_lib in $cf_check_list otermcap termcap tinfo termlib unknown
764 AC_CHECK_LIB($cf_term_lib,tgoto,[break])
769 # Check for library containing initscr
770 test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS"
771 if test "x$cf_curs_lib" = x
773 for cf_curs_lib in $cf_check_list xcurses jcurses pdcurses unknown
775 AC_CHECK_LIB($cf_curs_lib,initscr,[break])
778 test $cf_curs_lib = unknown && AC_MSG_ERROR(no curses library found)
780 LIBS="-l$cf_curs_lib $cf_save_LIBS"
781 if test "$cf_term_lib" = unknown ; then
782 AC_MSG_CHECKING(if we can link with $cf_curs_lib library)
783 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
787 AC_MSG_RESULT($cf_result)
788 test $cf_result = no && AC_MSG_ERROR(Cannot link curses library)
789 elif test "$cf_curs_lib" = "$cf_term_lib" ; then
791 elif test "$cf_term_lib" != predefined ; then
792 AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries)
793 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
794 [initscr(); tgoto((char *)0, 0, 0);],
797 LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS"
798 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
803 AC_MSG_RESULT($cf_result)
809 dnl ---------------------------------------------------------------------------
810 dnl CF_CURSES_TERM_H version: 11 updated: 2015/04/15 19:08:48
812 dnl SVr4 curses should have term.h as well (where it puts the definitions of
813 dnl the low-level interface). This may not be true in old/broken implementations,
814 dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
815 dnl running with Solaris 2.5.1).
816 AC_DEFUN([CF_CURSES_TERM_H],
818 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
820 AC_CACHE_CHECK(for term.h, cf_cv_term_header,[
822 # If we found <ncurses/curses.h>, look for <ncurses/term.h>, but always look
823 # for <term.h> if we do not find the variant.
825 cf_header_list="term.h ncurses/term.h ncursesw/term.h"
827 case ${cf_cv_ncurses_header:-curses.h} in
829 cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`term.h
830 cf_header_list="$cf_header_item $cf_header_list"
834 for cf_header in $cf_header_list
837 #include <${cf_cv_ncurses_header:-curses.h}>
838 #include <${cf_header}>],
840 [cf_cv_term_header=$cf_header
842 [cf_cv_term_header=no])
845 case $cf_cv_term_header in
847 # If curses is ncurses, some packagers still mess it up by trying to make
848 # us use GNU termcap. This handles the most common case.
849 for cf_header in ncurses/term.h ncursesw/term.h
852 #include <${cf_cv_ncurses_header:-curses.h}>
853 #ifdef NCURSES_VERSION
854 #include <${cf_header}>
859 [cf_cv_term_header=$cf_header
861 [cf_cv_term_header=no])
867 case $cf_cv_term_header in
869 AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
872 AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
875 AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
879 dnl ---------------------------------------------------------------------------
880 dnl CF_CURSES_UNCTRL_H version: 4 updated: 2015/04/15 19:08:48
881 dnl ------------------
882 dnl Any X/Open curses implementation must have unctrl.h, but ncurses packages
883 dnl may put it in a subdirectory (along with ncurses' other headers, of
884 dnl course). Packages which put the headers in inconsistent locations are
886 AC_DEFUN([CF_CURSES_UNCTRL_H],
888 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
890 AC_CACHE_CHECK(for unctrl.h, cf_cv_unctrl_header,[
892 # If we found <ncurses/curses.h>, look for <ncurses/unctrl.h>, but always look
893 # for <unctrl.h> if we do not find the variant.
895 cf_header_list="unctrl.h ncurses/unctrl.h ncursesw/unctrl.h"
897 case ${cf_cv_ncurses_header:-curses.h} in
899 cf_header_item=`echo ${cf_cv_ncurses_header:-curses.h} | sed -e 's%\..*%%' -e 's%/.*%/%'`unctrl.h
900 cf_header_list="$cf_header_item $cf_header_list"
904 for cf_header in $cf_header_list
907 #include <${cf_cv_ncurses_header:-curses.h}>
908 #include <${cf_header}>],
910 [cf_cv_unctrl_header=$cf_header
912 [cf_cv_unctrl_header=no])
916 case $cf_cv_unctrl_header in
918 AC_MSG_WARN(unctrl.h header not found)
922 case $cf_cv_unctrl_header in
924 AC_DEFINE(HAVE_UNCTRL_H,1,[Define to 1 if we have unctrl.h])
927 AC_DEFINE(HAVE_NCURSES_UNCTRL_H,1,[Define to 1 if we have ncurses/unctrl.h])
930 AC_DEFINE(HAVE_NCURSESW_UNCTRL_H,1,[Define to 1 if we have ncursesw/unctrl.h])
934 dnl ---------------------------------------------------------------------------
935 dnl CF_CURSES_WACS_MAP version: 6 updated: 2012/10/06 08:57:51
936 dnl ------------------
937 dnl Check for likely values of wacs_map[].
938 AC_DEFUN([CF_CURSES_WACS_MAP],
940 AC_CACHE_CHECK(for wide alternate character set array, cf_cv_curses_wacs_map,[
941 cf_cv_curses_wacs_map=unknown
942 for name in wacs_map _wacs_map __wacs_map _nc_wacs _wacs_char
945 #ifndef _XOPEN_SOURCE_EXTENDED
946 #define _XOPEN_SOURCE_EXTENDED
948 #include <${cf_cv_ncurses_header:-curses.h}>],
949 [void *foo = &($name['k'])],
950 [cf_cv_curses_wacs_map=$name
954 test "$cf_cv_curses_wacs_map" != unknown && AC_DEFINE_UNQUOTED(CURSES_WACS_ARRAY,$cf_cv_curses_wacs_map,[Define to name of (n)curses wide-character array])
956 dnl ---------------------------------------------------------------------------
957 dnl CF_CURSES_WACS_SYMBOLS version: 2 updated: 2012/10/06 08:57:51
958 dnl ----------------------
959 dnl Do a check to see if the WACS_xxx constants are defined compatibly with
960 dnl X/Open Curses. In particular, NetBSD's implementation of the WACS_xxx
961 dnl constants is broken since those constants do not point to cchar_t's.
962 AC_DEFUN([CF_CURSES_WACS_SYMBOLS],
964 AC_REQUIRE([CF_CURSES_WACS_MAP])
966 AC_CACHE_CHECK(for wide alternate character constants, cf_cv_curses_wacs_symbols,[
967 cf_cv_curses_wacs_symbols=no
968 if test "$cf_cv_curses_wacs_map" != unknown
971 #ifndef _XOPEN_SOURCE_EXTENDED
972 #define _XOPEN_SOURCE_EXTENDED
974 #include <${cf_cv_ncurses_header:-curses.h}>],
975 [cchar_t *foo = WACS_PLUS;
976 $cf_cv_curses_wacs_map['k'] = *WACS_PLUS],
977 [cf_cv_curses_wacs_symbols=yes])
980 #ifndef _XOPEN_SOURCE_EXTENDED
981 #define _XOPEN_SOURCE_EXTENDED
983 #include <${cf_cv_ncurses_header:-curses.h}>],
984 [cchar_t *foo = WACS_PLUS],
985 [cf_cv_curses_wacs_symbols=yes])
989 test "$cf_cv_curses_wacs_symbols" != no && AC_DEFINE(CURSES_WACS_SYMBOLS,1,[Define to 1 if (n)curses supports wide-character WACS_ symbols])
991 dnl ---------------------------------------------------------------------------
992 dnl CF_DIRNAME version: 4 updated: 2002/12/21 19:25:52
994 dnl "dirname" is not portable, so we fake it with a shell script.
995 AC_DEFUN([CF_DIRNAME],[$1=`echo $2 | sed -e 's%/[[^/]]*$%%'`])dnl
996 dnl ---------------------------------------------------------------------------
997 dnl CF_DISABLE_ECHO version: 13 updated: 2015/04/18 08:56:57
999 dnl You can always use "make -n" to see the actual options, but it's hard to
1000 dnl pick out/analyze warning messages when the compile-line is long.
1003 dnl ECHO_LT - symbol to control if libtool is verbose
1004 dnl ECHO_LD - symbol to prefix "cc -o" lines
1005 dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
1006 dnl SHOW_CC - symbol to put before explicit "cc -c" lines
1007 dnl ECHO_CC - symbol to put before any "cc" line
1009 AC_DEFUN([CF_DISABLE_ECHO],[
1010 AC_MSG_CHECKING(if you want to see long compiling messages)
1011 CF_ARG_DISABLE(echo,
1012 [ --disable-echo do not display "compiling" commands],
1015 ECHO_LD='@echo linking [$]@;'
1016 RULE_CC='@echo compiling [$]<'
1017 SHOW_CC='@echo compiling [$]@'
1026 AC_MSG_RESULT($enableval)
1033 dnl ---------------------------------------------------------------------------
1034 dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
1035 dnl ----------------
1036 dnl Combine no-leak checks with the libraries or tools that are used for the
1038 AC_DEFUN([CF_DISABLE_LEAKS],[
1040 AC_REQUIRE([CF_WITH_DMALLOC])
1041 AC_REQUIRE([CF_WITH_DBMALLOC])
1042 AC_REQUIRE([CF_WITH_VALGRIND])
1044 AC_MSG_CHECKING(if you want to perform memory-leak testing)
1045 AC_ARG_ENABLE(leaks,
1046 [ --disable-leaks test: free permanent memory, analyze leaks],
1047 [if test "x$enableval" = xno; then with_no_leaks=yes; else with_no_leaks=no; fi],
1048 : ${with_no_leaks:=no})
1049 AC_MSG_RESULT($with_no_leaks)
1051 if test "$with_no_leaks" = yes ; then
1052 AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
1053 AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
1056 dnl ---------------------------------------------------------------------------
1057 dnl CF_DISABLE_RPATH_HACK version: 2 updated: 2011/02/13 13:31:33
1058 dnl ---------------------
1059 dnl The rpath-hack makes it simpler to build programs, particularly with the
1060 dnl *BSD ports which may have essential libraries in unusual places. But it
1061 dnl can interfere with building an executable for the base system. Use this
1062 dnl option in that case.
1063 AC_DEFUN([CF_DISABLE_RPATH_HACK],
1065 AC_MSG_CHECKING(if rpath-hack should be disabled)
1066 CF_ARG_DISABLE(rpath-hack,
1067 [ --disable-rpath-hack don't add rpath options for additional libraries],
1068 [cf_disable_rpath_hack=yes],
1069 [cf_disable_rpath_hack=no])
1070 AC_MSG_RESULT($cf_disable_rpath_hack)
1071 if test "$cf_disable_rpath_hack" = no ; then
1075 dnl ---------------------------------------------------------------------------
1076 dnl CF_ENABLE_WARNINGS version: 4 updated: 2009/07/26 17:53:03
1077 dnl ------------------
1078 dnl Configure-option to enable gcc warnings
1079 AC_DEFUN([CF_ENABLE_WARNINGS],[
1080 if ( test "$GCC" = yes || test "$GXX" = yes )
1082 AC_MSG_CHECKING(if you want to turn on gcc warnings)
1083 CF_ARG_ENABLE(warnings,
1084 [ --enable-warnings test: turn on gcc compiler warnings],
1085 [with_warnings=yes],
1087 AC_MSG_RESULT($with_warnings)
1088 if test "$with_warnings" = "yes"
1095 dnl ---------------------------------------------------------------------------
1096 dnl CF_FIND_LIBRARY version: 9 updated: 2008/03/23 14:48:54
1098 dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We
1099 dnl prefer a standard location, and use -L options only if we do not find the
1100 dnl library in the standard library location(s).
1101 dnl $1 = library name
1102 dnl $2 = library class, usually the same as library name
1104 dnl $4 = code fragment to compile/link
1105 dnl $5 = corresponding function-name
1106 dnl $6 = flag, nonnull if failure should not cause an error-exit
1108 dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
1109 dnl to use a -L option.
1110 AC_DEFUN([CF_FIND_LIBRARY],
1112 eval 'cf_cv_have_lib_'$1'=no'
1115 eval 'cf_cv_have_lib_'$1'=yes',[
1116 cf_save_LIBS="$LIBS"
1117 AC_MSG_CHECKING(for $5 in -l$1)
1119 AC_TRY_LINK([$3],[$4],
1121 eval 'cf_cv_have_lib_'$1'=yes'
1124 CF_LIBRARY_PATH(cf_search,$2)
1125 for cf_libdir in $cf_search
1127 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
1128 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
1129 AC_TRY_LINK([$3],[$4],
1131 eval 'cf_cv_have_lib_'$1'=yes'
1134 LIBS="$cf_save_LIBS"])
1138 eval 'cf_found_library=[$]cf_cv_have_lib_'$1
1140 if test $cf_found_library = no ; then
1141 AC_MSG_ERROR(Cannot link $1 library)
1145 dnl ---------------------------------------------------------------------------
1146 dnl CF_FIND_LINKAGE version: 20 updated: 2015/04/18 08:56:57
1148 dnl Find a library (specifically the linkage used in the code fragment),
1149 dnl searching for it if it is not already in the library path.
1150 dnl See also CF_ADD_SEARCHPATH.
1152 dnl Parameters (4-on are optional):
1153 dnl $1 = headers for library entrypoint
1154 dnl $2 = code fragment for library entrypoint
1155 dnl $3 = the library name without the "-l" option or ".so" suffix.
1156 dnl $4 = action to perform if successful (default: update CPPFLAGS, etc)
1157 dnl $5 = action to perform if not successful
1158 dnl $6 = module name, if not the same as the library name
1159 dnl $7 = extra libraries
1161 dnl Sets these variables:
1162 dnl $cf_cv_find_linkage_$3 - yes/no according to whether linkage is found
1163 dnl $cf_cv_header_path_$3 - include-directory if needed
1164 dnl $cf_cv_library_path_$3 - library-directory if needed
1165 dnl $cf_cv_library_file_$3 - library-file if needed, e.g., -l$3
1166 AC_DEFUN([CF_FIND_LINKAGE],[
1168 # If the linkage is not already in the $CPPFLAGS/$LDFLAGS configuration, these
1169 # will be set on completion of the AC_TRY_LINK below.
1170 cf_cv_header_path_$3=
1171 cf_cv_library_path_$3=
1173 CF_MSG_LOG([Starting [FIND_LINKAGE]($3,$6)])
1175 cf_save_LIBS="$LIBS"
1177 AC_TRY_LINK([$1],[$2],[
1178 cf_cv_find_linkage_$3=yes
1179 cf_cv_header_path_$3=/usr/include
1180 cf_cv_library_path_$3=/usr/lib
1183 LIBS="-l$3 $7 $cf_save_LIBS"
1185 AC_TRY_LINK([$1],[$2],[
1186 cf_cv_find_linkage_$3=yes
1187 cf_cv_header_path_$3=/usr/include
1188 cf_cv_library_path_$3=/usr/lib
1189 cf_cv_library_file_$3="-l$3"
1191 cf_cv_find_linkage_$3=no
1192 LIBS="$cf_save_LIBS"
1194 CF_VERBOSE(find linkage for $3 library)
1195 CF_MSG_LOG([Searching for headers in [FIND_LINKAGE]($3,$6)])
1197 cf_save_CPPFLAGS="$CPPFLAGS"
1198 cf_test_CPPFLAGS="$CPPFLAGS"
1200 CF_HEADER_PATH(cf_search,ifelse([$6],,[$3],[$6]))
1201 for cf_cv_header_path_$3 in $cf_search
1203 if test -d $cf_cv_header_path_$3 ; then
1204 CF_VERBOSE(... testing $cf_cv_header_path_$3)
1205 CPPFLAGS="$cf_save_CPPFLAGS -I$cf_cv_header_path_$3"
1206 AC_TRY_COMPILE([$1],[$2],[
1207 CF_VERBOSE(... found $3 headers in $cf_cv_header_path_$3)
1208 cf_cv_find_linkage_$3=maybe
1209 cf_test_CPPFLAGS="$CPPFLAGS"
1211 CPPFLAGS="$cf_save_CPPFLAGS"
1216 if test "$cf_cv_find_linkage_$3" = maybe ; then
1218 CF_MSG_LOG([Searching for $3 library in [FIND_LINKAGE]($3,$6)])
1220 cf_save_LIBS="$LIBS"
1221 cf_save_LDFLAGS="$LDFLAGS"
1224 CPPFLAGS="$cf_test_CPPFLAGS"
1225 LIBS="-l$3 $7 $cf_save_LIBS"
1226 AC_TRY_LINK([$1],[$2],[
1227 CF_VERBOSE(... found $3 library in system)
1228 cf_cv_find_linkage_$3=yes])
1229 CPPFLAGS="$cf_save_CPPFLAGS"
1230 LIBS="$cf_save_LIBS"
1233 if test "$cf_cv_find_linkage_$3" != yes ; then
1234 CF_LIBRARY_PATH(cf_search,$3)
1235 for cf_cv_library_path_$3 in $cf_search
1237 if test -d $cf_cv_library_path_$3 ; then
1238 CF_VERBOSE(... testing $cf_cv_library_path_$3)
1239 CPPFLAGS="$cf_test_CPPFLAGS"
1240 LIBS="-l$3 $7 $cf_save_LIBS"
1241 LDFLAGS="$cf_save_LDFLAGS -L$cf_cv_library_path_$3"
1242 AC_TRY_LINK([$1],[$2],[
1243 CF_VERBOSE(... found $3 library in $cf_cv_library_path_$3)
1244 cf_cv_find_linkage_$3=yes
1245 cf_cv_library_file_$3="-l$3"
1247 CPPFLAGS="$cf_save_CPPFLAGS"
1248 LIBS="$cf_save_LIBS"
1249 LDFLAGS="$cf_save_LDFLAGS"
1253 CPPFLAGS="$cf_save_CPPFLAGS"
1254 LDFLAGS="$cf_save_LDFLAGS"
1258 cf_cv_find_linkage_$3=no
1263 LIBS="$cf_save_LIBS"
1265 if test "$cf_cv_find_linkage_$3" = yes ; then
1267 CF_ADD_INCDIR($cf_cv_header_path_$3)
1268 CF_ADD_LIBDIR($cf_cv_library_path_$3)
1272 ifelse([$5],,AC_MSG_WARN(Cannot find $3 library),[$5])
1275 dnl ---------------------------------------------------------------------------
1276 dnl CF_FUNC_CURSES_VERSION version: 6 updated: 2012/10/06 16:39:58
1277 dnl ----------------------
1278 dnl Solaris has a data item 'curses_version', which confuses AC_CHECK_FUNCS.
1279 dnl It's a character string "SVR4", not documented.
1280 AC_DEFUN([CF_FUNC_CURSES_VERSION],
1282 AC_CACHE_CHECK(for function curses_version, cf_cv_func_curses_version,[
1284 #include <${cf_cv_ncurses_header:-curses.h}>
1288 sprintf(temp, "%s\n", curses_version());
1289 ${cf_cv_main_return:-return}(0);
1291 ,[cf_cv_func_curses_version=yes]
1292 ,[cf_cv_func_curses_version=no]
1293 ,[cf_cv_func_curses_version=unknown])
1295 test "$cf_cv_func_curses_version" = yes && AC_DEFINE(HAVE_CURSES_VERSION,1,[Define to 1 if we have curses_version function])
1297 dnl ---------------------------------------------------------------------------
1298 dnl CF_GCC_ATTRIBUTES version: 17 updated: 2015/04/12 15:39:00
1299 dnl -----------------
1300 dnl Test for availability of useful gcc __attribute__ directives to quiet
1301 dnl compiler warnings. Though useful, not all are supported -- and contrary
1302 dnl to documentation, unrecognized directives cause older compilers to barf.
1303 AC_DEFUN([CF_GCC_ATTRIBUTES],
1305 if test "$GCC" = yes
1307 cat > conftest.i <<EOF
1309 #define GCC_PRINTF 0
1314 #ifndef GCC_NORETURN
1315 #define GCC_NORETURN /* nothing */
1318 #define GCC_UNUSED /* nothing */
1321 if test "$GCC" = yes
1323 AC_CHECKING([for $CC __attribute__ directives])
1324 cat > conftest.$ac_ext <<EOF
1325 #line __oline__ "${as_me:-configure}"
1326 #include "confdefs.h"
1327 #include "conftest.h"
1328 #include "conftest.i"
1330 #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
1332 #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
1335 #define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
1337 #define GCC_SCANFLIKE(fmt,var) /*nothing*/
1339 extern void wow(char *,...) GCC_SCANFLIKE(1,2);
1340 extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
1341 extern void foo(void) GCC_NORETURN;
1342 int main(int argc GCC_UNUSED, char *argv[[]] GCC_UNUSED) { return 0; }
1344 cf_printf_attribute=no
1345 cf_scanf_attribute=no
1346 for cf_attribute in scanf printf unused noreturn
1348 CF_UPPER(cf_ATTRIBUTE,$cf_attribute)
1349 cf_directive="__attribute__(($cf_attribute))"
1350 echo "checking for $CC $cf_directive" 1>&AC_FD_CC
1352 case $cf_attribute in
1354 cf_printf_attribute=yes
1355 cat >conftest.h <<EOF
1356 #define GCC_$cf_ATTRIBUTE 1
1360 cf_scanf_attribute=yes
1361 cat >conftest.h <<EOF
1362 #define GCC_$cf_ATTRIBUTE 1
1366 cat >conftest.h <<EOF
1367 #define GCC_$cf_ATTRIBUTE $cf_directive
1372 if AC_TRY_EVAL(ac_compile); then
1373 test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
1374 cat conftest.h >>confdefs.h
1375 case $cf_attribute in
1377 AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
1380 cf_value='/* nothing */'
1381 if test "$cf_printf_attribute" != no ; then
1382 cf_value='__attribute__((format(printf,fmt,var)))'
1383 AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
1385 AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
1388 cf_value='/* nothing */'
1389 if test "$cf_scanf_attribute" != no ; then
1390 cf_value='__attribute__((format(scanf,fmt,var)))'
1391 AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
1393 AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
1396 AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
1402 fgrep define conftest.i >>confdefs.h
1407 dnl ---------------------------------------------------------------------------
1408 dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
1410 dnl Find version of gcc
1411 AC_DEFUN([CF_GCC_VERSION],[
1412 AC_REQUIRE([AC_PROG_CC])
1414 if test "$GCC" = yes ; then
1415 AC_MSG_CHECKING(version of $CC)
1416 GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
1417 test -z "$GCC_VERSION" && GCC_VERSION=unknown
1418 AC_MSG_RESULT($GCC_VERSION)
1421 dnl ---------------------------------------------------------------------------
1422 dnl CF_GCC_WARNINGS version: 32 updated: 2015/04/12 15:39:00
1424 dnl Check if the compiler supports useful warning options. There's a few that
1425 dnl we don't use, simply because they're too noisy:
1427 dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
1428 dnl -Wredundant-decls (system headers make this too noisy)
1429 dnl -Wtraditional (combines too many unrelated messages, only a few useful)
1430 dnl -Wwrite-strings (too noisy, but should review occasionally). This
1431 dnl is enabled for ncurses using "--enable-const".
1435 dnl $1 is an optional list of gcc warning flags that a particular
1436 dnl application might want to use, e.g., "no-unused" for
1439 dnl If $with_ext_const is "yes", add a check for -Wwrite-strings
1441 AC_DEFUN([CF_GCC_WARNINGS],
1443 AC_REQUIRE([CF_GCC_VERSION])
1444 CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
1445 CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
1447 cat > conftest.$ac_ext <<EOF
1448 #line __oline__ "${as_me:-configure}"
1449 int main(int argc, char *argv[[]]) { return (argv[[argc-1]] == 0) ; }
1452 if test "$INTEL_COMPILER" = yes
1454 # The "-wdXXX" options suppress warnings:
1455 # remark #1419: external declaration in primary source file
1456 # remark #1683: explicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
1457 # remark #1684: conversion from pointer to same-sized integral type (potential portability problem)
1458 # remark #193: zero used for undefined preprocessing identifier
1459 # remark #593: variable "curs_sb_left_arrow" was set but never used
1460 # remark #810: conversion from "int" to "Dimension={unsigned short}" may lose significant bits
1461 # remark #869: parameter "tw" was never referenced
1462 # remark #981: operands are evaluated in unspecified order
1463 # warning #279: controlling expression is constant
1465 AC_CHECKING([for $CC warning options])
1466 cf_save_CFLAGS="$CFLAGS"
1467 EXTRA_CFLAGS="-Wall"
1479 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1480 if AC_TRY_EVAL(ac_compile); then
1481 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1482 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1485 CFLAGS="$cf_save_CFLAGS"
1487 elif test "$GCC" = yes
1489 AC_CHECKING([for $CC warning options])
1490 cf_save_CFLAGS="$CFLAGS"
1493 test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
1494 cf_gcc_warnings="Wignored-qualifiers Wlogical-op Wvarargs"
1495 test "x$CLANG_COMPILER" = xyes && cf_gcc_warnings=
1496 for cf_opt in W Wall \
1497 Wbad-function-cast \
1500 Wdeclaration-after-statement \
1503 Wmissing-declarations \
1504 Wmissing-prototypes \
1508 Wstrict-prototypes \
1509 Wundef $cf_gcc_warnings $cf_warn_CONST $1
1511 CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
1512 if AC_TRY_EVAL(ac_compile); then
1513 test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
1516 CPPFLAGS="$CPPFLAGS -DXTSTRINGDEFINES"
1519 case $GCC_VERSION in
1521 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1526 case $GCC_VERSION in
1528 CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
1533 EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
1536 CFLAGS="$cf_save_CFLAGS"
1540 AC_SUBST(EXTRA_CFLAGS)
1542 dnl ---------------------------------------------------------------------------
1543 dnl CF_GETOPT_HEADER version: 6 updated: 2014/07/22 14:45:54
1544 dnl ----------------
1545 dnl Check for getopt's variables which are commonly defined in stdlib.h,
1546 dnl unistd.h or (nonstandard) in getopt.h
1547 AC_DEFUN([CF_GETOPT_HEADER],
1549 AC_HAVE_HEADERS(unistd.h getopt.h)
1550 AC_CACHE_CHECK(for header declaring getopt variables,cf_cv_getopt_header,[
1551 cf_cv_getopt_header=none
1552 for cf_header in stdio.h stdlib.h unistd.h getopt.h
1555 #include <$cf_header>],
1556 [int x = optind; char *y = optarg],
1557 [cf_cv_getopt_header=$cf_header
1561 if test $cf_cv_getopt_header != none ; then
1562 AC_DEFINE(HAVE_GETOPT_HEADER,1,[Define to 1 if getopt variables are declared in header])
1564 if test $cf_cv_getopt_header = getopt.h ; then
1565 AC_DEFINE(NEED_GETOPT_H,1,[Define to 1 if we must include getopt.h])
1568 dnl ---------------------------------------------------------------------------
1569 dnl CF_GNU_SOURCE version: 6 updated: 2005/07/09 13:23:07
1571 dnl Check if we must define _GNU_SOURCE to get a reasonable value for
1572 dnl _XOPEN_SOURCE, upon which many POSIX definitions depend. This is a defect
1573 dnl (or misfeature) of glibc2, which breaks portability of many applications,
1574 dnl since it is interwoven with GNU extensions.
1576 dnl Well, yes we could work around it...
1577 AC_DEFUN([CF_GNU_SOURCE],
1579 AC_CACHE_CHECK(if we must define _GNU_SOURCE,cf_cv_gnu_source,[
1580 AC_TRY_COMPILE([#include <sys/types.h>],[
1581 #ifndef _XOPEN_SOURCE
1584 [cf_cv_gnu_source=no],
1585 [cf_save="$CPPFLAGS"
1586 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1587 AC_TRY_COMPILE([#include <sys/types.h>],[
1588 #ifdef _XOPEN_SOURCE
1591 [cf_cv_gnu_source=no],
1592 [cf_cv_gnu_source=yes])
1596 test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
1598 dnl ---------------------------------------------------------------------------
1599 dnl CF_HEADER_PATH version: 13 updated: 2015/04/15 19:08:48
1601 dnl Construct a search-list of directories for a nonstandard header-file
1604 dnl $1 = the variable to return as result
1605 dnl $2 = the package name
1606 AC_DEFUN([CF_HEADER_PATH],
1610 # collect the current set of include-directories from compiler flags
1611 cf_header_path_list=""
1612 if test -n "${CFLAGS}${CPPFLAGS}" ; then
1613 for cf_header_path in $CPPFLAGS $CFLAGS
1615 case $cf_header_path in
1617 cf_header_path=`echo ".$cf_header_path" |sed -e 's/^...//' -e 's,/include$,,'`
1618 CF_ADD_SUBDIR_PATH($1,$2,include,$cf_header_path,NONE)
1619 cf_header_path_list="$cf_header_path_list [$]$1"
1625 # add the variations for the package we are looking for
1626 CF_SUBDIR_PATH($1,$2,include)
1628 test "$includedir" != NONE && \
1629 test "$includedir" != "/usr/include" && \
1630 test -d "$includedir" && {
1631 test -d $includedir && $1="[$]$1 $includedir"
1632 test -d $includedir/$2 && $1="[$]$1 $includedir/$2"
1635 test "$oldincludedir" != NONE && \
1636 test "$oldincludedir" != "/usr/include" && \
1637 test -d "$oldincludedir" && {
1638 test -d $oldincludedir && $1="[$]$1 $oldincludedir"
1639 test -d $oldincludedir/$2 && $1="[$]$1 $oldincludedir/$2"
1642 $1="[$]$1 $cf_header_path_list"
1644 dnl ---------------------------------------------------------------------------
1645 dnl CF_HELP_MESSAGE version: 3 updated: 1998/01/14 10:56:23
1647 dnl Insert text into the help-message, for readability, from AC_ARG_WITH.
1648 AC_DEFUN([CF_HELP_MESSAGE],
1649 [AC_DIVERT_HELP([$1])dnl
1651 dnl ---------------------------------------------------------------------------
1652 dnl CF_INHERIT_SCRIPT version: 2 updated: 2003/03/01 23:50:42
1653 dnl -----------------
1654 dnl If we do not have a given script, look for it in the parent directory.
1655 AC_DEFUN([CF_INHERIT_SCRIPT],
1657 test -f $1 || ( test -f ../$1 && cp ../$1 ./ )
1659 dnl ---------------------------------------------------------------------------
1660 dnl CF_INTEL_COMPILER version: 7 updated: 2015/04/12 15:39:00
1661 dnl -----------------
1662 dnl Check if the given compiler is really the Intel compiler for Linux. It
1663 dnl tries to imitate gcc, but does not return an error when it finds a mismatch
1664 dnl between prototypes, e.g., as exercised by CF_MISSING_CHECK.
1666 dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
1667 dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
1668 dnl the wrappers for gcc and g++ warnings.
1670 dnl $1 = GCC (default) or GXX
1671 dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
1672 dnl $3 = CFLAGS (default) or CXXFLAGS
1673 AC_DEFUN([CF_INTEL_COMPILER],[
1674 AC_REQUIRE([AC_CANONICAL_HOST])
1675 ifelse([$2],,INTEL_COMPILER,[$2])=no
1677 if test "$ifelse([$1],,[$1],GCC)" = yes ; then
1680 AC_MSG_CHECKING(if this is really Intel ifelse([$1],GXX,C++,C) compiler)
1681 cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
1682 ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -no-gcc"
1684 #ifdef __INTEL_COMPILER
1688 ],[ifelse([$2],,INTEL_COMPILER,[$2])=yes
1689 cf_save_CFLAGS="$cf_save_CFLAGS -we147"
1691 ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
1692 AC_MSG_RESULT($ifelse([$2],,INTEL_COMPILER,[$2]))
1697 dnl ---------------------------------------------------------------------------
1698 dnl CF_LD_RPATH_OPT version: 6 updated: 2015/04/12 15:39:00
1700 dnl For the given system and compiler, find the compiler flags to pass to the
1701 dnl loader to use the "rpath" feature.
1702 AC_DEFUN([CF_LD_RPATH_OPT],
1704 AC_REQUIRE([CF_CHECK_CACHE])
1707 AC_MSG_CHECKING(for an rpath option)
1708 case $cf_cv_system_name in
1710 if test "$GCC" = yes; then
1711 LD_RPATH_OPT="-Wl,-rpath,"
1713 LD_RPATH_OPT="-rpath "
1716 (linux*|gnu*|k*bsd*-gnu)
1717 LD_RPATH_OPT="-Wl,-rpath,"
1719 (openbsd[[2-9]].*|mirbsd*)
1720 LD_RPATH_OPT="-Wl,-rpath,"
1722 (dragonfly*|freebsd*)
1723 LD_RPATH_OPT="-rpath "
1726 LD_RPATH_OPT="-Wl,-rpath,"
1729 LD_RPATH_OPT="-rpath "
1737 AC_MSG_RESULT($LD_RPATH_OPT)
1739 case "x$LD_RPATH_OPT" in
1741 AC_MSG_CHECKING(if we need a space after rpath option)
1742 cf_save_LIBS="$LIBS"
1743 CF_ADD_LIBS(${LD_RPATH_OPT}$libdir)
1744 AC_TRY_LINK(, , cf_rpath_space=no, cf_rpath_space=yes)
1745 LIBS="$cf_save_LIBS"
1746 AC_MSG_RESULT($cf_rpath_space)
1747 test "$cf_rpath_space" = yes && LD_RPATH_OPT="$LD_RPATH_OPT "
1751 dnl ---------------------------------------------------------------------------
1752 dnl CF_LIBRARY_PATH version: 10 updated: 2015/04/15 19:08:48
1754 dnl Construct a search-list of directories for a nonstandard library-file
1757 dnl $1 = the variable to return as result
1758 dnl $2 = the package name
1759 AC_DEFUN([CF_LIBRARY_PATH],
1762 cf_library_path_list=""
1763 if test -n "${LDFLAGS}${LIBS}" ; then
1764 for cf_library_path in $LDFLAGS $LIBS
1766 case $cf_library_path in
1768 cf_library_path=`echo ".$cf_library_path" |sed -e 's/^...//' -e 's,/lib$,,'`
1769 CF_ADD_SUBDIR_PATH($1,$2,lib,$cf_library_path,NONE)
1770 cf_library_path_list="$cf_library_path_list [$]$1"
1776 CF_SUBDIR_PATH($1,$2,lib)
1778 $1="$cf_library_path_list [$]$1"
1780 dnl ---------------------------------------------------------------------------
1781 dnl CF_MAKE_TAGS version: 6 updated: 2010/10/23 15:52:32
1783 dnl Generate tags/TAGS targets for makefiles. Do not generate TAGS if we have
1784 dnl a monocase filesystem.
1785 AC_DEFUN([CF_MAKE_TAGS],[
1786 AC_REQUIRE([CF_MIXEDCASE_FILENAMES])
1788 AC_CHECK_PROGS(CTAGS, exctags ctags)
1789 AC_CHECK_PROGS(ETAGS, exetags etags)
1791 AC_CHECK_PROG(MAKE_LOWER_TAGS, ${CTAGS:-ctags}, yes, no)
1793 if test "$cf_cv_mixedcase" = yes ; then
1794 AC_CHECK_PROG(MAKE_UPPER_TAGS, ${ETAGS:-etags}, yes, no)
1799 if test "$MAKE_UPPER_TAGS" = yes ; then
1805 if test "$MAKE_LOWER_TAGS" = yes ; then
1814 AC_SUBST(MAKE_UPPER_TAGS)
1815 AC_SUBST(MAKE_LOWER_TAGS)
1817 dnl ---------------------------------------------------------------------------
1818 dnl CF_MATH_LIB version: 8 updated: 2010/05/29 16:31:02
1820 dnl Checks for libraries. At least one UNIX system, Apple Macintosh
1821 dnl Rhapsody 5.5, does not have -lm. We cannot use the simpler
1822 dnl AC_CHECK_LIB(m,sin), because that fails for C++.
1823 AC_DEFUN([CF_MATH_LIB],
1825 AC_CACHE_CHECK(if -lm needed for math functions,
1831 [double x = rand(); printf("result = %g\n", ]ifelse([$2],,sin(x),$2)[)],
1832 [cf_cv_need_libm=no],
1833 [cf_cv_need_libm=yes])])
1834 if test "$cf_cv_need_libm" = yes
1841 dnl ---------------------------------------------------------------------------
1842 dnl CF_MIXEDCASE_FILENAMES version: 7 updated: 2015/04/12 15:39:00
1843 dnl ----------------------
1844 dnl Check if the file-system supports mixed-case filenames. If we're able to
1845 dnl create a lowercase name and see it as uppercase, it doesn't support that.
1846 AC_DEFUN([CF_MIXEDCASE_FILENAMES],
1848 AC_CACHE_CHECK(if filesystem supports mixed-case filenames,cf_cv_mixedcase,[
1849 if test "$cross_compiling" = yes ; then
1850 case $target_alias in
1851 (*-os2-emx*|*-msdosdjgpp*|*-cygwin*|*-msys*|*-mingw*|*-uwin*)
1859 rm -f conftest CONFTEST
1861 if test -f CONFTEST ; then
1866 rm -f conftest CONFTEST
1869 test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
1871 dnl ---------------------------------------------------------------------------
1872 dnl CF_MSG_LOG version: 5 updated: 2010/10/23 15:52:32
1874 dnl Write a debug message to config.log, along with the line number in the
1875 dnl configure script.
1876 AC_DEFUN([CF_MSG_LOG],[
1877 echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
1879 dnl ---------------------------------------------------------------------------
1880 dnl CF_NCURSES_CC_CHECK version: 4 updated: 2007/07/29 10:39:05
1881 dnl -------------------
1882 dnl Check if we can compile with ncurses' header file
1883 dnl $1 is the cache variable to set
1884 dnl $2 is the header-file to include
1885 dnl $3 is the root name (ncurses or ncursesw)
1886 AC_DEFUN([CF_NCURSES_CC_CHECK],[
1888 ]ifelse($3,ncursesw,[
1889 #define _XOPEN_SOURCE_EXTENDED
1890 #undef HAVE_LIBUTF8_H /* in case we used CF_UTF8_LIB */
1891 #define HAVE_LIBUTF8_H /* to force ncurses' header file to use cchar_t */
1894 #ifdef NCURSES_VERSION
1895 ]ifelse($3,ncursesw,[
1900 printf("%s\n", NCURSES_VERSION);
1912 dnl ---------------------------------------------------------------------------
1913 dnl CF_NCURSES_CONFIG version: 12 updated: 2015/04/24 20:52:45
1914 dnl -----------------
1915 dnl Tie together the configure-script macros for ncurses.
1916 dnl Prefer the "-config" script from ncurses 6.x, to simplify analysis.
1917 dnl Allow that to be overridden using the $NCURSES_CONFIG environment variable.
1919 dnl $1 is the root library name (default: "ncurses")
1920 AC_DEFUN([CF_NCURSES_CONFIG],[
1921 AC_REQUIRE([CF_PKG_CONFIG])
1922 cf_ncuconfig_root=ifelse($1,,ncurses,$1)
1923 cf_have_ncuconfig=no
1925 if test "x$PKG_CONFIG" != xnone; then
1926 AC_MSG_CHECKING(pkg-config for $cf_ncuconfig_root)
1927 if "$PKG_CONFIG" --exists $cf_ncuconfig_root ; then
1930 AC_MSG_CHECKING(if the $cf_ncuconfig_root package files work)
1931 cf_have_ncuconfig=unknown
1933 cf_save_CPPFLAGS="$CPPFLAGS"
1934 cf_save_LIBS="$LIBS"
1936 CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags $cf_ncuconfig_root`"
1937 CF_ADD_LIBS(`$PKG_CONFIG --libs $cf_ncuconfig_root`)
1939 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
1940 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
1941 [AC_TRY_RUN([#include <${cf_cv_ncurses_header:-curses.h}>
1943 { char *xx = curses_version(); return (xx == 0); }],
1944 [cf_have_ncuconfig=yes],
1945 [cf_have_ncuconfig=no])],
1946 [cf_have_ncuconfig=no])
1948 AC_MSG_RESULT($cf_have_ncuconfig)
1949 if test "$cf_have_ncuconfig" != "yes"
1951 CPPFLAGS="$cf_save_CPPFLAGS"
1952 LIBS="$cf_save_LIBS"
1954 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1962 if test "x$cf_have_ncuconfig" = "xno"; then
1963 echo "Looking for ${cf_ncuconfig_root}-config"
1965 CF_ACVERSION_CHECK(2.52,
1966 [AC_CHECK_TOOLS(NCURSES_CONFIG, ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)],
1967 [AC_PATH_PROGS(NCURSES_CONFIG, ${cf_ncuconfig_root}-config ${cf_ncuconfig_root}6-config ${cf_ncuconfig_root}5-config, none)])
1969 if test "$NCURSES_CONFIG" != none ; then
1971 CPPFLAGS="$CPPFLAGS `$NCURSES_CONFIG --cflags`"
1972 CF_ADD_LIBS(`$NCURSES_CONFIG --libs`)
1974 # even with config script, some packages use no-override for curses.h
1975 CF_CURSES_HEADER(ifelse($1,,ncurses,$1))
1977 dnl like CF_NCURSES_CPPFLAGS
1978 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
1980 dnl like CF_NCURSES_LIBS
1981 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_ncuconfig_root)
1982 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
1984 dnl like CF_NCURSES_VERSION
1985 cf_cv_ncurses_version=`$NCURSES_CONFIG --version`
1989 CF_NCURSES_CPPFLAGS(ifelse($1,,ncurses,$1))
1990 CF_NCURSES_LIBS(ifelse($1,,ncurses,$1))
1995 dnl ---------------------------------------------------------------------------
1996 dnl CF_NCURSES_CPPFLAGS version: 21 updated: 2012/10/06 08:57:51
1997 dnl -------------------
1998 dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
1999 dnl the CPPFLAGS variable so we can include its header.
2001 dnl The header files may be installed as either curses.h, or ncurses.h (would
2002 dnl be obsolete, except that some packagers prefer this name to distinguish it
2003 dnl from a "native" curses implementation). If not installed for overwrite,
2004 dnl the curses.h file would be in an ncurses subdirectory (e.g.,
2005 dnl /usr/include/ncurses), but someone may have installed overwriting the
2006 dnl vendor's curses. Only very old versions (pre-1.9.2d, the first autoconf'd
2007 dnl version) of ncurses don't define either __NCURSES_H or NCURSES_VERSION in
2010 dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
2011 dnl is already in the include-path, don't even bother with this, since we cannot
2012 dnl easily determine which file it is. In this case, it has to be <curses.h>.
2014 dnl The optional parameter gives the root name of the library, in case it is
2015 dnl not installed as the default curses library. That is how the
2016 dnl wide-character version of ncurses is installed.
2017 AC_DEFUN([CF_NCURSES_CPPFLAGS],
2018 [AC_REQUIRE([CF_WITH_CURSES_DIR])
2020 AC_PROVIDE([CF_CURSES_CPPFLAGS])dnl
2021 cf_ncuhdr_root=ifelse($1,,ncurses,$1)
2023 test -n "$cf_cv_curses_dir" && \
2024 test "$cf_cv_curses_dir" != "no" && { \
2025 CF_ADD_INCDIR($cf_cv_curses_dir/include/$cf_ncuhdr_root)
2028 AC_CACHE_CHECK(for $cf_ncuhdr_root header in include-path, cf_cv_ncurses_h,[
2029 cf_header_list="$cf_ncuhdr_root/curses.h $cf_ncuhdr_root/ncurses.h"
2030 ( test "$cf_ncuhdr_root" = ncurses || test "$cf_ncuhdr_root" = ncursesw ) && cf_header_list="$cf_header_list curses.h ncurses.h"
2031 for cf_header in $cf_header_list
2033 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h,$cf_header,$1)
2034 test "$cf_cv_ncurses_h" != no && break
2041 # some applications need this, but should check for NCURSES_VERSION
2042 AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2046 dnl ---------------------------------------------------------------------------
2047 dnl CF_NCURSES_EXT_FUNCS version: 4 updated: 2012/10/06 16:39:58
2048 dnl --------------------
2049 dnl Since 2007/11/17, ncurses has defined NCURSES_EXT_FUNCS; earlier versions
2050 dnl may provide these functions. Define the symbol if it is not defined, and
2052 AC_DEFUN([CF_NCURSES_EXT_FUNCS],
2054 AC_CACHE_CHECK(for ncurses extended functions,cf_cv_ncurses_ext_funcs,[
2056 #include <${cf_cv_ncurses_header:-curses.h}>],
2058 int x = NCURSES_EXT_FUNCS
2059 ],[cf_cv_ncurses_ext_funcs=defined],[
2061 #include <${cf_cv_ncurses_header:-curses.h}>],
2063 (void) assume_default_colors (0, 0);
2064 (void) curses_version ();
2065 (void) define_key (0, 0);
2066 (void) is_term_resized (0, 0);
2067 (void) key_defined (0);
2068 (void) keybound (0, 0);
2069 (void) keyok (0, 0);
2070 (void) resize_term (0, 0);
2071 (void) resizeterm (0, 0);
2072 (void) use_default_colors ();
2073 (void) use_extended_names (0);
2074 (void) wresize (0, 0, 0);],
2075 [cf_cv_ncurses_ext_funcs=yes],
2076 [cf_cv_ncurses_ext_funcs=no])
2079 test "$cf_cv_ncurses_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS,1,[Define to 1 if we have ncurses extensions])
2081 dnl ---------------------------------------------------------------------------
2082 dnl CF_NCURSES_HEADER version: 4 updated: 2015/04/15 19:08:48
2083 dnl -----------------
2084 dnl Find a "curses" header file, e.g,. "curses.h", or one of the more common
2085 dnl variations of ncurses' installs.
2087 dnl See also CF_CURSES_HEADER, which sets the same cache variable.
2088 AC_DEFUN([CF_NCURSES_HEADER],[
2090 if test "$cf_cv_ncurses_h" != no ; then
2091 cf_cv_ncurses_header=$cf_cv_ncurses_h
2094 AC_CACHE_CHECK(for $cf_ncuhdr_root include-path, cf_cv_ncurses_h2,[
2095 test -n "$verbose" && echo
2096 CF_HEADER_PATH(cf_search,$cf_ncuhdr_root)
2097 test -n "$verbose" && echo search path $cf_search
2098 cf_save2_CPPFLAGS="$CPPFLAGS"
2099 for cf_incdir in $cf_search
2101 CF_ADD_INCDIR($cf_incdir)
2106 CF_NCURSES_CC_CHECK(cf_cv_ncurses_h2,$cf_header,$1)
2107 if test "$cf_cv_ncurses_h2" != no ; then
2108 cf_cv_ncurses_h2=$cf_incdir/$cf_header
2109 test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG
2112 test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
2114 CPPFLAGS="$cf_save2_CPPFLAGS"
2115 test "$cf_cv_ncurses_h2" != no && break
2117 test "$cf_cv_ncurses_h2" = no && AC_MSG_ERROR(not found)
2120 CF_DIRNAME(cf_1st_incdir,$cf_cv_ncurses_h2)
2121 cf_cv_ncurses_header=`basename $cf_cv_ncurses_h2`
2122 if test `basename $cf_1st_incdir` = $cf_ncuhdr_root ; then
2123 cf_cv_ncurses_header=$cf_ncuhdr_root/$cf_cv_ncurses_header
2125 CF_ADD_INCDIR($cf_1st_incdir)
2129 # Set definitions to allow ifdef'ing for ncurses.h
2131 case $cf_cv_ncurses_header in
2133 AC_DEFINE(HAVE_NCURSES_H,1,[Define to 1 if we have ncurses.h])
2137 case $cf_cv_ncurses_header in
2138 (ncurses/curses.h|ncurses/ncurses.h)
2139 AC_DEFINE(HAVE_NCURSES_NCURSES_H,1,[Define to 1 if we have ncurses/ncurses.h])
2141 (ncursesw/curses.h|ncursesw/ncurses.h)
2142 AC_DEFINE(HAVE_NCURSESW_NCURSES_H,1,[Define to 1 if we have ncursesw/ncurses.h])
2147 dnl ---------------------------------------------------------------------------
2148 dnl CF_NCURSES_LIBS version: 17 updated: 2015/04/15 19:08:48
2150 dnl Look for the ncurses library. This is a little complicated on Linux,
2151 dnl because it may be linked with the gpm (general purpose mouse) library.
2152 dnl Some distributions have gpm linked with (bsd) curses, which makes it
2153 dnl unusable with ncurses. However, we don't want to link with gpm unless
2154 dnl ncurses has a dependency, since gpm is normally set up as a shared library,
2155 dnl and the linker will record a dependency.
2157 dnl The optional parameter gives the root name of the library, in case it is
2158 dnl not installed as the default curses library. That is how the
2159 dnl wide-character version of ncurses is installed.
2160 AC_DEFUN([CF_NCURSES_LIBS],
2161 [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
2163 cf_nculib_root=ifelse($1,,ncurses,$1)
2164 # This works, except for the special case where we find gpm, but
2165 # ncurses is in a nonstandard location via $LIBS, and we really want
2168 cf_ncurses_SAVE="$LIBS"
2169 AC_CHECK_LIB(gpm,Gpm_Open,
2170 [AC_CHECK_LIB(gpm,initscr,
2171 [LIBS="$cf_ncurses_SAVE"],
2172 [cf_ncurses_LIBS="-lgpm"])])
2176 # This is only necessary if you are linking against an obsolete
2177 # version of ncurses (but it should do no harm, since it's static).
2178 if test "$cf_nculib_root" = ncurses ; then
2179 AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
2184 CF_ADD_LIBS($cf_ncurses_LIBS)
2186 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
2188 CF_ADD_LIBS(-l$cf_nculib_root)
2190 CF_FIND_LIBRARY($cf_nculib_root,$cf_nculib_root,
2191 [#include <${cf_cv_ncurses_header:-curses.h}>],
2196 if test -n "$cf_ncurses_LIBS" ; then
2197 AC_MSG_CHECKING(if we can link $cf_nculib_root without $cf_ncurses_LIBS)
2198 cf_ncurses_SAVE="$LIBS"
2199 for p in $cf_ncurses_LIBS ; do
2200 q=`echo $LIBS | sed -e "s%$p %%" -e "s%$p$%%"`
2201 if test "$q" != "$LIBS" ; then
2205 AC_TRY_LINK([#include <${cf_cv_ncurses_header:-curses.h}>],
2206 [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
2207 [AC_MSG_RESULT(yes)],
2209 LIBS="$cf_ncurses_SAVE"])
2212 CF_UPPER(cf_nculib_ROOT,HAVE_LIB$cf_nculib_root)
2213 AC_DEFINE_UNQUOTED($cf_nculib_ROOT)
2215 dnl ---------------------------------------------------------------------------
2216 dnl CF_NCURSES_VERSION version: 14 updated: 2012/10/06 08:57:51
2217 dnl ------------------
2218 dnl Check for the version of ncurses, to aid in reporting bugs, etc.
2219 dnl Call CF_CURSES_CPPFLAGS first, or CF_NCURSES_CPPFLAGS. We don't use
2220 dnl AC_REQUIRE since that does not work with the shell's if/then/else/fi.
2221 AC_DEFUN([CF_NCURSES_VERSION],
2223 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
2224 AC_CACHE_CHECK(for ncurses version, cf_cv_ncurses_version,[
2225 cf_cv_ncurses_version=no
2229 #include <${cf_cv_ncurses_header:-curses.h}>
2233 FILE *fp = fopen("$cf_tempfile", "w");
2234 #ifdef NCURSES_VERSION
2235 # ifdef NCURSES_VERSION_PATCH
2236 fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
2238 fprintf(fp, "%s\n", NCURSES_VERSION);
2242 fprintf(fp, "old\n");
2247 ${cf_cv_main_return:-return}(0);
2249 cf_cv_ncurses_version=`cat $cf_tempfile`],,[
2251 # This will not work if the preprocessor splits the line after the
2252 # Autoconf token. The 'unproto' program does that.
2253 cat > conftest.$ac_ext <<EOF
2254 #include <${cf_cv_ncurses_header:-curses.h}>
2256 #ifdef NCURSES_VERSION
2257 Autoconf NCURSES_VERSION
2265 cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
2267 if test -f conftest.out ; then
2268 cf_out=`cat conftest.out | sed -e 's%^Autoconf %%' -e 's%^[[^"]]*"%%' -e 's%".*%%'`
2269 test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
2275 test "$cf_cv_ncurses_version" = no || AC_DEFINE(NCURSES,1,[Define to 1 if we are using ncurses headers/libraries])
2277 dnl ---------------------------------------------------------------------------
2278 dnl CF_NCURSES_WRAP_PREFIX version: 1 updated: 2009/03/28 16:08:10
2279 dnl ----------------------
2280 dnl Check for ncurses "wrap-prefix" used for public variables which have been
2281 dnl wrapped with a function to help with concurrency control.
2282 AC_DEFUN([CF_NCURSES_WRAP_PREFIX],
2284 AC_MSG_CHECKING(for ncurses wrap-prefix)
2285 AC_ARG_WITH(ncurses-wrap-prefix,
2286 [ --with-ncurses-wrap-prefix naming-prefix for ncurses wrapped-variables],
2287 [NCURSES_WRAP_PREFIX=$withval],
2288 [NCURSES_WRAP_PREFIX=_nc_])
2289 AC_MSG_RESULT($NCURSES_WRAP_PREFIX)
2291 AC_SUBST(NCURSES_WRAP_PREFIX)
2293 dnl ---------------------------------------------------------------------------
2294 dnl CF_NETBSD_FORM_H version: 2 updated: 2012/10/06 16:39:58
2295 dnl ----------------
2296 dnl Check for NetBSD's form.h, which is incompatible with SVr4 and ncurses.
2297 dnl Some workarounds are needed in client programs to allow them to compile.
2298 AC_DEFUN([CF_NETBSD_FORM_H],[
2299 AC_CACHE_CHECK(for NetBSD form.h,cf_cv_netbsd_form_h,[
2301 #include <${cf_cv_ncurses_header:-curses.h}>
2305 int y = current_field(form)->cursor_ypos;
2306 int x = current_field(form)->cursor_xpos;
2307 ],[cf_cv_netbsd_form_h=yes
2308 ],[cf_cv_netbsd_form_h=no])
2311 test "$cf_cv_netbsd_form_h" = yes && AC_DEFINE(HAVE_NETBSD_FORM_H,1,[Define to 1 if we appear to be using NetBSD form.h])
2313 dnl ---------------------------------------------------------------------------
2314 dnl CF_NETBSD_MENU_H version: 2 updated: 2012/10/06 16:39:58
2315 dnl ----------------
2316 dnl Check for NetBSD's menu.h, which is incompatible with SVr4 and ncurses.
2317 dnl Some workarounds are needed in client programs to allow them to compile.
2318 AC_DEFUN([CF_NETBSD_MENU_H],[
2319 AC_CACHE_CHECK(for NetBSD menu.h,cf_cv_netbsd_menu_h,[
2321 #include <${cf_cv_ncurses_header:-curses.h}>
2325 int y = menu->max_item_width;
2326 ],[cf_cv_netbsd_menu_h=yes
2327 ],[cf_cv_netbsd_menu_h=no])
2330 test "$cf_cv_netbsd_menu_h" = yes && AC_DEFINE(HAVE_NETBSD_MENU_H,1,[Define to 1 if we appear to be using NetBSD menu.h])
2332 dnl ---------------------------------------------------------------------------
2333 dnl CF_NO_LEAKS_OPTION version: 6 updated: 2015/04/12 15:39:00
2334 dnl ------------------
2335 dnl see CF_WITH_NO_LEAKS
2336 AC_DEFUN([CF_NO_LEAKS_OPTION],[
2337 AC_MSG_CHECKING(if you want to use $1 for testing)
2340 [AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
2343 : ${with_cflags:=-g}
2344 : ${with_no_leaks:=yes}
2347 AC_MSG_RESULT(${with_$1:-no})
2349 case .$with_cflags in
2361 dnl ---------------------------------------------------------------------------
2362 dnl CF_PATH_SYNTAX version: 16 updated: 2015/04/18 08:56:57
2364 dnl Check the argument to see that it looks like a pathname. Rewrite it if it
2365 dnl begins with one of the prefix/exec_prefix variables, and then again if the
2366 dnl result begins with 'NONE'. This is necessary to work around autoconf's
2367 dnl delayed evaluation of those symbols.
2368 AC_DEFUN([CF_PATH_SYNTAX],[
2369 if test "x$prefix" != xNONE; then
2370 cf_path_syntax="$prefix"
2372 cf_path_syntax="$ac_default_prefix"
2376 (.\[$]\(*\)*|.\'*\'*)
2380 (.[[a-zA-Z]]:[[\\/]]*) # OS/2 EMX
2382 (.\[$]{*prefix}*|.\[$]{*dir}*)
2386 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2391 $1=`echo [$]$1 | sed -e s%NONE%$cf_path_syntax%`
2394 ifelse([$2],,[AC_MSG_ERROR([expected a pathname, not \"[$]$1\"])],$2)
2398 dnl ---------------------------------------------------------------------------
2399 dnl CF_PDCURSES_X11 version: 13 updated: 2012/10/06 16:39:58
2401 dnl Configure for PDCurses' X11 library
2402 AC_DEFUN([CF_PDCURSES_X11],[
2403 AC_REQUIRE([CF_X_ATHENA])
2405 CF_ACVERSION_CHECK(2.52,
2406 [AC_CHECK_TOOLS(XCURSES_CONFIG, xcurses-config, none)],
2407 [AC_PATH_PROGS(XCURSES_CONFIG, xcurses-config, none)])
2409 if test "$XCURSES_CONFIG" != none ; then
2411 CPPFLAGS="$CPPFLAGS `$XCURSES_CONFIG --cflags`"
2412 CF_ADD_LIBS(`$XCURSES_CONFIG --libs`)
2414 cf_cv_lib_XCurses=yes
2418 LDFLAGS="$LDFLAGS $X_LIBS"
2419 CF_CHECK_CFLAGS($X_CFLAGS)
2420 AC_CHECK_LIB(X11,XOpenDisplay,
2421 [CF_ADD_LIBS(-lX11)],,
2422 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
2423 AC_CACHE_CHECK(for XCurses library,cf_cv_lib_XCurses,[
2424 CF_ADD_LIBS(-lXCurses)
2426 #include <xcurses.h>
2427 char *XCursesProgramName = "test";
2429 [cf_cv_lib_XCurses=yes],
2430 [cf_cv_lib_XCurses=no])
2435 if test $cf_cv_lib_XCurses = yes ; then
2436 AC_DEFINE(UNIX,1,[Define to 1 if using PDCurses on Unix])
2437 AC_DEFINE(XCURSES,1,[Define to 1 if using PDCurses on Unix])
2438 AC_CHECK_HEADER(xcurses.h, AC_DEFINE(HAVE_XCURSES,1,[Define to 1 if using PDCurses on Unix]))
2440 AC_MSG_ERROR(Cannot link with XCurses)
2443 dnl ---------------------------------------------------------------------------
2444 dnl CF_PKG_CONFIG version: 9 updated: 2015/04/12 15:39:00
2446 dnl Check for the package-config program, unless disabled by command-line.
2447 AC_DEFUN([CF_PKG_CONFIG],
2449 AC_MSG_CHECKING(if you want to use pkg-config)
2450 AC_ARG_WITH(pkg-config,
2451 [ --with-pkg-config{=path} enable/disable use of pkg-config],
2452 [cf_pkg_config=$withval],
2453 [cf_pkg_config=yes])
2454 AC_MSG_RESULT($cf_pkg_config)
2456 case $cf_pkg_config in
2461 CF_ACVERSION_CHECK(2.52,
2462 [AC_PATH_TOOL(PKG_CONFIG, pkg-config, none)],
2463 [AC_PATH_PROG(PKG_CONFIG, pkg-config, none)])
2470 test -z "$PKG_CONFIG" && PKG_CONFIG=none
2471 if test "$PKG_CONFIG" != none ; then
2472 CF_PATH_SYNTAX(PKG_CONFIG)
2474 AC_MSG_WARN(pkg-config is not installed)
2477 AC_SUBST(PKG_CONFIG)
2479 dnl ---------------------------------------------------------------------------
2480 dnl CF_POSIX_C_SOURCE version: 9 updated: 2015/04/12 15:39:00
2481 dnl -----------------
2482 dnl Define _POSIX_C_SOURCE to the given level, and _POSIX_SOURCE if needed.
2484 dnl POSIX.1-1990 _POSIX_SOURCE
2485 dnl POSIX.1-1990 and _POSIX_SOURCE and
2486 dnl POSIX.2-1992 C-Language _POSIX_C_SOURCE=2
2488 dnl POSIX.1b-1993 _POSIX_C_SOURCE=199309L
2489 dnl POSIX.1c-1996 _POSIX_C_SOURCE=199506L
2490 dnl X/Open 2000 _POSIX_C_SOURCE=200112L
2493 dnl $1 is the nominal value for _POSIX_C_SOURCE
2494 AC_DEFUN([CF_POSIX_C_SOURCE],
2496 cf_POSIX_C_SOURCE=ifelse([$1],,199506L,[$1])
2498 cf_save_CFLAGS="$CFLAGS"
2499 cf_save_CPPFLAGS="$CPPFLAGS"
2501 CF_REMOVE_DEFINE(cf_trim_CFLAGS,$cf_save_CFLAGS,_POSIX_C_SOURCE)
2502 CF_REMOVE_DEFINE(cf_trim_CPPFLAGS,$cf_save_CPPFLAGS,_POSIX_C_SOURCE)
2504 AC_CACHE_CHECK(if we should define _POSIX_C_SOURCE,cf_cv_posix_c_source,[
2505 CF_MSG_LOG(if the symbol is already defined go no further)
2506 AC_TRY_COMPILE([#include <sys/types.h>],[
2507 #ifndef _POSIX_C_SOURCE
2510 [cf_cv_posix_c_source=no],
2511 [cf_want_posix_source=no
2512 case .$cf_POSIX_C_SOURCE in
2514 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2517 cf_cv_posix_c_source="-D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE"
2518 cf_want_posix_source=yes
2521 cf_want_posix_source=yes
2524 if test "$cf_want_posix_source" = yes ; then
2525 AC_TRY_COMPILE([#include <sys/types.h>],[
2526 #ifdef _POSIX_SOURCE
2529 cf_cv_posix_c_source="$cf_cv_posix_c_source -D_POSIX_SOURCE")
2531 CF_MSG_LOG(ifdef from value $cf_POSIX_C_SOURCE)
2532 CFLAGS="$cf_trim_CFLAGS"
2533 CPPFLAGS="$cf_trim_CPPFLAGS $cf_cv_posix_c_source"
2534 CF_MSG_LOG(if the second compile does not leave our definition intact error)
2535 AC_TRY_COMPILE([#include <sys/types.h>],[
2536 #ifndef _POSIX_C_SOURCE
2539 [cf_cv_posix_c_source=no])
2540 CFLAGS="$cf_save_CFLAGS"
2541 CPPFLAGS="$cf_save_CPPFLAGS"
2545 if test "$cf_cv_posix_c_source" != no ; then
2546 CFLAGS="$cf_trim_CFLAGS"
2547 CPPFLAGS="$cf_trim_CPPFLAGS"
2548 CF_ADD_CFLAGS($cf_cv_posix_c_source)
2552 dnl ---------------------------------------------------------------------------
2553 dnl CF_PRG_RULES version: 1 updated: 2006/06/03 11:45:08
2555 dnl Append definitions and rules for the given programs to the subdirectory
2556 dnl Makefiles, and the recursion rule for the top-level Makefile.
2559 dnl $1 = script to run
2560 dnl $2 = list of subdirectories
2564 AC_DEFUN([CF_PRG_RULES],
2568 if test ! -d $srcdir/$cf_dir; then
2570 elif test -f $srcdir/$cf_dir/programs; then
2571 $AWK -f $1 $srcdir/$cf_dir/programs >>$cf_dir/Makefile
2576 dnl ---------------------------------------------------------------------------
2577 dnl CF_PROG_CC version: 4 updated: 2014/07/12 18:57:58
2579 dnl standard check for CC, plus followup sanity checks
2580 dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
2581 AC_DEFUN([CF_PROG_CC],[
2582 ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
2584 CF_ACVERSION_CHECK(2.52,
2589 dnl ---------------------------------------------------------------------------
2590 dnl CF_PROG_INSTALL version: 7 updated: 2015/04/18 08:56:57
2592 dnl Force $INSTALL to be an absolute-path. Otherwise, edit_man.sh and the
2593 dnl misc/tabset install won't work properly. Usually this happens only when
2594 dnl using the fallback mkinstalldirs script
2595 AC_DEFUN([CF_PROG_INSTALL],
2601 CF_DIRNAME(cf_dir,$INSTALL)
2602 test -z "$cf_dir" && cf_dir=.
2603 INSTALL=`cd $cf_dir && pwd`/`echo $INSTALL | sed -e 's%^.*/%%'`
2607 dnl ---------------------------------------------------------------------------
2608 dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
2610 AC_DEFUN([CF_PROG_LINT],
2612 AC_CHECK_PROGS(LINT, tdlint lint alint splint lclint)
2615 dnl ---------------------------------------------------------------------------
2616 dnl CF_REMOVE_DEFINE version: 3 updated: 2010/01/09 11:05:50
2617 dnl ----------------
2618 dnl Remove all -U and -D options that refer to the given symbol from a list
2619 dnl of C compiler options. This works around the problem that not all
2620 dnl compilers process -U and -D options from left-to-right, so a -U option
2621 dnl cannot be used to cancel the effect of a preceding -D option.
2623 dnl $1 = target (which could be the same as the source variable)
2624 dnl $2 = source (including '$')
2625 dnl $3 = symbol to remove
2626 define([CF_REMOVE_DEFINE],
2629 sed -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[[ ]]/ /g' \
2630 -e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
2632 dnl ---------------------------------------------------------------------------
2633 dnl CF_RPATH_HACK version: 11 updated: 2013/09/01 13:02:00
2635 AC_DEFUN([CF_RPATH_HACK],
2637 AC_REQUIRE([CF_LD_RPATH_OPT])
2638 AC_MSG_CHECKING(for updated LDFLAGS)
2639 if test -n "$LD_RPATH_OPT" ; then
2640 AC_MSG_RESULT(maybe)
2642 AC_CHECK_PROGS(cf_ldd_prog,ldd,no)
2643 cf_rpath_list="/usr/lib /lib"
2644 if test "$cf_ldd_prog" != no
2648 AC_TRY_LINK([#include <stdio.h>],
2650 [cf_rpath_oops=`$cf_ldd_prog conftest$ac_exeext | fgrep ' not found' | sed -e 's% =>.*$%%' |sort | uniq`
2651 cf_rpath_list=`$cf_ldd_prog conftest$ac_exeext | fgrep / | sed -e 's%^.*[[ ]]/%/%' -e 's%/[[^/]][[^/]]*$%%' |sort | uniq`])
2653 # If we passed the link-test, but get a "not found" on a given library,
2654 # this could be due to inept reconfiguration of gcc to make it only
2655 # partly honor /usr/local/lib (or whatever). Sometimes this behavior
2656 # is intentional, e.g., installing gcc in /usr/bin and suppressing the
2657 # /usr/local libraries.
2658 if test -n "$cf_rpath_oops"
2660 for cf_rpath_src in $cf_rpath_oops
2662 for cf_rpath_dir in \
2667 if test -f $cf_rpath_dir/lib/$cf_rpath_src
2669 CF_VERBOSE(...adding -L$cf_rpath_dir/lib to LDFLAGS for $cf_rpath_src)
2670 LDFLAGS="$LDFLAGS -L$cf_rpath_dir/lib"
2678 CF_VERBOSE(...checking EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2680 CF_RPATH_HACK_2(LDFLAGS)
2681 CF_RPATH_HACK_2(LIBS)
2683 CF_VERBOSE(...checked EXTRA_LDFLAGS $EXTRA_LDFLAGS)
2687 AC_SUBST(EXTRA_LDFLAGS)
2689 dnl ---------------------------------------------------------------------------
2690 dnl CF_RPATH_HACK_2 version: 7 updated: 2015/04/12 15:39:00
2692 dnl Do one set of substitutions for CF_RPATH_HACK, adding an rpath option to
2693 dnl EXTRA_LDFLAGS for each -L option found.
2695 dnl $cf_rpath_list contains a list of directories to ignore.
2697 dnl $1 = variable name to update. The LDFLAGS variable should be the only one,
2698 dnl but LIBS often has misplaced -L options.
2699 AC_DEFUN([CF_RPATH_HACK_2],
2701 CF_VERBOSE(...checking $1 [$]$1)
2704 for cf_rpath_src in [$]$1
2706 case $cf_rpath_src in
2709 # check if this refers to a directory which we will ignore
2711 if test -n "$cf_rpath_list"
2713 for cf_rpath_item in $cf_rpath_list
2715 if test "x$cf_rpath_src" = "x-L$cf_rpath_item"
2723 if test "$cf_rpath_skip" = no
2725 # transform the option
2726 if test "$LD_RPATH_OPT" = "-R " ; then
2727 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%-R %"`
2729 cf_rpath_tmp=`echo "$cf_rpath_src" |sed -e "s%-L%$LD_RPATH_OPT%"`
2732 # if we have not already added this, add it now
2733 cf_rpath_tst=`echo "$EXTRA_LDFLAGS" | sed -e "s%$cf_rpath_tmp %%"`
2734 if test "x$cf_rpath_tst" = "x$EXTRA_LDFLAGS"
2736 CF_VERBOSE(...Filter $cf_rpath_src ->$cf_rpath_tmp)
2737 EXTRA_LDFLAGS="$cf_rpath_tmp $EXTRA_LDFLAGS"
2742 cf_rpath_dst="$cf_rpath_dst $cf_rpath_src"
2746 CF_VERBOSE(...checked $1 [$]$1)
2747 AC_SUBST(EXTRA_LDFLAGS)
2749 dnl ---------------------------------------------------------------------------
2750 dnl CF_SIG_ATOMIC_T version: 3 updated: 2012/10/04 20:12:20
2752 dnl signal handler, but there are some gcc depedencies in that recommendation.
2754 AC_DEFUN([CF_SIG_ATOMIC_T],
2756 AC_MSG_CHECKING(for signal global datatype)
2757 AC_CACHE_VAL(cf_cv_sig_atomic_t,[
2759 "volatile sig_atomic_t" \
2764 #include <sys/types.h>
2770 static void handler(int sig)
2774 [signal(SIGINT, handler);
2776 [cf_cv_sig_atomic_t=$cf_type],
2777 [cf_cv_sig_atomic_t=no])
2778 test "$cf_cv_sig_atomic_t" != no && break
2781 AC_MSG_RESULT($cf_cv_sig_atomic_t)
2782 test "$cf_cv_sig_atomic_t" != no && AC_DEFINE_UNQUOTED(SIG_ATOMIC_T, $cf_cv_sig_atomic_t,[Define to signal global datatype])
2784 dnl ---------------------------------------------------------------------------
2785 dnl CF_SUBDIR_PATH version: 7 updated: 2014/12/04 04:33:06
2787 dnl Construct a search-list for a nonstandard header/lib-file
2788 dnl $1 = the variable to return as result
2789 dnl $2 = the package name
2790 dnl $3 = the subdirectory, e.g., bin, include or lib
2791 AC_DEFUN([CF_SUBDIR_PATH],
2795 CF_ADD_SUBDIR_PATH($1,$2,$3,$prefix,NONE)
2797 for cf_subdir_prefix in \
2805 CF_ADD_SUBDIR_PATH($1,$2,$3,$cf_subdir_prefix,$prefix)
2808 dnl ---------------------------------------------------------------------------
2809 dnl CF_SYS_TIME_SELECT version: 6 updated: 2015/04/18 08:56:57
2810 dnl ------------------
2811 dnl Check if we can include <sys/time.h> with <sys/select.h>; this breaks on
2812 dnl older SCO configurations.
2813 AC_DEFUN([CF_SYS_TIME_SELECT],
2815 AC_MSG_CHECKING(if sys/time.h works with sys/select.h)
2816 AC_CACHE_VAL(cf_cv_sys_time_select,[
2818 #include <sys/types.h>
2819 #ifdef HAVE_SYS_TIME_H
2820 #include <sys/time.h>
2822 #ifdef HAVE_SYS_SELECT_H
2823 #include <sys/select.h>
2825 ],[],[cf_cv_sys_time_select=yes],
2826 [cf_cv_sys_time_select=no])
2828 AC_MSG_RESULT($cf_cv_sys_time_select)
2829 test "$cf_cv_sys_time_select" = yes && AC_DEFINE(HAVE_SYS_TIME_SELECT,1,[Define to 1 if we can include <sys/time.h> with <sys/select.h>])
2831 dnl ---------------------------------------------------------------------------
2832 dnl CF_TERM_HEADER version: 4 updated: 2015/04/15 19:08:48
2834 dnl Look for term.h, which is part of X/Open curses. It defines the interface
2835 dnl to terminfo database. Usually it is in the same include-path as curses.h,
2836 dnl but some packagers change this, breaking various applications.
2837 AC_DEFUN([CF_TERM_HEADER],[
2838 AC_CACHE_CHECK(for terminfo header, cf_cv_term_header,[
2839 case ${cf_cv_ncurses_header} in
2840 (*/ncurses.h|*/ncursesw.h)
2841 cf_term_header=`echo "$cf_cv_ncurses_header" | sed -e 's%ncurses[[^.]]*\.h$%term.h%'`
2844 cf_term_header=term.h
2848 for cf_test in $cf_term_header "ncurses/term.h" "ncursesw/term.h"
2850 AC_TRY_COMPILE([#include <stdio.h>
2851 #include <${cf_cv_ncurses_header:-curses.h}>
2853 ],[int x = auto_left_margin],[
2854 cf_cv_term_header="$cf_test"],[
2855 cf_cv_term_header=unknown
2857 test "$cf_cv_term_header" != unknown && break
2861 # Set definitions to allow ifdef'ing to accommodate subdirectories
2863 case $cf_cv_term_header in
2865 AC_DEFINE(HAVE_TERM_H,1,[Define to 1 if we have term.h])
2869 case $cf_cv_term_header in
2871 AC_DEFINE(HAVE_NCURSES_TERM_H,1,[Define to 1 if we have ncurses/term.h])
2874 AC_DEFINE(HAVE_NCURSESW_TERM_H,1,[Define to 1 if we have ncursesw/term.h])
2878 dnl ---------------------------------------------------------------------------
2879 dnl CF_TOP_BUILDDIR version: 2 updated: 2013/07/27 17:38:32
2881 dnl Define a top_builddir symbol, for applications that need an absolute path.
2882 AC_DEFUN([CF_TOP_BUILDDIR],
2884 top_builddir=ifelse($1,,`pwd`,$1)
2885 AC_SUBST(top_builddir)
2887 dnl ---------------------------------------------------------------------------
2888 dnl CF_TPUTS_PROTO version: 3 updated: 2015/04/17 21:26:14
2890 dnl Check for type of function-pointer passed to tputs. Some old
2891 dnl implementations used functions that had different prototypes, making it
2892 dnl hard to compile portable programs using tputs.
2893 AC_DEFUN([CF_TPUTS_PROTO],[
2894 CF_CURSES_FUNCS(tputs)
2895 if test x$cf_cv_func_tputs = xyes
2898 for cf_arg in int char
2900 for cf_ret in int void
2902 if test $cf_ret = void
2904 cf_return="/* nothing */"
2906 cf_return="return value"
2909 #include <${cf_cv_ncurses_header:-curses.h}>
2910 #include <$cf_cv_term_header>
2912 static $cf_ret outc($cf_arg value) { $cf_return; }
2914 tputs("hello", 0, outc);
2915 ${cf_cv_main_return:-return}(0);
2917 CF_VERBOSE([prototype $cf_ret func($cf_arg value)])
2918 cat >>confdefs.h <<EOF
2919 #define TPUTS_ARG $cf_arg
2920 #define TPUTS_PROTO(func,value) $cf_ret func(TPUTS_ARG value)
2921 #define TPUTS_RETURN(value) $cf_return
2927 test $cf_done = yes && break
2931 dnl ---------------------------------------------------------------------------
2932 dnl CF_TRIM_X_LIBS version: 3 updated: 2015/04/12 15:39:00
2934 dnl Trim extra base X libraries added as a workaround for inconsistent library
2935 dnl dependencies returned by "new" pkg-config files.
2936 AC_DEFUN([CF_TRIM_X_LIBS],[
2937 for cf_trim_lib in Xmu Xt X11
2940 (*-l$cf_trim_lib\ *-l$cf_trim_lib*)
2941 LIBS=`echo "$LIBS " | sed -e 's/ / /g' -e 's%-l'"$cf_trim_lib"' %%' -e 's/ $//'`
2942 CF_VERBOSE(..trimmed $LIBS)
2947 dnl ---------------------------------------------------------------------------
2948 dnl CF_TRY_PKG_CONFIG version: 5 updated: 2013/07/06 21:27:06
2949 dnl -----------------
2950 dnl This is a simple wrapper to use for pkg-config, for libraries which may be
2951 dnl available in that form.
2953 dnl $1 = package name
2954 dnl $2 = extra logic to use, if any, after updating CFLAGS and LIBS
2955 dnl $3 = logic to use if pkg-config does not have the package
2956 AC_DEFUN([CF_TRY_PKG_CONFIG],[
2957 AC_REQUIRE([CF_PKG_CONFIG])
2959 if test "$PKG_CONFIG" != none && "$PKG_CONFIG" --exists $1; then
2960 CF_VERBOSE(found package $1)
2961 cf_pkgconfig_incs="`$PKG_CONFIG --cflags $1 2>/dev/null`"
2962 cf_pkgconfig_libs="`$PKG_CONFIG --libs $1 2>/dev/null`"
2963 CF_VERBOSE(package $1 CFLAGS: $cf_pkgconfig_incs)
2964 CF_VERBOSE(package $1 LIBS: $cf_pkgconfig_libs)
2965 CF_ADD_CFLAGS($cf_pkgconfig_incs)
2966 CF_ADD_LIBS($cf_pkgconfig_libs)
2967 ifelse([$2],,:,[$2])
2971 ifelse([$3],,:,[$3])
2974 dnl ---------------------------------------------------------------------------
2975 dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
2976 dnl -------------------
2977 dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
2978 dnl can define it successfully.
2979 AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
2980 AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
2984 #include <sys/types.h>
2986 #ifndef _XOPEN_SOURCE
2989 [cf_cv_xopen_source=no],
2990 [cf_save="$CPPFLAGS"
2991 CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
2995 #include <sys/types.h>
2997 #ifdef _XOPEN_SOURCE
3000 [cf_cv_xopen_source=no],
3001 [cf_cv_xopen_source=$cf_XOPEN_SOURCE])
3006 if test "$cf_cv_xopen_source" != no ; then
3007 CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
3008 CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
3009 cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
3010 CF_ADD_CFLAGS($cf_temp_xopen_source)
3013 dnl ---------------------------------------------------------------------------
3014 dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
3016 dnl Make an uppercase version of a variable
3017 dnl $1=uppercase($2)
3018 AC_DEFUN([CF_UPPER],
3020 $1=`echo "$2" | sed y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%`
3022 dnl ---------------------------------------------------------------------------
3023 dnl CF_UTF8_LIB version: 8 updated: 2012/10/06 08:57:51
3025 dnl Check for multibyte support, and if not found, utf8 compatibility library
3026 AC_DEFUN([CF_UTF8_LIB],
3028 AC_CACHE_CHECK(for multibyte character support,cf_cv_utf8_lib,[
3029 cf_save_LIBS="$LIBS"
3031 #include <stdlib.h>],[putwc(0,0);],
3032 [cf_cv_utf8_lib=yes],
3034 #include <libutf8.h>],[putwc(0,0);],utf8,
3035 [cf_cv_utf8_lib=add-on],
3036 [cf_cv_utf8_lib=no])
3039 # HAVE_LIBUTF8_H is used by ncurses if curses.h is shared between
3041 if test "$cf_cv_utf8_lib" = "add-on" ; then
3042 AC_DEFINE(HAVE_LIBUTF8_H,1,[Define to 1 if we should include libutf8.h])
3043 CF_ADD_INCDIR($cf_cv_header_path_utf8)
3044 CF_ADD_LIBDIR($cf_cv_library_path_utf8)
3045 CF_ADD_LIBS($cf_cv_library_file_utf8)
3048 dnl ---------------------------------------------------------------------------
3049 dnl CF_VERBOSE version: 3 updated: 2007/07/29 09:55:12
3051 dnl Use AC_VERBOSE w/o the warnings
3052 AC_DEFUN([CF_VERBOSE],
3053 [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG
3056 dnl ---------------------------------------------------------------------------
3057 dnl CF_WCHAR_TYPE version: 4 updated: 2012/10/06 16:39:58
3059 dnl Check if type wide-character type $1 is declared, and if so, which header
3060 dnl file is needed. The second parameter is used to set a shell variable when
3061 dnl the type is not found. The first parameter sets a shell variable for the
3063 AC_DEFUN([CF_WCHAR_TYPE],
3065 # This is needed on Tru64 5.0 to declare $1
3066 AC_CACHE_CHECK(if we must include wchar.h to declare $1,cf_cv_$1,[
3071 #ifdef HAVE_LIBUTF8_H
3072 #include <libutf8.h>
3081 #ifdef HAVE_LIBUTF8_H
3082 #include <libutf8.h>
3086 [cf_cv_$1=unknown])])])
3088 if test "$cf_cv_$1" = yes ; then
3089 AC_DEFINE(NEED_WCHAR_H,1,[Define to 1 if we must include wchar.h])
3094 # if we do not find $1 in either place, use substitution to provide a fallback.
3095 if test "$cf_cv_$1" = unknown ; then
3100 # if we find $1 in either place, use substitution to provide a fallback.
3101 if test "$cf_cv_$1" != unknown ; then
3106 dnl ---------------------------------------------------------------------------
3107 dnl CF_WITH_CURSES_DIR version: 3 updated: 2010/11/20 17:02:38
3108 dnl ------------------
3109 dnl Wrapper for AC_ARG_WITH to specify directory under which to look for curses
3111 AC_DEFUN([CF_WITH_CURSES_DIR],[
3113 AC_MSG_CHECKING(for specific curses-directory)
3114 AC_ARG_WITH(curses-dir,
3115 [ --with-curses-dir=DIR directory in which (n)curses is installed],
3116 [cf_cv_curses_dir=$withval],
3117 [cf_cv_curses_dir=no])
3118 AC_MSG_RESULT($cf_cv_curses_dir)
3120 if ( test -n "$cf_cv_curses_dir" && test "$cf_cv_curses_dir" != "no" )
3122 CF_PATH_SYNTAX(withval)
3123 if test -d "$cf_cv_curses_dir"
3125 CF_ADD_INCDIR($cf_cv_curses_dir/include)
3126 CF_ADD_LIBDIR($cf_cv_curses_dir/lib)
3130 dnl ---------------------------------------------------------------------------
3131 dnl CF_WITH_DBMALLOC version: 7 updated: 2010/06/21 17:26:47
3132 dnl ----------------
3133 dnl Configure-option for dbmalloc. The optional parameter is used to override
3134 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3135 AC_DEFUN([CF_WITH_DBMALLOC],[
3136 CF_NO_LEAKS_OPTION(dbmalloc,
3137 [ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
3140 if test "$with_dbmalloc" = yes ; then
3141 AC_CHECK_HEADER(dbmalloc.h,
3142 [AC_CHECK_LIB(dbmalloc,[debug_malloc]ifelse([$1],,[],[,$1]))])
3145 dnl ---------------------------------------------------------------------------
3146 dnl CF_WITH_DMALLOC version: 7 updated: 2010/06/21 17:26:47
3148 dnl Configure-option for dmalloc. The optional parameter is used to override
3149 dnl the updating of $LIBS, e.g., to avoid conflict with subsequent tests.
3150 AC_DEFUN([CF_WITH_DMALLOC],[
3151 CF_NO_LEAKS_OPTION(dmalloc,
3152 [ --with-dmalloc test: use Gray Watson's dmalloc library],
3155 if test "$with_dmalloc" = yes ; then
3156 AC_CHECK_HEADER(dmalloc.h,
3157 [AC_CHECK_LIB(dmalloc,[dmalloc_debug]ifelse([$1],,[],[,$1]))])
3160 dnl ---------------------------------------------------------------------------
3161 dnl CF_WITH_NCURSES_ETC version: 4 updated: 2015/04/25 20:53:11
3162 dnl -------------------
3163 dnl Use this macro for programs which use any variant of "curses", e.g.,
3164 dnl "ncurses", and "PDCurses". Programs that can use curses and some unrelated
3165 dnl library (such as slang) should use a "--with-screen=XXX" option.
3167 dnl This does not use AC_DEFUN, because that would tell autoconf to run each
3168 dnl of the macros inside this one - before this macro.
3169 define([CF_WITH_NCURSES_ETC],[
3174 AC_MSG_CHECKING(for specified curses library type)
3176 [ --with-screen=XXX use specified curses-libraries],
3177 [cf_cv_screen=$withval],[
3179 AC_ARG_WITH(ncursesw,
3180 [ --with-ncursesw use wide ncurses-libraries],
3181 [cf_cv_screen=ncursesw],[
3183 AC_ARG_WITH(ncurses,
3184 [ --with-ncurses use ncurses-libraries],
3185 [cf_cv_screen=ncurses],[
3187 AC_ARG_WITH(pdcurses,
3188 [ --with-pdcurses compile/link with pdcurses X11 library],
3189 [cf_cv_screen=pdcurses],[
3191 AC_ARG_WITH(curses-colr,
3192 [ --with-curses-colr compile/link with HPUX 10.x color-curses],
3193 [cf_cv_screen=curses_colr],[
3195 AC_ARG_WITH(curses-5lib,
3196 [ --with-curses-5lib compile/link with SunOS 5lib curses],
3197 [cf_cv_screen=curses_5lib])])])])])])
3199 AC_MSG_RESULT($cf_cv_screen)
3201 case $cf_cv_screen in
3207 CF_NCURSES_CONFIG($cf_cv_screen)
3210 CF_NCURSES_CONFIG($cf_cv_screen)
3216 AC_MSG_ERROR(unexpected screen-value: $cf_cv_screen)
3221 dnl ---------------------------------------------------------------------------
3222 dnl CF_WITH_VALGRIND version: 1 updated: 2006/12/14 18:00:21
3223 dnl ----------------
3224 AC_DEFUN([CF_WITH_VALGRIND],[
3225 CF_NO_LEAKS_OPTION(valgrind,
3226 [ --with-valgrind test: use valgrind],
3229 dnl ---------------------------------------------------------------------------
3230 dnl CF_XOPEN_CURSES version: 11 updated: 2011/01/18 18:15:30
3232 dnl Test if we should define X/Open source for curses, needed on Digital Unix
3233 dnl 4.x, to see the extended functions, but breaks on IRIX 6.x.
3235 dnl The getbegyx() check is needed for HPUX, which omits legacy macros such
3236 dnl as getbegy(). The latter is better design, but the former is standard.
3237 AC_DEFUN([CF_XOPEN_CURSES],
3239 AC_REQUIRE([CF_CURSES_CPPFLAGS])dnl
3240 AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[
3243 #include <${cf_cv_ncurses_header:-curses.h}>],[
3244 #if defined(NCURSES_VERSION_PATCH)
3245 #if (NCURSES_VERSION_PATCH < 20100501) && (NCURSES_VERSION_PATCH >= 20100403)
3249 long x = winnstr(stdscr, "", 0);
3251 getbegyx(stdscr, y1, x1)],
3252 [cf_cv_need_xopen_extension=no],
3254 #define _XOPEN_SOURCE_EXTENDED
3256 #include <${cf_cv_ncurses_header:-curses.h}>],[
3257 #ifdef NCURSES_VERSION
3259 int check2 = curs_set((int)sizeof(check));
3261 long x = winnstr(stdscr, "", 0);
3263 getbegyx(stdscr, y1, x1)],
3264 [cf_cv_need_xopen_extension=yes],
3265 [cf_cv_need_xopen_extension=unknown])])])
3266 test $cf_cv_need_xopen_extension = yes && CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED"
3268 dnl ---------------------------------------------------------------------------
3269 dnl CF_XOPEN_SOURCE version: 49 updated: 2015/04/12 15:39:00
3271 dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
3272 dnl or adapt to the vendor's definitions to get equivalent functionality,
3273 dnl without losing the common non-POSIX features.
3276 dnl $1 is the nominal value for _XOPEN_SOURCE
3277 dnl $2 is the nominal value for _POSIX_C_SOURCE
3278 AC_DEFUN([CF_XOPEN_SOURCE],[
3279 AC_REQUIRE([AC_CANONICAL_HOST])
3281 cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
3282 cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
3287 cf_xopen_source="-D_ALL_SOURCE"
3293 cf_xopen_source="-D_APPLE_C_SOURCE"
3296 cf_xopen_source="-D_DARWIN_C_SOURCE"
3299 (freebsd*|dragonfly*)
3300 # 5.x headers associate
3301 # _XOPEN_SOURCE=600 with _POSIX_C_SOURCE=200112L
3302 # _XOPEN_SOURCE=500 with _POSIX_C_SOURCE=199506L
3303 cf_POSIX_C_SOURCE=200112L
3305 cf_xopen_source="-D_BSD_TYPES -D__BSD_VISIBLE -D_POSIX_C_SOURCE=$cf_POSIX_C_SOURCE -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
3308 cf_xopen_source="-D_HPUX_SOURCE -D_XOPEN_SOURCE=500"
3311 cf_xopen_source="-D_HPUX_SOURCE"
3314 cf_xopen_source="-D_SGI_SOURCE"
3317 (linux*|gnu*|mint*|k*bsd*-gnu)
3321 cf_xopen_source="-D_NETBSD_SOURCE" # POSIX.1-2001 features are ifdef'd with this...
3324 # setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
3326 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3329 cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
3332 # setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
3333 cf_xopen_source="-D_BSD_SOURCE"
3337 # setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
3340 cf_xopen_source="-D_OSF_SOURCE"
3343 cf_xopen_source="-D_QNX_SOURCE"
3346 # setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
3349 cf_xopen_source="-D__EXTENSIONS__"
3350 cf_cv_xopen_source=broken
3352 (sysv4.2uw2.*) # Novell/SCO UnixWare 2.x (tested on 2.1.2)
3358 CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
3362 if test -n "$cf_xopen_source" ; then
3363 CF_ADD_CFLAGS($cf_xopen_source,true)
3366 dnl In anything but the default case, we may have system-specific setting
3367 dnl which is still not guaranteed to provide all of the entrypoints that
3368 dnl _XOPEN_SOURCE would yield.
3369 if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
3370 AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
3371 AC_TRY_COMPILE([#include <stdlib.h>],[
3372 #ifndef _XOPEN_SOURCE
3375 [cf_XOPEN_SOURCE_set=yes],
3376 [cf_XOPEN_SOURCE_set=no])
3377 AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
3378 if test $cf_XOPEN_SOURCE_set = yes
3380 AC_TRY_COMPILE([#include <stdlib.h>],[
3381 #if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
3384 [cf_XOPEN_SOURCE_set_ok=yes],
3385 [cf_XOPEN_SOURCE_set_ok=no])
3386 if test $cf_XOPEN_SOURCE_set_ok = no
3388 AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
3395 dnl ---------------------------------------------------------------------------
3396 dnl CF_X_ATHENA version: 23 updated: 2015/04/12 15:39:00
3398 dnl Check for Xaw (Athena) libraries
3400 dnl Sets $cf_x_athena according to the flavor of Xaw which is used.
3401 AC_DEFUN([CF_X_ATHENA],
3403 cf_x_athena=${cf_x_athena:-Xaw}
3405 AC_MSG_CHECKING(if you want to link with Xaw 3d library)
3408 [ --with-Xaw3d link with Xaw 3d library])
3409 if test "$withval" = yes ; then
3416 AC_MSG_CHECKING(if you want to link with Xaw 3d xft library)
3418 AC_ARG_WITH(Xaw3dxft,
3419 [ --with-Xaw3dxft link with Xaw 3d xft library])
3420 if test "$withval" = yes ; then
3421 cf_x_athena=Xaw3dxft
3427 AC_MSG_CHECKING(if you want to link with neXT Athena library)
3430 [ --with-neXtaw link with neXT Athena library])
3431 if test "$withval" = yes ; then
3438 AC_MSG_CHECKING(if you want to link with Athena-Plus library)
3440 AC_ARG_WITH(XawPlus,
3441 [ --with-XawPlus link with Athena-Plus library])
3442 if test "$withval" = yes ; then
3451 if test "$PKG_CONFIG" != none ; then
3453 test "$cf_x_athena" = Xaw && cf_athena_list="xaw8 xaw7 xaw6"
3454 for cf_athena_pkg in \
3457 ${cf_x_athena}-devel \
3459 lib${cf_x_athena}-devel
3461 CF_TRY_PKG_CONFIG($cf_athena_pkg,[
3462 cf_x_athena_lib="$cf_pkgconfig_libs"
3463 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3464 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3468 AC_CACHE_CHECK(for usable $cf_x_athena/Xmu package,cf_cv_xaw_compat,[
3470 #include <X11/Xmu/CharSet.h>
3472 int check = XmuCompareISOLatin1("big", "small")
3473 ],[cf_cv_xaw_compat=yes],[cf_cv_xaw_compat=no])])
3475 if test "$cf_cv_xaw_compat" = no
3477 # workaround for broken ".pc" files...
3478 case "$cf_x_athena_lib" in
3482 CF_VERBOSE(work around broken package)
3484 cf_first_lib=`echo "$cf_save_xmu" | sed -e 's/^[ ][ ]*//' -e 's/ .*//'`
3485 CF_TRY_PKG_CONFIG(xmu,[
3487 CF_ADD_LIB_AFTER($cf_first_lib,$cf_pkgconfig_libs)
3489 CF_ADD_LIB_AFTER($cf_first_lib,-lXmu)
3500 if test -z "$cf_x_athena_lib" ; then
3503 CF_X_ATHENA_CPPFLAGS($cf_x_athena)
3504 CF_X_ATHENA_LIBS($cf_x_athena)
3507 dnl ---------------------------------------------------------------------------
3508 dnl CF_X_ATHENA_CPPFLAGS version: 5 updated: 2010/05/26 17:35:30
3509 dnl --------------------
3510 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3511 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3512 AC_DEFUN([CF_X_ATHENA_CPPFLAGS],
3514 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3517 for cf_path in default \
3518 /usr/contrib/X11R6 \
3519 /usr/contrib/X11R5 \
3523 if test -z "$cf_x_athena_inc" ; then
3525 cf_test=X11/$cf_x_athena_root/SimpleMenu.h
3526 if test $cf_path != default ; then
3527 CPPFLAGS="$cf_save -I$cf_path/include"
3528 AC_MSG_CHECKING(for $cf_test in $cf_path)
3530 AC_MSG_CHECKING(for $cf_test)
3533 #include <X11/Intrinsic.h>
3534 #include <$cf_test>],[],
3537 AC_MSG_RESULT($cf_result)
3538 if test "$cf_result" = yes ; then
3539 cf_x_athena_inc=$cf_path
3547 if test -z "$cf_x_athena_inc" ; then
3549 [Unable to successfully find Athena header files with test program])
3550 elif test "$cf_x_athena_inc" != default ; then
3551 CPPFLAGS="$CPPFLAGS -I$cf_x_athena_inc"
3554 dnl ---------------------------------------------------------------------------
3555 dnl CF_X_ATHENA_LIBS version: 12 updated: 2011/07/17 19:55:02
3556 dnl ----------------
3557 dnl Normally invoked by CF_X_ATHENA, with $1 set to the appropriate flavor of
3558 dnl the Athena widgets, e.g., Xaw, Xaw3d, neXtaw.
3559 AC_DEFUN([CF_X_ATHENA_LIBS],
3560 [AC_REQUIRE([CF_X_TOOLKIT])
3561 cf_x_athena_root=ifelse([$1],,Xaw,[$1])
3564 for cf_path in default \
3565 /usr/contrib/X11R6 \
3566 /usr/contrib/X11R5 \
3571 ${cf_x_athena_root} \
3572 ${cf_x_athena_root}7 \
3573 ${cf_x_athena_root}6
3577 "-l$cf_lib -lXpm -lXmu" \
3578 "-l${cf_lib}_s -lXmu_s"
3580 if test -z "$cf_x_athena_lib" ; then
3582 cf_test=XawSimpleMenuAddGlobalActions
3583 if test $cf_path != default ; then
3584 CF_ADD_LIBS(-L$cf_path/lib $cf_libs)
3585 AC_MSG_CHECKING(for $cf_libs in $cf_path)
3587 CF_ADD_LIBS($cf_libs)
3588 AC_MSG_CHECKING(for $cf_test in $cf_libs)
3591 #include <X11/Intrinsic.h>
3592 #include <X11/$cf_x_athena_root/SimpleMenu.h>
3594 $cf_test((XtAppContext) 0)],
3597 AC_MSG_RESULT($cf_result)
3598 if test "$cf_result" = yes ; then
3599 cf_x_athena_lib="$cf_libs"
3605 test -n "$cf_x_athena_lib" && break
3609 if test -z "$cf_x_athena_lib" ; then
3611 [Unable to successfully link Athena library (-l$cf_x_athena_root) with test program])
3614 CF_UPPER(cf_x_athena_LIBS,HAVE_LIB_$cf_x_athena)
3615 AC_DEFINE_UNQUOTED($cf_x_athena_LIBS)
3617 dnl ---------------------------------------------------------------------------
3618 dnl CF_X_EXT version: 3 updated: 2010/06/02 05:03:05
3620 AC_DEFUN([CF_X_EXT],[
3621 CF_TRY_PKG_CONFIG(Xext,,[
3622 AC_CHECK_LIB(Xext,XextCreateExtension,
3623 [CF_ADD_LIB(Xext)])])
3625 dnl ---------------------------------------------------------------------------
3626 dnl CF_X_TOOLKIT version: 23 updated: 2015/04/12 15:39:00
3628 dnl Check for X Toolkit libraries
3629 AC_DEFUN([CF_X_TOOLKIT],
3631 AC_REQUIRE([AC_PATH_XTRA])
3632 AC_REQUIRE([CF_CHECK_CACHE])
3634 # OSX is schizoid about who owns /usr/X11 (old) versus /opt/X11 (new), and (and
3635 # in some cases has installed dummy files in the former, other cases replaced
3636 # it with a link to the new location). This complicates the configure script.
3637 # Check for that pitfall, and recover using pkg-config
3639 # If none of these are set, the configuration is almost certainly broken.
3640 if test -z "${X_CFLAGS}${X_PRE_LIBS}${X_LIBS}${X_EXTRA_LIBS}"
3642 CF_TRY_PKG_CONFIG(x11,,[AC_MSG_WARN(unable to find X11 library)])
3643 CF_TRY_PKG_CONFIG(ice,,[AC_MSG_WARN(unable to find ICE library)])
3644 CF_TRY_PKG_CONFIG(sm,,[AC_MSG_WARN(unable to find SM library)])
3645 CF_TRY_PKG_CONFIG(xt,,[AC_MSG_WARN(unable to find Xt library)])
3650 CF_TRY_PKG_CONFIG(xt,[
3656 # we have an "xt" package, but it may omit Xt's dependency on X11
3657 AC_CACHE_CHECK(for usable X dependency,cf_cv_xt_x11_compat,[
3659 #include <X11/Xlib.h>
3661 int rc1 = XDrawLine((Display*) 0, (Drawable) 0, (GC) 0, 0, 0, 0, 0);
3662 int rc2 = XClearWindow((Display*) 0, (Window) 0);
3663 int rc3 = XMoveWindow((Display*) 0, (Window) 0, 0, 0);
3664 int rc4 = XMoveResizeWindow((Display*)0, (Window)0, 0, 0, 0, 0);
3665 ],[cf_cv_xt_x11_compat=yes],[cf_cv_xt_x11_compat=no])])
3666 if test "$cf_cv_xt_x11_compat" = no
3668 CF_VERBOSE(work around broken X11 dependency)
3669 # 2010/11/19 - good enough until a working Xt on Xcb is delivered.
3670 CF_TRY_PKG_CONFIG(x11,,[CF_ADD_LIB_AFTER(-lXt,-lX11)])
3675 AC_CACHE_CHECK(for usable X Toolkit package,cf_cv_xt_ice_compat,[
3677 #include <X11/Shell.h>
3678 ],[int num = IceConnectionNumber(0)
3679 ],[cf_cv_xt_ice_compat=yes],[cf_cv_xt_ice_compat=no])])
3681 if test "$cf_cv_xt_ice_compat" = no
3683 # workaround for broken ".pc" files used for X Toolkit.
3684 case "x$X_PRE_LIBS" in
3690 CF_VERBOSE(work around broken ICE dependency)
3691 CF_TRY_PKG_CONFIG(ice,
3692 [CF_TRY_PKG_CONFIG(sm)],
3693 [CF_ADD_LIB_AFTER(-lXt,$X_PRE_LIBS)])
3703 LDFLAGS="$X_LIBS $LDFLAGS"
3704 CF_CHECK_CFLAGS($X_CFLAGS)
3706 AC_CHECK_FUNC(XOpenDisplay,,[
3707 AC_CHECK_LIB(X11,XOpenDisplay,
3709 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3711 AC_CHECK_FUNC(XtAppInitialize,,[
3712 AC_CHECK_LIB(Xt, XtAppInitialize,
3713 [AC_DEFINE(HAVE_LIBXT,1,[Define to 1 if we can compile with the Xt library])
3715 LIBS="-lXt $X_PRE_LIBS $LIBS $X_EXTRA_LIBS"],,
3716 [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
3719 if test $cf_have_X_LIBS = no ; then
3721 [Unable to successfully link X Toolkit library (-lXt) with
3722 test program. You will have to check and add the proper libraries by hand
3726 dnl ---------------------------------------------------------------------------
3727 dnl CF__CURSES_HEAD version: 2 updated: 2010/10/23 15:54:49
3729 dnl Define a reusable chunk which includes <curses.h> and <term.h> when they
3730 dnl are both available.
3731 define([CF__CURSES_HEAD],[
3733 #include <xcurses.h>
3734 char * XCursesProgramName = "test";
3736 #include <${cf_cv_ncurses_header:-curses.h}>
3737 #if defined(NCURSES_VERSION) && defined(HAVE_NCURSESW_TERM_H)
3738 #include <ncursesw/term.h>
3739 #elif defined(NCURSES_VERSION) && defined(HAVE_NCURSES_TERM_H)
3740 #include <ncurses/term.h>
3741 #elif defined(HAVE_TERM_H)